| 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_CreateJSFunctionProxy) { | |
| 15 HandleScope scope(isolate); | |
| 16 DCHECK(args.length() == 5); | |
| 17 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0); | |
| 18 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 1); | |
| 19 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, call_trap, 2); | |
| 20 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); | |
| 21 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 3); | |
| 22 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 4); | |
| 23 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); | |
| 24 return *isolate->factory()->NewJSFunctionProxy(target, handler, call_trap, | |
| 25 construct_trap, prototype); | |
| 26 } | |
| 27 | 14 |
| 28 | 15 |
| 29 RUNTIME_FUNCTION(Runtime_IsJSProxy) { | 16 RUNTIME_FUNCTION(Runtime_IsJSProxy) { |
| 30 SealHandleScope shs(isolate); | 17 SealHandleScope shs(isolate); |
| 31 DCHECK(args.length() == 1); | 18 DCHECK(args.length() == 1); |
| 32 CONVERT_ARG_CHECKED(Object, obj, 0); | 19 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 33 return isolate->heap()->ToBoolean(obj->IsJSProxy()); | 20 return isolate->heap()->ToBoolean(obj->IsJSProxy()); |
| 34 } | 21 } |
| 35 | 22 |
| 36 | 23 |
| 37 RUNTIME_FUNCTION(Runtime_IsJSFunctionProxy) { | |
| 38 SealHandleScope shs(isolate); | |
| 39 DCHECK(args.length() == 1); | |
| 40 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | |
| 41 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); | |
| 42 } | |
| 43 | |
| 44 | |
| 45 RUNTIME_FUNCTION(Runtime_GetHandler) { | 24 RUNTIME_FUNCTION(Runtime_GetHandler) { |
| 46 SealHandleScope shs(isolate); | 25 SealHandleScope shs(isolate); |
| 47 DCHECK(args.length() == 1); | 26 DCHECK(args.length() == 1); |
| 48 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); | 27 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); |
| 49 return proxy->handler(); | 28 return proxy->handler(); |
| 50 } | 29 } |
| 51 | 30 |
| 52 | 31 |
| 53 RUNTIME_FUNCTION(Runtime_GetCallTrap) { | |
| 54 SealHandleScope shs(isolate); | |
| 55 DCHECK(args.length() == 1); | |
| 56 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | |
| 57 return proxy->call_trap(); | |
| 58 } | |
| 59 | |
| 60 | |
| 61 RUNTIME_FUNCTION(Runtime_GetConstructTrap) { | |
| 62 SealHandleScope shs(isolate); | |
| 63 DCHECK(args.length() == 1); | |
| 64 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | |
| 65 return proxy->construct_trap(); | |
| 66 } | |
| 67 | |
| 68 } // namespace internal | 32 } // namespace internal |
| 69 } // namespace v8 | 33 } // namespace v8 |
| OLD | NEW |