[cleanup] Introduce ACCESSOR_INFO_ROOT_LIST

... containing ROOT_LIST-compatible entries.

Bug: v8:8015
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: Ia7a2620e2b6c9b2238cc0c2a6ead6bf7e6a46c00
Reviewed-on: https://chromium-review.googlesource.com/1238724
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56161}
This commit is contained in:
Igor Sheludko 2018-09-24 11:25:21 +02:00 committed by Commit Bot
parent 8ef91e123d
commit 7528a7e6a9
11 changed files with 67 additions and 95 deletions

View File

@ -23,26 +23,27 @@ class JavaScriptFrame;
// The list of accessor descriptors. This is a second-order macro
// taking a macro to be applied to all accessor descriptor names.
// V(accessor_name, AccessorName, GetterSideEffectType, SetterSideEffectType)
#define ACCESSOR_INFO_LIST(V) \
V(arguments_iterator, ArgumentsIterator, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(array_length, ArrayLength, kHasNoSideEffect, kHasSideEffectToReceiver) \
V(bound_function_length, BoundFunctionLength, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(bound_function_name, BoundFunctionName, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(error_stack, ErrorStack, kHasSideEffectToReceiver, \
kHasSideEffectToReceiver) \
V(function_arguments, FunctionArguments, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(function_caller, FunctionCaller, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(function_name, FunctionName, kHasNoSideEffect, kHasSideEffectToReceiver) \
V(function_length, FunctionLength, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(function_prototype, FunctionPrototype, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(string_length, StringLength, kHasNoSideEffect, kHasSideEffectToReceiver)
#define ACCESSOR_INFO_LIST_GENERATOR(V, _) \
V(_, arguments_iterator, ArgumentsIterator, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(_, array_length, ArrayLength, kHasNoSideEffect, kHasSideEffectToReceiver) \
V(_, bound_function_length, BoundFunctionLength, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(_, bound_function_name, BoundFunctionName, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(_, error_stack, ErrorStack, kHasSideEffectToReceiver, \
kHasSideEffectToReceiver) \
V(_, function_arguments, FunctionArguments, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(_, function_caller, FunctionCaller, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(_, function_name, FunctionName, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(_, function_length, FunctionLength, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(_, function_prototype, FunctionPrototype, kHasNoSideEffect, \
kHasSideEffectToReceiver) \
V(_, string_length, StringLength, kHasNoSideEffect, kHasSideEffectToReceiver)
#define ACCESSOR_SETTER_LIST(V) \
V(ArrayLengthSetter) \
@ -55,11 +56,11 @@ class JavaScriptFrame;
class Accessors : public AllStatic {
public:
#define ACCESSOR_GETTER_DECLARATION(accessor_name, AccessorName, ...) \
static void AccessorName##Getter( \
v8::Local<v8::Name> name, \
#define ACCESSOR_GETTER_DECLARATION(_, accessor_name, AccessorName, ...) \
static void AccessorName##Getter( \
v8::Local<v8::Name> name, \
const v8::PropertyCallbackInfo<v8::Value>& info);
ACCESSOR_INFO_LIST(ACCESSOR_GETTER_DECLARATION)
ACCESSOR_INFO_LIST_GENERATOR(ACCESSOR_GETTER_DECLARATION, /* not used */)
#undef ACCESSOR_GETTER_DECLARATION
#define ACCESSOR_SETTER_DECLARATION(accessor_name) \
@ -71,7 +72,7 @@ class Accessors : public AllStatic {
static constexpr int kAccessorInfoCount =
#define COUNT_ACCESSOR(...) +1
ACCESSOR_INFO_LIST(COUNT_ACCESSOR);
ACCESSOR_INFO_LIST_GENERATOR(COUNT_ACCESSOR, /* not used */);
#undef COUNT_ACCESSOR
static constexpr int kAccessorSetterCount =
@ -118,9 +119,9 @@ class Accessors : public AllStatic {
AccessorNameBooleanSetterCallback setter);
private:
#define ACCESSOR_INFO_DECLARATION(accessor_name, AccessorName, ...) \
#define ACCESSOR_INFO_DECLARATION(_, accessor_name, AccessorName, ...) \
static Handle<AccessorInfo> Make##AccessorName##Info(Isolate* isolate);
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
ACCESSOR_INFO_LIST_GENERATOR(ACCESSOR_INFO_DECLARATION, /* not used */)
#undef ACCESSOR_INFO_DECLARATION
friend class Heap;

View File

@ -9697,10 +9697,10 @@ int debug::GetNativeAccessorDescriptor(v8::Local<v8::Context> context,
}
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
int result = 0;
#define IS_BUILTIN_ACESSOR(name, ...) \
#define IS_BUILTIN_ACESSOR(_, name, ...) \
if (*structure == *isolate->factory()->name##_accessor()) \
result |= static_cast<int>(debug::NativeAccessorType::IsBuiltin);
ACCESSOR_INFO_LIST(IS_BUILTIN_ACESSOR)
ACCESSOR_INFO_LIST_GENERATOR(IS_BUILTIN_ACESSOR, /* not used */)
#undef IS_BUILTIN_ACESSOR
i::Handle<i::AccessorInfo> accessor_info =
i::Handle<i::AccessorInfo>::cast(structure);

View File

@ -159,10 +159,10 @@ void ExternalReferenceTable::AddAccessors(int* index) {
};
static const AccessorRefTable getters[] = {
#define ACCESSOR_INFO_DECLARATION(accessor_name, AccessorName, ...) \
{FUNCTION_ADDR(&Accessors::AccessorName##Getter), \
#define ACCESSOR_INFO_DECLARATION(_, accessor_name, AccessorName, ...) \
{FUNCTION_ADDR(&Accessors::AccessorName##Getter), \
"Accessors::" #AccessorName "Getter"}, /* NOLINT(whitespace/indent) */
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
ACCESSOR_INFO_LIST_GENERATOR(ACCESSOR_INFO_DECLARATION, /* not used */)
#undef ACCESSOR_INFO_DECLARATION
};
static const AccessorRefTable setters[] = {

View File

@ -29,16 +29,9 @@ 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
#define ACCESSOR_INFO_ACCESSOR(accessor_name, AccessorName, ...) \
Handle<AccessorInfo> Factory::accessor_name##_accessor() { \
return Handle<AccessorInfo>(bit_cast<AccessorInfo**>( \
&isolate()->heap()->roots_[RootIndex::k##AccessorName##Accessor])); \
}
ACCESSOR_INFO_LIST(ACCESSOR_INFO_ACCESSOR)
#undef ACCESSOR_INFO_ACCESSOR
Handle<String> Factory::InternalizeString(Handle<String> string) {
if (string->IsInternalizedString()) return string;
return StringTable::LookupString(isolate(), string);

View File

@ -835,13 +835,9 @@ class V8_EXPORT_PRIVATE Factory {
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
#define ACCESSOR_INFO_ACCESSOR(accessor_name, ...) \
inline Handle<AccessorInfo> accessor_name##_accessor();
ACCESSOR_INFO_LIST(ACCESSOR_INFO_ACCESSOR)
#undef ACCESSOR_INFO_ACCESSOR
// Allocates a new SharedFunctionInfo object.
Handle<SharedFunctionInfo> NewSharedFunctionInfoForApiFunction(
MaybeHandle<String> maybe_name,

View File

@ -58,17 +58,10 @@ 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 ACCESSOR_INFO_ACCESSOR(accessor_name, AccessorName, ...) \
AccessorInfo* Heap::accessor_name##_accessor() { \
return AccessorInfo::cast(roots_[RootIndex::k##AccessorName##Accessor]); \
}
ACCESSOR_INFO_LIST(ACCESSOR_INFO_ACCESSOR)
#undef ACCESSOR_INFO_ACCESSOR
#define ROOT_ACCESSOR(type, name, CamelName) \
void Heap::set_##name(type* value) { \
/* The deserializer makes use of the fact that these common roots are */ \

View File

@ -776,13 +776,9 @@ class Heap {
MUTABLE_ROOT_LIST(ROOT_ACCESSOR)
DATA_HANDLER_MAPS_LIST(ROOT_ACCESSOR)
ACCESSOR_INFO_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
#define ACCESSOR_INFO_ACCESSOR(accessor_name, ...) \
inline AccessorInfo* accessor_name##_accessor();
ACCESSOR_INFO_LIST(ACCESSOR_INFO_ACCESSOR)
#undef ACCESSOR_INFO_ACCESSOR
Object* root(RootIndex index) { return roots_[index]; }
Handle<Object> root_handle(RootIndex index) {
return Handle<Object>(&roots_[index]);

View File

@ -899,19 +899,19 @@ void Heap::CreateInternalAccessorInfoObjects() {
HandleScope scope(isolate);
Handle<AccessorInfo> acessor_info;
#define INIT_ACCESSOR_INFO(accessor_name, AccessorName, ...) \
acessor_info = Accessors::Make##AccessorName##Info(isolate); \
#define INIT_ACCESSOR_INFO(_, accessor_name, AccessorName, ...) \
acessor_info = Accessors::Make##AccessorName##Info(isolate); \
roots_[RootIndex::k##AccessorName##Accessor] = *acessor_info;
ACCESSOR_INFO_LIST(INIT_ACCESSOR_INFO)
ACCESSOR_INFO_LIST_GENERATOR(INIT_ACCESSOR_INFO, /* not used */)
#undef INIT_ACCESSOR_INFO
#define INIT_SIDE_EFFECT_FLAG(accessor_name, AccessorName, GetterType, \
SetterType) \
AccessorInfo::cast(roots_[RootIndex::k##AccessorName##Accessor]) \
->set_getter_side_effect_type(SideEffectType::GetterType); \
AccessorInfo::cast(roots_[RootIndex::k##AccessorName##Accessor]) \
#define INIT_SIDE_EFFECT_FLAG(_, accessor_name, AccessorName, GetterType, \
SetterType) \
AccessorInfo::cast(roots_[RootIndex::k##AccessorName##Accessor]) \
->set_getter_side_effect_type(SideEffectType::GetterType); \
AccessorInfo::cast(roots_[RootIndex::k##AccessorName##Accessor]) \
->set_setter_side_effect_type(SideEffectType::SetterType);
ACCESSOR_INFO_LIST(INIT_SIDE_EFFECT_FLAG)
ACCESSOR_INFO_LIST_GENERATOR(INIT_SIDE_EFFECT_FLAG, /* not used */)
#undef INIT_SIDE_EFFECT_FLAG
}

View File

@ -1854,11 +1854,10 @@ void V8HeapExplorer::SetGcSubrootReference(Root root, const char* description,
const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) {
ReadOnlyRoots roots(heap_);
if (strong_gc_subroot_names_.empty()) {
#define NAME_ENTRY(name) strong_gc_subroot_names_.emplace(heap_->name(), #name);
#define RO_NAME_ENTRY(name) \
#define 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);
#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)
STRONG_READ_ONLY_ROOT_LIST(RO_ROOT_NAME)
@ -1869,14 +1868,9 @@ const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) {
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
ACCESSOR_INFO_ROOT_LIST(ROOT_NAME)
#undef ROOT_NAME
#undef RO_ROOT_NAME
#undef NAME_ENTRY
#undef RO_NAME_ENTRY
CHECK(!strong_gc_subroot_names_.empty());
}
auto it = strong_gc_subroot_names_.find(object);

View File

@ -296,15 +296,24 @@ namespace internal {
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)
#define SYMBOL_ROOT_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)
PRIVATE_SYMBOL_LIST_GENERATOR(SYMBOL_ROOT_LIST_ADAPTER, V)
#define PUBLIC_SYMBOL_ROOT_LIST(V) \
PUBLIC_SYMBOL_LIST_GENERATOR(SYMBOL_LIST_ADAPTER, V)
PUBLIC_SYMBOL_LIST_GENERATOR(SYMBOL_ROOT_LIST_ADAPTER, V)
#define WELL_KNOWN_SYMBOL_ROOT_LIST(V) \
WELL_KNOWN_SYMBOL_LIST_GENERATOR(SYMBOL_LIST_ADAPTER, V)
WELL_KNOWN_SYMBOL_LIST_GENERATOR(SYMBOL_ROOT_LIST_ADAPTER, V)
// Adapts one ACCESSOR_INFO_LIST_GENERATOR entry to the ROOT_LIST-compatible
// entry
#define ACCESSOR_INFO_ROOT_LIST_ADAPTER(V, name, CamelName, ...) \
V(AccessorInfo, name##_accessor, CamelName##Accessor)
// Produces (AccessorInfo, name, CamelCase) entries
#define ACCESSOR_INFO_ROOT_LIST(V) \
ACCESSOR_INFO_LIST_GENERATOR(ACCESSOR_INFO_ROOT_LIST_ADAPTER, V)
// Declare all the root indices. This defines the root list order.
// clang-format off
@ -315,13 +324,7 @@ enum class RootIndex {
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,
ACCESSOR_INFO_LIST(DECL)
#undef DECL
#define DECL(type, name, CamelName) k##CamelName,
ACCESSOR_INFO_ROOT_LIST(DECL)
STRUCT_MAPS_LIST(DECL)
ALLOCATION_SITE_MAPS_LIST(DECL)
DATA_HANDLER_MAPS_LIST(DECL)

View File

@ -90,7 +90,7 @@ bool IsInitiallyMutable(Factory* factory, Address object_address) {
// The CHECK_EQ line is there just to ensure that the root is publicly
// accessible from Heap, but ultimately the factory is used as it provides
// handles that have the address in the root table.
#define CHECK_NOT_IN_RO_SPACE(name) \
#define CHECK_NOT_IN_RO_SPACE(type, name, CamelName) \
Handle<Object> name = factory->name(); \
CHECK_EQ(*name, heap->name()); \
if (name->IsHeapObject() && IsInitiallyMutable(factory, name.address())) \
@ -104,18 +104,14 @@ TEST(TestHeapRootsNotReadOnly) {
Factory* factory = CcTest::i_isolate()->factory();
Heap* heap = CcTest::i_isolate()->heap();
#define TEST_ROOT(type, name, CamelName) CHECK_NOT_IN_RO_SPACE(name)
MUTABLE_ROOT_LIST(TEST_ROOT)
#undef TEST_ROOT
MUTABLE_ROOT_LIST(CHECK_NOT_IN_RO_SPACE)
}
TEST(TestAccessorInfosNotReadOnly) {
Factory* factory = CcTest::i_isolate()->factory();
Heap* heap = CcTest::i_isolate()->heap();
#define TEST_ROOT(name, ...) CHECK_NOT_IN_RO_SPACE(name##_accessor)
ACCESSOR_INFO_LIST(TEST_ROOT)
#undef TEST_ROOT
ACCESSOR_INFO_ROOT_LIST(CHECK_NOT_IN_RO_SPACE)
}
#undef CHECK_NOT_IN_RO_SPACE