Commit 8ef91e12 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[cleanup] Convert more list macros to ROOT_LIST-compatible ones

INTERNALIZED_STRING_ROOT_LIST, [PRIVATE|PUBLIC|WELL_KNOWN]_SYMBOL_ROOT_LIST

Bug: v8:8015
Change-Id: I6f271fa8bfbe5e994ebcef191e6750fa3ff6dd7f
Reviewed-on: https://chromium-review.googlesource.com/1238567Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56160}
parent 14595004
......@@ -4026,17 +4026,17 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Factory* factory = isolate->factory();
HandleScope scope(isolate);
Handle<NativeContext> native_context = isolate->native_context();
#define EXPORT_PRIVATE_SYMBOL(NAME) \
#define EXPORT_PRIVATE_SYMBOL(_, NAME) \
Handle<String> NAME##_name = factory->NewStringFromAsciiChecked(#NAME); \
JSObject::AddProperty(isolate, container, NAME##_name, factory->NAME(), NONE);
PRIVATE_SYMBOL_LIST(EXPORT_PRIVATE_SYMBOL)
PRIVATE_SYMBOL_LIST_GENERATOR(EXPORT_PRIVATE_SYMBOL, /* not used */)
#undef EXPORT_PRIVATE_SYMBOL
#define EXPORT_PUBLIC_SYMBOL(NAME, DESCRIPTION) \
#define EXPORT_PUBLIC_SYMBOL(_, NAME, DESCRIPTION) \
Handle<String> NAME##_name = factory->NewStringFromAsciiChecked(#NAME); \
JSObject::AddProperty(isolate, container, NAME##_name, factory->NAME(), NONE);
PUBLIC_SYMBOL_LIST(EXPORT_PUBLIC_SYMBOL)
WELL_KNOWN_SYMBOL_LIST(EXPORT_PUBLIC_SYMBOL)
PUBLIC_SYMBOL_LIST_GENERATOR(EXPORT_PUBLIC_SYMBOL, /* not used */)
WELL_KNOWN_SYMBOL_LIST_GENERATOR(EXPORT_PUBLIC_SYMBOL, /* not used */)
#undef EXPORT_PUBLIC_SYMBOL
Handle<JSObject> iterator_prototype(
......
This diff is collapsed.
......@@ -25,33 +25,12 @@ 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)
#undef ROOT_ACCESSOR
#define STRING_ACCESSOR(name, str) \
Handle<String> Factory::name() { \
return Handle<String>( \
bit_cast<String**>(&isolate()->heap()->roots_[RootIndex::k##name])); \
}
INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
#undef STRING_ACCESSOR
#define SYMBOL_ACCESSOR(name) \
Handle<Symbol> Factory::name() { \
return Handle<Symbol>( \
bit_cast<Symbol**>(&isolate()->heap()->roots_[RootIndex::k##name])); \
}
PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define SYMBOL_ACCESSOR(name, description) \
Handle<Symbol> Factory::name() { \
return Handle<Symbol>( \
bit_cast<Symbol**>(&isolate()->heap()->roots_[RootIndex::k##name])); \
}
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define ACCESSOR_INFO_ACCESSOR(accessor_name, AccessorName, ...) \
Handle<AccessorInfo> Factory::accessor_name##_accessor() { \
return Handle<AccessorInfo>(bit_cast<AccessorInfo**>( \
......
......@@ -831,21 +831,12 @@ class V8_EXPORT_PRIVATE Factory {
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)
#undef ROOT_ACCESSOR
#define STRING_ACCESSOR(name, str) inline Handle<String> name();
INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
#undef STRING_ACCESSOR
#define SYMBOL_ACCESSOR(name) inline Handle<Symbol> name();
PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define SYMBOL_ACCESSOR(name, description) inline Handle<Symbol> name();
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define ACCESSOR_INFO_ACCESSOR(accessor_name, ...) \
inline Handle<AccessorInfo> accessor_name##_accessor();
ACCESSOR_INFO_LIST(ACCESSOR_INFO_ACCESSOR)
......
......@@ -3533,8 +3533,8 @@ bool Heap::RootIsImmortalImmovable(RootIndex root_index) {
#define IMMORTAL_IMMOVABLE_ROOT(name) case RootIndex::k##name:
IMMORTAL_IMMOVABLE_ROOT_LIST(IMMORTAL_IMMOVABLE_ROOT)
#undef IMMORTAL_IMMOVABLE_ROOT
#define INTERNALIZED_STRING(name, value) case RootIndex::k##name:
INTERNALIZED_STRING_LIST(INTERNALIZED_STRING)
#define INTERNALIZED_STRING(_, name, value) case RootIndex::k##name:
INTERNALIZED_STRING_LIST_GENERATOR(INTERNALIZED_STRING, /* not used */)
#undef INTERNALIZED_STRING
#define STRING_TYPE(NAME, size, name, Name) case RootIndex::k##Name##Map:
STRING_TYPE_LIST(STRING_TYPE)
......
......@@ -52,6 +52,10 @@ class JSArrayBuffer;
class ExternalString;
using v8::MemoryPressureLevel;
// Adapts PRIVATE_SYMBOL_LIST_GERNATOR entry to IMMORTAL_IMMOVABLE_ROOT_LIST
// entry
#define PRIVATE_SYMBOL_LIST_TO_IMMORTAL_IMMOVABLE_LIST_ADAPTER(V, name) V(name)
// Heap roots that are known to be immortal immovable, for which we can safely
// skip write barriers. This list is not complete and has omissions.
#define IMMORTAL_IMMOVABLE_ROOT_LIST(V) \
......@@ -164,7 +168,8 @@ using v8::MemoryPressureLevel;
V(WeakArrayListMap) \
V(WithContextMap) \
V(empty_string) \
PRIVATE_SYMBOL_LIST(V)
PRIVATE_SYMBOL_LIST_GENERATOR( \
PRIVATE_SYMBOL_LIST_TO_IMMORTAL_IMMOVABLE_LIST_ADAPTER, V)
class AllocationObserver;
class ArrayBufferCollector;
......
......@@ -65,8 +65,9 @@ const Heap::StringTypeTable Heap::string_type_table[] = {
const Heap::ConstantStringTable Heap::constant_string_table[] = {
{"", RootIndex::kempty_string},
#define CONSTANT_STRING_ELEMENT(name, contents) {contents, RootIndex::k##name},
INTERNALIZED_STRING_LIST(CONSTANT_STRING_ELEMENT)
#define CONSTANT_STRING_ELEMENT(_, name, contents) \
{contents, RootIndex::k##name},
INTERNALIZED_STRING_LIST_GENERATOR(CONSTANT_STRING_ELEMENT, /* not used */)
#undef CONSTANT_STRING_ELEMENT
};
......@@ -697,35 +698,35 @@ void Heap::CreateInitialObjects() {
{
HandleScope scope(isolate());
#define SYMBOL_INIT(name) \
#define SYMBOL_INIT(_, name) \
{ \
Handle<Symbol> symbol( \
isolate()->factory()->NewPrivateSymbol(TENURED_READ_ONLY)); \
roots_[RootIndex::k##name] = *symbol; \
}
PRIVATE_SYMBOL_LIST(SYMBOL_INIT)
PRIVATE_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
#undef SYMBOL_INIT
}
{
HandleScope scope(isolate());
#define SYMBOL_INIT(name, description) \
#define SYMBOL_INIT(_, name, description) \
Handle<Symbol> name = factory->NewSymbol(TENURED_READ_ONLY); \
Handle<String> name##d = \
factory->NewStringFromStaticChars(#description, TENURED_READ_ONLY); \
name->set_name(*name##d); \
roots_[RootIndex::k##name] = *name;
PUBLIC_SYMBOL_LIST(SYMBOL_INIT)
PUBLIC_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
#undef SYMBOL_INIT
#define SYMBOL_INIT(name, description) \
#define SYMBOL_INIT(_, name, description) \
Handle<Symbol> name = factory->NewSymbol(TENURED_READ_ONLY); \
Handle<String> name##d = \
factory->NewStringFromStaticChars(#description, TENURED_READ_ONLY); \
name->set_is_well_known_symbol(true); \
name->set_name(*name##d); \
roots_[RootIndex::k##name] = *name;
WELL_KNOWN_SYMBOL_LIST(SYMBOL_INIT)
WELL_KNOWN_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
#undef SYMBOL_INIT
// Mark "Interesting Symbols" appropriately.
......
......@@ -16027,9 +16027,9 @@ bool JSObject::IsDroppableApiWrapper() {
const char* Symbol::PrivateSymbolToName() const {
ReadOnlyRoots roots = GetReadOnlyRoots();
#define SYMBOL_CHECK_AND_PRINT(name) \
#define SYMBOL_CHECK_AND_PRINT(_, name) \
if (this == roots.name()) return #name;
PRIVATE_SYMBOL_LIST(SYMBOL_CHECK_AND_PRINT)
PRIVATE_SYMBOL_LIST_GENERATOR(SYMBOL_CHECK_AND_PRINT, /* not used */)
#undef SYMBOL_CHECK_AND_PRINT
return "UNKNOWN";
}
......
......@@ -1858,33 +1858,23 @@ const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) {
#define RO_NAME_ENTRY(name) \
strong_gc_subroot_names_.emplace(roots.name(), #name);
#define ROOT_NAME(type, name, CamelName) NAME_ENTRY(name)
#define RO_ROOT_NAME(type, name, CamelName) RO_NAME_ENTRY(name)
STRONG_MUTABLE_ROOT_LIST(ROOT_NAME)
#undef ROOT_NAME
#define ROOT_NAME(type, name, CamelName) RO_NAME_ENTRY(name)
STRONG_READ_ONLY_ROOT_LIST(ROOT_NAME)
#undef ROOT_NAME
#define STRUCT_MAP_NAME(NAME, Name, name) RO_NAME_ENTRY(name##_map)
STRUCT_LIST(STRUCT_MAP_NAME)
#undef STRUCT_MAP_NAME
#define ALLOCATION_SITE_MAP_NAME(type, name, CamelName) RO_NAME_ENTRY(name)
ALLOCATION_SITE_MAPS_LIST(ALLOCATION_SITE_MAP_NAME)
#undef ALLOCATION_SITE_MAP_NAME
#define DATA_HANDLER_MAP_NAME(type, name, CamelName) NAME_ENTRY(name)
DATA_HANDLER_MAPS_LIST(DATA_HANDLER_MAP_NAME)
#undef DATA_HANDLER_MAP_NAME
#define STRING_NAME(name, str) RO_NAME_ENTRY(name)
INTERNALIZED_STRING_LIST(STRING_NAME)
#undef STRING_NAME
#define SYMBOL_NAME(name) RO_NAME_ENTRY(name)
PRIVATE_SYMBOL_LIST(SYMBOL_NAME)
#undef SYMBOL_NAME
#define SYMBOL_NAME(name, description) RO_NAME_ENTRY(name)
PUBLIC_SYMBOL_LIST(SYMBOL_NAME)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_NAME)
#undef SYMBOL_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)
#define ACCESSOR_NAME(accessor_name, ...) NAME_ENTRY(accessor_name##_accessor)
ACCESSOR_INFO_LIST(ACCESSOR_NAME)
#undef ACCESSOR_NAME
#undef ROOT_NAME
#undef RO_ROOT_NAME
#undef NAME_ENTRY
#undef RO_NAME_ENTRY
CHECK(!strong_gc_subroot_names_.empty());
......
......@@ -24,42 +24,12 @@ ReadOnlyRoots::ReadOnlyRoots(Isolate* isolate) : heap_(isolate->heap()) {}
return Handle<type>( \
bit_cast<type**>(&heap_->roots_[RootIndex::k##CamelName])); \
}
STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#define STRING_ACCESSOR(name, str) \
String* ReadOnlyRoots::name() { \
return String::cast(heap_->roots_[RootIndex::k##name]); \
} \
Handle<String> ReadOnlyRoots::name##_handle() { \
return Handle<String>( \
bit_cast<String**>(&heap_->roots_[RootIndex::k##name])); \
}
INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
#undef STRING_ACCESSOR
#define SYMBOL_ACCESSOR(name) \
Symbol* ReadOnlyRoots::name() { \
return Symbol::cast(heap_->roots_[RootIndex::k##name]); \
} \
Handle<Symbol> ReadOnlyRoots::name##_handle() { \
return Handle<Symbol>( \
bit_cast<Symbol**>(&heap_->roots_[RootIndex::k##name])); \
}
PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define SYMBOL_ACCESSOR(name, description) \
Symbol* ReadOnlyRoots::name() { \
return Symbol::cast(heap_->roots_[RootIndex::k##name]); \
} \
Handle<Symbol> ReadOnlyRoots::name##_handle() { \
return Handle<Symbol>( \
bit_cast<Symbol**>(&heap_->roots_[RootIndex::k##name])); \
}
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
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)
#undef ROOT_ACCESSOR
......
......@@ -287,24 +287,34 @@ namespace internal {
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)
// Produces (String, name, CamelCase) entries
#define INTERNALIZED_STRING_ROOT_LIST(V) \
INTERNALIZED_STRING_LIST_GENERATOR(INTERNALIZED_STRING_LIST_ADAPTER, V)
// Adapts one XXX_SYMBOL_LIST_GENERATOR entry to the ROOT_LIST-compatible entry
#define SYMBOL_LIST_ADAPTER(V, name, ...) V(Symbol, name, name)
// Produces (Symbol, name, CamelCase) entries
#define PRIVATE_SYMBOL_ROOT_LIST(V) \
PRIVATE_SYMBOL_LIST_GENERATOR(SYMBOL_LIST_ADAPTER, V)
#define PUBLIC_SYMBOL_ROOT_LIST(V) \
PUBLIC_SYMBOL_LIST_GENERATOR(SYMBOL_LIST_ADAPTER, V)
#define WELL_KNOWN_SYMBOL_ROOT_LIST(V) \
WELL_KNOWN_SYMBOL_LIST_GENERATOR(SYMBOL_LIST_ADAPTER, 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)
#undef DECL
#define DECL(name, str) k##name,
INTERNALIZED_STRING_LIST(DECL)
#undef DECL
#define DECL(name) k##name,
PRIVATE_SYMBOL_LIST(DECL)
#undef DECL
#define DECL(name, description) k##name,
PUBLIC_SYMBOL_LIST(DECL)
WELL_KNOWN_SYMBOL_LIST(DECL)
INTERNALIZED_STRING_ROOT_LIST(DECL)
PRIVATE_SYMBOL_ROOT_LIST(DECL)
PUBLIC_SYMBOL_ROOT_LIST(DECL)
WELL_KNOWN_SYMBOL_ROOT_LIST(DECL)
#undef DECL
#define DECL(accessor_name, AccessorName, ...) k##AccessorName##Accessor,
......@@ -390,27 +400,12 @@ class ReadOnlyRoots {
#define ROOT_ACCESSOR(type, name, CamelName) \
inline class type* name(); \
inline Handle<type> name##_handle();
STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#define STRING_ACCESSOR(name, str) \
inline String* name(); \
inline Handle<String> name##_handle();
INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
#undef STRING_ACCESSOR
#define SYMBOL_ACCESSOR(name) \
inline Symbol* name(); \
inline Handle<Symbol> name##_handle();
PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define SYMBOL_ACCESSOR(name, description) \
inline Symbol* name(); \
inline Handle<Symbol> name##_handle();
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
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)
#undef ROOT_ACCESSOR
......
......@@ -18,8 +18,8 @@ AllocationSpace GetSpaceFromObject(Object* object) {
}
} // namespace
#define CHECK_IN_RO_SPACE(name) \
HeapObject* name = roots.name(); \
#define CHECK_IN_RO_SPACE(type, name, CamelName) \
HeapObject* name = roots.name(); \
CHECK_EQ(RO_SPACE, GetSpaceFromObject(name));
// The following tests check that all the roots accessible via ReadOnlyRoots are
......@@ -27,48 +27,38 @@ AllocationSpace GetSpaceFromObject(Object* object) {
TEST(TestStrongReadOnlyRoots) {
ReadOnlyRoots roots(CcTest::i_isolate());
#define TEST_ROOT(type, name, CamelName) CHECK_IN_RO_SPACE(name)
STRONG_READ_ONLY_ROOT_LIST(TEST_ROOT)
#undef TEST_ROOT
STRONG_READ_ONLY_ROOT_LIST(CHECK_IN_RO_SPACE)
}
TEST(TestInternalizedStrings) {
ReadOnlyRoots roots(CcTest::i_isolate());
#define TEST_ROOT(name, str) CHECK_IN_RO_SPACE(name)
INTERNALIZED_STRING_LIST(TEST_ROOT)
#undef TEST_ROOT
INTERNALIZED_STRING_ROOT_LIST(CHECK_IN_RO_SPACE)
}
TEST(TestPrivateSymbols) {
ReadOnlyRoots roots(CcTest::i_isolate());
PRIVATE_SYMBOL_LIST(CHECK_IN_RO_SPACE)
PRIVATE_SYMBOL_ROOT_LIST(CHECK_IN_RO_SPACE)
}
TEST(TestPublicSymbols) {
ReadOnlyRoots roots(CcTest::i_isolate());
#define TEST_ROOT(name, description) CHECK_IN_RO_SPACE(name)
PUBLIC_SYMBOL_LIST(TEST_ROOT)
WELL_KNOWN_SYMBOL_LIST(TEST_ROOT)
#undef TEST_ROOT
PUBLIC_SYMBOL_ROOT_LIST(CHECK_IN_RO_SPACE)
WELL_KNOWN_SYMBOL_ROOT_LIST(CHECK_IN_RO_SPACE)
}
TEST(TestStructMaps) {
ReadOnlyRoots roots(CcTest::i_isolate());
#define TEST_ROOT(NAME, Name, name) CHECK_IN_RO_SPACE(name##_map)
STRUCT_LIST(TEST_ROOT)
#undef TEST_ROOT
STRUCT_MAPS_LIST(CHECK_IN_RO_SPACE)
}
TEST(TestAllocationSiteMaps) {
ReadOnlyRoots roots(CcTest::i_isolate());
#define TEST_ROOT(type, name, CamelName) CHECK_IN_RO_SPACE(name)
ALLOCATION_SITE_MAPS_LIST(TEST_ROOT)
#undef TEST_ROOT
ALLOCATION_SITE_MAPS_LIST(CHECK_IN_RO_SPACE)
}
#undef CHECK_IN_RO_SPACE
......
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