Line data Source code
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/runtime/runtime-utils.h"
6 :
7 : #include "src/arguments.h"
8 : #include "src/elements.h"
9 : #include "src/factory.h"
10 : #include "src/isolate-inl.h"
11 : #include "src/objects-inl.h"
12 :
13 : namespace v8 {
14 : namespace internal {
15 :
16 :
17 0 : RUNTIME_FUNCTION(Runtime_IsJSProxy) {
18 : SealHandleScope shs(isolate);
19 : DCHECK_EQ(1, args.length());
20 0 : CONVERT_ARG_CHECKED(Object, obj, 0);
21 0 : return isolate->heap()->ToBoolean(obj->IsJSProxy());
22 : }
23 :
24 :
25 0 : RUNTIME_FUNCTION(Runtime_JSProxyGetHandler) {
26 : SealHandleScope shs(isolate);
27 : DCHECK_EQ(1, args.length());
28 0 : CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
29 0 : return proxy->handler();
30 : }
31 :
32 :
33 0 : RUNTIME_FUNCTION(Runtime_JSProxyGetTarget) {
34 : SealHandleScope shs(isolate);
35 : DCHECK_EQ(1, args.length());
36 0 : CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
37 0 : return proxy->target();
38 : }
39 :
40 :
41 270 : RUNTIME_FUNCTION(Runtime_JSProxyRevoke) {
42 135 : HandleScope scope(isolate);
43 : DCHECK_EQ(1, args.length());
44 270 : CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0);
45 135 : JSProxy::Revoke(proxy);
46 135 : return isolate->heap()->undefined_value();
47 : }
48 :
49 6568 : RUNTIME_FUNCTION(Runtime_GetPropertyWithReceiver) {
50 3284 : HandleScope scope(isolate);
51 :
52 : DCHECK_EQ(3, args.length());
53 6568 : CONVERT_ARG_HANDLE_CHECKED(JSReceiver, holder, 0);
54 3284 : CONVERT_ARG_HANDLE_CHECKED(Object, name, 1);
55 3284 : CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 2);
56 :
57 : bool success;
58 : LookupIterator it = LookupIterator::PropertyOrElement(isolate, receiver, name,
59 3284 : &success, holder);
60 3284 : if (!success) {
61 : DCHECK(isolate->has_pending_exception());
62 10 : return isolate->heap()->exception();
63 : }
64 9832 : RETURN_RESULT_OR_FAILURE(isolate, Object::GetProperty(&it));
65 : }
66 :
67 1064 : RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) {
68 532 : HandleScope scope(isolate);
69 :
70 : DCHECK_EQ(5, args.length());
71 1064 : CONVERT_ARG_HANDLE_CHECKED(JSReceiver, holder, 0);
72 532 : CONVERT_ARG_HANDLE_CHECKED(Object, name, 1);
73 532 : CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
74 532 : CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 3);
75 1064 : CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 4);
76 :
77 : bool success;
78 : LookupIterator it = LookupIterator::PropertyOrElement(isolate, receiver, name,
79 532 : &success, holder);
80 :
81 : Maybe<bool> result = Object::SetSuperProperty(
82 532 : &it, value, language_mode, Object::MAY_BE_STORE_FROM_KEYED);
83 532 : MAYBE_RETURN(result, isolate->heap()->exception());
84 200 : return *isolate->factory()->ToBoolean(result.FromJust());
85 : }
86 :
87 200 : RUNTIME_FUNCTION(Runtime_CheckProxyGetSetTrapResult) {
88 100 : HandleScope scope(isolate);
89 :
90 : DCHECK_EQ(4, args.length());
91 200 : CONVERT_ARG_HANDLE_CHECKED(Name, name, 0);
92 200 : CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 1);
93 100 : CONVERT_ARG_HANDLE_CHECKED(Object, trap_result, 2);
94 200 : CONVERT_NUMBER_CHECKED(int64_t, access_kind, Int64, args[3]);
95 :
96 200 : RETURN_RESULT_OR_FAILURE(isolate, JSProxy::CheckGetSetTrapResult(
97 : isolate, name, target, trap_result,
98 100 : JSProxy::AccessKind(access_kind)));
99 : }
100 :
101 20 : RUNTIME_FUNCTION(Runtime_CheckProxyHasTrap) {
102 10 : HandleScope scope(isolate);
103 :
104 : DCHECK_EQ(2, args.length());
105 20 : CONVERT_ARG_HANDLE_CHECKED(Name, name, 0);
106 20 : CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 1);
107 :
108 10 : Maybe<bool> result = JSProxy::CheckHasTrap(isolate, name, target);
109 10 : if (!result.IsJust()) return isolate->heap()->exception();
110 0 : return isolate->heap()->ToBoolean(result.FromJust());
111 : }
112 :
113 : } // namespace internal
114 : } // namespace v8
|