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
|
|
@ -838,21 +838,25 @@ ValueVector Object::ownPropertyKeys(ExecutionState& state)
|
|||
// https://www.ecma-international.org/ecma-262/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver
|
||||
ObjectGetResult Object::get(ExecutionState& state, const ObjectPropertyName& propertyName)
|
||||
{
|
||||
Object* temp = this;
|
||||
auto desc = this->getOwnProperty(state, propertyName);
|
||||
Object* iter = this;
|
||||
|
||||
while (true) {
|
||||
if (!desc.hasValue()) {
|
||||
Object* parent = temp->getPrototypeObject(state);
|
||||
if (!parent) {
|
||||
return ObjectGetResult();
|
||||
}
|
||||
desc = parent->getOwnProperty(state, propertyName);
|
||||
temp = parent;
|
||||
} else {
|
||||
ObjectGetResult desc = iter->getOwnProperty(state, propertyName);
|
||||
if (desc.hasValue()) {
|
||||
return desc;
|
||||
}
|
||||
|
||||
iter = iter->getPrototypeObject(state);
|
||||
|
||||
if (iter == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (UNLIKELY(iter->isProxyObject())) {
|
||||
return iter->get(state, propertyName);
|
||||
}
|
||||
}
|
||||
return desc;
|
||||
return ObjectGetResult();
|
||||
}
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue