diff options
author | Michaël Zasso <targos@protonmail.com> | 2019-08-01 08:38:30 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-08-01 12:53:56 +0200 |
commit | 2dcc3665abf57c3607cebffdeeca062f5894885d (patch) | |
tree | 4f560748132edcfb4c22d6f967a7e80d23d7ea2c /deps/v8/src/builtins/builtins-proxy-gen.cc | |
parent | 1ee47d550c6de132f06110aa13eceb7551d643b3 (diff) | |
download | node-new-2dcc3665abf57c3607cebffdeeca062f5894885d.tar.gz |
deps: update V8 to 7.6.303.28
PR-URL: https://github.com/nodejs/node/pull/28016
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Diffstat (limited to 'deps/v8/src/builtins/builtins-proxy-gen.cc')
-rw-r--r-- | deps/v8/src/builtins/builtins-proxy-gen.cc | 289 |
1 files changed, 38 insertions, 251 deletions
diff --git a/deps/v8/src/builtins/builtins-proxy-gen.cc b/deps/v8/src/builtins/builtins-proxy-gen.cc index 825e229451..a1a2f6308f 100644 --- a/deps/v8/src/builtins/builtins-proxy-gen.cc +++ b/deps/v8/src/builtins/builtins-proxy-gen.cc @@ -7,8 +7,8 @@ #include "src/builtins/builtins-utils.h" #include "src/builtins/builtins.h" -#include "src/counters.h" -#include "src/objects-inl.h" +#include "src/logging/counters.h" +#include "src/objects/objects-inl.h" namespace v8 { namespace internal { @@ -262,246 +262,22 @@ TF_BUILTIN(ConstructProxy, ProxiesCodeStubAssembler) { { ThrowTypeError(context, MessageTemplate::kProxyRevoked, "construct"); } } -TF_BUILTIN(ProxyHasProperty, ProxiesCodeStubAssembler) { - Node* context = Parameter(Descriptor::kContext); - Node* proxy = Parameter(Descriptor::kProxy); - Node* name = Parameter(Descriptor::kName); - - CSA_ASSERT(this, IsJSProxy(proxy)); - - PerformStackCheck(CAST(context)); - - // 1. Assert: IsPropertyKey(P) is true. - CSA_ASSERT(this, IsName(name)); - CSA_ASSERT(this, Word32Equal(IsPrivateSymbol(name), Int32Constant(0))); - - Label throw_proxy_handler_revoked(this, Label::kDeferred), - trap_undefined(this), - if_try_get_own_property_bailout(this, Label::kDeferred), - trap_not_callable(this, Label::kDeferred), return_true(this), - return_false(this), check_target_desc(this); - - // 2. Let handler be O.[[ProxyHandler]]. - Node* handler = LoadObjectField(proxy, JSProxy::kHandlerOffset); - - // 3. If handler is null, throw a TypeError exception. - // 4. Assert: Type(handler) is Object. - GotoIfNot(IsJSReceiver(handler), &throw_proxy_handler_revoked); - - // 5. Let target be O.[[ProxyTarget]]. - Node* target = LoadObjectField(proxy, JSProxy::kTargetOffset); - - // 6. Let trap be ? GetMethod(handler, "has"). - // 7. If trap is undefined, then (see 7.a below). - Handle<Name> trap_name = factory()->has_string(); - Node* trap = GetMethod(context, handler, trap_name, &trap_undefined); - - GotoIf(TaggedIsSmi(trap), &trap_not_callable); - GotoIfNot(IsCallable(trap), &trap_not_callable); - - // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, « target, P - // »)). - BranchIfToBooleanIsTrue(CallJS(CodeFactory::Call(isolate()), context, trap, - handler, target, name), - &return_true, &check_target_desc); - - BIND(&check_target_desc); - { - // 9. If booleanTrapResult is false, then (see 9.a. in CheckHasTrapResult). - CheckHasTrapResult(context, target, proxy, name, &return_false, - &if_try_get_own_property_bailout); - } - - BIND(&if_try_get_own_property_bailout); - { - CallRuntime(Runtime::kCheckProxyHasTrap, context, name, target); - Return(FalseConstant()); - } - - BIND(&trap_undefined); - { - // 7.a. Return ? target.[[HasProperty]](P). - TailCallBuiltin(Builtins::kHasProperty, context, target, name); - } - - BIND(&return_false); - Return(FalseConstant()); - - BIND(&return_true); - Return(TrueConstant()); - - BIND(&throw_proxy_handler_revoked); - ThrowTypeError(context, MessageTemplate::kProxyRevoked, "has"); - - BIND(&trap_not_callable); - ThrowTypeError(context, MessageTemplate::kPropertyNotFunction, trap, - StringConstant("has"), proxy); -} - -TF_BUILTIN(ProxyGetProperty, ProxiesCodeStubAssembler) { - Node* context = Parameter(Descriptor::kContext); - Node* proxy = Parameter(Descriptor::kProxy); - Node* name = Parameter(Descriptor::kName); - Node* receiver = Parameter(Descriptor::kReceiverValue); - Node* on_non_existent = Parameter(Descriptor::kOnNonExistent); - - CSA_ASSERT(this, IsJSProxy(proxy)); - - // 1. Assert: IsPropertyKey(P) is true. - CSA_ASSERT(this, TaggedIsNotSmi(name)); - CSA_ASSERT(this, IsName(name)); - CSA_ASSERT(this, Word32Equal(IsPrivateSymbol(name), Int32Constant(0))); - - Label throw_proxy_handler_revoked(this, Label::kDeferred), - trap_undefined(this); - - // 2. Let handler be O.[[ProxyHandler]]. - Node* handler = LoadObjectField(proxy, JSProxy::kHandlerOffset); - - // 3. If handler is null, throw a TypeError exception. - GotoIf(IsNull(handler), &throw_proxy_handler_revoked); - - // 4. Assert: Type(handler) is Object. - CSA_ASSERT(this, IsJSReceiver(handler)); - - // 5. Let target be O.[[ProxyTarget]]. - Node* target = LoadObjectField(proxy, JSProxy::kTargetOffset); - - // 6. Let trap be ? GetMethod(handler, "get"). - // 7. If trap is undefined, then (see 7.a below). - Handle<Name> trap_name = factory()->get_string(); - Node* trap = GetMethod(context, handler, trap_name, &trap_undefined); - - // 8. Let trapResult be ? Call(trap, handler, « target, P, Receiver »). - Node* trap_result = CallJS( - CodeFactory::Call(isolate(), ConvertReceiverMode::kNotNullOrUndefined), - context, trap, handler, target, name, receiver); - - // 9. Let targetDesc be ? target.[[GetOwnProperty]](P). - Label return_result(this); - CheckGetSetTrapResult(context, target, proxy, name, trap_result, - &return_result, JSProxy::kGet); - - BIND(&return_result); - { - // 11. Return trapResult. - Return(trap_result); - } - - BIND(&trap_undefined); - { - // 7.a. Return ? target.[[Get]](P, Receiver). - // TODO(mslekova): Introduce GetPropertyWithReceiver stub - Return(CallRuntime(Runtime::kGetPropertyWithReceiver, context, target, name, - receiver, on_non_existent)); - } - - BIND(&throw_proxy_handler_revoked); - ThrowTypeError(context, MessageTemplate::kProxyRevoked, "get"); -} - -TF_BUILTIN(ProxySetProperty, ProxiesCodeStubAssembler) { - Node* context = Parameter(Descriptor::kContext); - Node* proxy = Parameter(Descriptor::kProxy); - Node* name = Parameter(Descriptor::kName); - Node* value = Parameter(Descriptor::kValue); - Node* receiver = Parameter(Descriptor::kReceiverValue); - - CSA_ASSERT(this, IsJSProxy(proxy)); - - // 1. Assert: IsPropertyKey(P) is true. - CSA_ASSERT(this, TaggedIsNotSmi(name)); - CSA_ASSERT(this, IsName(name)); - - Label throw_proxy_handler_revoked(this, Label::kDeferred), - trap_undefined(this), failure(this, Label::kDeferred), - continue_checks(this), success(this), - private_symbol(this, Label::kDeferred); - - GotoIf(IsPrivateSymbol(name), &private_symbol); - - // 2. Let handler be O.[[ProxyHandler]]. - Node* handler = LoadObjectField(proxy, JSProxy::kHandlerOffset); - - // 3. If handler is null, throw a TypeError exception. - GotoIfNot(IsJSReceiver(handler), &throw_proxy_handler_revoked); - - // 4. Assert: Type(handler) is Object. - CSA_ASSERT(this, IsJSReceiver(handler)); - - // 5. Let target be O.[[ProxyTarget]]. - Node* target = LoadObjectField(proxy, JSProxy::kTargetOffset); - - // 6. Let trap be ? GetMethod(handler, "set"). - // 7. If trap is undefined, then (see 7.a below). - Handle<Name> set_string = factory()->set_string(); - Node* trap = GetMethod(context, handler, set_string, &trap_undefined); - - // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, - // « target, P, V, Receiver »)). - // 9. If booleanTrapResult is false, return false. - BranchIfToBooleanIsTrue( - CallJS(CodeFactory::Call(isolate(), - ConvertReceiverMode::kNotNullOrUndefined), - context, trap, handler, target, name, value, receiver), - &continue_checks, &failure); - - BIND(&continue_checks); - { - // 9. Let targetDesc be ? target.[[GetOwnProperty]](P). - Label return_result(this); - CheckGetSetTrapResult(context, target, proxy, name, value, &success, - JSProxy::kSet); - } - - BIND(&failure); - { - CallRuntime(Runtime::kThrowTypeErrorIfStrict, context, - SmiConstant(MessageTemplate::kProxyTrapReturnedFalsishFor), - HeapConstant(set_string), name); - Goto(&success); - } - - // 12. Return true. - BIND(&success); - Return(value); - - BIND(&private_symbol); - { - Label failure(this); - - CallRuntime(Runtime::kThrowTypeErrorIfStrict, context, - SmiConstant(MessageTemplate::kProxyPrivate)); - Return(UndefinedConstant()); - } - - BIND(&trap_undefined); - { - // 7.a. Return ? target.[[Set]](P, V, Receiver). - CallRuntime(Runtime::kSetPropertyWithReceiver, context, target, name, value, - receiver); - Return(value); - } - - BIND(&throw_proxy_handler_revoked); - ThrowTypeError(context, MessageTemplate::kProxyRevoked, "set"); -} - -void ProxiesCodeStubAssembler::CheckGetSetTrapResult( +Node* ProxiesCodeStubAssembler::CheckGetSetTrapResult( Node* context, Node* target, Node* proxy, Node* name, Node* trap_result, - Label* check_passed, JSProxy::AccessKind access_kind) { + JSProxy::AccessKind access_kind) { Node* map = LoadMap(target); VARIABLE(var_value, MachineRepresentation::kTagged); VARIABLE(var_details, MachineRepresentation::kWord32); VARIABLE(var_raw_value, MachineRepresentation::kTagged); - Label if_found_value(this), check_in_runtime(this, Label::kDeferred); + Label if_found_value(this), check_in_runtime(this, Label::kDeferred), + check_passed(this); GotoIfNot(IsUniqueNameNoIndex(CAST(name)), &check_in_runtime); Node* instance_type = LoadInstanceType(target); TryGetOwnProperty(context, target, target, map, instance_type, name, &if_found_value, &var_value, &var_details, &var_raw_value, - check_passed, &check_in_runtime, kReturnAccessorPair); + &check_passed, &check_in_runtime, kReturnAccessorPair); BIND(&if_found_value); { @@ -513,7 +289,7 @@ void ProxiesCodeStubAssembler::CheckGetSetTrapResult( // false, then: GotoIfNot(IsSetWord32(var_details.value(), PropertyDetails::kAttributesDontDeleteMask), - check_passed); + &check_passed); // If IsDataDescriptor(targetDesc) is true and // targetDesc.[[Writable]] is false, then: @@ -523,11 +299,11 @@ void ProxiesCodeStubAssembler::CheckGetSetTrapResult( { Node* read_only = IsSetWord32(var_details.value(), PropertyDetails::kAttributesReadOnlyMask); - GotoIfNot(read_only, check_passed); + GotoIfNot(read_only, &check_passed); // If SameValue(trapResult, targetDesc.[[Value]]) is false, // throw a TypeError exception. - BranchIfSameValue(trap_result, var_value.value(), check_passed, + BranchIfSameValue(trap_result, var_value.value(), &check_passed, &throw_non_configurable_data); } @@ -545,7 +321,7 @@ void ProxiesCodeStubAssembler::CheckGetSetTrapResult( // defined it's set as null. GotoIf(IsUndefined(getter), &continue_check); GotoIf(IsNull(getter), &continue_check); - Goto(check_passed); + Goto(&check_passed); // 10.b.i. If trapResult is not undefined, throw a TypeError exception. BIND(&continue_check); @@ -558,14 +334,7 @@ void ProxiesCodeStubAssembler::CheckGetSetTrapResult( GotoIf(IsUndefined(setter), &throw_non_configurable_accessor); GotoIf(IsNull(setter), &throw_non_configurable_accessor); } - Goto(check_passed); - } - - BIND(&check_in_runtime); - { - CallRuntime(Runtime::kCheckProxyGetSetTrapResult, context, name, target, - trap_result, SmiConstant(access_kind)); - Return(trap_result); + Goto(&check_passed); } BIND(&throw_non_configurable_data); @@ -588,13 +357,21 @@ void ProxiesCodeStubAssembler::CheckGetSetTrapResult( ThrowTypeError(context, MessageTemplate::kProxySetFrozenAccessor, name); } } + + BIND(&check_in_runtime); + { + CallRuntime(Runtime::kCheckProxyGetSetTrapResult, context, name, target, + trap_result, SmiConstant(access_kind)); + Goto(&check_passed); + } + + BIND(&check_passed); + return trap_result; } } -void ProxiesCodeStubAssembler::CheckHasTrapResult(Node* context, Node* target, - Node* proxy, Node* name, - Label* check_passed, - Label* if_bailout) { +Node* ProxiesCodeStubAssembler::CheckHasTrapResult(Node* context, Node* target, + Node* proxy, Node* name) { Node* target_map = LoadMap(target); VARIABLE(var_value, MachineRepresentation::kTagged); VARIABLE(var_details, MachineRepresentation::kWord32); @@ -602,14 +379,15 @@ void ProxiesCodeStubAssembler::CheckHasTrapResult(Node* context, Node* target, Label if_found_value(this, Label::kDeferred), throw_non_configurable(this, Label::kDeferred), - throw_non_extensible(this, Label::kDeferred); + throw_non_extensible(this, Label::kDeferred), check_passed(this), + check_in_runtime(this, Label::kDeferred); // 9.a. Let targetDesc be ? target.[[GetOwnProperty]](P). - GotoIfNot(IsUniqueNameNoIndex(CAST(name)), if_bailout); + GotoIfNot(IsUniqueNameNoIndex(CAST(name)), &check_in_runtime); Node* instance_type = LoadInstanceType(target); TryGetOwnProperty(context, target, target, target_map, instance_type, name, &if_found_value, &var_value, &var_details, &var_raw_value, - check_passed, if_bailout, kReturnAccessorPair); + &check_passed, &check_in_runtime, kReturnAccessorPair); // 9.b. If targetDesc is not undefined, then (see 9.b.i. below). BIND(&if_found_value); @@ -625,7 +403,7 @@ void ProxiesCodeStubAssembler::CheckHasTrapResult(Node* context, Node* target, // 9.b.iii. If extensibleTarget is false, throw a TypeError exception. GotoIfNot(target_extensible, &throw_non_extensible); - Goto(check_passed); + Goto(&check_passed); } BIND(&throw_non_configurable); @@ -633,6 +411,15 @@ void ProxiesCodeStubAssembler::CheckHasTrapResult(Node* context, Node* target, BIND(&throw_non_extensible); { ThrowTypeError(context, MessageTemplate::kProxyHasNonExtensible, name); } + + BIND(&check_in_runtime); + { + CallRuntime(Runtime::kCheckProxyHasTrapResult, context, name, target); + Goto(&check_passed); + } + + BIND(&check_passed); + return FalseConstant(); } } // namespace internal |