LCOV - code coverage report
Current view: top level - src - roots.h (source / functions) Hit Total Coverage
Test: app.info Lines: 14 14 100.0 %
Date: 2019-01-20 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright 2018 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_ROOTS_H_
       6             : #define V8_ROOTS_H_
       7             : 
       8             : #include "src/accessors.h"
       9             : #include "src/globals.h"
      10             : #include "src/heap-symbols.h"
      11             : #include "src/objects-definitions.h"
      12             : #include "src/objects.h"
      13             : #include "src/objects/slots.h"
      14             : 
      15             : namespace v8 {
      16             : namespace internal {
      17             : 
      18             : // Forward declarations.
      19             : enum ElementsKind : uint8_t;
      20             : class FixedTypedArrayBase;
      21             : template <typename T>
      22             : class Handle;
      23             : class Heap;
      24             : class Isolate;
      25             : class Map;
      26             : class PropertyCell;
      27             : class String;
      28             : class Symbol;
      29             : class RootVisitor;
      30             : 
      31             : // Defines all the read-only roots in Heap.
      32             : #define STRONG_READ_ONLY_ROOT_LIST(V)                                          \
      33             :   /* Cluster the most popular ones in a few cache lines here at the top.    */ \
      34             :   /* The first 32 entries are most often used in the startup snapshot and   */ \
      35             :   /* can use a shorter representation in the serialization format.          */ \
      36             :   V(Map, free_space_map, FreeSpaceMap)                                         \
      37             :   V(Map, one_pointer_filler_map, OnePointerFillerMap)                          \
      38             :   V(Map, two_pointer_filler_map, TwoPointerFillerMap)                          \
      39             :   V(Oddball, uninitialized_value, UninitializedValue)                          \
      40             :   V(Oddball, undefined_value, UndefinedValue)                                  \
      41             :   V(Oddball, the_hole_value, TheHoleValue)                                     \
      42             :   V(Oddball, null_value, NullValue)                                            \
      43             :   V(Oddball, true_value, TrueValue)                                            \
      44             :   V(Oddball, false_value, FalseValue)                                          \
      45             :   V(String, empty_string, empty_string)                                        \
      46             :   V(Map, meta_map, MetaMap)                                                    \
      47             :   V(Map, byte_array_map, ByteArrayMap)                                         \
      48             :   V(Map, fixed_array_map, FixedArrayMap)                                       \
      49             :   V(Map, fixed_cow_array_map, FixedCOWArrayMap)                                \
      50             :   V(Map, hash_table_map, HashTableMap)                                         \
      51             :   V(Map, symbol_map, SymbolMap)                                                \
      52             :   V(Map, one_byte_string_map, OneByteStringMap)                                \
      53             :   V(Map, one_byte_internalized_string_map, OneByteInternalizedStringMap)       \
      54             :   V(Map, scope_info_map, ScopeInfoMap)                                         \
      55             :   V(Map, shared_function_info_map, SharedFunctionInfoMap)                      \
      56             :   V(Map, code_map, CodeMap)                                                    \
      57             :   V(Map, function_context_map, FunctionContextMap)                             \
      58             :   V(Map, cell_map, CellMap)                                                    \
      59             :   V(Map, global_property_cell_map, GlobalPropertyCellMap)                      \
      60             :   V(Map, foreign_map, ForeignMap)                                              \
      61             :   V(Map, heap_number_map, HeapNumberMap)                                       \
      62             :   V(Map, transition_array_map, TransitionArrayMap)                             \
      63             :   V(Map, feedback_vector_map, FeedbackVectorMap)                               \
      64             :   V(ScopeInfo, empty_scope_info, EmptyScopeInfo)                               \
      65             :   V(FixedArray, empty_fixed_array, EmptyFixedArray)                            \
      66             :   V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray)             \
      67             :   /* Entries beyond the first 32                                            */ \
      68             :   /* Oddballs */                                                               \
      69             :   V(Oddball, arguments_marker, ArgumentsMarker)                                \
      70             :   V(Oddball, exception, Exception)                                             \
      71             :   V(Oddball, termination_exception, TerminationException)                      \
      72             :   V(Oddball, optimized_out, OptimizedOut)                                      \
      73             :   V(Oddball, stale_register, StaleRegister)                                    \
      74             :   /* Context maps */                                                           \
      75             :   V(Map, native_context_map, NativeContextMap)                                 \
      76             :   V(Map, module_context_map, ModuleContextMap)                                 \
      77             :   V(Map, eval_context_map, EvalContextMap)                                     \
      78             :   V(Map, script_context_map, ScriptContextMap)                                 \
      79             :   V(Map, await_context_map, AwaitContextMap)                                   \
      80             :   V(Map, block_context_map, BlockContextMap)                                   \
      81             :   V(Map, catch_context_map, CatchContextMap)                                   \
      82             :   V(Map, with_context_map, WithContextMap)                                     \
      83             :   V(Map, debug_evaluate_context_map, DebugEvaluateContextMap)                  \
      84             :   V(Map, script_context_table_map, ScriptContextTableMap)                      \
      85             :   /* Maps */                                                                   \
      86             :   V(Map, feedback_metadata_map, FeedbackMetadataArrayMap)                      \
      87             :   V(Map, array_list_map, ArrayListMap)                                         \
      88             :   V(Map, bigint_map, BigIntMap)                                                \
      89             :   V(Map, object_boilerplate_description_map, ObjectBoilerplateDescriptionMap)  \
      90             :   V(Map, bytecode_array_map, BytecodeArrayMap)                                 \
      91             :   V(Map, code_data_container_map, CodeDataContainerMap)                        \
      92             :   V(Map, descriptor_array_map, DescriptorArrayMap)                             \
      93             :   V(Map, fixed_double_array_map, FixedDoubleArrayMap)                          \
      94             :   V(Map, global_dictionary_map, GlobalDictionaryMap)                           \
      95             :   V(Map, many_closures_cell_map, ManyClosuresCellMap)                          \
      96             :   V(Map, module_info_map, ModuleInfoMap)                                       \
      97             :   V(Map, mutable_heap_number_map, MutableHeapNumberMap)                        \
      98             :   V(Map, name_dictionary_map, NameDictionaryMap)                               \
      99             :   V(Map, no_closures_cell_map, NoClosuresCellMap)                              \
     100             :   V(Map, no_feedback_cell_map, NoFeedbackCellMap)                              \
     101             :   V(Map, number_dictionary_map, NumberDictionaryMap)                           \
     102             :   V(Map, one_closure_cell_map, OneClosureCellMap)                              \
     103             :   V(Map, ordered_hash_map_map, OrderedHashMapMap)                              \
     104             :   V(Map, ordered_hash_set_map, OrderedHashSetMap)                              \
     105             :   V(Map, ordered_name_dictionary_map, OrderedNameDictionaryMap)                \
     106             :   V(Map, preparse_data_map, PreparseDataMap)                                   \
     107             :   V(Map, property_array_map, PropertyArrayMap)                                 \
     108             :   V(Map, side_effect_call_handler_info_map, SideEffectCallHandlerInfoMap)      \
     109             :   V(Map, side_effect_free_call_handler_info_map,                               \
     110             :     SideEffectFreeCallHandlerInfoMap)                                          \
     111             :   V(Map, next_call_side_effect_free_call_handler_info_map,                     \
     112             :     NextCallSideEffectFreeCallHandlerInfoMap)                                  \
     113             :   V(Map, simple_number_dictionary_map, SimpleNumberDictionaryMap)              \
     114             :   V(Map, sloppy_arguments_elements_map, SloppyArgumentsElementsMap)            \
     115             :   V(Map, small_ordered_hash_map_map, SmallOrderedHashMapMap)                   \
     116             :   V(Map, small_ordered_hash_set_map, SmallOrderedHashSetMap)                   \
     117             :   V(Map, small_ordered_name_dictionary_map, SmallOrderedNameDictionaryMap)     \
     118             :   V(Map, string_table_map, StringTableMap)                                     \
     119             :   V(Map, uncompiled_data_without_preparse_data_map,                            \
     120             :     UncompiledDataWithoutPreparseDataMap)                                      \
     121             :   V(Map, uncompiled_data_with_preparse_data_map,                               \
     122             :     UncompiledDataWithPreparseDataMap)                                         \
     123             :   V(Map, weak_fixed_array_map, WeakFixedArrayMap)                              \
     124             :   V(Map, weak_array_list_map, WeakArrayListMap)                                \
     125             :   V(Map, ephemeron_hash_table_map, EphemeronHashTableMap)                      \
     126             :   V(Map, embedder_data_array_map, EmbedderDataArrayMap)                        \
     127             :   /* String maps */                                                            \
     128             :   V(Map, native_source_string_map, NativeSourceStringMap)                      \
     129             :   V(Map, string_map, StringMap)                                                \
     130             :   V(Map, cons_one_byte_string_map, ConsOneByteStringMap)                       \
     131             :   V(Map, cons_string_map, ConsStringMap)                                       \
     132             :   V(Map, thin_one_byte_string_map, ThinOneByteStringMap)                       \
     133             :   V(Map, thin_string_map, ThinStringMap)                                       \
     134             :   V(Map, sliced_string_map, SlicedStringMap)                                   \
     135             :   V(Map, sliced_one_byte_string_map, SlicedOneByteStringMap)                   \
     136             :   V(Map, external_string_map, ExternalStringMap)                               \
     137             :   V(Map, external_string_with_one_byte_data_map,                               \
     138             :     ExternalStringWithOneByteDataMap)                                          \
     139             :   V(Map, external_one_byte_string_map, ExternalOneByteStringMap)               \
     140             :   V(Map, uncached_external_string_map, UncachedExternalStringMap)              \
     141             :   V(Map, uncached_external_string_with_one_byte_data_map,                      \
     142             :     UncachedExternalStringWithOneByteDataMap)                                  \
     143             :   V(Map, internalized_string_map, InternalizedStringMap)                       \
     144             :   V(Map, external_internalized_string_map, ExternalInternalizedStringMap)      \
     145             :   V(Map, external_internalized_string_with_one_byte_data_map,                  \
     146             :     ExternalInternalizedStringWithOneByteDataMap)                              \
     147             :   V(Map, external_one_byte_internalized_string_map,                            \
     148             :     ExternalOneByteInternalizedStringMap)                                      \
     149             :   V(Map, uncached_external_internalized_string_map,                            \
     150             :     UncachedExternalInternalizedStringMap)                                     \
     151             :   V(Map, uncached_external_internalized_string_with_one_byte_data_map,         \
     152             :     UncachedExternalInternalizedStringWithOneByteDataMap)                      \
     153             :   V(Map, uncached_external_one_byte_internalized_string_map,                   \
     154             :     UncachedExternalOneByteInternalizedStringMap)                              \
     155             :   V(Map, uncached_external_one_byte_string_map,                                \
     156             :     UncachedExternalOneByteStringMap)                                          \
     157             :   /* Array element maps */                                                     \
     158             :   V(Map, fixed_uint8_array_map, FixedUint8ArrayMap)                            \
     159             :   V(Map, fixed_int8_array_map, FixedInt8ArrayMap)                              \
     160             :   V(Map, fixed_uint16_array_map, FixedUint16ArrayMap)                          \
     161             :   V(Map, fixed_int16_array_map, FixedInt16ArrayMap)                            \
     162             :   V(Map, fixed_uint32_array_map, FixedUint32ArrayMap)                          \
     163             :   V(Map, fixed_int32_array_map, FixedInt32ArrayMap)                            \
     164             :   V(Map, fixed_float32_array_map, FixedFloat32ArrayMap)                        \
     165             :   V(Map, fixed_float64_array_map, FixedFloat64ArrayMap)                        \
     166             :   V(Map, fixed_uint8_clamped_array_map, FixedUint8ClampedArrayMap)             \
     167             :   V(Map, fixed_biguint64_array_map, FixedBigUint64ArrayMap)                    \
     168             :   V(Map, fixed_bigint64_array_map, FixedBigInt64ArrayMap)                      \
     169             :   /* Oddball maps */                                                           \
     170             :   V(Map, undefined_map, UndefinedMap)                                          \
     171             :   V(Map, the_hole_map, TheHoleMap)                                             \
     172             :   V(Map, null_map, NullMap)                                                    \
     173             :   V(Map, boolean_map, BooleanMap)                                              \
     174             :   V(Map, uninitialized_map, UninitializedMap)                                  \
     175             :   V(Map, arguments_marker_map, ArgumentsMarkerMap)                             \
     176             :   V(Map, exception_map, ExceptionMap)                                          \
     177             :   V(Map, termination_exception_map, TerminationExceptionMap)                   \
     178             :   V(Map, optimized_out_map, OptimizedOutMap)                                   \
     179             :   V(Map, stale_register_map, StaleRegisterMap)                                 \
     180             :   V(Map, self_reference_marker_map, SelfReferenceMarkerMap)                    \
     181             :   /* Canonical empty values */                                                 \
     182             :   V(EnumCache, empty_enum_cache, EmptyEnumCache)                               \
     183             :   V(PropertyArray, empty_property_array, EmptyPropertyArray)                   \
     184             :   V(ByteArray, empty_byte_array, EmptyByteArray)                               \
     185             :   V(ObjectBoilerplateDescription, empty_object_boilerplate_description,        \
     186             :     EmptyObjectBoilerplateDescription)                                         \
     187             :   V(ArrayBoilerplateDescription, empty_array_boilerplate_description,          \
     188             :     EmptyArrayBoilerplateDescription)                                          \
     189             :   V(FixedTypedArrayBase, empty_fixed_uint8_array, EmptyFixedUint8Array)        \
     190             :   V(FixedTypedArrayBase, empty_fixed_int8_array, EmptyFixedInt8Array)          \
     191             :   V(FixedTypedArrayBase, empty_fixed_uint16_array, EmptyFixedUint16Array)      \
     192             :   V(FixedTypedArrayBase, empty_fixed_int16_array, EmptyFixedInt16Array)        \
     193             :   V(FixedTypedArrayBase, empty_fixed_uint32_array, EmptyFixedUint32Array)      \
     194             :   V(FixedTypedArrayBase, empty_fixed_int32_array, EmptyFixedInt32Array)        \
     195             :   V(FixedTypedArrayBase, empty_fixed_float32_array, EmptyFixedFloat32Array)    \
     196             :   V(FixedTypedArrayBase, empty_fixed_float64_array, EmptyFixedFloat64Array)    \
     197             :   V(FixedTypedArrayBase, empty_fixed_uint8_clamped_array,                      \
     198             :     EmptyFixedUint8ClampedArray)                                               \
     199             :   V(FixedTypedArrayBase, empty_fixed_biguint64_array,                          \
     200             :     EmptyFixedBigUint64Array)                                                  \
     201             :   V(FixedTypedArrayBase, empty_fixed_bigint64_array, EmptyFixedBigInt64Array)  \
     202             :   V(FixedArray, empty_sloppy_arguments_elements, EmptySloppyArgumentsElements) \
     203             :   V(NumberDictionary, empty_slow_element_dictionary,                           \
     204             :     EmptySlowElementDictionary)                                                \
     205             :   V(FixedArray, empty_ordered_hash_map, EmptyOrderedHashMap)                   \
     206             :   V(FixedArray, empty_ordered_hash_set, EmptyOrderedHashSet)                   \
     207             :   V(FeedbackMetadata, empty_feedback_metadata, EmptyFeedbackMetadata)          \
     208             :   V(PropertyCell, empty_property_cell, EmptyPropertyCell)                      \
     209             :   V(NameDictionary, empty_property_dictionary, EmptyPropertyDictionary)        \
     210             :   V(InterceptorInfo, noop_interceptor_info, NoOpInterceptorInfo)               \
     211             :   V(WeakFixedArray, empty_weak_fixed_array, EmptyWeakFixedArray)               \
     212             :   V(WeakArrayList, empty_weak_array_list, EmptyWeakArrayList)                  \
     213             :   /* Special numbers */                                                        \
     214             :   V(HeapNumber, nan_value, NanValue)                                           \
     215             :   V(HeapNumber, hole_nan_value, HoleNanValue)                                  \
     216             :   V(HeapNumber, infinity_value, InfinityValue)                                 \
     217             :   V(HeapNumber, minus_zero_value, MinusZeroValue)                              \
     218             :   V(HeapNumber, minus_infinity_value, MinusInfinityValue)                      \
     219             :   /* Marker for self-references during code-generation */                      \
     220             :   V(HeapObject, self_reference_marker, SelfReferenceMarker)                    \
     221             :   /* Canonical trampoline RelocInfo */                                         \
     222             :   V(ByteArray, off_heap_trampoline_relocation_info,                            \
     223             :     OffHeapTrampolineRelocationInfo)                                           \
     224             :   /* Hash seed */                                                              \
     225             :   V(ByteArray, hash_seed, HashSeed)
     226             : 
     227             : // Mutable roots that are known to be immortal immovable, for which we can
     228             : // safely skip write barriers.
     229             : #define STRONG_MUTABLE_IMMOVABLE_ROOT_LIST(V)                                \
     230             :   ACCESSOR_INFO_ROOT_LIST(V)                                                 \
     231             :   /* Maps */                                                                 \
     232             :   V(Map, external_map, ExternalMap)                                          \
     233             :   V(Map, message_object_map, JSMessageObjectMap)                             \
     234             :   /* Canonical empty values */                                               \
     235             :   V(Script, empty_script, EmptyScript)                                       \
     236             :   V(FeedbackCell, many_closures_cell, ManyClosuresCell)                      \
     237             :   V(FeedbackCell, no_feedback_cell, NoFeedbackCell)                          \
     238             :   V(Cell, invalid_prototype_validity_cell, InvalidPrototypeValidityCell)     \
     239             :   /* Protectors */                                                           \
     240             :   V(Cell, array_constructor_protector, ArrayConstructorProtector)            \
     241             :   V(PropertyCell, no_elements_protector, NoElementsProtector)                \
     242             :   V(Cell, is_concat_spreadable_protector, IsConcatSpreadableProtector)       \
     243             :   V(PropertyCell, array_species_protector, ArraySpeciesProtector)            \
     244             :   V(PropertyCell, typed_array_species_protector, TypedArraySpeciesProtector) \
     245             :   V(PropertyCell, regexp_species_protector, RegExpSpeciesProtector)          \
     246             :   V(PropertyCell, promise_species_protector, PromiseSpeciesProtector)        \
     247             :   V(Cell, string_length_protector, StringLengthProtector)                    \
     248             :   V(PropertyCell, array_iterator_protector, ArrayIteratorProtector)          \
     249             :   V(PropertyCell, array_buffer_detaching_protector,                          \
     250             :     ArrayBufferDetachingProtector)                                           \
     251             :   V(PropertyCell, promise_hook_protector, PromiseHookProtector)              \
     252             :   V(Cell, promise_resolve_protector, PromiseResolveProtector)                \
     253             :   V(PropertyCell, map_iterator_protector, MapIteratorProtector)              \
     254             :   V(PropertyCell, promise_then_protector, PromiseThenProtector)              \
     255             :   V(PropertyCell, set_iterator_protector, SetIteratorProtector)              \
     256             :   V(PropertyCell, string_iterator_protector, StringIteratorProtector)        \
     257             :   /* Caches */                                                               \
     258             :   V(FixedArray, single_character_string_cache, SingleCharacterStringCache)   \
     259             :   V(FixedArray, string_split_cache, StringSplitCache)                        \
     260             :   V(FixedArray, regexp_multiple_cache, RegExpMultipleCache)                  \
     261             :   /* Indirection lists for isolate-independent builtins */                   \
     262             :   V(FixedArray, builtins_constants_table, BuiltinsConstantsTable)
     263             : 
     264             : // These root references can be updated by the mutator.
     265             : #define STRONG_MUTABLE_MOVABLE_ROOT_LIST(V)                                \
     266             :   /* Caches */                                                             \
     267             :   V(FixedArray, number_string_cache, NumberStringCache)                    \
     268             :   /* Lists and dictionaries */                                             \
     269             :   V(NameDictionary, public_symbol_table, PublicSymbolTable)                \
     270             :   V(NameDictionary, api_symbol_table, ApiSymbolTable)                      \
     271             :   V(NameDictionary, api_private_symbol_table, ApiPrivateSymbolTable)       \
     272             :   V(WeakArrayList, script_list, ScriptList)                                \
     273             :   V(FixedArray, materialized_objects, MaterializedObjects)                 \
     274             :   V(WeakArrayList, detached_contexts, DetachedContexts)                    \
     275             :   V(WeakArrayList, retaining_path_targets, RetainingPathTargets)           \
     276             :   V(WeakArrayList, retained_maps, RetainedMaps)                            \
     277             :   /* Feedback vectors that we need for code coverage or type profile */    \
     278             :   V(Object, feedback_vectors_for_profiling_tools,                          \
     279             :     FeedbackVectorsForProfilingTools)                                      \
     280             :   V(WeakArrayList, noscript_shared_function_infos,                         \
     281             :     NoScriptSharedFunctionInfos)                                           \
     282             :   V(FixedArray, serialized_objects, SerializedObjects)                     \
     283             :   V(FixedArray, serialized_global_proxy_sizes, SerializedGlobalProxySizes) \
     284             :   V(TemplateList, message_listeners, MessageListeners)                     \
     285             :   /* Support for async stack traces */                                     \
     286             :   V(HeapObject, current_microtask, CurrentMicrotask)                       \
     287             :   /* JSWeakFactory objects which need cleanup */                           \
     288             :   V(Object, dirty_js_weak_factories, DirtyJSWeakFactories)                 \
     289             :   /* KeepDuringJob set for JS WeakRefs */                                  \
     290             :   V(HeapObject, weak_refs_keep_during_job, WeakRefsKeepDuringJob)          \
     291             :   V(HeapObject, interpreter_entry_trampoline_for_profiling,                \
     292             :     InterpreterEntryTrampolineForProfiling)
     293             : 
     294             : // Entries in this list are limited to Smis and are not visited during GC.
     295             : #define SMI_ROOT_LIST(V)                                                       \
     296             :   V(Smi, stack_limit, StackLimit)                                              \
     297             :   V(Smi, real_stack_limit, RealStackLimit)                                     \
     298             :   V(Smi, last_script_id, LastScriptId)                                         \
     299             :   V(Smi, last_debugging_id, LastDebuggingId)                                   \
     300             :   /* To distinguish the function templates, so that we can find them in the */ \
     301             :   /* function cache of the native context. */                                  \
     302             :   V(Smi, next_template_serial_number, NextTemplateSerialNumber)                \
     303             :   V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset)     \
     304             :   V(Smi, construct_stub_create_deopt_pc_offset,                                \
     305             :     ConstructStubCreateDeoptPCOffset)                                          \
     306             :   V(Smi, construct_stub_invoke_deopt_pc_offset,                                \
     307             :     ConstructStubInvokeDeoptPCOffset)                                          \
     308             :   V(Smi, interpreter_entry_return_pc_offset, InterpreterEntryReturnPCOffset)
     309             : 
     310             : // Adapts one INTERNALIZED_STRING_LIST_GENERATOR entry to
     311             : // the ROOT_LIST-compatible entry
     312             : #define INTERNALIZED_STRING_LIST_ADAPTER(V, name, ...) V(String, name, name)
     313             : 
     314             : // Produces (String, name, CamelCase) entries
     315             : #define INTERNALIZED_STRING_ROOT_LIST(V) \
     316             :   INTERNALIZED_STRING_LIST_GENERATOR(INTERNALIZED_STRING_LIST_ADAPTER, V)
     317             : 
     318             : // Adapts one XXX_SYMBOL_LIST_GENERATOR entry to the ROOT_LIST-compatible entry
     319             : #define SYMBOL_ROOT_LIST_ADAPTER(V, name, ...) V(Symbol, name, name)
     320             : 
     321             : // Produces (Symbol, name, CamelCase) entries
     322             : #define PRIVATE_SYMBOL_ROOT_LIST(V) \
     323             :   PRIVATE_SYMBOL_LIST_GENERATOR(SYMBOL_ROOT_LIST_ADAPTER, V)
     324             : #define PUBLIC_SYMBOL_ROOT_LIST(V) \
     325             :   PUBLIC_SYMBOL_LIST_GENERATOR(SYMBOL_ROOT_LIST_ADAPTER, V)
     326             : #define WELL_KNOWN_SYMBOL_ROOT_LIST(V) \
     327             :   WELL_KNOWN_SYMBOL_LIST_GENERATOR(SYMBOL_ROOT_LIST_ADAPTER, V)
     328             : 
     329             : // Adapts one ACCESSOR_INFO_LIST_GENERATOR entry to the ROOT_LIST-compatible
     330             : // entry
     331             : #define ACCESSOR_INFO_ROOT_LIST_ADAPTER(V, name, CamelName, ...) \
     332             :   V(AccessorInfo, name##_accessor, CamelName##Accessor)
     333             : 
     334             : // Produces (AccessorInfo, name, CamelCase) entries
     335             : #define ACCESSOR_INFO_ROOT_LIST(V) \
     336             :   ACCESSOR_INFO_LIST_GENERATOR(ACCESSOR_INFO_ROOT_LIST_ADAPTER, V)
     337             : 
     338             : #define READ_ONLY_ROOT_LIST(V)     \
     339             :   STRONG_READ_ONLY_ROOT_LIST(V)    \
     340             :   INTERNALIZED_STRING_ROOT_LIST(V) \
     341             :   PRIVATE_SYMBOL_ROOT_LIST(V)      \
     342             :   PUBLIC_SYMBOL_ROOT_LIST(V)       \
     343             :   WELL_KNOWN_SYMBOL_ROOT_LIST(V)   \
     344             :   STRUCT_MAPS_LIST(V)              \
     345             :   ALLOCATION_SITE_MAPS_LIST(V)     \
     346             :   DATA_HANDLER_MAPS_LIST(V)
     347             : 
     348             : #define MUTABLE_ROOT_LIST(V)                \
     349             :   STRONG_MUTABLE_IMMOVABLE_ROOT_LIST(V)     \
     350             :   STRONG_MUTABLE_MOVABLE_ROOT_LIST(V)       \
     351             :   V(StringTable, string_table, StringTable) \
     352             :   SMI_ROOT_LIST(V)
     353             : 
     354             : #define ROOT_LIST(V)     \
     355             :   READ_ONLY_ROOT_LIST(V) \
     356             :   MUTABLE_ROOT_LIST(V)
     357             : 
     358             : // Declare all the root indices.  This defines the root list order.
     359             : // clang-format off
     360             : enum class RootIndex : uint16_t {
     361             : #define DECL(type, name, CamelName) k##CamelName,
     362             :   ROOT_LIST(DECL)
     363             : #undef DECL
     364             : 
     365             :   kRootListLength,
     366             : 
     367             :   // Helper aliases for inclusive regions of root indices.
     368             :   kFirstRoot = 0,
     369             :   kLastRoot = kRootListLength - 1,
     370             : 
     371             : #define ROOT(...) +1
     372             :   kReadOnlyRootsCount = 0 READ_ONLY_ROOT_LIST(ROOT),
     373             :   kImmortalImmovableRootsCount =
     374             :       kReadOnlyRootsCount STRONG_MUTABLE_IMMOVABLE_ROOT_LIST(ROOT),
     375             : #undef ROOT
     376             :   kFirstReadOnlyRoot = kFirstRoot,
     377             :   kLastReadOnlyRoot = kFirstReadOnlyRoot + kReadOnlyRootsCount - 1,
     378             : 
     379             :   // The strong roots visited by the garbage collector (not including read-only
     380             :   // roots).
     381             :   kFirstStrongRoot = kLastReadOnlyRoot + 1,
     382             :   // (kStringTable is not a strong root).
     383             :   kLastStrongRoot = kStringTable - 1,
     384             : 
     385             :   // All of the strong roots plus the read-only roots.
     386             :   kFirstStrongOrReadOnlyRoot = kFirstRoot,
     387             :   kLastStrongOrReadOnlyRoot = kLastStrongRoot,
     388             : 
     389             :   // All immortal immovable roots including read only ones.
     390             :   kFirstImmortalImmovableRoot = kFirstReadOnlyRoot,
     391             :   kLastImmortalImmovableRoot =
     392             :       kFirstImmortalImmovableRoot + kImmortalImmovableRootsCount - 1,
     393             : 
     394             :   kFirstSmiRoot = kStringTable + 1,
     395             :   kLastSmiRoot = kLastRoot
     396             : };
     397             : // clang-format on
     398             : 
     399             : // Represents a storage of V8 heap roots.
     400             : class RootsTable {
     401             :  public:
     402             :   static constexpr size_t kEntriesCount =
     403             :       static_cast<size_t>(RootIndex::kRootListLength);
     404             : 
     405       62882 :   RootsTable() : roots_{} {}
     406             : 
     407             :   inline bool IsRootHandleLocation(Address* handle_location,
     408             :                                    RootIndex* index) const;
     409             : 
     410             :   template <typename T>
     411             :   bool IsRootHandle(Handle<T> handle, RootIndex* index) const;
     412             : 
     413             :   Address const& operator[](RootIndex root_index) const {
     414             :     size_t index = static_cast<size_t>(root_index);
     415             :     DCHECK_LT(index, kEntriesCount);
     416             :     return roots_[index];
     417             :   }
     418             : 
     419             :   static const char* name(RootIndex root_index) {
     420      231819 :     size_t index = static_cast<size_t>(root_index);
     421             :     DCHECK_LT(index, kEntriesCount);
     422      231819 :     return root_names_[index];
     423             :   }
     424             : 
     425             :   static constexpr int offset_of(RootIndex root_index) {
     426     3186801 :     return static_cast<int>(root_index) * kSystemPointerSize;
     427             :   }
     428             : 
     429             :   static RootIndex RootIndexForFixedTypedArray(ExternalArrayType array_type);
     430             :   static RootIndex RootIndexForFixedTypedArray(ElementsKind elements_kind);
     431             :   static RootIndex RootIndexForEmptyFixedTypedArray(ElementsKind elements_kind);
     432             : 
     433             :   // Immortal immovable root objects are allocated in OLD space and GC never
     434             :   // moves them and the root table entries are guaranteed to not be modified
     435             :   // after initialization. Note, however, that contents of those root objects
     436             :   // that are allocated in writable space can still be modified after
     437             :   // initialization.
     438             :   // Generated code can treat direct references to these roots as constants.
     439             :   static constexpr bool IsImmortalImmovable(RootIndex root_index) {
     440             :     STATIC_ASSERT(static_cast<int>(RootIndex::kFirstImmortalImmovableRoot) ==
     441             :                   0);
     442             :     return static_cast<unsigned>(root_index) <=
     443             :            static_cast<unsigned>(RootIndex::kLastImmortalImmovableRoot);
     444             :   }
     445             : 
     446             :  private:
     447             :   FullObjectSlot begin() {
     448      384030 :     return FullObjectSlot(&roots_[static_cast<size_t>(RootIndex::kFirstRoot)]);
     449             :   }
     450             :   FullObjectSlot end() {
     451             :     return FullObjectSlot(
     452             :         &roots_[static_cast<size_t>(RootIndex::kLastRoot) + 1]);
     453             :   }
     454             : 
     455             :   // Used for iterating over all of the read-only and mutable strong roots.
     456             :   FullObjectSlot strong_or_read_only_roots_begin() {
     457             :     STATIC_ASSERT(static_cast<size_t>(RootIndex::kLastReadOnlyRoot) ==
     458             :                   static_cast<size_t>(RootIndex::kFirstStrongRoot) - 1);
     459             :     return FullObjectSlot(
     460             :         &roots_[static_cast<size_t>(RootIndex::kFirstStrongOrReadOnlyRoot)]);
     461             :   }
     462             :   FullObjectSlot strong_or_read_only_roots_end() {
     463             :     return FullObjectSlot(
     464             :         &roots_[static_cast<size_t>(RootIndex::kLastStrongOrReadOnlyRoot) + 1]);
     465             :   }
     466             : 
     467             :   // The read-only, strong and Smi roots as defined by these accessors are all
     468             :   // disjoint.
     469             :   FullObjectSlot read_only_roots_begin() {
     470             :     return FullObjectSlot(
     471       63477 :         &roots_[static_cast<size_t>(RootIndex::kFirstReadOnlyRoot)]);
     472             :   }
     473             :   FullObjectSlot read_only_roots_end() {
     474             :     return FullObjectSlot(
     475       63477 :         &roots_[static_cast<size_t>(RootIndex::kLastReadOnlyRoot) + 1]);
     476             :   }
     477             : 
     478             :   FullObjectSlot strong_roots_begin() {
     479             :     return FullObjectSlot(
     480      307250 :         &roots_[static_cast<size_t>(RootIndex::kFirstStrongRoot)]);
     481             :   }
     482             :   FullObjectSlot strong_roots_end() {
     483             :     return FullObjectSlot(
     484      307250 :         &roots_[static_cast<size_t>(RootIndex::kLastStrongRoot) + 1]);
     485             :   }
     486             : 
     487             :   FullObjectSlot smi_roots_begin() {
     488             :     return FullObjectSlot(
     489       63078 :         &roots_[static_cast<size_t>(RootIndex::kFirstSmiRoot)]);
     490             :   }
     491             :   FullObjectSlot smi_roots_end() {
     492             :     return FullObjectSlot(
     493       63078 :         &roots_[static_cast<size_t>(RootIndex::kLastSmiRoot) + 1]);
     494             :   }
     495             : 
     496  7664576272 :   Address& operator[](RootIndex root_index) {
     497  8599830257 :     size_t index = static_cast<size_t>(root_index);
     498             :     DCHECK_LT(index, kEntriesCount);
     499  7664576272 :     return roots_[index];
     500             :   }
     501             : 
     502             :   Address roots_[kEntriesCount];
     503             :   static const char* root_names_[kEntriesCount];
     504             : 
     505             :   friend class Isolate;
     506             :   friend class Heap;
     507             :   friend class Factory;
     508             :   friend class ReadOnlyRoots;
     509             :   friend class RootsSerializer;
     510             : };
     511             : 
     512             : class ReadOnlyRoots {
     513             :  public:
     514             :   V8_INLINE explicit ReadOnlyRoots(Heap* heap);
     515             :   V8_INLINE explicit ReadOnlyRoots(Isolate* isolate);
     516             : 
     517             : #define ROOT_ACCESSOR(Type, name, CamelName) \
     518             :   V8_INLINE class Type name() const;         \
     519             :   V8_INLINE Handle<Type> name##_handle() const;
     520             : 
     521             :   READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
     522             : #undef ROOT_ACCESSOR
     523             : 
     524             :   V8_INLINE Map MapForFixedTypedArray(ExternalArrayType array_type);
     525             :   V8_INLINE Map MapForFixedTypedArray(ElementsKind elements_kind);
     526             :   V8_INLINE FixedTypedArrayBase EmptyFixedTypedArrayForMap(const Map map);
     527             : 
     528             :   // Iterate over all the read-only roots. This is not necessary for garbage
     529             :   // collection and is usually only performed as part of (de)serialization or
     530             :   // heap verification.
     531             :   void Iterate(RootVisitor* visitor);
     532             : 
     533             :  private:
     534             :   RootsTable& roots_table_;
     535             : };
     536             : 
     537             : }  // namespace internal
     538             : }  // namespace v8
     539             : 
     540             : #endif  // V8_ROOTS_H_

Generated by: LCOV version 1.10