v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-proxy.h
Go to the documentation of this file.
1// Copyright 2018 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#ifndef V8_OBJECTS_JS_PROXY_H_
6#define V8_OBJECTS_JS_PROXY_H_
7
10#include "torque-generated/builtin-definitions.h"
11
12// Has to be the last include (doesn't have include guards):
14
15namespace v8 {
16namespace internal {
17
18class KeyAccumulator;
19
20#include "torque-generated/src/objects/js-proxy-tq.inc"
21
22// The JSProxy describes ECMAScript Harmony proxies
23class JSProxy : public TorqueGeneratedJSProxy<JSProxy, JSReceiver> {
24 public:
27
28 V8_INLINE bool IsRevoked() const;
29 static void Revoke(DirectHandle<JSProxy> proxy);
30
31 // ES6 9.5.1
34
35 // ES6 9.5.2
38 bool from_javascript, ShouldThrow should_throw);
39 // ES6 9.5.3
42
43 // ES6, #sec-isarray. NOT to be confused with %_IsArray.
45
46 // ES6 9.5.4 (when passed kDontThrow)
48 DirectHandle<JSProxy> proxy, ShouldThrow should_throw);
49
50 // ES6 9.5.5
53 PropertyDescriptor* desc);
54
55 // ES6 9.5.6
58 PropertyDescriptor* desc, Maybe<ShouldThrow> should_throw);
59
60 // ES6 9.5.7
63
64 // This function never returns false.
65 // It returns either true or throws.
67 Isolate* isolate, DirectHandle<Name> name,
69
70 // ES6 9.5.10
72 Isolate* isolate, DirectHandle<Name> name,
74
75 // ES6 9.5.8
78 DirectHandle<JSAny> receiver, bool* was_found);
79
80 enum AccessKind { kGet, kSet };
81
83 Isolate* isolate, DirectHandle<Name> name,
85 AccessKind access_kind);
86
87 // ES6 9.5.9
91 Maybe<ShouldThrow> should_throw);
92
93 // ES6 9.5.10 (when passed LanguageMode::kSloppy)
96 LanguageMode language_mode);
97
99 LookupIterator* it);
100
101 // Dispatched behavior.
103
104 static const int kMaxIterationLimit = 100 * 1024;
105
106 // kTargetOffset aliases with the elements of JSObject. The fact that
107 // JSProxy::target is a Javascript value which cannot be confused with an
108 // elements backing store is exploited by loading from this offset from an
109 // unknown JSReceiver.
110 static_assert(static_cast<int>(JSObject::kElementsOffset) ==
111 static_cast<int>(JSProxy::kTargetOffset));
112
114 FixedBodyDescriptor<JSReceiver::kPropertiesOrHashOffset, kSize, kSize>;
115
116 static Maybe<bool> SetPrivateSymbol(Isolate* isolate,
117 DirectHandle<JSProxy> proxy,
118 DirectHandle<Symbol> private_name,
119 PropertyDescriptor* desc,
120 Maybe<ShouldThrow> should_throw);
121
123};
124
125// JSProxyRevocableResult is just a JSObject with a specific initial map.
126// This initial map adds in-object properties for "proxy" and "revoke".
127// See https://tc39.github.io/ecma262/#sec-proxy.revocable
129 : public TorqueGeneratedJSProxyRevocableResult<JSProxyRevocableResult,
130 JSObject> {
131 public:
132 // Indices of in-object properties.
133 static const int kProxyIndex = 0;
134 static const int kRevokeIndex = 1;
135
136 private:
138};
139
140} // namespace internal
141} // namespace v8
142
144
145#endif // V8_OBJECTS_JS_PROXY_H_
DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxyRevocableResult)
static V8_WARN_UNUSED_RESULT Maybe< bool > HasProperty(Isolate *isolate, DirectHandle< JSProxy > proxy, DirectHandle< Name > name)
Definition objects.cc:2885
static V8_WARN_UNUSED_RESULT Maybe< bool > IsArray(DirectHandle< JSProxy > proxy)
Definition objects.cc:2864
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSProxy > New(Isolate *isolate, DirectHandle< Object >, DirectHandle< Object >)
Definition objects.cc:3083
static V8_WARN_UNUSED_RESULT MaybeHandle< JSAny > GetProperty(Isolate *isolate, DirectHandle< JSProxy > proxy, DirectHandle< Name > name, DirectHandle< JSAny > receiver, bool *was_found)
Definition objects.cc:1326
static void Revoke(DirectHandle< JSProxy > proxy)
Definition objects.cc:2851
static Maybe< bool > SetPrivateSymbol(Isolate *isolate, DirectHandle< JSProxy > proxy, DirectHandle< Symbol > private_name, PropertyDescriptor *desc, Maybe< ShouldThrow > should_throw)
Definition objects.cc:3443
static V8_WARN_UNUSED_RESULT Maybe< bool > SetProperty(DirectHandle< JSProxy > proxy, DirectHandle< Name > name, DirectHandle< Object > value, DirectHandle< JSAny > receiver, Maybe< ShouldThrow > should_throw)
Definition objects.cc:2958
static MaybeHandle< JSAny > CheckGetSetTrapResult(Isolate *isolate, DirectHandle< Name > name, DirectHandle< JSReceiver > target, DirectHandle< Object > trap_result, AccessKind access_kind)
Definition objects.cc:1379
static const int kMaxIterationLimit
Definition js-proxy.h:104
static V8_WARN_UNUSED_RESULT Maybe< bool > GetOwnPropertyDescriptor(Isolate *isolate, DirectHandle< JSProxy > proxy, DirectHandle< Name > name, PropertyDescriptor *desc)
Definition objects.cc:3490
static V8_WARN_UNUSED_RESULT Maybe< bool > SetPrototype(Isolate *isolate, DirectHandle< JSProxy > proxy, DirectHandle< Object > value, bool from_javascript, ShouldThrow should_throw)
Definition objects.cc:4822
static V8_WARN_UNUSED_RESULT Maybe< bool > IsExtensible(DirectHandle< JSProxy > proxy)
Definition objects.cc:3663
static V8_WARN_UNUSED_RESULT Maybe< bool > DeletePropertyOrElement(DirectHandle< JSProxy > proxy, DirectHandle< Name > name, LanguageMode language_mode)
Definition objects.cc:3010
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 > PreventExtensions(DirectHandle< JSProxy > proxy, ShouldThrow should_throw)
Definition objects.cc:3617
static V8_WARN_UNUSED_RESULT Maybe< bool > CheckDeleteTrap(Isolate *isolate, DirectHandle< Name > name, DirectHandle< JSReceiver > target)
Definition objects.cc:3054
V8_INLINE bool IsRevoked() const
static V8_WARN_UNUSED_RESULT Maybe< PropertyAttributes > GetPropertyAttributes(LookupIterator *it)
Definition objects.cc:3096
static V8_WARN_UNUSED_RESULT Maybe< bool > DefineOwnProperty(Isolate *isolate, DirectHandle< JSProxy > object, DirectHandle< Object > key, PropertyDescriptor *desc, Maybe< ShouldThrow > should_throw)
Definition objects.cc:3317
static MaybeDirectHandle< JSPrototype > GetPrototype(DirectHandle< JSProxy > receiver)
Definition objects.cc:1456
TNode< Object > receiver
#define DECL_VERIFIER(Name)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define V8_INLINE
Definition v8config.h:500
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671