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,
if (key >= limit) break;
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()) {
continue;
}
......@@ -108,7 +108,7 @@ Object* RemoveArrayHolesGeneric(Isolate* isolate, Handle<JSReceiver> receiver,
// Find next free position to move elements to.
Maybe<uint32_t> free_position =
FindNextFreePosition(isolate, receiver, current_pos);
MAYBE_RETURN(free_position, isolate->heap()->exception());
MAYBE_RETURN(free_position, ReadOnlyRoots(isolate).exception());
current_pos = free_position.FromJust();
// Do not move elements that are already in the "packed" area.
......@@ -148,7 +148,7 @@ Object* RemoveArrayHolesGeneric(Isolate* isolate, Handle<JSReceiver> receiver,
if (key >= limit) continue;
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);
......@@ -218,7 +218,7 @@ Object* RemoveArrayHoles(Isolate* isolate, Handle<JSReceiver> receiver,
}
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);
// Split elements into defined and the_hole, in that order.
unsigned int holes = limit;
......@@ -367,7 +367,7 @@ RUNTIME_FUNCTION(Runtime_PrepareElementsForSort) {
if (isolate->debug_execution_mode() == DebugInfo::kSideEffects) {
if (!isolate->debug()->PerformSideEffectCheckForObject(object)) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
}
......@@ -689,10 +689,10 @@ RUNTIME_FUNCTION(Runtime_HasComplexElements) {
for (PrototypeIterator iter(isolate, array, kStartAtReceiver);
!iter.IsAtEnd(); iter.Advance()) {
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
......@@ -701,7 +701,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIsArray) {
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
Maybe<bool> result = Object::IsArray(object);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return isolate->heap()->ToBoolean(result.FromJust());
}
......@@ -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
// produces the value 0.)
......@@ -773,7 +773,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) {
} else {
DCHECK(from_index->IsHeapNumber());
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 (start_from < 0) {
index = static_cast<int64_t>(std::max<double>(start_from + len, 0));
......@@ -795,7 +795,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) {
Maybe<bool> result = elements->IncludesValue(isolate, obj, search_element,
static_cast<uint32_t>(index),
static_cast<uint32_t>(len));
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust());
}
......@@ -815,10 +815,10 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) {
// If SameValueZero(searchElement, elementK) is true, return true.
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) {
......@@ -893,7 +893,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) {
Maybe<int64_t> result = elements->IndexOfValue(isolate, obj, search_element,
static_cast<uint32_t>(index),
static_cast<uint32_t>(len));
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->NewNumberFromInt64(result.FromJust());
}
......@@ -908,7 +908,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) {
isolate, object, index_obj, &success);
DCHECK(success);
Maybe<bool> present = JSReceiver::HasProperty(&it);
MAYBE_RETURN(present, isolate->heap()->exception());
MAYBE_RETURN(present, ReadOnlyRoots(isolate).exception());
if (!present.FromJust()) continue;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element_k,
Object::GetProperty(&it));
......
......@@ -103,7 +103,7 @@ RUNTIME_FUNCTION(Runtime_ThrowNotSuperConstructor) {
RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) {
DCHECK_EQ(0, args.length());
return isolate->heap()->home_object_symbol();
return ReadOnlyRoots(isolate).home_object_symbol();
}
namespace {
......@@ -128,7 +128,7 @@ inline void SetHomeObject(Isolate* isolate, JSFunction* method,
if (method->shared()->needs_home_object()) {
const int kPropertyIndex = JSFunction::kMaybeHomeObjectDescriptorIndex;
CHECK_EQ(method->map()->instance_descriptors()->GetKey(kPropertyIndex),
isolate->heap()->home_object_symbol());
ReadOnlyRoots(isolate).home_object_symbol());
FieldIndex field_index =
FieldIndex::ForDescriptor(method->map(), kPropertyIndex);
......@@ -287,7 +287,7 @@ bool AddDescriptorsByTemplate(
Handle<NumberDictionary> elements_dictionary =
*elements_dictionary_template ==
isolate->heap()->empty_slow_element_dictionary()
ReadOnlyRoots(isolate).empty_slow_element_dictionary()
? elements_dictionary_template
: ShallowCopyDictionaryTemplate(isolate,
elements_dictionary_template);
......@@ -519,7 +519,7 @@ bool InitClassConstructor(Isolate* isolate,
Handle<NameDictionary>::cast(properties_template);
map->set_is_dictionary_map(true);
map->InitializeDescriptors(isolate->heap()->empty_descriptor_array(),
map->InitializeDescriptors(ReadOnlyRoots(isolate).empty_descriptor_array(),
LayoutDescriptor::FastPointerLayout());
map->set_is_migration_target(false);
map->set_may_have_interesting_symbols(true);
......
......@@ -16,7 +16,7 @@ namespace internal {
RUNTIME_FUNCTION(Runtime_TheHole) {
SealHandleScope shs(isolate);
DCHECK_EQ(0, args.length());
return isolate->heap()->the_hole_value();
return ReadOnlyRoots(isolate).the_hole_value();
}
RUNTIME_FUNCTION(Runtime_SetGrow) {
......@@ -26,7 +26,7 @@ RUNTIME_FUNCTION(Runtime_SetGrow) {
Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()), isolate);
table = OrderedHashSet::EnsureGrowable(isolate, table);
holder->set_table(*table);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -37,7 +37,7 @@ RUNTIME_FUNCTION(Runtime_SetShrink) {
Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()), isolate);
table = OrderedHashSet::Shrink(isolate, table);
holder->set_table(*table);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_SetIteratorClone) {
......@@ -57,7 +57,7 @@ RUNTIME_FUNCTION(Runtime_MapShrink) {
Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()), isolate);
table = OrderedHashMap::Shrink(isolate, table);
holder->set_table(*table);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_MapGrow) {
......@@ -67,7 +67,7 @@ RUNTIME_FUNCTION(Runtime_MapGrow) {
Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()), isolate);
table = OrderedHashMap::EnsureGrowable(isolate, table);
holder->set_table(*table);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_MapIteratorClone) {
......
......@@ -36,7 +36,7 @@ RUNTIME_FUNCTION(Runtime_CompileLazy) {
return isolate->StackOverflow();
}
if (!Compiler::Compile(function, Compiler::KEEP_EXCEPTION)) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
DCHECK(function->is_compiled());
return function->code();
......@@ -51,7 +51,7 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) {
return isolate->StackOverflow();
}
if (!Compiler::CompileOptimized(function, ConcurrencyMode::kConcurrent)) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
DCHECK(function->is_compiled());
return function->code();
......@@ -85,7 +85,7 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized_NotConcurrent) {
return isolate->StackOverflow();
}
if (!Compiler::CompileOptimized(function, ConcurrencyMode::kNotConcurrent)) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
DCHECK(function->is_compiled());
return function->code();
......@@ -173,7 +173,7 @@ RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) {
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,
MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError(
MessageTemplate::kCodeGenFromStrings, error_message);
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
......@@ -320,7 +320,7 @@ static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source,
Compiler::GetFunctionFromEval(source, outer_info, context, language_mode,
restriction, kNoSourcePosition,
eval_scope_position, eval_position),
isolate->heap()->exception());
ReadOnlyRoots(isolate).exception());
return *compiled;
}
......
......@@ -84,7 +84,7 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_DebugBreakOnBytecode) {
operand_scale);
if (side_effect_check_failed) {
return MakePair(isolate->heap()->exception(),
return MakePair(ReadOnlyRoots(isolate).exception(),
Smi::FromInt(static_cast<uint8_t>(bytecode)));
}
Object* interrupt_object = isolate->stack_guard()->HandleInterrupts();
......@@ -110,7 +110,7 @@ RUNTIME_FUNCTION(Runtime_DebugBreakAtEntry) {
DCHECK_EQ(*function, it.frame()->function());
isolate->debug()->Break(it.frame(), function);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) {
......@@ -128,7 +128,7 @@ RUNTIME_FUNCTION(Runtime_ScheduleBreak) {
isolate->RequestInterrupt(
[](v8::Isolate* isolate, void*) { v8::debug::BreakRightNow(isolate); },
nullptr);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
template <class IteratorType>
......@@ -246,7 +246,7 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
result->set(1, *status_str);
Handle<Object> value_obj(promise->status() == Promise::kPending
? isolate->heap()->undefined_value()
? ReadOnlyRoots(isolate).undefined_value()
: promise->result(),
isolate);
Handle<String> promise_value =
......@@ -314,7 +314,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) {
DCHECK_EQ(2, args.length());
if (!args[0]->IsJSGeneratorObject()) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// Check arguments.
......@@ -323,7 +323,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) {
// Only inspect suspended generator scopes.
if (!gen->is_suspended()) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// Find the requested scope.
......@@ -333,7 +333,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) {
n++;
}
if (it.Done()) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
return *it.MaterializeScopeDetails();
......@@ -382,7 +382,7 @@ RUNTIME_FUNCTION(Runtime_GetBreakLocations) {
Handle<Object> break_locations =
Debug::GetSourceBreakLocations(isolate, shared);
if (break_locations->IsUndefined(isolate)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// Return array as JS array
return *isolate->factory()->NewJSArrayWithElements(
......@@ -408,7 +408,7 @@ RUNTIME_FUNCTION(Runtime_ClearStepping) {
DCHECK_EQ(0, args.length());
CHECK(isolate->debug()->is_active());
isolate->debug()->ClearStepping();
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) {
......@@ -420,7 +420,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) {
DebugScope debug_scope(isolate->debug());
if (debug_scope.failed()) {
DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
// Fill the script objects.
instances = isolate->debug()->GetLoadedScripts();
......@@ -451,7 +451,7 @@ RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) {
if (f->IsJSFunction()) {
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) {
DebugScope debug_scope(isolate->debug());
if (debug_scope.failed()) {
DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
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());
return context->global_proxy();
}
......@@ -480,7 +480,7 @@ RUNTIME_FUNCTION(Runtime_CollectGarbage) {
DCHECK_EQ(1, args.length());
isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask,
GarbageCollectionReason::kRuntime);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -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);
}
......@@ -729,10 +729,10 @@ RUNTIME_FUNCTION(Runtime_DebugOnFunctionCall) {
}
if (isolate->debug_execution_mode() == DebugInfo::kSideEffects &&
!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.
......@@ -740,7 +740,7 @@ RUNTIME_FUNCTION(Runtime_DebugPrepareStepInSuspendedGenerator) {
HandleScope scope(isolate);
DCHECK_EQ(0, args.length());
isolate->debug()->PrepareStepInSuspendedGenerator();
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugPushPromise) {
......@@ -748,7 +748,7 @@ RUNTIME_FUNCTION(Runtime_DebugPushPromise) {
HandleScope scope(isolate);
CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
isolate->PushPromise(promise);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -756,7 +756,7 @@ RUNTIME_FUNCTION(Runtime_DebugPopPromise) {
DCHECK_EQ(0, args.length());
SealHandleScope shs(isolate);
isolate->PopPromise();
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugIsActive) {
......@@ -838,7 +838,7 @@ RUNTIME_FUNCTION(Runtime_DebugTogglePreciseCoverage) {
CONVERT_BOOLEAN_ARG_CHECKED(enable, 0);
Coverage::SelectMode(isolate, enable ? debug::Coverage::kPreciseCount
: debug::Coverage::kBestEffort);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugToggleBlockCoverage) {
......@@ -846,7 +846,7 @@ RUNTIME_FUNCTION(Runtime_DebugToggleBlockCoverage) {
CONVERT_BOOLEAN_ARG_CHECKED(enable, 0);
Coverage::SelectMode(isolate, enable ? debug::Coverage::kBlockCount
: debug::Coverage::kBestEffort);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_IncBlockCounter) {
......@@ -866,7 +866,7 @@ RUNTIME_FUNCTION(Runtime_IncBlockCounter) {
coverage_info->IncrementBlockCount(coverage_array_slot_index);
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionSuspended) {
......@@ -874,7 +874,7 @@ RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionSuspended) {
HandleScope scope(isolate);
CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0);
isolate->OnAsyncFunctionStateChanged(promise, debug::kAsyncFunctionSuspended);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionFinished) {
......@@ -887,7 +887,7 @@ RUNTIME_FUNCTION(Runtime_DebugAsyncFunctionFinished) {
isolate->OnAsyncFunctionStateChanged(promise,
debug::kAsyncFunctionFinished);
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_LiveEditPatchScript) {
......@@ -924,9 +924,9 @@ RUNTIME_FUNCTION(Runtime_LiveEditPatchScript) {
return isolate->Throw(*isolate->factory()->NewStringFromAsciiChecked(
"LiveEdit failed: FRAME_RESTART_IS_NOT_SUPPORTED"));
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 v8
......@@ -40,7 +40,7 @@ RUNTIME_FUNCTION(Runtime_FunctionGetScript) {
return *Script::GetWrapper(Handle<Script>::cast(script));
}
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_FunctionGetScriptId) {
......@@ -67,7 +67,7 @@ RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) {
Handle<JSFunction>::cast(function)->shared(), isolate);
return *SharedFunctionInfo::GetSourceCode(shared);
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -102,7 +102,7 @@ RUNTIME_FUNCTION(Runtime_SetCode) {
if (!source->is_compiled() &&
!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
......@@ -163,7 +163,7 @@ RUNTIME_FUNCTION(Runtime_SetNativeFlag) {
JSFunction* func = JSFunction::cast(object);
func->shared()->set_native(true);
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......
......@@ -39,7 +39,7 @@ RUNTIME_FUNCTION(Runtime_SetAllowAtomicsWait) {
CONVERT_BOOLEAN_ARG_CHECKED(set, 0);
isolate->set_allow_atomics_wait(set);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
} // namespace internal
} // namespace v8
......@@ -96,7 +96,7 @@ RUNTIME_FUNCTION(Runtime_AsyncGeneratorHasCatchHandlerForPC) {
// 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
// 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();
DCHECK(shared->HasBytecodeArray());
......
......@@ -27,7 +27,7 @@ RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) {
SealHandleScope shs(isolate);
DCHECK_EQ(0, args.length());
CHECK(isolate->bootstrapper()->IsActive());
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_ExportFromRuntime) {
......@@ -63,7 +63,7 @@ RUNTIME_FUNCTION(Runtime_InstallToContext) {
CHECK_NE(index, Context::kNotFound);
native_context->set(index, *object);
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_Throw) {
......@@ -297,7 +297,7 @@ RUNTIME_FUNCTION(Runtime_AllocateSeqOneByteString) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
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;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, isolate->factory()->NewRawOneByteString(length));
......@@ -308,7 +308,7 @@ RUNTIME_FUNCTION(Runtime_AllocateSeqTwoByteString) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
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;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, isolate->factory()->NewRawTwoByteString(length));
......@@ -471,7 +471,7 @@ RUNTIME_FUNCTION(Runtime_IncrementUseCounter) {
DCHECK_EQ(1, args.length());
CONVERT_SMI_ARG_CHECKED(counter, 0);
isolate->CountUsage(static_cast<v8::Isolate::UseCounterFeature>(counter));
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_GetAndResetRuntimeCallStats) {
......@@ -516,7 +516,7 @@ RUNTIME_FUNCTION(Runtime_GetAndResetRuntimeCallStats) {
std::fclose(f);
else
std::fflush(f);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
}
......@@ -587,7 +587,7 @@ RUNTIME_FUNCTION(Runtime_ReportMessage) {
isolate->set_pending_exception(*message_obj);
isolate->ReportPendingMessagesFromJavaScript();
isolate->clear_pending_exception();
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
} // namespace internal
......
......@@ -118,7 +118,7 @@ void PrintRegisters(Isolate* isolate, std::ostream& os, bool is_input,
RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeEntry) {
if (!FLAG_trace_ignition) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
SealHandleScope shs(isolate);
......@@ -147,12 +147,12 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeEntry) {
os << std::flush;
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) {
if (!FLAG_trace_ignition) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
SealHandleScope shs(isolate);
......@@ -175,7 +175,7 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) {
PrintRegisters(isolate, os, false, bytecode_iterator, accumulator);
os << std::flush;
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
#endif
......@@ -184,7 +184,7 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) {
RUNTIME_FUNCTION(Runtime_InterpreterTraceUpdateFeedback) {
if (!FLAG_trace_feedback_updates) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
SealHandleScope shs(isolate);
......@@ -210,7 +210,7 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceUpdateFeedback) {
os << "]" << std::endl;
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
#endif
......
......@@ -204,7 +204,7 @@ RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) {
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
JSObject::SetProperty(input, marker, type, LanguageMode::kStrict).Assert();
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) {
......@@ -536,7 +536,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) {
break_iterator->setText(*u_text);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) {
......@@ -600,7 +600,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) {
if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {
return *isolate->factory()->NewStringFromStaticChars("none");
} 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) {
return *isolate->factory()->NewStringFromStaticChars("letter");
} else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) {
......@@ -674,7 +674,8 @@ RUNTIME_FUNCTION(Runtime_StringLocaleConvertCase) {
RUNTIME_FUNCTION(Runtime_DateCacheVersion) {
HandleScope scope(isolate);
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)) {
Handle<FixedArray> date_cache_version =
isolate->factory()->NewFixedArray(1, TENURED);
......
......@@ -155,7 +155,7 @@ MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
case PACKED_ELEMENTS:
case HOLEY_ELEMENTS: {
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
for (int i = 0; i < elements->length(); i++) {
DCHECK(!elements->get(i)->IsJSObject());
......@@ -412,7 +412,7 @@ struct ArrayBoilerplate {
} else {
DCHECK(IsSmiOrObjectElementsKind(constant_elements_kind));
const bool is_cow = (constant_elements_values->map() ==
isolate->heap()->fixed_cow_array_map());
ReadOnlyRoots(isolate).fixed_cow_array_map());
if (is_cow) {
copied_elements_values = constant_elements_values;
#if DEBUG
......
......@@ -95,7 +95,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) {
Handle<Script> script_handle = Handle<Script>::cast(old_script);
return *Script::GetWrapper(script_handle);
} else {
return isolate->heap()->null_value();
return ReadOnlyRoots(isolate).null_value();
}
}
......@@ -111,7 +111,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFixupScript) {
Handle<Script> script(Script::cast(script_value->value()), isolate);
LiveEdit::FixupScript(isolate, script, max_function_literal_id);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) {
......@@ -122,7 +122,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) {
CHECK(SharedInfoWrapper::IsInstance(shared_info));
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) {
CHECK(SharedInfoWrapper::IsInstance(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) {
// 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) {
LiveEdit::ReplaceRefToNestedFunction(isolate->heap(), parent_wrapper,
orig_wrapper, subst_wrapper);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -196,7 +196,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditPatchFunctionPositions) {
CHECK(SharedInfoWrapper::IsInstance(shared_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) {
}
int radix32 = DoubleToInt32(radix->Number());
if (radix32 != 0 && (radix32 < 2 || radix32 > 36)) {
return isolate->heap()->nan_value();
return ReadOnlyRoots(isolate).nan_value();
}
double result = StringToInt(isolate, subject, radix32);
......
......@@ -22,7 +22,7 @@ MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
Handle<Object> key,
bool* is_found_out) {
if (object->IsNullOrUndefined(isolate)) {
if (*key == isolate->heap()->iterator_symbol()) {
if (*key == ReadOnlyRoots(isolate).iterator_symbol()) {
return Runtime::ThrowIteratorError(isolate, object);
}
THROW_NEW_ERROR(
......@@ -180,9 +180,9 @@ bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver,
if (!index.is_inobject() && index.outobject_array_index() == 0) {
DCHECK(!Map::cast(backpointer)->HasOutOfObjectProperties());
// Clear out the properties backing store.
receiver->SetProperties(isolate->heap()->empty_fixed_array());
receiver->SetProperties(ReadOnlyRoots(isolate).empty_fixed_array());
} else {
Object* filler = isolate->heap()->one_pointer_filler_map();
Object* filler = ReadOnlyRoots(isolate).one_pointer_filler_map();
JSObject::cast(*receiver)->RawFastPropertyAtPut(index, filler);
// We must clear any recorded slot for the deleted property, because
// subsequent object modifications might put a raw double there.
......@@ -315,12 +315,12 @@ RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
if (key.is_null()) {
DCHECK(key_is_array_index);
// Namespace objects can't have indexed properties.
return isolate->heap()->false_value();
return ReadOnlyRoots(isolate).false_value();
}
Maybe<bool> result =
JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(object), key);
if (!result.IsJust()) return isolate->heap()->exception();
if (!result.IsJust()) return ReadOnlyRoots(isolate).exception();
return isolate->heap()->ToBoolean(result.FromJust());
} else if (object->IsJSObject()) {
......@@ -336,16 +336,16 @@ RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
key_is_array_index ? LookupIterator(isolate, js_obj, index, js_obj, c)
: LookupIterator(js_obj, key, js_obj, c);
Maybe<bool> maybe = JSReceiver::HasProperty(&it);
if (maybe.IsNothing()) return isolate->heap()->exception();
if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
DCHECK(!isolate->has_pending_exception());
if (maybe.FromJust()) return isolate->heap()->true_value();
if (maybe.FromJust()) return ReadOnlyRoots(isolate).true_value();
}
Map* map = js_obj->map();
if (!map->has_hidden_prototype() &&
(key_is_array_index ? !map->has_indexed_interceptor()
: !map->has_named_interceptor())) {
return isolate->heap()->false_value();
return ReadOnlyRoots(isolate).false_value();
}
// Slow case.
......@@ -355,7 +355,7 @@ RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
: LookupIterator(js_obj, key, js_obj, c);
Maybe<bool> maybe = JSReceiver::HasProperty(&it);
if (maybe.IsNothing()) return isolate->heap()->exception();
if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
DCHECK(!isolate->has_pending_exception());
return isolate->heap()->ToBoolean(maybe.FromJust());
......@@ -367,20 +367,20 @@ RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
Maybe<bool> result =
JSReceiver::HasOwnProperty(Handle<JSProxy>::cast(object), key);
if (result.IsNothing()) return isolate->heap()->exception();
if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
return isolate->heap()->ToBoolean(result.FromJust());
} else if (object->IsString()) {
return isolate->heap()->ToBoolean(
key_is_array_index
? index < static_cast<uint32_t>(String::cast(*object)->length())
: key->Equals(isolate->heap()->length_string()));
: key->Equals(ReadOnlyRoots(isolate).length_string()));
} else if (object->IsNullOrUndefined(isolate)) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject));
}
return isolate->heap()->false_value();
return ReadOnlyRoots(isolate).false_value();
}
RUNTIME_FUNCTION(Runtime_AddDictionaryProperty) {
......@@ -485,13 +485,13 @@ RUNTIME_FUNCTION(Runtime_InternalSetPrototype) {
Handle<Map> function_map(function->map(), isolate);
if (!JSFunction::SetName(function, isolate->factory()->proto_string(),
isolate->factory()->empty_string())) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
CHECK_EQ(*function_map, function->map());
}
}
MAYBE_RETURN(JSReceiver::SetPrototype(obj, prototype, false, kThrowOnError),
isolate->heap()->exception());
ReadOnlyRoots(isolate).exception());
return *obj;
}
......@@ -602,7 +602,7 @@ RUNTIME_FUNCTION(Runtime_AddNamedProperty) {
DCHECK(!name->ToArrayIndex(&index));
LookupIterator it(object, name, object, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (maybe.IsNothing()) return isolate->heap()->exception();
if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
DCHECK(!it.IsFound());
#endif
......@@ -628,7 +628,7 @@ RUNTIME_FUNCTION(Runtime_AddElement) {
LookupIterator it(isolate, object, index, object,
LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (maybe.IsNothing()) return isolate->heap()->exception();
if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
DCHECK(!it.IsFound());
if (object->IsJSArray()) {
......@@ -667,7 +667,7 @@ Object* DeleteProperty(Isolate* isolate, Handle<Object> object,
Object::ToObject(isolate, object));
Maybe<bool> result =
Runtime::DeleteObjectProperty(isolate, receiver, key, language_mode);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return isolate->heap()->ToBoolean(result.FromJust());
}
......@@ -715,7 +715,7 @@ RUNTIME_FUNCTION(Runtime_HasProperty) {
// Lookup the {name} on {receiver}.
Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name);
if (maybe.IsNothing()) return isolate->heap()->exception();
if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
return isolate->heap()->ToBoolean(maybe.FromJust());
}
......@@ -772,7 +772,7 @@ RUNTIME_FUNCTION(Runtime_CompleteInobjectSlackTrackingForMap) {
CONVERT_ARG_HANDLE_CHECKED(Map, initial_map, 0);
initial_map->CompleteInobjectSlackTracking(isolate);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -818,7 +818,7 @@ RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) {
RETURN_FAILURE_ON_EXCEPTION(
isolate, JSObject::DefineAccessor(obj, name, getter, setter, attrs));
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -861,7 +861,7 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) {
Handle<Map> function_map(function->map(), isolate);
if (!JSFunction::SetName(function, name,
isolate->factory()->empty_string())) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
// Class constructors do not reserve in-object space for name field.
CHECK_IMPLIES(!IsClassConstructor(function->shared()->kind()),
......@@ -892,14 +892,14 @@ RUNTIME_FUNCTION(Runtime_CollectTypeProfile) {
} else if (value->IsNull(isolate)) {
// typeof(null) is object. But it's more user-friendly to annotate
// null as type "null".
type = Handle<String>(isolate->heap()->null_string(), isolate);
type = Handle<String>(ReadOnlyRoots(isolate).null_string(), isolate);
}
DCHECK(vector->metadata()->HasTypeProfileSlot());
FeedbackNexus nexus(vector, vector->GetTypeProfileSlot());
nexus.Collect(type, position->value());
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_HasFastPackedElements) {
......@@ -932,7 +932,7 @@ RUNTIME_FUNCTION(Runtime_ClassOf) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_CHECKED(Object, obj, 0);
if (!obj->IsJSReceiver()) return isolate->heap()->null_value();
if (!obj->IsJSReceiver()) return ReadOnlyRoots(isolate).null_value();
return JSReceiver::cast(obj)->class_name();
}
......@@ -954,7 +954,7 @@ RUNTIME_FUNCTION(Runtime_DefineGetterPropertyUnchecked) {
if (String::cast(getter->shared()->Name())->length() == 0) {
Handle<Map> getter_map(getter->map(), isolate);
if (!JSFunction::SetName(getter, name, isolate->factory()->get_string())) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
CHECK_EQ(*getter_map, getter->map());
}
......@@ -963,7 +963,7 @@ RUNTIME_FUNCTION(Runtime_DefineGetterPropertyUnchecked) {
isolate,
JSObject::DefineAccessor(object, name, getter,
isolate->factory()->null_value(), attrs));
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_SetDataProperties) {
......@@ -974,12 +974,12 @@ RUNTIME_FUNCTION(Runtime_SetDataProperties) {
// 2. If source is undefined or null, let keys be an empty List.
if (source->IsUndefined(isolate) || source->IsNull(isolate)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source),
isolate->heap()->exception());
return isolate->heap()->undefined_value();
ReadOnlyRoots(isolate).exception());
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_CopyDataProperties) {
......@@ -990,13 +990,13 @@ RUNTIME_FUNCTION(Runtime_CopyDataProperties) {
// 2. If source is undefined or null, let keys be an empty List.
if (source->IsUndefined(isolate) || source->IsNull(isolate)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source,
nullptr, false),
isolate->heap()->exception());
return isolate->heap()->undefined_value();
ReadOnlyRoots(isolate).exception());
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) {
......@@ -1006,7 +1006,7 @@ RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) {
// 2. If source is undefined or null, let keys be an empty List.
if (source->IsUndefined(isolate) || source->IsNull(isolate)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
ScopedVector<Handle<Object>> excluded_properties(args.length() - 1);
......@@ -1029,7 +1029,7 @@ RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) {
isolate->factory()->NewJSObject(isolate->object_function());
MAYBE_RETURN(JSReceiver::SetOrCopyDataProperties(isolate, target, source,
&excluded_properties, false),
isolate->heap()->exception());
ReadOnlyRoots(isolate).exception());
return *target;
}
......@@ -1071,7 +1071,7 @@ RUNTIME_FUNCTION(Runtime_DefineMethodsInternal) {
for (int i = 0; i < keys->length(); ++i) {
Handle<Name> key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate));
if (*key == isolate->heap()->constructor_string()) continue;
if (*key == ReadOnlyRoots(isolate).constructor_string()) continue;
PropertyDescriptor descriptor;
Maybe<bool> did_get_descriptor =
......@@ -1088,7 +1088,7 @@ RUNTIME_FUNCTION(Runtime_DefineMethodsInternal) {
isolate, target, key, &descriptor, kDontThrow);
CHECK(success.FromJust());
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) {
......@@ -1102,7 +1102,7 @@ RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) {
if (String::cast(setter->shared()->Name())->length() == 0) {
Handle<Map> setter_map(setter->map(), isolate);
if (!JSFunction::SetName(setter, name, isolate->factory()->set_string())) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
CHECK_EQ(*setter_map, setter->map());
}
......@@ -1111,7 +1111,7 @@ RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) {
isolate,
JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
setter, attrs));
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_ToObject) {
......@@ -1204,10 +1204,10 @@ RUNTIME_FUNCTION(Runtime_HasInPrototypeChain) {
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
if (!object->IsJSReceiver()) return isolate->heap()->false_value();
if (!object->IsJSReceiver()) return ReadOnlyRoots(isolate).false_value();
Maybe<bool> result = JSReceiver::HasInPrototypeChain(
isolate, Handle<JSReceiver>::cast(object), prototype);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return isolate->heap()->ToBoolean(result.FromJust());
}
......@@ -1231,9 +1231,9 @@ RUNTIME_FUNCTION(Runtime_CreateDataProperty) {
bool success;
LookupIterator it = LookupIterator::PropertyOrElement(
isolate, o, key, &success, LookupIterator::OWN);
if (!success) return isolate->heap()->exception();
if (!success) return ReadOnlyRoots(isolate).exception();
MAYBE_RETURN(JSReceiver::CreateDataProperty(&it, value, kThrowOnError),
isolate->heap()->exception());
ReadOnlyRoots(isolate).exception());
return *value;
}
......@@ -1268,9 +1268,9 @@ RUNTIME_FUNCTION(Runtime_GetOwnPropertyDescriptor) {
PropertyDescriptor desc;
Maybe<bool> found =
JSReceiver::GetOwnPropertyDescriptor(isolate, object, name, &desc);
MAYBE_RETURN(found, isolate->heap()->exception());
MAYBE_RETURN(found, ReadOnlyRoots(isolate).exception());
if (!found.FromJust()) return isolate->heap()->undefined_value();
if (!found.FromJust()) return ReadOnlyRoots(isolate).undefined_value();
return *desc.ToPropertyDescriptorObject(isolate);
}
......@@ -1293,7 +1293,7 @@ RUNTIME_FUNCTION(Runtime_AddPrivateField) {
CHECK(Object::AddDataProperty(&it, value, NONE, kDontThrow,
Object::MAY_BE_STORE_FROM_KEYED)
.FromJust());
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
} // namespace internal
......
......@@ -24,7 +24,7 @@ RUNTIME_FUNCTION(Runtime_Equal) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
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());
}
......@@ -34,7 +34,7 @@ RUNTIME_FUNCTION(Runtime_NotEqual) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
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());
}
......@@ -60,7 +60,7 @@ RUNTIME_FUNCTION(Runtime_LessThan) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
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());
}
......@@ -70,7 +70,7 @@ RUNTIME_FUNCTION(Runtime_GreaterThan) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
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());
}
......@@ -80,7 +80,7 @@ RUNTIME_FUNCTION(Runtime_LessThanOrEqual) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
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());
}
......@@ -90,7 +90,7 @@ RUNTIME_FUNCTION(Runtime_GreaterThanOrEqual) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
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());
}
......
......@@ -36,7 +36,7 @@ RUNTIME_FUNCTION(Runtime_PromiseRejectEventFromStack) {
isolate->ReportPromiseReject(promise, value,
v8::kPromiseRejectWithNoHandler);
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) {
......@@ -47,7 +47,7 @@ RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) {
CHECK(!promise->has_handler());
isolate->ReportPromiseReject(promise, Handle<Object>(),
v8::kPromiseHandlerAddedAfterReject);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) {
......@@ -57,14 +57,14 @@ RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) {
Handle<CallableTask> microtask =
isolate->factory()->NewCallableTask(function, isolate->native_context());
isolate->EnqueueMicrotask(microtask);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_RunMicrotasks) {
HandleScope scope(isolate);
DCHECK_EQ(0, args.length());
isolate->RunMicrotasks();
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_RunMicrotaskCallback) {
......@@ -76,7 +76,7 @@ RUNTIME_FUNCTION(Runtime_RunMicrotaskCallback) {
void* data = ToCData<void*>(microtask_data);
callback(data);
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_PromiseStatus) {
......@@ -100,7 +100,7 @@ RUNTIME_FUNCTION(Runtime_PromiseMarkAsHandled) {
CONVERT_ARG_CHECKED(JSPromise, promise, 0);
promise->set_has_handler(true);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_PromiseHookInit) {
......@@ -109,7 +109,7 @@ RUNTIME_FUNCTION(Runtime_PromiseHookInit) {
CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, parent, 1);
isolate->RunPromiseHook(PromiseHookType::kInit, promise, parent);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_AwaitPromisesInit) {
......@@ -126,35 +126,37 @@ RUNTIME_FUNCTION(Runtime_AwaitPromisesInit) {
// async_task_id as outer_promise since we generate WillHandle and DidHandle
// events using throwaway promise.
throwaway->set_async_task_id(outer_promise->async_task_id());
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_PromiseHookBefore) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
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);
if (isolate->debug()->is_active()) isolate->PushPromise(promise);
if (promise->IsJSPromise()) {
isolate->RunPromiseHook(PromiseHookType::kBefore, promise,
isolate->factory()->undefined_value());
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_PromiseHookAfter) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
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);
if (isolate->debug()->is_active()) isolate->PopPromise();
if (promise->IsJSPromise()) {
isolate->RunPromiseHook(PromiseHookType::kAfter, promise,
isolate->factory()->undefined_value());
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_RejectPromise) {
......
......@@ -51,7 +51,7 @@ RUNTIME_FUNCTION(Runtime_GetPropertyWithReceiver) {
&success, holder);
if (!success) {
DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
RETURN_RESULT_OR_FAILURE(isolate, Object::GetProperty(&it));
}
......@@ -71,11 +71,11 @@ RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) {
&success, holder);
if (!success) {
DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
Maybe<bool> result = Object::SetSuperProperty(
&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());
}
......@@ -101,7 +101,7 @@ RUNTIME_FUNCTION(Runtime_CheckProxyHasTrap) {
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 1);
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());
}
......
......@@ -557,7 +557,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
result_len = static_cast<int>(result_len_64);
}
if (result_len == 0) {
return isolate->heap()->empty_string();
return ReadOnlyRoots(isolate).empty_string();
}
int subject_pos = 0;
......@@ -619,7 +619,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString(
// Ensure the RegExp is compiled so we can access the capture-name map.
if (RegExpImpl::IrregexpPrepare(isolate, regexp, subject) == -1) {
DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
}
......@@ -641,11 +641,11 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString(
}
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();
if (current_match == nullptr) {
if (global_cache.HasException()) return isolate->heap()->exception();
if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
return *subject;
}
......@@ -682,7 +682,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString(
current_match = global_cache.FetchNext();
} while (current_match != nullptr);
if (global_cache.HasException()) return isolate->heap()->exception();
if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
if (prev < subject_length) {
builder.EnsureCapacity(2);
......@@ -714,11 +714,11 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
}
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();
if (current_match == nullptr) {
if (global_cache.HasException()) return isolate->heap()->exception();
if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
return *subject;
}
......@@ -728,7 +728,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
int subject_length = subject->length();
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;
if (ResultSeqString::kHasOneByteEncoding) {
......@@ -755,7 +755,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
current_match = global_cache.FetchNext();
} 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,
global_cache.LastSuccessfulMatch());
......@@ -767,7 +767,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
position += subject_length - prev;
}
if (position == 0) return isolate->heap()->empty_string();
if (position == 0) return ReadOnlyRoots(isolate).empty_string();
// Shorten string and fill
int string_size = ResultSeqString::SizeFor(position);
......@@ -1164,7 +1164,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
}
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.
DCHECK(result_array->HasObjectElements());
......@@ -1232,7 +1232,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
elements->set(cursor++, *substring);
} else {
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,
}
}
if (global_cache.HasException()) return isolate->heap()->exception();
if (global_cache.HasException()) return ReadOnlyRoots(isolate).exception();
if (match_start >= 0) {
// Finished matching, with at least one match.
......@@ -1290,7 +1290,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
}
return *builder.ToJSArray(result_array);
} 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(
}
LookupIterator it(global, name, global, lookup_config);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (maybe.IsNothing()) return isolate->heap()->exception();
if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
if (it.IsFound()) {
PropertyAttributes old_attributes = maybe.FromJust();
// The name was declared before; check for conflicting 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);
if ((old_attributes & DONT_DELETE) != 0) {
......@@ -128,7 +128,7 @@ Object* DeclareGlobal(
nexus.ConfigurePropertyCellMode(it.GetPropertyCell());
}
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
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;
});
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
} // namespace
......@@ -275,13 +275,13 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
DCHECK_EQ(NONE, attributes);
// Skip var re-declarations.
if (is_var) return isolate->heap()->undefined_value();
if (is_var) return ReadOnlyRoots(isolate).undefined_value();
DCHECK(is_function);
if (index != Context::kNotFound) {
DCHECK(holder.is_identical_to(context));
context->set(index, *value);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
object = Handle<JSObject>::cast(holder);
......@@ -305,7 +305,7 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
object, name, value, NONE));
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
} // namespace
......@@ -407,7 +407,8 @@ Handle<JSObject> NewSloppyArguments(Isolate* isolate, Handle<JSFunction> callee,
int mapped_count = Min(argument_count, parameter_count);
Handle<FixedArray> parameter_map =
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_elements(*parameter_map);
......@@ -647,7 +648,7 @@ static Object* FindNameClash(Isolate* isolate, Handle<ScopeInfo> scope_info,
LookupIterator it(global_object, name, global_object,
LookupIterator::OWN_SKIP_INTERCEPTOR);
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) {
// ES#sec-globaldeclarationinstantiation 5.a:
// If envRec.HasVarDeclaration(name) is true, throw a SyntaxError
......@@ -661,7 +662,7 @@ static Object* FindNameClash(Isolate* isolate, Handle<ScopeInfo> scope_info,
JSGlobalObject::InvalidatePropertyCell(global_object, name);
}
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -768,14 +769,15 @@ RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) {
// If the slot was not found the result is true.
if (holder.is_null()) {
// In case of JSProxy, an exception might have been thrown.
if (isolate->has_pending_exception()) return isolate->heap()->exception();
return isolate->heap()->true_value();
if (isolate->has_pending_exception())
return ReadOnlyRoots(isolate).exception();
return ReadOnlyRoots(isolate).true_value();
}
// If the slot was found in a context or in module imports and exports it
// should be DONT_DELETE.
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,
......@@ -783,7 +785,7 @@ RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) {
// (respecting DONT_DELETE).
Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder);
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());
}
......@@ -880,7 +882,7 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadLookupSlotForCall) {
Handle<Object> receiver;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, value, LoadLookupSlot(isolate, name, kThrowOnError, &receiver),
MakePair(isolate->heap()->exception(), nullptr));
MakePair(ReadOnlyRoots(isolate).exception(), nullptr));
return MakePair(*value, *receiver);
}
......
......@@ -123,14 +123,16 @@ RUNTIME_FUNCTION(Runtime_StringReplaceOneCharWithString) {
kRecursionLimit).ToHandle(&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);
if (StringReplaceOneCharWithString(isolate, subject, search, replace, &found,
kRecursionLimit).ToHandle(&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.
return isolate->StackOverflow();
}
......@@ -166,7 +168,7 @@ RUNTIME_FUNCTION(Runtime_StringIncludes) {
Maybe<bool> is_reg_exp = RegExpUtils::IsRegExp(isolate, search);
if (is_reg_exp.IsNothing()) {
DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
if (is_reg_exp.FromJust()) {
THROW_NEW_ERROR_RETURN_FAILURE(
......@@ -260,7 +262,7 @@ RUNTIME_FUNCTION(Runtime_StringCharCodeAt) {
subject = String::Flatten(isolate, subject);
if (i >= static_cast<uint32_t>(subject->length())) {
return isolate->heap()->nan_value();
return ReadOnlyRoots(isolate).nan_value();
}
return Smi::FromInt(subject->Get(i));
......@@ -289,7 +291,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
int special_length = special->length();
if (!array->HasObjectElements()) {
return isolate->Throw(isolate->heap()->illegal_argument_string());
return isolate->Throw(ReadOnlyRoots(isolate).illegal_argument_string());
}
int length;
......@@ -303,7 +305,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
}
if (array_length == 0) {
return isolate->heap()->empty_string();
return ReadOnlyRoots(isolate).empty_string();
} else if (array_length == 1) {
Object* first = fixed_array->get(0);
if (first->IsString()) return first;
......@@ -313,10 +315,10 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
}
if (length == -1) {
return isolate->Throw(isolate->heap()->illegal_argument_string());
return isolate->Throw(ReadOnlyRoots(isolate).illegal_argument_string());
}
if (length == 0) {
return isolate->heap()->empty_string();
return ReadOnlyRoots(isolate).empty_string();
}
if (one_byte) {
......@@ -356,7 +358,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderJoin) {
}
if (array_length == 0) {
return isolate->heap()->empty_string();
return ReadOnlyRoots(isolate).empty_string();
} else if (array_length == 1) {
Object* first = fixed_array->get(0);
CHECK(first->IsString());
......@@ -570,7 +572,7 @@ static int CopyCachedOneByteCharsToArray(Heap* heap, const uint8_t* chars,
FixedArray* elements, int length) {
DisallowHeapAllocation no_gc;
FixedArray* one_byte_cache = heap->single_character_string_cache();
Object* undefined = heap->undefined_value();
Object* undefined = ReadOnlyRoots(heap).undefined_value();
int i;
WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc);
for (i = 0; i < length; ++i) {
......@@ -618,8 +620,8 @@ RUNTIME_FUNCTION(Runtime_StringToArray) {
position = CopyCachedOneByteCharsToArray(isolate->heap(), chars.start(),
*elements, length);
} else {
MemsetPointer(elements->data_start(), isolate->heap()->undefined_value(),
length);
MemsetPointer(elements->data_start(),
ReadOnlyRoots(isolate).undefined_value(), length);
}
} else {
elements = isolate->factory()->NewFixedArray(length);
......@@ -714,7 +716,7 @@ RUNTIME_FUNCTION(Runtime_StringCharFromCode) {
code &= 0xFFFF;
return *isolate->factory()->LookupSingleCharacterStringFromCode(code);
}
return isolate->heap()->empty_string();
return ReadOnlyRoots(isolate).empty_string();
}
RUNTIME_FUNCTION(Runtime_StringMaxLength) {
......
......@@ -140,16 +140,16 @@ RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) {
// Ignore calls on non-function objects to avoid runtime errors.
CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
if (!function_object->IsJSFunction()) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
// If the function is not optimized, just return.
if (!function->IsOptimized()) return isolate->heap()->undefined_value();
if (!function->IsOptimized()) return ReadOnlyRoots(isolate).undefined_value();
Deoptimizer::DeoptimizeFunction(*function);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -162,14 +162,14 @@ RUNTIME_FUNCTION(Runtime_DeoptimizeNow) {
// Find the JavaScript function on the top of the stack.
JavaScriptFrameIterator it(isolate);
if (!it.done()) function = handle(it.frame()->function(), isolate);
if (function.is_null()) return isolate->heap()->undefined_value();
if (function.is_null()) return ReadOnlyRoots(isolate).undefined_value();
// If the function is not optimized, just return.
if (!function->IsOptimized()) return isolate->heap()->undefined_value();
if (!function->IsOptimized()) return ReadOnlyRoots(isolate).undefined_value();
Deoptimizer::DeoptimizeFunction(*function);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -177,9 +177,9 @@ RUNTIME_FUNCTION(Runtime_RunningInSimulator) {
SealHandleScope shs(isolate);
DCHECK_EQ(0, args.length());
#if defined(USE_SIMULATOR)
return isolate->heap()->true_value();
return ReadOnlyRoots(isolate).true_value();
#else
return isolate->heap()->false_value();
return ReadOnlyRoots(isolate).false_value();
#endif
}
......@@ -196,14 +196,14 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
// This function is used by fuzzers, ignore calls with bogus arguments count.
if (args.length() != 1 && args.length() != 2) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// This function is used by fuzzers to get coverage for optimizations
// in compiler. Ignore calls on non-function objects to avoid runtime errors.
CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
if (!function_object->IsJSFunction()) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
......@@ -211,24 +211,24 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
// JSFunction::MarkForOptimization().
if (!function->shared()->allows_lazy_compilation()) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// If function isn't compiled, compile it now.
if (!function->shared()->is_compiled() &&
!Compiler::Compile(function, Compiler::CLEAR_EXCEPTION)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// If the function is already optimized, just return.
if (function->IsOptimized() || function->shared()->HasAsmWasmData()) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// If the function has optimized code, ensure that we check for it and return.
if (function->HasOptimizedCode()) {
DCHECK(function->ChecksOptimizationMarker());
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
ConcurrencyMode concurrency_mode = ConcurrencyMode::kNotConcurrent;
......@@ -257,7 +257,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
JSFunction::EnsureFeedbackVector(function);
function->MarkForOptimization(concurrency_mode);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
......@@ -273,10 +273,10 @@ RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
JavaScriptFrameIterator it(isolate);
while (!it.done() && stack_depth--) it.Advance();
if (!it.done()) function = handle(it.frame()->function(), isolate);
if (function.is_null()) return isolate->heap()->undefined_value();
if (function.is_null()) return ReadOnlyRoots(isolate).undefined_value();
// If the function is already optimized, just return.
if (function->IsOptimized()) return isolate->heap()->undefined_value();
if (function->IsOptimized()) return ReadOnlyRoots(isolate).undefined_value();
// Ensure that the function is marked for non-concurrent optimization, so that
// subsequent runs don't also optimize.
......@@ -295,7 +295,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
it.frame(), AbstractCode::kMaxLoopNestingMarker);
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -306,12 +306,12 @@ RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) {
// in compiler. Ignore calls on non-function objects to avoid runtime errors.
CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
if (!function_object->IsJSFunction()) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
function->shared()->DisableOptimization(
BailoutReason::kOptimizationDisabledForTest);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) {
......@@ -340,7 +340,8 @@ RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) {
bool sync_with_compiler_thread = true;
if (args.length() == 2) {
CONVERT_ARG_HANDLE_CHECKED(Object, sync_object, 1);
if (!sync_object->IsString()) return isolate->heap()->undefined_value();
if (!sync_object->IsString())
return ReadOnlyRoots(isolate).undefined_value();
Handle<String> sync = Handle<String>::cast(sync_object);
if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) {
sync_with_compiler_thread = false;
......@@ -402,7 +403,7 @@ RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) {
isolate->concurrent_recompilation_enabled()) {
isolate->optimizing_compile_dispatcher()->Unblock();
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_GetDeoptCount) {
......@@ -467,7 +468,7 @@ RUNTIME_FUNCTION(Runtime_ClearFunctionFeedback) {
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
function->ClearTypeFeedbackInfo();
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_SetWasmCompileControls) {
......@@ -480,7 +481,7 @@ RUNTIME_FUNCTION(Runtime_SetWasmCompileControls) {
ctrl.AllowAnySizeForAsync = allow_async;
ctrl.MaxWasmBufferSize = static_cast<uint32_t>(block_size->value());
v8_isolate->SetWasmModuleCallback(WasmModuleOverride);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_SetWasmInstantiateControls) {
......@@ -488,14 +489,14 @@ RUNTIME_FUNCTION(Runtime_SetWasmInstantiateControls) {
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
CHECK_EQ(args.length(), 0);
v8_isolate->SetWasmInstanceCallback(WasmInstanceOverride);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) {
HandleScope scope(isolate);
DCHECK_EQ(0, args.length());
isolate->heap()->NotifyContextDisposed(true);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -519,7 +520,7 @@ RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) {
}
}
#endif
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -596,14 +597,14 @@ RUNTIME_FUNCTION(Runtime_PrintWithNameForAssert) {
args[1]->ShortPrint();
PrintF("\n");
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugTrace) {
SealHandleScope shs(isolate);
DCHECK_EQ(0, args.length());
isolate->PrintStack(stdout);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_DebugTrackRetainingPath) {
......@@ -628,7 +629,7 @@ RUNTIME_FUNCTION(Runtime_DebugTrackRetainingPath) {
}
isolate->heap()->AddRetainingPathTarget(object, option);
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// This will not allocate (flatten the string), but it may run
......@@ -653,7 +654,7 @@ RUNTIME_FUNCTION(Runtime_SystemBreak) {
HandleScope scope(isolate);
DCHECK_EQ(0, args.length());
base::OS::DebugBreak();
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -665,7 +666,7 @@ RUNTIME_FUNCTION(Runtime_SetFlags) {
std::unique_ptr<char[]> flags =
arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get()));
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_SetForceSlowPath) {
......@@ -678,7 +679,7 @@ RUNTIME_FUNCTION(Runtime_SetForceSlowPath) {
DCHECK(arg->IsFalse(isolate));
isolate->set_force_slow_path(false);
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_Abort) {
......@@ -722,13 +723,13 @@ RUNTIME_FUNCTION(Runtime_DisassembleFunction) {
CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
if (!func->is_compiled() &&
!Compiler::Compile(func, Compiler::KEEP_EXCEPTION)) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
StdoutStream os;
func->code()->Print(isolate, os);
os << std::endl;
#endif // DEBUG
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
namespace {
......@@ -757,7 +758,7 @@ RUNTIME_FUNCTION(Runtime_TraceEnter) {
PrintIndentation(isolate);
JavaScriptFrame::PrintTop(isolate, stdout, true, false);
PrintF(" {\n");
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
......@@ -794,14 +795,14 @@ RUNTIME_FUNCTION(Runtime_IsAsmWasmCode) {
CONVERT_ARG_CHECKED(JSFunction, function, 0);
if (!function->shared()->HasAsmWasmData()) {
// Doesn't have wasm data.
return isolate->heap()->false_value();
return ReadOnlyRoots(isolate).false_value();
}
if (function->shared()->HasBuiltinId() &&
function->shared()->builtin_id() == Builtins::kInstantiateAsmJs) {
// Hasn't been compiled yet.
return isolate->heap()->false_value();
return ReadOnlyRoots(isolate).false_value();
}
return isolate->heap()->true_value();
return ReadOnlyRoots(isolate).true_value();
}
namespace {
......@@ -818,7 +819,7 @@ RUNTIME_FUNCTION(Runtime_DisallowCodegenFromStrings) {
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
v8_isolate->SetAllowCodeGenerationFromStringsCallback(
flag ? DisallowCodegenFromStringsCallback : nullptr);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_DisallowWasmCodegen) {
......@@ -828,7 +829,7 @@ RUNTIME_FUNCTION(Runtime_DisallowWasmCodegen) {
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
v8_isolate->SetAllowWasmCodeGenerationCallback(
flag ? DisallowCodegenFromStringsCallback : nullptr);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_IsWasmCode) {
......@@ -919,7 +920,7 @@ RUNTIME_FUNCTION(Runtime_SerializeWasmModule) {
!wasm::SerializeNativeModule(
isolate, native_module,
{reinterpret_cast<uint8_t*>(array_data), compiled_size})) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
return *array_buffer;
}
......@@ -954,7 +955,7 @@ RUNTIME_FUNCTION(Runtime_DeserializeWasmModule) {
}
Handle<WasmModuleObject> module_object;
if (!maybe_module_object.ToHandle(&module_object)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
return *module_object;
}
......@@ -1006,7 +1007,7 @@ RUNTIME_FUNCTION(Runtime_RedirectToWasmInterpreter) {
WasmInstanceObject::GetOrCreateDebugInfo(instance);
WasmDebugInfo::RedirectToInterpreter(debug_info,
Vector<int>(&function_index, 1));
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_WasmTraceMemory) {
......@@ -1035,7 +1036,7 @@ RUNTIME_FUNCTION(Runtime_WasmTraceMemory) {
: wasm::ExecutionEngine::kTurbofan;
wasm::TraceMemoryOperation(eng, info, func_index, pos - func_start,
mem_start);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_IsLiftoffFunction) {
......@@ -1060,7 +1061,7 @@ RUNTIME_FUNCTION(Runtime_CompleteInobjectSlackTracking) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
object->map()->CompleteInobjectSlackTracking(isolate);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_FreezeWasmLazyCompilation) {
......@@ -1069,7 +1070,7 @@ RUNTIME_FUNCTION(Runtime_FreezeWasmLazyCompilation) {
CONVERT_ARG_CHECKED(WasmInstanceObject, instance, 0);
instance->module_object()->native_module()->set_lazy_compile_frozen(true);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_WasmMemoryHasFullGuardRegion) {
......
......@@ -26,11 +26,11 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) {
}
Handle<JSArrayBuffer> array_buffer = Handle<JSArrayBuffer>::cast(argument);
if (!array_buffer->is_neuterable()) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
if (array_buffer->backing_store() == nullptr) {
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.
CHECK(!array_buffer->is_shared());
......@@ -41,7 +41,7 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) {
isolate->heap()->UnregisterArrayBuffer(*array_buffer);
array_buffer->Neuter();
isolate->array_buffer_allocator()->Free(backing_store, byte_length);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_TypedArrayCopyElements) {
......
......@@ -136,7 +136,7 @@ RUNTIME_FUNCTION(Runtime_WasmThrowCreate) {
wasm::WasmException::kRuntimeValuesStr),
values, LanguageMode::kStrict)
.is_null());
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_WasmThrow) {
......@@ -226,7 +226,7 @@ RUNTIME_FUNCTION(Runtime_WasmExceptionSetElement) {
}
}
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
......@@ -267,9 +267,9 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
if (!success) {
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) {
......
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