[cleanup] Ensure [READ_ONLY|MUTABLE]_ROOT_LIST contain ALL RO/mutable entries

... so that it is no longer needed to iterate over other lists.
This CL also moves data handler maps to the RO roots list (because they are RO).

Bug: v8:8015
Change-Id: If21fe5bac5a6ac1e44a47783ad930df5fcecda9a
Reviewed-on: https://chromium-review.googlesource.com/1240134
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56169}
This commit is contained in:
Igor Sheludko 2018-09-24 12:37:57 +02:00 committed by Commit Bot
parent c9ef63e568
commit c9e4a21c16
11 changed files with 70 additions and 153 deletions

View File

@ -32,8 +32,7 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
V(PromiseSpeciesProtector, promise_species_protector, \
PromiseSpeciesProtector) \
V(TypedArraySpeciesProtector, typed_array_species_protector, \
TypedArraySpeciesProtector) \
V(StoreHandler0Map, store_handler0_map, StoreHandler0Map)
TypedArraySpeciesProtector)
#define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) \
V(AccessorInfoMap, accessor_info_map, AccessorInfoMap) \
@ -70,6 +69,7 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
V(PreParsedScopeDataMap, pre_parsed_scope_data_map, PreParsedScopeDataMap) \
V(prototype_string, prototype_string, PrototypeString) \
V(SharedFunctionInfoMap, shared_function_info_map, SharedFunctionInfoMap) \
V(StoreHandler0Map, store_handler0_map, StoreHandler0Map) \
V(SymbolMap, symbol_map, SymbolMap) \
V(TheHoleValue, the_hole_value, TheHole) \
V(TransitionArrayMap, transition_array_map, TransitionArrayMap) \

View File

