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 : // Has to be the last include (doesn't have include guards):
30 : #include "src/objects/object-macros.h"
31 :
32 : //
33 : // Most object types in the V8 JavaScript are described in this file.
34 : //
35 : // Inheritance hierarchy:
36 : // - Object
37 : // - Smi (immediate small integer)
38 : // - HeapObject (superclass for everything allocated in the heap)
39 : // - JSReceiver (suitable for property access)
40 : // - JSObject
41 : // - JSArray
42 : // - JSArrayBuffer
43 : // - JSArrayBufferView
44 : // - JSTypedArray
45 : // - JSDataView
46 : // - JSBoundFunction
47 : // - JSCollection
48 : // - JSSet
49 : // - JSMap
50 : // - JSStringIterator
51 : // - JSSetIterator
52 : // - JSMapIterator
53 : // - JSWeakCollection
54 : // - JSWeakMap
55 : // - JSWeakSet
56 : // - JSRegExp
57 : // - JSFunction
58 : // - JSGeneratorObject
59 : // - JSGlobalObject
60 : // - JSGlobalProxy
61 : // - JSValue
62 : // - JSDate
63 : // - JSMessageObject
64 : // - JSModuleNamespace
65 : // - JSV8BreakIterator // If V8_INTL_SUPPORT enabled.
66 : // - JSCollator // If V8_INTL_SUPPORT enabled.
67 : // - JSDateTimeFormat // If V8_INTL_SUPPORT enabled.
68 : // - JSListFormat // If V8_INTL_SUPPORT enabled.
69 : // - JSLocale // If V8_INTL_SUPPORT enabled.
70 : // - JSNumberFormat // If V8_INTL_SUPPORT enabled.
71 : // - JSPluralRules // If V8_INTL_SUPPORT enabled.
72 : // - JSRelativeTimeFormat // If V8_INTL_SUPPORT enabled.
73 : // - JSSegmentIterator // If V8_INTL_SUPPORT enabled.
74 : // - JSSegmenter // If V8_INTL_SUPPORT enabled.
75 : // - WasmExceptionObject
76 : // - WasmGlobalObject
77 : // - WasmInstanceObject
78 : // - WasmMemoryObject
79 : // - WasmModuleObject
80 : // - WasmTableObject
81 : // - JSProxy
82 : // - FixedArrayBase
83 : // - ByteArray
84 : // - BytecodeArray
85 : // - FixedArray
86 : // - FrameArray
87 : // - HashTable
88 : // - Dictionary
89 : // - StringTable
90 : // - StringSet
91 : // - CompilationCacheTable
92 : // - MapCache
93 : // - OrderedHashTable
94 : // - OrderedHashSet
95 : // - OrderedHashMap
96 : // - FeedbackMetadata
97 : // - TemplateList
98 : // - TransitionArray
99 : // - ScopeInfo
100 : // - ModuleInfo
101 : // - ScriptContextTable
102 : // - FixedDoubleArray
103 : // - Name
104 : // - String
105 : // - SeqString
106 : // - SeqOneByteString
107 : // - SeqTwoByteString
108 : // - SlicedString
109 : // - ConsString
110 : // - ThinString
111 : // - ExternalString
112 : // - ExternalOneByteString
113 : // - ExternalTwoByteString
114 : // - InternalizedString
115 : // - SeqInternalizedString
116 : // - SeqOneByteInternalizedString
117 : // - SeqTwoByteInternalizedString
118 : // - ConsInternalizedString
119 : // - ExternalInternalizedString
120 : // - ExternalOneByteInternalizedString
121 : // - ExternalTwoByteInternalizedString
122 : // - Symbol
123 : // - Context
124 : // - NativeContext
125 : // - HeapNumber
126 : // - BigInt
127 : // - Cell
128 : // - DescriptorArray
129 : // - PropertyCell
130 : // - PropertyArray
131 : // - Code
132 : // - AbstractCode, a wrapper around Code or BytecodeArray
133 : // - Map
134 : // - Oddball
135 : // - Foreign
136 : // - SmallOrderedHashTable
137 : // - SmallOrderedHashMap
138 : // - SmallOrderedHashSet
139 : // - SharedFunctionInfo
140 : // - Struct
141 : // - AccessorInfo
142 : // - AsmWasmData
143 : // - PromiseReaction
144 : // - PromiseCapability
145 : // - AccessorPair
146 : // - AccessCheckInfo
147 : // - InterceptorInfo
148 : // - CallHandlerInfo
149 : // - EnumCache
150 : // - TemplateInfo
151 : // - FunctionTemplateInfo
152 : // - ObjectTemplateInfo
153 : // - Script
154 : // - DebugInfo
155 : // - BreakPoint
156 : // - BreakPointInfo
157 : // - StackFrameInfo
158 : // - StackTraceFrame
159 : // - SourcePositionTableWithFrameCache
160 : // - CodeCache
161 : // - PrototypeInfo
162 : // - Microtask
163 : // - CallbackTask
164 : // - CallableTask
165 : // - PromiseReactionJobTask
166 : // - PromiseFulfillReactionJobTask
167 : // - PromiseRejectReactionJobTask
168 : // - PromiseResolveThenableJobTask
169 : // - Module
170 : // - ModuleInfoEntry
171 : // - FeedbackCell
172 : // - FeedbackVector
173 : // - PreparseData
174 : // - UncompiledData
175 : // - UncompiledDataWithoutPreparseData
176 : // - UncompiledDataWithPreparseData
177 : //
178 : // Formats of Object::ptr_:
179 : // Smi: [31 bit signed int] 0
180 : // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01
181 :
182 : namespace v8 {
183 : namespace internal {
184 :
185 : struct InliningPosition;
186 : class PropertyDescriptorObject;
187 :
188 : // SKIP_WRITE_BARRIER skips the write barrier.
189 : // UPDATE_WEAK_WRITE_BARRIER skips the marking part of the write barrier and
190 : // only performs the generational part.
191 : // UPDATE_WRITE_BARRIER is doing the full barrier, marking and generational.
192 : enum WriteBarrierMode {
193 : SKIP_WRITE_BARRIER,
194 : UPDATE_WEAK_WRITE_BARRIER,
195 : UPDATE_WRITE_BARRIER
196 : };
197 :
198 :
199 : // PropertyNormalizationMode is used to specify whether to keep
200 : // inobject properties when normalizing properties of a JSObject.
201 : enum PropertyNormalizationMode {
202 : CLEAR_INOBJECT_PROPERTIES,
203 : KEEP_INOBJECT_PROPERTIES
204 : };
205 :
206 :
207 : // Indicates whether transitions can be added to a source map or not.
208 : enum TransitionFlag {
209 : INSERT_TRANSITION,
210 : OMIT_TRANSITION
211 : };
212 :
213 :
214 : // Indicates whether the transition is simple: the target map of the transition
215 : // either extends the current map with a new property, or it modifies the
216 : // property that was added last to the current map.
217 : enum SimpleTransitionFlag {
218 : SIMPLE_PROPERTY_TRANSITION,
219 : PROPERTY_TRANSITION,
220 : SPECIAL_TRANSITION
221 : };
222 :
223 : // Indicates whether we are only interested in the descriptors of a particular
224 : // map, or in all descriptors in the descriptor array.
225 : enum DescriptorFlag {
226 : ALL_DESCRIPTORS,
227 : OWN_DESCRIPTORS
228 : };
229 :
230 : // Instance size sentinel for objects of variable size.
231 : const int kVariableSizeSentinel = 0;
232 :
233 : // We may store the unsigned bit field as signed Smi value and do not
234 : // use the sign bit.
235 : const int kStubMajorKeyBits = 8;
236 : const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
237 :
238 : // Result of an abstract relational comparison of x and y, implemented according
239 : // to ES6 section 7.2.11 Abstract Relational Comparison.
240 : enum class ComparisonResult {
241 : kLessThan, // x < y
242 : kEqual, // x = y
243 : kGreaterThan, // x > y
244 : kUndefined // at least one of x or y was undefined or NaN
245 : };
246 :
247 : // (Returns false whenever {result} is kUndefined.)
248 : bool ComparisonResultToBool(Operation op, ComparisonResult result);
249 :
250 : enum class OnNonExistent { kThrowReferenceError, kReturnUndefined };
251 :
252 : class AbstractCode;
253 : class AccessorPair;
254 : class AccessCheckInfo;
255 : class AllocationSite;
256 : class ByteArray;
257 : class CachedTemplateObject;
258 : class Cell;
259 : class ConsString;
260 : class DependentCode;
261 : class ElementsAccessor;
262 : class EnumCache;
263 : class FixedArrayBase;
264 : class FixedDoubleArray;
265 : class FreeSpace;
266 : class FunctionLiteral;
267 : class FunctionTemplateInfo;
268 : class JSAsyncGeneratorObject;
269 : class JSGlobalProxy;
270 : class JSPromise;
271 : class JSProxy;
272 : class JSProxyRevocableResult;
273 : class KeyAccumulator;
274 : class LayoutDescriptor;
275 : class LookupIterator;
276 : class FieldType;
277 : class Module;
278 : class ModuleInfoEntry;
279 : class MutableHeapNumber;
280 : class ObjectHashTable;
281 : class ObjectTemplateInfo;
282 : class ObjectVisitor;
283 : class PreparseData;
284 : class PropertyArray;
285 : class PropertyCell;
286 : class PropertyDescriptor;
287 : class PrototypeInfo;
288 : class ReadOnlyRoots;
289 : class RegExpMatchInfo;
290 : class RootVisitor;
291 : class SafepointEntry;
292 : class ScriptContextTable;
293 : class SharedFunctionInfo;
294 : class StringStream;
295 : class Symbol;
296 : class FeedbackCell;
297 : class FeedbackMetadata;
298 : class FeedbackVector;
299 : class UncompiledData;
300 : class TemplateInfo;
301 : class TransitionArray;
302 : class TemplateList;
303 : class WasmInstanceObject;
304 : class WasmMemoryObject;
305 : template <typename T>
306 : class ZoneForwardList;
307 :
308 : #ifdef OBJECT_PRINT
309 : #define DECL_PRINTER(Name) void Name##Print(std::ostream& os); // NOLINT
310 : #else
311 : #define DECL_PRINTER(Name)
312 : #endif
313 :
314 : #define OBJECT_TYPE_LIST(V) \
315 : V(Smi) \
316 : V(LayoutDescriptor) \
317 : V(HeapObject) \
318 : V(Primitive) \
319 : V(Number) \
320 : V(Numeric)
321 :
322 : #define HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V) \
323 : V(AbstractCode) \
324 : V(AccessCheckNeeded) \
325 : V(AllocationSite) \
326 : V(ArrayList) \
327 : V(BigInt) \
328 : V(BigIntWrapper) \
329 : V(ObjectBoilerplateDescription) \
330 : V(Boolean) \
331 : V(BooleanWrapper) \
332 : V(BreakPoint) \
333 : V(BreakPointInfo) \
334 : V(ByteArray) \
335 : V(BytecodeArray) \
336 : V(CachedTemplateObject) \
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(JSWeakRef) \
423 : V(JSWeakCollection) \
424 : V(JSFinalizationGroup) \
425 : V(JSFinalizationGroupCleanupIterator) \
426 : V(JSWeakMap) \
427 : V(JSWeakSet) \
428 : V(LoadHandler) \
429 : V(Map) \
430 : V(MapCache) \
431 : V(Microtask) \
432 : V(ModuleInfo) \
433 : V(MutableHeapNumber) \
434 : V(Name) \
435 : V(NameDictionary) \
436 : V(NativeContext) \
437 : V(NormalizedMapCache) \
438 : V(NumberDictionary) \
439 : V(NumberWrapper) \
440 : V(ObjectHashSet) \
441 : V(ObjectHashTable) \
442 : V(Oddball) \
443 : V(OrderedHashMap) \
444 : V(OrderedHashSet) \
445 : V(OrderedNameDictionary) \
446 : V(PreparseData) \
447 : V(PromiseReactionJobTask) \
448 : V(PropertyArray) \
449 : V(PropertyCell) \
450 : V(PropertyDescriptorObject) \
451 : V(RegExpMatchInfo) \
452 : V(ScopeInfo) \
453 : V(ScriptContextTable) \
454 : V(ScriptWrapper) \
455 : V(SeqOneByteString) \
456 : V(SeqString) \
457 : V(SeqTwoByteString) \
458 : V(SharedFunctionInfo) \
459 : V(SimpleNumberDictionary) \
460 : V(SlicedString) \
461 : V(SloppyArgumentsElements) \
462 : V(SmallOrderedHashMap) \
463 : V(SmallOrderedHashSet) \
464 : V(SmallOrderedNameDictionary) \
465 : V(SourcePositionTableWithFrameCache) \
466 : V(StoreHandler) \
467 : V(String) \
468 : V(StringSet) \
469 : V(StringTable) \
470 : V(StringWrapper) \
471 : V(Struct) \
472 : V(Symbol) \
473 : V(SymbolWrapper) \
474 : V(TemplateInfo) \
475 : V(TemplateList) \
476 : V(TemplateObjectDescription) \
477 : V(ThinString) \
478 : V(TransitionArray) \
479 : V(UncompiledData) \
480 : V(UncompiledDataWithPreparseData) \
481 : V(UncompiledDataWithoutPreparseData) \
482 : V(Undetectable) \
483 : V(UniqueName) \
484 : V(WasmExceptionObject) \
485 : V(WasmGlobalObject) \
486 : V(WasmInstanceObject) \
487 : V(WasmMemoryObject) \
488 : V(WasmModuleObject) \
489 : V(WasmTableObject) \
490 : V(WeakFixedArray) \
491 : V(WeakArrayList) \
492 : V(WeakCell)
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 : // TODO(mythria): Move this to a better place.
535 : ShouldThrow GetShouldThrow(Isolate* isolate, Maybe<ShouldThrow> should_throw);
536 :
537 : // Object is the abstract superclass for all classes in the
538 : // object hierarchy.
539 : // Object does not use any virtual functions to avoid the
540 : // allocation of the C++ vtable.
541 : // There must only be a single data member in Object: the Address ptr,
542 : // containing the tagged heap pointer that this Object instance refers to.
543 : // For a design overview, see https://goo.gl/Ph4CGz.
544 : class Object {
545 : public:
546 551578045 : constexpr Object() : ptr_(kNullAddress) {}
547 550748213 : explicit constexpr Object(Address ptr) : ptr_(ptr) {}
548 :
549 : // Make clang on Linux catch what MSVC complains about on Windows:
550 : operator bool() const = delete;
551 :
552 60846270 : bool operator==(const Object that) const { return this->ptr() == that.ptr(); }
553 29113837 : bool operator!=(const Object that) const { return this->ptr() != that.ptr(); }
554 : // Usage in std::set requires operator<.
555 2709034 : bool operator<(const Object that) const { return this->ptr() < that.ptr(); }
556 :
557 : // Returns the tagged "(heap) object pointer" representation of this object.
558 61275856228 : constexpr Address ptr() const { return ptr_; }
559 :
560 : // These operator->() overloads are required for handlified code.
561 373877 : Object* operator->() { return this; }
562 : const Object* operator->() const { return this; }
563 :
564 : // Type testing.
565 : bool IsObject() const { return true; }
566 :
567 : #define IS_TYPE_FUNCTION_DECL(Type) V8_INLINE bool Is##Type() const;
568 : OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
569 : HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
570 : #undef IS_TYPE_FUNCTION_DECL
571 :
572 : // Oddball checks are faster when they are raw pointer comparisons, so the
573 : // isolate/read-only roots overloads should be preferred where possible.
574 : #define IS_TYPE_FUNCTION_DECL(Type, Value) \
575 : V8_INLINE bool Is##Type(Isolate* isolate) const; \
576 : V8_INLINE bool Is##Type(ReadOnlyRoots roots) const; \
577 : V8_INLINE bool Is##Type() const;
578 : ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
579 : #undef IS_TYPE_FUNCTION_DECL
580 :
581 : V8_INLINE bool IsNullOrUndefined(Isolate* isolate) const;
582 : V8_INLINE bool IsNullOrUndefined(ReadOnlyRoots roots) const;
583 : V8_INLINE bool IsNullOrUndefined() const;
584 :
585 : enum class Conversion { kToNumber, kToNumeric };
586 :
587 : #define RETURN_FAILURE(isolate, should_throw, call) \
588 : do { \
589 : if ((should_throw) == kDontThrow) { \
590 : return Just(false); \
591 : } else { \
592 : isolate->Throw(*isolate->factory()->call); \
593 : return Nothing<bool>(); \
594 : } \
595 : } while (false)
596 :
597 : #define MAYBE_RETURN(call, value) \
598 : do { \
599 : if ((call).IsNothing()) return value; \
600 : } while (false)
601 :
602 : #define MAYBE_RETURN_NULL(call) MAYBE_RETURN(call, MaybeHandle<Object>())
603 :
604 : #define MAYBE_ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call) \
605 : do { \
606 : Isolate* __isolate__ = (isolate); \
607 : if (!(call).To(&dst)) { \
608 : DCHECK(__isolate__->has_pending_exception()); \
609 : return ReadOnlyRoots(__isolate__).exception(); \
610 : } \
611 : } while (false)
612 :
613 : #define DECL_STRUCT_PREDICATE(NAME, Name, name) V8_INLINE bool Is##Name() const;
614 : STRUCT_LIST(DECL_STRUCT_PREDICATE)
615 : #undef DECL_STRUCT_PREDICATE
616 :
617 : // ES6, #sec-isarray. NOT to be confused with %_IsArray.
618 : V8_INLINE
619 : V8_WARN_UNUSED_RESULT static Maybe<bool> IsArray(Handle<Object> object);
620 :
621 : V8_INLINE bool IsHashTableBase() const;
622 : V8_INLINE bool IsSmallOrderedHashTable() const;
623 :
624 : // Extract the number.
625 : inline double Number() const;
626 : V8_INLINE bool IsNaN() const;
627 : V8_INLINE bool IsMinusZero() const;
628 : V8_EXPORT_PRIVATE bool ToInt32(int32_t* value);
629 : inline bool ToUint32(uint32_t* value) const;
630 :
631 : inline Representation OptimalRepresentation();
632 :
633 : inline ElementsKind OptimalElementsKind();
634 :
635 : inline bool FitsRepresentation(Representation representation);
636 :
637 : inline bool FilterKey(PropertyFilter filter);
638 :
639 : Handle<FieldType> OptimalType(Isolate* isolate,
640 : Representation representation);
641 :
642 : static Handle<Object> NewStorageFor(Isolate* isolate, Handle<Object> object,
643 : Representation representation);
644 :
645 : static Handle<Object> WrapForRead(Isolate* isolate, Handle<Object> object,
646 : Representation representation);
647 :
648 : // Returns true if the object is of the correct type to be used as a
649 : // implementation of a JSObject's elements.
650 : inline bool HasValidElements();
651 :
652 : // ECMA-262 9.2.
653 : bool BooleanValue(Isolate* isolate);
654 : Object ToBoolean(Isolate* isolate);
655 :
656 : // ES6 section 7.2.11 Abstract Relational Comparison
657 : V8_WARN_UNUSED_RESULT static Maybe<ComparisonResult> Compare(
658 : Isolate* isolate, Handle<Object> x, Handle<Object> y);
659 :
660 : // ES6 section 7.2.12 Abstract Equality Comparison
661 : V8_WARN_UNUSED_RESULT static Maybe<bool> Equals(Isolate* isolate,
662 : Handle<Object> x,
663 : Handle<Object> y);
664 :
665 : // ES6 section 7.2.13 Strict Equality Comparison
666 : bool StrictEquals(Object that);
667 :
668 : // ES6 section 7.1.13 ToObject
669 : // Convert to a JSObject if needed.
670 : // native_context is used when creating wrapper object.
671 : //
672 : // Passing a non-null method_name allows us to give a more informative
673 : // error message for those cases where ToObject is being called on
674 : // the receiver of a built-in method.
675 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<JSReceiver> ToObject(
676 : Isolate* isolate, Handle<Object> object,
677 : const char* method_name = nullptr);
678 : V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> ToObjectImpl(
679 : Isolate* isolate, Handle<Object> object,
680 : const char* method_name = nullptr);
681 :
682 : // ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee.
683 : V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> ConvertReceiver(
684 : Isolate* isolate, Handle<Object> object);
685 :
686 : // ES6 section 7.1.14 ToPropertyKey
687 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Name> ToName(
688 : Isolate* isolate, Handle<Object> input);
689 :
690 : // ES6 section 7.1.1 ToPrimitive
691 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToPrimitive(
692 : Handle<Object> input, ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
693 :
694 : // ES6 section 7.1.3 ToNumber
695 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToNumber(
696 : Isolate* isolate, Handle<Object> input);
697 :
698 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToNumeric(
699 : Isolate* isolate, Handle<Object> input);
700 :
701 : // ES6 section 7.1.4 ToInteger
702 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToInteger(
703 : Isolate* isolate, Handle<Object> input);
704 :
705 : // ES6 section 7.1.5 ToInt32
706 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToInt32(
707 : Isolate* isolate, Handle<Object> input);
708 :
709 : // ES6 section 7.1.6 ToUint32
710 : V8_WARN_UNUSED_RESULT inline static MaybeHandle<Object> ToUint32(
711 : Isolate* isolate, Handle<Object> input);
712 :
713 : // ES6 section 7.1.12 ToString
714 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<String> ToString(
715 : Isolate* isolate, Handle<Object> input);
716 :
717 : static Handle<String> NoSideEffectsToString(Isolate* isolate,
718 : Handle<Object> input);
719 :
720 : // ES6 section 7.1.14 ToPropertyKey
721 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToPropertyKey(
722 : Isolate* isolate, Handle<Object> value);
723 :
724 : // ES6 section 7.1.15 ToLength
725 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToLength(
726 : Isolate* isolate, Handle<Object> input);
727 :
728 : // ES6 section 7.1.17 ToIndex
729 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToIndex(
730 : Isolate* isolate, Handle<Object> input, MessageTemplate error_index);
731 :
732 : // ES6 section 7.3.9 GetMethod
733 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetMethod(
734 : Handle<JSReceiver> receiver, Handle<Name> name);
735 :
736 : // ES6 section 7.3.17 CreateListFromArrayLike
737 : V8_WARN_UNUSED_RESULT static MaybeHandle<FixedArray> CreateListFromArrayLike(
738 : Isolate* isolate, Handle<Object> object, ElementTypes element_types);
739 :
740 : // Get length property and apply ToLength.
741 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetLengthFromArrayLike(
742 : Isolate* isolate, Handle<JSReceiver> object);
743 :
744 : // ES6 section 12.5.6 The typeof Operator
745 : static Handle<String> TypeOf(Isolate* isolate, Handle<Object> object);
746 :
747 : // ES6 section 12.7 Additive Operators
748 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> Add(Isolate* isolate,
749 : Handle<Object> lhs,
750 : Handle<Object> rhs);
751 :
752 : // ES6 section 12.9 Relational Operators
753 : V8_WARN_UNUSED_RESULT static inline Maybe<bool> GreaterThan(Isolate* isolate,
754 : Handle<Object> x,
755 : Handle<Object> y);
756 : V8_WARN_UNUSED_RESULT static inline Maybe<bool> GreaterThanOrEqual(
757 : Isolate* isolate, Handle<Object> x, Handle<Object> y);
758 : V8_WARN_UNUSED_RESULT static inline Maybe<bool> LessThan(Isolate* isolate,
759 : Handle<Object> x,
760 : Handle<Object> y);
761 : V8_WARN_UNUSED_RESULT static inline Maybe<bool> LessThanOrEqual(
762 : Isolate* isolate, Handle<Object> x, Handle<Object> y);
763 :
764 : // ES6 section 7.3.19 OrdinaryHasInstance (C, O).
765 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> OrdinaryHasInstance(
766 : Isolate* isolate, Handle<Object> callable, Handle<Object> object);
767 :
768 : // ES6 section 12.10.4 Runtime Semantics: InstanceofOperator(O, C)
769 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> InstanceOf(
770 : Isolate* isolate, Handle<Object> object, Handle<Object> callable);
771 :
772 : V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Object>
773 : GetProperty(LookupIterator* it,
774 : OnNonExistent on_non_existent = OnNonExistent::kReturnUndefined);
775 :
776 : // ES6 [[Set]] (when passed kDontThrow)
777 : // Invariants for this and related functions (unless stated otherwise):
778 : // 1) When the result is Nothing, an exception is pending.
779 : // 2) When passed kThrowOnError, the result is never Just(false).
780 : // In some cases, an exception is thrown regardless of the ShouldThrow
781 : // argument. These cases are either in accordance with the spec or not
782 : // covered by it (eg., concerning API callbacks).
783 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetProperty(
784 : LookupIterator* it, Handle<Object> value, StoreOrigin store_origin,
785 : Maybe<ShouldThrow> should_throw = Nothing<ShouldThrow>());
786 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SetProperty(
787 : Isolate* isolate, Handle<Object> object, Handle<Name> name,
788 : Handle<Object> value, StoreOrigin store_origin = StoreOrigin::kMaybeKeyed,
789 : Maybe<ShouldThrow> should_throw = Nothing<ShouldThrow>());
790 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> SetPropertyOrElement(
791 : Isolate* isolate, Handle<Object> object, Handle<Name> name,
792 : Handle<Object> value,
793 : Maybe<ShouldThrow> should_throw = Nothing<ShouldThrow>(),
794 : StoreOrigin store_origin = StoreOrigin::kMaybeKeyed);
795 :
796 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetSuperProperty(
797 : LookupIterator* it, Handle<Object> value, StoreOrigin store_origin,
798 : Maybe<ShouldThrow> should_throw = Nothing<ShouldThrow>());
799 :
800 : V8_WARN_UNUSED_RESULT static Maybe<bool> CannotCreateProperty(
801 : Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
802 : Handle<Object> value, Maybe<ShouldThrow> should_throw);
803 : V8_WARN_UNUSED_RESULT static Maybe<bool> WriteToReadOnlyProperty(
804 : LookupIterator* it, Handle<Object> value,
805 : Maybe<ShouldThrow> should_throw);
806 : V8_WARN_UNUSED_RESULT static Maybe<bool> WriteToReadOnlyProperty(
807 : Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
808 : Handle<Object> value, ShouldThrow should_throw);
809 : V8_WARN_UNUSED_RESULT static Maybe<bool> RedefineIncompatibleProperty(
810 : Isolate* isolate, Handle<Object> name, Handle<Object> value,
811 : Maybe<ShouldThrow> should_throw);
812 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetDataProperty(
813 : LookupIterator* it, Handle<Object> value);
814 : V8_WARN_UNUSED_RESULT static Maybe<bool> AddDataProperty(
815 : LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
816 : Maybe<ShouldThrow> should_throw, StoreOrigin store_origin);
817 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
818 : Isolate* isolate, Handle<Object> object, Handle<Name> name);
819 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
820 : Handle<Object> receiver, Handle<Name> name, Handle<JSReceiver> holder);
821 : V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetProperty(
822 : Isolate* isolate, Handle<Object> object, Handle<Name> name);
823 :
824 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetPropertyWithAccessor(
825 : LookupIterator* it);
826 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyWithAccessor(
827 : LookupIterator* it, Handle<Object> value,
828 : Maybe<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 : Maybe<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, ShouldThrow should_throw);
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 : 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 2912 : inline static Object cast(Object object) { return object; }
932 : inline static Object unchecked_cast(Object object) { return object; }
933 :
934 : // Layout description.
935 : static const int kHeaderSize = 0; // Object does not take up any space.
936 :
937 : #ifdef OBJECT_PRINT
938 : // For our gdb macros, we should perhaps change these in the future.
939 : void Print() const;
940 :
941 : // Prints this object with details.
942 : void Print(std::ostream& os) const; // NOLINT
943 : #else
944 24 : void Print() const { ShortPrint(); }
945 0 : void Print(std::ostream& os) const { ShortPrint(os); } // NOLINT
946 : #endif
947 :
948 : // For use with std::unordered_set.
949 : struct Hasher {
950 : size_t operator()(const Object o) const {
951 : return std::hash<v8::internal::Address>{}(o.ptr());
952 : }
953 : };
954 :
955 : // For use with std::map.
956 : struct Comparer {
957 : bool operator()(const Object a, const Object b) const {
958 0 : return a.ptr() < b.ptr();
959 : }
960 : };
961 :
962 : private:
963 : friend class CompressedObjectSlot;
964 : friend class FullObjectSlot;
965 : friend class LookupIterator;
966 : friend class StringStream;
967 :
968 : // Return the map of the root of object's prototype chain.
969 : Map GetPrototypeChainRootMap(Isolate* isolate) const;
970 :
971 : // Returns a non-SMI for JSReceivers, but returns the hash code for
972 : // simple objects. This avoids a double lookup in the cases where
973 : // we know we will add the hash to the JSReceiver if it does not
974 : // already exist.
975 : //
976 : // Despite its size, this needs to be inlined for performance
977 : // reasons.
978 : static inline Object GetSimpleHash(Object object);
979 :
980 : // Helper for SetProperty and SetSuperProperty.
981 : // Return value is only meaningful if [found] is set to true on return.
982 : V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyInternal(
983 : LookupIterator* it, Handle<Object> value, Maybe<ShouldThrow> should_throw,
984 : StoreOrigin store_origin, bool* found);
985 :
986 : V8_WARN_UNUSED_RESULT static MaybeHandle<Name> ConvertToName(
987 : Isolate* isolate, Handle<Object> input);
988 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToPropertyKey(
989 : Isolate* isolate, Handle<Object> value);
990 : V8_WARN_UNUSED_RESULT static MaybeHandle<String> ConvertToString(
991 : Isolate* isolate, Handle<Object> input);
992 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToNumberOrNumeric(
993 : Isolate* isolate, Handle<Object> input, Conversion mode);
994 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToInteger(
995 : Isolate* isolate, Handle<Object> input);
996 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToInt32(
997 : Isolate* isolate, Handle<Object> input);
998 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToUint32(
999 : Isolate* isolate, Handle<Object> input);
1000 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToLength(
1001 : Isolate* isolate, Handle<Object> input);
1002 : V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ConvertToIndex(
1003 : Isolate* isolate, Handle<Object> input, MessageTemplate error_index);
1004 :
1005 : Address ptr_;
1006 : };
1007 :
1008 : V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const Object& obj);
1009 :
1010 : // In objects.h to be usable without objects-inl.h inclusion.
1011 22356259720 : bool Object::IsSmi() const { return HAS_SMI_TAG(ptr()); }
1012 : bool Object::IsHeapObject() const {
1013 : DCHECK_EQ(!IsSmi(), Internals::HasHeapObjectTag(ptr()));
1014 31324414 : return !IsSmi();
1015 : }
1016 :
1017 : struct Brief {
1018 : V8_EXPORT_PRIVATE explicit Brief(const Object v);
1019 : explicit Brief(const MaybeObject v);
1020 : // {value} is a tagged heap object reference (weak or strong), equivalent to
1021 : // a MaybeObject's payload. It has a plain Address type to keep #includes
1022 : // lightweight.
1023 : const Address value;
1024 : };
1025 :
1026 : V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const Brief& v);
1027 :
1028 : // Objects should never have the weak tag; this variant is for overzealous
1029 : // checking.
1030 : V8_INLINE static bool HasWeakHeapObjectTag(const Object value) {
1031 : return ((value->ptr() & kHeapObjectTagMask) == kWeakHeapObjectTag);
1032 : }
1033 :
1034 : // Heap objects typically have a map pointer in their first word. However,
1035 : // during GC other data (e.g. mark bits, forwarding addresses) is sometimes
1036 : // encoded in the first word. The class MapWord is an abstraction of the
1037 : // value in a heap object's first word.
1038 : class MapWord {
1039 : public:
1040 : // Normal state: the map word contains a map pointer.
1041 :
1042 : // Create a map word from a map pointer.
1043 : static inline MapWord FromMap(const Map map);
1044 :
1045 : // View this map word as a map pointer.
1046 : inline Map ToMap() const;
1047 :
1048 : // Scavenge collection: the map word of live objects in the from space
1049 : // contains a forwarding address (a heap object pointer in the to space).
1050 :
1051 : // True if this map word is a forwarding address for a scavenge
1052 : // collection. Only valid during a scavenge collection (specifically,
1053 : // when all map words are heap object pointers, i.e. not during a full GC).
1054 : inline bool IsForwardingAddress() const;
1055 :
1056 : // Create a map word from a forwarding address.
1057 : static inline MapWord FromForwardingAddress(HeapObject object);
1058 :
1059 : // View this map word as a forwarding address.
1060 : inline HeapObject ToForwardingAddress();
1061 :
1062 : static inline MapWord FromRawValue(uintptr_t value) {
1063 : return MapWord(value);
1064 : }
1065 :
1066 : inline uintptr_t ToRawValue() {
1067 : return value_;
1068 : }
1069 :
1070 : private:
1071 : // HeapObject calls the private constructor and directly reads the value.
1072 : friend class HeapObject;
1073 :
1074 10304 : explicit MapWord(Address value) : value_(value) {}
1075 :
1076 : Address value_;
1077 : };
1078 :
1079 : template <int start_offset, int end_offset, int size>
1080 : class FixedBodyDescriptor;
1081 :
1082 : template <int start_offset>
1083 : class FlexibleBodyDescriptor;
1084 :
1085 : template <int start_offset>
1086 : class FlexibleWeakBodyDescriptor;
1087 :
1088 : template <class ParentBodyDescriptor, class ChildBodyDescriptor>
1089 : class SubclassBodyDescriptor;
1090 :
1091 : enum EnsureElementsMode {
1092 : DONT_ALLOW_DOUBLE_ELEMENTS,
1093 : ALLOW_COPIED_DOUBLE_ELEMENTS,
1094 : ALLOW_CONVERTED_DOUBLE_ELEMENTS
1095 : };
1096 :
1097 :
1098 : // Indicator for one component of an AccessorPair.
1099 : enum AccessorComponent {
1100 : ACCESSOR_GETTER,
1101 : ACCESSOR_SETTER
1102 : };
1103 :
1104 : enum class GetKeysConversion {
1105 : kKeepNumbers = static_cast<int>(v8::KeyConversionMode::kKeepNumbers),
1106 : kConvertToString = static_cast<int>(v8::KeyConversionMode::kConvertToString)
1107 : };
1108 :
1109 : enum class KeyCollectionMode {
1110 : kOwnOnly = static_cast<int>(v8::KeyCollectionMode::kOwnOnly),
1111 : kIncludePrototypes =
1112 : static_cast<int>(v8::KeyCollectionMode::kIncludePrototypes)
1113 : };
1114 :
1115 : // Utility superclass for stack-allocated objects that must be updated
1116 : // on gc. It provides two ways for the gc to update instances, either
1117 : // iterating or updating after gc.
1118 : class Relocatable {
1119 : public:
1120 : explicit inline Relocatable(Isolate* isolate);
1121 : inline virtual ~Relocatable();
1122 74 : virtual void IterateInstance(RootVisitor* v) {}
1123 31309 : virtual void PostGarbageCollection() { }
1124 :
1125 : static void PostGarbageCollectionProcessing(Isolate* isolate);
1126 : static int ArchiveSpacePerThread();
1127 : static char* ArchiveState(Isolate* isolate, char* to);
1128 : static char* RestoreState(Isolate* isolate, char* from);
1129 : static void Iterate(Isolate* isolate, RootVisitor* v);
1130 : static void Iterate(RootVisitor* v, Relocatable* top);
1131 : static char* Iterate(RootVisitor* v, char* t);
1132 :
1133 : private:
1134 : Isolate* isolate_;
1135 : Relocatable* prev_;
1136 : };
1137 :
1138 : // BooleanBit is a helper class for setting and getting a bit in an integer.
1139 : class BooleanBit : public AllStatic {
1140 : public:
1141 : static inline bool get(int value, int bit_position) {
1142 63852919 : return (value & (1 << bit_position)) != 0;
1143 : }
1144 :
1145 : static inline int set(int value, int bit_position, bool v) {
1146 18746586 : if (v) {
1147 7861482 : value |= (1 << bit_position);
1148 : } else {
1149 10885104 : value &= ~(1 << bit_position);
1150 : }
1151 : return value;
1152 : }
1153 : };
1154 :
1155 :
1156 : } // NOLINT, false-positive due to second-order macros.
1157 : } // NOLINT, false-positive due to second-order macros.
1158 :
1159 : #include "src/objects/object-macros-undef.h"
1160 :
1161 : #endif // V8_OBJECTS_H_
|