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