@ -22,14 +22,6 @@ namespace internal {
&isolate()->heap()->roots_[RootIndex::k##CamelName])); \
}
ROOT_LIST(ROOT_ACCESSOR)
STRUCT_MAPS_LIST(ROOT_ACCESSOR)
ALLOCATION_SITE_MAPS_LIST(ROOT_ACCESSOR)
DATA_HANDLER_MAPS_LIST(ROOT_ACCESSOR)
INTERNALIZED_STRING_ROOT_LIST(ROOT_ACCESSOR)
PRIVATE_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
PUBLIC_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
WELL_KNOWN_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
ACCESSOR_INFO_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
Handle<String> Factory::InternalizeString(Handle<String> string) {

View File

@ -827,15 +827,6 @@ class V8_EXPORT_PRIVATE Factory {
#define ROOT_ACCESSOR(type, name, CamelName) inline Handle<type> name();
ROOT_LIST(ROOT_ACCESSOR)
STRUCT_MAPS_LIST(ROOT_ACCESSOR)
ALLOCATION_SITE_MAPS_LIST(ROOT_ACCESSOR)
DATA_HANDLER_MAPS_LIST(ROOT_ACCESSOR)
INTERNALIZED_STRING_ROOT_LIST(ROOT_ACCESSOR)
PRIVATE_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
PUBLIC_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
WELL_KNOWN_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
ACCESSOR_INFO_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
// Allocates a new SharedFunctionInfo object.

View File

@ -58,8 +58,6 @@ HeapObject* AllocationResult::ToObjectChecked() {
#define ROOT_ACCESSOR(type, name, CamelName) \
type* Heap::name() { return type::cast(roots_[RootIndex::k##CamelName]); }
MUTABLE_ROOT_LIST(ROOT_ACCESSOR)
DATA_HANDLER_MAPS_LIST(ROOT_ACCESSOR)
ACCESSOR_INFO_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
#define ROOT_ACCESSOR(type, name, CamelName) \

View File

@ -774,9 +774,6 @@ class Heap {
// Heap root getters.
#define ROOT_ACCESSOR(type, name, CamelName) inline type* name();
MUTABLE_ROOT_LIST(ROOT_ACCESSOR)
DATA_HANDLER_MAPS_LIST(ROOT_ACCESSOR)
ACCESSOR_INFO_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
Object* root(RootIndex index) { return roots_[index]; }

View File

@ -1854,22 +1854,13 @@ void V8HeapExplorer::SetGcSubrootReference(Root root, const char* description,
const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) {
ReadOnlyRoots roots(heap_);
if (strong_gc_subroot_names_.empty()) {
#define ROOT_NAME(type, name, CamelName) \
#define MUTABLE_ROOT_NAME(type, name, CamelName) \
strong_gc_subroot_names_.emplace(heap_->name(), #name);
#define RO_ROOT_NAME(type, name, CamelName) \
strong_gc_subroot_names_.emplace(roots.name(), #name);
STRONG_MUTABLE_ROOT_LIST(ROOT_NAME)
STRONG_READ_ONLY_ROOT_LIST(RO_ROOT_NAME)
STRUCT_MAPS_LIST(RO_ROOT_NAME)
ALLOCATION_SITE_MAPS_LIST(RO_ROOT_NAME)
DATA_HANDLER_MAPS_LIST(ROOT_NAME)
INTERNALIZED_STRING_ROOT_LIST(RO_ROOT_NAME)
PRIVATE_SYMBOL_ROOT_LIST(RO_ROOT_NAME)
PUBLIC_SYMBOL_ROOT_LIST(RO_ROOT_NAME)
WELL_KNOWN_SYMBOL_ROOT_LIST(RO_ROOT_NAME)
ACCESSOR_INFO_ROOT_LIST(ROOT_NAME)
#undef ROOT_NAME
MUTABLE_ROOT_LIST(MUTABLE_ROOT_NAME)
READ_ONLY_ROOT_LIST(RO_ROOT_NAME)
#undef MUTABLE_ROOT_NAME
#undef RO_ROOT_NAME
CHECK(!strong_gc_subroot_names_.empty());
}

View File

@ -25,13 +25,7 @@ ReadOnlyRoots::ReadOnlyRoots(Isolate* isolate) : heap_(isolate->heap()) {}
bit_cast<type**>(&heap_->roots_[RootIndex::k##CamelName])); \
}
STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
INTERNALIZED_STRING_ROOT_LIST(ROOT_ACCESSOR)
PRIVATE_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
PUBLIC_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
WELL_KNOWN_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
STRUCT_MAPS_LIST(ROOT_ACCESSOR)
ALLOCATION_SITE_MAPS_LIST(ROOT_ACCESSOR)
READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
FixedTypedArrayBase* ReadOnlyRoots::EmptyFixedTypedArrayForMap(const Map* map) {

View File

@ -258,10 +258,6 @@ namespace internal {
V(Code, js_construct_entry_code, JsConstructEntryCode) \
V(Code, js_run_microtasks_entry_code, JsRunMicrotasksEntryCode)
#define STRONG_ROOT_LIST(V) \
STRONG_READ_ONLY_ROOT_LIST(V) \
STRONG_MUTABLE_ROOT_LIST(V)
// Entries in this list are limited to Smis and are not visited during GC.
#define SMI_ROOT_LIST(V) \
V(Smi, stack_limit, StackLimit) \
@ -278,15 +274,6 @@ namespace internal {
ConstructStubInvokeDeoptPCOffset) \
V(Smi, interpreter_entry_return_pc_offset, InterpreterEntryReturnPCOffset)
#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)
// Adapts one INTERNALIZED_STRING_LIST_GENERATOR entry to
// the ROOT_LIST-compatible entry
#define INTERNALIZED_STRING_LIST_ADAPTER(V, name, ...) V(String, name, name)
@ -315,25 +302,31 @@ namespace internal {
#define ACCESSOR_INFO_ROOT_LIST(V) \
ACCESSOR_INFO_LIST_GENERATOR(ACCESSOR_INFO_ROOT_LIST_ADAPTER, V)
#define READ_ONLY_ROOT_LIST(V) \
STRONG_READ_ONLY_ROOT_LIST(V) \
INTERNALIZED_STRING_ROOT_LIST(V) \
PRIVATE_SYMBOL_ROOT_LIST(V) \
PUBLIC_SYMBOL_ROOT_LIST(V) \
WELL_KNOWN_SYMBOL_ROOT_LIST(V) \
STRUCT_MAPS_LIST(V) \
ALLOCATION_SITE_MAPS_LIST(V) \
DATA_HANDLER_MAPS_LIST(V)
#define MUTABLE_ROOT_LIST(V) \
STRONG_MUTABLE_ROOT_LIST(V) \
ACCESSOR_INFO_ROOT_LIST(V) \
V(StringTable, string_table, StringTable) \
SMI_ROOT_LIST(V)
#define ROOT_LIST(V) \
READ_ONLY_ROOT_LIST(V) \
MUTABLE_ROOT_LIST(V)
// Declare all the root indices. This defines the root list order.
// clang-format off
enum class RootIndex {
#define DECL(type, name, CamelName) k##CamelName,
STRONG_ROOT_LIST(DECL)
INTERNALIZED_STRING_ROOT_LIST(DECL)
PRIVATE_SYMBOL_ROOT_LIST(DECL)
PUBLIC_SYMBOL_ROOT_LIST(DECL)
WELL_KNOWN_SYMBOL_ROOT_LIST(DECL)
ACCESSOR_INFO_ROOT_LIST(DECL)
STRUCT_MAPS_LIST(DECL)
ALLOCATION_SITE_MAPS_LIST(DECL)
DATA_HANDLER_MAPS_LIST(DECL)
#undef DECL
kStringTable,
#define DECL(type, name, CamelName) k##CamelName,
SMI_ROOT_LIST(DECL)
ROOT_LIST(DECL)
#undef DECL
kRootListLength,
@ -404,13 +397,7 @@ class ReadOnlyRoots {
inline class type* name(); \
inline Handle<type> name##_handle();
STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
INTERNALIZED_STRING_ROOT_LIST(ROOT_ACCESSOR)
PRIVATE_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
PUBLIC_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
WELL_KNOWN_SYMBOL_ROOT_LIST(ROOT_ACCESSOR)
STRUCT_MAPS_LIST(ROOT_ACCESSOR)
ALLOCATION_SITE_MAPS_LIST(ROOT_ACCESSOR)
READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
inline FixedTypedArrayBase* EmptyFixedTypedArrayForMap(const Map* map);

View File

@ -24,41 +24,10 @@ AllocationSpace GetSpaceFromObject(Object* object) {
// The following tests check that all the roots accessible via ReadOnlyRoots are
// in RO_SPACE.
TEST(TestStrongReadOnlyRoots) {
TEST(TestReadOnlyRoots) {
ReadOnlyRoots roots(CcTest::i_isolate());
STRONG_READ_ONLY_ROOT_LIST(CHECK_IN_RO_SPACE)
}
TEST(TestInternalizedStrings) {
ReadOnlyRoots roots(CcTest::i_isolate());
INTERNALIZED_STRING_ROOT_LIST(CHECK_IN_RO_SPACE)
}
TEST(TestPrivateSymbols) {
ReadOnlyRoots roots(CcTest::i_isolate());
PRIVATE_SYMBOL_ROOT_LIST(CHECK_IN_RO_SPACE)
}
TEST(TestPublicSymbols) {
ReadOnlyRoots roots(CcTest::i_isolate());
PUBLIC_SYMBOL_ROOT_LIST(CHECK_IN_RO_SPACE)
WELL_KNOWN_SYMBOL_ROOT_LIST(CHECK_IN_RO_SPACE)
}
TEST(TestStructMaps) {
ReadOnlyRoots roots(CcTest::i_isolate());
STRUCT_MAPS_LIST(CHECK_IN_RO_SPACE)
}
TEST(TestAllocationSiteMaps) {
ReadOnlyRoots roots(CcTest::i_isolate());
ALLOCATION_SITE_MAPS_LIST(CHECK_IN_RO_SPACE)
READ_ONLY_ROOT_LIST(CHECK_IN_RO_SPACE)
}
#undef CHECK_IN_RO_SPACE
@ -107,13 +76,6 @@ TEST(TestHeapRootsNotReadOnly) {
MUTABLE_ROOT_LIST(CHECK_NOT_IN_RO_SPACE)
}
TEST(TestAccessorInfosNotReadOnly) {
Factory* factory = CcTest::i_isolate()->factory();
Heap* heap = CcTest::i_isolate()->heap();
ACCESSOR_INFO_ROOT_LIST(CHECK_NOT_IN_RO_SPACE)
}
#undef CHECK_NOT_IN_RO_SPACE
} // namespace internal

View File

@ -43,7 +43,7 @@ class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
#define RO_ROOT_LIST_CASE(type, name, CamelName) \
if (n == NULL && o == roots.name()) n = #CamelName;
#define ROOT_LIST_CASE(type, name, CamelName) \
#define MUTABLE_ROOT_LIST_CASE(type, name, CamelName) \
if (n == NULL && o == space->heap()->name()) n = #CamelName;
static void DumpMaps(i::PagedSpace* space) {
i::HeapObjectIterator it(space);
@ -54,17 +54,15 @@ static void DumpMaps(i::PagedSpace* space) {
const char* n = nullptr;
intptr_t p = reinterpret_cast<intptr_t>(m) & 0x7FFFF;
int t = m->instance_type();
STRONG_READ_ONLY_ROOT_LIST(RO_ROOT_LIST_CASE)
MUTABLE_ROOT_LIST(ROOT_LIST_CASE)
STRUCT_MAPS_LIST(RO_ROOT_LIST_CASE)
ALLOCATION_SITE_MAPS_LIST(RO_ROOT_LIST_CASE)
READ_ONLY_ROOT_LIST(RO_ROOT_LIST_CASE)
MUTABLE_ROOT_LIST(MUTABLE_ROOT_LIST_CASE)
if (n == nullptr) continue;
const char* sname = space->name();
i::PrintF(" (\"%s\", 0x%05" V8PRIxPTR "): (%d, \"%s\"),\n", sname, p, t,
n);
}
}
#undef ROOT_LIST_CASE
#undef MUTABLE_ROOT_LIST_CASE
#undef RO_ROOT_LIST_CASE
static int DumpHeapConstants(const char* argv0) {

View File

@ -288,34 +288,41 @@ KNOWN_MAPS = {
("RO_SPACE", 0x04711): (171, "Tuple2Map"),
("RO_SPACE", 0x047b1): (173, "ArrayBoilerplateDescriptionMap"),
("RO_SPACE", 0x04aa1): (161, "InterceptorInfoMap"),
("RO_SPACE", 0x04b91): (169, "ScriptMap"),
("RO_SPACE", 0x04c59): (181, "MicrotaskQueueMap"),
("RO_SPACE", 0x08d41): (154, "AccessorInfoMap"),
("RO_SPACE", 0x08d91): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x08de1): (155, "AccessorPairMap"),
("RO_SPACE", 0x08e31): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x08e81): (157, "AllocationMementoMap"),
("RO_SPACE", 0x08ed1): (158, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x08f21): (159, "DebugInfoMap"),
("RO_SPACE", 0x08f71): (160, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x08fc1): (162, "InterpreterDataMap"),
("RO_SPACE", 0x09011): (163, "ModuleInfoEntryMap"),
("RO_SPACE", 0x09061): (164, "ModuleMap"),
("RO_SPACE", 0x090b1): (165, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x09101): (166, "PromiseCapabilityMap"),
("RO_SPACE", 0x09151): (167, "PromiseReactionMap"),
("RO_SPACE", 0x091a1): (168, "PrototypeInfoMap"),
("RO_SPACE", 0x091f1): (170, "StackFrameInfoMap"),
("RO_SPACE", 0x09241): (172, "Tuple3Map"),
("RO_SPACE", 0x09291): (174, "WasmDebugInfoMap"),
("RO_SPACE", 0x092e1): (175, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x09331): (176, "CallableTaskMap"),
("RO_SPACE", 0x09381): (177, "CallbackTaskMap"),
("RO_SPACE", 0x093d1): (178, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x09421): (179, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x09471): (180, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x094c1): (182, "AllocationSiteWithWeakNextMap"),
("RO_SPACE", 0x09511): (182, "AllocationSiteWithoutWeakNextMap"),
("RO_SPACE", 0x06d11): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x06d61): (154, "AccessorInfoMap"),
("RO_SPACE", 0x06db1): (155, "AccessorPairMap"),
("RO_SPACE", 0x06e01): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x06e51): (157, "AllocationMementoMap"),
("RO_SPACE", 0x06ea1): (158, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x06ef1): (159, "DebugInfoMap"),
("RO_SPACE", 0x06f41): (160, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x06f91): (162, "InterpreterDataMap"),
("RO_SPACE", 0x06fe1): (163, "ModuleInfoEntryMap"),
("RO_SPACE", 0x07031): (164, "ModuleMap"),
("RO_SPACE", 0x07081): (165, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x070d1): (166, "PromiseCapabilityMap"),
("RO_SPACE", 0x07121): (167, "PromiseReactionMap"),
("RO_SPACE", 0x07171): (168, "PrototypeInfoMap"),
("RO_SPACE", 0x071c1): (169, "ScriptMap"),
("RO_SPACE", 0x07211): (170, "StackFrameInfoMap"),
("RO_SPACE", 0x07261): (172, "Tuple3Map"),
("RO_SPACE", 0x072b1): (174, "WasmDebugInfoMap"),
("RO_SPACE", 0x07301): (175, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x07351): (176, "CallableTaskMap"),
("RO_SPACE", 0x073a1): (177, "CallbackTaskMap"),
("RO_SPACE", 0x073f1): (178, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x07441): (179, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x07491): (180, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x074e1): (181, "MicrotaskQueueMap"),
("RO_SPACE", 0x07531): (182, "AllocationSiteWithWeakNextMap"),
("RO_SPACE", 0x07581): (182, "AllocationSiteWithoutWeakNextMap"),
("RO_SPACE", 0x075d1): (213, "LoadHandler1Map"),
("RO_SPACE", 0x07621): (213, "LoadHandler2Map"),
("RO_SPACE", 0x07671): (213, "LoadHandler3Map"),
("RO_SPACE", 0x076c1): (220, "StoreHandler0Map"),
("RO_SPACE", 0x07711): (220, "StoreHandler1Map"),
("RO_SPACE", 0x07761): (220, "StoreHandler2Map"),
("RO_SPACE", 0x077b1): (220, "StoreHandler3Map"),
("MAP_SPACE", 0x02201): (1057, "ExternalMap"),
("MAP_SPACE", 0x02251): (1072, "JSMessageObjectMap"),
}