[explicit isolates] Convert regexp, debug and snapshot 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: I631fa1e44d2b9998a5567c96c6977955ac86d5a1 Reviewed-on: https://chromium-review.googlesource.com/1125931 Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#54215}
This commit is contained in:
parent
85051099ae
commit
0ddcee75db
@ -575,7 +575,7 @@ void Coverage::SelectMode(Isolate* isolate, debug::Coverage::Mode mode) {
|
||||
isolate->debug()->RemoveAllCoverageInfos();
|
||||
if (!isolate->is_collecting_type_profile()) {
|
||||
isolate->SetFeedbackVectorsForProfilingTools(
|
||||
isolate->heap()->undefined_value());
|
||||
ReadOnlyRoots(isolate).undefined_value());
|
||||
}
|
||||
break;
|
||||
case debug::Coverage::kBlockBinary:
|
||||
|
@ -778,7 +778,7 @@ bool ScopeIterator::SetLocalVariableValue(Handle<String> variable_name,
|
||||
case VariableLocation::UNALLOCATED:
|
||||
// Drop assignments to unallocated locals.
|
||||
DCHECK(var->is_this() ||
|
||||
*variable_name == isolate_->heap()->arguments_string());
|
||||
*variable_name == ReadOnlyRoots(isolate_).arguments_string());
|
||||
return false;
|
||||
|
||||
case VariableLocation::PARAMETER: {
|
||||
|
@ -100,7 +100,7 @@ void TypeProfile::SelectMode(Isolate* isolate, debug::TypeProfile::Mode mode) {
|
||||
// coverage.
|
||||
if (isolate->is_best_effort_code_coverage()) {
|
||||
isolate->SetFeedbackVectorsForProfilingTools(
|
||||
isolate->heap()->undefined_value());
|
||||
ReadOnlyRoots(isolate).undefined_value());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2194,7 +2194,7 @@ void Debug::StopSideEffectCheckMode() {
|
||||
DCHECK(isolate_->debug_execution_mode() == DebugInfo::kSideEffects);
|
||||
if (side_effect_check_failed_) {
|
||||
DCHECK(isolate_->has_pending_exception());
|
||||
DCHECK_EQ(isolate_->heap()->termination_exception(),
|
||||
DCHECK_EQ(ReadOnlyRoots(isolate_).termination_exception(),
|
||||
isolate_->pending_exception());
|
||||
// Convert the termination exception into a regular exception.
|
||||
isolate_->CancelTerminateExecution();
|
||||
|
@ -6872,7 +6872,8 @@ void RegExpResultsCache::Enter(Isolate* isolate, Handle<String> key_string,
|
||||
}
|
||||
}
|
||||
// Convert backing store to a copy-on-write array.
|
||||
value_array->set_map_no_write_barrier(isolate->heap()->fixed_cow_array_map());
|
||||
value_array->set_map_no_write_barrier(
|
||||
ReadOnlyRoots(isolate).fixed_cow_array_map());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1514,7 +1514,7 @@ class RegExpEngine: public AllStatic {
|
||||
struct CompilationResult {
|
||||
CompilationResult(Isolate* isolate, const char* error_message)
|
||||
: error_message(error_message),
|
||||
code(isolate->heap()->the_hole_value()),
|
||||
code(ReadOnlyRoots(isolate).the_hole_value()),
|
||||
num_registers(0) {}
|
||||
CompilationResult(Object* code, int registers)
|
||||
: error_message(nullptr), code(code), num_registers(registers) {}
|
||||
|
@ -164,29 +164,29 @@ void CodeSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
ReadOnlyRoots roots(isolate());
|
||||
if (ElideObject(obj)) {
|
||||
return SerializeObject(isolate()->heap()->undefined_value(), how_to_code,
|
||||
where_to_point, skip);
|
||||
return SerializeObject(roots.undefined_value(), how_to_code, where_to_point,
|
||||
skip);
|
||||
}
|
||||
|
||||
if (obj->IsScript()) {
|
||||
Script* script_obj = Script::cast(obj);
|
||||
DCHECK_NE(script_obj->compilation_type(), Script::COMPILATION_TYPE_EVAL);
|
||||
// Wrapper object is a context-dependent JSValue. Reset it here.
|
||||
script_obj->set_wrapper(isolate()->heap()->undefined_value());
|
||||
script_obj->set_wrapper(roots.undefined_value());
|
||||
// We want to differentiate between undefined and uninitialized_symbol for
|
||||
// context_data for now. It is hack to allow debugging for scripts that are
|
||||
// included as a part of custom snapshot. (see debug::Script::IsEmbedded())
|
||||
Object* context_data = script_obj->context_data();
|
||||
if (context_data != isolate()->heap()->undefined_value() &&
|
||||
context_data != isolate()->heap()->uninitialized_symbol()) {
|
||||
script_obj->set_context_data(isolate()->heap()->undefined_value());
|
||||
if (context_data != roots.undefined_value() &&
|
||||
context_data != roots.uninitialized_symbol()) {
|
||||
script_obj->set_context_data(roots.undefined_value());
|
||||
}
|
||||
// We don't want to serialize host options to avoid serializing unnecessary
|
||||
// object graph.
|
||||
FixedArray* host_options = script_obj->host_defined_options();
|
||||
script_obj->set_host_defined_options(
|
||||
isolate()->heap()->empty_fixed_array());
|
||||
script_obj->set_host_defined_options(roots.empty_fixed_array());
|
||||
SerializeGeneric(obj, how_to_code, where_to_point);
|
||||
script_obj->set_host_defined_options(host_options);
|
||||
script_obj->set_context_data(context_data);
|
||||
@ -315,7 +315,7 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
|
||||
|
||||
if (isolate->logger()->is_listening_to_code_events() ||
|
||||
isolate->is_profiling()) {
|
||||
String* name = isolate->heap()->empty_string();
|
||||
String* name = ReadOnlyRoots(isolate).empty_string();
|
||||
if (result->script()->IsScript()) {
|
||||
Script* script = Script::cast(result->script());
|
||||
if (script->name()->IsString()) name = String::cast(script->name());
|
||||
|
@ -71,9 +71,9 @@ Address DefaultDeserializerAllocator::Allocate(AllocationSpace space,
|
||||
// aligned object when the filler maps have not been deserialized yet.
|
||||
// We require filler maps as padding to align the object.
|
||||
Heap* heap = isolate()->heap();
|
||||
DCHECK(heap->free_space_map()->IsMap());
|
||||
DCHECK(heap->one_pointer_filler_map()->IsMap());
|
||||
DCHECK(heap->two_pointer_filler_map()->IsMap());
|
||||
DCHECK(ReadOnlyRoots(heap).free_space_map()->IsMap());
|
||||
DCHECK(ReadOnlyRoots(heap).one_pointer_filler_map()->IsMap());
|
||||
DCHECK(ReadOnlyRoots(heap).two_pointer_filler_map()->IsMap());
|
||||
obj = heap->AlignWithFiller(obj, size, reserved, next_alignment_);
|
||||
address = obj->address();
|
||||
next_alignment_ = kWordAligned;
|
||||
|
@ -182,7 +182,7 @@ HeapObject* Deserializer<AllocatorT>::PostProcessNewObject(HeapObject* obj,
|
||||
// as a (weak) root. If this root is relocated correctly, this becomes
|
||||
// unnecessary.
|
||||
if (isolate_->heap()->allocation_sites_list() == Smi::kZero) {
|
||||
site->set_weak_next(isolate_->heap()->undefined_value());
|
||||
site->set_weak_next(ReadOnlyRoots(isolate_).undefined_value());
|
||||
} else {
|
||||
site->set_weak_next(isolate_->heap()->allocation_sites_list());
|
||||
}
|
||||
@ -203,7 +203,7 @@ HeapObject* Deserializer<AllocatorT>::PostProcessNewObject(HeapObject* obj,
|
||||
call_handler_infos_.push_back(CallHandlerInfo::cast(obj));
|
||||
#endif
|
||||
} else if (obj->IsExternalString()) {
|
||||
if (obj->map() == isolate_->heap()->native_source_string_map()) {
|
||||
if (obj->map() == ReadOnlyRoots(isolate_).native_source_string_map()) {
|
||||
ExternalOneByteString* string = ExternalOneByteString::cast(obj);
|
||||
DCHECK(string->is_short());
|
||||
string->set_resource(
|
||||
|
@ -37,11 +37,11 @@ void PartialSerializer::Serialize(Context** o, bool include_global_proxy) {
|
||||
// it before serializing, it will get re-added to the context list
|
||||
// explicitly when it's loaded.
|
||||
context_->set(Context::NEXT_CONTEXT_LINK,
|
||||
isolate()->heap()->undefined_value());
|
||||
ReadOnlyRoots(isolate()).undefined_value());
|
||||
DCHECK(!context_->global_object()->IsUndefined());
|
||||
// Reset math random cache to get fresh random numbers.
|
||||
context_->set_math_random_index(Smi::kZero);
|
||||
context_->set_math_random_cache(isolate()->heap()->undefined_value());
|
||||
context_->set_math_random_cache(ReadOnlyRoots(isolate()).undefined_value());
|
||||
|
||||
VisitRootPointer(Root::kPartialSnapshotCache, nullptr,
|
||||
reinterpret_cast<Object**>(o));
|
||||
@ -125,8 +125,8 @@ bool PartialSerializer::ShouldBeInThePartialSnapshotCache(HeapObject* o) {
|
||||
return o->IsName() || o->IsSharedFunctionInfo() || o->IsHeapNumber() ||
|
||||
o->IsCode() || o->IsScopeInfo() || o->IsAccessorInfo() ||
|
||||
o->IsTemplateInfo() ||
|
||||
o->map() ==
|
||||
startup_serializer_->isolate()->heap()->fixed_cow_array_map();
|
||||
o->map() == ReadOnlyRoots(startup_serializer_->isolate())
|
||||
.fixed_cow_array_map();
|
||||
}
|
||||
|
||||
void PartialSerializer::SerializeEmbedderFields() {
|
||||
|
@ -500,7 +500,7 @@ void Serializer<AllocatorT>::ObjectSerializer::SerializeExternalString() {
|
||||
// for native native source code strings, we replace the resource field
|
||||
// with the native source id.
|
||||
// For the rest we serialize them to look like ordinary sequential strings.
|
||||
if (object_->map() != heap->native_source_string_map()) {
|
||||
if (object_->map() != ReadOnlyRoots(heap).native_source_string_map()) {
|
||||
ExternalString* string = ExternalString::cast(object_);
|
||||
Address resource = string->resource_as_address();
|
||||
ExternalReferenceEncoder::Value reference;
|
||||
@ -532,9 +532,9 @@ void Serializer<
|
||||
AllocatorT>::ObjectSerializer::SerializeExternalStringAsSequentialString() {
|
||||
// Instead of serializing this as an external string, we serialize
|
||||
// an imaginary sequential string with the same content.
|
||||
Isolate* isolate = serializer_->isolate();
|
||||
ReadOnlyRoots roots(serializer_->isolate());
|
||||
DCHECK(object_->IsExternalString());
|
||||
DCHECK(object_->map() != isolate->heap()->native_source_string_map());
|
||||
DCHECK(object_->map() != roots.native_source_string_map());
|
||||
ExternalString* string = ExternalString::cast(object_);
|
||||
int length = string->length();
|
||||
Map* map;
|
||||
@ -544,15 +544,14 @@ void Serializer<
|
||||
// Find the map and size for the imaginary sequential string.
|
||||
bool internalized = object_->IsInternalizedString();
|
||||
if (object_->IsExternalOneByteString()) {
|
||||
map = internalized ? isolate->heap()->one_byte_internalized_string_map()
|
||||
: isolate->heap()->one_byte_string_map();
|
||||
map = internalized ? roots.one_byte_internalized_string_map()
|
||||
: roots.one_byte_string_map();
|
||||
allocation_size = SeqOneByteString::SizeFor(length);
|
||||
content_size = length * kCharSize;
|
||||
resource = reinterpret_cast<const byte*>(
|
||||
ExternalOneByteString::cast(string)->resource()->data());
|
||||
} else {
|
||||
map = internalized ? isolate->heap()->internalized_string_map()
|
||||
: isolate->heap()->string_map();
|
||||
map = internalized ? roots.internalized_string_map() : roots.string_map();
|
||||
allocation_size = SeqTwoByteString::SizeFor(length);
|
||||
content_size = length * kShortSize;
|
||||
resource = reinterpret_cast<const byte*>(
|
||||
@ -595,7 +594,8 @@ class UnlinkWeakNextScope {
|
||||
if (object->IsAllocationSite()) {
|
||||
object_ = object;
|
||||
next_ = AllocationSite::cast(object)->weak_next();
|
||||
AllocationSite::cast(object)->set_weak_next(heap->undefined_value());
|
||||
AllocationSite::cast(object)->set_weak_next(
|
||||
ReadOnlyRoots(heap).undefined_value());
|
||||
}
|
||||
}
|
||||
|
||||
@ -648,7 +648,7 @@ void Serializer<AllocatorT>::ObjectSerializer::Serialize() {
|
||||
|
||||
if (object_->IsScript()) {
|
||||
// Clear cached line ends.
|
||||
Object* undefined = serializer_->isolate()->heap()->undefined_value();
|
||||
Object* undefined = ReadOnlyRoots(serializer_->isolate()).undefined_value();
|
||||
Script::cast(object_)->set_line_ends(undefined);
|
||||
}
|
||||
|
||||
|
@ -52,12 +52,13 @@ void StartupDeserializer::DeserializeInto(Isolate* isolate) {
|
||||
FlushICacheForNewIsolate();
|
||||
}
|
||||
|
||||
isolate->heap()->set_native_contexts_list(isolate->heap()->undefined_value());
|
||||
isolate->heap()->set_native_contexts_list(
|
||||
ReadOnlyRoots(isolate).undefined_value());
|
||||
// The allocation site list is build during root iteration, but if no sites
|
||||
// were encountered then it needs to be initialized to undefined.
|
||||
if (isolate->heap()->allocation_sites_list() == Smi::kZero) {
|
||||
isolate->heap()->set_allocation_sites_list(
|
||||
isolate->heap()->undefined_value());
|
||||
ReadOnlyRoots(isolate).undefined_value());
|
||||
}
|
||||
|
||||
// Issue code events for newly deserialized code objects.
|
||||
|
@ -65,12 +65,12 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
|
||||
call_handler_infos_.push_back(info);
|
||||
} else if (obj->IsScript() && Script::cast(obj)->IsUserJavaScript()) {
|
||||
Script::cast(obj)->set_context_data(
|
||||
isolate()->heap()->uninitialized_symbol());
|
||||
ReadOnlyRoots(isolate()).uninitialized_symbol());
|
||||
} else if (obj->IsSharedFunctionInfo()) {
|
||||
// Clear inferred name for native functions.
|
||||
SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj);
|
||||
if (!shared->IsSubjectToDebugging() && shared->HasInferredName()) {
|
||||
shared->set_inferred_name(isolate()->heap()->empty_string());
|
||||
shared->set_inferred_name(ReadOnlyRoots(isolate()).empty_string());
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ void StartupSerializer::SerializeWeakReferencesAndDeferred() {
|
||||
// This comes right after serialization of the partial snapshot, where we
|
||||
// add entries to the partial snapshot cache of the startup snapshot. Add
|
||||
// one entry with 'undefined' to terminate the partial snapshot cache.
|
||||
Object* undefined = isolate()->heap()->undefined_value();
|
||||
Object* undefined = ReadOnlyRoots(isolate()).undefined_value();
|
||||
VisitRootPointer(Root::kPartialSnapshotCache, nullptr, &undefined);
|
||||
isolate()->heap()->IterateWeakRoots(this, VISIT_FOR_SERIALIZATION);
|
||||
SerializeDeferredObjects();
|
||||
|
Loading…
Reference in New Issue
Block a user