[runtime] Eliminate all GetIsolates

Removes all explicit calls to GetIsolate() in runtime/ by passing it
through calling function functions and implicit calls via the single
argument Handle constructor and handle function.

Bug: v8:7786
Change-Id: I96ac2289a72a42c7abb6754418fecb8e03f2bb29
Reviewed-on: https://chromium-review.googlesource.com/1080528
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53457}
This commit is contained in:
Dan Elphick 2018-05-31 11:29:41 +01:00 committed by Commit Bot
parent 0f1204f2b5
commit 0a028aa30f
12 changed files with 51 additions and 53 deletions

View File

@ -628,7 +628,7 @@ MaybeHandle<JSReceiver> GetSuperHolder(
Isolate* isolate, Handle<Object> receiver, Handle<JSObject> home_object,
SuperMode mode, MaybeHandle<Name> maybe_name, uint32_t index) {
if (home_object->IsAccessCheckNeeded() &&
!isolate->MayAccess(handle(isolate->context()), home_object)) {
!isolate->MayAccess(handle(isolate->context(), isolate), home_object)) {
isolate->ReportFailedAccessCheck(home_object);
RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, JSReceiver);
}

View File

@ -294,8 +294,8 @@ static Object* CompileGlobalEval(Isolate* isolate, Handle<String> source,
Handle<SharedFunctionInfo> outer_info,
LanguageMode language_mode,
int eval_scope_position, int eval_position) {
Handle<Context> context = Handle<Context>(isolate->context());
Handle<Context> native_context = Handle<Context>(context->native_context());
Handle<Context> context(isolate->context(), isolate);
Handle<Context> native_context(context->native_context(), isolate);
// Check if native context allows code generation from
// strings. Throw an exception if it doesn't.

View File

@ -47,7 +47,8 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_DebugBreakOnBytecode) {
// Get the top-most JavaScript frame.
JavaScriptFrameIterator it(isolate);
if (isolate->debug_execution_mode() == DebugInfo::kBreakpoints) {
isolate->debug()->Break(it.frame(), handle(it.frame()->function()));
isolate->debug()->Break(it.frame(),
handle(it.frame()->function(), isolate));
}
// Return the handler from the original bytecode array.
@ -116,7 +117,7 @@ RUNTIME_FUNCTION(Runtime_DebugApplyInstrumentation) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
isolate->debug()->ApplyInstrumentation(handle(function->shared()));
isolate->debug()->ApplyInstrumentation(handle(function->shared(), isolate));
return isolate->heap()->undefined_value();
}
@ -1211,7 +1212,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) {
// Convert the script objects to proper JS objects.
for (int i = 0; i < instances->length(); i++) {
Handle<Script> script = Handle<Script>(Script::cast(instances->get(i)));
Handle<Script> script(Script::cast(instances->get(i)), isolate);
// Get the script wrapper in a local handle before calling GetScriptWrapper,
// because using
// instances->set(i, *GetScriptWrapper(script))
@ -1471,7 +1472,7 @@ RUNTIME_FUNCTION(Runtime_ScriptLineCount) {
CONVERT_ARG_CHECKED(JSValue, script, 0);
CHECK(script->value()->IsScript());
Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
Handle<Script> script_handle(Script::cast(script->value()), isolate);
if (script_handle->type() == Script::TYPE_WASM) {
// Return 0 for now; this function will disappear soon anyway.
@ -1590,7 +1591,7 @@ bool GetScriptById(Isolate* isolate, int needle, Handle<Script>* result) {
Script* script = nullptr;
while ((script = iterator.Next()) != nullptr) {
if (script->id() == needle) {
*result = handle(script);
*result = handle(script, isolate);
return true;
}
}
@ -1618,7 +1619,7 @@ RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine) {
CONVERT_NUMBER_CHECKED(int32_t, offset, Int32, args[3]);
CHECK(script->value()->IsScript());
Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
Handle<Script> script_handle(Script::cast(script->value()), isolate);
return *ScriptLocationFromLine(isolate, script_handle, opt_line, opt_column,
offset);
@ -1648,7 +1649,7 @@ RUNTIME_FUNCTION(Runtime_ScriptPositionInfo) {
CONVERT_BOOLEAN_ARG_CHECKED(with_offset, 2);
CHECK(script->value()->IsScript());
Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
Handle<Script> script_handle(Script::cast(script->value()), isolate);
const Script::OffsetFlag offset_flag =
with_offset ? Script::WITH_OFFSET : Script::NO_OFFSET;

View File

@ -21,8 +21,8 @@ namespace {
// that contains all enumerable properties of the {receiver} and its prototypes
// have none, the map of the {receiver}. This is used to speed up the check for
// deletions during a for-in.
MaybeHandle<HeapObject> Enumerate(Handle<JSReceiver> receiver) {
Isolate* const isolate = receiver->GetIsolate();
MaybeHandle<HeapObject> Enumerate(Isolate* isolate,
Handle<JSReceiver> receiver) {
JSObject::MakePrototypesFast(receiver, kStartAtReceiver, isolate);
FastKeyAccumulator accumulator(isolate, receiver,
KeyCollectionMode::kIncludePrototypes,
@ -116,7 +116,7 @@ RUNTIME_FUNCTION(Runtime_ForInEnumerate) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
RETURN_RESULT_OR_FAILURE(isolate, Enumerate(receiver));
RETURN_RESULT_OR_FAILURE(isolate, Enumerate(isolate, receiver));
}

View File

@ -150,7 +150,7 @@ RUNTIME_FUNCTION(Runtime_SetCode) {
if (isolate->logger()->is_listening_to_code_events() ||
isolate->is_profiling()) {
isolate->logger()->LogExistingFunction(
source_shared, Handle<AbstractCode>(source_shared->abstract_code()));
source_shared, handle(source_shared->abstract_code(), isolate));
}
return *target;

View File

@ -58,7 +58,7 @@ void AdvanceToOffsetForTracing(
interpreter::OperandScale::kSingle));
}
void PrintRegisters(std::ostream& os, bool is_input,
void PrintRegisters(Isolate* isolate, std::ostream& os, bool is_input,
interpreter::BytecodeArrayIterator& bytecode_iterator,
Handle<Object> accumulator) {
static const char kAccumulator[] = "accumulator";
@ -82,8 +82,7 @@ void PrintRegisters(std::ostream& os, bool is_input,
}
// Print the registers.
JavaScriptFrameIterator frame_iterator(
bytecode_iterator.bytecode_array()->GetIsolate());
JavaScriptFrameIterator frame_iterator(isolate);
InterpretedFrame* frame =
reinterpret_cast<InterpretedFrame*>(frame_iterator.frame());
int operand_count = interpreter::Bytecodes::NumberOfOperands(bytecode);
@ -144,7 +143,7 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeEntry) {
bytecode_array->parameter_count());
os << std::endl;
// Print all input registers and accumulator.
PrintRegisters(os, true, bytecode_iterator, accumulator);
PrintRegisters(isolate, os, true, bytecode_iterator, accumulator);
os << std::flush;
}

View File

@ -25,7 +25,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) {
CONVERT_ARG_CHECKED(JSValue, script_value, 0);
CHECK(script_value->value()->IsScript());
Handle<Script> script = Handle<Script>(Script::cast(script_value->value()));
Handle<Script> script(Script::cast(script_value->value()), isolate);
std::vector<Handle<SharedFunctionInfo>> found;
Heap* heap = isolate->heap();
@ -36,7 +36,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) {
if (!heap_obj->IsSharedFunctionInfo()) continue;
SharedFunctionInfo* shared = SharedFunctionInfo::cast(heap_obj);
if (shared->script() != *script) continue;
found.push_back(Handle<SharedFunctionInfo>(shared));
found.push_back(Handle<SharedFunctionInfo>(shared, isolate));
}
}
@ -69,7 +69,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditGatherCompileInfo) {
CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
CHECK(script->value()->IsScript());
Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
Handle<Script> script_handle(Script::cast(script->value()), isolate);
RETURN_RESULT_OR_FAILURE(isolate,
LiveEdit::GatherCompileInfo(script_handle, source));

View File

@ -803,7 +803,7 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) {
FeedbackNexus nexus(vector, FeedbackVector::ToSlot(index));
if (nexus.ic_state() == UNINITIALIZED) {
if (name->IsUniqueName()) {
nexus.ConfigureMonomorphic(name, handle(object->map()),
nexus.ConfigureMonomorphic(name, handle(object->map(), isolate),
MaybeObjectHandle());
} else {
nexus.ConfigureMegamorphic(PROPERTY);
@ -860,7 +860,7 @@ 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());
type = Handle<String>(isolate->heap()->null_string(), isolate);
}
DCHECK(vector->metadata()->HasTypeProfileSlot());

View File

@ -68,8 +68,9 @@ class CompiledReplacement {
: parts_(1, zone), replacement_substrings_(0, zone), zone_(zone) {}
// Return whether the replacement is simple.
bool Compile(Handle<JSRegExp> regexp, Handle<String> replacement,
int capture_count, int subject_length);
bool Compile(Isolate* isolate, Handle<JSRegExp> regexp,
Handle<String> replacement, int capture_count,
int subject_length);
// Use Apply only if Compile returned false.
void Apply(ReplacementStringBuilder* builder, int match_from, int match_to,
@ -315,7 +316,7 @@ class CompiledReplacement {
Zone* zone_;
};
bool CompiledReplacement::Compile(Handle<JSRegExp> regexp,
bool CompiledReplacement::Compile(Isolate* isolate, Handle<JSRegExp> regexp,
Handle<String> replacement, int capture_count,
int subject_length) {
{
@ -347,7 +348,6 @@ bool CompiledReplacement::Compile(Handle<JSRegExp> regexp,
if (simple) return true;
}
Isolate* isolate = replacement->GetIsolate();
// Find substrings of replacement string and create them as String objects.
int substring_index = 0;
for (int i = 0, n = parts_.length(); i < n; i++) {
@ -630,7 +630,7 @@ V8_WARN_UNUSED_RESULT static Object* StringReplaceGlobalRegExpWithString(
Zone zone(isolate->allocator(), ZONE_NAME);
CompiledReplacement compiled_replacement(&zone);
const bool simple_replace = compiled_replacement.Compile(
regexp, replacement, capture_count, subject_length);
isolate, regexp, replacement, capture_count, subject_length);
// Shortcut for simple non-regexp global replacements
if (typeTag == JSRegExp::ATOM && simple_replace) {
@ -948,7 +948,7 @@ class MatchInfoBackedMatch : public String::Match {
has_named_captures_ = o->IsFixedArray();
if (has_named_captures_) {
DCHECK(FLAG_harmony_regexp_named_captures);
capture_name_map_ = handle(FixedArray::cast(o));
capture_name_map_ = handle(FixedArray::cast(o), isolate);
}
} else {
has_named_captures_ = false;
@ -1154,7 +1154,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
last_match[i] = Smi::ToInt(last_match_cache->get(i));
}
Handle<FixedArray> cached_fixed_array =
Handle<FixedArray>(FixedArray::cast(cached_answer));
Handle<FixedArray>(FixedArray::cast(cached_answer), isolate);
// The cache FixedArray is a COW-array and we need to return a copy.
Handle<FixedArray> copied_fixed_array =
isolate->factory()->CopyFixedArrayWithMap(
@ -1491,7 +1491,7 @@ RUNTIME_FUNCTION(Runtime_StringReplaceNonGlobalRegExpWithFunction) {
Object* maybe_capture_map = regexp->CaptureNameMap();
if (maybe_capture_map->IsFixedArray()) {
has_named_captures = true;
capture_map = handle(FixedArray::cast(maybe_capture_map));
capture_map = handle(FixedArray::cast(maybe_capture_map), isolate);
}
}

View File

@ -645,10 +645,9 @@ RUNTIME_FUNCTION(Runtime_NewClosure_Tenured) {
return *function;
}
static Object* FindNameClash(Handle<ScopeInfo> scope_info,
static Object* FindNameClash(Isolate* isolate, Handle<ScopeInfo> scope_info,
Handle<JSGlobalObject> global_object,
Handle<ScriptContextTable> script_context) {
Isolate* isolate = scope_info->GetIsolate();
for (int var = 0; var < scope_info->ContextLocalCount(); var++) {
Handle<String> name(scope_info->ContextLocalName(var));
VariableMode mode = scope_info->ContextLocalMode(var);
@ -697,7 +696,7 @@ RUNTIME_FUNCTION(Runtime_NewScriptContext) {
native_context->script_context_table());
Object* name_clash_result =
FindNameClash(scope_info, global_object, script_context_table);
FindNameClash(isolate, scope_info, global_object, script_context_table);
if (isolate->has_pending_exception()) return name_clash_result;
// We do not need script contexts here during bootstrap.
@ -809,11 +808,9 @@ RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) {
namespace {
MaybeHandle<Object> LoadLookupSlot(Handle<String> name,
MaybeHandle<Object> LoadLookupSlot(Isolate* isolate, Handle<String> name,
ShouldThrow should_throw,
Handle<Object>* receiver_return = nullptr) {
Isolate* const isolate = name->GetIsolate();
int index;
PropertyAttributes attributes;
InitializationFlag flag;
@ -879,7 +876,8 @@ RUNTIME_FUNCTION(Runtime_LoadLookupSlot) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
RETURN_RESULT_OR_FAILURE(isolate, LoadLookupSlot(name, kThrowOnError));
RETURN_RESULT_OR_FAILURE(isolate,
LoadLookupSlot(isolate, name, kThrowOnError));
}
@ -887,7 +885,7 @@ RUNTIME_FUNCTION(Runtime_LoadLookupSlotInsideTypeof) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
RETURN_RESULT_OR_FAILURE(isolate, LoadLookupSlot(name, kDontThrow));
RETURN_RESULT_OR_FAILURE(isolate, LoadLookupSlot(isolate, name, kDontThrow));
}
@ -899,7 +897,7 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadLookupSlotForCall) {
Handle<Object> value;
Handle<Object> receiver;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, value, LoadLookupSlot(name, kThrowOnError, &receiver),
isolate, value, LoadLookupSlot(isolate, name, kThrowOnError, &receiver),
MakePair(isolate->heap()->exception(), nullptr));
return MakePair(*value, *receiver);
}
@ -908,9 +906,9 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadLookupSlotForCall) {
namespace {
MaybeHandle<Object> StoreLookupSlot(
Handle<String> name, Handle<Object> value, LanguageMode language_mode,
Isolate* isolate, Handle<String> name, Handle<Object> value,
LanguageMode language_mode,
ContextLookupFlags context_lookup_flags = FOLLOW_CHAINS) {
Isolate* const isolate = name->GetIsolate();
Handle<Context> context(isolate->context(), isolate);
int index;
@ -963,7 +961,7 @@ MaybeHandle<Object> StoreLookupSlot(
isolate, NewReferenceError(MessageTemplate::kNotDefined, name), Object);
} else {
// If absent in sloppy mode: add the property to the global object.
object = Handle<JSReceiver>(context->global_object());
object = handle(context->global_object(), isolate);
}
ASSIGN_RETURN_ON_EXCEPTION(
@ -980,8 +978,8 @@ RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Sloppy) {
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
RETURN_RESULT_OR_FAILURE(isolate,
StoreLookupSlot(name, value, LanguageMode::kSloppy));
RETURN_RESULT_OR_FAILURE(
isolate, StoreLookupSlot(isolate, name, value, LanguageMode::kSloppy));
}
// Store into a dynamic context for sloppy-mode block-scoped function hoisting
@ -995,8 +993,8 @@ RUNTIME_FUNCTION(Runtime_StoreLookupSlot_SloppyHoisting) {
const ContextLookupFlags lookup_flags = static_cast<ContextLookupFlags>(
FOLLOW_CONTEXT_CHAIN | STOP_AT_DECLARATION_SCOPE | SKIP_WITH_CONTEXT);
RETURN_RESULT_OR_FAILURE(
isolate,
StoreLookupSlot(name, value, LanguageMode::kSloppy, lookup_flags));
isolate, StoreLookupSlot(isolate, name, value, LanguageMode::kSloppy,
lookup_flags));
}
RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) {
@ -1004,8 +1002,8 @@ RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) {
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
RETURN_RESULT_OR_FAILURE(isolate,
StoreLookupSlot(name, value, LanguageMode::kStrict));
RETURN_RESULT_OR_FAILURE(
isolate, StoreLookupSlot(isolate, name, value, LanguageMode::kStrict));
}
} // namespace internal

View File

@ -74,8 +74,8 @@ MaybeHandle<String> StringReplaceOneCharWithString(
recursion_limit--;
if (subject->IsConsString()) {
ConsString* cons = ConsString::cast(*subject);
Handle<String> first = Handle<String>(cons->first());
Handle<String> second = Handle<String>(cons->second());
Handle<String> first = handle(cons->first(), isolate);
Handle<String> second = handle(cons->second(), isolate);
Handle<String> new_first;
if (!StringReplaceOneCharWithString(isolate, first, search, replace, found,
recursion_limit).ToHandle(&new_first)) {

View File

@ -160,7 +160,7 @@ RUNTIME_FUNCTION(Runtime_DeoptimizeNow) {
// Find the JavaScript function on the top of the stack.
JavaScriptFrameIterator it(isolate);
if (!it.done()) function = Handle<JSFunction>(it.frame()->function());
if (!it.done()) function = handle(it.frame()->function(), isolate);
if (function.is_null()) return isolate->heap()->undefined_value();
// If the function is not optimized, just return.
@ -271,7 +271,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
// Find the JavaScript function on the top of the stack.
JavaScriptFrameIterator it(isolate);
while (!it.done() && stack_depth--) it.Advance();
if (!it.done()) function = Handle<JSFunction>(it.frame()->function());
if (!it.done()) function = handle(it.frame()->function(), isolate);
if (function.is_null()) return isolate->heap()->undefined_value();
// If the function is already optimized, just return.