Commit 61f174a2 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[explicit isolates] Convert runtime/ to ReadOnlyRoots

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

Bug: v8:7786
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Ifd2f75298bacd2f6a89c551f689d269a59d87e97
Reviewed-on: https://chromium-review.googlesource.com/1124470
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54183}
parent 1fd8207b
...@@ -93,7 +93,7 @@ Object* RemoveArrayHolesGeneric(Isolate* isolate, Handle<JSReceiver> receiver, ...@@ -93,7 +93,7 @@ Object* RemoveArrayHolesGeneric(Isolate* isolate, Handle<JSReceiver> receiver,
if (key >= limit) break; if (key >= limit) break;
Maybe<bool> has_element = JSReceiver::HasElement(receiver, key); Maybe<bool> has_element = JSReceiver::HasElement(receiver, key);
MAYBE_RETURN(has_element, isolate->heap()->exception()); MAYBE_RETURN(has_element, ReadOnlyRoots(isolate).exception());
if (!has_element.FromJust()) { if (!has_element.FromJust()) {
continue; continue;
} }
...@@ -108,7 +108,7 @@ Object* RemoveArrayHolesGeneric(Isolate* isolate, Handle<JSReceiver> receiver, ...@@ -108,7 +108,7 @@ Object* RemoveArrayHolesGeneric(Isolate* isolate, Handle<JSReceiver> receiver,
// Find next free position to move elements to. // Find next free position to move elements to.
Maybe<uint32_t> free_position = Maybe<uint32_t> free_position =
FindNextFreePosition(isolate, receiver, current_pos); FindNextFreePosition(isolate, receiver, current_pos);
MAYBE_RETURN(free_position, isolate->heap()->exception()); MAYBE_RETURN(free_position, ReadOnlyRoots(isolate).exception());
current_pos = free_position.FromJust(); current_pos = free_position.FromJust();
// Do not move elements that are already in the "packed" area. // Do not move elements that are already in the "packed" area.
...@@ -148,7 +148,7 @@ Object* RemoveArrayHolesGeneric(Isolate* isolate, Handle<JSReceiver> receiver, ...@@ -148,7 +148,7 @@ Object* RemoveArrayHolesGeneric(Isolate* isolate, Handle<JSReceiver> receiver,
if (key >= limit) continue; if (key >= limit) continue;
Maybe<bool> delete_result = JSReceiver::DeleteElement(receiver, key); Maybe<bool> delete_result = JSReceiver::DeleteElement(receiver, key);
MAYBE_RETURN(delete_result, isolate->heap()->exception()); MAYBE_RETURN(delete_result, ReadOnlyRoots(isolate).exception());
} }
return *isolate->factory()->NewNumberFromUint(result); return *isolate->factory()->NewNumberFromUint(result);
...@@ -218,7 +218,7 @@ Object* RemoveArrayHoles(Isolate* isolate, Handle<JSReceiver> receiver, ...@@ -218,7 +218,7 @@ Object* RemoveArrayHoles(Isolate* isolate, Handle<JSReceiver> receiver,
} }
uint32_t result = 0; uint32_t result = 0;
if (elements_base->map() == isolate->heap()->fixed_double_array_map()) { if (elements_base->map() == ReadOnlyRoots(isolate).fixed_double_array_map()) {
FixedDoubleArray* elements = FixedDoubleArray::cast(*elements_base); FixedDoubleArray* elements = FixedDoubleArray::cast(*elements_base);
// Split elements into defined and the_hole, in that order. // Split elements into defined and the_hole, in that order.
unsigned int holes = limit; unsigned int holes = limit;
...@@ -367,7 +367,7 @@ RUNTIME_FUNCTION(Runtime_PrepareElementsForSort) { ...@@ -367,7 +367,7 @@ RUNTIME_FUNCTION(Runtime_PrepareElementsForSort) {
if (isolate->debug_execution_mode() == DebugInfo::kSideEffects) { if (isolate->debug_execution_mode() == DebugInfo::kSideEffects) {
if (!isolate->debug()->PerformSideEffectCheckForObject(object)) { if (!isolate->debug()->PerformSideEffectCheckForObject(object)) {
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
} }
...@@ -689,10 +689,10 @@ RUNTIME_FUNCTION(Runtime_HasComplexElements) { ...@@ -689,10 +689,10 @@ RUNTIME_FUNCTION(Runtime_HasComplexElements) {
for (PrototypeIterator iter(isolate, array, kStartAtReceiver); for (PrototypeIterator iter(isolate, array, kStartAtReceiver);
!iter.IsAtEnd(); iter.Advance()) { !iter.IsAtEnd(); iter.Advance()) {
if (PrototypeIterator::GetCurrent<JSReceiver>(iter)->HasComplexElements()) { if (PrototypeIterator::GetCurrent<JSReceiver>(iter)->HasComplexElements()) {
return isolate->heap()->true_value(); return ReadOnlyRoots(isolate).true_value();
} }
} }
return isolate->heap()->false_value(); return ReadOnlyRoots(isolate).false_value();
} }
// ES6 22.1.2.2 Array.isArray // ES6 22.1.2.2 Array.isArray
...@@ -701,7 +701,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIsArray) { ...@@ -701,7 +701,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIsArray) {
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
Maybe<bool> result = Object::IsArray(object); Maybe<bool> result = Object::IsArray(object);
MAYBE_RETURN(result, isolate->heap()->exception()); MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return isolate->heap()->ToBoolean(result.FromJust()); return isolate->heap()->ToBoolean(result.FromJust());
} }
...@@ -754,7 +754,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) { ...@@ -754,7 +754,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) {
} }
} }
if (len == 0) return isolate->heap()->false_value(); if (len == 0) return ReadOnlyRoots(isolate).false_value();
// Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step // Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
// produces the value 0.) // produces the value 0.)
...@@ -773,7 +773,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) { ...@@ -773,7 +773,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) {
} else { } else {
DCHECK(from_index->IsHeapNumber()); DCHECK(from_index->IsHeapNumber());
double start_from = from_index->Number(); double start_from = from_index->Number();
if (start_from >= len) return isolate->heap()->false_value(); if (start_from >= len) return ReadOnlyRoots(isolate).false_value();
if (V8_LIKELY(std::isfinite(start_from))) { if (V8_LIKELY(std::isfinite(start_from))) {
if (start_from < 0) { if (start_from < 0) {
index = static_cast<int64_t>(std::max<double>(start_from + len, 0)); index = static_cast<int64_t>(std::max<double>(start_from + len, 0));
...@@ -795,7 +795,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) { ...@@ -795,7 +795,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) {
Maybe<bool> result = elements->IncludesValue(isolate, obj, search_element, Maybe<bool> result = elements->IncludesValue(isolate, obj, search_element,
static_cast<uint32_t>(index), static_cast<uint32_t>(index),
static_cast<uint32_t>(len)); static_cast<uint32_t>(len));
MAYBE_RETURN(result, isolate->heap()->exception()); MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust()); return *isolate->factory()->ToBoolean(result.FromJust());
} }
...@@ -815,10 +815,10 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) { ...@@ -815,10 +815,10 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) {
// If SameValueZero(searchElement, elementK) is true, return true. // If SameValueZero(searchElement, elementK) is true, return true.
if (search_element->SameValueZero(*element_k)) { if (search_element->SameValueZero(*element_k)) {
return isolate->heap()->true_value(); return ReadOnlyRoots(isolate).true_value();
} }
} }
return isolate->heap()->false_value(); return ReadOnlyRoots(isolate).false_value();
} }
RUNTIME_FUNCTION(Runtime_ArrayIndexOf) { RUNTIME_FUNCTION(Runtime_ArrayIndexOf) {
...@@ -893,7 +893,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) { ...@@ -893,7 +893,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) {
Maybe<int64_t> result = elements->IndexOfValue(isolate, obj, search_element, Maybe<int64_t> result = elements->IndexOfValue(isolate, obj, search_element,
static_cast<uint32_t>(index), static_cast<uint32_t>(index),
static_cast<uint32_t>(len)); static_cast<uint32_t>(len));
MAYBE_RETURN(result, isolate->heap()->exception()); MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->NewNumberFromInt64(result.FromJust()); return *isolate->factory()->NewNumberFromInt64(result.FromJust());
} }
...@@ -908,7 +908,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) { ...@@ -908,7 +908,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) {
isolate, object, index_obj, &success); isolate, object, index_obj, &success);
DCHECK(success); DCHECK(success);
Maybe<bool> present = JSReceiver::HasProperty(&it); Maybe<bool> present = JSReceiver::HasProperty(&it);
MAYBE_RETURN(present, isolate->heap()->exception()); MAYBE_RETURN(present, ReadOnlyRoots(isolate).exception());
if (!present.FromJust()) continue; if (!present.FromJust()) continue;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element_k, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element_k,
Object::GetProperty(&it)); Object::GetProperty(&it));
......
...@@ -103,7 +103,7 @@ RUNTIME_FUNCTION(Runtime_ThrowNotSuperConstructor) { ...@@ -103,7 +103,7 @@ RUNTIME_FUNCTION(Runtime_ThrowNotSuperConstructor) {
RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) { RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) {
DCHECK_EQ(0, args.length()); DCHECK_EQ(0, args.length());
return isolate->heap()->home_object_symbol(); return ReadOnlyRoots(isolate).home_object_symbol();
} }
namespace { namespace {
...@@ -128,7 +128,7 @@ inline void SetHomeObject(Isolate* isolate, JSFunction* method, ...@@ -128,7 +128,7 @@ inline void SetHomeObject(Isolate* isolate, JSFunction* method,
if (method->shared()->needs_home_object()) { if (method->shared()->needs_home_object()) {
const int kPropertyIndex = JSFunction::kMaybeHomeObjectDescriptorIndex; const int kPropertyIndex = JSFunction::kMaybeHomeObjectDescriptorIndex;
CHECK_EQ(method->map()->instance_descriptors()->GetKey(kPropertyIndex), CHECK_EQ(method->map()->instance_descriptors()->GetKey(kPropertyIndex),
isolate->heap()->home_object_symbol()); ReadOnlyRoots(isolate).home_object_symbol());
FieldIndex field_index = FieldIndex field_index =
FieldIndex::ForDescriptor(method->map(), kPropertyIndex); FieldIndex::ForDescriptor(method->map(), kPropertyIndex);
...@@ -287,7 +287,7 @@ bool AddDescriptorsByTemplate( ...@@ -287,7 +287,7 @@ bool AddDescriptorsByTemplate(
Handle<NumberDictionary> elements_dictionary = Handle<NumberDictionary> elements_dictionary =
*elements_dictionary_template == *elements_dictionary_template ==
isolate->heap()->empty_slow_element_dictionary() ReadOnlyRoots(isolate).empty_slow_element_dictionary()
? elements_dictionary_template ? elements_dictionary_template
: ShallowCopyDictionaryTemplate(isolate, : ShallowCopyDictionaryTemplate(isolate,
elements_dictionary_template); elements_dictionary_template);
...@@ -519,7 +519,7 @@ bool InitClassConstructor(Isolate* isolate, ...@@ -519,7 +519,7 @@ bool InitClassConstructor(Isolate* isolate,
Handle<NameDictionary>::cast(properties_template); Handle<NameDictionary>::cast(properties_template);
map->set_is_dictionary_map(true); map->set_is_dictionary_map(true);
map->InitializeDescriptors(isolate->heap()->empty_descriptor_array(), map->InitializeDescriptors(ReadOnlyRoots(isolate).empty_descriptor_array(),
LayoutDescriptor::FastPointerLayout()); LayoutDescriptor::FastPointerLayout());
map->set_is_migration_target(false); map->set_is_migration_target(false);
map->set_may_have_interesting_symbols(true); map->set_may_have_interesting_symbols(true);
......
...@@ -16,7 +16,7 @@ namespace internal { ...@@ -16,7 +16,7 @@ namespace internal {
RUNTIME_FUNCTION(Runtime_TheHole) { RUNTIME_FUNCTION(Runtime_TheHole) {
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
DCHECK_EQ(0, args.length()); DCHECK_EQ(0, args.length());
return isolate->heap()->the_hole_value(); return ReadOnlyRoots(isolate).the_hole_value();
} }
RUNTIME_FUNCTION(Runtime_SetGrow) { RUNTIME_FUNCTION(Runtime_SetGrow) {
...@@ -26,7 +26,7 @@ RUNTIME_FUNCTION(Runtime_SetGrow) { ...@@ -26,7 +26,7 @@ RUNTIME_FUNCTION(Runtime_SetGrow) {
Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()), isolate); Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()), isolate);
table = OrderedHashSet::EnsureGrowable(isolate, table); table = OrderedHashSet::EnsureGrowable(isolate, table);
holder->set_table(*table); holder->set_table(*table);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
...@@ -37,7 +37,7 @@ RUNTIME_FUNCTION(Runtime_SetShrink) { ...@@ -37,7 +37,7 @@ RUNTIME_FUNCTION(Runtime_SetShrink) {
Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()), isolate); Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()), isolate);
table = OrderedHashSet::Shrink(isolate, table); table = OrderedHashSet::Shrink(isolate, table);
holder->set_table(*table); holder->set_table(*table);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_SetIteratorClone) { RUNTIME_FUNCTION(Runtime_SetIteratorClone) {
...@@ -57,7 +57,7 @@ RUNTIME_FUNCTION(Runtime_MapShrink) { ...@@ -57,7 +57,7 @@ RUNTIME_FUNCTION(Runtime_MapShrink) {
Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()), isolate); Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()), isolate);
table = OrderedHashMap::Shrink(isolate, table); table = OrderedHashMap::Shrink(isolate, table);
holder->set_table(*table); holder->set_table(*table);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_MapGrow) { RUNTIME_FUNCTION(Runtime_MapGrow) {
...@@ -67,7 +67,7 @@ RUNTIME_FUNCTION(Runtime_MapGrow) { ...@@ -67,7 +67,7 @@ RUNTIME_FUNCTION(Runtime_MapGrow) {
Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()), isolate); Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()), isolate);
table = OrderedHashMap::EnsureGrowable(isolate, table); table = OrderedHashMap::EnsureGrowable(isolate, table);
holder->set_table(*table); holder->set_table(*table);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_MapIteratorClone) { RUNTIME_FUNCTION(Runtime_MapIteratorClone) {
......
...@@ -36,7 +36,7 @@ RUNTIME_FUNCTION(Runtime_CompileLazy) { ...@@ -36,7 +36,7 @@ RUNTIME_FUNCTION(Runtime_CompileLazy) {
return isolate->StackOverflow(); return isolate->StackOverflow();
} }
if (!Compiler::Compile(function, Compiler::KEEP_EXCEPTION)) { if (!Compiler::Compile(function, Compiler::KEEP_EXCEPTION)) {
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
DCHECK(function->is_compiled()); DCHECK(function->is_compiled());
return function->code(); return function->code();
...@@ -51,7 +51,7 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) { ...@@ -51,7 +51,7 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) {
return isolate->StackOverflow(); return isolate->StackOverflow();
} }
if (!Compiler::CompileOptimized(function, ConcurrencyMode::kConcurrent)) { if (!Compiler::CompileOptimized(function, ConcurrencyMode::kConcurrent)) {
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
DCHECK(function->is_compiled()); DCHECK(function->is_compiled());
return function->code(); return function->code();
...@@ -85,7 +85,7 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized_NotConcurrent) { ...@@ -85,7 +85,7 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized_NotConcurrent) {
return isolate->StackOverflow(); return isolate->StackOverflow();
} }
if (!Compiler::CompileOptimized(function, ConcurrencyMode::kNotConcurrent)) { if (!Compiler::CompileOptimized(function, ConcurrencyMode::kNotConcurrent)) {
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
DCHECK(function->is_compiled()); DCHECK(function->is_compiled());
return function->code(); return function->code();
...@@ -173,7 +173,7 @@ RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) { ...@@ -173,7 +173,7 @@ RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) {
Deoptimizer::DeoptimizeFunction(*function); Deoptimizer::DeoptimizeFunction(*function);
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
...@@ -308,7 +308,7 @@ static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source, ...@@ -308,7 +308,7 @@ static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source,
MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError( MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError(
MessageTemplate::kCodeGenFromStrings, error_message); MessageTemplate::kCodeGenFromStrings, error_message);
if (maybe_error.ToHandle(&error)) isolate->Throw(*error); if (maybe_error.ToHandle(&error)) isolate->Throw(*error);
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
// Deal with a normal eval call with a string argument. Compile it // Deal with a normal eval call with a string argument. Compile it
...@@ -320,7 +320,7 @@ static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source, ...@@ -320,7 +320,7 @@ static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source,
Compiler::GetFunctionFromEval(source, outer_info, context, language_mode, Compiler::GetFunctionFromEval(source, outer_info, context, language_mode,
restriction, kNoSourcePosition, restriction, kNoSourcePosition,
eval_scope_position, eval_position), eval_scope_position, eval_position),
isolate->heap()->exception()); ReadOnlyRoots(isolate).exception());
return *compiled; return *compiled;
} }
......
...@@ -84,7 +84,7 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_DebugBreakOnBytecode) { ...@@ -84,7 +84,7 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_DebugBreakOnBytecode) {
operand_scale); operand_scale);
if (side_effect_check_failed) { if (side_effect_check_failed) {
return MakePair(isolate->heap()->exception(), return MakePair(ReadOnlyRoots(isolate).exception(),
Smi::FromInt(static_cast<uint8_t>(bytecode))); Smi::FromInt(static_cast<uint8_t>(bytecode)));
} }
Object* interrupt_object = isolate->stack_guard()->HandleInterrupts(); Object* interrupt_object = isolate->stack_guard()->HandleInterrupts();
...@@ -110,7 +110,7 @@ RUNTIME_FUNCTION(Runtime_DebugBreakAtEntry) { ...@@ -110,7 +110,7 @@ RUNTIME_FUNCTION(Runtime_DebugBreakAtEntry) {
DCHECK_EQ(*function, it.frame()->function()); DCHECK_EQ(*function, it.frame()->function());
isolate->debug()->Break(it.frame(), function); isolate->debug()->Break(it.frame(), function);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) { RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) {
...@@ -128,7 +128,7 @@ RUNTIME_FUNCTION(Runtime_ScheduleBreak) { ...@@ -128,7 +128,7 @@ RUNTIME_FUNCTION(Runtime_ScheduleBreak) {
isolate->RequestInterrupt( isolate->RequestInterrupt(
[](v8::Isolate* isolate, void*) { v8::debug::BreakRightNow(isolate); }, [](v8::Isolate* isolate, void*) { v8::debug::BreakRightNow(isolate); },
nullptr); nullptr);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
template <class IteratorType> template <class IteratorType>
...@@ -246,7 +246,7 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate, ...@@ -246,7 +246,7 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
result->set(1, *status_str); result->set(1, *status_str);
Handle<Object> value_obj(promise->status() == Promise::kPending Handle<Object> value_obj(promise->status() == Promise::kPending
? isolate->heap()->undefined_value() ? ReadOnlyRoots(isolate).undefined_value()
: promise->result(), : promise->result(),
isolate); isolate);
Handle<String> promise_value = Handle<String> promise_value =
...@@ -314,7 +314,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) { ...@@ -314,7 +314,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) {
DCHECK_EQ(2, args.length()); DCHECK_EQ(2, args.length());
if (!args[0]->IsJSGeneratorObject()) { if (!args[0]->IsJSGeneratorObject()) {
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
// Check arguments. // Check arguments.
...@@ -323,7 +323,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) { ...@@ -323,7 +323,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) {
// Only inspect suspended generator scopes. // Only inspect suspended generator scopes.
if (!gen->is_suspended()) { if (!gen->is_suspended()) {
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
// Find the requested scope. // Find the requested scope.
...@@ -333,7 +333,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) { ...@@ -333,7 +333,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) {
n++; n++;
} }
if (it.Done()) { if (it.Done()) {
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
return *it.MaterializeScopeDetails(); return *it.MaterializeScopeDetails();
...@@ -382,7 +382,7 @@ RUNTIME_FUNCTION(Runtime_GetBreakLocations) { ...@@ -382,7 +382,7 @@ RUNTIME_FUNCTION(Runtime_GetBreakLocations) {
Handle<Object> break_locations = Handle<Object> break_locations =
Debug::GetSourceBreakLocations(isolate, shared); Debug::GetSourceBreakLocations(isolate, shared);
if (break_locations->IsUndefined(isolate)) { if (break_locations->IsUndefined(isolate)) {
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
// Return array as JS array // Return array as JS array
return *isolate->factory()->NewJSArrayWithElements( return *isolate->factory()->NewJSArrayWithElements(
...@@ -408,7 +408,7 @@ RUNTIME_FUNCTION(Runtime_ClearStepping) { ...@@ -408,7 +408,7 @@ RUNTIME_FUNCTION(Runtime_ClearStepping) {
DCHECK_EQ(0, args.length()); DCHECK_EQ(0, args.length());
CHECK(isolate->debug()->is_active()); CHECK(isolate->debug()->is_active());
isolate->debug()->ClearStepping(); isolate->debug()->ClearStepping();
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) {
...@@ -420,7 +420,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { ...@@ -420,7 +420,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) {
DebugScope debug_scope(isolate->debug()); DebugScope debug_scope(isolate->debug());
if (debug_scope.failed()) { if (debug_scope.failed()) {
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
// Fill the script objects. // Fill the script objects.
instances = isolate->debug()->GetLoadedScripts(); instances = isolate->debug()->GetLoadedScripts();
...@@ -451,7 +451,7 @@ RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { ...@@ -451,7 +451,7 @@ RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) {
if (f->IsJSFunction()) { if (f->IsJSFunction()) {
return JSFunction::cast(f)->shared()->inferred_name(); return JSFunction::cast(f)->shared()->inferred_name();
} }
return isolate->heap()->empty_string(); return ReadOnlyRoots(isolate).empty_string();
} }
...@@ -463,11 +463,11 @@ RUNTIME_FUNCTION(Runtime_GetDebugContext) { ...@@ -463,11 +463,11 @@ RUNTIME_FUNCTION(Runtime_GetDebugContext) {
DebugScope debug_scope(isolate->debug()); DebugScope debug_scope(isolate->debug());
if (debug_scope.failed()) { if (debug_scope.failed()) {
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
context = isolate->debug()->GetDebugContext(); context = isolate->debug()->GetDebugContext();
} }
if (context.is_null()) return isolate->heap()->undefined_value(); if (context.is_null()) return ReadOnlyRoots(isolate).undefined_value();
context->set_security_token(isolate->native_context()->security_token()); context->set_security_token(isolate->native_context()->security_token());
return context->global_proxy(); return context->global_proxy();
} }
...@@ -480,7 +480,7 @@ RUNTIME_FUNCTION(Runtime_CollectGarbage) { ...@@ -480,7 +480,7 @@ RUNTIME_FUNCTION(Runtime_CollectGarbage) {
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask, isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask,
GarbageCollectionReason::kRuntime); GarbageCollectionReason::kRuntime);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
...@@ -521,7 +521,7 @@ RUNTIME_FUNCTION(Runtime_GetScript) { ...@@ -521,7 +521,7 @@ RUNTIME_FUNCTION(Runtime_GetScript) {
} }
} }
if (found.is_null()) return isolate->heap()->undefined_value(); if (found.is_null()) return ReadOnlyRoots(isolate).undefined_value();
return *Script::GetWrapper(found); return *Script::GetWrapper(found);
} }
...@@ -729,10 +729,10 @@ RUNTIME_FUNCTION(Runtime_DebugOnFunctionCall) { ...@@ -729,10 +729,10 @@ RUNTIME_FUNCTION(Runtime_DebugOnFunctionCall) {
} }
if (isolate->debug_execution_mode() == DebugInfo::kSideEffects && if (isolate->debug_execution_mode() == DebugInfo::kSideEffects &&
!isolate->debug()->PerformSideEffectCheck(fun, receiver)) { !isolate->debug()->PerformSideEffectCheck(fun, receiver)) {
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
// Set one shot breakpoints for the suspended generator object. // Set one shot breakpoints for the suspended generator object.
...@@ -740,7 +740,7 @@ RUNTIME_FUNCTION(Runtime_DebugPrepareStepInSuspendedGenerator) { ...@@ -740,7 +740,7 @@ RUNTIME_FUNCTION(Runtime_DebugPrepareStepInSuspendedGenerator) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(0, args.length()); DCHECK_EQ(0, args.length());
isolate->debug()->PrepareStepInSuspendedGenerator(); isolate->debug()->PrepareStepInSuspendedGenerator();
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_DebugPushPromise) { RUNTIME_FUNCTION(Runtime_DebugPushPromise) {
...@@ -748,7 +748,7 @@ RUNTIME_FUNCTION(Runtime_DebugPushPromise) { ...@@ -748,7 +748,7 @@ RUNTIME_FUNCTION(Runtime_DebugPushPromise) {
HandleScope scope(isolate); HandleScope scope(isolate);
CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
isolate->PushPromise(promise); isolate->PushPromise(promise);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
...@@ -756,7 +756,7 @@ RUNTIME_FUNCTION(Runtime_DebugPopPromise) { ...@@ -756,7 +756,7 @@ RUNTIME_FUNCTION(Runtime_DebugPopPromise) {
DCHECK_EQ(0, args.length()); DCHECK_EQ(0, args.length());
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
isolate->PopPromise(); isolate->PopPromise();
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_DebugIsActive) { RUNTIME_FUNCTION(Runtime_DebugIsActive) {
...@@ -838,7 +838,7 @@ RUNTIME_FUNCTION(Runtime_DebugTogglePreciseCoverage) { ...@@ -838,7 +838,7 @@ RUNTIME_FUNCTION(Runtime_DebugTogglePreciseCoverage) {
CONVERT_BOOLEAN_ARG_CHECKED(enable, 0); CONVERT_BOOLEAN_ARG_CHECKED(enable, 0);
Coverage::SelectMode(isolate, enable ? debug::Coverage::kPreciseCount Coverage::SelectMode(isolate, enable ? debug::Coverage::kPreciseCount
: debug::Coverage::kBestEffort); : debug::Coverage::kBestEffort);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_DebugToggleBlockCoverage) { RUNTIME_FUNCTION(Runtime_DebugToggleBlockCoverage) {
...@@ -846,7 +846,7 @@ RUNTIME_FUNCTION(Runtime_DebugToggleBlockCoverage) { ...@@ -846,7 +846,7 @@ RUNTIME_FUNCTION(Runtime_DebugToggleBlockCoverage) {
CONVERT_BOOLEAN_ARG_CHECKED(enable, 0); CONVERT_BOOLEAN_ARG_CHECKED(enable, 0);
Coverage::SelectMode(isolate, enable ? debug::Coverage::kBlockCount Coverage::SelectMode(isolate, enable ? debug::Coverage::kBlockCount
: debug::Coverage::kBestEffort); : debug::Coverage::kBestEffort);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_IncBlockCounter) { RUNTIME_FUNCTION(Runtime_IncBlockCounter) {
...@@ -866,7 +866,7 @@ RUNTIME_FUNCTION(Runtime_IncBlockCounter) { ...@@ -866,7 +866,7 @@ RUNTIME_FUNCTION(Runtime_IncBlockCounter) {
coverage_info->IncrementBlockCount(coverage_array_slot_index); coverage_info->IncrementBlockCount(coverage_array_slot_index);
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionSuspended) { RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionSuspended) {
...@@ -874,7 +874,7 @@ RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionSuspended) { ...@@ -874,7 +874,7 @@ RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionSuspended) {
HandleScope scope(isolate); HandleScope scope(isolate);
CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0); CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0);
isolate->OnAsyncFunctionStateChanged(promise, debug::kAsyncFunctionSuspended); isolate->OnAsyncFunctionStateChanged(promise, debug::kAsyncFunctionSuspended);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionFinished) { RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionFinished) {
...@@ -887,7 +887,7 @@ RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionFinished) { ...@@ -887,7 +887,7 @@ RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionFinished) {
isolate->OnAsyncFunctionStateChanged(promise, isolate->OnAsyncFunctionStateChanged(promise,
debug::kAsyncFunctionFinished); debug::kAsyncFunctionFinished);
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_LiveEditPatchScript) { RUNTIME_FUNCTION(Runtime_LiveEditPatchScript) {
...@@ -924,9 +924,9 @@ RUNTIME_FUNCTION(Runtime_LiveEditPatchScript) { ...@@ -924,9 +924,9 @@ RUNTIME_FUNCTION(Runtime_LiveEditPatchScript) {
return isolate->Throw(*isolate->factory()->NewStringFromAsciiChecked( return isolate->Throw(*isolate->factory()->NewStringFromAsciiChecked(
"LiveEdit failed: FRAME_RESTART_IS_NOT_SUPPORTED")); "LiveEdit failed: FRAME_RESTART_IS_NOT_SUPPORTED"));
case v8::debug::LiveEditResult::OK: case v8::debug::LiveEditResult::OK:
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -40,7 +40,7 @@ RUNTIME_FUNCTION(Runtime_FunctionGetScript) { ...@@ -40,7 +40,7 @@ RUNTIME_FUNCTION(Runtime_FunctionGetScript) {
return *Script::GetWrapper(Handle<Script>::cast(script)); return *Script::GetWrapper(Handle<Script>::cast(script));
} }
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_FunctionGetScriptId) { RUNTIME_FUNCTION(Runtime_FunctionGetScriptId) {
...@@ -67,7 +67,7 @@ RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) { ...@@ -67,7 +67,7 @@ RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) {
Handle<JSFunction>::cast(function)->shared(), isolate); Handle<JSFunction>::cast(function)->shared(), isolate);
return *SharedFunctionInfo::GetSourceCode(shared); return *SharedFunctionInfo::GetSourceCode(shared);
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
...@@ -102,7 +102,7 @@ RUNTIME_FUNCTION(Runtime_SetCode) { ...@@ -102,7 +102,7 @@ RUNTIME_FUNCTION(Runtime_SetCode) {
if (!source->is_compiled() && if (!source->is_compiled() &&
!Compiler::Compile(source, Compiler::KEEP_EXCEPTION)) { !Compiler::Compile(source, Compiler::KEEP_EXCEPTION)) {
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
// Set the function data, scope info, formal parameter count, and the length // Set the function data, scope info, formal parameter count, and the length
...@@ -163,7 +163,7 @@ RUNTIME_FUNCTION(Runtime_SetNativeFlag) { ...@@ -163,7 +163,7 @@ RUNTIME_FUNCTION(Runtime_SetNativeFlag) {
JSFunction* func = JSFunction::cast(object); JSFunction* func = JSFunction::cast(object);
func->shared()->set_native(true); func->shared()->set_native(true);
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
......
...@@ -39,7 +39,7 @@ RUNTIME_FUNCTION(Runtime_SetAllowAtomicsWait) { ...@@ -39,7 +39,7 @@ RUNTIME_FUNCTION(Runtime_SetAllowAtomicsWait) {
CONVERT_BOOLEAN_ARG_CHECKED(set, 0); CONVERT_BOOLEAN_ARG_CHECKED(set, 0);
isolate->set_allow_atomics_wait(set); isolate->set_allow_atomics_wait(set);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -96,7 +96,7 @@ RUNTIME_FUNCTION(Runtime_AsyncGeneratorHasCatchHandlerForPC) { ...@@ -96,7 +96,7 @@ RUNTIME_FUNCTION(Runtime_AsyncGeneratorHasCatchHandlerForPC) {
// If state is 0 ("suspendedStart"), there is guaranteed to be no catch // If state is 0 ("suspendedStart"), there is guaranteed to be no catch
// handler. Otherwise, if state is below 0, the generator is closed and will // handler. Otherwise, if state is below 0, the generator is closed and will
// not reach a catch handler. // not reach a catch handler.
if (state < 1) return isolate->heap()->false_value(); if (state < 1) return ReadOnlyRoots(isolate).false_value();
SharedFunctionInfo* shared = generator->function()->shared(); SharedFunctionInfo* shared = generator->function()->shared();
DCHECK(shared->HasBytecodeArray()); DCHECK(shared->HasBytecodeArray());
......
...@@ -27,7 +27,7 @@ RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) { ...@@ -27,7 +27,7 @@ RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) {
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
DCHECK_EQ(0, args.length()); DCHECK_EQ(0, args.length());
CHECK(isolate->bootstrapper()->IsActive()); CHECK(isolate->bootstrapper()->IsActive());
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_ExportFromRuntime) { RUNTIME_FUNCTION(Runtime_ExportFromRuntime) {
...@@ -63,7 +63,7 @@ RUNTIME_FUNCTION(Runtime_InstallToContext) { ...@@ -63,7 +63,7 @@ RUNTIME_FUNCTION(Runtime_InstallToContext) {
CHECK_NE(index, Context::kNotFound); CHECK_NE(index, Context::kNotFound);
native_context->set(index, *object); native_context->set(index, *object);
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_Throw) { RUNTIME_FUNCTION(Runtime_Throw) {
...@@ -297,7 +297,7 @@ RUNTIME_FUNCTION(Runtime_AllocateSeqOneByteString) { ...@@ -297,7 +297,7 @@ RUNTIME_FUNCTION(Runtime_AllocateSeqOneByteString) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_SMI_ARG_CHECKED(length, 0); CONVERT_SMI_ARG_CHECKED(length, 0);
if (length == 0) return isolate->heap()->empty_string(); if (length == 0) return ReadOnlyRoots(isolate).empty_string();
Handle<SeqOneByteString> result; Handle<SeqOneByteString> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, isolate->factory()->NewRawOneByteString(length)); isolate, result, isolate->factory()->NewRawOneByteString(length));
...@@ -308,7 +308,7 @@ RUNTIME_FUNCTION(Runtime_AllocateSeqTwoByteString) { ...@@ -308,7 +308,7 @@ RUNTIME_FUNCTION(Runtime_AllocateSeqTwoByteString) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_SMI_ARG_CHECKED(length, 0); CONVERT_SMI_ARG_CHECKED(length, 0);
if (length == 0) return isolate->heap()->empty_string(); if (length == 0) return ReadOnlyRoots(isolate).empty_string();
Handle<SeqTwoByteString> result; Handle<SeqTwoByteString> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, isolate->factory()->NewRawTwoByteString(length)); isolate, result, isolate->factory()->NewRawTwoByteString(length));
...@@ -471,7 +471,7 @@ RUNTIME_FUNCTION(Runtime_IncrementUseCounter) { ...@@ -471,7 +471,7 @@ RUNTIME_FUNCTION(Runtime_IncrementUseCounter) {
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_SMI_ARG_CHECKED(counter, 0); CONVERT_SMI_ARG_CHECKED(counter, 0);
isolate->CountUsage(static_cast<v8::Isolate::UseCounterFeature>(counter)); isolate->CountUsage(static_cast<v8::Isolate::UseCounterFeature>(counter));
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_GetAndResetRuntimeCallStats) { RUNTIME_FUNCTION(Runtime_GetAndResetRuntimeCallStats) {
...@@ -516,7 +516,7 @@ RUNTIME_FUNCTION(Runtime_GetAndResetRuntimeCallStats) { ...@@ -516,7 +516,7 @@ RUNTIME_FUNCTION(Runtime_GetAndResetRuntimeCallStats) {
std::fclose(f); std::fclose(f);
else else
std::fflush(f); std::fflush(f);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
} }
...@@ -587,7 +587,7 @@ RUNTIME_FUNCTION(Runtime_ReportMessage) { ...@@ -587,7 +587,7 @@ RUNTIME_FUNCTION(Runtime_ReportMessage) {
isolate->set_pending_exception(*message_obj); isolate->set_pending_exception(*message_obj);
isolate->ReportPendingMessagesFromJavaScript(); isolate->ReportPendingMessagesFromJavaScript();
isolate->clear_pending_exception(); isolate->clear_pending_exception();
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
} // namespace internal } // namespace internal
......
...@@ -118,7 +118,7 @@ void PrintRegisters(Isolate* isolate, std::ostream& os, bool is_input, ...@@ -118,7 +118,7 @@ void PrintRegisters(Isolate* isolate, std::ostream& os, bool is_input,
RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeEntry) { RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeEntry) {
if (!FLAG_trace_ignition) { if (!FLAG_trace_ignition) {
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
...@@ -147,12 +147,12 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeEntry) { ...@@ -147,12 +147,12 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeEntry) {
os << std::flush; os << std::flush;
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) { RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) {
if (!FLAG_trace_ignition) { if (!FLAG_trace_ignition) {
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
...@@ -175,7 +175,7 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) { ...@@ -175,7 +175,7 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) {
PrintRegisters(isolate, os, false, bytecode_iterator, accumulator); PrintRegisters(isolate, os, false, bytecode_iterator, accumulator);
os << std::flush; os << std::flush;
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
#endif #endif
...@@ -184,7 +184,7 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) { ...@@ -184,7 +184,7 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) {
RUNTIME_FUNCTION(Runtime_InterpreterTraceUpdateFeedback) { RUNTIME_FUNCTION(Runtime_InterpreterTraceUpdateFeedback) {
if (!FLAG_trace_feedback_updates) { if (!FLAG_trace_feedback_updates) {
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
...@@ -210,7 +210,7 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceUpdateFeedback) { ...@@ -210,7 +210,7 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceUpdateFeedback) {
os << "]" << std::endl; os << "]" << std::endl;
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
#endif #endif
......
...@@ -204,7 +204,7 @@ RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) { ...@@ -204,7 +204,7 @@ RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) {
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol(); Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
JSObject::SetProperty(input, marker, type, LanguageMode::kStrict).Assert(); JSObject::SetProperty(input, marker, type, LanguageMode::kStrict).Assert();
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) {
...@@ -536,7 +536,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) { ...@@ -536,7 +536,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) {
break_iterator->setText(*u_text); break_iterator->setText(*u_text);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) { RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) {
...@@ -600,7 +600,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) { ...@@ -600,7 +600,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) {
if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) { if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {
return *isolate->factory()->NewStringFromStaticChars("none"); return *isolate->factory()->NewStringFromStaticChars("none");
} else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) { } else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) {
return isolate->heap()->number_string(); return ReadOnlyRoots(isolate).number_string();
} else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) { } else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) {
return *isolate->factory()->NewStringFromStaticChars("letter"); return *isolate->factory()->NewStringFromStaticChars("letter");
} else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) { } else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) {
...@@ -674,7 +674,8 @@ RUNTIME_FUNCTION(Runtime_StringLocaleConvertCase) { ...@@ -674,7 +674,8 @@ RUNTIME_FUNCTION(Runtime_StringLocaleConvertCase) {
RUNTIME_FUNCTION(Runtime_DateCacheVersion) { RUNTIME_FUNCTION(Runtime_DateCacheVersion) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(0, args.length()); DCHECK_EQ(0, args.length());
if (isolate->serializer_enabled()) return isolate->heap()->undefined_value(); if (isolate->serializer_enabled())
return ReadOnlyRoots(isolate).undefined_value();
if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) { if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) {
Handle<FixedArray> date_cache_version = Handle<FixedArray> date_cache_version =
isolate->factory()->NewFixedArray(1, TENURED); isolate->factory()->NewFixedArray(1, TENURED);
......
...@@ -155,7 +155,7 @@ MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk( ...@@ -155,7 +155,7 @@ MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
case PACKED_ELEMENTS: case PACKED_ELEMENTS:
case HOLEY_ELEMENTS: { case HOLEY_ELEMENTS: {
Handle<FixedArray> elements(FixedArray::cast(copy->elements()), isolate); Handle<FixedArray> elements(FixedArray::cast(copy->elements()), isolate);
if (elements->map() == isolate->heap()->fixed_cow_array_map()) { if (elements->map() == ReadOnlyRoots(isolate).fixed_cow_array_map()) {
#ifdef DEBUG #ifdef DEBUG
for (int i = 0; i < elements->length(); i++) { for (int i = 0; i < elements->length(); i++) {
DCHECK(!elements->get(i)->IsJSObject()); DCHECK(!elements->get(i)->IsJSObject());
...@@ -412,7 +412,7 @@ struct ArrayBoilerplate { ...@@ -412,7 +412,7 @@ struct ArrayBoilerplate {
} else { } else {
DCHECK(IsSmiOrObjectElementsKind(constant_elements_kind)); DCHECK(IsSmiOrObjectElementsKind(constant_elements_kind));
const bool is_cow = (constant_elements_values->map() == const bool is_cow = (constant_elements_values->map() ==
isolate->heap()->fixed_cow_array_map()); ReadOnlyRoots(isolate).fixed_cow_array_map());
if (is_cow) { if (is_cow) {
copied_elements_values = constant_elements_values; copied_elements_values = constant_elements_values;
#if DEBUG #if DEBUG
......
...@@ -95,7 +95,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) { ...@@ -95,7 +95,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) {
Handle<Script> script_handle = Handle<Script>::cast(old_script); Handle<Script> script_handle = Handle<Script>::cast(old_script);
return *Script::GetWrapper(script_handle); return *Script::GetWrapper(script_handle);
} else { } else {
return isolate->heap()->null_value(); return ReadOnlyRoots(isolate).null_value();
} }
} }
...@@ -111,7 +111,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFixupScript) { ...@@ -111,7 +111,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFixupScript) {
Handle<Script> script(Script::cast(script_value->value()), isolate); Handle<Script> script(Script::cast(script_value->value()), isolate);
LiveEdit::FixupScript(isolate, script, max_function_literal_id); LiveEdit::FixupScript(isolate, script, max_function_literal_id);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) { RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) {
...@@ -122,7 +122,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) { ...@@ -122,7 +122,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) {
CHECK(SharedInfoWrapper::IsInstance(shared_info)); CHECK(SharedInfoWrapper::IsInstance(shared_info));
LiveEdit::FunctionSourceUpdated(shared_info, new_function_literal_id); LiveEdit::FunctionSourceUpdated(shared_info, new_function_literal_id);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
...@@ -135,7 +135,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditReplaceFunctionCode) { ...@@ -135,7 +135,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditReplaceFunctionCode) {
CHECK(SharedInfoWrapper::IsInstance(shared_info)); CHECK(SharedInfoWrapper::IsInstance(shared_info));
LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
...@@ -160,7 +160,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFunctionSetScript) { ...@@ -160,7 +160,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFunctionSetScript) {
// and we check it in this function. // and we check it in this function.
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
...@@ -179,7 +179,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditReplaceRefToNestedFunction) { ...@@ -179,7 +179,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditReplaceRefToNestedFunction) {
LiveEdit::ReplaceRefToNestedFunction(isolate->heap(), parent_wrapper, LiveEdit::ReplaceRefToNestedFunction(isolate->heap(), parent_wrapper,
orig_wrapper, subst_wrapper); orig_wrapper, subst_wrapper);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
...@@ -196,7 +196,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditPatchFunctionPositions) { ...@@ -196,7 +196,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditPatchFunctionPositions) {
CHECK(SharedInfoWrapper::IsInstance(shared_array)); CHECK(SharedInfoWrapper::IsInstance(shared_array));
LiveEdit::PatchFunctionPositions(shared_array, position_change_array); LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
......
...@@ -48,7 +48,7 @@ RUNTIME_FUNCTION(Runtime_StringParseInt) { ...@@ -48,7 +48,7 @@ RUNTIME_FUNCTION(Runtime_StringParseInt) {
} }
int radix32 = DoubleToInt32(radix->Number()); int radix32 = DoubleToInt32(radix->Number());
if (radix32 != 0 && (radix32 < 2 || radix32 > 36)) { if (radix32 != 0 && (radix32 < 2 || radix32 > 36)) {
return isolate->heap()->nan_value(); return ReadOnlyRoots(isolate).nan_value();
} }
double result = StringToInt(isolate, subject, radix32); double result = StringToInt(isolate, subject, radix32);
......
This diff is collapsed.
...@@ -24,7 +24,7 @@ RUNTIME_FUNCTION(Runtime_Equal) { ...@@ -24,7 +24,7 @@ RUNTIME_FUNCTION(Runtime_Equal) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::Equals(isolate, x, y); Maybe<bool> result = Object::Equals(isolate, x, y);
if (result.IsNothing()) return isolate->heap()->exception(); if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
return isolate->heap()->ToBoolean(result.FromJust()); return isolate->heap()->ToBoolean(result.FromJust());
} }
...@@ -34,7 +34,7 @@ RUNTIME_FUNCTION(Runtime_NotEqual) { ...@@ -34,7 +34,7 @@ RUNTIME_FUNCTION(Runtime_NotEqual) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::Equals(isolate, x, y); Maybe<bool> result = Object::Equals(isolate, x, y);
if (result.IsNothing()) return isolate->heap()->exception(); if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
return isolate->heap()->ToBoolean(!result.FromJust()); return isolate->heap()->ToBoolean(!result.FromJust());
} }
...@@ -60,7 +60,7 @@ RUNTIME_FUNCTION(Runtime_LessThan) { ...@@ -60,7 +60,7 @@ RUNTIME_FUNCTION(Runtime_LessThan) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::LessThan(isolate, x, y); Maybe<bool> result = Object::LessThan(isolate, x, y);
if (result.IsNothing()) return isolate->heap()->exception(); if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
return isolate->heap()->ToBoolean(result.FromJust()); return isolate->heap()->ToBoolean(result.FromJust());
} }
...@@ -70,7 +70,7 @@ RUNTIME_FUNCTION(Runtime_GreaterThan) { ...@@ -70,7 +70,7 @@ RUNTIME_FUNCTION(Runtime_GreaterThan) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::GreaterThan(isolate, x, y); Maybe<bool> result = Object::GreaterThan(isolate, x, y);
if (result.IsNothing()) return isolate->heap()->exception(); if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
return isolate->heap()->ToBoolean(result.FromJust()); return isolate->heap()->ToBoolean(result.FromJust());
} }
...@@ -80,7 +80,7 @@ RUNTIME_FUNCTION(Runtime_LessThanOrEqual) { ...@@ -80,7 +80,7 @@ RUNTIME_FUNCTION(Runtime_LessThanOrEqual) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::LessThanOrEqual(isolate, x, y); Maybe<bool> result = Object::LessThanOrEqual(isolate, x, y);
if (result.IsNothing()) return isolate->heap()->exception(); if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
return isolate->heap()->ToBoolean(result.FromJust()); return isolate->heap()->ToBoolean(result.FromJust());
} }
...@@ -90,7 +90,7 @@ RUNTIME_FUNCTION(Runtime_GreaterThanOrEqual) { ...@@ -90,7 +90,7 @@ RUNTIME_FUNCTION(Runtime_GreaterThanOrEqual) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::GreaterThanOrEqual(isolate, x, y); Maybe<bool> result = Object::GreaterThanOrEqual(isolate, x, y);
if (result.IsNothing()) return isolate->heap()->exception(); if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
return isolate->heap()->ToBoolean(result.FromJust()); return isolate->heap()->ToBoolean(result.FromJust());
} }
......
...@@ -36,7 +36,7 @@ RUNTIME_FUNCTION(Runtime_PromiseRejectEventFromStack) { ...@@ -36,7 +36,7 @@ RUNTIME_FUNCTION(Runtime_PromiseRejectEventFromStack) {
isolate->ReportPromiseReject(promise, value, isolate->ReportPromiseReject(promise, value,
v8::kPromiseRejectWithNoHandler); v8::kPromiseRejectWithNoHandler);
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) { RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) {
...@@ -47,7 +47,7 @@ RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) { ...@@ -47,7 +47,7 @@ RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) {
CHECK(!promise->has_handler()); CHECK(!promise->has_handler());
isolate->ReportPromiseReject(promise, Handle<Object>(), isolate->ReportPromiseReject(promise, Handle<Object>(),
v8::kPromiseHandlerAddedAfterReject); v8::kPromiseHandlerAddedAfterReject);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) { RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) {
...@@ -57,14 +57,14 @@ RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) { ...@@ -57,14 +57,14 @@ RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) {
Handle<CallableTask> microtask = Handle<CallableTask> microtask =
isolate->factory()->NewCallableTask(function, isolate->native_context()); isolate->factory()->NewCallableTask(function, isolate->native_context());
isolate->EnqueueMicrotask(microtask); isolate->EnqueueMicrotask(microtask);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_RunMicrotasks) { RUNTIME_FUNCTION(Runtime_RunMicrotasks) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(0, args.length()); DCHECK_EQ(0, args.length());
isolate->RunMicrotasks(); isolate->RunMicrotasks();
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_RunMicrotaskCallback) { RUNTIME_FUNCTION(Runtime_RunMicrotaskCallback) {
...@@ -76,7 +76,7 @@ RUNTIME_FUNCTION(Runtime_RunMicrotaskCallback) { ...@@ -76,7 +76,7 @@ RUNTIME_FUNCTION(Runtime_RunMicrotaskCallback) {
void* data = ToCData<void*>(microtask_data); void* data = ToCData<void*>(microtask_data);
callback(data); callback(data);
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_PromiseStatus) { RUNTIME_FUNCTION(Runtime_PromiseStatus) {
...@@ -100,7 +100,7 @@ RUNTIME_FUNCTION(Runtime_PromiseMarkAsHandled) { ...@@ -100,7 +100,7 @@ RUNTIME_FUNCTION(Runtime_PromiseMarkAsHandled) {
CONVERT_ARG_CHECKED(JSPromise, promise, 0); CONVERT_ARG_CHECKED(JSPromise, promise, 0);
promise->set_has_handler(true); promise->set_has_handler(true);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_PromiseHookInit) { RUNTIME_FUNCTION(Runtime_PromiseHookInit) {
...@@ -109,7 +109,7 @@ RUNTIME_FUNCTION(Runtime_PromiseHookInit) { ...@@ -109,7 +109,7 @@ RUNTIME_FUNCTION(Runtime_PromiseHookInit) {
CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0); CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, parent, 1); CONVERT_ARG_HANDLE_CHECKED(Object, parent, 1);
isolate->RunPromiseHook(PromiseHookType::kInit, promise, parent); isolate->RunPromiseHook(PromiseHookType::kInit, promise, parent);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_AwaitPromisesInit) { RUNTIME_FUNCTION(Runtime_AwaitPromisesInit) {
...@@ -126,35 +126,37 @@ RUNTIME_FUNCTION(Runtime_AwaitPromisesInit) { ...@@ -126,35 +126,37 @@ RUNTIME_FUNCTION(Runtime_AwaitPromisesInit) {
// async_task_id as outer_promise since we generate WillHandle and DidHandle // async_task_id as outer_promise since we generate WillHandle and DidHandle
// events using throwaway promise. // events using throwaway promise.
throwaway->set_async_task_id(outer_promise->async_task_id()); throwaway->set_async_task_id(outer_promise->async_task_id());
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_PromiseHookBefore) { RUNTIME_FUNCTION(Runtime_PromiseHookBefore) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, maybe_promise, 0); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, maybe_promise, 0);
if (!maybe_promise->IsJSPromise()) return isolate->heap()->undefined_value(); if (!maybe_promise->IsJSPromise())
return ReadOnlyRoots(isolate).undefined_value();
Handle<JSPromise> promise = Handle<JSPromise>::cast(maybe_promise); Handle<JSPromise> promise = Handle<JSPromise>::cast(maybe_promise);
if (isolate->debug()->is_active()) isolate->PushPromise(promise); if (isolate->debug()->is_active()) isolate->PushPromise(promise);
if (promise->IsJSPromise()) { if (promise->IsJSPromise()) {
isolate->RunPromiseHook(PromiseHookType::kBefore, promise, isolate->RunPromiseHook(PromiseHookType::kBefore, promise,
isolate->factory()->undefined_value()); isolate->factory()->undefined_value());
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_PromiseHookAfter) { RUNTIME_FUNCTION(Runtime_PromiseHookAfter) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, maybe_promise, 0); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, maybe_promise, 0);
if (!maybe_promise->IsJSPromise()) return isolate->heap()->undefined_value(); if (!maybe_promise->IsJSPromise())
return ReadOnlyRoots(isolate).undefined_value();
Handle<JSPromise> promise = Handle<JSPromise>::cast(maybe_promise); Handle<JSPromise> promise = Handle<JSPromise>::cast(maybe_promise);
if (isolate->debug()->is_active()) isolate->PopPromise(); if (isolate->debug()->is_active()) isolate->PopPromise();
if (promise->IsJSPromise()) { if (promise->IsJSPromise()) {
isolate->RunPromiseHook(PromiseHookType::kAfter, promise, isolate->RunPromiseHook(PromiseHookType::kAfter, promise,
isolate->factory()->undefined_value()); isolate->factory()->undefined_value());
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_RejectPromise) { RUNTIME_FUNCTION(Runtime_RejectPromise) {
......
...@@ -51,7 +51,7 @@ RUNTIME_FUNCTION(Runtime_GetPropertyWithReceiver) { ...@@ -51,7 +51,7 @@ RUNTIME_FUNCTION(Runtime_GetPropertyWithReceiver) {
&success, holder); &success, holder);
if (!success) { if (!success) {
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
RETURN_RESULT_OR_FAILURE(isolate, Object::GetProperty(&it)); RETURN_RESULT_OR_FAILURE(isolate, Object::GetProperty(&it));
} }
...@@ -71,11 +71,11 @@ RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) { ...@@ -71,11 +71,11 @@ RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) {
&success, holder); &success, holder);
if (!success) { if (!success) {
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
Maybe<bool> result = Object::SetSuperProperty( Maybe<bool> result = Object::SetSuperProperty(
&it, value, language_mode, Object::MAY_BE_STORE_FROM_KEYED); &it, value, language_mode, Object::MAY_BE_STORE_FROM_KEYED);
MAYBE_RETURN(result, isolate->heap()->exception()); MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust()); return *isolate->factory()->ToBoolean(result.FromJust());
} }
...@@ -101,7 +101,7 @@ RUNTIME_FUNCTION(Runtime_CheckProxyHasTrap) { ...@@ -101,7 +101,7 @@ RUNTIME_FUNCTION(Runtime_CheckProxyHasTrap) {
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 1); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 1);
Maybe<bool> result = JSProxy::CheckHasTrap(isolate, name, target); Maybe<bool> result = JSProxy::CheckHasTrap(isolate, name, target);
if (!result.IsJust()) return isolate->heap()->exception(); if (!result.IsJust()) return ReadOnlyRoots(isolate).exception();
return isolate->heap()->ToBoolean(result.FromJust()); return isolate->heap()->ToBoolean(result.FromJust());
} }
......
...@@ -557,7 +557,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalAtomRegExpWithString( ...@@ -557,7 +557,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
result_len = static_cast<int>(result_len_64); result_len = static_cast<int>(result_len_64);
} }
if (result_len == 0) { if (result_len == 0) {
return isolate->heap()->empty_string(); return ReadOnlyRoots(isolate).empty_string();
} }
int subject_pos = 0; int subject_pos = 0;
...@@ -619,7 +619,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString( ...@@ -619,7 +619,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString(
// Ensure the RegExp is compiled so we can access the capture-name map. // Ensure the RegExp is compiled so we can access the capture-name map.
if (RegExpImpl::IrregexpPrepare(isolate, regexp, subject) == -1) { if (RegExpImpl::IrregexpPrepare(isolate, regexp, subject) == -1) {
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
} }
...@@ -641,11 +641,11 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString( ...@@ -641,11 +641,11 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString(
} }
RegExpImpl::GlobalCache global_cache(regexp, subject, isolate); RegExpImpl::GlobalCache global_cache(regexp, subject, isolate);
if (global_cache.HasException()) return isolate->heap()->exception(); if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
int32_t* current_match = global_cache.FetchNext(); int32_t* current_match = global_cache.FetchNext();
if (current_match == nullptr) { if (current_match == nullptr) {
if (global_cache.HasException()) return isolate->heap()->exception(); if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
return *subject; return *subject;
} }
...@@ -682,7 +682,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString( ...@@ -682,7 +682,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString(
current_match = global_cache.FetchNext(); current_match = global_cache.FetchNext();
} while (current_match != nullptr); } while (current_match != nullptr);
if (global_cache.HasException()) return isolate->heap()->exception(); if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
if (prev < subject_length) { if (prev < subject_length) {
builder.EnsureCapacity(2); builder.EnsureCapacity(2);
...@@ -714,11 +714,11 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString( ...@@ -714,11 +714,11 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
} }
RegExpImpl::GlobalCache global_cache(regexp, subject, isolate); RegExpImpl::GlobalCache global_cache(regexp, subject, isolate);
if (global_cache.HasException()) return isolate->heap()->exception(); if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
int32_t* current_match = global_cache.FetchNext(); int32_t* current_match = global_cache.FetchNext();
if (current_match == nullptr) { if (current_match == nullptr) {
if (global_cache.HasException()) return isolate->heap()->exception(); if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
return *subject; return *subject;
} }
...@@ -728,7 +728,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString( ...@@ -728,7 +728,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
int subject_length = subject->length(); int subject_length = subject->length();
int new_length = subject_length - (end - start); int new_length = subject_length - (end - start);
if (new_length == 0) return isolate->heap()->empty_string(); if (new_length == 0) return ReadOnlyRoots(isolate).empty_string();
Handle<ResultSeqString> answer; Handle<ResultSeqString> answer;
if (ResultSeqString::kHasOneByteEncoding) { if (ResultSeqString::kHasOneByteEncoding) {
...@@ -755,7 +755,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString( ...@@ -755,7 +755,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
current_match = global_cache.FetchNext(); current_match = global_cache.FetchNext();
} while (current_match != nullptr); } while (current_match != nullptr);
if (global_cache.HasException()) return isolate->heap()->exception(); if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
RegExpImpl::SetLastMatchInfo(isolate, last_match_info, subject, capture_count, RegExpImpl::SetLastMatchInfo(isolate, last_match_info, subject, capture_count,
global_cache.LastSuccessfulMatch()); global_cache.LastSuccessfulMatch());
...@@ -767,7 +767,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString( ...@@ -767,7 +767,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
position += subject_length - prev; position += subject_length - prev;
} }
if (position == 0) return isolate->heap()->empty_string(); if (position == 0) return ReadOnlyRoots(isolate).empty_string();
// Shorten string and fill // Shorten string and fill
int string_size = ResultSeqString::SizeFor(position); int string_size = ResultSeqString::SizeFor(position);
...@@ -1164,7 +1164,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject, ...@@ -1164,7 +1164,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
} }
RegExpImpl::GlobalCache global_cache(regexp, subject, isolate); RegExpImpl::GlobalCache global_cache(regexp, subject, isolate);
if (global_cache.HasException()) return isolate->heap()->exception(); if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
// Ensured in Runtime_RegExpExecMultiple. // Ensured in Runtime_RegExpExecMultiple.
DCHECK(result_array->HasObjectElements()); DCHECK(result_array->HasObjectElements());
...@@ -1232,7 +1232,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject, ...@@ -1232,7 +1232,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
elements->set(cursor++, *substring); elements->set(cursor++, *substring);
} else { } else {
DCHECK_GT(0, current_match[i * 2 + 1]); DCHECK_GT(0, current_match[i * 2 + 1]);
elements->set(cursor++, isolate->heap()->undefined_value()); elements->set(cursor++, ReadOnlyRoots(isolate).undefined_value());
} }
} }
...@@ -1255,7 +1255,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject, ...@@ -1255,7 +1255,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
} }
} }
if (global_cache.HasException()) return isolate->heap()->exception(); if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
if (match_start >= 0) { if (match_start >= 0) {
// Finished matching, with at least one match. // Finished matching, with at least one match.
...@@ -1290,7 +1290,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject, ...@@ -1290,7 +1290,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
} }
return *builder.ToJSArray(result_array); return *builder.ToJSArray(result_array);
} else { } else {
return isolate->heap()->null_value(); // No matches at all. return ReadOnlyRoots(isolate).null_value(); // No matches at all.
} }
} }
......
...@@ -71,14 +71,14 @@ Object* DeclareGlobal( ...@@ -71,14 +71,14 @@ Object* DeclareGlobal(
} }
LookupIterator it(global, name, global, lookup_config); LookupIterator it(global, name, global, lookup_config);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (maybe.IsNothing()) return isolate->heap()->exception(); if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
if (it.IsFound()) { if (it.IsFound()) {
PropertyAttributes old_attributes = maybe.FromJust(); PropertyAttributes old_attributes = maybe.FromJust();
// The name was declared before; check for conflicting re-declarations. // The name was declared before; check for conflicting re-declarations.
// Skip var re-declarations. // Skip var re-declarations.
if (is_var) return isolate->heap()->undefined_value(); if (is_var) return ReadOnlyRoots(isolate).undefined_value();
DCHECK(is_function_declaration); DCHECK(is_function_declaration);
if ((old_attributes & DONT_DELETE) != 0) { if ((old_attributes & DONT_DELETE) != 0) {
...@@ -128,7 +128,7 @@ Object* DeclareGlobal( ...@@ -128,7 +128,7 @@ Object* DeclareGlobal(
nexus.ConfigurePropertyCellMode(it.GetPropertyCell()); nexus.ConfigurePropertyCellMode(it.GetPropertyCell());
} }
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations, Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations,
...@@ -187,7 +187,7 @@ Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations, ...@@ -187,7 +187,7 @@ Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations,
if (isolate->has_pending_exception()) return result; if (isolate->has_pending_exception()) return result;
}); });
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
} // namespace } // namespace
...@@ -275,13 +275,13 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name, ...@@ -275,13 +275,13 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
DCHECK_EQ(NONE, attributes); DCHECK_EQ(NONE, attributes);
// Skip var re-declarations. // Skip var re-declarations.
if (is_var) return isolate->heap()->undefined_value(); if (is_var) return ReadOnlyRoots(isolate).undefined_value();
DCHECK(is_function); DCHECK(is_function);
if (index != Context::kNotFound) { if (index != Context::kNotFound) {
DCHECK(holder.is_identical_to(context)); DCHECK(holder.is_identical_to(context));
context->set(index, *value); context->set(index, *value);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
object = Handle<JSObject>::cast(holder); object = Handle<JSObject>::cast(holder);
...@@ -305,7 +305,7 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name, ...@@ -305,7 +305,7 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
object, name, value, NONE)); object, name, value, NONE));
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
} // namespace } // namespace
...@@ -407,7 +407,8 @@ Handle<JSObject> NewSloppyArguments(Isolate* isolate, Handle<JSFunction> callee, ...@@ -407,7 +407,8 @@ Handle<JSObject> NewSloppyArguments(Isolate* isolate, Handle<JSFunction> callee,
int mapped_count = Min(argument_count, parameter_count); int mapped_count = Min(argument_count, parameter_count);
Handle<FixedArray> parameter_map = Handle<FixedArray> parameter_map =
isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED); isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED);
parameter_map->set_map(isolate->heap()->sloppy_arguments_elements_map()); parameter_map->set_map(
ReadOnlyRoots(isolate).sloppy_arguments_elements_map());
result->set_map(isolate->native_context()->fast_aliased_arguments_map()); result->set_map(isolate->native_context()->fast_aliased_arguments_map());
result->set_elements(*parameter_map); result->set_elements(*parameter_map);
...@@ -647,7 +648,7 @@ static Object* FindNameClash(Isolate* isolate, Handle<ScopeInfo> scope_info, ...@@ -647,7 +648,7 @@ static Object* FindNameClash(Isolate* isolate, Handle<ScopeInfo> scope_info,
LookupIterator it(global_object, name, global_object, LookupIterator it(global_object, name, global_object,
LookupIterator::OWN_SKIP_INTERCEPTOR); LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (maybe.IsNothing()) return isolate->heap()->exception(); if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
if ((maybe.FromJust() & DONT_DELETE) != 0) { if ((maybe.FromJust() & DONT_DELETE) != 0) {
// ES#sec-globaldeclarationinstantiation 5.a: // ES#sec-globaldeclarationinstantiation 5.a:
// If envRec.HasVarDeclaration(name) is true, throw a SyntaxError // If envRec.HasVarDeclaration(name) is true, throw a SyntaxError
...@@ -661,7 +662,7 @@ static Object* FindNameClash(Isolate* isolate, Handle<ScopeInfo> scope_info, ...@@ -661,7 +662,7 @@ static Object* FindNameClash(Isolate* isolate, Handle<ScopeInfo> scope_info,
JSGlobalObject::InvalidatePropertyCell(global_object, name); JSGlobalObject::InvalidatePropertyCell(global_object, name);
} }
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
...@@ -768,14 +769,15 @@ RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) { ...@@ -768,14 +769,15 @@ RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) {
// If the slot was not found the result is true. // If the slot was not found the result is true.
if (holder.is_null()) { if (holder.is_null()) {
// In case of JSProxy, an exception might have been thrown. // In case of JSProxy, an exception might have been thrown.
if (isolate->has_pending_exception()) return isolate->heap()->exception(); if (isolate->has_pending_exception())
return isolate->heap()->true_value(); return ReadOnlyRoots(isolate).exception();
return ReadOnlyRoots(isolate).true_value();
} }
// If the slot was found in a context or in module imports and exports it // If the slot was found in a context or in module imports and exports it
// should be DONT_DELETE. // should be DONT_DELETE.
if (holder->IsContext() || holder->IsModule()) { if (holder->IsContext() || holder->IsModule()) {
return isolate->heap()->false_value(); return ReadOnlyRoots(isolate).false_value();
} }
// The slot was found in a JSReceiver, either a context extension object, // The slot was found in a JSReceiver, either a context extension object,
...@@ -783,7 +785,7 @@ RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) { ...@@ -783,7 +785,7 @@ RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) {
// (respecting DONT_DELETE). // (respecting DONT_DELETE).
Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder); Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder);
Maybe<bool> result = JSReceiver::DeleteProperty(object, name); Maybe<bool> result = JSReceiver::DeleteProperty(object, name);
MAYBE_RETURN(result, isolate->heap()->exception()); MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return isolate->heap()->ToBoolean(result.FromJust()); return isolate->heap()->ToBoolean(result.FromJust());
} }
...@@ -880,7 +882,7 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadLookupSlotForCall) { ...@@ -880,7 +882,7 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadLookupSlotForCall) {
Handle<Object> receiver; Handle<Object> receiver;
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, value, LoadLookupSlot(isolate, name, kThrowOnError, &receiver), isolate, value, LoadLookupSlot(isolate, name, kThrowOnError, &receiver),
MakePair(isolate->heap()->exception(), nullptr)); MakePair(ReadOnlyRoots(isolate).exception(), nullptr));
return MakePair(*value, *receiver); return MakePair(*value, *receiver);
} }
......
...@@ -123,14 +123,16 @@ RUNTIME_FUNCTION(Runtime_StringReplaceOneCharWithString) { ...@@ -123,14 +123,16 @@ RUNTIME_FUNCTION(Runtime_StringReplaceOneCharWithString) {
kRecursionLimit).ToHandle(&result)) { kRecursionLimit).ToHandle(&result)) {
return *result; return *result;
} }
if (isolate->has_pending_exception()) return isolate->heap()->exception(); if (isolate->has_pending_exception())
return ReadOnlyRoots(isolate).exception();
subject = String::Flatten(isolate, subject); subject = String::Flatten(isolate, subject);
if (StringReplaceOneCharWithString(isolate, subject, search, replace, &found, if (StringReplaceOneCharWithString(isolate, subject, search, replace, &found,
kRecursionLimit).ToHandle(&result)) { kRecursionLimit).ToHandle(&result)) {
return *result; return *result;
} }
if (isolate->has_pending_exception()) return isolate->heap()->exception(); if (isolate->has_pending_exception())
return ReadOnlyRoots(isolate).exception();
// In case of empty handle and no pending exception we have stack overflow. // In case of empty handle and no pending exception we have stack overflow.
return isolate->StackOverflow(); return isolate->StackOverflow();
} }
...@@ -166,7 +168,7 @@ RUNTIME_FUNCTION(Runtime_StringIncludes) { ...@@ -166,7 +168,7 @@ RUNTIME_FUNCTION(Runtime_StringIncludes) {
Maybe<bool> is_reg_exp = RegExpUtils::IsRegExp(isolate, search); Maybe<bool> is_reg_exp = RegExpUtils::IsRegExp(isolate, search);
if (is_reg_exp.IsNothing()) { if (is_reg_exp.IsNothing()) {
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
if (is_reg_exp.FromJust()) { if (is_reg_exp.FromJust()) {
THROW_NEW_ERROR_RETURN_FAILURE( THROW_NEW_ERROR_RETURN_FAILURE(
...@@ -260,7 +262,7 @@ RUNTIME_FUNCTION(Runtime_StringCharCodeAt) { ...@@ -260,7 +262,7 @@ RUNTIME_FUNCTION(Runtime_StringCharCodeAt) {
subject = String::Flatten(isolate, subject); subject = String::Flatten(isolate, subject);
if (i >= static_cast<uint32_t>(subject->length())) { if (i >= static_cast<uint32_t>(subject->length())) {
return isolate->heap()->nan_value(); return ReadOnlyRoots(isolate).nan_value();
} }
return Smi::FromInt(subject->Get(i)); return Smi::FromInt(subject->Get(i));
...@@ -289,7 +291,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) { ...@@ -289,7 +291,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
int special_length = special->length(); int special_length = special->length();
if (!array->HasObjectElements()) { if (!array->HasObjectElements()) {
return isolate->Throw(isolate->heap()->illegal_argument_string()); return isolate->Throw(ReadOnlyRoots(isolate).illegal_argument_string());
} }
int length; int length;
...@@ -303,7 +305,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) { ...@@ -303,7 +305,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
} }
if (array_length == 0) { if (array_length == 0) {
return isolate->heap()->empty_string(); return ReadOnlyRoots(isolate).empty_string();
} else if (array_length == 1) { } else if (array_length == 1) {
Object* first = fixed_array->get(0); Object* first = fixed_array->get(0);
if (first->IsString()) return first; if (first->IsString()) return first;
...@@ -313,10 +315,10 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) { ...@@ -313,10 +315,10 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
} }
if (length == -1) { if (length == -1) {
return isolate->Throw(isolate->heap()->illegal_argument_string()); return isolate->Throw(ReadOnlyRoots(isolate).illegal_argument_string());
} }
if (length == 0) { if (length == 0) {
return isolate->heap()->empty_string(); return ReadOnlyRoots(isolate).empty_string();
} }
if (one_byte) { if (one_byte) {
...@@ -356,7 +358,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderJoin) { ...@@ -356,7 +358,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderJoin) {
} }
if (array_length == 0) { if (array_length == 0) {
return isolate->heap()->empty_string(); return ReadOnlyRoots(isolate).empty_string();
} else if (array_length == 1) { } else if (array_length == 1) {
Object* first = fixed_array->get(0); Object* first = fixed_array->get(0);
CHECK(first->IsString()); CHECK(first->IsString());
...@@ -570,7 +572,7 @@ static int CopyCachedOneByteCharsToArray(Heap* heap, const uint8_t* chars, ...@@ -570,7 +572,7 @@ static int CopyCachedOneByteCharsToArray(Heap* heap, const uint8_t* chars,
FixedArray* elements, int length) { FixedArray* elements, int length) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
FixedArray* one_byte_cache = heap->single_character_string_cache(); FixedArray* one_byte_cache = heap->single_character_string_cache();
Object* undefined = heap->undefined_value(); Object* undefined = ReadOnlyRoots(heap).undefined_value();
int i; int i;
WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc);
for (i = 0; i < length; ++i) { for (i = 0; i < length; ++i) {
...@@ -618,8 +620,8 @@ RUNTIME_FUNCTION(Runtime_StringToArray) { ...@@ -618,8 +620,8 @@ RUNTIME_FUNCTION(Runtime_StringToArray) {
position = CopyCachedOneByteCharsToArray(isolate->heap(), chars.start(), position = CopyCachedOneByteCharsToArray(isolate->heap(), chars.start(),
*elements, length); *elements, length);
} else { } else {
MemsetPointer(elements->data_start(), isolate->heap()->undefined_value(), MemsetPointer(elements->data_start(),
length); ReadOnlyRoots(isolate).undefined_value(), length);
} }
} else { } else {
elements = isolate->factory()->NewFixedArray(length); elements = isolate->factory()->NewFixedArray(length);
...@@ -714,7 +716,7 @@ RUNTIME_FUNCTION(Runtime_StringCharFromCode) { ...@@ -714,7 +716,7 @@ RUNTIME_FUNCTION(Runtime_StringCharFromCode) {
code &= 0xFFFF; code &= 0xFFFF;
return *isolate->factory()->LookupSingleCharacterStringFromCode(code); return *isolate->factory()->LookupSingleCharacterStringFromCode(code);
} }
return isolate->heap()->empty_string(); return ReadOnlyRoots(isolate).empty_string();
} }
RUNTIME_FUNCTION(Runtime_StringMaxLength) { RUNTIME_FUNCTION(Runtime_StringMaxLength) {
......
This diff is collapsed.
...@@ -26,11 +26,11 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) { ...@@ -26,11 +26,11 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) {
} }
Handle<JSArrayBuffer> array_buffer = Handle<JSArrayBuffer>::cast(argument); Handle<JSArrayBuffer> array_buffer = Handle<JSArrayBuffer>::cast(argument);
if (!array_buffer->is_neuterable()) { if (!array_buffer->is_neuterable()) {
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
if (array_buffer->backing_store() == nullptr) { if (array_buffer->backing_store() == nullptr) {
CHECK_EQ(Smi::kZero, array_buffer->byte_length()); CHECK_EQ(Smi::kZero, array_buffer->byte_length());
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
// Shared array buffers should never be neutered. // Shared array buffers should never be neutered.
CHECK(!array_buffer->is_shared()); CHECK(!array_buffer->is_shared());
...@@ -41,7 +41,7 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) { ...@@ -41,7 +41,7 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) {
isolate->heap()->UnregisterArrayBuffer(*array_buffer); isolate->heap()->UnregisterArrayBuffer(*array_buffer);
array_buffer->Neuter(); array_buffer->Neuter();
isolate->array_buffer_allocator()->Free(backing_store, byte_length); isolate->array_buffer_allocator()->Free(backing_store, byte_length);
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_TypedArrayCopyElements) { RUNTIME_FUNCTION(Runtime_TypedArrayCopyElements) {
......
...@@ -136,7 +136,7 @@ RUNTIME_FUNCTION(Runtime_WasmThrowCreate) { ...@@ -136,7 +136,7 @@ RUNTIME_FUNCTION(Runtime_WasmThrowCreate) {
wasm::WasmException::kRuntimeValuesStr), wasm::WasmException::kRuntimeValuesStr),
values, LanguageMode::kStrict) values, LanguageMode::kStrict)
.is_null()); .is_null());
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_WasmThrow) { RUNTIME_FUNCTION(Runtime_WasmThrow) {
...@@ -226,7 +226,7 @@ RUNTIME_FUNCTION(Runtime_WasmExceptionSetElement) { ...@@ -226,7 +226,7 @@ RUNTIME_FUNCTION(Runtime_WasmExceptionSetElement) {
} }
} }
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
...@@ -267,9 +267,9 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { ...@@ -267,9 +267,9 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
if (!success) { if (!success) {
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception(); return ReadOnlyRoots(isolate).exception();
} }
return isolate->heap()->undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
} }
RUNTIME_FUNCTION(Runtime_WasmStackGuard) { RUNTIME_FUNCTION(Runtime_WasmStackGuard) {
......
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