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

Generated by: LCOV version 1.10