v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
objects.h
Go to the documentation of this file.
1// Copyright 2015 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_OBJECTS_H_
6#define V8_OBJECTS_OBJECTS_H_
7
8#include <iosfwd>
9#include <memory>
10
11#include "include/v8-internal.h"
12#include "include/v8config.h"
13#include "src/base/bits.h"
15#include "src/base/flags.h"
16#include "src/base/logging.h"
17#include "src/base/memory.h"
20#include "src/common/checks.h"
24#include "src/flags/flags.h"
31#include "src/objects/tagged.h"
32#include "src/utils/utils.h"
33
34// Has to be the last include (doesn't have include guards):
36
37namespace v8 {
38namespace internal {
39
40struct InliningPosition;
41class LookupIterator;
42class PropertyDescriptorObject;
43class ReadOnlyRoots;
44class RootVisitor;
45class PropertyKey;
46
47// UNSAFE_SKIP_WRITE_BARRIER skips the write barrier.
48// SKIP_WRITE_BARRIER skips the write barrier and asserts that this is safe in
49// the MemoryOptimizer
50// UPDATE_WRITE_BARRIER is doing the full barrier, marking and generational.
57
58// PropertyNormalizationMode is used to specify whether to keep
59// inobject properties when normalizing properties of a JSObject.
64
65// Indicates whether transitions can be added to a source map or not.
67
68// Indicates the kind of transition: the target map of the transition
69// either extends the current map with a new property, or it modifies the
70// property that was added last to the current map. Otherwise, it can
71// be a prototype transition, or anything else.
78
79// Indicates whether we are only interested in the descriptors of a particular
80// map, or in all descriptors in the descriptor array.
82
83// Instance size sentinel for objects of variable size.
85
86// We may store the unsigned bit field as signed Smi value and do not
87// use the sign bit.
88const int kStubMajorKeyBits = 8;
90
91// Result of an abstract relational comparison of x and y, implemented according
92// to ES6 section 7.2.11 Abstract Relational Comparison.
93enum class ComparisonResult {
94 kLessThan = -1, // x < y
95 kEqual = 0, // x = y
96 kGreaterThan = 1, // x > y
97 kUndefined = 2 // at least one of x or y was undefined or NaN
98};
99
100// (Returns false whenever {result} is kUndefined.)
102
104
105// The element types selection for CreateListFromArrayLike.
107
108// Currently DefineOwnPropertyIgnoreAttributes invokes the setter
109// interceptor and user-defined setters during define operations,
110// even in places where it makes more sense to invoke the definer
111// interceptor and not invoke the setter: e.g. both the definer and
112// the setter interceptors are called in Object.defineProperty().
113// kDefine allows us to implement the define semantics correctly
114// in selected locations.
115// TODO(joyee): see if we can deprecate the old behavior.
117
118// TODO(mythria): Move this to a better place.
120
121// Object is the abstract superclass for all classes in the
122// object hierarchy.
123// Object does not use any virtual functions to avoid the
124// allocation of the C++ vtable.
125// There must only be a single data member in Object: the Address ptr,
126// containing the tagged heap pointer that this Object instance refers to.
127// For a design overview, see https://goo.gl/Ph4CGz.
128class Object : public AllStatic {
129 public:
130 enum class Conversion {
131 kToNumber, // Number = Smi or HeapNumber
132 kToNumeric // Numeric = Smi or HeapNumber or BigInt
133 };
134
135 // ES6, #sec-isarray. NOT to be confused with %_IsArray.
138
139 // Extract the double value of a Number (Smi or HeapNumber).
140 static inline double NumberValue(Tagged<Number> obj);
141 static inline double NumberValue(Tagged<Object> obj);
142 static inline double NumberValue(Tagged<HeapNumber> obj);
143 static inline double NumberValue(Tagged<Smi> obj);
144 V8_EXPORT_PRIVATE static bool ToInt32(Tagged<Object> obj, int32_t* value);
145 static inline bool ToUint32(Tagged<Object> obj, uint32_t* value);
146
147 // ES6 section 7.1.5 ToIntegerOrInfinity
148 template <typename T, template <typename> typename HandleType>
149 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
151 Isolate* isolate, HandleType<T> input);
152
154 Tagged<Object> obj, PtrComprCageBase cage_base);
155
157 PtrComprCageBase cage_base);
158
159 // If {allow_coercion} is true, then a Smi will be considered to fit
160 // a Double representation, since it can be converted to a HeapNumber
161 // and stored.
162 static inline bool FitsRepresentation(Tagged<Object> obj,
163 Representation representation,
164 bool allow_coercion = true);
165
166 static inline bool FilterKey(Tagged<Object> obj, PropertyFilter filter);
167
169 Isolate* isolate,
170 Representation representation);
171
173 Isolate* isolate, Handle<UnionOf<JSAny, Hole>> object,
174 Representation representation);
175
176 template <AllocationType allocation_type = AllocationType::kYoung,
177 typename IsolateT>
178 static Handle<JSAny> WrapForRead(IsolateT* isolate, Handle<JSAny> object,
179 Representation representation);
180
181 // Returns true if the object is of the correct type to be used as an
182 // implementation of a JSObject's elements.
183 static inline bool HasValidElements(Tagged<Object> obj);
184
185 // ECMA-262 9.2.
186 template <typename IsolateT>
188 IsolateT* isolate);
189 static Tagged<Object> ToBoolean(Tagged<Object> obj, Isolate* isolate);
190
191 // ES6 section 7.2.11 Abstract Relational Comparison
194
195 // ES6 section 7.2.12 Abstract Equality Comparison
198
199 // ES6 section 7.2.13 Strict Equality Comparison
201 Tagged<Object> that);
202
203 // TODO(b/42203211): ToObject, ToString and other conversion methods are
204 // templatized by the handle type and by the object type, so that passing a
205 // Handle<T> is not ambiguous when T is a subtype of Object (it could be
206 // implicitly converted both to Handle<Object> and to DirectHandle<Object>).
207 // Here, T should be a subtype of Object, which is enforced by the last
208 // template argument and the similar restriction on Handle's constructor. When
209 // the migration to DirectHandle is complete, these functions can again accept
210 // simply a DirectHandle<Object>.
211
212 // ES6 section 7.1.13 ToObject
213 // Convert to a JSObject if needed.
214 // native_context is used when creating wrapper object.
215 //
216 // Passing a non-null method_name allows us to give a more informative
217 // error message for those cases where ToObject is being called on
218 // the receiver of a built-in method.
219 template <typename T, template <typename> typename HandleType>
220 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
221 V8_WARN_UNUSED_RESULT static inline typename HandleType<JSReceiver>::MaybeType
222 ToObject(Isolate* isolate, HandleType<T> object,
223 const char* method_name = nullptr);
225 Isolate* isolate, DirectHandle<Object> object,
226 const char* method_name = nullptr);
227
228 // ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee.
230 Isolate* isolate, DirectHandle<Object> object);
231
232 // ES6 section 7.1.14 ToPropertyKey
233 template <template <typename> typename HandleType>
234 V8_WARN_UNUSED_RESULT static inline typename HandleType<Name>::MaybeType
235 ToName(Isolate* isolate, HandleType<Object> input)
236 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>);
237
238 // ES6 section 7.1.1 ToPrimitive
239 template <typename T, template <typename> typename HandleType>
240 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
241 V8_WARN_UNUSED_RESULT static inline typename HandleType<Object>::MaybeType
242 ToPrimitive(Isolate* isolate, HandleType<T> input,
244
245 // ES6 section 7.1.3 ToNumber
246 template <typename T, template <typename> typename HandleType>
247 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
248 V8_WARN_UNUSED_RESULT static inline typename HandleType<Number>::MaybeType
249 ToNumber(Isolate* isolate, HandleType<T> input);
250
251 template <typename T, template <typename> typename HandleType>
252 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
253 V8_WARN_UNUSED_RESULT static inline typename HandleType<Object>::MaybeType
254 ToNumeric(Isolate* isolate, HandleType<T> input);
255
256 // ES6 section 7.1.4 ToInteger
257 template <typename T, template <typename> typename HandleType>
258 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
259 V8_WARN_UNUSED_RESULT static inline typename HandleType<Number>::MaybeType
260 ToInteger(Isolate* isolate, HandleType<T> input);
261
262 // ES6 section 7.1.5 ToInt32
263 template <typename T, template <typename> typename HandleType>
264 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
265 V8_WARN_UNUSED_RESULT static inline typename HandleType<Number>::MaybeType
266 ToInt32(Isolate* isolate, HandleType<T> input);
267
268 // ES6 section 7.1.6 ToUint32
269 template <typename T, template <typename> typename HandleType>
270 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
271 V8_WARN_UNUSED_RESULT static inline typename HandleType<Number>::MaybeType
272 ToUint32(Isolate* isolate, HandleType<T> input);
273
274 // ES6 section 7.1.12 ToString
275 template <typename T, template <typename> typename HandleType>
276 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
277 V8_WARN_UNUSED_RESULT static inline typename HandleType<String>::MaybeType
278 ToString(Isolate* isolate, HandleType<T> input);
279
281 Isolate* isolate, DirectHandle<Object> input);
282
284 Isolate* isolate, DirectHandle<Object> input);
285
286 // ES6 section 7.1.14 ToPropertyKey
287 template <typename T, template <typename> typename HandleType>
288 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
289 V8_WARN_UNUSED_RESULT static inline typename HandleType<Object>::MaybeType
290 ToPropertyKey(Isolate* isolate, HandleType<T> value);
291
292 // ES6 section 7.1.15 ToLength
294 Isolate* isolate, DirectHandle<Object> input);
295
296 // ES6 section 7.1.17 ToIndex
297 template <typename T, template <typename> typename HandleType>
298 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
299 V8_WARN_UNUSED_RESULT static inline typename HandleType<Object>::MaybeType
300 ToIndex(Isolate* isolate, HandleType<T> input, MessageTemplate error_index);
301
302 // ES6 section 7.3.9 GetMethod
305 DirectHandle<Name> name);
306
307 // ES6 section 7.3.17 CreateListFromArrayLike
310 ElementTypes element_types);
311
312 // Get length property and apply ToLength.
314 Isolate* isolate, DirectHandle<JSReceiver> object);
315
316 // ES6 section 12.5.6 The typeof Operator
317 static Handle<String> TypeOf(Isolate* isolate, DirectHandle<Object> object);
318
319 // ES6 section 12.7 Additive Operators
321 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs);
322
323 // ES6 section 12.9 Relational Operators
332
333 // ES6 section 7.3.19 OrdinaryHasInstance (C, O).
335 Isolate* isolate, DirectHandle<JSAny> callable,
336 DirectHandle<JSAny> object);
337
338 // ES6 section 12.10.4 Runtime Semantics: InstanceofOperator(O, C)
340 Isolate* isolate, DirectHandle<JSAny> object,
341 DirectHandle<JSAny> callable);
342
344 GetProperty(LookupIterator* it, bool is_global_reference = false);
345
346 // ES6 [[Set]] (when passed kDontThrow)
347 // Invariants for this and related functions (unless stated otherwise):
348 // 1) When the result is Nothing, an exception is pending.
349 // 2) When passed kThrowOnError, the result is never Just(false).
350 // In some cases, an exception is thrown regardless of the ShouldThrow
351 // argument. These cases are either in accordance with the spec or not
352 // covered by it (eg., concerning API callbacks).
354 LookupIterator* it, DirectHandle<Object> value, StoreOrigin store_origin,
357 SetProperty(Isolate* isolate, DirectHandle<JSAny> object,
371
373 LookupIterator* it, DirectHandle<Object> value, StoreOrigin store_origin,
375
378 DirectHandle<Object> value, Maybe<ShouldThrow> should_throw);
381 Maybe<ShouldThrow> should_throw);
384 DirectHandle<Object> value, ShouldThrow should_throw);
387 Maybe<ShouldThrow> should_throw);
392 PropertyAttributes attributes, Maybe<ShouldThrow> should_throw,
393 StoreOrigin store_origin,
395
398 PropertyAttributes attributes, Maybe<ShouldThrow> should_throw,
399 StoreOrigin store_origin);
400
402 Isolate* isolate, DirectHandle<JSAny> object, DirectHandle<Name> name);
404 Isolate* isolate, DirectHandle<JSAny> object, PropertyKey key);
406 Isolate* isolate, DirectHandle<JSAny> object, DirectHandle<Name> name);
407
409 LookupIterator* it);
412 Maybe<ShouldThrow> should_throw);
413
418 DirectHandle<Object> value, Maybe<ShouldThrow> should_throw);
419
421 Isolate* isolate, DirectHandle<JSAny> object, uint32_t index);
422
424 Isolate* isolate, DirectHandle<JSAny> object, uint32_t index,
425 DirectHandle<Object> value, ShouldThrow should_throw);
426
427 // Returns the permanent hash code associated with this object. May return
428 // undefined if not yet created.
429 static inline Tagged<Object> GetHash(Tagged<Object> obj);
430
431 // Returns the permanent hash code associated with this object depending on
432 // the actual object type. May create and store a hash code if needed and none
433 // exists.
435 Isolate* isolate);
436
437 // Checks whether this object has the same value as the given one. This
438 // function is implemented according to ES5, section 9.12 and can be used
439 // to implement the Object.is function.
441 Tagged<Object> other);
442
443 // A part of SameValue which handles Number vs. Number case.
444 // Treats NaN == NaN and +0 != -0.
445 inline static bool SameNumberValue(double number1, double number2);
446
447 // Checks whether this object has the same value as the given one.
448 // +0 and -0 are treated equal. Everything else is the same as SameValue.
449 // This function is implemented according to ES6, section 7.2.4 and is used
450 // by ES6 Map and Set.
451 static bool SameValueZero(Tagged<Object> obj, Tagged<Object> other);
452
453 // ES6 section 9.4.2.3 ArraySpeciesCreate (part of it)
455 ArraySpeciesConstructor(Isolate* isolate, DirectHandle<JSAny> original_array);
456
457 // ES6 section 7.3.20 SpeciesConstructor ( O, defaultConstructor )
459 Isolate* isolate, DirectHandle<JSReceiver> recv,
460 DirectHandle<JSFunction> default_ctor);
461
462 // Tries to convert an object to an array length. Returns true and sets the
463 // output parameter if it succeeds.
464 static inline bool ToArrayLength(Tagged<Object> obj, uint32_t* index);
465
466 // Tries to convert an object to an array index. Returns true and sets the
467 // output parameter if it succeeds. Equivalent to ToArrayLength, but does not
468 // allow kMaxUInt32.
470 uint32_t* index);
471
472 // Tries to convert an object to an index (in the range 0..size_t::max).
473 // Returns true and sets the output parameter if it succeeds.
474 static inline bool ToIntegerIndex(Tagged<Object> obj, size_t* index);
475
476 // Returns true if the result of iterating over the object is the same
477 // (including observable effects) as simply accessing the properties between 0
478 // and length.
480 Tagged<Object> obj);
481
482 // TC39 "Dynamic Code Brand Checks"
483 static bool IsCodeLike(Tagged<Object> obj, Isolate* isolate);
484
486
487#ifdef VERIFY_HEAP
488 // Verify a pointer is a valid (non-InstructionStream) object pointer.
489 // When V8_EXTERNAL_CODE_SPACE is enabled InstructionStream objects are
490 // not allowed.
491 static void VerifyPointer(Isolate* isolate, Tagged<Object> p);
492 // Verify a pointer is a valid (non-InstructionStream) object pointer,
493 // potentially a weak one.
494 // When V8_EXTERNAL_CODE_SPACE is enabled InstructionStream objects are
495 // not allowed.
496 static void VerifyMaybeObjectPointer(Isolate* isolate, Tagged<MaybeObject> p);
497 // Verify a pointer is a valid object pointer.
498 // InstructionStream objects are allowed regardless of the
499 // V8_EXTERNAL_CODE_SPACE mode.
500 static void VerifyAnyTagged(Isolate* isolate, Tagged<Object> p);
501#endif
502
503 // Layout description.
504 static const int kHeaderSize = 0; // Object does not take up any space.
505
506 // For use with std::unordered_set.
507 struct Hasher {
508 size_t operator()(const Tagged<Object> o) const {
509 return std::hash<v8::internal::Address>{}(static_cast<Tagged_t>(o.ptr()));
510 }
511 };
512
513 // For use with std::unordered_set/unordered_map when one of the objects may
514 // be located outside the main pointer compression cage, for example in
515 // trusted space. In this case, we must use full pointer comparison.
517 bool operator()(const Tagged<Object> a, const Tagged<Object> b) const {
518 return a.SafeEquals(b);
519 }
520 };
521
522 // For use with std::map.
523 struct Comparer {
524 bool operator()(const Tagged<Object> a, const Tagged<Object> b) const {
525 return a < b;
526 }
527 };
528
529 // Same as above, but can be used when one of the objects may be located
530 // outside of the main pointer compression cage, for example in trusted
531 // space. In this case, we must use full pointer comparison.
533 bool operator()(const Tagged<Object> a, const Tagged<Object> b) const {
534 return a.ptr() < b.ptr();
535 }
536 };
537
538 // If the receiver is the JSGlobalObject, the store was contextual. In case
539 // the property did not exist yet on the global object itself, we have to
540 // throw a reference error in strict mode. In sloppy mode, we continue.
541 // Returns false if the exception was thrown, otherwise true.
543 LookupIterator* it, Maybe<ShouldThrow> should_throw);
544
545 // Returns an equivalent value that's safe to share across Isolates if
546 // possible. Acts as the identity function when value->IsShared().
547 template <typename T, template <typename> typename HandleType>
548 requires(std::is_convertible_v<HandleType<T>, DirectHandle<T>>)
549 static inline typename HandleType<Object>::MaybeType Share(
550 Isolate* isolate, HandleType<T> value,
551 ShouldThrow throw_if_cannot_be_shared);
552
553 template <template <typename> typename HandleType>
554 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
555 static typename HandleType<Object>::MaybeType ShareSlow(
556 Isolate* isolate, HandleType<HeapObject> value,
557 ShouldThrow throw_if_cannot_be_shared);
558
559 // Whether this Object can be held weakly, i.e. whether it can be used as a
560 // key in WeakMap, as a key in WeakSet, as the target of a WeakRef, or as a
561 // target or unregister token of a FinalizationRegistry.
562 static inline bool CanBeHeldWeakly(Tagged<Object> obj);
563
564 private:
566 friend class FullObjectSlot;
567 friend class LookupIterator;
568 friend class StringStream;
569
570 // Return the map of the root of object's prototype chain.
572 Isolate* isolate);
573
574 // Returns a non-SMI for JSReceivers, but returns the hash code forp
575 // simple objects. This avoids a double lookup in the cases where
576 // we know we will add the hash to the JSReceiver if it does not
577 // already exist.
578 //
579 // Despite its size, this needs to be inlined for performance
580 // reasons.
581 static inline Tagged<Object> GetSimpleHash(Tagged<Object> object);
582
583 // Helper for SetProperty and SetSuperProperty.
584 // Return value is only meaningful if [found] is set to true on return.
587 Maybe<ShouldThrow> should_throw, StoreOrigin store_origin, bool* found);
588
589 template <template <typename> typename HandleType>
590 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
591 V8_WARN_UNUSED_RESULT static typename HandleType<Name>::MaybeType
592 ConvertToName(Isolate* isolate, HandleType<Object> input);
593 template <template <typename> typename HandleType>
594 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
595 V8_WARN_UNUSED_RESULT static typename HandleType<Object>::MaybeType
596 ConvertToPropertyKey(Isolate* isolate, HandleType<Object> value);
597 template <template <typename> typename HandleType>
598 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
600 typename HandleType<String>::MaybeType
601 ConvertToString(Isolate* isolate, HandleType<Object> input);
602 template <template <typename> typename HandleType>
603 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
604 V8_WARN_UNUSED_RESULT static typename HandleType<Number>::MaybeType
605 ConvertToNumber(Isolate* isolate, HandleType<Object> input);
606 template <template <typename> typename HandleType>
607 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
608 V8_WARN_UNUSED_RESULT static typename HandleType<Numeric>::MaybeType
609 ConvertToNumeric(Isolate* isolate, HandleType<Object> input);
610 template <template <typename> typename HandleType>
611 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
613 typename HandleType<Number>::MaybeType
614 ConvertToInteger(Isolate* isolate, HandleType<Object> input);
615 template <template <typename> typename HandleType>
616 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
617 V8_WARN_UNUSED_RESULT static HandleType<Number>::MaybeType ConvertToInt32(
618 Isolate* isolate, HandleType<Object> input);
619 template <template <typename> typename HandleType>
620 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
621 V8_WARN_UNUSED_RESULT static HandleType<Number>::MaybeType ConvertToUint32(
622 Isolate* isolate, HandleType<Object> input);
625 template <template <typename> typename HandleType>
626 requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
628 typename HandleType<Number>::MaybeType
629 ConvertToIndex(Isolate* isolate, HandleType<Object> input,
630 MessageTemplate error_index);
631};
632
633V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
634 Tagged<Object> obj);
635V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
637
638struct Brief {
639 template <HeapObjectReferenceType kRefType>
640 explicit Brief(TaggedImpl<kRefType, Address> v) : value{v.ptr()} {}
641 template <typename T>
642 explicit Brief(T* v) : value{v->ptr()} {}
643 // {value} is a tagged heap object reference (weak or strong), equivalent to
644 // a MaybeObject's payload. It has a plain Address type to keep #includes
645 // lightweight.
647};
648
649V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const Brief& v);
650
651// Objects should never have the weak tag; this variant is for overzealous
652// checking.
654 return HAS_WEAK_HEAP_OBJECT_TAG(value.ptr());
655}
656
657// For compatibility with TaggedImpl, and users of this header that don't pull
658// in objects-inl.h
659// TODO(leszeks): Remove once no longer needed.
660template <HeapObjectReferenceType kRefType, typename StorageType>
662 return obj.IsObject();
663}
664template <HeapObjectReferenceType kRefType, typename StorageType>
666 return obj.IsSmi();
667}
668template <HeapObjectReferenceType kRefType, typename StorageType>
670 return obj.IsHeapObject();
671}
672template <typename StorageType>
673V8_INLINE constexpr bool IsWeak(
675 return obj.IsWeak();
676}
677
678// TODO(leszeks): These exist both as free functions and members of Tagged. They
679// probably want to be cleaned up at some point.
680V8_INLINE bool IsSmi(Tagged<Object> obj) { return obj.IsSmi(); }
681V8_INLINE bool IsSmi(Tagged<HeapObject> obj) { return false; }
682V8_INLINE bool IsSmi(Tagged<Smi> obj) { return true; }
683
685V8_INLINE bool IsHeapObject(Tagged<HeapObject> obj) { return true; }
686V8_INLINE bool IsHeapObject(Tagged<Smi> obj) { return false; }
687
689
690#define IS_TYPE_FUNCTION_DECL(Type) \
691 V8_INLINE bool Is##Type(Tagged<Object> obj); \
692 V8_INLINE bool Is##Type(Tagged<Object> obj, PtrComprCageBase cage_base);
695IS_TYPE_FUNCTION_DECL(HashTableBase)
696IS_TYPE_FUNCTION_DECL(SmallOrderedHashTable)
698#undef IS_TYPE_FUNCTION_DECL
700
701// A wrapper around IsHole to make it easier to distinguish from specific hole
702// checks (e.g. IsTheHole).
705
706// Oddball checks are faster when they are raw pointer comparisons, so the
707// isolate/read-only roots overloads should be preferred where possible.
708#define IS_TYPE_FUNCTION_DECL(Type, Value, _) \
709 V8_INLINE bool Is##Type(Tagged<Object> obj, Isolate* isolate); \
710 V8_INLINE bool Is##Type(Tagged<Object> obj, LocalIsolate* isolate); \
711 V8_INLINE bool Is##Type(Tagged<Object> obj, ReadOnlyRoots roots); \
712 V8_INLINE bool Is##Type(Tagged<Object> obj);
715IS_TYPE_FUNCTION_DECL(NullOrUndefined, , /* unused */)
716#undef IS_TYPE_FUNCTION_DECL
717
722#if !V8_ENABLE_WEBASSEMBLY
723// Dummy implementation on builds without WebAssembly.
724template <typename T>
725V8_INLINE bool IsWasmObject(T obj, Isolate* = nullptr) {
726 return false;
727}
728#endif
729
732
734V8_INLINE bool IsJSApiWrapperObject(Tagged<Map> map);
735
736#define DECL_STRUCT_PREDICATE(NAME, Name, name) \
737 V8_INLINE bool Is##Name(Tagged<Object> obj); \
738 V8_INLINE bool Is##Name(Tagged<Object> obj, PtrComprCageBase cage_base);
740#undef DECL_STRUCT_PREDICATE
741
744
745// Returns whether the object is safe to share across Isolates.
746//
747// Currently, the following kinds of values can be safely shared across
748// Isolates:
749// - Smis
750// - Objects in RO space when the RO space is shared
751// - HeapNumbers in the shared old space
752// - Strings for which String::IsShared() is true
753// - JSSharedStructs
754// - JSSharedArrays
755inline bool IsShared(Tagged<Object> obj);
756
757// Prints this object without details.
758V8_EXPORT_PRIVATE void ShortPrint(Tagged<Object> obj, FILE* out = stdout);
759
760// Prints this object without details to a message accumulator.
762 StringStream* accumulator);
763
764V8_EXPORT_PRIVATE void ShortPrint(Tagged<Object> obj, std::ostream& os);
765
766#ifdef OBJECT_PRINT
767// For our gdb macros, we should perhaps change these in the future.
769
770// Prints this object with details.
771V8_EXPORT_PRIVATE void Print(Tagged<Object> obj, std::ostream& os);
772
773#else
774inline void Print(Tagged<Object> obj) { ShortPrint(obj); }
775inline void Print(Tagged<Object> obj, std::ostream& os) { ShortPrint(obj, os); }
776#endif
777
778// Heap objects typically have a map pointer in their first word. However,
779// during GC other data (e.g. mark bits, forwarding addresses) is sometimes
780// encoded in the first word. The class MapWord is an abstraction of the
781// value in a heap object's first word.
782//
783// When external code space is enabled forwarding pointers are encoded as
784// Smi values representing a diff from the source or map word host object
785// address in kObjectAlignment chunks. Such a representation has the following
786// properties:
787// a) it can hold both positive an negative diffs for full pointer compression
788// cage size (HeapObject address has only valuable 30 bits while Smis have
789// 31 bits),
790// b) it's independent of the pointer compression base and pointer compression
791// scheme.
792class MapWord {
793 public:
794 // Normal state: the map word contains a map pointer.
795
796 // Create a map word from a map pointer.
797 static inline MapWord FromMap(const Tagged<Map> map);
798
799 // View this map word as a map pointer.
800 inline Tagged<Map> ToMap() const;
801
802 // Scavenge collection: the map word of live objects in the from space
803 // contains a forwarding address (a heap object pointer in the to space).
804
805 // True if this map word is a forwarding address for a scavenge
806 // collection. Only valid during a scavenge collection (specifically,
807 // when all map words are heap object pointers, i.e. not during a full GC).
808 inline bool IsForwardingAddress() const;
809
811
812 // Create a map word from a forwarding address.
813 static inline MapWord FromForwardingAddress(Tagged<HeapObject> map_word_host,
814 Tagged<HeapObject> object);
815
816 // View this map word as a forwarding address.
818 Tagged<HeapObject> map_word_host);
819
820 constexpr inline Address ptr() const { return value_; }
821
822 // When pointer compression is enabled, MapWord is uniquely identified by
823 // the lower 32 bits. On the other hand full-value comparison is not correct
824 // because map word in a forwarding state might have corrupted upper part.
825 constexpr bool operator==(MapWord other) const {
826 return static_cast<Tagged_t>(ptr()) == static_cast<Tagged_t>(other.ptr());
827 }
828 constexpr bool operator!=(MapWord other) const {
829 return static_cast<Tagged_t>(ptr()) != static_cast<Tagged_t>(other.ptr());
830 }
831
832#ifdef V8_MAP_PACKING
833 static constexpr Address Pack(Address map) {
834 return map ^ Internals::kMapWordXorMask;
835 }
836 static constexpr Address Unpack(Address mapword) {
837 // TODO(wenyuzhao): Clear header metadata.
838 return mapword ^ Internals::kMapWordXorMask;
839 }
840 static constexpr bool IsPacked(Address mapword) {
841 return (static_cast<intptr_t>(mapword) & Internals::kMapWordXorMask) ==
842 Internals::kMapWordSignature &&
843 (0xffffffff00000000 & static_cast<intptr_t>(mapword)) != 0;
844 }
845#else
846 static constexpr bool IsPacked(Address) { return false; }
847#endif
848
849 private:
850 // HeapObject calls the private constructor and directly reads the value.
851 friend class HeapObject;
852 template <typename TFieldType, int kFieldOffset, typename CompressionScheme>
853 friend class TaggedField;
854
855 explicit constexpr MapWord(Address value) : value_(value) {}
856
858};
859
860template <int start_offset, int end_offset, int size>
862
863template <int start_offset>
865
866template <int start_offset>
868
869template <class ParentBodyDescriptor, class ChildBodyDescriptor>
871
877
878// Indicator for one component of an AccessorPair.
880
881// Utility superclass for stack-allocated objects that must be updated
882// on gc. It provides two ways for the gc to update instances, either
883// iterating or updating after gc.
885 public:
886 explicit inline Relocatable(Isolate* isolate);
887 inline virtual ~Relocatable();
888 virtual void IterateInstance(RootVisitor* v) {}
889 virtual void PostGarbageCollection() {}
890
891 static void PostGarbageCollectionProcessing(Isolate* isolate);
892 static int ArchiveSpacePerThread();
893 static char* ArchiveState(Isolate* isolate, char* to);
894 static char* RestoreState(Isolate* isolate, char* from);
895 static void Iterate(Isolate* isolate, RootVisitor* v);
896 static void Iterate(RootVisitor* v, Relocatable* top);
897 static char* Iterate(RootVisitor* v, char* t);
898
899 private:
902};
903
904// BooleanBit is a helper class for setting and getting a bit in an integer.
905class BooleanBit : public AllStatic {
906 public:
907 static inline bool get(int value, int bit_position) {
908 return (value & (1 << bit_position)) != 0;
909 }
910
911 static inline int set(int value, int bit_position, bool v) {
912 if (v) {
913 value |= (1 << bit_position);
914 } else {
915 value &= ~(1 << bit_position);
916 }
917 return value;
918 }
919};
920
921// This is an RAII helper class to emit a store-store memory barrier when
922// publishing objects allocated in the shared heap.
923//
924// This helper must be used in every Factory method that allocates a shared
925// JSObject visible user JS code. This is also used in Object::ShareSlow when
926// publishing newly shared JS primitives.
927//
928// While there is no default ordering guarantee for shared JS objects
929// (e.g. without the use of Atomics methods or postMessage, data races on
930// fields are observable), the internal VM state of a JS object must be safe
931// for publishing so that other threads do not crash.
932//
933// This barrier does not provide synchronization for publishing JS shared
934// objects. It only ensures the weaker "do not crash the VM" guarantee.
935//
936// In particular, note that memory barriers are invisible to TSAN. When
937// concurrent marking is active, field accesses are performed with relaxed
938// atomics, and TSAN is unable to detect data races in shared JS objects. When
939// concurrent marking is inactive, unordered publishes of shared JS objects in
940// JS code are reported as data race warnings by TSAN.
942 public:
944 // A release fence is used to prevent store-store reorderings of stores to
945 // VM-internal state of shared objects past any subsequent stores (i.e. the
946 // publish).
947 //
948 // On the loading side, we rely on neither the compiler nor the CPU
949 // reordering loads that are dependent on observing the address of the
950 // published shared object, like fields of the shared object.
951 std::atomic_thread_fence(std::memory_order_release);
952 }
953};
954
955} // namespace internal
956} // namespace v8
957
959
960#endif // V8_OBJECTS_OBJECTS_H_
Builtins::Kind kind
Definition builtins.cc:40
PropertyT * getter
static bool get(int value, int bit_position)
Definition objects.h:907
static int set(int value, int bit_position, bool v)
Definition objects.h:911
static constexpr bool IsPacked(Address)
Definition objects.h:846
Tagged< Map > ToMap() const
constexpr Address ptr() const
Definition objects.h:820
bool IsForwardingAddress() const
constexpr bool operator==(MapWord other) const
Definition objects.h:825
constexpr MapWord(Address value)
Definition objects.h:855
static V8_EXPORT_PRIVATE bool IsMapOrForwarded(Tagged< Map > map)
Definition objects.cc:6701
static MapWord FromForwardingAddress(Tagged< HeapObject > map_word_host, Tagged< HeapObject > object)
constexpr bool operator!=(MapWord other) const
Definition objects.h:828
static MapWord FromMap(const Tagged< Map > map)
Tagged< HeapObject > ToForwardingAddress(Tagged< HeapObject > map_word_host)
static V8_EXPORT_PRIVATE DirectHandle< String > NoSideEffectsToString(Isolate *isolate, DirectHandle< Object > input)
Definition objects.cc:687
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > ToLength(Isolate *isolate, DirectHandle< Object > input)
static V8_WARN_UNUSED_RESULT MaybeHandle< JSAny > GetPropertyWithAccessor(LookupIterator *it)
Definition objects.cc:1513
static bool CanBeHeldWeakly(Tagged< Object > obj)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Number > ConvertToLength(Isolate *isolate, DirectHandle< Object > input)
Definition objects.cc:732
static V8_WARN_UNUSED_RESULT Maybe< bool > GreaterThan(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
static Tagged< Map > GetPrototypeChainRootMap(Tagged< Object > obj, Isolate *isolate)
Definition objects.cc:1683
static V8_WARN_UNUSED_RESULT Maybe< bool > RedefineIncompatibleProperty(Isolate *isolate, DirectHandle< Object > name, DirectHandle< Object > value, Maybe< ShouldThrow > should_throw)
Definition objects.cc:2597
static V8_WARN_UNUSED_RESULT bool ToArrayIndex(Tagged< Object > obj, uint32_t *index)
static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ToInt32(Isolate *isolate, HandleType< T > input)
static bool ToArrayLength(Tagged< Object > obj, uint32_t *index)
static V8_WARN_UNUSED_RESULT HandleType< String >::MaybeType ToString(Isolate *isolate, HandleType< T > input)
static V8_EXPORT_PRIVATE Handle< UnionOf< JSAny, Hole > > NewStorageFor(Isolate *isolate, Handle< UnionOf< JSAny, Hole > > object, Representation representation)
Definition objects.cc:240
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > AddDataProperty(LookupIterator *it, DirectHandle< Object > value, PropertyAttributes attributes, Maybe< ShouldThrow > should_throw, StoreOrigin store_origin, EnforceDefineSemantics semantics=EnforceDefineSemantics::kSet)
Definition objects.cc:2667
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) V8_WARN_UNUSED_RESULT static typename HandleType< Number > static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ConvertToInt32(Isolate *isolate, HandleType< Object > input)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > SetProperty(LookupIterator *it, DirectHandle< Object > value, StoreOrigin store_origin, Maybe< ShouldThrow > should_throw=Nothing< ShouldThrow >())
Definition objects.cc:2439
static V8_WARN_UNUSED_RESULT HandleType< Name >::MaybeType ConvertToName(Isolate *isolate, HandleType< Object > input)
friend class CompressedObjectSlot
Definition objects.h:565
static V8_WARN_UNUSED_RESULT Maybe< bool > SetPropertyWithDefinedSetter(DirectHandle< JSAny > receiver, DirectHandle< JSReceiver > setter, DirectHandle< Object > value, Maybe< ShouldThrow > should_throw)
Definition objects.cc:1670
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > GetPropertyOrElement(Isolate *isolate, DirectHandle< JSAny > object, DirectHandle< Name > name)
static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ToUint32(Isolate *isolate, HandleType< T > input)
static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ToNumber(Isolate *isolate, HandleType< T > input)
static bool SameNumberValue(double number1, double number2)
static V8_WARN_UNUSED_RESULT MaybeHandle< JSAny > GetPropertyWithDefinedGetter(DirectHandle< JSAny > receiver, DirectHandle< JSReceiver > getter)
Definition objects.cc:1649
static bool SameValueZero(Tagged< Object > obj, Tagged< Object > other)
Definition objects.cc:1723
static DirectHandle< FieldType > OptimalType(Tagged< Object > obj, Isolate *isolate, Representation representation)
Definition objects.cc:224
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > OrdinaryHasInstance(Isolate *isolate, DirectHandle< JSAny > callable, DirectHandle< JSAny > object)
Definition objects.cc:1045
static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ConvertToUint32(Isolate *isolate, HandleType< Object > input)
static Handle< String > TypeOf(Isolate *isolate, DirectHandle< Object > object)
Definition objects.cc:1001
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< FixedArray > CreateListFromArrayLike(Isolate *isolate, DirectHandle< Object > object, ElementTypes element_types)
Definition objects.cc:1176
static V8_EXPORT_PRIVATE bool BooleanValue(Tagged< Object > obj, IsolateT *isolate)
static ElementsKind OptimalElementsKind(Tagged< Object > obj, PtrComprCageBase cage_base)
static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ToInteger(Isolate *isolate, HandleType< T > input)
static V8_WARN_UNUSED_RESULT HandleType< JSReceiver >::MaybeType ToObject(Isolate *isolate, HandleType< T > object, const char *method_name=nullptr)
V8_INLINE static V8_WARN_UNUSED_RESULT Maybe< bool > IsArray(DirectHandle< Object > object)
static Representation OptimalRepresentation(Tagged< Object > obj, PtrComprCageBase cage_base)
static V8_EXPORT_PRIVATE Tagged< Smi > GetOrCreateHash(Tagged< Object > obj, Isolate *isolate)
Definition objects.cc:1696
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > Add(Isolate *isolate, Handle< Object > lhs, Handle< Object > rhs)
Definition objects.cc:1016
static bool FilterKey(Tagged< Object > obj, PropertyFilter filter)
static V8_WARN_UNUSED_RESULT HandleType< Object >::MaybeType ToIndex(Isolate *isolate, HandleType< T > input, MessageTemplate error_index)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > Equals(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
Definition objects.cc:886
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
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > InstanceOf(Isolate *isolate, DirectHandle< JSAny > object, DirectHandle< JSAny > callable)
Definition objects.cc:1085
static V8_WARN_UNUSED_RESULT HandleType< Object >::MaybeType ToPropertyKey(Isolate *isolate, HandleType< T > value)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > SetElement(Isolate *isolate, DirectHandle< JSAny > object, uint32_t index, DirectHandle< Object > value, ShouldThrow should_throw)
static V8_WARN_UNUSED_RESULT Maybe< bool > LessThan(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > SetPropertyOrElement(Isolate *isolate, DirectHandle< JSAny > object, DirectHandle< Name > name, DirectHandle< Object > value, Maybe< ShouldThrow > should_throw=Nothing< ShouldThrow >(), StoreOrigin store_origin=StoreOrigin::kMaybeKeyed)
static double NumberValue(Tagged< Number > obj)
static V8_WARN_UNUSED_RESULT Maybe< bool > SetPropertyWithAccessor(LookupIterator *it, DirectHandle< Object > value, Maybe< ShouldThrow > should_throw)
Definition objects.cc:1578
static V8_WARN_UNUSED_RESULT Maybe< bool > TransitionAndWriteDataProperty(LookupIterator *it, DirectHandle< Object > value, PropertyAttributes attributes, Maybe< ShouldThrow > should_throw, StoreOrigin store_origin)
Definition objects.cc:2737
static bool CheckContextualStoreToJSGlobalObject(LookupIterator *it, Maybe< ShouldThrow > should_throw)
Definition objects.cc:2419
static V8_EXPORT_PRIVATE MaybeDirectHandle< String > NoSideEffectsToMaybeString(Isolate *isolate, DirectHandle< Object > input)
Definition objects.cc:584
static Handle< JSAny > WrapForRead(IsolateT *isolate, Handle< JSAny > object, Representation representation)
Definition objects.cc:257
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > GetLengthFromArrayLike(Isolate *isolate, DirectHandle< JSReceiver > object)
Definition objects.cc:1238
static Tagged< Object > GetHash(Tagged< Object > obj)
static V8_WARN_UNUSED_RESULT Maybe< double > IntegerValue(Isolate *isolate, HandleType< T > input)
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) V8_WARN_UNUSED_RESULT static typename HandleType< String > static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ConvertToNumber(Isolate *isolate, HandleType< Object > input)
static V8_EXPORT_PRIVATE bool SameValue(Tagged< Object > obj, Tagged< Object > other)
Definition objects.cc:1706
static V8_EXPORT_PRIVATE bool ToInt32(Tagged< Object > obj, int32_t *value)
Definition objects.cc:1438
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSReceiver > ConvertReceiver(Isolate *isolate, DirectHandle< Object > object)
Definition objects.cc:305
static V8_WARN_UNUSED_RESULT Maybe< bool > GreaterThanOrEqual(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
static V8_WARN_UNUSED_RESULT HandleType< Object >::MaybeType ToPrimitive(Isolate *isolate, HandleType< T > input, ToPrimitiveHint hint=ToPrimitiveHint::kDefault)
static V8_WARN_UNUSED_RESULT Maybe< bool > LessThanOrEqual(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
static V8_WARN_UNUSED_RESULT Maybe< bool > CannotCreateProperty(Isolate *isolate, DirectHandle< JSAny > receiver, DirectHandle< Object > name, DirectHandle< Object > value, Maybe< ShouldThrow > should_throw)
Definition objects.cc:2559
static V8_WARN_UNUSED_RESULT HandleType< Name >::MaybeType ToName(Isolate *isolate, HandleType< Object > input)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > SpeciesConstructor(Isolate *isolate, DirectHandle< JSReceiver > recv, DirectHandle< JSFunction > default_ctor)
Definition objects.cc:1791
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > GetMethod(Isolate *isolate, DirectHandle< JSReceiver > receiver, DirectHandle< Name > name)
Definition objects.cc:1125
static V8_EXPORT_PRIVATE bool StrictEquals(Tagged< Object > obj, Tagged< Object > that)
Definition objects.cc:986
static const int kHeaderSize
Definition objects.h:504
static Tagged< Object > ToBoolean(Tagged< Object > obj, Isolate *isolate)
Definition objects.cc:791
static V8_EXPORT_PRIVATE bool IterationHasObservableEffects(Tagged< Object > obj)
Definition objects.cc:1826
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Object > GetProperty(LookupIterator *it, bool is_global_reference=false)
Definition objects.cc:1248
static bool ToUint32(Tagged< Object > obj, uint32_t *value)
static bool HasValidElements(Tagged< Object > obj)
static V8_WARN_UNUSED_RESULT Maybe< bool > WriteToReadOnlyProperty(LookupIterator *it, DirectHandle< Object > value, Maybe< ShouldThrow > should_throw)
Definition objects.cc:2570
static HandleType< Object >::MaybeType ShareSlow(Isolate *isolate, HandleType< HeapObject > value, ShouldThrow throw_if_cannot_be_shared)
Definition objects.cc:2765
static V8_WARN_UNUSED_RESULT HandleType< Numeric >::MaybeType ConvertToNumeric(Isolate *isolate, HandleType< Object > input)
static bool ToIntegerIndex(Tagged< Object > obj, size_t *index)
static V8_WARN_UNUSED_RESULT Maybe< bool > SetDataProperty(LookupIterator *it, DirectHandle< Object > value)
Definition objects.cc:2604
static bool FitsRepresentation(Tagged< Object > obj, Representation representation, bool allow_coercion=true)
static V8_WARN_UNUSED_RESULT HandleType< Object >::MaybeType ConvertToPropertyKey(Isolate *isolate, HandleType< Object > value)
static V8_WARN_UNUSED_RESULT Maybe< bool > SetPropertyInternal(LookupIterator *it, DirectHandle< Object > value, Maybe< ShouldThrow > should_throw, StoreOrigin store_origin, bool *found)
Definition objects.cc:2267
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > ArraySpeciesConstructor(Isolate *isolate, DirectHandle< JSAny > original_array)
Definition objects.cc:1742
static Tagged< Object > GetSimpleHash(Tagged< Object > object)
static bool IsCodeLike(Tagged< Object > obj, Isolate *isolate)
Definition objects.cc:1860
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< ComparisonResult > Compare(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
Definition objects.cc:841
static HandleType< Object >::MaybeType Share(Isolate *isolate, HandleType< T > value, ShouldThrow throw_if_cannot_be_shared)
static V8_WARN_UNUSED_RESULT MaybeHandle< JSReceiver > ToObjectImpl(Isolate *isolate, DirectHandle< Object > object, const char *method_name=nullptr)
Definition objects.cc:273
static V8_WARN_UNUSED_RESULT HandleType< Object >::MaybeType ToNumeric(Isolate *isolate, HandleType< T > input)
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > GetElement(Isolate *isolate, DirectHandle< JSAny > object, uint32_t index)
static char * RestoreState(Isolate *isolate, char *from)
Definition objects.cc:4097
Relocatable(Isolate *isolate)
Relocatable * prev_
Definition objects.h:901
static void Iterate(Isolate *isolate, RootVisitor *v)
Definition objects.cc:4108
virtual void PostGarbageCollection()
Definition objects.h:889
static int ArchiveSpacePerThread()
Definition objects.cc:4087
static void PostGarbageCollectionProcessing(Isolate *isolate)
Definition objects.cc:4078
virtual void IterateInstance(RootVisitor *v)
Definition objects.h:888
static char * ArchiveState(Isolate *isolate, char *to)
Definition objects.cc:4090
V8_INLINE constexpr StorageType ptr() const
constexpr bool IsWeak() const
constexpr bool IsSmi() const
constexpr bool IsObject() const
constexpr bool IsHeapObject() const
constexpr V8_INLINE bool IsHeapObject() const
Definition tagged.h:507
constexpr V8_INLINE bool IsSmi() const
Definition tagged.h:508
#define HAS_WEAK_HEAP_OBJECT_TAG(value)
Definition globals.h:1778
#define EXPORT_TEMPLATE_DECLARE(export)
#define DECL_STRUCT_PREDICATE(NAME, Name, name)
#define IS_TYPE_FUNCTION_DECL(Type)
TNode< Object > receiver
ZoneVector< RpoNumber > & result
int x
@ DONT_ALLOW_DOUBLE_ELEMENTS
Definition objects.h:873
@ ALLOW_CONVERTED_DOUBLE_ELEMENTS
Definition objects.h:875
@ ALLOW_COPIED_DOUBLE_ELEMENTS
Definition objects.h:874
static V8_INLINE bool HasWeakHeapObjectTag(const Tagged< Object > value)
Definition objects.h:653
bool IsNaN(Tagged< Object > obj)
@ SKIP_WRITE_BARRIER
Definition objects.h:52
@ UPDATE_WRITE_BARRIER
Definition objects.h:55
@ UPDATE_EPHEMERON_KEY_WRITE_BARRIER
Definition objects.h:54
@ UNSAFE_SKIP_WRITE_BARRIER
Definition objects.h:53
bool ComparisonResultToBool(Operation op, ComparisonResult result)
Definition objects.cc:164
bool IsNumber(Tagged< Object > obj)
bool IsAnyHole(Tagged< Object > obj, PtrComprCageBase cage_base)
@ INSERT_TRANSITION
Definition objects.h:66
@ OMIT_TRANSITION
Definition objects.h:66
V8_INLINE constexpr bool IsWeak(TaggedImpl< HeapObjectReferenceType::WEAK, StorageType > obj)
Definition objects.h:673
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
Definition objects.h:665
bool IsPublicSymbol(Tagged< Object > obj)
kInterpreterTrampolineOffset Tagged< HeapObject >
Address Tagged_t
Definition globals.h:547
@ SIMPLE_PROPERTY_TRANSITION
Definition objects.h:73
@ PROPERTY_TRANSITION
Definition objects.h:74
@ PROTOTYPE_TRANSITION
Definition objects.h:75
@ SPECIAL_TRANSITION
Definition objects.h:76
std::ostream & operator<<(std::ostream &os, AtomicMemoryOrder order)
const int kVariableSizeSentinel
Definition objects.h:84
void Print(Tagged< Object > obj)
Definition objects.h:774
const int kStubMinorKeyBits
Definition objects.h:89
ShouldThrow GetShouldThrow(Isolate *isolate, Maybe< ShouldThrow > should_throw)
Definition objects.cc:140
bool IsShared(Tagged< Object > obj)
void ShortPrint(Tagged< Object > obj, FILE *out)
Definition objects.cc:1865
bool IsJSObjectThatCanBeTrackedAsPrototype(Tagged< Object > obj)
Definition objects-inl.h:96
typename detail::FlattenUnionHelper< Union<>, Ts... >::type UnionOf
Definition union.h:123
V8_INLINE constexpr bool IsObject(TaggedImpl< kRefType, StorageType > obj)
Definition objects.h:661
const int kSmiValueSize
V8_INLINE constexpr bool IsHeapObject(TaggedImpl< kRefType, StorageType > obj)
Definition objects.h:669
V8_INLINE bool IsWasmObject(T obj, Isolate *=nullptr)
Definition objects.h:725
const int kStubMajorKeyBits
Definition objects.h:88
NameDictionary PropertyDictionary
Definition dictionary.h:26
return value
Definition map-inl.h:893
static bool IsMinusZero(double value)
bool IsJSApiWrapperObject(Tagged< Map > map)
bool IsTaggedIndex(Tagged< Object > obj)
Definition objects-inl.h:91
bool IsPrivateSymbol(Tagged< Object > obj)
bool IsNoSharedNameSentinel(Tagged< Object > obj)
@ ACCESSOR_GETTER
Definition objects.h:879
@ ACCESSOR_SETTER
Definition objects.h:879
EnforceDefineSemantics
Definition objects.h:116
@ OWN_DESCRIPTORS
Definition objects.h:81
@ ALL_DESCRIPTORS
Definition objects.h:81
static bool IsZero(const Operand &rt)
PropertyNormalizationMode
Definition objects.h:60
@ KEEP_INOBJECT_PROPERTIES
Definition objects.h:62
@ CLEAR_INOBJECT_PROPERTIES
Definition objects.h:61
Maybe< T > Nothing()
Definition v8-maybe.h:112
#define HEAP_OBJECT_TYPE_LIST(V)
#define HOLE_LIST(V)
#define ODDBALL_LIST(V)
#define OBJECT_TYPE_LIST(V)
#define EXPORT_DECL_STATIC_VERIFIER(Name)
#define STRUCT_LIST(V)
Operation
Definition operation.h:43
#define V8_EXPORT_PRIVATE
Definition macros.h:460
Brief(TaggedImpl< kRefType, Address > v)
Definition objects.h:640
const Address value
Definition objects.h:646
bool operator()(const Tagged< Object > a, const Tagged< Object > b) const
Definition objects.h:524
bool operator()(const Tagged< Object > a, const Tagged< Object > b) const
Definition objects.h:533
size_t operator()(const Tagged< Object > o) const
Definition objects.h:508
bool operator()(const Tagged< Object > a, const Tagged< Object > b) const
Definition objects.h:517
#define V8_INLINE
Definition v8config.h:500
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671
#define V8_NODISCARD
Definition v8config.h:693