Commit f9c4d000 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[explicit isolates] Move remaining roots to ReadOnyRoots

Moves STRUCT_LIST AND ALLOCATION_SITE_LIST into roots.h and adds access
to their associated maps using ReadOnlyRoots.

Also corrects the location of external_map, message_object_map,
empty_script, many_closures_cell, invalid_prototype_validity_cell and
builtins_constants_table which are not in RO_SPACE.

Finally this adds a convenience ReadOnlyRoots(Isolate*) constructor.

Bug: v8:7786
Change-Id: I4982dd0cbea2062a124605678599ba48831f020f
Reviewed-on: https://chromium-review.googlesource.com/1124319Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54178}
parent 37dd992c
This diff is collapsed.
This diff is collapsed.
......@@ -13,6 +13,8 @@ namespace v8 {
namespace internal {
ReadOnlyRoots::ReadOnlyRoots(Isolate* isolate) : heap_(isolate->heap()) {}
#define ROOT_ACCESSOR(type, name, camel_name) \
type* ReadOnlyRoots::name() { return heap_->name(); }
STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
......@@ -34,6 +36,16 @@ PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define STRUCT_MAP_ACCESSOR(NAME, Name, name) \
Map* ReadOnlyRoots::name##_map() { return heap_->name##_map(); }
STRUCT_LIST(STRUCT_MAP_ACCESSOR)
#undef STRUCT_MAP_ACCESSOR
#define ALLOCATION_SITE_MAP_ACCESSOR(NAME, Name, Size, name) \
Map* ReadOnlyRoots::name##_map() { return heap_->name##_map(); }
ALLOCATION_SITE_LIST(ALLOCATION_SITE_MAP_ACCESSOR)
#undef ALLOCATION_SITE_MAP_ACCESSOR
} // namespace internal
} // namespace v8
......
......@@ -6,6 +6,7 @@
#define V8_ROOTS_H_
#include "src/heap-symbols.h"
#include "src/objects-definitions.h"
namespace v8 {
......@@ -76,11 +77,9 @@ namespace internal {
V(Map, bytecode_array_map, BytecodeArrayMap) \
V(Map, code_data_container_map, CodeDataContainerMap) \
V(Map, descriptor_array_map, DescriptorArrayMap) \
V(Map, external_map, ExternalMap) \
V(Map, fixed_double_array_map, FixedDoubleArrayMap) \
V(Map, global_dictionary_map, GlobalDictionaryMap) \
V(Map, many_closures_cell_map, ManyClosuresCellMap) \
V(Map, message_object_map, JSMessageObjectMap) \
V(Map, module_info_map, ModuleInfoMap) \
V(Map, mutable_heap_number_map, MutableHeapNumberMap) \
V(Map, name_dictionary_map, NameDictionaryMap) \
......@@ -175,8 +174,6 @@ namespace internal {
V(FixedTypedArrayBase, empty_fixed_biguint64_array, \
EmptyFixedBigUint64Array) \
V(FixedTypedArrayBase, empty_fixed_bigint64_array, EmptyFixedBigInt64Array) \
V(Script, empty_script, EmptyScript) \
V(FeedbackCell, many_closures_cell, ManyClosuresCell) \
V(FixedArray, empty_sloppy_arguments_elements, EmptySloppyArgumentsElements) \
V(NumberDictionary, empty_slow_element_dictionary, \
EmptySlowElementDictionary) \
......@@ -185,7 +182,6 @@ namespace internal {
V(FeedbackMetadata, empty_feedback_metadata, EmptyFeedbackMetadata) \
V(PropertyCell, empty_property_cell, EmptyPropertyCell) \
V(WeakCell, empty_weak_cell, EmptyWeakCell) \
V(Cell, invalid_prototype_validity_cell, InvalidPrototypeValidityCell) \
V(InterceptorInfo, noop_interceptor_info, NoOpInterceptorInfo) \
V(WeakFixedArray, empty_weak_fixed_array, EmptyWeakFixedArray) \
V(WeakArrayList, empty_weak_array_list, EmptyWeakArrayList) \
......@@ -196,11 +192,16 @@ namespace internal {
V(HeapNumber, minus_zero_value, MinusZeroValue) \
V(HeapNumber, minus_infinity_value, MinusInfinityValue) \
/* Marker for self-references during code-generation */ \
V(HeapObject, self_reference_marker, SelfReferenceMarker) \
/* Indirection lists for isolate-independent builtins */ \
V(FixedArray, builtins_constants_table, BuiltinsConstantsTable)
V(HeapObject, self_reference_marker, SelfReferenceMarker)
#define STRONG_MUTABLE_ROOT_LIST(V) \
/* Maps */ \
V(Map, external_map, ExternalMap) \
V(Map, message_object_map, JSMessageObjectMap) \
/* Canonical empty values */ \
V(Script, empty_script, EmptyScript) \
V(FeedbackCell, many_closures_cell, ManyClosuresCell) \
V(Cell, invalid_prototype_validity_cell, InvalidPrototypeValidityCell) \
/* Protectors */ \
V(Cell, array_constructor_protector, ArrayConstructorProtector) \
V(PropertyCell, no_elements_protector, NoElementsProtector) \
......@@ -232,6 +233,8 @@ namespace internal {
V(FixedArray, detached_contexts, DetachedContexts) \
V(HeapObject, retaining_path_targets, RetainingPathTargets) \
V(WeakArrayList, retained_maps, RetainedMaps) \
/* Indirection lists for isolate-independent builtins */ \
V(FixedArray, builtins_constants_table, BuiltinsConstantsTable) \
/* Feedback vectors that we need for code coverage or type profile */ \
V(Object, feedback_vectors_for_profiling_tools, \
FeedbackVectorsForProfilingTools) \
......@@ -271,18 +274,24 @@ namespace internal {
ConstructStubInvokeDeoptPCOffset) \
V(Smi, interpreter_entry_return_pc_offset, InterpreterEntryReturnPCOffset)
#define ROOT_LIST(V) \
STRONG_ROOT_LIST(V) \
SMI_ROOT_LIST(V) \
#define MUTABLE_ROOT_LIST(V) \
STRONG_MUTABLE_ROOT_LIST(V) \
SMI_ROOT_LIST(V) \
V(StringTable, string_table, StringTable)
#define ROOT_LIST(V) \
MUTABLE_ROOT_LIST(V) \
STRONG_READ_ONLY_ROOT_LIST(V)
class Heap;
class Isolate;
class String;
class Symbol;
class ReadOnlyRoots {
public:
explicit ReadOnlyRoots(Heap* heap) : heap_(heap) {}
inline explicit ReadOnlyRoots(Isolate* isolate);
#define ROOT_ACCESSOR(type, name, camel_name) inline class type* name();
STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
......@@ -301,6 +310,16 @@ class ReadOnlyRoots {
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
// Utility type maps.
#define STRUCT_MAP_ACCESSOR(NAME, Name, name) inline Map* name##_map();
STRUCT_LIST(STRUCT_MAP_ACCESSOR)
#undef STRUCT_MAP_ACCESSOR
#define ALLOCATION_SITE_MAP_ACCESSOR(NAME, Name, Size, name) \
inline Map* name##_map();
ALLOCATION_SITE_LIST(ALLOCATION_SITE_MAP_ACCESSOR)
#undef ALLOCATION_SITE_MAP_ACCESSOR
private:
Heap* heap_;
};
......
......@@ -41,21 +41,25 @@ class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
void Free(void* p, size_t) override {}
};
#define RO_ROOT_LIST_CASE(type, name, camel_name) \
if (n == NULL && o == roots.name()) n = #camel_name;
#define ROOT_LIST_CASE(type, name, camel_name) \
if (n == NULL && o == space->heap()->name()) n = #camel_name;
#define STRUCT_LIST_CASE(upper_name, camel_name, name) \
if (n == NULL && o == space->heap()->name##_map()) n = #camel_name "Map";
if (n == NULL && o == roots.name##_map()) n = #camel_name "Map";
#define ALLOCATION_SITE_LIST_CASE(upper_name, camel_name, size, name) \
if (n == NULL && o == space->heap()->name##_map()) n = #camel_name "Map";
if (n == NULL && o == roots.name##_map()) n = #camel_name "Map";
static void DumpMaps(i::PagedSpace* space) {
i::HeapObjectIterator it(space);
i::ReadOnlyRoots roots(space->heap());
for (i::Object* o = it.Next(); o != NULL; o = it.Next()) {
if (!o->IsMap()) continue;
i::Map* m = i::Map::cast(o);
const char* n = NULL;
intptr_t p = reinterpret_cast<intptr_t>(m) & 0x7FFFF;
int t = m->instance_type();
ROOT_LIST(ROOT_LIST_CASE)
STRONG_READ_ONLY_ROOT_LIST(RO_ROOT_LIST_CASE)
MUTABLE_ROOT_LIST(ROOT_LIST_CASE)
STRUCT_LIST(STRUCT_LIST_CASE)
ALLOCATION_SITE_LIST(ALLOCATION_SITE_LIST_CASE)
if (n == NULL) continue;
......@@ -67,6 +71,7 @@ static void DumpMaps(i::PagedSpace* space) {
#undef ALLOCATION_SITE_LIST_CASE
#undef STRUCT_LIST_CASE
#undef ROOT_LIST_CASE
#undef RO_ROOT_LIST_CASE
static int DumpHeapConstants(const char* argv0) {
// Start up V8.
......@@ -81,6 +86,7 @@ static int DumpHeapConstants(const char* argv0) {
{
Isolate::Scope scope(isolate);
i::Heap* heap = reinterpret_cast<i::Isolate*>(isolate)->heap();
i::ReadOnlyRoots roots(heap);
i::PrintF("%s", kHeader);
#define DUMP_TYPE(T) i::PrintF(" %d: \"%s\",\n", i::T, #T);
i::PrintF("INSTANCE_TYPES = {\n");
......@@ -97,6 +103,11 @@ static int DumpHeapConstants(const char* argv0) {
// Dump the KNOWN_OBJECTS table to the console.
i::PrintF("\n# List of known V8 objects.\n");
#define RO_ROOT_LIST_CASE(type, name, camel_name) \
if (n == NULL && o == roots.name()) { \
n = #camel_name; \
i = i::Heap::k##camel_name##RootIndex; \
}
#define ROOT_LIST_CASE(type, name, camel_name) \
if (n == NULL && o == heap->name()) { \
n = #camel_name; \
......@@ -116,7 +127,8 @@ static int DumpHeapConstants(const char* argv0) {
const char* n = NULL;
i::Heap::RootListIndex i = i::Heap::kStrongRootListLength;
intptr_t p = reinterpret_cast<intptr_t>(o) & 0x7FFFF;
ROOT_LIST(ROOT_LIST_CASE)
STRONG_READ_ONLY_ROOT_LIST(RO_ROOT_LIST_CASE)
MUTABLE_ROOT_LIST(ROOT_LIST_CASE)
if (n == NULL) continue;
if (!i::Heap::RootIsImmortalImmovable(i)) continue;
i::PrintF(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n);
......@@ -124,6 +136,7 @@ static int DumpHeapConstants(const char* argv0) {
}
i::PrintF("}\n");
#undef ROOT_LIST_CASE
#undef RO_ROOT_LIST_CASE
// Dump frame markers
i::PrintF("\n# List of known V8 Frame Markers.\n");
......
......@@ -272,8 +272,8 @@ KNOWN_MAPS = {
("RO_SPACE", 0x04f99): (148, "FixedBigInt64ArrayMap"),
("RO_SPACE", 0x05001): (131, "SelfReferenceMarkerMap"),
("RO_SPACE", 0x05081): (171, "Tuple2Map"),
("RO_SPACE", 0x05279): (169, "ScriptMap"),
("RO_SPACE", 0x05441): (161, "InterceptorInfoMap"),
("RO_SPACE", 0x053c9): (161, "InterceptorInfoMap"),
("RO_SPACE", 0x054e9): (169, "ScriptMap"),
("RO_SPACE", 0x09dc1): (154, "AccessorInfoMap"),
("RO_SPACE", 0x09fd1): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x0a039): (155, "AccessorPairMap"),
......@@ -333,26 +333,26 @@ KNOWN_OBJECTS = {
("RO_SPACE", 0x051d9): "EmptyFixedFloat32Array",
("RO_SPACE", 0x051f9): "EmptyFixedFloat64Array",
("RO_SPACE", 0x05219): "EmptyFixedUint8ClampedArray",
("RO_SPACE", 0x052f1): "EmptySloppyArgumentsElements",
("RO_SPACE", 0x05311): "EmptySlowElementDictionary",
("RO_SPACE", 0x05359): "EmptyOrderedHashMap",
("RO_SPACE", 0x05381): "EmptyOrderedHashSet",
("RO_SPACE", 0x053b9): "EmptyPropertyCell",
("RO_SPACE", 0x053e1): "EmptyWeakCell",
("RO_SPACE", 0x054c1): "InfinityValue",
("RO_SPACE", 0x054d1): "MinusZeroValue",
("RO_SPACE", 0x054e1): "MinusInfinityValue",
("RO_SPACE", 0x054f1): "SelfReferenceMarker",
("RO_SPACE", 0x05279): "EmptySloppyArgumentsElements",
("RO_SPACE", 0x05299): "EmptySlowElementDictionary",
("RO_SPACE", 0x052e1): "EmptyOrderedHashMap",
("RO_SPACE", 0x05309): "EmptyOrderedHashSet",
("RO_SPACE", 0x05341): "EmptyPropertyCell",
("RO_SPACE", 0x05369): "EmptyWeakCell",
("RO_SPACE", 0x05459): "InfinityValue",
("RO_SPACE", 0x05469): "MinusZeroValue",
("RO_SPACE", 0x05479): "MinusInfinityValue",
("RO_SPACE", 0x05489): "SelfReferenceMarker",
("OLD_SPACE", 0x02211): "EmptyScript",
("OLD_SPACE", 0x02299): "ManyClosuresCell",
("OLD_SPACE", 0x02919): "NoElementsProtector",
("OLD_SPACE", 0x02941): "IsConcatSpreadableProtector",
("OLD_SPACE", 0x02951): "ArraySpeciesProtector",
("OLD_SPACE", 0x02979): "TypedArraySpeciesProtector",
("OLD_SPACE", 0x029a1): "PromiseSpeciesProtector",
("OLD_SPACE", 0x029c9): "StringLengthProtector",
("OLD_SPACE", 0x029d9): "ArrayIteratorProtector",
("OLD_SPACE", 0x02a01): "ArrayBufferNeuteringProtector",
("OLD_SPACE", 0x022b9): "NoElementsProtector",
("OLD_SPACE", 0x022e1): "IsConcatSpreadableProtector",
("OLD_SPACE", 0x022f1): "ArraySpeciesProtector",
("OLD_SPACE", 0x02319): "TypedArraySpeciesProtector",
("OLD_SPACE", 0x02341): "PromiseSpeciesProtector",
("OLD_SPACE", 0x02369): "StringLengthProtector",
("OLD_SPACE", 0x02379): "ArrayIteratorProtector",
("OLD_SPACE", 0x023a1): "ArrayBufferNeuteringProtector",
}
# List of known V8 Frame Markers.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment