Commit 747d71e1 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[refactoring] Specify full type in ROOT_LIST

Instead of putting "Foo" as type into the list macro, and
then extending to "type*" at consumer macros, put "Foo*"
into the macro.
This is in preparation for incremental transition to ObjectPtr,
where some roots will return pointer types and others won't.
When that migration is complete, everything will be uniform
(and without "*") again.

Bug: v8:3770
Change-Id: Ib4a9900b1fc6e59f5fc924b779ed7e94dc136ad0
Reviewed-on: https://chromium-review.googlesource.com/c/1285397
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56798}
parent 5c46c24d
...@@ -16,10 +16,11 @@ ...@@ -16,10 +16,11 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
#define ROOT_ACCESSOR(type, name, CamelName) \ // TODO(jkummerow): Drop std::remove_pointer after the migration to ObjectPtr.
Handle<type> Factory::name() { \ #define ROOT_ACCESSOR(Type, name, CamelName) \
return Handle<type>( \ Handle<std::remove_pointer<Type>::type> Factory::name() { \
bit_cast<type**>(&isolate()->roots_table()[RootIndex::k##CamelName])); \ return Handle<std::remove_pointer<Type>::type>(bit_cast<Address*>( \
&isolate()->roots_table()[RootIndex::k##CamelName])); \
} }
ROOT_LIST(ROOT_ACCESSOR) ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
......
...@@ -826,7 +826,9 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -826,7 +826,9 @@ class V8_EXPORT_PRIVATE Factory {
inline Handle<String> Uint32ToString(uint32_t value, bool check_cache = true); inline Handle<String> Uint32ToString(uint32_t value, bool check_cache = true);
#define ROOT_ACCESSOR(type, name, CamelName) inline Handle<type> name(); // TODO(jkummerow): Drop std::remove_pointer after the migration to ObjectPtr.
#define ROOT_ACCESSOR(Type, name, CamelName) \
inline Handle<std::remove_pointer<Type>::type> name();
ROOT_LIST(ROOT_ACCESSOR) ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
......
...@@ -55,15 +55,17 @@ HeapObject* AllocationResult::ToObjectChecked() { ...@@ -55,15 +55,17 @@ HeapObject* AllocationResult::ToObjectChecked() {
return HeapObject::cast(object_); return HeapObject::cast(object_);
} }
#define ROOT_ACCESSOR(type, name, CamelName) \ // TODO(jkummerow): Drop std::remove_pointer after the migration to ObjectPtr.
type* Heap::name() { \ #define ROOT_ACCESSOR(Type, name, CamelName) \
return type::cast(roots_table()[RootIndex::k##CamelName]); \ Type Heap::name() { \
return std::remove_pointer<Type>::type::cast( \
roots_table()[RootIndex::k##CamelName]); \
} }
MUTABLE_ROOT_LIST(ROOT_ACCESSOR) MUTABLE_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
#define ROOT_ACCESSOR(type, name, CamelName) \ #define ROOT_ACCESSOR(type, name, CamelName) \
void Heap::set_##name(type* value) { \ void Heap::set_##name(type value) { \
/* The deserializer makes use of the fact that these common roots are */ \ /* The deserializer makes use of the fact that these common roots are */ \
/* never in new space and never on a page that is being compacted. */ \ /* never in new space and never on a page that is being compacted. */ \
DCHECK_IMPLIES(deserialization_complete(), \ DCHECK_IMPLIES(deserialization_complete(), \
......
...@@ -651,7 +651,7 @@ class Heap { ...@@ -651,7 +651,7 @@ class Heap {
V8_INLINE RootsTable& roots_table() { return isolate_data_.roots(); } V8_INLINE RootsTable& roots_table() { return isolate_data_.roots(); }
// Heap root getters. // Heap root getters.
#define ROOT_ACCESSOR(type, name, CamelName) inline type* name(); #define ROOT_ACCESSOR(type, name, CamelName) inline type name();
MUTABLE_ROOT_LIST(ROOT_ACCESSOR) MUTABLE_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
...@@ -1391,8 +1391,7 @@ class Heap { ...@@ -1391,8 +1391,7 @@ class Heap {
return 0; return 0;
} }
#define ROOT_ACCESSOR(type, name, CamelName) \ #define ROOT_ACCESSOR(type, name, CamelName) inline void set_##name(type value);
inline void set_##name(type* value);
ROOT_LIST(ROOT_ACCESSOR) ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
......
...@@ -352,9 +352,9 @@ namespace internal { ...@@ -352,9 +352,9 @@ namespace internal {
// Adapts one STRUCT_LIST_GENERATOR entry to the STRUCT_MAPS_LIST entry // Adapts one STRUCT_LIST_GENERATOR entry to the STRUCT_MAPS_LIST entry
#define STRUCT_MAPS_LIST_ADAPTER(V, NAME, Name, name) \ #define STRUCT_MAPS_LIST_ADAPTER(V, NAME, Name, name) \
V(Map, name##_map, Name##Map) V(Map*, name##_map, Name##Map)
// Produces (Map, struct_name_map, StructNameMap) entries // Produces (Map*, struct_name_map, StructNameMap) entries
#define STRUCT_MAPS_LIST(V) STRUCT_LIST_GENERATOR(STRUCT_MAPS_LIST_ADAPTER, V) #define STRUCT_MAPS_LIST(V) STRUCT_LIST_GENERATOR(STRUCT_MAPS_LIST_ADAPTER, V)
// //
...@@ -368,7 +368,7 @@ namespace internal { ...@@ -368,7 +368,7 @@ namespace internal {
// Adapts one ALLOCATION_SITE_LIST entry to the ALLOCATION_SITE_MAPS_LIST entry // Adapts one ALLOCATION_SITE_LIST entry to the ALLOCATION_SITE_MAPS_LIST entry
#define ALLOCATION_SITE_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \ #define ALLOCATION_SITE_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \
V(Map, name_size##_map, Name##Size##Map) V(Map*, name_size##_map, Name##Size##Map)
// Produces (Map, allocation_site_name_map, AllocationSiteNameMap) entries // Produces (Map, allocation_site_name_map, AllocationSiteNameMap) entries
#define ALLOCATION_SITE_MAPS_LIST(V) \ #define ALLOCATION_SITE_MAPS_LIST(V) \
...@@ -389,7 +389,7 @@ namespace internal { ...@@ -389,7 +389,7 @@ namespace internal {
// Adapts one DATA_HANDLER_LIST entry to the DATA_HANDLER_MAPS_LIST entry. // Adapts one DATA_HANDLER_LIST entry to the DATA_HANDLER_MAPS_LIST entry.
#define DATA_HANDLER_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \ #define DATA_HANDLER_MAPS_LIST_ADAPTER(V, TYPE, Name, Size, name_size) \
V(Map, name_size##_map, Name##Size##Map) V(Map*, name_size##_map, Name##Size##Map)
// Produces (Map, handler_name_map, HandlerNameMap) entries // Produces (Map, handler_name_map, HandlerNameMap) entries
#define DATA_HANDLER_MAPS_LIST(V) \ #define DATA_HANDLER_MAPS_LIST(V) \
......
...@@ -36,13 +36,16 @@ ReadOnlyRoots::ReadOnlyRoots(Heap* heap) ...@@ -36,13 +36,16 @@ ReadOnlyRoots::ReadOnlyRoots(Heap* heap)
ReadOnlyRoots::ReadOnlyRoots(Isolate* isolate) ReadOnlyRoots::ReadOnlyRoots(Isolate* isolate)
: roots_table_(isolate->roots_table()) {} : roots_table_(isolate->roots_table()) {}
#define ROOT_ACCESSOR(type, name, CamelName) \ // TODO(jkummerow): Drop std::remove_pointer after the migration to ObjectPtr.
type* ReadOnlyRoots::name() { \ #define ROOT_ACCESSOR(Type, name, CamelName) \
return type::cast(roots_table_[RootIndex::k##CamelName]); \ Type ReadOnlyRoots::name() const { \
} \ return std::remove_pointer<Type>::type::cast( \
Handle<type> ReadOnlyRoots::name##_handle() { \ roots_table_[RootIndex::k##CamelName]); \
return Handle<type>( \ } \
bit_cast<type**>(&roots_table_[RootIndex::k##CamelName])); \ Handle<std::remove_pointer<Type>::type> ReadOnlyRoots::name##_handle() \
const { \
return Handle<std::remove_pointer<Type>::type>( \
bit_cast<Address*>(&roots_table_[RootIndex::k##CamelName])); \
} }
READ_ONLY_ROOT_LIST(ROOT_ACCESSOR) READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
......
This diff is collapsed.
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