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