mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Add fast paths for hasProperty internal method (#407)
Also the Object.[[Get]] method is modified to follow the standard requirements without recursion. Signed-off-by: Robert Fancsik <frobert@inf.u-szeged.hu>
This commit is contained in:
parent
387a30267c
commit
1df4dcd1a8
10 changed files with 86 additions and 11 deletions
|
|
@ -185,6 +185,27 @@ static Value builtinEval(ExecutionState& state, Value thisValue, size_t argc, Va
|
|||
return fn->m_globalObject->eval(state, argv[0]);
|
||||
}
|
||||
|
||||
ObjectHasPropertyResult GlobalObject::hasProperty(ExecutionState& state, const ObjectPropertyName& P) ESCARGOT_OBJECT_SUBCLASS_MUST_REDEFINE
|
||||
{
|
||||
ObjectHasPropertyResult hasResult = Object::hasProperty(state, P);
|
||||
if (!hasResult.hasProperty() && UNLIKELY((bool)state.context()->virtualIdentifierCallback())) {
|
||||
Object* target = getPrototypeObject(state);
|
||||
while (target) {
|
||||
ObjectHasPropertyResult targetHasProperty = target->hasProperty(state, P);
|
||||
if (targetHasProperty.hasProperty()) {
|
||||
return hasResult;
|
||||
}
|
||||
target = target->getPrototypeObject(state);
|
||||
}
|
||||
Value virtialIdResult = state.context()->virtualIdentifierCallback()(state, P.toPlainValue(state));
|
||||
if (!virtialIdResult.isEmpty()) {
|
||||
return ObjectHasPropertyResult(ObjectGetResult(virtialIdResult, true, true, true));
|
||||
}
|
||||
}
|
||||
|
||||
return hasResult;
|
||||
}
|
||||
|
||||
ObjectGetResult GlobalObject::getOwnProperty(ExecutionState& state, const ObjectPropertyName& P) ESCARGOT_OBJECT_SUBCLASS_MUST_REDEFINE
|
||||
{
|
||||
ObjectGetResult r = Object::getOwnProperty(state, P);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue