Line data Source code
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_H_
6 : #define V8_OBJECTS_H_
7 :
8 : #include <iosfwd>
9 : #include <memory>
10 :
11 : #include "include/v8-internal.h"
12 : #include "include/v8.h"
13 : #include "include/v8config.h"
14 : #include "src/assert-scope.h"
15 : #include "src/base/bits.h"
16 : #include "src/base/build_config.h"
17 : #include "src/base/flags.h"
18 : #include "src/base/logging.h"
19 : #include "src/checks.h"
20 : #include "src/constants-arch.h"
21 : #include "src/elements-kind.h"
22 : #include "src/field-index.h"
23 : #include "src/flags.h"
24 : #include "src/message-template.h"
25 : #include "src/objects-definitions.h"
26 : #include "src/property-details.h"
27 : #include "src/utils.h"
28 :
29 : #ifdef V8_COMPRESS_POINTERS
30 : #include "src/ptr-compr.h"
31 : #endif
32 :
33 : // Has to be the last include (doesn't have include guards):
34 : #include "src/objects/object-macros.h"
35 :
36 : //
37 : // Most object types in the V8 JavaScript are described in this file.
38 : //
39 : // Inheritance hierarchy:
40 : // - Object
41 : // - Smi (immediate small integer)
42 : // - HeapObject (superclass for everything allocated in the heap)
43 : // - JSReceiver (suitable for property access)
44 : // - JSObject
45 : // - JSArray
46 : // - JSArrayBuffer
47 : // - JSArrayBufferView
48 : // - JSTypedArray
49 : // - JSDataView
50 : // - JSBoundFunction
51 : // - JSCollection
52 : // - JSSet
53 : // - JSMap
54 : // - JSStringIterator
55 : // - JSSetIterator
56 : // - JSMapIterator
57 : // - JSWeakCollection
58 : // - JSWeakMap
59 : // - JSWeakSet
60 : // - JSRegExp
61 : // - JSFunction
62 : // - JSGeneratorObject
63 : // - JSGlobalObject
64 : // - JSGlobalProxy
65 : // - JSValue
66 : // - JSDate
67 : // - JSMessageObject
68 : // - JSModuleNamespace
69 : // - JSV8BreakIterator // If V8_INTL_SUPPORT enabled.
70 : // - JSCollator // If V8_INTL_SUPPORT enabled.
71 : // - JSDateTimeFormat // If V8_INTL_SUPPORT enabled.
72 : // - JSListFormat // If V8_INTL_SUPPORT enabled.
73 : // - JSLocale // If V8_INTL_SUPPORT enabled.
74 : // - JSNumberFormat // If V8_INTL_SUPPORT enabled.
75 : // - JSPluralRules // If V8_INTL_SUPPORT enabled.
76 : // - JSRelativeTimeFormat // If V8_INTL_SUPPORT enabled.
77 : // - JSSegmentIterator // If V8_INTL_SUPPORT enabled.
78 : // - JSSegmenter // If V8_INTL_SUPPORT enabled.
79 : // - WasmExceptionObject
80 : // - WasmGlobalObject
81 : // - WasmInstanceObject
82 : // - WasmMemoryObject
83 : // - WasmModuleObject
84 : // - WasmTableObject
85 : // - JSProxy
86 : // - FixedArrayBase
87 : // - ByteArray
88 : // - BytecodeArray
89 : // - FixedArray
90 : // - FrameArray
91 : // - HashTable
92 : // - Dictionary
93 : // - StringTable
94 : // - StringSet
95 : // - CompilationCacheTable
96 : // - MapCache
97 : // - OrderedHashTable
98 : // - OrderedHashSet
99 : // - OrderedHashMap
100 : // - FeedbackMetadata
101 : // - TemplateList
102 : // - TransitionArray
103 : // - ScopeInfo
104 : // - ModuleInfo
105 : // - ScriptContextTable
106 : // - FixedDoubleArray
107 : // - Name
108 : // - String
109 : // - SeqString
110 : // - SeqOneByteString
111 : // - SeqTwoByteString
112 : // - SlicedString
113 : // - ConsString
114 : // - ThinString
115 : // - ExternalString
116 : // - ExternalOneByteString
117 : // - ExternalTwoByteString
118 : // - InternalizedString
119 : // - SeqInternalizedString
120 : // - SeqOneByteInternalizedString
121 : // - SeqTwoByteInternalizedString
122 : // - ConsInternalizedString
123 : // - ExternalInternalizedString
124 : // - ExternalOneByteInternalizedString
125 : // - ExternalTwoByteInternalizedString
126 : // - Symbol
127 : // - Context
128 : // - NativeContext
129 : // - HeapNumber
130 : // - BigInt
131 : // - Cell
132 : // - DescriptorArray
133 : // - PropertyCell
134 : // - PropertyArray
135 : // - Code
136 : // - AbstractCode, a wrapper around Code or BytecodeArray
137 : // - Map
138 : // - Oddball
139 : // - Foreign
140 : // - SmallOrderedHashTable
141 : // - SmallOrderedHashMap
142 : // - SmallOrderedHashSet
143 : // - SharedFunctionInfo
144 : // - Struct
145 : // - AccessorInfo
146 : // - AsmWasmData
147 : // - PromiseReaction
148 : // - PromiseCapability
149 : // - AccessorPair
150 : // - AccessCheckInfo
151 : // - InterceptorInfo
152 : // - CallHandlerInfo
153 : // - EnumCache
154 : // - TemplateInfo
155 : // - FunctionTemplateInfo
156 : // - ObjectTemplateInfo
157 : // - Script
158 : // - DebugInfo
159 : // - BreakPoint
160 : // - BreakPointInfo
161 : // - StackFrameInfo
162 : // - SourcePositionTableWithFrameCache
163 : // - CodeCache
164 : // - PrototypeInfo
165 : // - Microtask
166 : // - CallbackTask
167 : // - CallableTask
168 : // - PromiseReactionJobTask
169 : // - PromiseFulfillReactionJobTask
170 : // - PromiseRejectReactionJobTask
171 : // - PromiseResolveThenableJobTask
172 : // - Module
173 : // - ModuleInfoEntry
174 : // - FeedbackCell
175 : // - FeedbackVector
176 : // - PreparseData
177 : // - UncompiledData
178 : // - UncompiledDataWithoutPreparseData
179 : // - UncompiledDataWithPreparseData
180 : //
181 : // Formats of Object::ptr_:
182 : // Smi: [31 bit signed int] 0
183 : // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01
184 :
185 : namespace v8 {
186 : namespace internal {
187 :
188 : struct InliningPosition;
189 : class PropertyDescriptorObject;
190 :
191 : // SKIP_WRITE_BARRIER skips the write barrier.
192 : // UPDATE_WEAK_WRITE_BARRIER skips the marking part of the write barrier and
193 : // only performs the generational part.
194 : // UPDATE_WRITE_BARRIER is doing the full barrier, marking and generational.
195 : enum WriteBarrierMode {
196 : SKIP_WRITE_BARRIER,
197 : UPDATE_WEAK_WRITE_BARRIER,
198 : UPDATE_WRITE_BARRIER
199 : };
200 :
201 :
202 : // PropertyNormalizationMode is used to specify whether to keep
203 : // inobject properties when normalizing properties of a JSObject.
204 : enum PropertyNormalizationMode {
205 : CLEAR_INOBJECT_PROPERTIES,
206 : KEEP_INOBJECT_PROPERTIES
207 : };
208 :
209 :
210 : // Indicates whether transitions can be added to a source map or not.
211 : enum TransitionFlag {
212 : INSERT_TRANSITION,
213 : OMIT_TRANSITION
214 : };
215 :
216 :
217 : // Indicates whether the transition is simple: the target map of the transition
218 : // either extends the current map with a new property, or it modifies the
219 : // property that was added last to the current map.
220 : enum SimpleTransitionFlag {
221 : SIMPLE_PROPERTY_TRANSITION,
222 : PROPERTY_TRANSITION,
223 : SPECIAL_TRANSITION
224 : };
225 :
226 : // Indicates whether we are only interested in the descriptors of a particular
227 : // map, or in all descriptors in the descriptor array.
228 : enum DescriptorFlag {
229 : ALL_DESCRIPTORS,
230 : OWN_DESCRIPTORS
231 : };
232 :
233 : // Instance size sentinel for objects of variable size.
234 : const int kVariableSizeSentinel = 0;
235 :
236 : // We may store the unsigned bit field as signed Smi value and do not
237 : // use the sign bit.
238 : const int kStubMajorKeyBits = 8;
239 : const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
240 :
241 : // Result of an abstract relational comparison of x and y, implemented according
242 : // to ES6 section 7.2.11 Abstract Relational Comparison.
243 : enum class ComparisonResult {
244 : kLessThan, // x < y
245 : kEqual, // x = y
246 : kGreaterThan, // x > y
247 : kUndefined // at least one of x or y was undefined or NaN
248 : };
249 :
250 : // (Returns false whenever {result} is kUndefined.)
251 : bool ComparisonResultToBool(Operation op, ComparisonResult result);
252 :
253 : enum class OnNonExistent { kThrowReferenceError, kReturnUndefined };
254 :
255 : class AbstractCode;
256 : class AccessorPair;
257 : class AccessCheckInfo;
258 : class AllocationSite;
259 : class ByteArray;
260 : class Cell;
261 : class ConsString;
262 : class DependentCode;
263 : class ElementsAccessor;
264 : class EnumCache;
265 : class FixedArrayBase;
266 : class FixedDoubleArray;
267 : class FreeSpace;
268 : class FunctionLiteral;
269 : class FunctionTemplateInfo;
270 : class JSAsyncGeneratorObject;
271 : class JSGlobalProxy;
272 : class JSPromise;
273 : class JSProxy;
274 : class KeyAccumulator;
275 : class LayoutDescriptor;
276 : class LookupIterator;
277 : class FieldType;
278 : class Module;
279 : class ModuleInfoEntry;
280 : class MutableHeapNumber;
281 : class ObjectHashTable;
282 : class ObjectTemplateInfo;
283 : class ObjectVisitor;
284 : class PreparseData;
285 : class PropertyArray;
286 : class PropertyCell;
287 : class PropertyDescriptor;
288 : class PrototypeInfo;
289 : class ReadOnlyRoots;
290 : class RegExpMatchInfo;
291 : class RootVisitor;
292 : class SafepointEntry;
293 : class ScriptContextTable;
294 : class SharedFunctionInfo;
295 : class StringStream;
296 : class Symbol;
297 : class FeedbackCell;
298 : class FeedbackMetadata;
299 : class FeedbackVector;
300 : class UncompiledData;
301 : class TemplateInfo;
302 : class TransitionArray;
303 : class TemplateList;
304 : class WasmInstanceObject;
305 : class WasmMemoryObject;
306 : template <typename T>
307 : class ZoneForwardList;
308 :
309 : #ifdef OBJECT_PRINT
310 : #define DECL_PRINTER(Name) void Name##Print(std::ostream& os); // NOLINT
311 : #else
312 : #define DECL_PRINTER(Name)
313 : #endif
314 :
315 : #define OBJECT_TYPE_LIST(V) \
316 : V(Smi) \
317 : V(LayoutDescriptor) \
318 : V(HeapObject) \
319 : V(Primitive) \
320 : V(Number) \
321 : V(Numeric)
322 :
323 : #define HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V) \
324 : V(AbstractCode) \
325 : V(AccessCheckNeeded) \
326 : V(AllocationSite) \
327 : V(ArrayList) \
328 : V(BigInt) \
329 : V(BigIntWrapper) \
330 : V(ObjectBoilerplateDescription) \
331 : V(Boolean) \
332 : V(BooleanWrapper) \
333 : V(BreakPoint) \
334 : V(BreakPointInfo) \
335 : V(ByteArray) \
336 : V(BytecodeArray) \
337 : V(CallHandlerInfo) \
338 : V(Callable) \
339 : V(Cell) \
340 : V(ClassBoilerplate) \
341 : V(Code) \
342 : V(CodeDataContainer) \
343 : V(CompilationCacheTable) \
344 : V(ConsString) \
345 : V(Constructor) \
346 : V(Context) \
347 : V(CoverageInfo) \
348 : V(DataHandler) \
349 : V(DeoptimizationData) \
350 : V(DependentCode) \
351 : V(DescriptorArray) \
352 : V(EmbedderDataArray) \
353 : V(EphemeronHashTable) \
354 : V(EnumCache) \
355 : V(ExternalOneByteString) \
356 : V(ExternalString) \
357 : V(ExternalTwoByteString) \
358 : V(FeedbackCell) \
359 : V(FeedbackMetadata) \
360 : V(FeedbackVector) \
361 : V(Filler) \
362 : V(FixedArray) \
363 : V(FixedArrayBase) \
364 : V(FixedArrayExact) \
365 : V(FixedBigInt64Array) \
366 : V(FixedBigUint64Array) \
367 : V(FixedDoubleArray) \
368 : V(FixedFloat32Array) \
369 : V(FixedFloat64Array) \
370 : V(FixedInt16Array) \
371 : V(FixedInt32Array) \
372 : V(FixedInt8Array) \
373 : V(FixedTypedArrayBase) \
374 : V(FixedUint16Array) \
375 : V(FixedUint32Array) \
376 : V(FixedUint8Array) \
377 : V(FixedUint8ClampedArray) \
378 : V(Foreign) \
379 : V(FrameArray) \
380 : V(FreeSpace) \
381 : V(Function) \
382 : V(GlobalDictionary) \
383 : V(HandlerTable) \
384 : V(HeapNumber) \
385 : V(InternalizedString) \
386 : V(JSArgumentsObject) \
387 : V(JSArgumentsObjectWithLength) \
388 : V(JSArray) \
389 : V(JSArrayBuffer) \
390 : V(JSArrayBufferView) \
391 : V(JSArrayIterator) \
392 : V(JSAsyncFromSyncIterator) \
393 : V(JSAsyncFunctionObject) \
394 : V(JSAsyncGeneratorObject) \
395 : V(JSBoundFunction) \
396 : V(JSCollection) \
397 : V(JSContextExtensionObject) \
398 : V(JSDataView) \
399 : V(JSDate) \
400 : V(JSError) \
401 : V(JSFunction) \
402 : V(JSGeneratorObject) \
403 : V(JSGlobalObject) \
404 : V(JSGlobalProxy) \
405 : V(JSMap) \
406 : V(JSMapIterator) \
407 : V(JSMessageObject) \
408 : V(JSModuleNamespace) \
409 : V(JSObject) \
410 : V(JSPromise) \
411 : V(JSProxy) \
412 : V(JSReceiver) \
413 : V(JSRegExp) \
414 : V(JSRegExpResult) \
415 : V(JSRegExpStringIterator) \
416 : V(JSSet) \
417 : V(JSSetIterator) \
418 : V(JSSloppyArgumentsObject) \
419 : V(JSStringIterator) \
420 : V(JSTypedArray) \
421 : V(JSValue) \
422 : V(JSWeakCell) \
423 : V(JSWeakRef) \
424 : V(JSWeakCollection) \
425 : V(JSWeakFactory) \
426 : V(JSWeakFactoryCleanupIterator) \
427 : V(JSWeakMap) \
428 : V(JSWeakSet) \
429 : V(LoadHandler) \
430 : V(Map) \
431 : V(MapCache) \
432 : V(Microtask) \
433 : V(ModuleInfo) \
434 : V(MutableHeapNumber) \
435 : V(Name) \
436 : V(NameDictionary) \
437 : V(NativeContext) \
438 : V(NormalizedMapCache) \
439 : V(NumberDictionary) \
440 : V(NumberWrapper) \
441 : V(ObjectHashSet) \
442 : V(ObjectHashTable) \
443 : V(Oddball) \
444 : V(OrderedHashMap) \
445 : V(OrderedHashSet) \
446 : V(OrderedNameDictionary) \
447 : V(PreparseData) \
448 : V(PromiseReactionJobTask) \
449 : V(PropertyArray) \
450 : V(PropertyCell) \
451 : V(PropertyDescriptorObject) \
452 : V(RegExpMatchInfo) \
453 : V(ScopeInfo) \
454 : V(ScriptContextTable) \
455 : V(ScriptWrapper) \
456 : V(SeqOneByteString) \
457 : V(SeqString) \
458 : V(SeqTwoByteString) \
459 : V(SharedFunctionInfo) \
460 : V(SimpleNumberDictionary) \
461 : V(SlicedString) \
462 : V(SloppyArgumentsElements) \
463 : V(SmallOrderedHashMap) \
464 : V(SmallOrderedHashSet) \
465 : V(SmallOrderedNameDictionary) \
466 : V(SourcePositionTableWithFrameCache) \
467 : V(StoreHandler) \
468 : V(String) \
469 : V(StringSet) \
470 : V(StringTable) \
471 : V(StringWrapper) \
472 : V(Struct) \
473 : V(Symbol) \
474 : V(SymbolWrapper) \
475 : V(TemplateInfo) \
476 : V(TemplateList) \
477 : V(TemplateObjectDescription) \
478 : V(ThinString) \
479 : V(TransitionArray) \
480 : V(UncompiledData) \
481 : V(UncompiledDataWithPreparseData) \
482 : V(UncompiledDataWithoutPreparseData) \
483 : V(Undetectable) \
484 : V(UniqueName) \
485 : V(WasmExceptionObject) \
486 : V(WasmGlobalObject) \
487 : V(WasmInstanceObject) \
488 : V(WasmMemoryObject) \
489 : V(WasmModuleObject) \
490 : V(WasmTableObject) \
491 : V(WeakFixedArray) \
492 : V(WeakArrayList)
493 :
494 : #ifdef V8_INTL_SUPPORT
495 : #define HEAP_OBJECT_ORDINARY_TYPE_LIST(V) \
496 : HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V) \
497 : V(JSV8BreakIterator) \
498 : V(JSCollator) \
499 : V(JSDateTimeFormat) \
500 : V(JSListFormat) \
501 : V(JSLocale) \
502 : V(JSNumberFormat) \
503 : V(JSPluralRules) \
504 : V(JSRelativeTimeFormat) \
505 : V(JSSegmentIterator) \
506 : V(JSSegmenter)
507 : #else
508 : #define HEAP_OBJECT_ORDINARY_TYPE_LIST(V) HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V)
509 : #endif // V8_INTL_SUPPORT
510 :
511 : #define HEAP_OBJECT_TEMPLATE_TYPE_LIST(V) \
512 : V(Dictionary) \
513 : V(HashTable)
514 :
515 : #define HEAP_OBJECT_TYPE_LIST(V) \
516 : HEAP_OBJECT_ORDINARY_TYPE_LIST(V) \
517 : HEAP_OBJECT_TEMPLATE_TYPE_LIST(V)
518 :
519 : #define ODDBALL_LIST(V) \
520 : V(Undefined, undefined_value) \
521 : V(Null, null_value) \
522 : V(TheHole, the_hole_value) \
523 : V(Exception, exception) \
524 : V(Uninitialized, uninitialized_value) \
525 : V(True, true_value) \
526 : V(False, false_value) \
527 : V(ArgumentsMarker, arguments_marker) \
528 : V(OptimizedOut, optimized_out) \
529 : V(StaleRegister, stale_register)
530 :
531 : // The element types selection for CreateListFromArrayLike.
532 : enum class ElementTypes { kAll, kStringAndSymbol };
533 :
534 : // Object is the abstract superclass for all classes in the
535 : // object hierarchy.
536 : // Object does not use any virtual functions to avoid the
537 : // allocation of the C++ vtable.
538 : // There must only be a single data member in Object: the Address ptr,
539 : // containing the tagged heap pointer that this Object instance refers to.
540 : // For a design overview, see https://goo.gl/Ph4CGz.
541 : class Object {
542 : public:
543 1621739475 : constexpr Object() : ptr_(kNullAddress) {}
544 92523143943 : explicit constexpr Object(Address ptr) : ptr_(ptr) {}
545 :
546 : // Make clang on Linux catch what MSVC complains about on Windows:
547 : operator bool() const = delete;
548 :
549 3799856955 : bool operator==(const Object that) const { return this->ptr() == that.ptr(); }
550 421131022 : bool operator!=(const Object that) const { return this->ptr() != that.ptr(); }
551 : // Usage in std::set requires operator<.
552 3930086 : bool operator<(const Object that) const { return this->ptr() < that.ptr(); }
553 :
554 : // Returns the tagged "(heap) object pointer" representation of this object.
555 >20778*10^7 : constexpr Address ptr() const { return ptr_; }
556 :
557 : // These operator->() overloads are required for handlified code.
558 616241310 : Object* operator->() { return this; }
559 : const Object* operator->() const { return this; }
560 :
561 : // Type testing.
562 54710099 : bool IsObject() const { return true; }
563 :
564 : #define IS_TYPE_FUNCTION_DECL(Type) V8_INLINE bool Is##Type() const;
565 : OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
566 : HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
567 : #undef IS_TYPE_FUNCTION_DECL
568 :
569 : // Oddball checks are faster when they are raw pointer comparisons, so the
570 : // isolate/read-only roots overloads should be preferred where possible.
571 : #define IS_TYPE_FUNCTION_DECL(Type, Value) \
572 : V8_INLINE bool Is##Type(Isolate* isolate) const; \
573 : V8_INLINE bool Is##Type(ReadOnlyRoots roots) const; \
574 : V8_INLINE bool Is##Type() const;
575 : ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
576 : #undef IS_TYPE_FUNCTION_DECL
577 :
578 : V8_INLINE bool IsNullOrUndefined(Isolate* isolate) const;
579 : V8_INLINE bool IsNullOrUndefined(ReadOnlyRoots roots) const;
580 : V8_INLINE bool IsNullOrUndefined() const;
581 :
582 : enum class Conversion { kToNumber, kToNumeric };
583 :
584 : #define RETURN_FAILURE(isolate, should_throw, call) \
585 : do { \
586 : if ((should_throw) == kDontThrow) { \
587 : return Just(false); \
588 : } else { \
589 : isolate->Throw(*isolate->factory()->call); \
590 : return Nothing<bool>(); \
591 : } \
592 : } while (false)
593 :
594 : #define MAYBE_RETURN(call, value) \
595 : do { \
596 : if ((call).IsNothing()) return value; \
597 : } while (false)
598 :
599 : #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>())
600 :
601 : #define MAYBE_ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call) \
602 : do { \
603 : Isolate* __isolate__ = (isolate); \
604 : if (!(call).To(&dst)) { \
605 : DCHECK(__isolate__->has_pending_exception()); \
606 : return ReadOnlyRoots(__isolate__).exception(); \
607 : } \
608 : } while (false)
609 :
610 : #define DECL_STRUCT_PREDICATE(NAME, Name, name) V8_INLINE bool Is##Name() const;
611 : STRUCT_LIST(DECL_STRUCT_PREDICATE)
612 : #undef DECL_STRUCT_PREDICATE
613 :
614 : // ES6, #sec-isarray. NOT to be confused with %_IsArray.
615 : V8_INLINE
616 : V8_WARN_UNUSED_RESULT static Maybe<bool> IsArray(Handle<Object> object);
617 :
618 : V8_INLINE bool IsHashTableBase() const;
619 : V8_INLINE bool IsSmallOrderedHashTable() const;
620 :
621 : // Extract the number.
622 : inline double Number() const;
623 : V8_INLINE bool IsNaN() const;
624 : V8_INLINE bool IsMinusZero() const;
625 : V8_EXPORT_PRIVATE bool ToInt32(int32_t* value);
626 : inline bool ToUint32(uint32_t* value) const;
627 :
628 : inline Representation OptimalRepresentation();
629 :
630 : inline ElementsKind OptimalElementsKind();
631 :
632 : inline bool FitsRepresentation(Representation representation);
633 :
634 : // Checks whether two valid primitive encodings of a property name resolve to
635 : // the same logical property. E.g., the smi 1, the string "1" and the double
636 : // 1 all refer to the same property, so this helper will return true.
637 : inline bool KeyEquals(Object other);
638 :
639 : inline bool FilterKey(PropertyFilter filter);
640 :
641 : Handle<FieldType> OptimalType(Isolate* isolate,
642 : Representation representation);
643 :
644 : inline static Handle<Object> NewStorageFor(Isolate* isolate,
645 : Handle<Object> object,
646 : Representation representation);
647 :
648 : inline static Handle<Object> WrapForRead(Isolate* isolate,
649 : Handle<Object> object,
650 : Representation representation);
651 :
652 : // Returns true if the object is of the correct type to be used as a
653 : // implementation of a JSObject's elements.
654 : inline bool HasValidElements();
655 :
656 : // ECMA-262 9.2.
657 : bool BooleanValue(Isolate* isolate);
658 :
659 : // ES6 section 7.2.11 Abstract Relational Comparison
660 : V8_WARN_UNUSED_RESULT static Maybe<ComparisonResult> Compare(
661 : Isolate* isolate, Handle<Object> x, Handle<Object> y);
662 :
663 : // ES6 section 7.2.12 Abstract Equality Comparison
664 : V8_WARN_UNUSED_RESULT static Maybe<bool> Equals(Isolate* isolate,
665 : Handle<Object> x,
666 : Handle<Object> y);
667 :
668 : // ES6 section 7.2.13 Strict Equality Comparison
669 : bool StrictEquals(Object that);
670 :
671 : // ES6 section 7.1.13 ToObject
672 : // Convert to a JSObject if needed.
673 : // native_context is used when creating wrapper object.
674 : //
675 : // Passing a non-null method_name allows us to give a more informative
676 : // error message for those cases where ToObject is being called on
677 : // the receiver of a built-in method.
678 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<JSReceiver> ToObject(
679 : Isolate* isolate, Handle<Object> object,
680 : const char* method_name = nullptr);
681 : V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> ToObject(
682 : Isolate* isolate, Handle<Object> object, Handle<Context> native_context,
683 : const char* method_name = nullptr);
684 :
685 : // ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee.
686 : V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> ConvertReceiver(
687 : Isolate* isolate, Handle<Object> object);
688 :
689 : // ES6 section 7.1.14 ToPropertyKey
690 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Name> ToName(
691 : Isolate* isolate, Handle<Object> input);
692 :
693 : // ES6 section 7.1.1 ToPrimitive
694 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToPrimitive(
695 : Handle<Object> input, ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
696 :
697 : // ES6 section 7.1.3 ToNumber
698 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToNumber(
699 : Isolate* isolate, Handle<Object> input);
700 :
701 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToNumeric(
702 : Isolate* isolate, Handle<Object> input);
703 :
704 : // ES6 section 7.1.4 ToInteger
705 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToInteger(
706 : Isolate* isolate, Handle<Object> input);
707 :
708 : // ES6 section 7.1.5 ToInt32
709 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToInt32(
710 : Isolate* isolate, Handle<Object> input);
711 :
712 : // ES6 section 7.1.6 ToUint32
713 : V8_WARN_UNUSED_RESULT inline static MaybeHandle<Object> ToUint32(
714 : Isolate* isolate, Handle<Object> input);
715 :
716 : // ES6 section 7.1.12 ToString
717 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<String> ToString(
718 : Isolate* isolate, Handle<Object> input);
719 :
720 : static Handle<String> NoSideEffectsToString(Isolate* isolate,
721 : Handle<Object> input);
722 :
723 : // ES6 section 7.1.14 ToPropertyKey
724 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToPropertyKey(
725 : Isolate* isolate, Handle<Object> value);
726 :
727 : // ES6 section 7.1.15 ToLength
728 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToLength(
729 : Isolate* isolate, Handle<Object> input);
730 :
731 : // ES6 section 7.1.17 ToIndex
732 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToIndex(
733 : Isolate* isolate, Handle<Object> input, MessageTemplate error_index);
734 :
735 : // ES6 section 7.3.9 GetMethod
736 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetMethod(
737 : Handle<JSReceiver> receiver, Handle<Name> name);
738 :
739 : // ES6 section 7.3.17 CreateListFromArrayLike
740 : V8_WARN_UNUSED_RESULT static MaybeHandle<FixedArray> CreateListFromArrayLike(
741 : Isolate* isolate, Handle<Object> object, ElementTypes element_types);
742 :
743 : // Get length property and apply ToLength.
744 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetLengthFromArrayLike(
745 : Isolate* isolate, Handle<JSReceiver> object);
746 :
747 : // ES6 section 12.5.6 The typeof Operator
748 : static Handle<String> TypeOf(Isolate* isolate, Handle<Object> object);
749 :
750 : // ES6 section 12.7 Additive Operators
751 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> Add(Isolate* isolate,
752 : Handle<Object> lhs,
753 : Handle<Object> rhs);
754 :
755 : // ES6 section 12.9 Relational Operators
756 : V8_WARN_UNUSED_RESULT static inline Maybe<bool> GreaterThan(Isolate* isolate,
757 : Handle<Object> x,
758 : Handle<Object> y);
759 : V8_WARN_UNUSED_RESULT static inline Maybe<bool> GreaterThanOrEqual(
760 : Isolate* isolate, Handle<Object> x, Handle<Object> y);
761 : V8_WARN_UNUSED_RESULT static inline Maybe<bool> LessThan(Isolate* isolate,
762 : Handle<Object> x,
763 : Handle<Object> y);
764 : V8_WARN_UNUSED_RESULT static inline Maybe<bool> LessThanOrEqual(
765 : Isolate* isolate, Handle<Object> x, Handle<Object> y);
766 :
767 : // ES6 section 7.3.19 OrdinaryHasInstance (C, O).
768 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> OrdinaryHasInstance(
769 : Isolate* isolate, Handle<Object> callable, Handle<Object> object);
770 :
771 : // ES6 section 12.10.4 Runtime Semantics: InstanceofOperator(O, C)
772 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> InstanceOf(
773 : Isolate* isolate, Handle<Object> object, Handle<Object> callable);
774 :
775 : V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
776 : GetProperty(LookupIterator* it,
777 : OnNonExistent on_non_existent = OnNonExistent::kReturnUndefined);
778 :
779 : // ES6 [[Set]] (when passed kDontThrow)
780 : // Invariants for this and related functions (unless stated otherwise):
781 : // 1) When the result is Nothing, an exception is pending.
782 : // 2) When passed kThrowOnError, the result is never Just(false).
783 : // In some cases, an exception is thrown regardless of the ShouldThrow
784 : // argument. These cases are either in accordance with the spec or not
785 : // covered by it (eg., concerning API callbacks).
786 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetProperty(
787 : LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
788 : StoreOrigin store_origin);
789 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SetProperty(
790 : Isolate* isolate, Handle<Object> object, Handle<Name> name,
791 : Handle<Object> value, LanguageMode language_mode,
792 : StoreOrigin store_origin = StoreOrigin::kMaybeKeyed);
793 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> SetPropertyOrElement(
794 : Isolate* isolate, Handle<Object> object, Handle<Name> name,
795 : Handle<Object> value, LanguageMode language_mode,
796 : StoreOrigin store_origin = StoreOrigin::kMaybeKeyed);
797 :
798 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetSuperProperty(
799 : LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
800 : StoreOrigin store_origin);
801 :
802 : V8_WARN_UNUSED_RESULT static Maybe<bool> CannotCreateProperty(
803 : Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
804 : Handle<Object> value, ShouldThrow should_throw);
805 : V8_WARN_UNUSED_RESULT static Maybe<bool> WriteToReadOnlyProperty(
806 : LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
807 : V8_WARN_UNUSED_RESULT static Maybe<bool> WriteToReadOnlyProperty(
808 : Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
809 : Handle<Object> value, ShouldThrow should_throw);
810 : V8_WARN_UNUSED_RESULT static Maybe<bool> RedefineIncompatibleProperty(
811 : Isolate* isolate, Handle<Object> name, Handle<Object> value,
812 : ShouldThrow should_throw);
813 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetDataProperty(
814 : LookupIterator* it, Handle<Object> value);
815 : V8_WARN_UNUSED_RESULT static Maybe<bool> AddDataProperty(
816 : LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
817 : ShouldThrow should_throw, StoreOrigin store_origin);
818 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
819 : Isolate* isolate, Handle<Object> object, Handle<Name> name);
820 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
821 : Handle<Object> receiver, Handle<Name> name, Handle<JSReceiver> holder);
822 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetProperty(
823 : Isolate* isolate, Handle<Object> object, Handle<Name> name);
824 :
825 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetPropertyWithAccessor(
826 : LookupIterator* it);
827 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyWithAccessor(
828 : LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
829 :
830 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetPropertyWithDefinedGetter(
831 : Handle<Object> receiver, Handle<JSReceiver> getter);
832 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyWithDefinedSetter(
833 : Handle<Object> receiver, Handle<JSReceiver> setter, Handle<Object> value,
834 : ShouldThrow should_throw);
835 :
836 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetElement(
837 : Isolate* isolate, Handle<Object> object, uint32_t index);
838 :
839 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> SetElement(
840 : Isolate* isolate, Handle<Object> object, uint32_t index,
841 : Handle<Object> value, LanguageMode language_mode);
842 :
843 : // Returns the permanent hash code associated with this object. May return
844 : // undefined if not yet created.
845 : inline Object GetHash();
846 :
847 : // Returns the permanent hash code associated with this object depending on
848 : // the actual object type. May create and store a hash code if needed and none
849 : // exists.
850 : Smi GetOrCreateHash(Isolate* isolate);
851 :
852 : // Checks whether this object has the same value as the given one. This
853 : // function is implemented according to ES5, section 9.12 and can be used
854 : // to implement the Object.is function.
855 : V8_EXPORT_PRIVATE bool SameValue(Object other);
856 :
857 : // Checks whether this object has the same value as the given one.
858 : // +0 and -0 are treated equal. Everything else is the same as SameValue.
859 : // This function is implemented according to ES6, section 7.2.4 and is used
860 : // by ES6 Map and Set.
861 : bool SameValueZero(Object other);
862 :
863 : // ES6 section 9.4.2.3 ArraySpeciesCreate (part of it)
864 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ArraySpeciesConstructor(
865 : Isolate* isolate, Handle<Object> original_array);
866 :
867 : // ES6 section 7.3.20 SpeciesConstructor ( O, defaultConstructor )
868 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SpeciesConstructor(
869 : Isolate* isolate, Handle<JSReceiver> recv,
870 : Handle<JSFunction> default_ctor);
871 :
872 : // Tries to convert an object to an array length. Returns true and sets the
873 : // output parameter if it succeeds.
874 : inline bool ToArrayLength(uint32_t* index) const;
875 :
876 : // Tries to convert an object to an array index. Returns true and sets the
877 : // output parameter if it succeeds. Equivalent to ToArrayLength, but does not
878 : // allow kMaxUInt32.
879 : V8_WARN_UNUSED_RESULT inline bool ToArrayIndex(uint32_t* index) const;
880 :
881 : // Returns true if the result of iterating over the object is the same
882 : // (including observable effects) as simply accessing the properties between 0
883 : // and length.
884 : bool IterationHasObservableEffects();
885 :
886 : //
887 : // The following GetHeapObjectXX methods mimic corresponding functionality
888 : // in MaybeObject. Having them here allows us to unify code that processes
889 : // ObjectSlots and MaybeObjectSlots.
890 : //
891 :
892 : // If this Object is a strong pointer to a HeapObject, returns true and
893 : // sets *result. Otherwise returns false.
894 : inline bool GetHeapObjectIfStrong(HeapObject* result) const;
895 :
896 : // If this Object is a strong pointer to a HeapObject (weak pointers are not
897 : // expected), returns true and sets *result. Otherwise returns false.
898 : inline bool GetHeapObject(HeapObject* result) const;
899 :
900 : // DCHECKs that this Object is a strong pointer to a HeapObject and returns
901 : // the HeapObject.
902 : inline HeapObject GetHeapObject() const;
903 :
904 : // Always returns false because Object is not expected to be a weak pointer
905 : // to a HeapObject.
906 : inline bool GetHeapObjectIfWeak(HeapObject* result) const {
907 : DCHECK(!HasWeakHeapObjectTag(ptr()));
908 : return false;
909 : }
910 : // Always returns false because Object is not expected to be a weak pointer
911 : // to a HeapObject.
912 0 : inline bool IsCleared() const { return false; }
913 :
914 : DECL_VERIFIER(Object)
915 :
916 : #ifdef VERIFY_HEAP
917 : // Verify a pointer is a valid object pointer.
918 : static void VerifyPointer(Isolate* isolate, Object p);
919 : #endif
920 :
921 : inline void VerifyApiCallResultType();
922 :
923 : // Prints this object without details.
924 : void ShortPrint(FILE* out = stdout) const;
925 :
926 : // Prints this object without details to a message accumulator.
927 : void ShortPrint(StringStream* accumulator) const;
928 :
929 : void ShortPrint(std::ostream& os) const; // NOLINT
930 :
931 : DECL_CAST(Object)
932 :
933 : // Layout description.
934 : static const int kHeaderSize = 0; // Object does not take up any space.
935 :
936 : #ifdef OBJECT_PRINT
937 : // For our gdb macros, we should perhaps change these in the future.
938 : void Print() const;
939 :
940 : // Prints this object with details.
941 : void Print(std::ostream& os) const; // NOLINT
942 : #else
943 30 : void Print() const { ShortPrint(); }
944 : void Print(std::ostream& os) const { ShortPrint(os); } // NOLINT
945 : #endif
946 :
947 : // For use with std::unordered_set.
948 : struct Hasher {
949 : size_t operator()(const Object o) const {
950 : return std::hash<v8::internal::Address>{}(o.ptr());
951 : }
952 : };
953 :
954 : // For use with std::map.
955 : struct Comparer {
956 : bool operator()(const Object a, const Object b) const {
957 0 : return a.ptr() < b.ptr();
958 : }
959 : };
960 :
961 : private:
962 : friend class CompressedObjectSlot;
963 : friend class FullObjectSlot;
964 : friend class LookupIterator;
965 : friend class StringStream;
966 :
967 : // Return the map of the root of object's prototype chain.
968 : Map GetPrototypeChainRootMap(Isolate* isolate) const;
969 :
970 : // Returns a non-SMI for JSReceivers, but returns the hash code for
971 : // simple objects. This avoids a double lookup in the cases where
972 : // we know we will add the hash to the JSReceiver if it does not
973 : // already exist.
974 : //
975 : // Despite its size, this needs to be inlined for performance
976 : // reasons.
977 : static inline Object GetSimpleHash(Object object);
978 :
979 : // Helper for SetProperty and SetSuperProperty.
980 : // Return value is only meaningful if [found] is set to true on return.
981 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyInternal(
982 : LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
983 : StoreOrigin store_origin, bool* found);
984 :
985 : V8_WARN_UNUSED_RESULT static MaybeHandle<Name> ConvertToName(
986 : Isolate* isolate, Handle<Object> input);
987 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToPropertyKey(
988 : Isolate* isolate, Handle<Object> value);
989 : V8_WARN_UNUSED_RESULT static MaybeHandle<String> ConvertToString(
990 : Isolate* isolate, Handle<Object> input);
991 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToNumberOrNumeric(
992 : Isolate* isolate, Handle<Object> input, Conversion mode);
993 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToInteger(
994 : Isolate* isolate, Handle<Object> input);
995 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToInt32(
996 : Isolate* isolate, Handle<Object> input);
997 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToUint32(
998 : Isolate* isolate, Handle<Object> input);
999 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToLength(
1000 : Isolate* isolate, Handle<Object> input);
1001 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToIndex(
1002 : Isolate* isolate, Handle<Object> input, MessageTemplate error_index);
1003 :
1004 : Address ptr_;
1005 : };
1006 :
1007 : V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const Object& obj);
1008 :
1009 : // In objects.h to be usable without objects-inl.h inclusion.
1010 21100790725 : bool Object::IsSmi() const { return HAS_SMI_TAG(ptr()); }
1011 : bool Object::IsHeapObject() const {
1012 : DCHECK_EQ(!IsSmi(), Internals::HasHeapObjectTag(ptr()));
1013 34837290 : return !IsSmi();
1014 : }
1015 :
1016 : struct Brief {
1017 : V8_EXPORT_PRIVATE explicit Brief(const Object v);
1018 : explicit Brief(const MaybeObject v);
1019 : // {value} is a tagged heap object reference (weak or strong), equivalent to
1020 : // a MaybeObject's payload. It has a plain Address type to keep #includes
1021 : // lightweight.
1022 : const Address value;
1023 : };
1024 :
1025 : V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const Brief& v);
1026 :
1027 : // Objects should never have the weak tag; this variant is for overzealous
1028 : // checking.
1029 : V8_INLINE static bool HasWeakHeapObjectTag(const Object value) {
1030 : return ((value->ptr() & kHeapObjectTagMask) == kWeakHeapObjectTag);
1031 : }
1032 :
1033 : // Heap objects typically have a map pointer in their first word. However,
1034 : // during GC other data (e.g. mark bits, forwarding addresses) is sometimes
1035 : // encoded in the first word. The class MapWord is an abstraction of the
1036 : // value in a heap object's first word.
1037 : class MapWord {
1038 : public:
1039 : // Normal state: the map word contains a map pointer.
1040 :
1041 : // Create a map word from a map pointer.
1042 : static inline MapWord FromMap(const Map map);
1043 :
1044 : // View this map word as a map pointer.
1045 : inline Map ToMap() const;
1046 :
1047 : // Scavenge collection: the map word of live objects in the from space
1048 : // contains a forwarding address (a heap object pointer in the to space).
1049 :
1050 : // True if this map word is a forwarding address for a scavenge
1051 : // collection. Only valid during a scavenge collection (specifically,
1052 : // when all map words are heap object pointers, i.e. not during a full GC).
1053 : inline bool IsForwardingAddress() const;
1054 :
1055 : // Create a map word from a forwarding address.
1056 : static inline MapWord FromForwardingAddress(HeapObject object);
1057 :
1058 : // View this map word as a forwarding address.
1059 : inline HeapObject ToForwardingAddress();
1060 :
1061 : static inline MapWord FromRawValue(uintptr_t value) {
1062 : return MapWord(value);
1063 : }
1064 :
1065 : inline uintptr_t ToRawValue() {
1066 : return value_;
1067 : }
1068 :
1069 : private:
1070 : // HeapObject calls the private constructor and directly reads the value.
1071 : friend class HeapObject;
1072 :
1073 : explicit MapWord(Address value) : value_(value) {}
1074 :
1075 : Address value_;
1076 : };
1077 :
1078 : template <int start_offset, int end_offset, int size>
1079 : class FixedBodyDescriptor;
1080 :
1081 : template <int start_offset>
1082 : class FlexibleBodyDescriptor;
1083 :
1084 : template <int start_offset>
1085 : class FlexibleWeakBodyDescriptor;
1086 :
1087 : template <class ParentBodyDescriptor, class ChildBodyDescriptor>
1088 : class SubclassBodyDescriptor;
1089 :
1090 : enum EnsureElementsMode {
1091 : DONT_ALLOW_DOUBLE_ELEMENTS,
1092 : ALLOW_COPIED_DOUBLE_ELEMENTS,
1093 : ALLOW_CONVERTED_DOUBLE_ELEMENTS
1094 : };
1095 :
1096 :
1097 : // Indicator for one component of an AccessorPair.
1098 : enum AccessorComponent {
1099 : ACCESSOR_GETTER,
1100 : ACCESSOR_SETTER
1101 : };
1102 :
1103 : enum class GetKeysConversion {
1104 : kKeepNumbers = static_cast<int>(v8::KeyConversionMode::kKeepNumbers),
1105 : kConvertToString = static_cast<int>(v8::KeyConversionMode::kConvertToString)
1106 : };
1107 :
1108 : enum class KeyCollectionMode {
1109 : kOwnOnly = static_cast<int>(v8::KeyCollectionMode::kOwnOnly),
1110 : kIncludePrototypes =
1111 : static_cast<int>(v8::KeyCollectionMode::kIncludePrototypes)
1112 : };
1113 :
1114 : // Utility superclass for stack-allocated objects that must be updated
1115 : // on gc. It provides two ways for the gc to update instances, either
1116 : // iterating or updating after gc.
1117 : class Relocatable {
1118 : public:
1119 : explicit inline Relocatable(Isolate* isolate);
1120 : inline virtual ~Relocatable();
1121 422 : virtual void IterateInstance(RootVisitor* v) {}
1122 30690 : virtual void PostGarbageCollection() { }
1123 :
1124 : static void PostGarbageCollectionProcessing(Isolate* isolate);
1125 : static int ArchiveSpacePerThread();
1126 : static char* ArchiveState(Isolate* isolate, char* to);
1127 : static char* RestoreState(Isolate* isolate, char* from);
1128 : static void Iterate(Isolate* isolate, RootVisitor* v);
1129 : static void Iterate(RootVisitor* v, Relocatable* top);
1130 : static char* Iterate(RootVisitor* v, char* t);
1131 :
1132 : private:
1133 : Isolate* isolate_;
1134 : Relocatable* prev_;
1135 : };
1136 :
1137 : // BooleanBit is a helper class for setting and getting a bit in an integer.
1138 : class BooleanBit : public AllStatic {
1139 : public:
1140 : static inline bool get(int value, int bit_position) {
1141 64968667 : return (value & (1 << bit_position)) != 0;
1142 : }
1143 :
1144 : static inline int set(int value, int bit_position, bool v) {
1145 19599686 : if (v) {
1146 8326168 : value |= (1 << bit_position);
1147 : } else {
1148 11273518 : value &= ~(1 << bit_position);
1149 : }
1150 : return value;
1151 : }
1152 : };
1153 :
1154 :
1155 : } // NOLINT, false-positive due to second-order macros.
1156 : } // NOLINT, false-positive due to second-order macros.
1157 :
1158 : #include "src/objects/object-macros-undef.h"
1159 :
1160 : #endif // V8_OBJECTS_H_
|