OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/v8.h" |
| 6 |
| 7 #include "src/arguments.h" |
| 8 #include "src/runtime/runtime.h" |
| 9 #include "src/runtime/runtime-utils.h" |
| 10 |
| 11 namespace v8 { |
| 12 namespace internal { |
| 13 |
| 14 RUNTIME_FUNCTION(Runtime_CreateJSProxy) { |
| 15 HandleScope scope(isolate); |
| 16 DCHECK(args.length() == 2); |
| 17 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); |
| 18 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
| 19 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); |
| 20 return *isolate->factory()->NewJSProxy(handler, prototype); |
| 21 } |
| 22 |
| 23 |
| 24 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) { |
| 25 HandleScope scope(isolate); |
| 26 DCHECK(args.length() == 4); |
| 27 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); |
| 28 CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1); |
| 29 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); |
| 30 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2); |
| 31 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3); |
| 32 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); |
| 33 return *isolate->factory()->NewJSFunctionProxy(handler, call_trap, |
| 34 construct_trap, prototype); |
| 35 } |
| 36 |
| 37 |
| 38 RUNTIME_FUNCTION(Runtime_IsJSProxy) { |
| 39 SealHandleScope shs(isolate); |
| 40 DCHECK(args.length() == 1); |
| 41 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
| 42 return isolate->heap()->ToBoolean(obj->IsJSProxy()); |
| 43 } |
| 44 |
| 45 |
| 46 RUNTIME_FUNCTION(Runtime_IsJSFunctionProxy) { |
| 47 SealHandleScope shs(isolate); |
| 48 DCHECK(args.length() == 1); |
| 49 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
| 50 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); |
| 51 } |
| 52 |
| 53 |
| 54 RUNTIME_FUNCTION(Runtime_GetHandler) { |
| 55 SealHandleScope shs(isolate); |
| 56 DCHECK(args.length() == 1); |
| 57 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); |
| 58 return proxy->handler(); |
| 59 } |
| 60 |
| 61 |
| 62 RUNTIME_FUNCTION(Runtime_GetCallTrap) { |
| 63 SealHandleScope shs(isolate); |
| 64 DCHECK(args.length() == 1); |
| 65 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
| 66 return proxy->call_trap(); |
| 67 } |
| 68 |
| 69 |
| 70 RUNTIME_FUNCTION(Runtime_GetConstructTrap) { |
| 71 SealHandleScope shs(isolate); |
| 72 DCHECK(args.length() == 1); |
| 73 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
| 74 return proxy->construct_trap(); |
| 75 } |
| 76 |
| 77 |
| 78 RUNTIME_FUNCTION(Runtime_Fix) { |
| 79 HandleScope scope(isolate); |
| 80 DCHECK(args.length() == 1); |
| 81 CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0); |
| 82 JSProxy::Fix(proxy); |
| 83 return isolate->heap()->undefined_value(); |
| 84 } |
| 85 } |
| 86 } // namespace v8::internal |
OLD | NEW |