<https://webkit.org/b/129673>
Source/JavaScriptCore:
Make jsStringWithWeakOwner() take a StringImpl& instead of a String.
This avoids branches in length() and operator[].
Also call JSString::create() directly instead of jsString() and just
assert that the string length is >1. This way we don't duplicate the
optimizations for empty and single-character strings.
Reviewed by Ryosuke Niwa.
* runtime/JSString.h:
(JSC::jsStringWithWeakOwner):
Source/WebCore:
Tweaked for new jsStringWithWeakOwner signature. This patch removes
36 bytes of code from every wrapper getter that returns a DOMString.
Reviewed by Ryosuke Niwa.
* bindings/js/JSDOMBinding.h:
(WebCore::jsStringWithCache):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165054
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-03-04 Andreas Kling <akling@apple.com>
+
+ Micro-optimize Strings in JS bindings.
+ <https://webkit.org/b/129673>
+
+ Make jsStringWithWeakOwner() take a StringImpl& instead of a String.
+ This avoids branches in length() and operator[].
+
+ Also call JSString::create() directly instead of jsString() and just
+ assert that the string length is >1. This way we don't duplicate the
+ optimizations for empty and single-character strings.
+
+ Reviewed by Ryosuke Niwa.
+
+ * runtime/JSString.h:
+ (JSC::jsStringWithWeakOwner):
+
2014-03-04 Dániel Bátyai <dbatyai.u-szeged@partner.samsung.com>
Implement Number.prototype.clz()
return JSString::create(*vm, s.impl());
}
- inline JSString* jsStringWithWeakOwner(VM* vm, const String& s)
+ inline JSString* jsStringWithWeakOwner(VM& vm, StringImpl& stringImpl)
{
- WeakHandleOwner* jsStringWeakOwner = vm->jsStringWeakOwner.get();
- StringImpl* impl = s.impl();
+ WeakHandleOwner* jsStringWeakOwner = vm.jsStringWeakOwner.get();
- // If this vm is not allowed to weakly own strings just call jsString.
- if (!jsStringWeakOwner || !impl)
- return jsString(vm, s);
+ // Should have picked a VM-global empty or single-character string already.
+ ASSERT(stringImpl.length() > 1);
+
+ // If this VM is not allowed to weakly own strings just make a new JSString.
+ if (!jsStringWeakOwner)
+ return JSString::create(vm, &stringImpl);
// Check for an existing weakly owned JSString.
- if (WeakImpl* weakImpl = impl->weakJSString()) {
+ if (WeakImpl* weakImpl = stringImpl.weakJSString()) {
if (weakImpl->state() == WeakImpl::Live)
return asString(weakImpl->jsValue());
WeakSet::deallocate(weakImpl);
- impl->setWeakJSString(nullptr);
+ stringImpl.setWeakJSString(nullptr);
}
- JSString* string = jsString(vm, s);
- impl->setWeakJSString(WeakSet::allocate(string, jsStringWeakOwner, impl));
+ JSString* string = JSString::create(vm, &stringImpl);
+ stringImpl.setWeakJSString(WeakSet::allocate(string, jsStringWeakOwner, &stringImpl));
return string;
}
+2014-03-04 Andreas Kling <akling@apple.com>
+
+ Micro-optimize Strings in JS bindings.
+ <https://webkit.org/b/129673>
+
+ Tweaked for new jsStringWithWeakOwner signature. This patch removes
+ 36 bytes of code from every wrapper getter that returns a DOMString.
+
+ Reviewed by Ryosuke Niwa.
+
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::jsStringWithCache):
+
2014-03-03 David Kilzer <ddkilzer@apple.com>
SVGPropertyTearOffs should detachChildren before deleting its value.
inline JSC::JSValue jsStringWithCache(JSC::ExecState* exec, const String& s)
{
+ JSC::VM& vm = exec->vm();
+
StringImpl* stringImpl = s.impl();
if (!stringImpl || !stringImpl->length())
- return jsEmptyString(exec);
+ return jsEmptyString(&vm);
if (stringImpl->length() == 1) {
UChar singleCharacter = (*stringImpl)[0u];
- if (singleCharacter <= JSC::maxSingleCharacterString) {
- JSC::VM* vm = &exec->vm();
- return vm->smallStrings.singleCharacterString(static_cast<unsigned char>(singleCharacter));
- }
+ if (singleCharacter <= JSC::maxSingleCharacterString)
+ return vm.smallStrings.singleCharacterString(static_cast<unsigned char>(singleCharacter));
}
- return JSC::jsStringWithWeakOwner(&exec->vm(), s);
+ return JSC::jsStringWithWeakOwner(vm, *stringImpl);
}
inline String propertyNameToString(JSC::PropertyName propertyName)