v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
map.h
Go to the documentation of this file.
1// Copyright 2017 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_MAP_H_
6#define V8_OBJECTS_MAP_H_
7
8#include <optional>
9
11#include "src/base/bit-field.h"
13#include "src/common/globals.h"
14#include "src/objects/code.h"
19#include "src/objects/objects.h"
21#include "src/roots/roots.h"
22#include "torque-generated/bit-fields.h"
23#include "torque-generated/visitor-lists.h"
24
25// Has to be the last include (doesn't have include guards):
27
28namespace v8::internal {
29
30class WasmTypeInfo;
31
33
34#define DATA_ONLY_VISITOR_ID_LIST(V) \
35 V(BigInt) \
36 V(CoverageInfo) \
37 V(FeedbackMetadata) \
38 V(Filler) \
39 V(HeapNumber) \
40 V(SeqOneByteString) \
41 V(SeqTwoByteString) \
42 IF_WASM(V, WasmNull)
43
44#define POINTER_VISITOR_ID_LIST(V) \
45 V(AccessorInfo) \
46 V(AllocationSite) \
47 V(BytecodeWrapper) \
48 V(CallSiteInfo) \
49 V(Cell) \
50 V(CodeWrapper) \
51 V(ConsString) \
52 V(ContextSidePropertyCell) \
53 V(DataHandler) \
54 V(DebugInfo) \
55 V(EmbedderDataArray) \
56 V(EphemeronHashTable) \
57 V(ExternalString) \
58 V(FeedbackCell) \
59 V(Foreign) \
60 V(FreeSpace) \
61 V(FunctionTemplateInfo) \
62 V(Hole) \
63 V(InterceptorInfo) \
64 V(JSApiObject) \
65 V(JSArrayBuffer) \
66 V(JSDataViewOrRabGsabDataView) \
67 V(JSDate) \
68 V(JSExternalObject) \
69 V(JSFinalizationRegistry) \
70 V(JSFunction) \
71 V(JSObject) \
72 V(JSObjectFast) \
73 V(JSRegExp) \
74 V(JSSynchronizationPrimitive) \
75 V(JSTypedArray) \
76 V(JSWeakCollection) \
77 V(JSWeakRef) \
78 V(Map) \
79 V(NativeContext) \
80 V(Oddball) \
81 V(PreparseData) \
82 V(PropertyArray) \
83 V(PropertyCell) \
84 V(PrototypeInfo) \
85 V(RegExpBoilerplateDescription) \
86 V(RegExpDataWrapper) \
87 V(SharedFunctionInfo) \
88 V(ShortcutCandidate) \
89 V(SlicedString) \
90 V(SloppyArgumentsElements) \
91 V(SmallOrderedHashMap) \
92 V(SmallOrderedHashSet) \
93 V(SmallOrderedNameDictionary) \
94 V(SourceTextModule) \
95 V(Struct) \
96 V(SwissNameDictionary) \
97 V(Symbol) \
98 V(SyntheticModule) \
99 V(ThinString) \
100 V(TransitionArray) \
101 IF_WASM(V, WasmArray) \
102 IF_WASM(V, WasmFuncRef) \
103 IF_WASM(V, WasmGlobalObject) \
104 IF_WASM(V, WasmInstanceObject) \
105 IF_WASM(V, WasmMemoryMapDescriptor) \
106 IF_WASM(V, WasmMemoryObject) \
107 IF_WASM(V, WasmResumeData) \
108 IF_WASM(V, WasmStruct) \
109 IF_WASM(V, WasmSuspenderObject) \
110 IF_WASM(V, WasmSuspendingObject) \
111 IF_WASM(V, WasmTableObject) \
112 IF_WASM(V, WasmTagObject) \
113 IF_WASM(V, WasmTypeInfo) \
114 V(WeakCell) \
115 SIMPLE_HEAP_OBJECT_LIST1(V)
116
117#define TORQUE_VISITOR_ID_LIST(V) \
118 TORQUE_DATA_ONLY_VISITOR_ID_LIST(V) \
119 TORQUE_POINTER_VISITOR_ID_LIST(V)
120
121#define TRUSTED_VISITOR_ID_LIST(V) CONCRETE_TRUSTED_OBJECT_TYPE_LIST1(V)
122
123// Objects with the same visitor id are processed in the same way by
124// the heap visitors. The visitor ids for data only objects must precede
125// other visitor ids. We rely on kDataOnlyVisitorIdCount for quick check
126// of whether an object contains only data or may contain pointers.
128#define VISITOR_ID_ENUM_DECL(id) kVisit##id,
129 // clang-format off
131 TORQUE_DATA_ONLY_VISITOR_ID_LIST(VISITOR_ID_ENUM_DECL)
134 TORQUE_POINTER_VISITOR_ID_LIST(VISITOR_ID_ENUM_DECL)
137// clang-format on
138#undef VISITOR_ID_ENUM_DECL
140
141enum class ObjectFields {
142 kDataOnly,
144};
145
149
150#include "torque-generated/src/objects/map-tq.inc"
151
152// All heap objects have a Map that describes their structure.
153// A Map contains information about:
154// - Size information about the object
155// - How to iterate over an object (for garbage collection)
156//
157// Map layout:
158// +---------------+-------------------------------------------------+
159// | _ Type _ | _ Description _ |
160// +---------------+-------------------------------------------------+
161// | TaggedPointer | map - Always a pointer to the MetaMap root |
162// +---------------+-------------------------------------------------+
163// | Int | The first int field |
164// `---+----------+-------------------------------------------------+
165// | Byte | [instance_size] |
166// +----------+-------------------------------------------------+
167// | Byte | If Map for a primitive type: |
168// | | native context index for constructor fn |
169// | | If Map for an Object type: |
170// | | inobject properties start offset in words |
171// +----------+-------------------------------------------------+
172// | Byte | [used_or_unused_instance_size_in_words] |
173// | | For JSObject in fast mode this byte encodes |
174// | | the size of the object that includes only |
175// | | the used property fields or the slack size |
176// | | in properties backing store. |
177// +----------+-------------------------------------------------+
178// | Byte | [visitor_id] |
179// +----+----------+-------------------------------------------------+
180// | Int | The second int field |
181// `---+----------+-------------------------------------------------+
182// | Short | [instance_type] |
183// +----------+-------------------------------------------------+
184// | Byte | [bit_field] |
185// | | - has_non_instance_prototype (bit 0) |
186// | | - is_callable (bit 1) |
187// | | - has_named_interceptor (bit 2) |
188// | | - has_indexed_interceptor (bit 3) |
189// | | - is_undetectable (bit 4) |
190// | | - is_access_check_needed (bit 5) |
191// | | - is_constructor (bit 6) |
192// | | - has_prototype_slot (bit 7) |
193// +----------+-------------------------------------------------+
194// | Byte | [bit_field2] |
195// | | - new_target_is_base (bit 0) |
196// | | - is_immutable_proto (bit 1) |
197// | | - elements_kind (bits 2..7) |
198// +----+----------+-------------------------------------------------+
199// | Int | [bit_field3] |
200// | | - enum_length (bit 0..9) |
201// | | - number_of_own_descriptors (bit 10..19) |
202// | | - is_prototype_map (bit 20) |
203// | | - is_dictionary_map (bit 21) |
204// | | - owns_descriptors (bit 22) |
205// | | - is_in_retained_map_list (bit 23) |
206// | | - is_deprecated (bit 24) |
207// | | - is_unstable (bit 25) |
208// | | - is_migration_target (bit 26) |
209// | | - is_extensible (bit 28) |
210// | | - may_have_interesting_properties (bit 28) |
211// | | - construction_counter (bit 29..31) |
212// | | |
213// +*****************************************************************+
214// | Int | On systems with 64bit pointer types, there |
215// | | is an unused 32bits after bit_field3 |
216// +*****************************************************************+
217// | TaggedPointer | [prototype] |
218// +---------------+-------------------------------------------------+
219// | TaggedPointer | [constructor_or_back_pointer_or_native_context] |
220// +---------------+-------------------------------------------------+
221// | TaggedPointer | [instance_descriptors] (if JS object) |
222// | | [custom_descriptor] (if WasmStruct) |
223// +---------------+-------------------------------------------------+
224// | TaggedPointer | [dependent_code] |
225// +---------------+-------------------------------------------------+
226// | TaggedPointer | [prototype_validity_cell] |
227// +---------------+-------------------------------------------------+
228// | TaggedPointer | If Map is a prototype map: |
229// | | [prototype_info] |
230// | | Else: |
231// | | [raw_transitions] |
232// +---------------+-------------------------------------------------+
233
234class Map : public TorqueGeneratedMap<Map, HeapObject> {
235 public:
236 // Instance size.
237 // Size in bytes or kVariableSizeSentinel if instances do not have
238 // a fixed size.
239 DECL_INT_ACCESSORS(instance_size)
240 // Size in words or kVariableSizeSentinel if instances do not have
241 // a fixed size.
242 DECL_INT_ACCESSORS(instance_size_in_words)
243
244 // [inobject_properties_start_or_constructor_function_index]:
245 // Provides access to the inobject properties start offset in words in case of
246 // JSObject maps, or the constructor function index in case of primitive maps.
247 DECL_INT_ACCESSORS(inobject_properties_start_or_constructor_function_index)
248
249 // Get/set the in-object property area start offset in words in the object.
250 inline int GetInObjectPropertiesStartInWords() const;
251 inline void SetInObjectPropertiesStartInWords(int value);
252 // Count of properties allocated in the object (JSObject only).
253 inline int GetInObjectProperties() const;
254 // Index of the constructor function in the native context (primitives only),
255 // or the special sentinel value to indicate that there is no object wrapper
256 // for the primitive (i.e. in case of null or undefined).
257 static const int kNoConstructorFunctionIndex = 0;
258 inline int GetConstructorFunctionIndex() const;
259 inline void SetConstructorFunctionIndex(int value);
260 static std::optional<Tagged<JSFunction>> GetConstructorFunction(
262
263 // Retrieve interceptors.
264 DECL_GETTER(GetNamedInterceptor, Tagged<InterceptorInfo>)
265 DECL_GETTER(GetIndexedInterceptor, Tagged<InterceptorInfo>)
266
267 // Instance type.
269
270 // Returns the size of the used in-object area including object header
271 // (only used for JSObject in fast mode, for the other kinds of objects it
272 // is equal to the instance size).
273 inline int UsedInstanceSize() const;
274
275 inline bool HasOutOfObjectProperties() const;
276
277 // Tells how many unused property fields (in-object or out-of object) are
278 // available in the instance (only used for JSObject in fast mode).
279 inline int UnusedPropertyFields() const;
280 // Tells how many unused in-object property words are present.
281 inline int UnusedInObjectProperties() const;
282 // Updates the counters tracking unused fields in the object.
283 inline void SetInObjectUnusedPropertyFields(int unused_property_fields);
284 // Updates the counters tracking unused fields in the property array.
285 inline void SetOutOfObjectUnusedPropertyFields(int unused_property_fields);
286 inline void CopyUnusedPropertyFields(Tagged<Map> map);
288 inline void AccountAddedPropertyField();
290 int unused_in_property_array);
291
292 //
293 // Bit field.
294 //
295 // The setter in this pair calls the relaxed setter if concurrent marking is
296 // on, or performs the write non-atomically if it's off. The read is always
297 // non-atomically. This is done to have wider TSAN coverage on the cases where
298 // it's possible.
300
301 // Atomic accessors, used for allowlisting legitimate concurrent accesses.
303
304 // Bit positions for |bit_field|.
305 struct Bits1 {
306 DEFINE_TORQUE_GENERATED_MAP_BIT_FIELDS1()
307 };
308
309 //
310 // Bit field 2.
311 //
313
314 // Bit positions for |bit_field2|.
315 struct Bits2 {
316 DEFINE_TORQUE_GENERATED_MAP_BIT_FIELDS2()
317 };
318
319 //
320 // Bit field 3.
321 //
322 // {bit_field3} calls the relaxed accessors if concurrent marking is on, or
323 // performs the read/write non-atomically if it's off. This is done to have
324 // wider TSAN coverage on the cases where it's possible.
326
329
330 // Clear uninitialized padding space. This ensures that the snapshot content
331 // is deterministic. Depending on the V8 build mode there could be no padding.
333
334 // Bit positions for |bit_field3|.
335 struct Bits3 {
336 DEFINE_TORQUE_GENERATED_MAP_BIT_FIELDS3()
337 };
338
339 // Ensure that Torque-defined bit widths for |bit_field3| are as expected.
340 static_assert(Bits3::EnumLengthBits::kSize == kDescriptorIndexBitCount);
341 static_assert(Bits3::NumberOfOwnDescriptorsBits::kSize ==
343
344 static_assert(Bits3::NumberOfOwnDescriptorsBits::kMax >=
346
347 static const int kSlackTrackingCounterStart = 7;
348 static const int kSlackTrackingCounterEnd = 1;
349 static const int kNoSlackTracking = 0;
350 static_assert(kSlackTrackingCounterStart <=
351 Bits3::ConstructionCounterBits::kMax);
352
353 // Inobject slack tracking is the way to reclaim unused inobject space.
354 //
355 // The instance size is initially determined by adding some slack to
356 // expected_nof_properties (to allow for a few extra properties added
357 // after the constructor). There is no guarantee that the extra space
358 // will not be wasted.
359 //
360 // Here is the algorithm to reclaim the unused inobject space:
361 // - Detect the first constructor call for this JSFunction.
362 // When it happens enter the "in progress" state: initialize construction
363 // counter in the initial_map.
364 // - While the tracking is in progress initialize unused properties of a new
365 // object with one_pointer_filler_map instead of undefined_value (the "used"
366 // part is initialized with undefined_value as usual). This way they can
367 // be resized quickly and safely.
368 // - Once enough objects have been created compute the 'slack'
369 // (traverse the map transition tree starting from the
370 // initial_map and find the lowest value of unused_property_fields).
371 // - Traverse the transition tree again and decrease the instance size
372 // of every map. Existing objects will resize automatically (they are
373 // filled with one_pointer_filler_map). All further allocations will
374 // use the adjusted instance size.
375 // - SharedFunctionInfo's expected_nof_properties left unmodified since
376 // allocations made using different closures could actually create different
377 // kind of objects (see prototype inheritance pattern).
378 //
379 // Important: inobject slack tracking is not attempted during the snapshot
380 // creation.
381
382 static const int kGenerousAllocationCount =
384
385 // Starts the tracking by initializing object constructions countdown counter.
387
388 // True if the object constructions countdown counter is a range
389 // [kSlackTrackingCounterEnd, kSlackTrackingCounterStart].
390 inline bool IsInobjectSlackTrackingInProgress() const;
391
392 // Does the tracking step.
393 inline void InobjectSlackTrackingStep(Isolate* isolate);
394
395 // Computes inobject slack for the transition tree starting at this initial
396 // map.
397 int ComputeMinObjectSlack(Isolate* isolate);
398 inline int InstanceSizeFromSlack(int slack) const;
399
400 // Tells whether the object in the prototype property will be used
401 // for instances created from this function. If the prototype
402 // property is set to a value that is not a JSObject, the prototype
403 // property will not be used to create instances of the function.
404 // See ECMA-262, 13.2.2.
405 DECL_BOOLEAN_ACCESSORS(has_non_instance_prototype)
406
407 // Tells whether the instance has a [[Construct]] internal method.
408 // This property is implemented according to ES6, section 7.2.4.
410
411 // Tells whether the instance with this map may have properties for
412 // interesting symbols on it.
413 // An "interesting symbol" is one for which Name::IsInteresting()
414 // returns true, i.e. a well-known symbol like @@toStringTag.
415 DECL_BOOLEAN_ACCESSORS(may_have_interesting_properties)
416
418
419 // Records and queries whether the instance has a named interceptor.
421
422 // Records and queries whether the instance has an indexed interceptor.
423 DECL_BOOLEAN_ACCESSORS(has_indexed_interceptor)
424
425 // Tells whether the instance is undetectable.
426 // An undetectable object is a special class of JSObject: 'typeof' operator
427 // returns undefined, ToBoolean returns false. Otherwise it behaves like
428 // a normal JS object. It is useful for implementing undetectable
429 // document.all in Firefox & Safari.
430 // See https://bugzilla.mozilla.org/show_bug.cgi?id=248549.
432
433 // Tells whether the instance has a [[Call]] internal method.
434 // This property is implemented according to ES6, section 7.2.3.
435 DECL_BOOLEAN_ACCESSORS(is_callable)
436
437 DECL_BOOLEAN_ACCESSORS(new_target_is_base)
440 inline bool is_abandoned_prototype_map() const;
441 inline bool has_prototype_info() const;
443
444 // Whether the instance has been added to the retained map list by
445 // Heap::AddRetainedMap.
446 DECL_BOOLEAN_ACCESSORS(is_in_retained_map_list)
447
449
450 // Tells whether the instance has fast elements that are only Smis.
451 inline bool has_fast_smi_elements() const;
452
453 // Tells whether the instance has fast elements.
454 inline bool has_fast_object_elements() const;
455 inline bool has_fast_smi_or_object_elements() const;
456 inline bool has_fast_double_elements() const;
457 inline bool has_fast_elements() const;
458 inline bool has_fast_packed_elements() const;
459 inline bool has_sloppy_arguments_elements() const;
460 inline bool has_fast_sloppy_arguments_elements() const;
461 inline bool has_fast_string_wrapper_elements() const;
464 inline bool has_dictionary_elements() const;
465 inline bool has_any_nonextensible_elements() const;
466 inline bool has_nonextensible_elements() const;
467 inline bool has_sealed_elements() const;
468 inline bool has_frozen_elements() const;
469 inline bool has_shared_array_elements() const;
470
471 // Weakly checks whether a map is detached from all transition trees. If this
472 // returns true, the map is guaranteed to be detached. If it returns false,
473 // there is no guarantee it is attached.
474 inline bool IsDetached(Isolate* isolate) const;
475
476 // Returns true if there is an object with potentially read-only elements
477 // in the prototype chain. It could be a Proxy, a string wrapper,
478 // an object with DICTIONARY_ELEMENTS potentially containing read-only
479 // elements or an object with any frozen elements, or a slow arguments object.
481
483 ConcurrencyMode cmode);
484
486
487 // [raw_transitions]: Provides access to the transitions storage field.
488 // Don't call set_raw_transitions() directly to overwrite transitions, use
489 // the TransitionArray::ReplaceTransitions() wrapper instead!
494 // [prototype_info]: Per-prototype metadata. Aliased with transitions
495 // (which prototype maps don't have).
496 DECL_GETTER(prototype_info, Tagged<UnionOf<Smi, PrototypeInfo>>)
499 // PrototypeInfo is created lazily using this helper (which installs it on
500 // the given prototype's map).
502 DirectHandle<JSObject> prototype, Isolate* isolate);
504 DirectHandle<Map> prototype_map, Isolate* isolate);
505 inline bool should_be_fast_prototype_map() const;
506 static void SetShouldBeFastPrototypeMap(DirectHandle<Map> map, bool value,
507 Isolate* isolate);
508
509 // [prototype chain validity cell]: Associated with a prototype object,
510 // stored in that object's map, indicates that prototype chains through this
511 // object are currently valid. The cell will be invalidated and replaced when
512 // the prototype chain changes. When there's nothing to guard (for example,
513 // when direct prototype is null or Proxy) this function returns Smi with
514 // |kPrototypeChainValid| sentinel value, which is zero.
516 DirectHandle<Map> map, Isolate* isolate);
517 static constexpr int kPrototypeChainValid = 0;
518 static constexpr int kPrototypeChainInvalid = 1;
519 static constexpr Tagged<Smi> kPrototypeChainValidSmi = Smi::zero();
520
521 static bool IsPrototypeChainInvalidated(Tagged<Map> map);
522
523 // Return the map of the root of object's prototype chain.
525
528 InternalIndex descriptor) const;
529
530 inline int GetInObjectPropertyOffset(int index) const;
531
533 public:
534 FieldCounts(int mutable_count, int const_count)
535 : mutable_count_(mutable_count), const_count_(const_count) {}
536
537 int GetTotal() const { return mutable_count() + const_count(); }
538
539 int mutable_count() const { return mutable_count_; }
540 int const_count() const { return const_count_; }
541
542 private:
545 };
546
548 int NumberOfFields(ConcurrencyMode cmode) const;
549
550 // TODO(ishell): candidate with JSObject::MigrateToMap().
551 bool InstancesNeedRewriting(Tagged<Map> target, ConcurrencyMode cmode) const;
552 bool InstancesNeedRewriting(Tagged<Map> target, int target_number_of_fields,
553 int target_inobject, int target_unused,
554 int* old_number_of_fields,
555 ConcurrencyMode cmode) const;
556 // Returns true if the |field_type| is the most general one for
557 // given |representation|.
558 static inline bool IsMostGeneralFieldType(Representation representation,
559 Tagged<FieldType> field_type);
560
561 // Generalizes representation and field_type if objects with given
562 // instance type can have fast elements that can be transitioned by
563 // stubs or optimized code to more general elements kind.
564 // This generalization is necessary in order to ensure that elements kind
565 // transitions performed by stubs / optimized code don't silently transition
566 // fields with representation "Tagged" back to "Smi" or "HeapObject" or
567 // fields with HeapObject representation and "Any" type back to "Class" type.
569 Isolate* isolate, InstanceType instance_type,
570 Representation* representation, DirectHandle<FieldType>* field_type);
571
573 Isolate* isolate, DirectHandle<Map> old_map,
574 InternalIndex descriptor_number, PropertyConstness constness,
576
578 Isolate* isolate, DirectHandle<Map> map, ElementsKind new_elements_kind,
580 bool use_cache, const char* reason);
582 Isolate* isolate, DirectHandle<Map> map, ElementsKind new_elements_kind,
584 const char* reason) {
585 const bool kUseCache = true;
586 return Normalize(isolate, map, new_elements_kind, new_prototype, mode,
587 kUseCache, reason);
588 }
589
590 inline static Handle<Map> Normalize(Isolate* isolate,
591 DirectHandle<Map> fast_map,
593 const char* reason);
594
595 // Tells whether the map is used for JSObjects in dictionary mode (ie
596 // normalized objects, ie objects for which HasFastProperties returns false).
597 // A map can never be used for both dictionary mode and fast mode JSObjects.
598 // False by default and for HeapObjects that are not JSObjects.
599 DECL_BOOLEAN_ACCESSORS(is_dictionary_map)
600
601 // Tells whether the instance needs security checks when accessing its
602 // properties.
603 DECL_BOOLEAN_ACCESSORS(is_access_check_needed)
604
605 // [prototype]: implicit prototype object.
607 // TODO(jkummerow): make set_prototype private.
609 Isolate* isolate, DirectHandle<Map> map,
611 bool enable_prototype_setup_mode = true);
612
613 // Sets prototype and constructor fields to null. Can be called during
614 // bootstrapping.
616 ReadOnlyRoots roots);
617
618 // [constructor]: points back to the function or FunctionTemplateInfo
619 // responsible for this map.
620 // The field overlaps with the back pointer. All maps in a transition tree
621 // have the same constructor, so maps with back pointers can walk the
622 // back pointer chain until they find the map holding their constructor.
623 // Returns null_value if there's neither a constructor function nor a
624 // FunctionTemplateInfo available.
625 // The field also overlaps with the native context pointer for context maps,
626 // and with the Wasm type info for WebAssembly object maps.
630 DECL_ACCESSORS(native_context_or_null, Tagged<Object>)
632 DECL_ACCESSORS(wasm_type_info, Tagged<WasmTypeInfo>)
633
634 // Gets |constructor_or_back_pointer| field value from the root map.
635 // The result might be null, JSFunction, FunctionTemplateInfo or a Tuple2
636 // for JSFunctions with non-instance prototypes.
637 DECL_GETTER(GetConstructorRaw, Tagged<Object>)
638
639 // Gets constructor value from the root map. Unwraps Tuple2 in case of
640 // JSFunction map with non-instance prototype.
641 // The result returned might be null, JSFunction or FunctionTemplateInfo.
642 DECL_GETTER(GetConstructor, Tagged<Object>)
643 DECL_GETTER(GetFunctionTemplateInfo, Tagged<FunctionTemplateInfo>)
644 inline void SetConstructor(Tagged<Object> constructor,
646 // Constructor getter that performs at most the given number of steps
647 // in the transition tree. Returns either the constructor or the map at
648 // which the walk has stopped.
650 int max_steps);
651
652 // Gets non-instance prototype value which is stored in Tuple2 in a
653 // root map's |constructor_or_back_pointer| field.
654 DECL_GETTER(GetNonInstancePrototype, Tagged<Object>)
655
656 // [back pointer]: points back to the parent map from which a transition
657 // leads to this map. The field overlaps with the constructor (see above).
658 DECL_GETTER(GetBackPointer, Tagged<HeapObject>)
659 inline void SetBackPointer(Tagged<HeapObject> value,
661 inline bool TryGetBackPointer(PtrComprCageBase cage_base,
662 Tagged<Map>* back_pointer) const;
663
664 // [instance descriptors]: describes the object.
669 Isolate* isolate, Tagged<DescriptorArray> descriptors,
670 int number_of_own_descriptors,
672
673#if V8_ENABLE_WEBASSEMBLY
674 // Only for WasmStructs: custom descriptor instead of instance_descriptors.
675 DECL_ACCESSORS(custom_descriptor, Tagged<WasmStruct>)
676#endif // V8_ENABLE_WEBASSEMBLY
677
678 inline void UpdateDescriptors(Isolate* isolate,
679 Tagged<DescriptorArray> descriptors,
680 int number_of_own_descriptors);
681 inline void InitializeDescriptors(Isolate* isolate,
682 Tagged<DescriptorArray> descriptors);
683
684 // [dependent code]: list of optimized codes that weakly embed this map.
686
687 // [prototype_validity_cell]: Cell containing the validity bit for prototype
688 // chains or Tagged<Smi>(0) if uninitialized.
689 // The meaning of this validity cell is different for prototype maps and
690 // non-prototype maps.
691 // For prototype maps the validity bit "guards" modifications of prototype
692 // chains going through this object. When a prototype object changes, both its
693 // own validity cell and those of all "downstream" prototypes are invalidated;
694 // handlers for a given receiver embed the currently valid cell for that
695 // receiver's prototype during their creation and check it on execution.
696 // For non-prototype maps which are used as transitioning store handlers this
697 // field contains the validity cell which guards modifications of this map's
698 // prototype.
699 DECL_RELAXED_ACCESSORS(prototype_validity_cell, Tagged<UnionOf<Smi, Cell>>)
700
701 // Returns true if prototype validity cell value represents "valid" prototype
702 // chain state.
703 inline bool IsPrototypeValidityCellValid() const;
704
705 // Returns true if this map belongs to the same native context as given map,
706 // i.e. this map's meta map is equal to other_map's meta map.
707 // Returns false if this map is contextless (in case of JSObject map this
708 // means that the object is remote).
709 inline bool BelongsToSameNativeContextAs(Tagged<Map> other_map) const;
710 inline bool BelongsToSameNativeContextAs(Tagged<Context> context) const;
711
712 inline Tagged<Name> GetLastDescriptorName(Isolate* isolate) const;
713 inline PropertyDetails GetLastDescriptorDetails(Isolate* isolate) const;
714
715 inline InternalIndex LastAdded() const;
716
717 inline int NumberOfOwnDescriptors() const;
718 inline void SetNumberOfOwnDescriptors(int number);
720
722
723 // Checks whether all properties are stored either in the map or on the object
724 // (inobject, properties, or elements backing store), requiring no special
725 // checks.
726 bool OnlyHasSimpleProperties() const;
727 inline int EnumLength() const;
728 inline void SetEnumLength(int length);
729
730 DECL_BOOLEAN_ACCESSORS(owns_descriptors)
731
732 inline void mark_unstable();
733 inline bool is_stable() const;
734
735 DECL_BOOLEAN_ACCESSORS(is_migration_target)
736
738
739 // This counter is used for in-object slack tracking.
740 // The in-object slack tracking is considered enabled when the counter is
741 // non zero. The counter only has a valid count for initial maps. For
742 // transitioned maps only kNoSlackTracking has a meaning, namely that inobject
743 // slack tracking already finished for the transition tree. Any other value
744 // indicates that either inobject slack tracking is still in progress, or that
745 // the map isn't part of the transition tree anymore.
747
749 inline bool CanBeDeprecated() const;
750
751 // Returns a non-deprecated version of the input. If the input was not
752 // deprecated, it is directly returned. Otherwise, the non-deprecated version
753 // is found by re-transitioning from the root of the transition tree using the
754 // descriptor array of the map. Returns MaybeHandle<Map>() if no updated map
755 // is found.
757 Isolate* isolate, Handle<Map> map) V8_WARN_UNUSED_RESULT;
758
759 // Returns a non-deprecated version of the input. This method may deprecate
760 // existing maps along the way if encodings conflict. Not for use while
761 // gathering type feedback. Use TryUpdate in those cases instead.
763 DirectHandle<Map> map);
764
765 static inline Handle<Map> CopyInitialMap(Isolate* isolate,
766 DirectHandle<Map> map);
768 Isolate* isolate, DirectHandle<Map> map, int instance_size,
769 int in_object_properties, int unused_property_fields);
771 Isolate* isolate, DirectHandle<Map> map,
773 static Handle<Map> CopyDropDescriptors(Isolate* isolate,
774 DirectHandle<Map> map);
776 Isolate* isolate, DirectHandle<Map> map, Descriptor* descriptor,
777 TransitionFlag flag);
778
781 Tagged<MaybeObject> wrapped_type);
782
784 Isolate* isolate, DirectHandle<Map> map, DirectHandle<Name> name,
785 DirectHandle<FieldType> type, PropertyAttributes attributes,
786 PropertyConstness constness, Representation representation,
787 TransitionFlag flag);
788
791 DirectHandle<Name> name, DirectHandle<Object> constant,
792 PropertyAttributes attributes, TransitionFlag flag);
793
794 // Returns a new map with all transitions dropped from the given map and
795 // the ElementsKind set.
797 DirectHandle<Map> map,
798 ElementsKind to_kind);
799
800 static std::optional<Tagged<Map>> TryAsElementsKind(Isolate* isolate,
801 DirectHandle<Map> map,
803 ConcurrencyMode cmode);
805 DirectHandle<Map> map,
807
808 static Handle<Map> CopyAsElementsKind(Isolate* isolate, DirectHandle<Map> map,
810
812 Isolate* isolate, DirectHandle<Map> initial_map,
813 DirectHandle<SharedFunctionInfo> shared_info);
814
816 Isolate* isolate, DirectHandle<Map> map, PropertyAttributes attrs_to_add,
817 DirectHandle<Symbol> transition_marker, const char* reason,
818 bool old_map_is_dictionary_elements_kind = false);
819
820 // Maximal number of fast properties. Used to restrict the number of map
821 // transitions to avoid an explosion in the number of maps for objects used as
822 // dictionaries.
823 inline bool TooManyFastProperties(StoreOrigin store_origin) const;
825 Isolate* isolate, DirectHandle<Map> map, DirectHandle<Name> name,
826 DirectHandle<Object> value, PropertyAttributes attributes,
827 PropertyConstness constness, StoreOrigin store_origin);
829 Isolate* isolate, DirectHandle<Map> map, DirectHandle<Name> name,
832
833 inline void AppendDescriptor(Isolate* isolate, Descriptor* desc);
834
835 // Returns a copy of the map, prepared for inserting into the transition
836 // tree (if the |map| owns descriptors then the new one will share
837 // descriptors with |map|).
839 DirectHandle<Map> map);
840
841 // Returns a copy of the map, prepared for inserting into the transition
842 // tree as a prototype transition.
844 Isolate* isolate, DirectHandle<Map> map,
845 DirectHandle<JSPrototype> prototype);
846
847 // Returns a copy of the map, with all transitions dropped from the
848 // instance descriptors.
849 static Handle<Map> Copy(Isolate* isolate, DirectHandle<Map> map,
850 const char* reason,
852 V8_EXPORT_PRIVATE static Handle<Map> Create(Isolate* isolate,
853 int inobject_properties);
854
855 // Returns the next free property index (only valid for FAST MODE).
856 int NextFreePropertyIndex() const;
857
858 // Returns the number of enumerable properties.
860
861 static inline int SlackForArraySize(int old_size, int size_limit);
862
864 DirectHandle<Map> map,
865 int slack);
866
867 // Returns the map to be used for instances when the given {prototype} is
868 // passed to an Object.create call. Might transition the given {prototype}.
870 Isolate* isolate, DirectHandle<JSPrototype> prototype);
871
872 // Returns the map to be used for instances when the given {prototype} is
873 // passed to Reflect.construct or proxy constructors.
874 static Handle<Map> GetDerivedMap(Isolate* isolate, DirectHandle<Map> from,
875 DirectHandle<JSReceiver> prototype);
876
877 // Computes a hash value for this map, to be used e.g. in HashTables. The
878 // prototype value should be either the Map's prototype or another prototype
879 // in case the hash is supposed to be computed for a copy of this map with a
880 // changed prototype value.
881 int Hash(Isolate* isolate, Tagged<HeapObject> prototype);
882
883 // Returns the transitioned map for this map with the most generic
884 // elements_kind that's found in |candidates|, or |nullptr| if no match is
885 // found at all.
888
889 inline bool CanTransition() const;
890
891 static constexpr std::optional<RootIndex> TryGetMapRootIdxFor(
892 InstanceType type) {
893 switch (type) {
894#define MAKE_CASE(TYPE, Name, name) \
895 case TYPE: \
896 return RootIndex::k##Name##Map;
898 TORQUE_DEFINED_INSTANCE_TYPE_LIST(MAKE_CASE)
899#undef MAKE_CASE
900 default:
901 break;
902 }
903 return {};
904 }
905 static inline Tagged<Map> GetMapFor(ReadOnlyRoots roots, InstanceType type);
906
907 bool IsMapInArrayPrototypeChain(Isolate* isolate) const;
908
909 // Dispatched behavior.
910 void MapPrint(std::ostream& os);
912
913#ifdef VERIFY_HEAP
914 void DictionaryMapVerify(Isolate* isolate);
915#endif
916
918
919 static constexpr ObjectFields ObjectFieldsFrom(VisitorId visitor_id) {
920 return (visitor_id < kDataOnlyVisitorIdCount)
923 }
924
926 Isolate* isolate, DirectHandle<Map> map,
927 DirectHandle<JSPrototype> prototype);
929 Isolate* isolate, DirectHandle<Map> map,
930 DirectHandle<JSPrototype> prototype);
931
934
935 static_assert(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset);
936
937 class BodyDescriptor;
938
939 // Compares this map to another to see if they describe equivalent objects,
940 // up to the given |elements_kind| and |prototype|. If |mode| is set to
941 // CLEAR_INOBJECT_PROPERTIES, |other| is treated as if it had exactly zero
942 // inobject properties. The "shared" flags of both this map and |other| are
943 // ignored.
945 ElementsKind elements_kind,
946 Tagged<HeapObject> prototype,
947 PropertyNormalizationMode mode) const;
949 const Tagged<Map> other, PropertyNormalizationMode mode) const;
950
951 void PrintMapDetails(std::ostream& os);
952
954 Isolate* isolate, DirectHandle<Map> split_map,
956
957 // Fires when the layout of an object with a leaf map changes.
958 // This includes adding transitions to the leaf map or changing
959 // the descriptor array.
960 inline void NotifyLeafMapLayoutChange(Isolate* isolate);
961
963
964 // Returns true if objects with given instance type are allowed to have
965 // fast transitionable elements kinds. This predicate is used to ensure
966 // that objects that can have transitionable fast elements kind will not
967 // get in-place generalizable fields because the elements kind transition
968 // performed by stubs or optimized code can't properly generalize such
969 // fields.
970 static inline bool CanHaveFastTransitionableElementsKind(
971 InstanceType instance_type);
972 inline bool CanHaveFastTransitionableElementsKind() const;
973
974 // Maps for Wasm objects can use certain fields for other purposes.
975 inline uint8_t WasmByte1() const;
976 inline uint8_t WasmByte2() const;
977 inline void SetWasmByte1(uint8_t value);
978 inline void SetWasmByte2(uint8_t value);
979
980 private:
981 // This byte encodes either the instance size without the in-object slack or
982 // the slack size in properties backing store.
983 // Let H be JSObject::kHeaderSize / kTaggedSize.
984 // If value >= H then:
985 // - all field properties are stored in the object.
986 // - there is no property array.
987 // - value * kTaggedSize is the actual object size without the slack.
988 // Otherwise:
989 // - there is no slack in the object.
990 // - the property array has value slack slots.
991 // Note that this encoding requires that H = JSObject::kFieldsAdded.
992 DECL_INT_ACCESSORS(used_or_unused_instance_size_in_words)
993
994 // Returns the map that this (root) map transitions to if its elements_kind
995 // is changed to |elements_kind|, or |nullptr| if no such map is cached yet.
997 ElementsKind elements_kind,
998 ConcurrencyMode cmode);
999
1000 // Tries to replay property transitions starting from this (root) map using
1001 // the descriptor array of the |map|. The |root_map| is expected to have
1002 // proper elements kind and therefore elements kinds transitions are not
1003 // taken by this function. Returns |nullptr| if matching transition map is
1004 // not found.
1006 ConcurrencyMode cmode);
1007
1008 static void ConnectTransition(Isolate* isolate, DirectHandle<Map> parent,
1009 DirectHandle<Map> child,
1010 DirectHandle<Name> name,
1011 TransitionKindFlag transition_kind,
1012 bool force_connect = false);
1013
1015 const Tagged<Map> other, ConcurrencyMode cmode,
1016 DirectHandle<HeapObject> new_prototype = {}) const;
1018 ConcurrencyMode cmode) const;
1019 static Handle<Map> RawCopy(Isolate* isolate, DirectHandle<Map> map,
1020 int instance_size, int inobject_properties);
1023 Descriptor* descriptor);
1025 Isolate* isolate, DirectHandle<Map> map,
1026 DirectHandle<DescriptorArray> descriptors);
1027 static void InstallDescriptors(Isolate* isolate, DirectHandle<Map> parent_map,
1028 DirectHandle<Map> child_map,
1029 InternalIndex new_descriptor,
1031 // force_connect is used when copying a map
1032 // tree to enforce transitions being added even
1033 // for (still) seemingly detached maps.
1034 bool force_connect = false);
1036 Descriptor* descriptor,
1037 TransitionFlag flag);
1039 Isolate* isolate, DirectHandle<Map> map,
1041 MaybeDirectHandle<Name> maybe_name, const char* reason,
1042 TransitionKindFlag transition_kind);
1043
1045 Isolate* isolate, DirectHandle<Map> map,
1046 DirectHandle<DescriptorArray> descriptors, Descriptor* descriptor,
1047 InternalIndex index, TransitionFlag flag);
1050
1051 void DeprecateTransitionTree(Isolate* isolate);
1052
1053 void ReplaceDescriptors(Isolate* isolate,
1054 Tagged<DescriptorArray> new_descriptors);
1055
1056 // This is the replacement for IsMap() which avoids reading the instance type
1057 // but compares the object's map against given meta_map, so it can be used
1058 // concurrently without acquire load.
1060 PtrComprCageBase cage_base, Tagged<Object> object, Tagged<Map> meta_map);
1061
1062 // Use the high-level instance_descriptors/SetInstanceDescriptors instead.
1064
1065 // Hide inherited accessors from the generated superclass.
1066 DECL_ACCESSORS(constructor_or_back_pointer_or_native_context, Tagged<Object>)
1067 DECL_ACCESSORS(transitions_or_prototype_info, Tagged<Object>)
1068
1069 friend class MapUpdater;
1070 template <typename ConcreteVisitor>
1072
1074};
1075
1076// The cache for maps used by normalized (dictionary mode) objects.
1077// Such maps do not have property descriptors, so a typical program
1078// needs very limited number of distinct normalized maps.
1080 public:
1082 static DirectHandle<NormalizedMapCache> New(Isolate* isolate);
1083
1085 DirectHandle<Map> fast_map,
1086 ElementsKind elements_kind,
1087 Tagged<HeapObject> prototype,
1089 void Set(Isolate* isolate, DirectHandle<Map> fast_map,
1090 DirectHandle<Map> normalized_map);
1091
1093
1094 private:
1096 PtrComprCageBase cage_base);
1097
1098 static const int kEntries = 64;
1099
1100 static inline int GetIndex(Isolate* isolate, Tagged<Map> map,
1101 Tagged<HeapObject> prototype);
1102
1103 // The following declarations hide base class methods.
1105 void set(int index, Tagged<Object> value);
1106};
1107
1108#define DECL_TESTER(Type, ...) inline bool Is##Type##Map(Tagged<Map> map);
1110#undef DECL_TESTER
1111inline bool IsBooleanMap(Tagged<Map> map);
1112inline bool IsNullOrUndefinedMap(Tagged<Map> map);
1113inline bool IsPrimitiveMap(Tagged<Map> map);
1114inline bool IsSpecialReceiverMap(Tagged<Map> map);
1115inline bool IsCustomElementsReceiverMap(Tagged<Map> map);
1116
1117} // namespace v8::internal
1118
1120
1121#endif // V8_OBJECTS_MAP_H_
Builtins::Kind kind
Definition builtins.cc:40
PropertyT * getter
static const int kMapInstanceTypeOffset
int mutable_count() const
Definition map.h:539
FieldCounts(int mutable_count, int const_count)
Definition map.h:534
static V8_INLINE bool ConcurrentIsHeapObjectWithMap(PtrComprCageBase cage_base, Tagged< Object > object, Tagged< Map > meta_map)
Definition map-inl.h:810
static Handle< Map > CopyForElementsTransition(Isolate *isolate, DirectHandle< Map > map)
Definition map.cc:1775
static V8_EXPORT_PRIVATE Handle< Map > Create(Isolate *isolate, int inobject_properties)
Definition map.cc:1824
static bool IsPrototypeChainInvalidated(Tagged< Map > map)
Definition map.cc:2456
int NumberOfEnumerableProperties() const
Definition map.cc:1177
InternalIndex::Range IterateOwnDescriptors() const
Definition map-inl.h:245
static std::optional< Tagged< JSFunction > > GetConstructorFunction(Tagged< Map > map, Tagged< Context > native_context)
Definition map.cc:53
void SetEnumLength(int length)
Definition map-inl.h:253
int NumberOfFields(ConcurrencyMode cmode) const
Definition map.cc:610
static DirectHandle< PrototypeInfo > GetOrCreatePrototypeInfo(DirectHandle< Map > prototype_map, Isolate *isolate)
Definition map.cc:2377
bool IsPrototypeValidityCellValid() const
Definition map-inl.h:902
bool has_sealed_elements() const
Definition map-inl.h:677
Tagged< Map > ElementsTransitionMap(Isolate *isolate, ConcurrencyMode cmode)
Definition map-inl.h:861
static V8_EXPORT_PRIVATE Handle< Map > TransitionToUpdatePrototype(Isolate *isolate, DirectHandle< Map > map, DirectHandle< JSPrototype > prototype)
Definition map.cc:2506
static V8_EXPORT_PRIVATE void EnsureDescriptorSlack(Isolate *isolate, DirectHandle< Map > map, int slack)
Definition map.cc:850
bool EquivalentToForTransition(const Tagged< Map > other, ConcurrencyMode cmode, DirectHandle< HeapObject > new_prototype={}) const
Definition map.cc:2279
void CopyUnusedPropertyFieldsAdjustedForInstanceSize(Tagged< Map > map)
Definition map-inl.h:468
bool HasOutOfObjectProperties() const
Definition map-inl.h:334
uint8_t WasmByte1() const
static constexpr Tagged< Smi > kPrototypeChainValidSmi
Definition map.h:519
void SetWasmByte2(uint8_t value)
static Handle< Map > CopyForPrototypeTransition(Isolate *isolate, DirectHandle< Map > map, DirectHandle< JSPrototype > prototype)
Definition map.cc:1800
void AccountAddedOutOfObjectPropertyField(int unused_in_property_array)
Definition map-inl.h:500
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Map > CopyWithConstant(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Name > name, DirectHandle< Object > constant, PropertyAttributes attributes, TransitionFlag flag)
Definition map.cc:541
static V8_EXPORT_PRIVATE Handle< Map > CopyInsertDescriptor(Isolate *isolate, DirectHandle< Map > map, Descriptor *descriptor, TransitionFlag flag)
Definition map.cc:2209
static DirectHandle< Map > GetObjectCreateMap(Isolate *isolate, DirectHandle< JSPrototype > prototype)
Definition map.cc:903
void SetBackPointer(Tagged< HeapObject > value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
Definition map-inl.h:845
void MapPrint(std::ostream &os)
bool has_prototype_info() const
Definition map-inl.h:593
DECL_ACCESSORS(raw_transitions, Tagged< UnionOf< Smi, MaybeWeak< Map >, TransitionArray > >) DECL_RELEASE_ACQUIRE_ACCESSORS(raw_transitions
static const int kSlackTrackingCounterStart
Definition map.h:347
static const int kNoSlackTracking
Definition map.h:349
void SetConstructorFunctionIndex(int value)
Definition map-inl.h:358
static Handle< Map > CopyDropDescriptors(Isolate *isolate, DirectHandle< Map > map)
Definition map.cc:1480
static void SetShouldBeFastPrototypeMap(DirectHandle< Map > map, bool value, Isolate *isolate)
Definition map.cc:2408
static Handle< UnionOf< Smi, Cell > > GetOrCreatePrototypeChainValidityCell(DirectHandle< Map > map, Isolate *isolate)
Definition map.cc:2419
static constexpr ObjectFields ObjectFieldsFrom(VisitorId visitor_id)
Definition map.h:919
int UsedInstanceSize() const
Definition map-inl.h:425
static Handle< Map > Copy(Isolate *isolate, DirectHandle< Map > map, const char *reason, TransitionKindFlag kind=SPECIAL_TRANSITION)
Definition map.cc:1811
bool IsDetached(Isolate *isolate) const
Definition map-inl.h:173
Tagged< Name > GetLastDescriptorName(Isolate *isolate) const
Definition map-inl.h:218
bool IsInobjectSlackTrackingInProgress() const
Definition map-inl.h:1014
bool EquivalentToForNormalization(const Tagged< Map > other, ElementsKind elements_kind, Tagged< HeapObject > prototype, PropertyNormalizationMode mode) const
Definition map.cc:2331
static V8_EXPORT_PRIVATE DirectHandle< Map > TransitionToDataProperty(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Name > name, DirectHandle< Object > value, PropertyAttributes attributes, PropertyConstness constness, StoreOrigin store_origin)
Definition map.cc:1987
int GetInObjectPropertiesStartInWords() const
Definition map-inl.h:324
bool should_be_fast_prototype_map() const
Definition map-inl.h:587
static void InstallDescriptors(Isolate *isolate, DirectHandle< Map > parent_map, DirectHandle< Map > child_map, InternalIndex new_descriptor, DirectHandle< DescriptorArray > descriptors, bool force_connect=false)
Definition map.cc:1664
static DirectHandle< Map > AsLanguageMode(Isolate *isolate, DirectHandle< Map > initial_map, DirectHandle< SharedFunctionInfo > shared_info)
Definition map.cc:1734
static V8_EXPORT_PRIVATE MaybeHandle< Map > TryUpdate(Isolate *isolate, Handle< Map > map) V8_WARN_UNUSED_RESULT
Definition map.cc:751
static MaybeObjectDirectHandle WrapFieldType(DirectHandle< FieldType > type)
Definition map.cc:487
bool CanHaveFastTransitionableElementsKind() const
Definition map-inl.h:169
bool has_fast_double_elements() const
Definition map-inl.h:628
static V8_EXPORT_PRIVATE DirectHandle< Map > PrepareForDataProperty(Isolate *isolate, DirectHandle< Map > old_map, InternalIndex descriptor_number, PropertyConstness constness, DirectHandle< Object > value)
Definition map.cc:1975
int GetInObjectPropertyOffset(int index) const
Definition map-inl.h:363
void SetOutOfObjectUnusedPropertyFields(int unused_property_fields)
Definition map-inl.h:453
PropertyDetails GetLastDescriptorDetails(Isolate *isolate) const
Definition map-inl.h:222
void StartInobjectSlackTracking()
Definition map.cc:2486
int InstanceSizeFromSlack(int slack) const
Definition map-inl.h:1040
static Tagged< Map > GetMapFor(ReadOnlyRoots roots, InstanceType type)
Definition map-inl.h:855
bool has_fast_object_elements() const
Definition map-inl.h:620
bool has_dictionary_elements() const
Definition map-inl.h:665
bool is_stable() const
Definition map-inl.h:705
bool has_any_typed_array_or_wasm_array_elements() const
Definition map-inl.h:656
Tagged< Map > LookupElementsTransitionMap(Isolate *isolate, ElementsKind elements_kind, ConcurrencyMode cmode)
Definition map.cc:1047
V8_EXPORT_PRIVATE Tagged< Map > FindRootMap(PtrComprCageBase cage_base) const
Definition map.cc:699
static V8_EXPORT_PRIVATE Handle< Map > TransitionRootMapToPrototypeForNewObject(Isolate *isolate, DirectHandle< Map > map, DirectHandle< JSPrototype > prototype)
Definition map.cc:2492
static const int kSlackTrackingCounterEnd
Definition map.h:348
static void ConnectTransition(Isolate *isolate, DirectHandle< Map > parent, DirectHandle< Map > child, DirectHandle< Name > name, TransitionKindFlag transition_kind, bool force_connect=false)
Definition map.cc:1534
void SetNumberOfOwnDescriptors(int number)
Definition map-inl.h:237
void SetWasmByte1(uint8_t value)
bool CanTransition() const
Definition map-inl.h:729
bool IsMapInArrayPrototypeChain(Isolate *isolate) const
Definition map.cc:1056
bool has_typed_array_or_rab_gsab_typed_array_elements() const
Definition map-inl.h:652
FieldCounts GetFieldCounts() const
Definition map.cc:622
void PrintMapDetails(std::ostream &os)
static bool IsMostGeneralFieldType(Representation representation, Tagged< FieldType > field_type)
Definition map-inl.h:157
Tagged< Map > GetPrototypeChainRootMap(Isolate *isolate) const
Definition map.cc:37
static constexpr int kPrototypeChainInvalid
Definition map.h:518
int GetInObjectProperties() const
Definition map-inl.h:341
bool OnlyHasSimpleProperties() const
Definition map.cc:1202
bool has_fast_smi_elements() const
Definition map-inl.h:616
static constexpr std::optional< RootIndex > TryGetMapRootIdxFor(InstanceType type)
Definition map.h:891
void ReplaceDescriptors(Isolate *isolate, Tagged< DescriptorArray > new_descriptors)
Definition map.cc:668
static Handle< Map > CopyAsElementsKind(Isolate *isolate, DirectHandle< Map > map, ElementsKind kind, TransitionFlag flag)
Definition map.cc:1688
bool has_any_nonextensible_elements() const
Definition map-inl.h:669
static Handle< Map > CopyAddDescriptor(Isolate *isolate, DirectHandle< Map > map, Descriptor *descriptor, TransitionFlag flag)
Definition map.cc:2186
void DeprecateTransitionTree(Isolate *isolate)
Definition map.cc:642
static V8_EXPORT_PRIVATE Handle< Map > Normalize(Isolate *isolate, DirectHandle< Map > map, ElementsKind new_elements_kind, DirectHandle< JSPrototype > new_prototype, PropertyNormalizationMode mode, const char *reason)
Definition map.h:581
InternalIndex LastAdded() const
Definition map-inl.h:226
static V8_EXPORT_PRIVATE void SetPrototype(Isolate *isolate, DirectHandle< Map > map, DirectHandle< JSPrototype > prototype, bool enable_prototype_setup_mode=true)
Definition map.cc:2467
void InobjectSlackTrackingStep(Isolate *isolate)
Definition map-inl.h:1018
Tagged< FixedArrayBase > GetInitialElements() const
Definition map-inl.h:262
int ComputeMinObjectSlack(Isolate *isolate)
Definition map.cc:2350
bool ShouldCheckForReadOnlyElementsInPrototypeChain(Isolate *isolate)
Definition map.cc:1209
void AppendDescriptor(Isolate *isolate, Descriptor *desc)
Definition map-inl.h:777
bool has_sloppy_arguments_elements() const
Definition map-inl.h:640
static const int kGenerousAllocationCount
Definition map.h:382
bool has_fast_packed_elements() const
Definition map-inl.h:636
V8_EXPORT_PRIVATE void SetInstanceDescriptors(Isolate *isolate, Tagged< DescriptorArray > descriptors, int number_of_own_descriptors, WriteBarrierMode barrier_mode=UPDATE_WRITE_BARRIER)
Definition map.cc:2363
void CopyUnusedPropertyFields(Tagged< Map > map)
Definition map-inl.h:462
bool has_frozen_elements() const
Definition map-inl.h:681
bool has_fast_smi_or_object_elements() const
Definition map-inl.h:624
bool EquivalentToForElementsKindTransition(const Tagged< Map > other, ConcurrencyMode cmode) const
Definition map.cc:2308
V8_EXPORT_PRIVATE Tagged< Map > FindElementsKindTransitionedMap(Isolate *isolate, MapHandlesSpan candidates, ConcurrencyMode cmode)
Definition map.cc:982
bool TooManyFastProperties(StoreOrigin store_origin) const
Definition map-inl.h:207
bool has_nonextensible_elements() const
Definition map-inl.h:673
static V8_EXPORT_PRIVATE Handle< Map > Normalize(Isolate *isolate, DirectHandle< Map > map, ElementsKind new_elements_kind, DirectHandle< JSPrototype > new_prototype, PropertyNormalizationMode mode, bool use_cache, const char *reason)
Definition map.cc:1282
Tagged< Cell > RetrieveDescriptorsPointer()
int Hash(Isolate *isolate, Tagged< HeapObject > prototype)
Definition map.cc:2250
static DirectHandle< Map > AddMissingTransitionsForTesting(Isolate *isolate, DirectHandle< Map > split_map, DirectHandle< DescriptorArray > descriptors)
Definition map-inl.h:367
bool has_fast_sloppy_arguments_elements() const
Definition map-inl.h:644
void AccountAddedPropertyField()
Definition map-inl.h:479
static V8_EXPORT_PRIVATE DirectHandle< Map > Update(Isolate *isolate, DirectHandle< Map > map)
Definition map.cc:839
static std::optional< Tagged< Map > > TryAsElementsKind(Isolate *isolate, DirectHandle< Map > map, ElementsKind kind, ConcurrencyMode cmode)
Definition map.cc:1152
int UnusedInObjectProperties() const
Definition map-inl.h:401
static V8_EXPORT_PRIVATE Tagged< FieldType > UnwrapFieldType(Tagged< MaybeObject > wrapped_type)
Definition map.cc:495
void SetInObjectUnusedPropertyFields(int unused_property_fields)
Definition map-inl.h:438
static V8_EXPORT_PRIVATE Handle< Map > CopyForPreventExtensions(Isolate *isolate, DirectHandle< Map > map, PropertyAttributes attrs_to_add, DirectHandle< Symbol > transition_marker, const char *reason, bool old_map_is_dictionary_elements_kind=false)
Definition map.cc:1852
bool has_shared_array_elements() const
Definition map-inl.h:685
bool BelongsToSameNativeContextAs(Tagged< Map > other_map) const
Definition map-inl.h:913
static Handle< Map > GetDerivedMap(Isolate *isolate, DirectHandle< Map > from, DirectHandle< JSReceiver > prototype)
Definition map.cc:934
bool TryGetBackPointer(PtrComprCageBase cage_base, Tagged< Map > *back_pointer) const
Definition map-inl.h:826
void UpdateDescriptors(Isolate *isolate, Tagged< DescriptorArray > descriptors, int number_of_own_descriptors)
Definition map-inl.h:758
static Handle< Map > CopyReplaceDescriptors(Isolate *isolate, DirectHandle< Map > map, DirectHandle< DescriptorArray > descriptors, TransitionFlag flag, MaybeDirectHandle< Name > maybe_name, const char *reason, TransitionKindFlag transition_kind)
Definition map.cc:1564
static void GeneralizeIfCanHaveTransitionableFastElementsKind(Isolate *isolate, InstanceType instance_type, Representation *representation, DirectHandle< FieldType > *field_type)
Definition map-inl.h:180
static V8_EXPORT_PRIVATE VisitorId GetVisitorId(Tagged< Map > map)
Definition map.cc:65
void InitializeDescriptors(Isolate *isolate, Tagged< DescriptorArray > descriptors)
Definition map-inl.h:764
V8_INLINE void clear_padding()
Definition map-inl.h:770
static V8_EXPORT_PRIVATE Handle< Map > AsElementsKind(Isolate *isolate, DirectHandle< Map > map, ElementsKind kind)
Definition map.cc:1163
static V8_EXPORT_PRIVATE Handle< Map > AddMissingTransitions(Isolate *isolate, DirectHandle< Map > map, DirectHandle< DescriptorArray > descriptors)
Definition map.cc:1618
void SetConstructor(Tagged< Object > constructor, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
Definition map-inl.h:999
int NumberOfOwnDescriptors() const
Definition map-inl.h:232
static Handle< Map > CopyReplaceDescriptor(Isolate *isolate, DirectHandle< Map > map, DirectHandle< DescriptorArray > descriptors, Descriptor *descriptor, InternalIndex index, TransitionFlag flag)
Definition map.cc:2225
static int SlackForArraySize(int old_size, int size_limit)
Definition map-inl.h:1030
static Handle< Map > ShareDescriptor(Isolate *isolate, DirectHandle< Map > map, DirectHandle< DescriptorArray > descriptors, Descriptor *descriptor)
Definition map.cc:1493
static Handle< Map > RawCopy(Isolate *isolate, DirectHandle< Map > map, int instance_size, int inobject_properties)
Definition map.cc:1246
int GetConstructorFunctionIndex() const
Definition map-inl.h:346
static constexpr int kPrototypeChainValid
Definition map.h:517
V8_EXPORT_PRIVATE Tagged< Map > FindFieldOwner(PtrComprCageBase cage_base, InternalIndex descriptor) const
Definition map.cc:716
void SetInObjectPropertiesStartInWords(int value)
Definition map-inl.h:329
static Handle< Map > CopyNormalized(Isolate *isolate, DirectHandle< Map > map, PropertyNormalizationMode mode)
Definition map.cc:1378
static DirectHandle< Map > TransitionElementsTo(Isolate *isolate, DirectHandle< Map > map, ElementsKind to_kind)
Definition map.cc:1068
bool has_fast_elements() const
Definition map-inl.h:632
void mark_unstable()
Definition map-inl.h:700
uint8_t WasmByte2() const
static DirectHandle< Map > CopyInitialMapNormalized(Isolate *isolate, DirectHandle< Map > map, PropertyNormalizationMode mode=CLEAR_INOBJECT_PROPERTIES)
Definition map.cc:1448
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Map > CopyWithField(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Name > name, DirectHandle< FieldType > type, PropertyAttributes attributes, PropertyConstness constness, Representation representation, TransitionFlag flag)
Definition map.cc:504
Tagged< Map > TryReplayPropertyTransitions(Isolate *isolate, Tagged< Map > map, ConcurrencyMode cmode)
Definition map.cc:773
void init_prototype_and_constructor_or_back_pointer(ReadOnlyRoots roots)
bool InstancesNeedRewriting(Tagged< Map > target, ConcurrencyMode cmode) const
Definition map.cc:559
bool CanBeDeprecated() const
Definition map-inl.h:709
int UnusedPropertyFields() const
Definition map-inl.h:384
bool is_abandoned_prototype_map() const
Definition map-inl.h:583
bool has_fast_string_wrapper_elements() const
Definition map-inl.h:648
static DirectHandle< Map > TransitionToImmutableProto(Isolate *isolate, DirectHandle< Map > map)
Definition map.cc:1413
int NextFreePropertyIndex() const
Definition map.cc:1189
int EnumLength() const
Definition map-inl.h:249
static V8_EXPORT_PRIVATE DirectHandle< Map > TransitionToAccessorProperty(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Name > name, InternalIndex descriptor, DirectHandle< Object > getter, DirectHandle< Object > setter, PropertyAttributes attributes)
Definition map.cc:2072
Tagged< Object > TryGetConstructor(PtrComprCageBase cage_base, int max_steps)
Definition map-inl.h:971
static const int kNoConstructorFunctionIndex
Definition map.h:257
bool TryGetPrototypeInfo(Tagged< PrototypeInfo > *result) const
Definition map-inl.h:598
static Handle< Map > CopyInitialMap(Isolate *isolate, DirectHandle< Map > map)
Definition map-inl.h:1008
void NotifyLeafMapLayoutChange(Isolate *isolate)
Definition map-inl.h:721
friend bool IsNormalizedMapCache(Tagged< HeapObject > obj, PtrComprCageBase cage_base)
void set(int index, Tagged< Object > value)
Tagged< Object > get(int index)
ZoneVector< OpIndex > candidates
#define INSTANCE_TYPE_CHECKERS(V)
ZoneVector< RpoNumber > & result
#define VISITOR_ID_ENUM_DECL(id)
Definition map.h:128
#define MAKE_CASE(TYPE, Name, name)
#define DATA_ONLY_VISITOR_ID_LIST(V)
Definition map.h:34
#define TRUSTED_VISITOR_ID_LIST(V)
Definition map.h:121
#define POINTER_VISITOR_ID_LIST(V)
Definition map.h:44
#define DECL_TESTER(Type,...)
Definition map.h:1108
STL namespace.
unsigned short uint16_t
Definition unicode.cc:39
V8_INLINE const Operation & Get(const Graph &graph, OpIndex index)
Definition graph.h:1231
bool IsPrimitiveMap(Tagged< Map > map)
Definition map-inl.h:754
@ UPDATE_WRITE_BARRIER
Definition objects.h:55
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit Map::Bits2::IsImmutablePrototypeBit Map::Bits3::IsDeprecatedBit is_prototype_map
Definition map-inl.h:133
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit bit_field2
Definition map-inl.h:123
bool IsCustomElementsReceiverMap(Tagged< Map > map)
bool IsSpecialReceiverMap(Tagged< Map > map)
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit is_immutable_proto
Definition map-inl.h:123
@ SPECIAL_TRANSITION
Definition objects.h:76
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit Map::Bits2::IsImmutablePrototypeBit Map::Bits3::IsDeprecatedBit Map::Bits3::IsPrototypeMapBit Map::Bits3::IsExtensibleBit construction_counter
Definition map-inl.h:141
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit is_undetectable
Definition map-inl.h:113
Map::Bits1::HasPrototypeSlotBit has_named_interceptor
Definition map-inl.h:109
!IsContextMap !IsContextMap IsContextMap this IsMapMap this raw_native_context_or_null
Definition map-inl.h:886
instance_descriptors
Definition map-inl.h:52
bool IsBooleanMap(Tagged< Map > map)
Definition map-inl.h:745
kInstanceDescriptorsOffset raw_transitions
Definition map-inl.h:61
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit Map::Bits2::IsImmutablePrototypeBit is_deprecated
Definition map-inl.h:129
bool IsNullOrUndefinedMap(Tagged< Map > map)
Definition map-inl.h:749
typename detail::FlattenUnionHelper< Union<>, Ts... >::type UnionOf
Definition union.h:123
static const int kMaxNumberOfDescriptors
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit Map::Bits2::IsImmutablePrototypeBit Map::Bits3::IsDeprecatedBit Map::Bits3::IsPrototypeMapBit bit_field3
Definition map-inl.h:137
static const int kDescriptorIndexBitCount
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit Map::Bits2::IsImmutablePrototypeBit Map::Bits3::IsDeprecatedBit Map::Bits3::IsPrototypeMapBit is_extensible
Definition map-inl.h:137
constructor_or_back_pointer
Definition map-inl.h:870
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit Map::Bits2::IsImmutablePrototypeBit Map::Bits3::IsDeprecatedBit Map::Bits3::IsPrototypeMapBit relaxed_bit_field3
Definition map-inl.h:137
@ kDataOnlyVisitorIdCount
Definition map.h:132
@ kVisitorIdCount
Definition map.h:136
!IsContextMap !IsContextMap native_context
Definition map-inl.h:877
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit Map::Bits2::IsImmutablePrototypeBit release_acquire_bit_field3
Definition map-inl.h:129
PropertyNormalizationMode
Definition objects.h:60
@ CLEAR_INOBJECT_PROPERTIES
Definition objects.h:61
#define DECL_ACCESSORS(name,...)
#define DECL_GETTER(name,...)
#define DECL_ACQUIRE_GETTER(name,...)
#define DECL_VERIFIER(Name)
#define DECL_BOOLEAN_ACCESSORS(name)
#define DECL_RELEASE_SETTER(name,...)
#define DECL_RELAXED_ACCESSORS(name,...)
#define NEVER_READ_ONLY_SPACE
#define DECL_PRIMITIVE_ACCESSORS(name, type)
#define DECL_RELEASE_ACQUIRE_ACCESSORS(name,...)
#define DECL_INT_ACCESSORS(name)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define STRUCT_LIST(V)
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define V8_INLINE
Definition v8config.h:500
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671