Commit 45b622d9 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[explicit isolates] Add Handle getters to ReadOnlyRoots

Add <root>_handle getters to ReadOnlyRoots, so an Isolate isn't required
to get a handle of a root.

Also convert one GetIsolate()->factory()->accessor() to
GetReadOnlyRoots().accessor_handle() in FixedArray.

Bug: v8:7786
Change-Id: I1b72c58f90eacf64be95abb65df91cf993178a93
Reviewed-on: https://chromium-review.googlesource.com/1129225
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54334}
parent 16aa6d04
...@@ -10250,7 +10250,7 @@ bool FixedArray::ContainsSortedNumbers() { ...@@ -10250,7 +10250,7 @@ bool FixedArray::ContainsSortedNumbers() {
Handle<FixedArray> FixedArray::ShrinkOrEmpty(Handle<FixedArray> array, Handle<FixedArray> FixedArray::ShrinkOrEmpty(Handle<FixedArray> array,
int new_length) { int new_length) {
if (new_length == 0) { if (new_length == 0) {
return array->GetIsolate()->factory()->empty_fixed_array(); return array->GetReadOnlyRoots().empty_fixed_array_handle();
} else { } else {
array->Shrink(new_length); array->Shrink(new_length);
return array; return array;
......
...@@ -19,6 +19,10 @@ ReadOnlyRoots::ReadOnlyRoots(Isolate* isolate) : heap_(isolate->heap()) {} ...@@ -19,6 +19,10 @@ ReadOnlyRoots::ReadOnlyRoots(Isolate* isolate) : heap_(isolate->heap()) {}
#define ROOT_ACCESSOR(type, name, camel_name) \ #define ROOT_ACCESSOR(type, name, camel_name) \
type* ReadOnlyRoots::name() { \ type* ReadOnlyRoots::name() { \
return type::cast(heap_->roots_[Heap::k##camel_name##RootIndex]); \ return type::cast(heap_->roots_[Heap::k##camel_name##RootIndex]); \
} \
Handle<type> ReadOnlyRoots::name##_handle() { \
return Handle<type>( \
bit_cast<type**>(&heap_->roots_[Heap::k##camel_name##RootIndex])); \
} }
STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR) STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
...@@ -26,6 +30,10 @@ STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR) ...@@ -26,6 +30,10 @@ STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#define STRING_ACCESSOR(name, str) \ #define STRING_ACCESSOR(name, str) \
String* ReadOnlyRoots::name() { \ String* ReadOnlyRoots::name() { \
return String::cast(heap_->roots_[Heap::k##name##RootIndex]); \ return String::cast(heap_->roots_[Heap::k##name##RootIndex]); \
} \
Handle<String> ReadOnlyRoots::name##_handle() { \
return Handle<String>( \
bit_cast<String**>(&heap_->roots_[Heap::k##name##RootIndex])); \
} }
INTERNALIZED_STRING_LIST(STRING_ACCESSOR) INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
#undef STRING_ACCESSOR #undef STRING_ACCESSOR
...@@ -33,6 +41,10 @@ INTERNALIZED_STRING_LIST(STRING_ACCESSOR) ...@@ -33,6 +41,10 @@ INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
#define SYMBOL_ACCESSOR(name) \ #define SYMBOL_ACCESSOR(name) \
Symbol* ReadOnlyRoots::name() { \ Symbol* ReadOnlyRoots::name() { \
return Symbol::cast(heap_->roots_[Heap::k##name##RootIndex]); \ return Symbol::cast(heap_->roots_[Heap::k##name##RootIndex]); \
} \
Handle<Symbol> ReadOnlyRoots::name##_handle() { \
return Handle<Symbol>( \
bit_cast<Symbol**>(&heap_->roots_[Heap::k##name##RootIndex])); \
} }
PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR) PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR #undef SYMBOL_ACCESSOR
...@@ -40,6 +52,10 @@ PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR) ...@@ -40,6 +52,10 @@ PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
#define SYMBOL_ACCESSOR(name, description) \ #define SYMBOL_ACCESSOR(name, description) \
Symbol* ReadOnlyRoots::name() { \ Symbol* ReadOnlyRoots::name() { \
return Symbol::cast(heap_->roots_[Heap::k##name##RootIndex]); \ return Symbol::cast(heap_->roots_[Heap::k##name##RootIndex]); \
} \
Handle<Symbol> ReadOnlyRoots::name##_handle() { \
return Handle<Symbol>( \
bit_cast<Symbol**>(&heap_->roots_[Heap::k##name##RootIndex])); \
} }
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR) PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR) WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
...@@ -48,6 +64,10 @@ WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR) ...@@ -48,6 +64,10 @@ WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \
Map* ReadOnlyRoots::name##_map() { \ Map* ReadOnlyRoots::name##_map() { \
return Map::cast(heap_->roots_[Heap::k##Name##MapRootIndex]); \ return Map::cast(heap_->roots_[Heap::k##Name##MapRootIndex]); \
} \
Handle<Map> ReadOnlyRoots::name##_map_handle() { \
return Handle<Map>( \
bit_cast<Map**>(&heap_->roots_[Heap::k##Name##MapRootIndex])); \
} }
STRUCT_LIST(STRUCT_MAP_ACCESSOR) STRUCT_LIST(STRUCT_MAP_ACCESSOR)
#undef STRUCT_MAP_ACCESSOR #undef STRUCT_MAP_ACCESSOR
...@@ -55,6 +75,10 @@ STRUCT_LIST(STRUCT_MAP_ACCESSOR) ...@@ -55,6 +75,10 @@ STRUCT_LIST(STRUCT_MAP_ACCESSOR)
#define ALLOCATION_SITE_MAP_ACCESSOR(NAME, Name, Size, name) \ #define ALLOCATION_SITE_MAP_ACCESSOR(NAME, Name, Size, name) \
Map* ReadOnlyRoots::name##_map() { \ Map* ReadOnlyRoots::name##_map() { \
return Map::cast(heap_->roots_[Heap::k##Name##Size##MapRootIndex]); \ return Map::cast(heap_->roots_[Heap::k##Name##Size##MapRootIndex]); \
} \
Handle<Map> ReadOnlyRoots::name##_map_handle() { \
return Handle<Map>( \
bit_cast<Map**>(&heap_->roots_[Heap::k##Name##Size##MapRootIndex])); \
} }
ALLOCATION_SITE_LIST(ALLOCATION_SITE_MAP_ACCESSOR) ALLOCATION_SITE_LIST(ALLOCATION_SITE_MAP_ACCESSOR)
#undef ALLOCATION_SITE_MAP_ACCESSOR #undef ALLOCATION_SITE_MAP_ACCESSOR
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef V8_ROOTS_H_ #ifndef V8_ROOTS_H_
#define V8_ROOTS_H_ #define V8_ROOTS_H_
#include "src/handles.h"
#include "src/heap-symbols.h" #include "src/heap-symbols.h"
#include "src/objects-definitions.h" #include "src/objects-definitions.h"
...@@ -289,6 +290,7 @@ namespace internal { ...@@ -289,6 +290,7 @@ namespace internal {
class Heap; class Heap;
class Isolate; class Isolate;
class Map;
class String; class String;
class Symbol; class Symbol;
...@@ -297,30 +299,41 @@ class ReadOnlyRoots { ...@@ -297,30 +299,41 @@ class ReadOnlyRoots {
explicit ReadOnlyRoots(Heap* heap) : heap_(heap) {} explicit ReadOnlyRoots(Heap* heap) : heap_(heap) {}
inline explicit ReadOnlyRoots(Isolate* isolate); inline explicit ReadOnlyRoots(Isolate* isolate);
#define ROOT_ACCESSOR(type, name, camel_name) inline class type* name(); #define ROOT_ACCESSOR(type, name, camel_name) \
inline class type* name(); \
inline Handle<type> name##_handle();
STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR) STRONG_READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
#define STRING_ACCESSOR(name, str) inline String* name(); #define STRING_ACCESSOR(name, str) \
inline String* name(); \
inline Handle<String> name##_handle();
INTERNALIZED_STRING_LIST(STRING_ACCESSOR) INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
#undef STRING_ACCESSOR #undef STRING_ACCESSOR
#define SYMBOL_ACCESSOR(name) inline Symbol* name(); #define SYMBOL_ACCESSOR(name) \
inline Symbol* name(); \
inline Handle<Symbol> name##_handle();
PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR) PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR #undef SYMBOL_ACCESSOR
#define SYMBOL_ACCESSOR(name, description) inline Symbol* name(); #define SYMBOL_ACCESSOR(name, description) \
inline Symbol* name(); \
inline Handle<Symbol> name##_handle();
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR) PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR) WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR #undef SYMBOL_ACCESSOR
// Utility type maps. // Utility type maps.
#define STRUCT_MAP_ACCESSOR(NAME, Name, name) inline Map* name##_map(); #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \
inline Map* name##_map(); \
inline class Handle<Map> name##_map_handle();
STRUCT_LIST(STRUCT_MAP_ACCESSOR) STRUCT_LIST(STRUCT_MAP_ACCESSOR)
#undef STRUCT_MAP_ACCESSOR #undef STRUCT_MAP_ACCESSOR
#define ALLOCATION_SITE_MAP_ACCESSOR(NAME, Name, Size, name) \ #define ALLOCATION_SITE_MAP_ACCESSOR(NAME, Name, Size, name) \
inline Map* name##_map(); inline Map* name##_map(); \
inline class Handle<Map> name##_map_handle();
ALLOCATION_SITE_LIST(ALLOCATION_SITE_MAP_ACCESSOR) ALLOCATION_SITE_LIST(ALLOCATION_SITE_MAP_ACCESSOR)
#undef ALLOCATION_SITE_MAP_ACCESSOR #undef ALLOCATION_SITE_MAP_ACCESSOR
......
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