Chromium Code Reviews| Index: src/builtins.cc |
| diff --git a/src/builtins.cc b/src/builtins.cc |
| index 269736b76adff537077fa42792eb622b7bb50e9d..0362460289ad6e2f81651268f149913276b2f5b5 100644 |
| --- a/src/builtins.cc |
| +++ b/src/builtins.cc |
| @@ -1745,6 +1745,46 @@ BUILTIN(SymbolConstructor_ConstructStub) { |
| } |
| +// ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Call]] case. |
| +BUILTIN(ProxyConstructor) { |
| + HandleScope scope(isolate); |
| + THROW_NEW_ERROR_RETURN_FAILURE( |
| + isolate, |
| + NewTypeError(MessageTemplate::kConstructorNotFunction, |
| + isolate->factory()->NewStringFromAsciiChecked("Proxy"))); |
| +} |
| + |
| + |
| +// ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Construct]] case. |
|
Camillo Bruni
2015/12/02 12:02:56
Could you add section "9.5.15 ProxyCreate(target,
Benedikt Meurer
2015/12/02 12:07:20
Moved to dedicated ProxyCreate function.
|
| +BUILTIN(ProxyConstructor_ConstructStub) { |
| + HandleScope scope(isolate); |
| + DCHECK_EQ(3, args.length()); |
| + Handle<Object> target = args.at<Object>(1); |
| + Handle<Object> handler = args.at<Object>(2); |
| + // The ConstructStub is executed in the context of the caller, so we need |
| + // to enter the callee context first before raising an exception. |
| + isolate->set_context(args.target()->context()); |
| + if (!target->IsJSReceiver()) { |
| + THROW_NEW_ERROR_RETURN_FAILURE( |
| + isolate, NewTypeError(MessageTemplate::kProxyTargetNonObject)); |
| + } |
| + if (target->IsJSProxy() && JSProxy::cast(*target)->IsRevoked()) { |
| + THROW_NEW_ERROR_RETURN_FAILURE( |
| + isolate, NewTypeError(MessageTemplate::kProxyHandlerOrTargetRevoked)); |
| + } |
| + if (!handler->IsJSReceiver()) { |
| + THROW_NEW_ERROR_RETURN_FAILURE( |
| + isolate, NewTypeError(MessageTemplate::kProxyHandlerNonObject)); |
| + } |
| + if (handler->IsJSProxy() && JSProxy::cast(*handler)->IsRevoked()) { |
| + THROW_NEW_ERROR_RETURN_FAILURE( |
| + isolate, NewTypeError(MessageTemplate::kProxyHandlerOrTargetRevoked)); |
| + } |
| + return *isolate->factory()->NewJSProxy(Handle<JSReceiver>::cast(target), |
| + Handle<JSReceiver>::cast(handler)); |
| +} |
| + |
| + |
| // ----------------------------------------------------------------------------- |
| // Throwers for restricted function properties and strict arguments object |
| // properties |