v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
runtime-proxy.cc
Go to the documentation of this file.
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
7#include "src/heap/factory.h"
8#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop.
10
11namespace v8 {
12namespace internal {
13
14RUNTIME_FUNCTION(Runtime_IsJSProxy) {
15 SealHandleScope shs(isolate);
16 DCHECK_EQ(1, args.length());
17 Tagged<Object> obj = args[0];
18 return isolate->heap()->ToBoolean(IsJSProxy(obj));
19}
20
21RUNTIME_FUNCTION(Runtime_JSProxyGetHandler) {
22 SealHandleScope shs(isolate);
23 DCHECK_EQ(1, args.length());
24 auto proxy = Cast<JSProxy>(args[0]);
25 return proxy->handler();
26}
27
28RUNTIME_FUNCTION(Runtime_JSProxyGetTarget) {
29 SealHandleScope shs(isolate);
30 DCHECK_EQ(1, args.length());
31 auto proxy = Cast<JSProxy>(args[0]);
32 return proxy->target();
33}
34
35RUNTIME_FUNCTION(Runtime_GetPropertyWithReceiver) {
36 HandleScope scope(isolate);
37
38 DCHECK_EQ(4, args.length());
40 Handle<Object> key = args.at(1);
42 // TODO(mythria): Remove the on_non_existent parameter to this function. This
43 // should only be called when getting named properties on receiver. This
44 // doesn't handle the global variable loads.
45#ifdef DEBUG
46 int on_non_existent = args.smi_value_at(3);
47 DCHECK_NE(static_cast<OnNonExistent>(on_non_existent),
49#endif
50
51 bool success = false;
52 PropertyKey lookup_key(isolate, key, &success);
53 if (!success) {
54 DCHECK(isolate->has_exception());
55 return ReadOnlyRoots(isolate).exception();
56 }
57 LookupIterator it(isolate, receiver, lookup_key, holder);
58
60}
61
62RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) {
63 HandleScope scope(isolate);
64
65 DCHECK_EQ(4, args.length());
67 Handle<Object> key = args.at(1);
68 DirectHandle<Object> value = args.at(2);
70
71 bool success = false;
72 PropertyKey lookup_key(isolate, key, &success);
73 if (!success) {
74 DCHECK(isolate->has_exception());
75 return ReadOnlyRoots(isolate).exception();
76 }
77 LookupIterator it(isolate, receiver, lookup_key, holder);
80 MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
81 return *isolate->factory()->ToBoolean(result.FromJust());
82}
83
84RUNTIME_FUNCTION(Runtime_CheckProxyGetSetTrapResult) {
85 HandleScope scope(isolate);
86
87 DCHECK_EQ(4, args.length());
88 DirectHandle<Name> name = args.at<Name>(0);
90 DirectHandle<Object> trap_result = args.at(2);
91 int64_t access_kind = NumberToInt64(args[3]);
92
94 isolate, name, target, trap_result,
95 JSProxy::AccessKind(access_kind)));
96}
97
98RUNTIME_FUNCTION(Runtime_CheckProxyHasTrapResult) {
99 HandleScope scope(isolate);
100
101 DCHECK_EQ(2, args.length());
102 DirectHandle<Name> name = args.at<Name>(0);
104
105 Maybe<bool> result = JSProxy::CheckHasTrap(isolate, name, target);
106 if (!result.IsJust()) return ReadOnlyRoots(isolate).exception();
107 return isolate->heap()->ToBoolean(result.FromJust());
108}
109
110RUNTIME_FUNCTION(Runtime_CheckProxyDeleteTrapResult) {
111 HandleScope scope(isolate);
112
113 DCHECK_EQ(2, args.length());
114 DirectHandle<Name> name = args.at<Name>(0);
116
117 Maybe<bool> result = JSProxy::CheckDeleteTrap(isolate, name, target);
118 if (!result.IsJust()) return ReadOnlyRoots(isolate).exception();
119 return isolate->heap()->ToBoolean(result.FromJust());
120}
121
122} // namespace internal
123} // namespace v8
static MaybeHandle< JSAny > CheckGetSetTrapResult(Isolate *isolate, DirectHandle< Name > name, DirectHandle< JSReceiver > target, DirectHandle< Object > trap_result, AccessKind access_kind)
Definition objects.cc:1379
static V8_WARN_UNUSED_RESULT Maybe< bool > CheckHasTrap(Isolate *isolate, DirectHandle< Name > name, DirectHandle< JSReceiver > target)
Definition objects.cc:2929
static V8_WARN_UNUSED_RESULT Maybe< bool > CheckDeleteTrap(Isolate *isolate, DirectHandle< Name > name, DirectHandle< JSReceiver > target)
Definition objects.cc:3054
static V8_WARN_UNUSED_RESULT Maybe< bool > SetSuperProperty(LookupIterator *it, DirectHandle< Object > value, StoreOrigin store_origin, Maybe< ShouldThrow > should_throw=Nothing< ShouldThrow >())
Definition objects.cc:2455
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Object > GetProperty(LookupIterator *it, bool is_global_reference=false)
Definition objects.cc:1248
#define RUNTIME_FUNCTION(Name)
Definition arguments.h:162
#define MAYBE_RETURN(call, value)
Definition isolate.h:408
#define RETURN_RESULT_OR_FAILURE(isolate, call)
Definition isolate.h:264
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
TNode< Object > receiver
ZoneVector< RpoNumber > & result
int64_t NumberToInt64(Tagged< Object > number)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define DCHECK_NE(v1, v2)
Definition logging.h:486
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_EQ(v1, v2)
Definition logging.h:485