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.
7 #include "src/arguments.h"
8 #include "src/runtime/runtime-utils.h"
13 RUNTIME_FUNCTION(Runtime_CreateJSProxy) {
14 HandleScope scope(isolate);
15 DCHECK(args.length() == 2);
16 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0);
17 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
18 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value();
19 return *isolate->factory()->NewJSProxy(handler, prototype);
23 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) {
24 HandleScope scope(isolate);
25 DCHECK(args.length() == 4);
26 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0);
27 CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1);
28 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy());
29 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2);
30 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3);
31 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value();
32 return *isolate->factory()->NewJSFunctionProxy(handler, call_trap,
33 construct_trap, prototype);
37 RUNTIME_FUNCTION(Runtime_IsJSProxy) {
38 SealHandleScope shs(isolate);
39 DCHECK(args.length() == 1);
40 CONVERT_ARG_CHECKED(Object, obj, 0);
41 return isolate->heap()->ToBoolean(obj->IsJSProxy());
45 RUNTIME_FUNCTION(Runtime_IsJSFunctionProxy) {
46 SealHandleScope shs(isolate);
47 DCHECK(args.length() == 1);
48 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
49 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy());
53 RUNTIME_FUNCTION(Runtime_GetHandler) {
54 SealHandleScope shs(isolate);
55 DCHECK(args.length() == 1);
56 CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
57 return proxy->handler();
61 RUNTIME_FUNCTION(Runtime_GetCallTrap) {
62 SealHandleScope shs(isolate);
63 DCHECK(args.length() == 1);
64 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
65 return proxy->call_trap();
69 RUNTIME_FUNCTION(Runtime_GetConstructTrap) {
70 SealHandleScope shs(isolate);
71 DCHECK(args.length() == 1);
72 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
73 return proxy->construct_trap();
77 RUNTIME_FUNCTION(Runtime_Fix) {
78 HandleScope scope(isolate);
79 DCHECK(args.length() == 1);
80 CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0);
82 return isolate->heap()->undefined_value();
85 } // namespace v8::internal