Commit 6bdfeea6 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[explicit isolates] Convert ast/ and compiler/ to use ReadOnlyRoots

In future the RO_SPACE root accessors in Heap will become private, so
instead convert them all to use ReadOnlyRoots.

Bug: v8:7786
Change-Id: I315e63a30ca6f3077f18eb1a5004daefba9bc673
Reviewed-on: https://chromium-review.googlesource.com/1125929
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54223}
parent 86bdb100
...@@ -629,7 +629,7 @@ void ArrayLiteral::BuildConstantElements(Isolate* isolate) { ...@@ -629,7 +629,7 @@ void ArrayLiteral::BuildConstantElements(Isolate* isolate) {
// elements array to a copy-on-write array. // elements array to a copy-on-write array.
if (is_simple() && depth() == 1 && array_index > 0 && if (is_simple() && depth() == 1 && array_index > 0 &&
IsSmiOrObjectElementsKind(kind)) { IsSmiOrObjectElementsKind(kind)) {
fixed_array->set_map(isolate->heap()->fixed_cow_array_map()); fixed_array->set_map(ReadOnlyRoots(isolate).fixed_cow_array_map());
} }
Handle<FixedArrayBase> elements = fixed_array; Handle<FixedArrayBase> elements = fixed_array;
...@@ -722,7 +722,7 @@ Handle<TemplateObjectDescription> GetTemplateObject::GetOrBuildDescription( ...@@ -722,7 +722,7 @@ Handle<TemplateObjectDescription> GetTemplateObject::GetOrBuildDescription(
if (this->cooked_strings()->at(i) != nullptr) { if (this->cooked_strings()->at(i) != nullptr) {
cooked_strings->set(i, *this->cooked_strings()->at(i)->string()); cooked_strings->set(i, *this->cooked_strings()->at(i)->string());
} else { } else {
cooked_strings->set(i, isolate->heap()->undefined_value()); cooked_strings->set(i, ReadOnlyRoots(isolate).undefined_value());
} }
} }
} }
......
...@@ -431,7 +431,7 @@ Reduction JSCallReducer::ReduceFunctionPrototypeBind(Node* node) { ...@@ -431,7 +431,7 @@ Reduction JSCallReducer::ReduceFunctionPrototypeBind(Node* node) {
isolate()); isolate());
if (descriptors->number_of_descriptors() < 2) return NoChange(); if (descriptors->number_of_descriptors() < 2) return NoChange();
if (descriptors->GetKey(JSFunction::kLengthDescriptorIndex) != if (descriptors->GetKey(JSFunction::kLengthDescriptorIndex) !=
isolate()->heap()->length_string()) { ReadOnlyRoots(isolate()).length_string()) {
return NoChange(); return NoChange();
} }
if (!descriptors->GetStrongValue(JSFunction::kLengthDescriptorIndex) if (!descriptors->GetStrongValue(JSFunction::kLengthDescriptorIndex)
...@@ -439,7 +439,7 @@ Reduction JSCallReducer::ReduceFunctionPrototypeBind(Node* node) { ...@@ -439,7 +439,7 @@ Reduction JSCallReducer::ReduceFunctionPrototypeBind(Node* node) {
return NoChange(); return NoChange();
} }
if (descriptors->GetKey(JSFunction::kNameDescriptorIndex) != if (descriptors->GetKey(JSFunction::kNameDescriptorIndex) !=
isolate()->heap()->name_string()) { ReadOnlyRoots(isolate()).name_string()) {
return NoChange(); return NoChange();
} }
if (!descriptors->GetStrongValue(JSFunction::kNameDescriptorIndex) if (!descriptors->GetStrongValue(JSFunction::kNameDescriptorIndex)
......
...@@ -980,7 +980,8 @@ Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) { ...@@ -980,7 +980,8 @@ Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) {
// Use inline allocation of closures only for instantiation sites that have // Use inline allocation of closures only for instantiation sites that have
// seen more than one instantiation, this simplifies the generated code and // seen more than one instantiation, this simplifies the generated code and
// also serves as a heuristic of which allocation sites benefit from it. // also serves as a heuristic of which allocation sites benefit from it.
if (feedback_cell->map() != isolate()->heap()->many_closures_cell_map()) { if (feedback_cell->map() !=
ReadOnlyRoots(isolate()).many_closures_cell_map()) {
// The generic path can only create closures for user functions. // The generic path can only create closures for user functions.
DCHECK_EQ(isolate()->builtins()->builtin(Builtins::kCompileLazy), *code); DCHECK_EQ(isolate()->builtins()->builtin(Builtins::kCompileLazy), *code);
return NoChange(); return NoChange();
...@@ -1391,7 +1392,7 @@ Reduction JSCreateLowering::ReduceJSCreateObject(Node* node) { ...@@ -1391,7 +1392,7 @@ Reduction JSCreateLowering::ReduceJSCreateObject(Node* node) {
if (instance_map->is_dictionary_map()) { if (instance_map->is_dictionary_map()) {
DCHECK(prototype_const->IsNull()); DCHECK(prototype_const->IsNull());
// Allocated an empty NameDictionary as backing store for the properties. // Allocated an empty NameDictionary as backing store for the properties.
Handle<Map> map(isolate()->heap()->name_dictionary_map(), isolate()); Handle<Map> map(ReadOnlyRoots(isolate()).name_dictionary_map(), isolate());
int capacity = int capacity =
NameDictionary::ComputeCapacity(NameDictionary::kInitialCapacity); NameDictionary::ComputeCapacity(NameDictionary::kInitialCapacity);
DCHECK(base::bits::IsPowerOfTwo(capacity)); DCHECK(base::bits::IsPowerOfTwo(capacity));
......
...@@ -83,25 +83,25 @@ JSHeapBroker::JSHeapBroker(Isolate* isolate) : isolate_(isolate) {} ...@@ -83,25 +83,25 @@ JSHeapBroker::JSHeapBroker(Isolate* isolate) : isolate_(isolate) {}
HeapObjectType JSHeapBroker::HeapObjectTypeFromMap(Map* map) const { HeapObjectType JSHeapBroker::HeapObjectTypeFromMap(Map* map) const {
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
Heap* heap = isolate_->heap();
OddballType oddball_type = OddballType::kNone; OddballType oddball_type = OddballType::kNone;
if (map->instance_type() == ODDBALL_TYPE) { if (map->instance_type() == ODDBALL_TYPE) {
if (map == heap->undefined_map()) { ReadOnlyRoots roots(isolate_);
if (map == roots.undefined_map()) {
oddball_type = OddballType::kUndefined; oddball_type = OddballType::kUndefined;
} else if (map == heap->null_map()) { } else if (map == roots.null_map()) {
oddball_type = OddballType::kNull; oddball_type = OddballType::kNull;
} else if (map == heap->boolean_map()) { } else if (map == roots.boolean_map()) {
oddball_type = OddballType::kBoolean; oddball_type = OddballType::kBoolean;
} else if (map == heap->the_hole_map()) { } else if (map == roots.the_hole_map()) {
oddball_type = OddballType::kHole; oddball_type = OddballType::kHole;
} else if (map == heap->uninitialized_map()) { } else if (map == roots.uninitialized_map()) {
oddball_type = OddballType::kUninitialized; oddball_type = OddballType::kUninitialized;
} else { } else {
oddball_type = OddballType::kOther; oddball_type = OddballType::kOther;
DCHECK(map == heap->termination_exception_map() || DCHECK(map == roots.termination_exception_map() ||
map == heap->arguments_marker_map() || map == roots.arguments_marker_map() ||
map == heap->optimized_out_map() || map == roots.optimized_out_map() ||
map == heap->stale_register_map()); map == roots.stale_register_map());
} }
} }
HeapObjectType::Flags flags(0); HeapObjectType::Flags flags(0);
...@@ -248,7 +248,7 @@ bool IsFastLiteralHelper(Handle<JSObject> boilerplate, int max_depth, ...@@ -248,7 +248,7 @@ bool IsFastLiteralHelper(Handle<JSObject> boilerplate, int max_depth,
Isolate* const isolate = boilerplate->GetIsolate(); Isolate* const isolate = boilerplate->GetIsolate();
Handle<FixedArrayBase> elements(boilerplate->elements(), isolate); Handle<FixedArrayBase> elements(boilerplate->elements(), isolate);
if (elements->length() > 0 && if (elements->length() > 0 &&
elements->map() != isolate->heap()->fixed_cow_array_map()) { elements->map() != ReadOnlyRoots(isolate).fixed_cow_array_map()) {
if (boilerplate->HasSmiOrObjectElements()) { if (boilerplate->HasSmiOrObjectElements()) {
Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
int length = elements->length(); int length = elements->length();
...@@ -385,7 +385,8 @@ bool MapRef::IsJSArrayMap() const { ...@@ -385,7 +385,8 @@ bool MapRef::IsJSArrayMap() const {
bool MapRef::IsFixedCowArrayMap(const JSHeapBroker* broker) const { bool MapRef::IsFixedCowArrayMap(const JSHeapBroker* broker) const {
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return *object<Map>() == broker->isolate()->heap()->fixed_cow_array_map(); return *object<Map>() ==
ReadOnlyRoots(broker->isolate()).fixed_cow_array_map();
} }
ElementsKind JSArrayRef::GetElementsKind() const { ElementsKind JSArrayRef::GetElementsKind() const {
......
...@@ -877,7 +877,7 @@ PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl( ...@@ -877,7 +877,7 @@ PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl(
} }
if (compilation_info()->closure()->feedback_cell()->map() == if (compilation_info()->closure()->feedback_cell()->map() ==
isolate->heap()->one_closure_cell_map()) { ReadOnlyRoots(isolate).one_closure_cell_map()) {
compilation_info()->MarkAsFunctionContextSpecializing(); compilation_info()->MarkAsFunctionContextSpecializing();
} }
......
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