| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 RUNTIME_FUNCTION(Runtime_CreateJSProxy) { | 14 RUNTIME_FUNCTION(Runtime_CreateJSProxy) { |
| 15 HandleScope scope(isolate); | 15 HandleScope scope(isolate); |
| 16 DCHECK(args.length() == 2); | 16 DCHECK(args.length() == 2); |
| 17 CONVERT_ARG_HANDLE_CHECKED(Object, target, 0); | 17 CONVERT_ARG_HANDLE_CHECKED(Object, target, 0); |
| 18 CONVERT_ARG_HANDLE_CHECKED(Object, handler, 1); | 18 CONVERT_ARG_HANDLE_CHECKED(Object, handler, 1); |
| 19 if (!target->IsSpecObject()) { | 19 if (!target->IsSpecObject()) { |
| 20 THROW_NEW_ERROR_RETURN_FAILURE( | 20 THROW_NEW_ERROR_RETURN_FAILURE( |
| 21 isolate, NewTypeError(MessageTemplate::kProxyTargetNonObject)); | 21 isolate, NewTypeError(MessageTemplate::kProxyTargetNonObject)); |
| 22 } | 22 } |
| 23 if (target->IsJSProxy() && !JSProxy::cast(*target)->has_handler()) { | |
| 24 // TODO(cbruni): Use better error message. | |
| 25 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 26 isolate, NewTypeError(MessageTemplate::kProxyTargetNonObject)); | |
| 27 } | |
| 28 if (!handler->IsSpecObject()) { | 23 if (!handler->IsSpecObject()) { |
| 29 THROW_NEW_ERROR_RETURN_FAILURE( | 24 THROW_NEW_ERROR_RETURN_FAILURE( |
| 30 isolate, NewTypeError(MessageTemplate::kProxyHandlerNonObject)); | 25 isolate, NewTypeError(MessageTemplate::kProxyHandlerNonObject)); |
| 31 } | 26 } |
| 32 if (handler->IsJSProxy() && !JSProxy::cast(*handler)->has_handler()) { | 27 if ((target->IsJSProxy() && JSProxy::cast(*target)->IsRevoked()) || |
| 33 // TODO(cbruni): Use better error message. | 28 (handler->IsJSProxy() && JSProxy::cast(*handler)->IsRevoked())) { |
| 34 THROW_NEW_ERROR_RETURN_FAILURE( | 29 THROW_NEW_ERROR_RETURN_FAILURE( |
| 35 isolate, NewTypeError(MessageTemplate::kProxyHandlerNonObject)); | 30 isolate, NewTypeError(MessageTemplate::kProxyHandlerOrTargetRevoked)); |
| 36 } | 31 } |
| 37 return *isolate->factory()->NewJSProxy(Handle<JSReceiver>::cast(target), | 32 return *isolate->factory()->NewJSProxy(Handle<JSReceiver>::cast(target), |
| 38 Handle<JSReceiver>::cast(handler)); | 33 Handle<JSReceiver>::cast(handler)); |
| 39 } | 34 } |
| 40 | 35 |
| 41 | 36 |
| 42 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) { | 37 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) { |
| 43 HandleScope scope(isolate); | 38 HandleScope scope(isolate); |
| 44 DCHECK(args.length() == 5); | 39 DCHECK(args.length() == 5); |
| 45 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0); | 40 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 83 |
| 89 RUNTIME_FUNCTION(Runtime_GetConstructTrap) { | 84 RUNTIME_FUNCTION(Runtime_GetConstructTrap) { |
| 90 SealHandleScope shs(isolate); | 85 SealHandleScope shs(isolate); |
| 91 DCHECK(args.length() == 1); | 86 DCHECK(args.length() == 1); |
| 92 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | 87 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
| 93 return proxy->construct_trap(); | 88 return proxy->construct_trap(); |
| 94 } | 89 } |
| 95 | 90 |
| 96 } // namespace internal | 91 } // namespace internal |
| 97 } // namespace v8 | 92 } // namespace v8 |
| OLD | NEW |