<https://webkit.org/b/134635>
Source/JavaScriptCore:
Also moved the whole thing from WebCore to JavaScriptCore since it
makes more sense here, and inline the lightweight checks, leaving only
the hashmap stuff out of line.
Reviewed by Darin Adler.
* runtime/JSString.cpp:
(JSC::jsStringWithCacheSlowCase):
* runtime/JSString.h:
(JSC::jsStringWithCache):
* runtime/VM.h:
Source/WebCore:
Reviewed by Darin Adler.
* WebCore.exp.in:
* bindings/js/JSDOMBinding.cpp:
(WebCore::jsStringWithCache): Deleted.
* bindings/js/JSDOMBinding.h:
(WebCore::JSValueTraits<String>::arrayJSValue):
(WebCore::jsStringWithCache): Deleted.
* bridge/c/c_utility.cpp:
(JSC::Bindings::convertNPVariantToValue):
* loader/cache/CachedResourceHandle.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170818
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-07-04 Andreas Kling <akling@apple.com>
+
+ Fast path for jsStringWithCache() when asked for the same string repeatedly.
+ <https://webkit.org/b/134635>
+
+ Also moved the whole thing from WebCore to JavaScriptCore since it
+ makes more sense here, and inline the lightweight checks, leaving only
+ the hashmap stuff out of line.
+
+ Reviewed by Darin Adler.
+
+ * runtime/JSString.cpp:
+ (JSC::jsStringWithCacheSlowCase):
+ * runtime/JSString.h:
+ (JSC::jsStringWithCache):
+ * runtime/VM.h:
+
2014-07-03 Daniel Bates <dabates@apple.com>
Add WTF::move()
return false;
}
+JSString* jsStringWithCacheSlowCase(VM& vm, StringImpl& stringImpl)
+{
+ auto addResult = vm.stringCache.add(&stringImpl, nullptr);
+ if (addResult.isNewEntry)
+ addResult.iterator->value = jsString(&vm, String(stringImpl));
+ vm.lastCachedString = addResult.iterator->value.get();
+ return vm.lastCachedString.get();
+}
+
} // namespace JSC
inline JSString* jsNontrivialString(ExecState* exec, const String& s) { return jsNontrivialString(&exec->vm(), s); }
inline JSString* jsOwnedString(ExecState* exec, const String& s) { return jsOwnedString(&exec->vm(), s); }
+ JS_EXPORT_PRIVATE JSString* jsStringWithCacheSlowCase(VM&, StringImpl&);
+
+ ALWAYS_INLINE JSString* jsStringWithCache(ExecState* exec, const String& s)
+ {
+ VM& vm = exec->vm();
+ StringImpl* stringImpl = s.impl();
+ if (!stringImpl || !stringImpl->length())
+ return jsEmptyString(&vm);
+
+ if (stringImpl->length() == 1) {
+ UChar singleCharacter = (*stringImpl)[0u];
+ if (singleCharacter <= maxSingleCharacterString)
+ return vm.smallStrings.singleCharacterString(static_cast<unsigned char>(singleCharacter));
+ }
+
+ if (JSString* lastCachedString = vm.lastCachedString.get()) {
+ if (lastCachedString->tryGetValueImpl() == stringImpl)
+ return lastCachedString;
+ }
+
+ return jsStringWithCacheSlowCase(vm, *stringImpl);
+ }
+
+ ALWAYS_INLINE JSString* jsStringWithCache(ExecState* exec, const AtomicString& s)
+ {
+ return jsStringWithCache(exec, s.string());
+ }
+
ALWAYS_INLINE bool JSString::getStringPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
if (propertyName == exec->propertyNames().length) {
DateInstanceCache dateInstanceCache;
WTF::SimpleStats machineCodeBytesPerBytecodeWordForBaselineJIT;
WeakGCMap<StringImpl*, JSString, PtrHash<StringImpl*>> stringCache;
+ Weak<JSString> lastCachedString;
AtomicStringTable* atomicStringTable() const { return m_atomicStringTable; }
+2014-07-04 Andreas Kling <akling@apple.com>
+
+ Fast path for jsStringWithCache() when asked for the same string repeatedly.
+ <https://webkit.org/b/134635>
+
+ Reviewed by Darin Adler.
+
+ * WebCore.exp.in:
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::jsStringWithCache): Deleted.
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::JSValueTraits<String>::arrayJSValue):
+ (WebCore::jsStringWithCache): Deleted.
+ * bridge/c/c_utility.cpp:
+ (JSC::Bindings::convertNPVariantToValue):
+ * loader/cache/CachedResourceHandle.h:
+
2014-07-04 Zalan Bujtas <zalan@apple.com>
Subpixel rendering: ebay.com rotating billboard on the main page has cut off buttons.
__ZN7WebCore17SubresourceLoader6createEPNS_5FrameEPNS_14CachedResourceERKNS_15ResourceRequestERKNS_21ResourceLoaderOptionsE
__ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE
__ZN7WebCore17encodeForFileNameERKN3WTF6StringE
-__ZN7WebCore17jsStringWithCacheEPN3JSC9ExecStateERKN3WTF6StringE
__ZN7WebCore17languageDidChangeEv
__ZN7WebCore17openTemporaryFileERKN3WTF6StringERi
__ZN7WebCore17sRGBColorSpaceRefEv
return DOMObjectHashTableMap::mapFor(vm).get(staticTable);
}
-JSC::JSValue jsStringWithCache(JSC::ExecState* exec, const String& s)
-{
- JSC::VM& vm = exec->vm();
- StringImpl* stringImpl = s.impl();
- if (!stringImpl || !stringImpl->length())
- return jsEmptyString(&vm);
-
- if (stringImpl->length() == 1) {
- UChar singleCharacter = (*stringImpl)[0u];
- if (singleCharacter <= JSC::maxSingleCharacterString)
- return vm.smallStrings.singleCharacterString(static_cast<unsigned char>(singleCharacter));
- }
-
- auto addResult = vm.stringCache.add(stringImpl, nullptr);
- if (addResult.isNewEntry)
- addResult.iterator->value = JSC::jsString(&vm, String(stringImpl));
- return JSC::JSValue(addResult.iterator->value.get());
-}
-
JSValue jsStringOrNull(ExecState* exec, const String& s)
{
if (s.isNull())
// Convert a DOM implementation exception code into a JavaScript exception in the execution state.
void setDOMException(JSC::ExecState*, ExceptionCode);
-JSC::JSValue jsStringWithCache(JSC::ExecState*, const String&);
JSC::JSValue jsString(JSC::ExecState*, const URL&); // empty if the URL is null
-inline JSC::JSValue jsStringWithCache(JSC::ExecState* exec, const AtomicString& s)
-{
- return jsStringWithCache(exec, s.string());
-}
JSC::JSValue jsStringOrNull(JSC::ExecState*, const String&); // null if the string is null
JSC::JSValue jsStringOrNull(JSC::ExecState*, const URL&); // null if the URL is null
template<> struct JSValueTraits<String> {
static JSC::JSValue arrayJSValue(JSC::ExecState* exec, JSDOMGlobalObject*, const String& value)
{
- return jsStringWithCache(exec, value);
+ return JSC::jsStringWithCache(exec, value);
}
};
if (type == NPVariantType_Double)
return jsNumber(NPVARIANT_TO_DOUBLE(*variant));
if (type == NPVariantType_String)
- return WebCore::jsStringWithCache(exec, convertNPStringToUTF16(&variant->value.stringValue));
+ return jsStringWithCache(exec, convertNPStringToUTF16(&variant->value.stringValue));
if (type == NPVariantType_Object) {
NPObject* obj = variant->value.objectValue;
symbolWithPointer(?isActiveInsertionPoint@WebCore@@YA_NPBVNode@1@@Z, ?isActiveInsertionPoint@WebCore@@YA_NPEBVNode@1@@Z)
symbolWithPointer(?isPreloaded@CachedResourceLoader@WebCore@@QBE_NABVString@WTF@@@Z, ?isPreloaded@CachedResourceLoader@WebCore@@QEBA_NAEBVString@WTF@@@Z)
symbolWithPointer(?jsArray@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@PAVJSDOMGlobalObject@1@V?$PassRefPtr@VDOMStringList@WebCore@@@WTF@@@Z, ?jsArray@WebCore@@YA?AVJSValue@JSC@@PEAVExecState@3@PEAVJSDOMGlobalObject@1@V?$PassRefPtr@VDOMStringList@WebCore@@@WTF@@@Z)
- symbolWithPointer(?jsStringWithCache@WebCore@@YA?AVJSValue@JSC@@PAVExecState@3@ABVString@WTF@@@Z, ?jsStringWithCache@WebCore@@YA?AVJSValue@JSC@@PEAVExecState@3@AEBVString@WTF@@@Z)
symbolWithPointer(?lastChangeWasUserEdit@HTMLTextFormControlElement@WebCore@@QBE_NXZ, ?lastChangeWasUserEdit@HTMLTextFormControlElement@WebCore@@QEBA_NXZ)
symbolWithPointer(?synchronousScrollingReasonsAsText@Page@WebCore@@QAE?AVString@WTF@@XZ, ?synchronousScrollingReasonsAsText@Page@WebCore@@QEAA?AVString@WTF@@XZ)
symbolWithPointer(?markerTextForListItem@WebCore@@YA?AVString@WTF@@PAVElement@1@@Z, ?markerTextForListItem@WebCore@@YA?AVString@WTF@@PEAVElement@1@@Z)