Optimize GetByVal when subscript is a rope string.
<https://webkit.org/b/132590>
Use JSString::toIdentifier() in the various GetByVal implementations
to try and avoid allocating extra strings.
Added canUseFastGetOwnProperty() and wrap calls to fastGetOwnProperty()
in that, to avoid calling JSString::value() which always resolves ropes
into new strings and de-optimizes subsequent toIdentifier() calls.
My iMac says ~9% progression on Dromaeo/dom-attr.html
Reviewed by Phil Pizlo.
* dfg/DFGOperations.cpp:
* jit/JITOperations.cpp:
(JSC::getByVal):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::getByVal):
* runtime/JSCell.h:
* runtime/JSCellInlines.h:
(JSC::JSCell::fastGetOwnProperty):
(JSC::JSCell::canUseFastGetOwnProperty):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@168335 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/dfg/DFGOperations.cpp b/Source/JavaScriptCore/dfg/DFGOperations.cpp
index 8c9ab40..99a8725 100644
--- a/Source/JavaScriptCore/dfg/DFGOperations.cpp
+++ b/Source/JavaScriptCore/dfg/DFGOperations.cpp
@@ -295,15 +295,18 @@
if (propertyAsUInt32 == propertyAsDouble)
return getByVal(exec, base, propertyAsUInt32);
} else if (property.isString()) {
- if (JSValue result = base->fastGetOwnProperty(vm, asString(property)->value(exec)))
- return JSValue::encode(result);
+ Structure& structure = *base->structure(vm);
+ if (JSCell::canUseFastGetOwnProperty(structure)) {
+ if (JSValue result = base->fastGetOwnProperty(vm, structure, asString(property)->value(exec)))
+ return JSValue::encode(result);
+ }
}
}
if (isName(property))
return JSValue::encode(baseValue.get(exec, jsCast<NameInstance*>(property.asCell())->privateName()));
- Identifier ident(exec, property.toString(exec)->value(exec));
+ Identifier ident = property.toString(exec)->toIdentifier(exec);
return JSValue::encode(baseValue.get(exec, ident));
}
@@ -322,14 +325,17 @@
if (propertyAsUInt32 == propertyAsDouble)
return getByVal(exec, base, propertyAsUInt32);
} else if (property.isString()) {
- if (JSValue result = base->fastGetOwnProperty(vm, asString(property)->value(exec)))
- return JSValue::encode(result);
+ Structure& structure = *base->structure(vm);
+ if (JSCell::canUseFastGetOwnProperty(structure)) {
+ if (JSValue result = base->fastGetOwnProperty(vm, structure, asString(property)->value(exec)))
+ return JSValue::encode(result);
+ }
}
if (isName(property))
return JSValue::encode(JSValue(base).get(exec, jsCast<NameInstance*>(property.asCell())->privateName()));
- Identifier ident(exec, property.toString(exec)->value(exec));
+ Identifier ident = property.toString(exec)->toIdentifier(exec);
return JSValue::encode(JSValue(base).get(exec, ident));
}