v8 14.1.146 (node 25.0.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-object.h
Go to the documentation of this file.
1// Copyright 2021 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 INCLUDE_V8_OBJECT_H_
6#define INCLUDE_V8_OBJECT_H_
7
8#include "cppgc/garbage-collected.h"
9#include "cppgc/name-provider.h"
10#include "v8-internal.h" // NOLINT(build/include_directory)
11#include "v8-local-handle.h" // NOLINT(build/include_directory)
12#include "v8-maybe.h" // NOLINT(build/include_directory)
13#include "v8-persistent-handle.h" // NOLINT(build/include_directory)
14#include "v8-primitive.h" // NOLINT(build/include_directory)
15#include "v8-sandbox.h" // NOLINT(build/include_directory)
16#include "v8-traced-handle.h" // NOLINT(build/include_directory)
17#include "v8-value.h" // NOLINT(build/include_directory)
18#include "v8config.h" // NOLINT(build/include_directory)
19
20namespace v8 {
21
22class Array;
23class Function;
25template <typename T>
27
28/**
29 * A tag for embedder data. Objects with different C++ types should use
30 * different values of EmbedderDataTypeTag when written to embedder data. The
31 * allowed range is 0..V8_EMBEDDER_DATA_TAG_COUNT - 1. If this is not
32 * sufficient, V8_EMBEDDER_DATA_TAG_COUNT can be increased.
33 */
34using EmbedderDataTypeTag = uint16_t;
35
36/**
37 * A private symbol
38 *
39 * This is an experimental feature. Use at your own risk.
40 */
41class V8_EXPORT Private : public Data {
42 public:
43 /**
44 * Returns the print name string of the private symbol, or undefined if none.
45 */
46 Local<Value> Name() const;
47
48 /**
49 * Create a private symbol. If name is not empty, it will be the description.
50 */
51 static Local<Private> New(Isolate* isolate,
52 Local<String> name = Local<String>());
53
54 /**
55 * Retrieve a global private symbol. If a symbol with this name has not
56 * been retrieved in the same isolate before, it is created.
57 * Note that private symbols created this way are never collected, so
58 * they should only be used for statically fixed properties.
59 * Also, there is only one global name space for the names used as keys.
60 * To minimize the potential for clashes, use qualified names as keys,
61 * e.g., "Class#property".
62 */
63 static Local<Private> ForApi(Isolate* isolate, Local<String> name);
64
65 V8_INLINE static Private* Cast(Data* data);
66
67 private:
68 Private();
69
70 static void CheckCast(Data* that);
71};
72
73/**
74 * An instance of a Property Descriptor, see Ecma-262 6.2.4.
75 *
76 * Properties in a descriptor are present or absent. If you do not set
77 * `enumerable`, `configurable`, and `writable`, they are absent. If `value`,
78 * `get`, or `set` are absent, but you must specify them in the constructor, use
79 * empty handles.
80 *
81 * Accessors `get` and `set` must be callable or undefined if they are present.
82 *
83 * \note Only query properties if they are present, i.e., call `x()` only if
84 * `has_x()` returns true.
85 *
86 * \code
87 * // var desc = {writable: false}
88 * v8::PropertyDescriptor d(Local<Value>()), false);
89 * d.value(); // error, value not set
90 * if (d.has_writable()) {
91 * d.writable(); // false
92 * }
93 *
94 * // var desc = {value: undefined}
95 * v8::PropertyDescriptor d(v8::Undefined(isolate));
96 *
97 * // var desc = {get: undefined}
98 * v8::PropertyDescriptor d(v8::Undefined(isolate), Local<Value>()));
99 * \endcode
100 */
102 public:
103 // GenericDescriptor
105
106 // DataDescriptor
108
109 // DataDescriptor with writable property
110 PropertyDescriptor(Local<Value> value, bool writable);
111
112 // AccessorDescriptor
114
116
117 Local<Value> value() const;
118 bool has_value() const;
119
120 Local<Value> get() const;
121 bool has_get() const;
122 Local<Value> set() const;
123 bool has_set() const;
124
125 void set_enumerable(bool enumerable);
126 bool enumerable() const;
127 bool has_enumerable() const;
128
129 void set_configurable(bool configurable);
130 bool configurable() const;
131 bool has_configurable() const;
132
133 bool writable() const;
134 bool has_writable() const;
135
136 struct PrivateData;
137 PrivateData* get_private() const { return private_; }
138
140 void operator=(const PropertyDescriptor&) = delete;
141
142 private:
143 PrivateData* private_;
144};
145
146/**
147 * PropertyAttribute.
148 */
150 /** None. **/
151 None = 0,
152 /** ReadOnly, i.e., not writable. **/
153 ReadOnly = 1 << 0,
154 /** DontEnum, i.e., not enumerable. **/
155 DontEnum = 1 << 1,
156 /** DontDelete, i.e., not configurable. **/
157 DontDelete = 1 << 2
159
160/**
161 * Accessor[Getter|Setter] are used as callback functions when setting|getting
162 * a particular data property. See Object::SetNativeDataProperty and
163 * ObjectTemplate::SetNativeDataProperty methods.
164 */
165using AccessorNameGetterCallback =
166 void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
167
168using AccessorNameSetterCallback =
169 void (*)(Local<Name> property, Local<Value> value,
170 const PropertyCallbackInfo<void>& info);
171
172/**
173 * Access control specifications.
174 *
175 * Some accessors should be accessible across contexts. These
176 * accessors have an explicit access control parameter which specifies
177 * the kind of cross-context access that should be allowed.
178 *
179 */
181 "This enum is no longer used and will be removed in V8 12.9.")
182 AccessControl {
183 DEFAULT V8_ENUM_DEPRECATE_SOON("not used") = 0,
184 };
185
186/**
187 * Property filter bits. They can be or'ed to build a composite filter.
188 */
195 SKIP_SYMBOLS = 16
197
198/**
199 * Options for marking whether callbacks may trigger JS-observable side effects.
200 * Side-effect-free callbacks are allowlisted during debug evaluation with
201 * throwOnSideEffect. It applies when calling a Function, FunctionTemplate,
202 * or an Accessor callback. For Interceptors, please see
203 * PropertyHandlerFlags's kHasNoSideEffect.
204 * Callbacks that only cause side effects to the receiver are allowlisted if
205 * invoked on receiver objects that are created within the same debug-evaluate
206 * call, as these objects are temporary and the side effect does not escape.
207 */
208enum class SideEffectType {
212};
213
214/**
215 * Keys/Properties filter enums:
216 *
217 * KeyCollectionMode limits the range of collected properties. kOwnOnly limits
218 * the collected properties to the given Object only. kIncludesPrototypes will
219 * include all keys of the objects's prototype chain as well.
220 */
222
223/**
224 * kIncludesIndices allows for integer indices to be collected, while
225 * kSkipIndices will exclude integer indices from being collected.
226 */
228
229/**
230 * kConvertToString will convert integer indices to strings.
231 * kKeepNumbers will return numbers for integer indices.
232 */
234
235/**
236 * Integrity level for objects.
237 */
239
240/**
241 * A JavaScript object (ECMA-262, 4.3.3)
242 */
243class V8_EXPORT Object : public Value {
244 public:
245 /**
246 * Set only return Just(true) or Empty(), so if it should never fail, use
247 * result.Check().
248 */
250 Local<Value> key, Local<Value> value);
252 Local<Value> key, Local<Value> value,
253 MaybeLocal<Object> receiver);
254
255 V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
256 Local<Value> value);
257
258 /**
259 * Implements CreateDataProperty(O, P, V), see
260 * https://tc39.es/ecma262/#sec-createdataproperty.
261 *
262 * Defines a configurable, writable, enumerable property with the given value
263 * on the object unless the property already exists and is not configurable
264 * or the object is not extensible.
265 *
266 * Returns true on success.
267 */
269 Local<Name> key,
270 Local<Value> value);
272 uint32_t index,
273 Local<Value> value);
274
275 /**
276 * Implements [[DefineOwnProperty]] for data property case, see
277 * https://tc39.es/ecma262/#table-essential-internal-methods.
278 *
279 * In general, CreateDataProperty will be faster, however, does not allow
280 * for specifying attributes.
281 *
282 * Returns true on success.
283 */
285 Local<Context> context, Local<Name> key, Local<Value> value,
286 PropertyAttribute attributes = None);
287
288 /**
289 * Implements Object.defineProperty(O, P, Attributes), see
290 * https://tc39.es/ecma262/#sec-object.defineproperty.
291 *
292 * The defineProperty function is used to add an own property or
293 * update the attributes of an existing own property of an object.
294 *
295 * Both data and accessor descriptors can be used.
296 *
297 * In general, CreateDataProperty is faster, however, does not allow
298 * for specifying attributes or an accessor descriptor.
299 *
300 * The PropertyDescriptor can change when redefining a property.
301 *
302 * Returns true on success.
303 */
305 Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
306
308 Local<Value> key);
310 Local<Value> key,
311 MaybeLocal<Object> receiver);
312
314 uint32_t index);
315
316 /**
317 * Gets the property attributes of a property which can be None or
318 * any combination of ReadOnly, DontEnum and DontDelete. Returns
319 * None when the property doesn't exist.
320 */
322 Local<Context> context, Local<Value> key);
323
324 /**
325 * Implements Object.getOwnPropertyDescriptor(O, P), see
326 * https://tc39.es/ecma262/#sec-object.getownpropertydescriptor.
327 */
329 Local<Context> context, Local<Name> key);
330
331 /**
332 * Object::Has() calls the abstract operation HasProperty(O, P), see
333 * https://tc39.es/ecma262/#sec-hasproperty. Has() returns
334 * true, if the object has the property, either own or on the prototype chain.
335 * Interceptors, i.e., PropertyQueryCallbacks, are called if present.
336 *
337 * Has() has the same side effects as JavaScript's `variable in object`.
338 * For example, calling Has() on a revoked proxy will throw an exception.
339 *
340 * \note Has() converts the key to a name, which possibly calls back into
341 * JavaScript.
342 *
343 * See also v8::Object::HasOwnProperty() and
344 * v8::Object::HasRealNamedProperty().
345 */
347 Local<Value> key);
348
350 Local<Value> key);
351
352 V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index);
353
355 uint32_t index);
356
357 /**
358 * Sets an accessor property like Template::SetAccessorProperty, but
359 * this method sets on this object directly.
360 */
362 Local<Function> setter = Local<Function>(),
363 PropertyAttribute attributes = None);
364
365 /**
366 * Sets a native data property like Template::SetNativeDataProperty, but
367 * this method sets on this object directly.
368 */
370 Local<Context> context, Local<Name> name,
371 AccessorNameGetterCallback getter,
372 AccessorNameSetterCallback setter = nullptr,
373 Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
374 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
375 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
376
377 /**
378 * Attempts to create a property with the given name which behaves like a data
379 * property, except that the provided getter is invoked (and provided with the
380 * data value) to supply its value the first time it is read. After the
381 * property is accessed once, it is replaced with an ordinary data property.
382 *
383 * Analogous to Template::SetLazyDataProperty.
384 */
386 Local<Context> context, Local<Name> name,
387 AccessorNameGetterCallback getter, Local<Value> data = Local<Value>(),
388 PropertyAttribute attributes = None,
389 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
390 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
391
392 /**
393 * Functionality for private properties.
394 * This is an experimental feature, use at your own risk.
395 * Note: Private properties are not inherited. Do not rely on this, since it
396 * may change.
397 */
398 Maybe<bool> HasPrivate(Local<Context> context, Local<Private> key);
400 Local<Value> value);
403
404 /**
405 * Returns an array containing the names of the enumerable properties
406 * of this object, including properties from prototype objects. The
407 * array returned by this method contains the same values as would
408 * be enumerated by a for-in statement over this object.
409 */
411 Local<Context> context);
413 Local<Context> context, KeyCollectionMode mode,
414 PropertyFilter property_filter, IndexFilter index_filter,
416
417 /**
418 * This function has the same functionality as GetPropertyNames but
419 * the returned array doesn't contain the names of properties from
420 * prototype objects.
421 */
423 Local<Context> context);
424
425 /**
426 * Returns an array containing the names of the filtered properties
427 * of this object, including properties from prototype objects. The
428 * array returned by this method contains the same values as would
429 * be enumerated by a for-in statement over this object.
430 */
432 Local<Context> context, PropertyFilter filter,
434
435 /**
436 * Get the prototype object. This does not skip objects marked to
437 * be skipped by __proto__ and it does not consult the security
438 * handler.
439 */
441 "V8 will stop providing access to hidden prototype (i.e. "
442 "JSGlobalObject). Use GetPrototypeV2() instead. "
443 "See http://crbug.com/333672197.")
444 Local<Value> GetPrototype();
445
446 /**
447 * Get the prototype object (same as calling Object.getPrototypeOf(..)).
448 * This does not consult the security handler.
449 * TODO(333672197): rename back to GetPrototype() once the old version goes
450 * through the deprecation process and is removed.
451 */
453
454 /**
455 * Set the prototype object. This does not skip objects marked to
456 * be skipped by __proto__ and it does not consult the security
457 * handler.
458 */
460 "V8 will stop providing access to hidden prototype (i.e. "
461 "JSGlobalObject). Use SetPrototypeV2() instead. "
462 "See http://crbug.com/333672197.")
463 V8_WARN_UNUSED_RESULT Maybe<bool> SetPrototype(Local<Context> context,
465
466 /**
467 * Set the prototype object (same as calling Object.setPrototypeOf(..)).
468 * This does not consult the security handler.
469 * TODO(333672197): rename back to SetPrototype() once the old version goes
470 * through the deprecation process and is removed.
471 */
473 Local<Value> prototype);
474
475 /**
476 * Finds an instance of the given function template in the prototype
477 * chain.
478 */
480
481 /**
482 * Call builtin Object.prototype.toString on this object.
483 * This is different from Value::ToString() that may call
484 * user-defined toString function. This one does not.
485 */
487 Local<Context> context);
488
489 /**
490 * Returns the name of the function invoked as a constructor for this object.
491 */
493
494 /**
495 * Sets the integrity level of the object.
496 */
498
499 /** Gets the number of internal fields for this Object. */
501
502 /** Same as above, but works for PersistentBase. */
504 const PersistentBase<Object>& object) {
505 return object.template value<Object>()->InternalFieldCount();
506 }
507
508 /** Same as above, but works for BasicTracedReference. */
510 const BasicTracedReference<Object>& object) {
511 return object.template value<Object>()->InternalFieldCount();
512 }
513
514 /**
515 * Gets the data from an internal field.
516 * To cast the return value into v8::Value subtypes, it needs to be
517 * casted to a v8::Value first. For example, to cast it into v8::External:
518 *
519 * object->GetInternalField(index).As<v8::Value>().As<v8::External>();
520 *
521 * The embedder should make sure that the internal field being retrieved
522 * using this method has already been set with SetInternalField() before.
523 **/
525
526 /** Sets the data in an internal field. */
527 void SetInternalField(int index, Local<Data> data);
528
529 /**
530 * Gets a 2-byte-aligned native pointer from an internal field. This field
531 * must have been set by SetAlignedPointerInInternalField, everything else
532 * leads to undefined behavior.
533 */
536 int index);
537
538 /** Same as above, but works for PersistentBase. */
540 const PersistentBase<Object>& object, int index) {
541 return object.template value<Object>()->GetAlignedPointerFromInternalField(
542 index);
543 }
544
545 /** Same as above, but works for TracedReference. */
547 const BasicTracedReference<Object>& object, int index) {
548 return object.template value<Object>()->GetAlignedPointerFromInternalField(
549 index);
550 }
551
552 /**
553 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such
554 * a field, GetAlignedPointerFromInternalField must be used, everything else
555 * leads to undefined behavior.
556 */
558 "Use SetAlignedPointerInInternalField with EmbedderDataTypeTag parameter "
559 "instead.")
560 void SetAlignedPointerInInternalField(int index, void* value);
561
562 void SetAlignedPointerInInternalField(int index, void* value,
563 EmbedderDataTypeTag tag);
564
566 "Use SetAlignedPointerInInternalField with EmbedderDataTypeTag "
567 "parameter instead.")
568 void SetAlignedPointerInInternalFields(int argc, int indices[],
569 void* values[]);
570
571 // Type information for a Wrappable object that got wrapped with
572 // `v8::Object::Wrap()`.
574 const int16_t type_id;
575 };
576
577 // v8::Object::Wrappable serves as the base class for all C++ objects that can
578 // be wrapped by a JavaScript object using `v8::Object::Wrap()`.
579 //
580 // Note that v8::Object::Wrappable` inherits from `NameProvider` and provides
581 // `GetWrapperTypeInfo` to allow subclasses to have smaller object sizes.
583 public cppgc::NameProvider {
584 public:
585 virtual const WrapperTypeInfo* GetWrapperTypeInfo() const {
586 return nullptr;
587 }
588
589 const char* GetHumanReadableName() const override { return "internal"; }
590
591 virtual void Trace(cppgc::Visitor* visitor) const {}
592 };
593
594 /**
595 * Unwraps a JS wrapper object.
596 *
597 * \param tag The tag for retrieving the wrappable instance. Must match the
598 * tag that has been used for a previous `Wrap()` operation.
599 * \param isolate The Isolate for the `wrapper` object.
600 * \param wrapper The JS wrapper object that should be unwrapped.
601 * \returns the C++ wrappable instance, or nullptr if the JS object has never
602 * been wrapped.
603 */
604 template <CppHeapPointerTag tag, typename T = void>
605 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
606 const v8::Local<v8::Object>& wrapper);
607 template <CppHeapPointerTag tag, typename T = void>
608 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
609 const PersistentBase<Object>& wrapper);
610 template <CppHeapPointerTag tag, typename T = void>
611 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
612 const BasicTracedReference<Object>& wrapper);
613
614 template <typename T = void>
615 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
616 const v8::Local<v8::Object>& wrapper,
617 CppHeapPointerTagRange tag_range);
618 template <typename T = void>
619 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
620 const PersistentBase<Object>& wrapper,
621 CppHeapPointerTagRange tag_range);
622 template <typename T = void>
623 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
624 const BasicTracedReference<Object>& wrapper,
625 CppHeapPointerTagRange tag_range);
626
627 /**
628 * Wraps a JS wrapper with a C++ instance.
629 *
630 * \param tag The pointer tag that should be used for storing this object.
631 * Future `Unwrap()` operations must provide a matching tag.
632 * \param isolate The Isolate for the `wrapper` object.
633 * \param wrapper The JS wrapper object.
634 * \param wrappable The C++ object instance that is wrapped by the JS object.
635 */
636 template <CppHeapPointerTag tag>
637 static V8_INLINE void Wrap(v8::Isolate* isolate,
638 const v8::Local<v8::Object>& wrapper,
639 Wrappable* wrappable);
640 template <CppHeapPointerTag tag>
641 static V8_INLINE void Wrap(v8::Isolate* isolate,
642 const PersistentBase<Object>& wrapper,
643 Wrappable* wrappable);
644 template <CppHeapPointerTag tag>
645 static V8_INLINE void Wrap(v8::Isolate* isolate,
646 const BasicTracedReference<Object>& wrapper,
647 Wrappable* wrappable);
648 static V8_INLINE void Wrap(v8::Isolate* isolate,
649 const v8::Local<v8::Object>& wrapper,
650 Wrappable* wrappable, CppHeapPointerTag tag);
651 static V8_INLINE void Wrap(v8::Isolate* isolate,
652 const PersistentBase<Object>& wrapper,
653 Wrappable* wrappable, CppHeapPointerTag tag);
654 static V8_INLINE void Wrap(v8::Isolate* isolate,
655 const BasicTracedReference<Object>& wrapper,
656 Wrappable* wrappable, CppHeapPointerTag tag);
657
658 // Version of Wrap() function for v8::Context::Global() objects.
659 // Unlike the functions above it wraps both JSGlobalProxy and its hidden
660 // prototype (JSGlobalObject or remote object).
661 static void WrapGlobal(v8::Isolate* isolate,
662 const v8::Local<v8::Object>& wrapper,
663 Wrappable* wrappable, CppHeapPointerTag tag);
664
665 // Checks that wrappables set on JSGlobalProxy and its hidden prototype are
666 // the same.
667 static bool CheckGlobalWrappable(v8::Isolate* isolate,
668 const v8::Local<v8::Object>& wrapper,
669 CppHeapPointerTagRange tag_range);
670
671 /**
672 * HasOwnProperty() is like JavaScript's
673 * Object.prototype.hasOwnProperty().
674 *
675 * See also v8::Object::Has() and v8::Object::HasRealNamedProperty().
676 */
678 Local<Name> key);
680 uint32_t index);
681 /**
682 * Use HasRealNamedProperty() if you want to check if an object has an own
683 * property without causing side effects, i.e., without calling interceptors.
684 *
685 * This function is similar to v8::Object::HasOwnProperty(), but it does not
686 * call interceptors.
687 *
688 * \note Consider using non-masking interceptors, i.e., the interceptors are
689 * not called if the receiver has the real named property. See
690 * `v8::PropertyHandlerFlags::kNonMasking`.
691 *
692 * See also v8::Object::Has().
693 */
695 Local<Name> key);
697 Local<Context> context, uint32_t index);
699 Local<Context> context, Local<Name> key);
700
701 /**
702 * If result.IsEmpty() no real property was located in the prototype chain.
703 * This means interceptors in the prototype chain are not called.
704 */
706 Local<Context> context, Local<Name> key);
707
708 /**
709 * Gets the property attributes of a real property in the prototype chain,
710 * which can be None or any combination of ReadOnly, DontEnum and DontDelete.
711 * Interceptors in the prototype chain are not called.
712 */
715 Local<Name> key);
716
717 /**
718 * If result.IsEmpty() no real property was located on the object or
719 * in the prototype chain.
720 * This means interceptors in the prototype chain are not called.
721 */
723 Local<Context> context, Local<Name> key);
724
725 /**
726 * Gets the property attributes of a real property which can be
727 * None or any combination of ReadOnly, DontEnum and DontDelete.
728 * Interceptors in the prototype chain are not called.
729 */
731 Local<Context> context, Local<Name> key);
732
733 /** Tests for a named lookup interceptor.*/
735
736 /** Tests for an index lookup interceptor.*/
738
739 /**
740 * Returns the identity hash for this object. The current implementation
741 * uses a hidden property on the object to store the identity hash.
742 *
743 * The return value will never be 0. Also, it is not guaranteed to be
744 * unique.
745 */
747
748 /**
749 * Clone this object with a fast but shallow copy. Values will point to the
750 * same values as the original object.
751 *
752 * Prefer using version with Isolate parameter.
753 */
756
757 /**
758 * Returns the context in which the object was created.
759 *
760 * Prefer using version with Isolate parameter.
761 */
763 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
765
766 /**
767 * Shortcut for GetCreationContext(...).ToLocalChecked().
768 *
769 * Prefer using version with Isolate parameter.
770 **/
772 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
774
775 /** Same as above, but works for Persistents */
777 v8::Isolate* isolate, const PersistentBase<Object>& object) {
778 return object.template value<Object>()->GetCreationContext(isolate);
779 }
780 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
782 const PersistentBase<Object>& object);
783
784 /**
785 * Gets the context in which the object was created (see GetCreationContext())
786 * and if it's available reads respective embedder field value.
787 * If the context can't be obtained nullptr is returned.
788 * Basically it's a shortcut for
789 * obj->GetCreationContext().GetAlignedPointerFromEmbedderData(index)
790 * which doesn't create a handle for Context object on the way and doesn't
791 * try to expand the embedder data attached to the context.
792 * In case the Local<Context> is already available because of other reasons,
793 * it's fine to keep using Context::GetAlignedPointerFromEmbedderData().
794 *
795 * Prefer using version with Isolate parameter if you have an Isolate,
796 * otherwise use the other one.
797 */
799 int index);
801
802 /**
803 * Checks whether a callback is set by the
804 * ObjectTemplate::SetCallAsFunctionHandler method.
805 * When an Object is callable this method returns true.
806 */
807 bool IsCallable() const;
808
809 /**
810 * True if this object is a constructor.
811 */
812 bool IsConstructor() const;
813
814 /**
815 * Returns true if this object can be generally used to wrap object objects.
816 * This means that the object either follows the convention of using embedder
817 * fields to denote type/instance pointers or is using the Wrap()/Unwrap()
818 * APIs for the same purpose. Returns false otherwise.
819 *
820 * Note that there may be other objects that use embedder fields but are not
821 * used as API wrapper objects. E.g., v8::Promise may in certain configuration
822 * use embedder fields but promises are not generally supported as API
823 * wrappers. The method will return false in those cases.
824 */
825 bool IsApiWrapper() const;
826
827 /**
828 * True if this object was created from an object template which was marked
829 * as undetectable. See v8::ObjectTemplate::MarkAsUndetectable for more
830 * information.
831 */
832 bool IsUndetectable() const;
833
834 /**
835 * Call an Object as a function if a callback is set by the
836 * ObjectTemplate::SetCallAsFunctionHandler method.
837 */
839 Local<Value> recv,
840 int argc,
841 Local<Value> argv[]);
842
843 /**
844 * Call an Object as a constructor if a callback is set by the
845 * ObjectTemplate::SetCallAsFunctionHandler method.
846 * Note: This method behaves like the Function::NewInstance method.
847 */
849 Local<Context> context, int argc, Local<Value> argv[]);
850
851 /**
852 * Return the isolate to which the Object belongs to.
853 */
855 "Use Isolate::GetCurrent() instead, which is guaranteed to return the "
856 "same isolate since https://crrev.com/c/6458560.")
857 Isolate* GetIsolate();
858
860 "Use Isolate::GetCurrent() instead, which is guaranteed to return the "
861 "same isolate since https://crrev.com/c/6458560.")
862 V8_INLINE static Isolate* GetIsolate(const TracedReference<Object>& handle) {
863 return handle.template value<Object>()->GetIsolate();
864 }
865
866 /**
867 * If this object is a Set, Map, WeakSet or WeakMap, this returns a
868 * representation of the elements of this object as an array.
869 * If this object is a SetIterator or MapIterator, this returns all
870 * elements of the underlying collection, starting at the iterator's current
871 * position.
872 * For other types, this will return an empty MaybeLocal<Array> (without
873 * scheduling an exception).
874 */
875 MaybeLocal<Array> PreviewEntries(bool* is_key_value);
876
877 static Local<Object> New(Isolate* isolate);
878
879 /**
880 * Creates a JavaScript object with the given properties, and
881 * a the given prototype_or_null (which can be any JavaScript
882 * value, and if it's null, the newly created object won't have
883 * a prototype at all). This is similar to Object.create().
884 * All properties will be created as enumerable, configurable
885 * and writable properties.
886 */
887 static Local<Object> New(Isolate* isolate, Local<Value> prototype_or_null,
888 Local<Name>* names, Local<Value>* values,
889 size_t length);
890
891 V8_INLINE static Object* Cast(Value* obj);
892
893 /**
894 * Support for TC39 "dynamic code brand checks" proposal.
895 *
896 * This API allows to query whether an object was constructed from a
897 * "code like" ObjectTemplate.
898 *
899 * See also: v8::ObjectTemplate::SetCodeLike
900 */
901 bool IsCodeLike(Isolate* isolate) const;
902
903 private:
904 static void* Unwrap(v8::Isolate* isolate, internal::Address wrapper_obj,
905 CppHeapPointerTagRange tag_range);
906 static void Wrap(v8::Isolate* isolate, internal::Address wrapper_obj,
907 CppHeapPointerTag tag, void* wrappable);
908
909 Object();
910 static void CheckCast(Value* obj);
911 Local<Data> SlowGetInternalField(int index);
912 void* SlowGetAlignedPointerFromInternalField(int index);
913 void* SlowGetAlignedPointerFromInternalField(v8::Isolate* isolate, int index);
914};
915
916// --- Implementation ---
917
919#ifndef V8_ENABLE_CHECKS
920 using A = internal::Address;
921 using I = internal::Internals;
922 A obj = internal::ValueHelper::ValueAsAddress(this);
923 // Fast path: If the object is a plain JSObject, which is the common case, we
924 // know where to find the internal fields and can return the value directly.
925 int instance_type = I::GetInstanceType(obj);
926 if (I::CanHaveInternalField(instance_type)) {
928 (I::kEmbedderDataSlotSize * index);
929 A value = I::ReadRawField<A>(obj, offset);
930#ifdef V8_COMPRESS_POINTERS
931 // We read the full pointer value and then decompress it in order to avoid
932 // dealing with potential endiannes issues.
933 value = I::DecompressTaggedField(obj, static_cast<uint32_t>(value));
934#endif
935
936 auto* isolate = I::GetCurrentIsolate();
937 return Local<Data>::New(isolate, value);
938 }
939#endif
940 return SlowGetInternalField(index);
941}
942
944 int index) {
945#if !defined(V8_ENABLE_CHECKS)
946 using A = internal::Address;
947 using I = internal::Internals;
948 A obj = internal::ValueHelper::ValueAsAddress(this);
949 // Fast path: If the object is a plain JSObject, which is the common case, we
950 // know where to find the internal fields and can return the value directly.
951 auto instance_type = I::GetInstanceType(obj);
952 if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
954 (I::kEmbedderDataSlotSize * index) +
956 A value =
957 I::ReadExternalPointerField<{internal::kFirstEmbedderDataTag,
959 isolate, obj, offset);
960 return reinterpret_cast<void*>(value);
961 }
962#endif
963 return SlowGetAlignedPointerFromInternalField(isolate, index);
964}
965
967#if !defined(V8_ENABLE_CHECKS)
968 using A = internal::Address;
969 using I = internal::Internals;
970 A obj = internal::ValueHelper::ValueAsAddress(this);
971 // Fast path: If the object is a plain JSObject, which is the common case, we
972 // know where to find the internal fields and can return the value directly.
973 auto instance_type = I::GetInstanceType(obj);
974 if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
976 (I::kEmbedderDataSlotSize * index) +
979 A value =
980 I::ReadExternalPointerField<{internal::kFirstEmbedderDataTag,
982 isolate, obj, offset);
983 return reinterpret_cast<void*>(value);
984 }
985#endif
986 return SlowGetAlignedPointerFromInternalField(index);
987}
988
989// static
990template <CppHeapPointerTag tag, typename T>
991T* Object::Unwrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper) {
992 CppHeapPointerTagRange tag_range(tag, tag);
993 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
994#if !defined(V8_ENABLE_CHECKS)
995 return internal::ReadCppHeapPointerField<T>(
996 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
997#else // defined(V8_ENABLE_CHECKS)
998 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
999#endif // defined(V8_ENABLE_CHECKS)
1000}
1001
1002// static
1003template <CppHeapPointerTag tag, typename T>
1004T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper) {
1005 CppHeapPointerTagRange tag_range(tag, tag);
1006 auto obj =
1007 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1008#if !defined(V8_ENABLE_CHECKS)
1009 return internal::ReadCppHeapPointerField<T>(
1010 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1011#else // defined(V8_ENABLE_CHECKS)
1012 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1013#endif // defined(V8_ENABLE_CHECKS)
1014}
1015
1016// static
1017template <CppHeapPointerTag tag, typename T>
1018T* Object::Unwrap(v8::Isolate* isolate,
1019 const BasicTracedReference<Object>& wrapper) {
1020 CppHeapPointerTagRange tag_range(tag, tag);
1021 auto obj =
1022 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1023#if !defined(V8_ENABLE_CHECKS)
1024 return internal::ReadCppHeapPointerField<T>(
1025 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1026#else // defined(V8_ENABLE_CHECKS)
1027 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1028#endif // defined(V8_ENABLE_CHECKS)
1029}
1030
1031// static
1032template <typename T>
1033T* Object::Unwrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1034 CppHeapPointerTagRange tag_range) {
1035 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1036#if !defined(V8_ENABLE_CHECKS)
1037 return internal::ReadCppHeapPointerField<T>(
1038 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1039#else // defined(V8_ENABLE_CHECKS)
1040 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1041#endif // defined(V8_ENABLE_CHECKS)
1042}
1043
1044// static
1045template <typename T>
1046T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1047 CppHeapPointerTagRange tag_range) {
1048 auto obj =
1049 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1050#if !defined(V8_ENABLE_CHECKS)
1051 return internal::ReadCppHeapPointerField<T>(
1052 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1053#else // defined(V8_ENABLE_CHECKS)
1054
1055 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1056#endif // defined(V8_ENABLE_CHECKS)
1057}
1058
1059// static
1060template <typename T>
1061T* Object::Unwrap(v8::Isolate* isolate,
1062 const BasicTracedReference<Object>& wrapper,
1063 CppHeapPointerTagRange tag_range) {
1064 auto obj =
1065 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1066#if !defined(V8_ENABLE_CHECKS)
1067 return internal::ReadCppHeapPointerField<T>(
1068 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1069#else // defined(V8_ENABLE_CHECKS)
1070 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1071#endif // defined(V8_ENABLE_CHECKS)
1072}
1073
1074// static
1075template <CppHeapPointerTag tag>
1076void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1077 v8::Object::Wrappable* wrappable) {
1078 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1079 Wrap(isolate, obj, tag, wrappable);
1080}
1081
1082// static
1083template <CppHeapPointerTag tag>
1084void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1085 v8::Object::Wrappable* wrappable) {
1086 auto obj =
1087 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1088 Wrap(isolate, obj, tag, wrappable);
1089}
1090
1091// static
1092template <CppHeapPointerTag tag>
1093void Object::Wrap(v8::Isolate* isolate,
1094 const BasicTracedReference<Object>& wrapper,
1095 v8::Object::Wrappable* wrappable) {
1096 auto obj =
1097 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1098 Wrap(isolate, obj, tag, wrappable);
1099}
1100
1101// static
1102void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1103 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1104 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1105 Wrap(isolate, obj, tag, wrappable);
1106}
1107
1108// static
1109void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1110 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1111 auto obj =
1112 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1113 Wrap(isolate, obj, tag, wrappable);
1114}
1115
1116// static
1117void Object::Wrap(v8::Isolate* isolate,
1118 const BasicTracedReference<Object>& wrapper,
1119 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1120 auto obj =
1121 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1122 Wrap(isolate, obj, tag, wrappable);
1123}
1124
1126#ifdef V8_ENABLE_CHECKS
1127 CheckCast(data);
1128#endif
1129 return reinterpret_cast<Private*>(data);
1130}
1131
1133#ifdef V8_ENABLE_CHECKS
1134 CheckCast(value);
1135#endif
1136 return static_cast<Object*>(value);
1137}
1138
1139} // namespace v8
1140
1141#endif // INCLUDE_V8_OBJECT_H_
friend class Local
friend class MaybeLocal
virtual void Trace(cppgc::Visitor *visitor) const
Definition v8-object.h:591
const char * GetHumanReadableName() const override
Definition v8-object.h:589
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition v8-object.h:585
static V8_INLINE void Wrap(v8::Isolate *isolate, const PersistentBase< Object > &wrapper, Wrappable *wrappable, CppHeapPointerTag tag)
Definition v8-object.h:1109
bool HasNamedLookupInterceptor() const
static V8_INLINE int InternalFieldCount(const PersistentBase< Object > &object)
Definition v8-object.h:503
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetPropertyNames(Local< Context > context, KeyCollectionMode mode, PropertyFilter property_filter, IndexFilter index_filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
V8_INLINE void * GetAlignedPointerFromInternalField(v8::Isolate *isolate, int index)
Definition v8-object.h:943
V8_WARN_UNUSED_RESULT Maybe< bool > HasOwnProperty(Local< Context > context, uint32_t index)
void * value
Definition v8-object.h:560
int indices[]
Definition v8-object.h:568
bool HasIndexedLookupInterceptor() const
static V8_INLINE void Wrap(v8::Isolate *isolate, const PersistentBase< Object > &wrapper, Wrappable *wrappable)
V8_WARN_UNUSED_RESULT Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value, MaybeLocal< Object > receiver)
bool IsCallable() const
V8_WARN_UNUSED_RESULT Maybe< PropertyAttribute > GetPropertyAttributes(Local< Context > context, Local< Value > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Has(Local< Context > context, Local< Value > key)
V8_WARN_UNUSED_RESULT Maybe< bool > SetPrototypeV2(Local< Context > context, Local< Value > prototype)
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context)
static V8_INLINE int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition v8-object.h:509
V8_WARN_UNUSED_RESULT MaybeLocal< Value > CallAsConstructor(Local< Context > context, int argc, Local< Value > argv[])
V8_WARN_UNUSED_RESULT Maybe< bool > HasRealNamedProperty(Local< Context > context, Local< Name > key)
Local< Object > Clone()
int GetIdentityHash()
V8_WARN_UNUSED_RESULT Maybe< bool > Delete(Local< Context > context, Local< Value > key)
V8_WARN_UNUSED_RESULT Maybe< bool > SetLazyDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
Maybe< bool > SetIntegrityLevel(Local< Context > context, IntegrityLevel level)
static bool CheckGlobalWrappable(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, CppHeapPointerTagRange tag_range)
V8_WARN_UNUSED_RESULT Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
Local< Context > GetCreationContextChecked()
void * GetAlignedPointerFromEmbedderDataInCreationContext(int index)
static V8_INLINE void * GetAlignedPointerFromInternalField(const BasicTracedReference< Object > &object, int index)
Definition v8-object.h:546
V8_WARN_UNUSED_RESULT Maybe< bool > DefineOwnProperty(Local< Context > context, Local< Name > key, Local< Value > value, PropertyAttribute attributes=None)
V8_INLINE void * GetAlignedPointerFromInternalField(int index)
Definition v8-object.h:966
static V8_INLINE void Wrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, Wrappable *wrappable, CppHeapPointerTag tag)
Definition v8-object.h:1102
V8_INLINE Local< Data > GetInternalField(int index)
Definition v8-object.h:918
bool IsApiWrapper() const
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper)
Local< String > GetConstructorName()
MaybeLocal< Context > GetCreationContext()
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context, PropertyFilter filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
static V8_INLINE void Wrap(v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper, Wrappable *wrappable, CppHeapPointerTag tag)
Definition v8-object.h:1117
void SetAlignedPointerInInternalField(int index, void *value, EmbedderDataTypeTag tag)
static V8_INLINE void Wrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, Wrappable *wrappable)
Local< Object > Clone(v8::Isolate *isolate)
Maybe< bool > DeletePrivate(Local< Context > context, Local< Private > key)
V8_WARN_UNUSED_RESULT Maybe< PropertyAttribute > GetRealNamedPropertyAttributes(Local< Context > context, Local< Name > key)
void * GetAlignedPointerFromEmbedderDataInCreationContext(v8::Isolate *isolate, int index)
Maybe< bool > HasPrivate(Local< Context > context, Local< Private > key)
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper)
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper, CppHeapPointerTagRange tag_range)
void SetInternalField(int index, Local< Data > data)
V8_WARN_UNUSED_RESULT Maybe< bool > CreateDataProperty(Local< Context > context, uint32_t index, Local< Value > value)
static void WrapGlobal(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, Wrappable *wrappable, CppHeapPointerTag tag)
MaybeLocal< Array > PreviewEntries(bool *is_key_value)
bool IsCodeLike(Isolate *isolate) const
Local< Value > prototype
Definition v8-object.h:464
Local< Value > GetPrototypeV2()
static V8_INLINE MaybeLocal< Context > GetCreationContext(const PersistentBase< Object > &object)
V8_WARN_UNUSED_RESULT MaybeLocal< String > ObjectProtoToString(Local< Context > context)
bool IsConstructor() const
static V8_INLINE Object * Cast(Value *obj)
Definition v8-object.h:1132
void SetAccessorProperty(Local< Name > name, Local< Function > getter, Local< Function > setter=Local< Function >(), PropertyAttribute attributes=None)
V8_WARN_UNUSED_RESULT Maybe< bool > HasRealIndexedProperty(Local< Context > context, uint32_t index)
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const PersistentBase< Object > &wrapper)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetPropertyNames(Local< Context > context)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > CallAsFunction(Local< Context > context, Local< Value > recv, int argc, Local< Value > argv[])
Maybe< bool > SetPrivate(Local< Context > context, Local< Private > key, Local< Value > value)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > GetOwnPropertyDescriptor(Local< Context > context, Local< Name > key)
static V8_INLINE MaybeLocal< Context > GetCreationContext(v8::Isolate *isolate, const PersistentBase< Object > &object)
Definition v8-object.h:776
static V8_INLINE void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index)
Definition v8-object.h:539
V8_WARN_UNUSED_RESULT Maybe< bool > Set(Local< Context > context, uint32_t index, Local< Value > value)
V8_WARN_UNUSED_RESULT Maybe< bool > HasOwnProperty(Local< Context > context, Local< Name > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Delete(Local< Context > context, uint32_t index)
V8_WARN_UNUSED_RESULT Maybe< bool > CreateDataProperty(Local< Context > context, Local< Name > key, Local< Value > value)
MaybeLocal< Context > GetCreationContext(v8::Isolate *isolate)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Get(Local< Context > context, uint32_t index)
V8_WARN_UNUSED_RESULT Maybe< bool > HasRealNamedCallbackProperty(Local< Context > context, Local< Name > key)
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, CppHeapPointerTagRange tag_range)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Get(Local< Context > context, Local< Value > key, MaybeLocal< Object > receiver)
Local< Object > FindInstanceInPrototypeChain(Local< FunctionTemplate > tmpl)
static Local< Object > New(Isolate *isolate)
static Local< Object > New(Isolate *isolate, Local< Value > prototype_or_null, Local< Name > *names, Local< Value > *values, size_t length)
V8_WARN_UNUSED_RESULT Maybe< bool > DefineProperty(Local< Context > context, Local< Name > key, PropertyDescriptor &descriptor)
bool IsUndetectable() const
V8_WARN_UNUSED_RESULT Maybe< PropertyAttribute > GetRealNamedPropertyAttributesInPrototypeChain(Local< Context > context, Local< Name > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Has(Local< Context > context, uint32_t index)
static V8_INLINE void Wrap(v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper, Wrappable *wrappable)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > GetRealNamedProperty(Local< Context > context, Local< Name > key)
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const PersistentBase< Object > &wrapper, CppHeapPointerTagRange tag_range)
Local< Context > GetCreationContextChecked(v8::Isolate *isolate)
MaybeLocal< Value > GetPrivate(Local< Context > context, Local< Private > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
int void * values[]
Definition v8-object.h:569
int InternalFieldCount() const
Local< Value > Name() const
static Local< Private > ForApi(Isolate *isolate, Local< String > name)
static V8_INLINE Private * Cast(Data *data)
Definition v8-object.h:1125
static Local< Private > New(Isolate *isolate, Local< String > name=Local< String >())
PrivateData * get_private() const
Definition v8-object.h:137
bool has_configurable() const
PropertyDescriptor(const PropertyDescriptor &)=delete
bool has_enumerable() const
Local< Value > set() const
void set_configurable(bool configurable)
bool has_value() const
void operator=(const PropertyDescriptor &)=delete
PropertyDescriptor(Local< Value > get, Local< Value > set)
bool has_writable() const
bool enumerable() const
PropertyDescriptor(Local< Value > value)
Local< Value > value() const
void set_enumerable(bool enumerable)
Local< Value > get() const
PropertyDescriptor(Local< Value > value, bool writable)
bool configurable() const
static const int kEmbedderDataSlotExternalPointerOffset
static V8_INLINE constexpr bool CanHaveInternalField(int instance_type)
static V8_INLINE int GetInstanceType(Address obj)
static V8_INLINE v8::Isolate * GetCurrentIsolateForSandbox()
static const int kEmbedderDataSlotSize
static V8_EXPORT v8::Isolate * GetCurrentIsolate()
static const int kJSAPIObjectWithEmbedderSlotsHeaderSize
static const int kJSObjectHeaderSize
uintptr_t Address
Definition v8-internal.h:52
CppHeapPointerTag
Definition v8-sandbox.h:28
SideEffectType
Definition v8-object.h:208
PropertyFilter
Definition v8-object.h:189
@ SKIP_SYMBOLS
Definition v8-object.h:195
@ ALL_PROPERTIES
Definition v8-object.h:190
@ ONLY_CONFIGURABLE
Definition v8-object.h:193
@ ONLY_WRITABLE
Definition v8-object.h:191
@ ONLY_ENUMERABLE
Definition v8-object.h:192
@ SKIP_STRINGS
Definition v8-object.h:194
IntegrityLevel
Definition v8-object.h:238
PropertyAttribute
Definition v8-object.h:149
@ DontDelete
Definition v8-object.h:157
@ DontEnum
Definition v8-object.h:155
@ None
Definition v8-object.h:151
@ ReadOnly
Definition v8-object.h:153
IndexFilter
Definition v8-object.h:227
KeyCollectionMode
Definition v8-object.h:221
KeyConversionMode
Definition v8-object.h:233
constexpr CppHeapPointerTagRange(CppHeapPointerTag lower, CppHeapPointerTag upper)
Definition v8-sandbox.h:71
#define V8_EXPORT
Definition v8config.h:860
#define V8_INLINE
Definition v8config.h:513
#define V8_DEPRECATE_SOON(message)
Definition v8config.h:627
#define V8_DEPRECATED(message)
Definition v8config.h:619
#define V8_LIKELY(condition)
Definition v8config.h:674
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:684
#define V8_ENUM_DEPRECATE_SOON(message)
Definition v8config.h:664