v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
api-callbacks.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_API_CALLBACKS_H_
6#define V8_OBJECTS_API_CALLBACKS_H_
7
9#include "torque-generated/bit-fields.h"
10
11// Has to be the last include (doesn't have include guards):
13
14namespace v8 {
15namespace internal {
16
17class Undefined;
18class StructBodyDescriptor;
19
20#include "torque-generated/src/objects/api-callbacks-tq.inc"
21
22// An accessor must have a getter, but can have no setter.
23//
24// When setting a property, V8 searches accessors in prototypes.
25// If an accessor was found and it does not have a setter,
26// the request is ignored.
27//
28// If the accessor in the prototype has the READ_ONLY property attribute, then
29// a new value is added to the derived object when the property is set.
30// This shadows the accessor in the prototype.
32 : public TorqueGeneratedAccessorInfo<AccessorInfo, HeapObject> {
33 public:
34 // This is a wrapper around |maybe_redirected_getter| accessor which
35 // returns/accepts C function and converts the value from and to redirected
36 // pointer.
38 inline void init_getter_redirection(IsolateForSandbox isolate);
40 inline bool has_getter(Isolate* isolate);
41
42 // The field contains the address of the C function.
44 inline bool has_setter(Isolate* isolate);
45
46 DECL_BOOLEAN_ACCESSORS(replace_on_access)
48
51
54
55 // The property attributes used when an API object template is instantiated
56 // for the first time. Changing of this value afterwards does not affect
57 // the actual attributes of a property.
60
61 // Checks whether the given receiver is compatible with this accessor.
63 Handle<Map> map);
65
66 // Append all descriptors to the array that are not already there.
67 // Return number added.
68 static int AppendUnique(Isolate* isolate, DirectHandle<Object> descriptors,
70 int valid_descriptors);
71
73
74 inline void clear_padding();
75
76 class BodyDescriptor;
77
78 private:
79 // When simulator is enabled the field stores the "redirected" address of the
80 // C function (the one that's callabled from simulated compiled code), in
81 // this case the original address of the C function has to be taken from the
82 // redirection.
83 // For native builds the field contains the address of the C function.
84 // This field is initialized implicitly via respective |getter|-related
85 // methods.
86 DECL_EXTERNAL_POINTER_ACCESSORS(maybe_redirected_getter, Address)
87
88 // Bit positions in |flags|.
89 DEFINE_TORQUE_GENERATED_ACCESSOR_INFO_FLAGS()
90
92};
93
95 : public TorqueGeneratedAccessCheckInfo<AccessCheckInfo, Struct> {
96 public:
97 static Tagged<AccessCheckInfo> Get(Isolate* isolate,
99
101
103};
104
105#define INTERCEPTOR_INFO_CALLBACK_LIST(V) \
106 V(Getter, getter) \
107 V(Setter, setter) \
108 V(Query, query) \
109 V(Descriptor, descriptor) \
110 V(Deleter, deleter) \
111 V(Enumerator, enumerator) \
112 V(Definer, definer)
113
115 : public TorqueGeneratedInterceptorInfo<InterceptorInfo, HeapObject> {
116 public:
117 // Convenient predicates without named/indexed prefix.
118 inline bool has_getter() const;
119 inline bool has_setter() const;
120 inline bool has_query() const;
121 inline bool has_descriptor() const;
122 inline bool has_deleter() const;
123 inline bool has_enumerator() const;
124 inline bool has_definer() const;
125
126 // Accessor callbacks for named interceptors.
128 Address)
130 Address)
132 Address)
134 Address)
136 Address)
138 Address)
140 Address)
141
142 // Accessor callbacks for indexed interceptors.
144 Address)
146 Address)
148 Address)
150 Address)
152 Address)
154 Address)
156 Address)
157
158 DECL_BOOLEAN_ACCESSORS(can_intercept_symbols)
159 DECL_BOOLEAN_ACCESSORS(non_masking)
160 DECL_BOOLEAN_ACCESSORS(is_named)
161 DECL_BOOLEAN_ACCESSORS(has_no_side_effect)
162 // TODO(ishell): remove support for old signatures once they go through
163 // Api deprecation process.
164 DECL_BOOLEAN_ACCESSORS(has_new_callbacks_signature)
165
166 DEFINE_TORQUE_GENERATED_INTERCEPTOR_INFO_FLAGS()
167
169
170 inline void clear_padding();
171
172 class BodyDescriptor;
173
174 private:
175 friend class Factory;
176
177 inline void AllocateExternalPointerEntries(Isolate* isolate);
178
180};
181
182} // namespace internal
183} // namespace v8
184
185#include "src/objects/object-macros-undef.h"
186
187#endif // V8_OBJECTS_API_CALLBACKS_H_
PropertyT * getter
void init_getter_redirection(IsolateForSandbox isolate)
void set_getter_side_effect_type(SideEffectType type)
void set_setter_side_effect_type(SideEffectType type)
static int AppendUnique(Isolate *isolate, DirectHandle< Object > descriptors, DirectHandle< FixedArray > array, int valid_descriptors)
Definition objects.cc:2841
void set_initial_property_attributes(PropertyAttributes attributes)
PropertyAttributes initial_property_attributes() const
void remove_getter_redirection(IsolateForSandbox isolate)
bool has_getter(Isolate *isolate)
static bool IsCompatibleReceiverMap(Handle< AccessorInfo > info, Handle< Map > map)
bool IsCompatibleReceiver(Tagged< Object > receiver)
SideEffectType setter_side_effect_type() const
bool has_setter(Isolate *isolate)
SideEffectType getter_side_effect_type() const
DECL_LAZY_EXTERNAL_POINTER_ACCESSORS_MAYBE_READ_ONLY_HOST(named_getter, Address) DECL_LAZY_EXTERNAL_POINTER_ACCESSORS_MAYBE_READ_ONLY_HOST(named_setter
TNode< Object > receiver
V8_INLINE const Operation & Get(const Graph &graph, OpIndex index)
Definition graph.h:1231
bool is_sloppy(LanguageMode language_mode)
Definition globals.h:773
SideEffectType
Definition v8-object.h:198
V8_INLINE Local< Primitive > Undefined(Isolate *isolate)
#define DECL_EXTERNAL_POINTER_ACCESSORS(name, type)
#define DECL_BOOLEAN_ACCESSORS(name)
#define DECL_PRINTER(Name)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define DECL_EXTERNAL_POINTER_ACCESSORS_MAYBE_READ_ONLY_HOST(name, type)
#define DECL_LAZY_EXTERNAL_POINTER_ACCESSORS_MAYBE_READ_ONLY_HOST(name, type)