Commit a890034b authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[GetIsolate] Remove GetIsolate in src/debug

Bug: v8:7786
Change-Id: I369eb0bf32d89603b6b944c2bb8fe402a16e429b
Reviewed-on: https://chromium-review.googlesource.com/1104423
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53880}
parent 48d66504
......@@ -44,7 +44,8 @@ MaybeHandle<Object> DebugEvaluate::Global(Isolate* isolate,
context);
if (throw_on_side_effect) isolate->debug()->StartSideEffectCheckMode();
MaybeHandle<Object> result = Execution::Call(
isolate, fun, Handle<JSObject>(context->global_proxy()), 0, nullptr);
isolate, fun, Handle<JSObject>(context->global_proxy(), isolate), 0,
nullptr);
if (throw_on_side_effect) isolate->debug()->StopSideEffectCheckMode();
return result;
}
......@@ -72,7 +73,7 @@ MaybeHandle<Object> DebugEvaluate::Local(Isolate* isolate,
if (isolate->has_pending_exception()) return MaybeHandle<Object>();
Handle<Context> context = context_builder.evaluation_context();
Handle<JSObject> receiver(context->global_proxy());
Handle<JSObject> receiver(context->global_proxy(), isolate);
MaybeHandle<Object> maybe_result =
Evaluate(isolate, context_builder.outer_info(), context, receiver, source,
throw_on_side_effect);
......@@ -115,7 +116,7 @@ MaybeHandle<Object> DebugEvaluate::WithTopmostArguments(Isolate* isolate,
Handle<Context>(), Handle<StringSet>());
Handle<SharedFunctionInfo> outer_info(
native_context->empty_function()->shared(), isolate);
Handle<JSObject> receiver(native_context->global_proxy());
Handle<JSObject> receiver(native_context->global_proxy(), isolate);
const bool throw_on_side_effect = false;
MaybeHandle<Object> maybe_result =
Evaluate(isolate, outer_info, evaluation_context, receiver, source,
......@@ -170,7 +171,8 @@ DebugEvaluate::ContextBuilder::ContextBuilder(Isolate* isolate,
frame_inspector_(frame, inlined_jsframe_index, isolate),
scope_iterator_(isolate, &frame_inspector_,
ScopeIterator::COLLECT_NON_LOCALS) {
Handle<Context> outer_context(frame_inspector_.GetFunction()->context());
Handle<Context> outer_context(frame_inspector_.GetFunction()->context(),
isolate);
evaluation_context_ = outer_context;
Factory* factory = isolate->factory();
......@@ -856,7 +858,7 @@ bool BytecodeRequiresRuntimeCheck(interpreter::Bytecode bytecode) {
// static
SharedFunctionInfo::SideEffectState DebugEvaluate::FunctionGetSideEffectState(
Handle<SharedFunctionInfo> info) {
Isolate* isolate, Handle<SharedFunctionInfo> info) {
if (FLAG_trace_side_effect_free_debug_evaluate) {
PrintF("[debug-evaluate] Checking function %s for side effect.\n",
info->DebugName()->ToCString().get());
......@@ -865,7 +867,7 @@ SharedFunctionInfo::SideEffectState DebugEvaluate::FunctionGetSideEffectState(
DCHECK(info->is_compiled());
if (info->HasBytecodeArray()) {
// Check bytecodes against whitelist.
Handle<BytecodeArray> bytecode_array(info->GetBytecodeArray());
Handle<BytecodeArray> bytecode_array(info->GetBytecodeArray(), isolate);
if (FLAG_trace_side_effect_free_debug_evaluate) bytecode_array->Print();
bool requires_runtime_checks = false;
for (interpreter::BytecodeArrayIterator it(bytecode_array); !it.done();
......@@ -914,7 +916,6 @@ SharedFunctionInfo::SideEffectState DebugEvaluate::FunctionGetSideEffectState(
BuiltinGetSideEffectState(static_cast<Builtins::Name>(builtin_index));
#ifdef DEBUG
if (state == SharedFunctionInfo::kHasNoSideEffect) {
Isolate* isolate = info->GetIsolate();
Code* code = isolate->builtins()->builtin(builtin_index);
if (code->builtin_index() == Builtins::kDeserializeLazy) {
// Target builtin is not yet deserialized. Deserialize it now.
......
......@@ -40,7 +40,7 @@ class DebugEvaluate : public AllStatic {
Handle<String> source);
static SharedFunctionInfo::SideEffectState FunctionGetSideEffectState(
Handle<SharedFunctionInfo> info);
Isolate* isolate, Handle<SharedFunctionInfo> info);
static bool CallbackHasNoSideEffect(Object* callback_info);
static void ApplySideEffectChecks(Handle<BytecodeArray> bytecode_array);
......
......@@ -46,7 +46,7 @@ Handle<Object> ScopeIterator::GetFunctionDebugName() const {
if (!context_->IsNativeContext()) {
DisallowHeapAllocation no_gc;
ScopeInfo* closure_info = context_->closure_context()->scope_info();
Handle<String> debug_name(closure_info->FunctionDebugName());
Handle<String> debug_name(closure_info->FunctionDebugName(), isolate_);
if (debug_name->length() > 0) return debug_name;
}
return isolate_->factory()->undefined_value();
......@@ -54,8 +54,8 @@ Handle<Object> ScopeIterator::GetFunctionDebugName() const {
ScopeIterator::ScopeIterator(Isolate* isolate, Handle<JSFunction> function)
: isolate_(isolate),
context_(function->context()),
script_(Script::cast(function->shared()->script())) {
context_(function->context(), isolate),
script_(Script::cast(function->shared()->script()), isolate) {
if (!function->shared()->IsSubjectToDebugging()) {
context_ = Handle<Context>();
return;
......@@ -67,9 +67,9 @@ ScopeIterator::ScopeIterator(Isolate* isolate,
Handle<JSGeneratorObject> generator)
: isolate_(isolate),
generator_(generator),
function_(generator->function()),
context_(generator->context()),
script_(Script::cast(function_->shared()->script())) {
function_(generator->function(), isolate),
context_(generator->context(), isolate),
script_(Script::cast(function_->shared()->script()), isolate) {
if (!function_->shared()->IsSubjectToDebugging()) {
context_ = Handle<Context>();
return;
......@@ -88,8 +88,8 @@ void ScopeIterator::Restart() {
void ScopeIterator::TryParseAndRetrieveScopes(ScopeIterator::Option option) {
// Catch the case when the debugger stops in an internal function.
Handle<SharedFunctionInfo> shared_info(function_->shared());
Handle<ScopeInfo> scope_info(shared_info->scope_info());
Handle<SharedFunctionInfo> shared_info(function_->shared(), isolate_);
Handle<ScopeInfo> scope_info(shared_info->scope_info(), isolate_);
if (shared_info->script()->IsUndefined(isolate_)) {
current_scope_ = closure_scope_ = nullptr;
context_ = handle(function_->context(), isolate_);
......@@ -106,7 +106,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ScopeIterator::Option option) {
// inspect the function scope.
// This can only happen if we set a break point inside right before the
// return, which requires a debug info to be available.
Handle<DebugInfo> debug_info(shared_info->GetDebugInfo());
Handle<DebugInfo> debug_info(shared_info->GetDebugInfo(), isolate_);
// Find the break point where execution has stopped.
BreakLocation location = BreakLocation::FromFrame(debug_info, GetFrame());
......@@ -121,7 +121,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ScopeIterator::Option option) {
info_ = new ParseInfo(isolate_, shared_info);
} else {
// Global or eval code.
Handle<Script> script(Script::cast(shared_info->script()));
Handle<Script> script(Script::cast(shared_info->script()), isolate_);
info_ = new ParseInfo(isolate_, script);
if (scope_info->scope_type() == EVAL_SCOPE) {
info_->set_eval();
......@@ -547,7 +547,7 @@ void ScopeIterator::VisitScriptScope(const Visitor& visitor) const {
context_index++) {
Handle<Context> context =
ScriptContextTable::GetContext(script_contexts, context_index);
Handle<ScopeInfo> scope_info(context->scope_info());
Handle<ScopeInfo> scope_info(context->scope_info(), isolate_);
if (VisitContextLocals(visitor, scope_info, context)) return;
}
}
......@@ -555,7 +555,7 @@ void ScopeIterator::VisitScriptScope(const Visitor& visitor) const {
void ScopeIterator::VisitModuleScope(const Visitor& visitor) const {
DCHECK(context_->IsModuleContext());
Handle<ScopeInfo> scope_info(context_->scope_info());
Handle<ScopeInfo> scope_info(context_->scope_info(), isolate_);
if (VisitContextLocals(visitor, scope_info, context_)) return;
int count_index = scope_info->ModuleVariableCountIndex();
......@@ -585,7 +585,7 @@ bool ScopeIterator::VisitContextLocals(const Visitor& visitor,
Handle<Context> context) const {
// Fill all context locals to the context extension.
for (int i = 0; i < scope_info->ContextLocalCount(); ++i) {
Handle<String> name(scope_info->ContextLocalName(i));
Handle<String> name(scope_info->ContextLocalName(i), isolate_);
if (ScopeInfo::VariableIsSynthetic(*name)) continue;
int context_index = Context::MIN_CONTEXT_SLOTS + i;
Handle<Object> value(context->get(context_index), isolate_);
......@@ -759,7 +759,7 @@ void ScopeIterator::VisitLocalScope(const Visitor& visitor, Mode mode) const {
for (int i = 0; i < keys->length(); i++) {
// Names of variables introduced by eval are strings.
DCHECK(keys->get(i)->IsString());
Handle<String> key(String::cast(keys->get(i)));
Handle<String> key(String::cast(keys->get(i)), isolate_);
Handle<Object> value = JSReceiver::GetDataProperty(extension, key);
if (visitor(key, value)) return;
}
......@@ -890,7 +890,8 @@ bool ScopeIterator::SetModuleVariableValue(Handle<String> variable_name,
bool ScopeIterator::SetScriptVariableValue(Handle<String> variable_name,
Handle<Object> new_value) {
Handle<ScriptContextTable> script_contexts(
context_->global_object()->native_context()->script_context_table());
context_->global_object()->native_context()->script_context_table(),
isolate_);
ScriptContextTable::LookupResult lookup_result;
if (ScriptContextTable::Lookup(script_contexts, variable_name,
&lookup_result)) {
......
......@@ -84,7 +84,7 @@ v8::MaybeLocal<v8::Value> DebugStackTraceIterator::GetReceiver() const {
// So let's try to fetch it using same logic as is used to retrieve 'this'
// during DebugEvaluate::Local.
Handle<JSFunction> function = frame_inspector_->GetFunction();
Handle<Context> context(function->context());
Handle<Context> context(function->context(), isolate_);
// Arrow function defined in top level function without references to
// variables may have NativeContext as context.
if (!context->IsFunctionContext()) return v8::MaybeLocal<v8::Value>();
......@@ -95,7 +95,7 @@ v8::MaybeLocal<v8::Value> DebugStackTraceIterator::GetReceiver() const {
if (!scope_iterator.GetNonLocals()->Has(isolate_->factory()->this_string()))
return v8::MaybeLocal<v8::Value>();
Handle<ScopeInfo> scope_info(context->scope_info());
Handle<ScopeInfo> scope_info(context->scope_info(), isolate_);
VariableMode mode;
InitializationFlag flag;
MaybeAssignedFlag maybe_assigned_flag;
......
......@@ -301,7 +301,7 @@ void BreakIterator::ClearDebugBreak() {
BreakLocation BreakIterator::GetBreakLocation() {
Handle<AbstractCode> code(
AbstractCode::cast(debug_info_->DebugBytecodeArray()));
AbstractCode::cast(debug_info_->DebugBytecodeArray()), isolate());
DebugBreakType type = GetDebugBreakType();
int generator_object_reg_index = -1;
if (type == DEBUG_BREAK_SLOT_AT_SUSPEND) {
......@@ -378,9 +378,10 @@ void Debug::Iterate(RootVisitor* v) {
&thread_local_.ignore_step_into_function_);
}
DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info) : next_(nullptr) {
DebugInfoListNode::DebugInfoListNode(Isolate* isolate, DebugInfo* debug_info)
: next_(nullptr) {
// Globalize the request debug info object and make it weak.
GlobalHandles* global_handles = debug_info->GetIsolate()->global_handles();
GlobalHandles* global_handles = isolate->global_handles();
debug_info_ = global_handles->Create(debug_info).location();
}
......@@ -462,7 +463,7 @@ void Debug::Break(JavaScriptFrame* frame, Handle<JSFunction> break_target) {
DisableBreak no_recursive_break(this);
// Return if we fail to retrieve debug info.
Handle<SharedFunctionInfo> shared(break_target->shared());
Handle<SharedFunctionInfo> shared(break_target->shared(), isolate_);
if (!EnsureBreakInfo(shared)) return;
PrepareFunctionForDebugExecution(shared);
......@@ -580,7 +581,7 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) {
DCHECK(!summary.IsWasm());
Handle<JSFunction> function = summary.AsJavaScript().function();
if (!function->shared()->HasBreakInfo()) return false;
Handle<DebugInfo> debug_info(function->shared()->GetDebugInfo());
Handle<DebugInfo> debug_info(function->shared()->GetDebugInfo(), isolate_);
// Enter the debugger.
DebugScope debug_scope(this);
if (debug_scope.failed()) return false;
......@@ -625,7 +626,7 @@ bool Debug::CheckBreakPoint(Handle<BreakPoint> break_point,
HandleScope scope(isolate_);
if (!break_point->condition()->length()) return true;
Handle<String> condition(break_point->condition());
Handle<String> condition(break_point->condition(), isolate_);
MaybeHandle<Object> maybe_result;
Handle<Object> result;
......@@ -656,11 +657,11 @@ bool Debug::SetBreakPoint(Handle<JSFunction> function,
HandleScope scope(isolate_);
// Make sure the function is compiled and has set up the debug info.
Handle<SharedFunctionInfo> shared(function->shared());
Handle<SharedFunctionInfo> shared(function->shared(), isolate_);
if (!EnsureBreakInfo(shared)) return false;
PrepareFunctionForDebugExecution(shared);
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
Handle<DebugInfo> debug_info(shared->GetDebugInfo(), isolate_);
// Source positions starts with zero.
DCHECK_LE(0, *source_position);
......@@ -708,7 +709,7 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
*source_position = shared->StartPosition();
}
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
Handle<DebugInfo> debug_info(shared->GetDebugInfo(), isolate_);
// Find breakable position returns first breakable position after
// *source_position, it can return 0 if no break location is found after
......@@ -842,7 +843,7 @@ void Debug::FloodWithOneShot(Handle<SharedFunctionInfo> shared,
if (!EnsureBreakInfo(shared)) return;
PrepareFunctionForDebugExecution(shared);
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
Handle<DebugInfo> debug_info(shared->GetDebugInfo(), isolate_);
// Flood the function with break points.
DCHECK(debug_info->HasDebugBytecodeArray());
for (BreakIterator it(debug_info); !it.Done(); it.Next()) {
......@@ -883,7 +884,7 @@ MaybeHandle<FixedArray> Debug::GetHitBreakPoints(Handle<DebugInfo> debug_info,
return break_points_hit;
}
Handle<FixedArray> array(FixedArray::cast(*break_points));
Handle<FixedArray> array(FixedArray::cast(*break_points), isolate_);
int num_objects = array->length();
Handle<FixedArray> break_points_hit =
isolate_->factory()->NewFixedArray(num_objects);
......@@ -921,7 +922,7 @@ void Debug::PrepareStepIn(Handle<JSFunction> function) {
if (ignore_events()) return;
if (in_debug_scope()) return;
if (break_disabled()) return;
Handle<SharedFunctionInfo> shared(function->shared());
Handle<SharedFunctionInfo> shared(function->shared(), isolate_);
if (IsBlackboxed(shared)) return;
if (*function == thread_local_.ignore_step_into_function_) return;
thread_local_.ignore_step_into_function_ = Smi::kZero;
......@@ -936,7 +937,8 @@ void Debug::PrepareStepInSuspendedGenerator() {
thread_local_.last_step_action_ = StepIn;
UpdateHookOnFunctionCall();
Handle<JSFunction> function(
JSGeneratorObject::cast(thread_local_.suspended_generator_)->function());
JSGeneratorObject::cast(thread_local_.suspended_generator_)->function(),
isolate_);
FloodWithOneShot(Handle<SharedFunctionInfo>(function->shared(), isolate_));
clear_suspended_generator();
}
......@@ -1003,7 +1005,7 @@ void Debug::PrepareStepOnThrow() {
continue;
}
Handle<SharedFunctionInfo> info(
summary.AsJavaScript().function()->shared());
summary.AsJavaScript().function()->shared(), isolate_);
if (IsBlackboxed(info)) continue;
FloodWithOneShot(info);
return;
......@@ -1049,11 +1051,11 @@ void Debug::PrepareStep(StepAction step_action) {
// Get the debug info (create it if it does not exist).
auto summary = FrameSummary::GetTop(frame).AsJavaScript();
Handle<JSFunction> function(summary.function());
Handle<SharedFunctionInfo> shared(function->shared());
Handle<SharedFunctionInfo> shared(function->shared(), isolate_);
if (!EnsureBreakInfo(shared)) return;
PrepareFunctionForDebugExecution(shared);
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
Handle<DebugInfo> debug_info(shared->GetDebugInfo(), isolate_);
BreakLocation location = BreakLocation::FromFrame(debug_info, js_frame);
......@@ -1140,12 +1142,11 @@ void Debug::PrepareStep(StepAction step_action) {
// Simple function for returning the source positions for active break points.
Handle<Object> Debug::GetSourceBreakLocations(
Handle<SharedFunctionInfo> shared) {
Isolate* isolate = shared->GetIsolate();
Isolate* isolate, Handle<SharedFunctionInfo> shared) {
if (!shared->HasBreakInfo()) {
return isolate->factory()->undefined_value();
}
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
Handle<DebugInfo> debug_info(shared->GetDebugInfo(), isolate);
if (debug_info->GetBreakPointCount() == 0) {
return isolate->factory()->undefined_value();
}
......@@ -1260,7 +1261,7 @@ void Debug::PrepareFunctionForDebugExecution(
Handle<Object> maybe_debug_bytecode_array =
isolate_->factory()->undefined_value();
if (shared->HasBytecodeArray()) {
Handle<BytecodeArray> original(shared->GetBytecodeArray());
Handle<BytecodeArray> original(shared->GetBytecodeArray(), isolate_);
maybe_debug_bytecode_array =
isolate_->factory()->CopyBytecodeArray(original);
}
......@@ -1367,7 +1368,7 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
if (!EnsureBreakInfo(shared)) return false;
PrepareFunctionForDebugExecution(shared);
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
Handle<DebugInfo> debug_info(shared->GetDebugInfo(), isolate_);
FindBreakablePositions(debug_info, start_position, end_position, locations);
return true;
}
......@@ -1405,7 +1406,7 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
for (const auto& candidate : candidates) {
CHECK(candidate->HasBreakInfo());
Handle<DebugInfo> debug_info(candidate->GetDebugInfo());
Handle<DebugInfo> debug_info(candidate->GetDebugInfo(), isolate_);
FindBreakablePositions(debug_info, start_position, end_position,
locations);
}
......@@ -1491,7 +1492,7 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
if (shared == nullptr) break;
// We found it if it's already compiled.
if (shared->is_compiled()) {
Handle<SharedFunctionInfo> shared_handle(shared);
Handle<SharedFunctionInfo> shared_handle(shared, isolate_);
// If the iteration count is larger than 1, we had to compile the outer
// function in order to create this shared function info. So there can
// be no JSFunction referencing it. We can anticipate creating a debug
......@@ -1558,7 +1559,7 @@ Handle<DebugInfo> Debug::GetOrCreateDebugInfo(
// Create debug info and add it to the list.
Handle<DebugInfo> debug_info = isolate_->factory()->NewDebugInfo(shared);
DebugInfoListNode* node = new DebugInfoListNode(*debug_info);
DebugInfoListNode* node = new DebugInfoListNode(isolate_, *debug_info);
node->set_next(debug_info_list_);
debug_info_list_ = node;
......@@ -1645,13 +1646,13 @@ bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) {
HandleScope scope(isolate_);
// Get the executing function in which the debug break occurred.
Handle<SharedFunctionInfo> shared(frame->function()->shared());
Handle<SharedFunctionInfo> shared(frame->function()->shared(), isolate_);
// With no debug info there are no break points, so we can't be at a return.
if (!shared->HasBreakInfo()) return false;
DCHECK(!frame->is_optimized());
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
Handle<DebugInfo> debug_info(shared->GetDebugInfo(), isolate_);
BreakLocation location = BreakLocation::FromFrame(debug_info, frame);
return location.IsReturn();
}
......@@ -1739,7 +1740,7 @@ v8::Local<v8::Context> GetDebugEventContext(Isolate* isolate) {
// Isolate::context() may have been nullptr when "script collected" event
// occurred.
if (context.is_null()) return v8::Local<v8::Context>();
Handle<Context> native_context(context->native_context());
Handle<Context> native_context(context->native_context(), isolate);
return v8::Utils::ToLocal(native_context);
}
} // anonymous namespace
......@@ -1871,7 +1872,7 @@ bool Debug::IsBlackboxed(Handle<SharedFunctionInfo> shared) {
PostponeInterruptsScope no_interrupts(isolate_);
DisableBreak no_recursive_break(this);
DCHECK(shared->script()->IsScript());
Handle<Script> script(Script::cast(shared->script()));
Handle<Script> script(Script::cast(shared->script()), isolate_);
DCHECK(script->IsUserJavaScript());
debug::Location start = GetDebugLocation(script, shared->StartPosition());
debug::Location end = GetDebugLocation(script, shared->EndPosition());
......@@ -2088,13 +2089,14 @@ void Debug::PrintBreakLocation() {
PrintF("'.\n");
if (script_obj->IsScript()) {
Handle<Script> script = Handle<Script>::cast(script_obj);
Handle<String> source(String::cast(script->source()));
Handle<String> source(String::cast(script->source()), isolate_);
Script::InitLineEnds(script);
int line =
Script::GetLineNumber(script, source_position) - script->line_offset();
int column = Script::GetColumnNumber(script, source_position) -
(line == 0 ? script->column_offset() : 0);
Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()),
isolate_);
int line_start = line == 0 ? 0 : Smi::ToInt(line_ends->get(line - 1)) + 1;
int line_end = Smi::ToInt(line_ends->get(line));
DisallowHeapAllocation no_gc;
......@@ -2169,8 +2171,8 @@ void Debug::StartSideEffectCheckMode() {
DCHECK(!temporary_objects_);
temporary_objects_.reset(new TemporaryObjectsTracker());
isolate_->heap()->AddHeapObjectAllocationTracker(temporary_objects_.get());
Handle<FixedArray> array(
isolate_->native_context()->regexp_last_match_info());
Handle<FixedArray> array(isolate_->native_context()->regexp_last_match_info(),
isolate_);
regexp_match_info_ =
Handle<RegExpMatchInfo>::cast(isolate_->factory()->CopyFixedArray(array));
}
......@@ -2199,15 +2201,17 @@ void Debug::StopSideEffectCheckMode() {
void Debug::ApplySideEffectChecks(Handle<DebugInfo> debug_info) {
DCHECK(debug_info->HasDebugBytecodeArray());
Handle<BytecodeArray> debug_bytecode(debug_info->DebugBytecodeArray());
Handle<BytecodeArray> debug_bytecode(debug_info->DebugBytecodeArray(),
isolate_);
DebugEvaluate::ApplySideEffectChecks(debug_bytecode);
debug_info->SetDebugExecutionMode(DebugInfo::kSideEffects);
}
void Debug::ClearSideEffectChecks(Handle<DebugInfo> debug_info) {
DCHECK(debug_info->HasDebugBytecodeArray());
Handle<BytecodeArray> debug_bytecode(debug_info->DebugBytecodeArray());
Handle<BytecodeArray> original(debug_info->OriginalBytecodeArray());
Handle<BytecodeArray> debug_bytecode(debug_info->DebugBytecodeArray(),
isolate_);
Handle<BytecodeArray> original(debug_info->OriginalBytecodeArray(), isolate_);
for (interpreter::BytecodeArrayIterator it(debug_bytecode); !it.done();
it.Advance()) {
debug_bytecode->set(it.current_offset(),
......@@ -2225,7 +2229,7 @@ bool Debug::PerformSideEffectCheck(Handle<JSFunction> function,
}
SharedFunctionInfo::SideEffectState side_effect_state =
SharedFunctionInfo::GetSideEffectState(
handle(function->shared(), isolate_));
isolate_, handle(function->shared(), isolate_));
switch (side_effect_state) {
case SharedFunctionInfo::kHasSideEffects:
if (FLAG_trace_side_effect_free_debug_evaluate) {
......@@ -2237,7 +2241,7 @@ bool Debug::PerformSideEffectCheck(Handle<JSFunction> function,
isolate_->TerminateExecution();
return false;
case SharedFunctionInfo::kRequiresRuntimeChecks: {
Handle<SharedFunctionInfo> shared(function->shared());
Handle<SharedFunctionInfo> shared(function->shared(), isolate_);
if (!shared->HasBytecodeArray()) {
return PerformSideEffectCheckForObject(receiver);
}
......
......@@ -170,7 +170,7 @@ class BreakIterator {
// weak handles to avoid a debug info object to keep a function alive.
class DebugInfoListNode {
public:
explicit DebugInfoListNode(DebugInfo* debug_info);
DebugInfoListNode(Isolate* isolate, DebugInfo* debug_info);
~DebugInfoListNode();
DebugInfoListNode* next() { return next_; }
......@@ -295,7 +295,7 @@ class Debug {
int position);
static Handle<Object> GetSourceBreakLocations(
Handle<SharedFunctionInfo> shared);
Isolate* isolate, Handle<SharedFunctionInfo> shared);
// Check whether a global object is the debug global object.
bool IsDebugGlobal(JSGlobalObject* global);
......
......@@ -501,13 +501,17 @@ class LineArrayCompareInput : public SubrangableInput {
// a fine-grained nested diff token-wise.
class TokenizingLineArrayCompareOutput : public SubrangableOutput {
public:
TokenizingLineArrayCompareOutput(LineEndsWrapper line_ends1,
TokenizingLineArrayCompareOutput(Isolate* isolate, LineEndsWrapper line_ends1,
LineEndsWrapper line_ends2,
Handle<String> s1, Handle<String> s2)
: array_writer_(s1->GetIsolate()),
line_ends1_(line_ends1), line_ends2_(line_ends2), s1_(s1), s2_(s2),
subrange_offset1_(0), subrange_offset2_(0) {
}
: isolate_(isolate),
array_writer_(isolate),
line_ends1_(line_ends1),
line_ends2_(line_ends2),
s1_(s1),
s2_(s2),
subrange_offset1_(0),
subrange_offset2_(0) {}
void AddChunk(int line_pos1, int line_pos2, int line_len1, int line_len2) {
line_pos1 += subrange_offset1_;
......@@ -520,7 +524,7 @@ class TokenizingLineArrayCompareOutput : public SubrangableOutput {
if (char_len1 < CHUNK_LEN_LIMIT && char_len2 < CHUNK_LEN_LIMIT) {
// Chunk is small enough to conduct a nested token-level diff.
HandleScope subTaskScope(s1_->GetIsolate());
HandleScope subTaskScope(isolate_);
TokensCompareInput tokens_input(s1_, char_pos1, char_len1,
s2_, char_pos2, char_len2);
......@@ -546,6 +550,7 @@ class TokenizingLineArrayCompareOutput : public SubrangableOutput {
private:
static const int CHUNK_LEN_LIMIT = 800;
Isolate* isolate_;
CompareOutputArrayWriter array_writer_;
LineEndsWrapper line_ends1_;
LineEndsWrapper line_ends2_;
......@@ -555,8 +560,7 @@ class TokenizingLineArrayCompareOutput : public SubrangableOutput {
int subrange_offset2_;
};
Handle<JSArray> LiveEdit::CompareStrings(Handle<String> s1,
Handle<JSArray> LiveEdit::CompareStrings(Isolate* isolate, Handle<String> s1,
Handle<String> s2) {
s1 = String::Flatten(s1);
s2 = String::Flatten(s2);
......@@ -565,7 +569,8 @@ Handle<JSArray> LiveEdit::CompareStrings(Handle<String> s1,
LineEndsWrapper line_ends2(s2);
LineArrayCompareInput input(s1, s2, line_ends1, line_ends2);
TokenizingLineArrayCompareOutput output(line_ends1, line_ends2, s1, s2);
TokenizingLineArrayCompareOutput output(isolate, line_ends1, line_ends2, s1,
s2);
NarrowDownInput(&input, &output);
......@@ -583,8 +588,8 @@ static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) {
// Wraps any object into a OpaqueReference, that will hide the object
// from JavaScript.
static Handle<JSValue> WrapInJSValue(Handle<HeapObject> object) {
Isolate* isolate = object->GetIsolate();
static Handle<JSValue> WrapInJSValue(Isolate* isolate,
Handle<HeapObject> object) {
Handle<JSFunction> constructor = isolate->opaque_reference_function();
Handle<JSValue> result =
Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor));
......@@ -597,7 +602,8 @@ static Handle<SharedFunctionInfo> UnwrapSharedFunctionInfoFromJSValue(
Handle<JSValue> jsValue) {
Object* shared = jsValue->value();
CHECK(shared->IsSharedFunctionInfo());
return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(shared));
return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(shared),
jsValue->GetIsolate());
}
......@@ -622,8 +628,8 @@ void FunctionInfoWrapper::SetInitialProperties(Handle<String> name,
}
void FunctionInfoWrapper::SetSharedFunctionInfo(
Handle<SharedFunctionInfo> info) {
Handle<JSValue> info_holder = WrapInJSValue(info);
Isolate* isolate, Handle<SharedFunctionInfo> info) {
Handle<JSValue> info_holder = WrapInJSValue(isolate, info);
this->SetField(kSharedFunctionInfoOffset_, info_holder);
}
......@@ -641,7 +647,7 @@ void SharedInfoWrapper::SetProperties(Handle<String> name,
Handle<SharedFunctionInfo> info) {
HandleScope scope(isolate());
this->SetField(kFunctionNameOffset_, name);
Handle<JSValue> info_holder = WrapInJSValue(info);
Handle<JSValue> info_holder = WrapInJSValue(scope.isolate(), info);
this->SetField(kSharedInfoOffset_, info_holder);
this->SetSmiValueField(kStartPositionOffset_, start_position);
this->SetSmiValueField(kEndPositionOffset_, end_position);
......@@ -659,11 +665,9 @@ void LiveEdit::InitializeThreadLocal(Debug* debug) {
debug->thread_local_.restart_fp_ = 0;
}
MaybeHandle<JSArray> LiveEdit::GatherCompileInfo(Handle<Script> script,
MaybeHandle<JSArray> LiveEdit::GatherCompileInfo(Isolate* isolate,
Handle<Script> script,
Handle<String> source) {
Isolate* isolate = script->GetIsolate();
MaybeHandle<JSArray> infos;
Handle<Object> original_source =
Handle<Object>(script->source(), isolate);
......@@ -742,7 +746,8 @@ class FeedbackVectorFixer {
CollectJSFunctions(shared_info, isolate);
for (int i = 0; i < function_instances->length(); i++) {
Handle<JSFunction> fun(JSFunction::cast(function_instances->get(i)));
Handle<JSFunction> fun(JSFunction::cast(function_instances->get(i)),
isolate);
Handle<FeedbackCell> feedback_cell =
isolate->factory()->NewManyClosuresCell(
isolate->factory()->undefined_value());
......@@ -871,8 +876,8 @@ void LiveEdit::FunctionSourceUpdated(Handle<JSArray> shared_info_array,
shared_info_array->GetIsolate()->debug()->DeoptimizeFunction(shared_info);
}
void LiveEdit::FixupScript(Handle<Script> script, int max_function_literal_id) {
Isolate* isolate = script->GetIsolate();
void LiveEdit::FixupScript(Isolate* isolate, Handle<Script> script,
int max_function_literal_id) {
Handle<WeakFixedArray> old_infos(script->shared_function_infos(), isolate);
Handle<WeakFixedArray> new_infos(
isolate->factory()->NewWeakFixedArray(max_function_literal_id + 1));
......@@ -948,10 +953,10 @@ static int TranslatePosition(int original_position,
void TranslateSourcePositionTable(Handle<BytecodeArray> code,
Handle<JSArray> position_change_array) {
Isolate* isolate = code->GetIsolate();
Isolate* isolate = position_change_array->GetIsolate();
SourcePositionTableBuilder builder;
Handle<ByteArray> source_position_table(code->SourcePositionTable());
Handle<ByteArray> source_position_table(code->SourcePositionTable(), isolate);
for (SourcePositionTableIterator iterator(*source_position_table);
!iterator.done(); iterator.Advance()) {
SourcePosition position = iterator.source_position();
......@@ -1004,11 +1009,9 @@ void LiveEdit::PatchFunctionPositions(Handle<JSArray> shared_info_array,
}
}
static Handle<Script> CreateScriptCopy(Handle<Script> original) {
Isolate* isolate = original->GetIsolate();
Handle<String> original_source(String::cast(original->source()));
static Handle<Script> CreateScriptCopy(Isolate* isolate,
Handle<Script> original) {
Handle<String> original_source(String::cast(original->source()), isolate);
Handle<Script> copy = isolate->factory()->NewScript(original_source);
copy->set_name(original->name());
......@@ -1031,13 +1034,13 @@ static Handle<Script> CreateScriptCopy(Handle<Script> original) {
return copy;
}
Handle<Object> LiveEdit::ChangeScriptSource(Handle<Script> original_script,
Handle<Object> LiveEdit::ChangeScriptSource(Isolate* isolate,
Handle<Script> original_script,
Handle<String> new_source,
Handle<Object> old_script_name) {
Isolate* isolate = original_script->GetIsolate();
Handle<Object> old_script_object;
if (old_script_name->IsString()) {
Handle<Script> old_script = CreateScriptCopy(original_script);
Handle<Script> old_script = CreateScriptCopy(isolate, original_script);
old_script->set_name(String::cast(*old_script_name));
old_script_object = old_script;
isolate->debug()->OnAfterCompile(old_script);
......@@ -1082,7 +1085,8 @@ static bool CheckActivation(Handle<JSArray> shared_info_array,
LiveEdit::FunctionPatchabilityStatus status) {
if (!frame->is_java_script()) return false;
Handle<JSFunction> function(JavaScriptFrame::cast(frame)->function());
Handle<JSFunction> function(JavaScriptFrame::cast(frame)->function(),
frame->isolate());
Isolate* isolate = shared_info_array->GetIsolate();
int len = GetArrayLength(shared_info_array);
......@@ -1122,7 +1126,8 @@ class MultipleFunctionTarget {
bool FrameUsesNewTarget(StackFrame* frame) {
if (!frame->is_java_script()) return false;
JavaScriptFrame* jsframe = JavaScriptFrame::cast(frame);
Handle<SharedFunctionInfo> old_shared(jsframe->function()->shared());
Handle<SharedFunctionInfo> old_shared(jsframe->function()->shared(),
jsframe->isolate());
Isolate* isolate = jsframe->isolate();
int len = GetArrayLength(old_shared_array_);
// Find corresponding new shared function info and return whether it
......@@ -1310,11 +1315,9 @@ static const char* DropActivationsInActiveThread(
return nullptr;
}
bool LiveEdit::FindActiveGenerators(Handle<FixedArray> shared_info_array,
Handle<FixedArray> result,
int len) {
Isolate* isolate = shared_info_array->GetIsolate();
bool LiveEdit::FindActiveGenerators(Isolate* isolate,
Handle<FixedArray> shared_info_array,
Handle<FixedArray> result, int len) {
bool found_suspended_activations = false;
DCHECK_LE(len, result->length());
......@@ -1382,7 +1385,7 @@ Handle<JSArray> LiveEdit::CheckAndDropActivations(
DCHECK(old_shared_array->HasFastElements());
Handle<FixedArray> old_shared_array_elements(
FixedArray::cast(old_shared_array->elements()));
FixedArray::cast(old_shared_array->elements()), isolate);
Handle<JSArray> result = isolate->factory()->NewJSArray(len);
result->set_length(Smi::FromInt(len));
......@@ -1400,7 +1403,8 @@ Handle<JSArray> LiveEdit::CheckAndDropActivations(
// running (as we wouldn't want to restart them, because we don't know where
// to restart them from) or suspended. Fail if any one corresponds to the set
// of functions being edited.
if (FindActiveGenerators(old_shared_array_elements, result_elements, len)) {
if (FindActiveGenerators(isolate, old_shared_array_elements, result_elements,
len)) {
return result;
}
......@@ -1455,7 +1459,8 @@ class SingleFrameTarget {
bool FrameUsesNewTarget(StackFrame* frame) {
if (!frame->is_java_script()) return false;
JavaScriptFrame* jsframe = JavaScriptFrame::cast(frame);
Handle<SharedFunctionInfo> shared(jsframe->function()->shared());
Handle<SharedFunctionInfo> shared(jsframe->function()->shared(),
jsframe->isolate());
return shared->scope_info()->HasNewTarget();
}
......@@ -1532,7 +1537,7 @@ void LiveEditFunctionTracker::FunctionDone(Handle<SharedFunctionInfo> shared,
FunctionInfoWrapper info = FunctionInfoWrapper::cast(
*JSReceiver::GetElement(isolate_, result_, current_parent_index_)
.ToHandleChecked());
info.SetSharedFunctionInfo(shared);
info.SetSharedFunctionInfo(isolate_, shared);
Handle<Object> scope_info_list = SerializeFunctionScope(scope);
info.SetFunctionScopeInfo(scope_info_list);
......
......@@ -77,12 +77,13 @@ class LiveEdit : AllStatic {
static void InitializeThreadLocal(Debug* debug);
V8_WARN_UNUSED_RESULT static MaybeHandle<JSArray> GatherCompileInfo(
Handle<Script> script, Handle<String> source);
Isolate* isolate, Handle<Script> script, Handle<String> source);
static void ReplaceFunctionCode(Handle<JSArray> new_compile_info_array,
Handle<JSArray> shared_info_array);
static void FixupScript(Handle<Script> script, int max_function_literal_id);
static void FixupScript(Isolate* isolate, Handle<Script> script,
int max_function_literal_id);
static void FunctionSourceUpdated(Handle<JSArray> shared_info_array,
int new_function_literal_id);
......@@ -97,7 +98,8 @@ class LiveEdit : AllStatic {
// For a script updates its source field. If old_script_name is provided
// (i.e. is a String), also creates a copy of the script with its original
// source and sends notification to debugger.
static Handle<Object> ChangeScriptSource(Handle<Script> original_script,
static Handle<Object> ChangeScriptSource(Isolate* isolate,
Handle<Script> original_script,
Handle<String> new_source,
Handle<Object> old_script_name);
......@@ -110,7 +112,8 @@ class LiveEdit : AllStatic {
// Find open generator activations, and set corresponding "result" elements to
// FUNCTION_BLOCKED_ACTIVE_GENERATOR.
static bool FindActiveGenerators(Handle<FixedArray> shared_info_array,
static bool FindActiveGenerators(Isolate* isolate,
Handle<FixedArray> shared_info_array,
Handle<FixedArray> result, int len);
// Checks listed functions on stack and return array with corresponding
......@@ -141,7 +144,7 @@ class LiveEdit : AllStatic {
// Compares 2 strings line-by-line, then token-wise and returns diff in form
// of array of triplets (pos1, pos1_end, pos2_end) describing list
// of diff chunks.
static Handle<JSArray> CompareStrings(Handle<String> s1,
static Handle<JSArray> CompareStrings(Isolate* isolate, Handle<String> s1,
Handle<String> s2);
// Architecture-specific constant.
......@@ -254,7 +257,7 @@ class FunctionInfoWrapper : public JSArrayBasedStruct<FunctionInfoWrapper> {
this->SetField(kFunctionScopeInfoOffset_, scope_info_array);
}
void SetSharedFunctionInfo(Handle<SharedFunctionInfo> info);
void SetSharedFunctionInfo(Isolate* isolate, Handle<SharedFunctionInfo> info);
Handle<SharedFunctionInfo> GetSharedFunctionInfo();
......
......@@ -13721,10 +13721,10 @@ String* SharedFunctionInfo::DebugName() {
// static
SharedFunctionInfo::SideEffectState SharedFunctionInfo::GetSideEffectState(
Handle<SharedFunctionInfo> info) {
Isolate* isolate, Handle<SharedFunctionInfo> info) {
if (info->side_effect_state() == kNotComputed) {
SharedFunctionInfo::SideEffectState has_no_side_effect =
DebugEvaluate::FunctionGetSideEffectState(info);
DebugEvaluate::FunctionGetSideEffectState(isolate, info);
info->set_side_effect_state(has_no_side_effect);
}
return static_cast<SideEffectState>(info->side_effect_state());
......
......@@ -282,7 +282,8 @@ class SharedFunctionInfo : public HeapObject {
kRequiresRuntimeChecks = 2,
kHasNoSideEffect = 3,
};
static SideEffectState GetSideEffectState(Handle<SharedFunctionInfo> info);
static SideEffectState GetSideEffectState(Isolate* isolate,
Handle<SharedFunctionInfo> info);
// Used for flags such as --turbo-filter.
bool PassesFilter(const char* raw_filter);
......
......@@ -387,7 +387,8 @@ RUNTIME_FUNCTION(Runtime_GetBreakLocations) {
Handle<SharedFunctionInfo> shared(fun->shared());
// Find the number of break points
Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared);
Handle<Object> break_locations =
Debug::GetSourceBreakLocations(isolate, shared);
if (break_locations->IsUndefined(isolate)) {
return isolate->heap()->undefined_value();
}
......
......@@ -71,8 +71,8 @@ RUNTIME_FUNCTION(Runtime_LiveEditGatherCompileInfo) {
CHECK(script->value()->IsScript());
Handle<Script> script_handle(Script::cast(script->value()), isolate);
RETURN_RESULT_OR_FAILURE(isolate,
LiveEdit::GatherCompileInfo(script_handle, source));
RETURN_RESULT_OR_FAILURE(
isolate, LiveEdit::GatherCompileInfo(isolate, script_handle, source));
}
......@@ -91,7 +91,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) {
Handle<Script> original_script(Script::cast(original_script_value->value()));
Handle<Object> old_script = LiveEdit::ChangeScriptSource(
original_script, new_source, old_script_name);
isolate, original_script, new_source, old_script_name);
if (old_script->IsScript()) {
Handle<Script> script_handle = Handle<Script>::cast(old_script);
......@@ -113,7 +113,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFixupScript) {
CHECK(script_value->value()->IsScript());
Handle<Script> script(Script::cast(script_value->value()));
LiveEdit::FixupScript(script, max_function_literal_id);
LiveEdit::FixupScript(isolate, script, max_function_literal_id);
return isolate->heap()->undefined_value();
}
......@@ -257,7 +257,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditCompareStrings) {
CONVERT_ARG_HANDLE_CHECKED(String, s1, 0);
CONVERT_ARG_HANDLE_CHECKED(String, s2, 1);
Handle<JSArray> result = LiveEdit::CompareStrings(s1, s2);
Handle<JSArray> result = LiveEdit::CompareStrings(isolate, s1, s2);
uint32_t array_length = 0;
CHECK(result->length()->ToArrayLength(&array_length));
if (array_length > 0) {
......
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