Commit 37dcd837 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[debug] remove debugger context

After liveedit removed - we do not need this context any more.

R=yangguo@chromium.org
TBR=clemensh@chromium.org

Bug: v8:5530
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: Idb43d016d51b8048f6cd2ca590fd7510abcacb49
Reviewed-on: https://chromium-review.googlesource.com/1106802
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54273}
parent bb097587
...@@ -9627,9 +9627,7 @@ MaybeLocal<UnboundScript> debug::CompileInspectorScript(Isolate* v8_isolate, ...@@ -9627,9 +9627,7 @@ MaybeLocal<UnboundScript> debug::CompileInspectorScript(Isolate* v8_isolate,
void debug::SetDebugDelegate(Isolate* v8_isolate, void debug::SetDebugDelegate(Isolate* v8_isolate,
debug::DebugDelegate* delegate) { debug::DebugDelegate* delegate) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
// Might create the Debug context. isolate->debug()->SetDebugDelegate(delegate);
ENTER_V8_FOR_NEW_CONTEXT(isolate);
isolate->debug()->SetDebugDelegate(delegate, false);
} }
void debug::SetAsyncEventDelegate(Isolate* v8_isolate, void debug::SetAsyncEventDelegate(Isolate* v8_isolate,
......
...@@ -1629,7 +1629,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript( ...@@ -1629,7 +1629,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
if (extension == nullptr) { if (extension == nullptr) {
bool can_consume_code_cache = bool can_consume_code_cache =
compile_options == ScriptCompiler::kConsumeCodeCache && compile_options == ScriptCompiler::kConsumeCodeCache &&
!isolate->debug()->is_loaded(); !isolate->debug()->is_active();
if (can_consume_code_cache) { if (can_consume_code_cache) {
compile_timer.set_consuming_code_cache(); compile_timer.set_consuming_code_cache();
} }
...@@ -1720,7 +1720,7 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction( ...@@ -1720,7 +1720,7 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
MaybeHandle<SharedFunctionInfo> maybe_result; MaybeHandle<SharedFunctionInfo> maybe_result;
bool can_consume_code_cache = bool can_consume_code_cache =
compile_options == ScriptCompiler::kConsumeCodeCache && compile_options == ScriptCompiler::kConsumeCodeCache &&
!isolate->debug()->is_loaded(); !isolate->debug()->is_active();
if (can_consume_code_cache) { if (can_consume_code_cache) {
compile_timer.set_consuming_code_cache(); compile_timer.set_consuming_code_cache();
// Then check cached code provided by embedder. // Then check cached code provided by embedder.
......
...@@ -79,8 +79,7 @@ class Debug::TemporaryObjectsTracker : public HeapObjectAllocationTracker { ...@@ -79,8 +79,7 @@ class Debug::TemporaryObjectsTracker : public HeapObjectAllocationTracker {
}; };
Debug::Debug(Isolate* isolate) Debug::Debug(Isolate* isolate)
: debug_context_(Handle<Context>()), : is_active_(false),
is_active_(false),
hook_on_function_call_(false), hook_on_function_call_(false),
is_suppressed_(false), is_suppressed_(false),
break_disabled_(false), break_disabled_(false),
...@@ -392,60 +391,12 @@ DebugInfoListNode::~DebugInfoListNode() { ...@@ -392,60 +391,12 @@ DebugInfoListNode::~DebugInfoListNode() {
debug_info_ = nullptr; debug_info_ = nullptr;
} }
bool Debug::Load() {
// Return if debugger is already loaded.
if (is_loaded()) return true;
// Bail out if we're already in the process of compiling the native
// JavaScript source code for the debugger.
if (is_suppressed_) return false;
SuppressDebug while_loading(this);
// Disable breakpoints and interrupts while compiling and running the
// debugger scripts including the context creation code.
DisableBreak disable(this);
PostponeInterruptsScope postpone(isolate_);
// Create the debugger context.
HandleScope scope(isolate_);
ExtensionConfiguration no_extensions;
// TODO(yangguo): we rely on the fact that first context snapshot is usable
// as debug context. This dependency is gone once we remove
// debug context completely.
static const int kFirstContextSnapshotIndex = 0;
Handle<Context> context = isolate_->bootstrapper()->CreateEnvironment(
MaybeHandle<JSGlobalProxy>(), v8::Local<ObjectTemplate>(), &no_extensions,
kFirstContextSnapshotIndex, v8::DeserializeEmbedderFieldsCallback(),
DEBUG_CONTEXT);
// Fail if no context could be created.
if (context.is_null()) return false;
debug_context_ = isolate_->global_handles()->Create(*context);
GlobalHandles::AnnotateStrongRetainer(
Handle<Object>::cast(debug_context_).location(),
"v8::internal::Debug::debug_context_");
feature_tracker()->Track(DebugFeatureTracker::kActive);
return true;
}
void Debug::Unload() { void Debug::Unload() {
ClearAllBreakPoints(); ClearAllBreakPoints();
ClearStepping(); ClearStepping();
RemoveAllCoverageInfos(); RemoveAllCoverageInfos();
ClearAllDebuggerHints(); ClearAllDebuggerHints();
RemoveDebugDelegate(); debug_delegate_ = nullptr;
// Return debugger is not loaded.
if (!is_loaded()) return;
// Clear debugger context global handle.
GlobalHandles::Destroy(Handle<Object>::cast(debug_context_).location());
debug_context_ = Handle<Context>();
} }
void Debug::Break(JavaScriptFrame* frame, Handle<JSFunction> break_target) { void Debug::Break(JavaScriptFrame* frame, Handle<JSFunction> break_target) {
...@@ -457,7 +408,6 @@ void Debug::Break(JavaScriptFrame* frame, Handle<JSFunction> break_target) { ...@@ -457,7 +408,6 @@ void Debug::Break(JavaScriptFrame* frame, Handle<JSFunction> break_target) {
// Enter the debugger. // Enter the debugger.
DebugScope debug_scope(this); DebugScope debug_scope(this);
if (debug_scope.failed()) return;
// Postpone interrupt during breakpoint processing. // Postpone interrupt during breakpoint processing.
PostponeInterruptsScope postpone(isolate_); PostponeInterruptsScope postpone(isolate_);
...@@ -585,7 +535,6 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) { ...@@ -585,7 +535,6 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) {
Handle<DebugInfo> debug_info(function->shared()->GetDebugInfo(), isolate_); 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;
std::vector<BreakLocation> break_locations; std::vector<BreakLocation> break_locations;
BreakLocation::AllAtCurrentStatement(debug_info, frame, &break_locations); BreakLocation::AllAtCurrentStatement(debug_info, frame, &break_locations);
bool has_break_points_at_all = false; bool has_break_points_at_all = false;
...@@ -599,22 +548,6 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) { ...@@ -599,22 +548,6 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) {
return has_break_points_at_all; return has_break_points_at_all;
} }
MaybeHandle<Object> Debug::CallFunction(const char* name, int argc,
Handle<Object> args[],
MaybeHandle<Object>* maybe_exception) {
AllowJavascriptExecutionDebugOnly allow_script(isolate_);
PostponeInterruptsScope no_interrupts(isolate_);
AssertDebugContext();
Handle<JSReceiver> holder =
Handle<JSReceiver>::cast(isolate_->natives_utils_object());
Handle<JSFunction> fun = Handle<JSFunction>::cast(
JSReceiver::GetProperty(isolate_, holder, name).ToHandleChecked());
Handle<Object> undefined = isolate_->factory()->undefined_value();
return Execution::TryCall(isolate_, fun, undefined, argc, args,
Execution::MessageHandling::kReport,
maybe_exception);
}
// Check whether a single break point object is triggered. // Check whether a single break point object is triggered.
bool Debug::CheckBreakPoint(Handle<BreakPoint> break_point, bool Debug::CheckBreakPoint(Handle<BreakPoint> break_point,
bool is_break_at_entry) { bool is_break_at_entry) {
...@@ -1683,12 +1616,6 @@ void Debug::ScheduleFrameRestart(StackFrame* frame) { ...@@ -1683,12 +1616,6 @@ void Debug::ScheduleFrameRestart(StackFrame* frame) {
} }
} }
bool Debug::IsDebugGlobal(JSGlobalObject* global) {
return is_loaded() && global == debug_context()->global_object();
}
Handle<FixedArray> Debug::GetLoadedScripts() { Handle<FixedArray> Debug::GetLoadedScripts() {
isolate_->heap()->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask, isolate_->heap()->CollectAllGarbage(Heap::kFinalizeIncrementalMarkingMask,
GarbageCollectionReason::kDebugger); GarbageCollectionReason::kDebugger);
...@@ -1739,17 +1666,6 @@ void Debug::OnPromiseReject(Handle<Object> promise, Handle<Object> value) { ...@@ -1739,17 +1666,6 @@ void Debug::OnPromiseReject(Handle<Object> promise, Handle<Object> value) {
} }
} }
namespace {
v8::Local<v8::Context> GetDebugEventContext(Isolate* isolate) {
Handle<Context> context = handle(isolate->context(), 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(), isolate);
return v8::Utils::ToLocal(native_context);
}
} // anonymous namespace
bool Debug::IsExceptionBlackboxed(bool uncaught) { bool Debug::IsExceptionBlackboxed(bool uncaught) {
// Uncaught exception is blackboxed if all current frames are blackboxed, // Uncaught exception is blackboxed if all current frames are blackboxed,
// caught exception if top frame is blackboxed. // caught exception if top frame is blackboxed.
...@@ -1812,14 +1728,14 @@ void Debug::OnException(Handle<Object> exception, Handle<Object> promise) { ...@@ -1812,14 +1728,14 @@ void Debug::OnException(Handle<Object> exception, Handle<Object> promise) {
} }
DebugScope debug_scope(this); DebugScope debug_scope(this);
if (debug_scope.failed()) return;
HandleScope scope(isolate_); HandleScope scope(isolate_);
PostponeInterruptsScope postpone(isolate_); PostponeInterruptsScope postpone(isolate_);
DisableBreak no_recursive_break(this); DisableBreak no_recursive_break(this);
debug_delegate_->ExceptionThrown( Handle<Context> native_context(isolate_->native_context());
GetDebugEventContext(isolate_), debug_delegate_->ExceptionThrown(v8::Utils::ToLocal(native_context),
v8::Utils::ToLocal(exception), v8::Utils::ToLocal(promise), uncaught); v8::Utils::ToLocal(exception),
v8::Utils::ToLocal(promise), uncaught);
} }
void Debug::OnDebugBreak(Handle<FixedArray> break_points_hit) { void Debug::OnDebugBreak(Handle<FixedArray> break_points_hit) {
...@@ -1847,9 +1763,9 @@ void Debug::OnDebugBreak(Handle<FixedArray> break_points_hit) { ...@@ -1847,9 +1763,9 @@ void Debug::OnDebugBreak(Handle<FixedArray> break_points_hit) {
++inspector_break_points_count; ++inspector_break_points_count;
} }
debug_delegate_->BreakProgramRequested( Handle<Context> native_context(isolate_->native_context());
GetDebugEventContext(isolate_), debug_delegate_->BreakProgramRequested(v8::Utils::ToLocal(native_context),
inspector_break_points_hit); inspector_break_points_hit);
} }
namespace { namespace {
...@@ -1940,7 +1856,6 @@ void Debug::ProcessCompileEvent(bool has_compile_error, Handle<Script> script) { ...@@ -1940,7 +1856,6 @@ void Debug::ProcessCompileEvent(bool has_compile_error, Handle<Script> script) {
if (!debug_delegate_) return; if (!debug_delegate_) return;
SuppressDebug while_processing(this); SuppressDebug while_processing(this);
DebugScope debug_scope(this); DebugScope debug_scope(this);
if (debug_scope.failed()) return;
HandleScope scope(isolate_); HandleScope scope(isolate_);
PostponeInterruptsScope postpone(isolate_); PostponeInterruptsScope postpone(isolate_);
DisableBreak no_recursive_break(this); DisableBreak no_recursive_break(this);
...@@ -1949,14 +1864,6 @@ void Debug::ProcessCompileEvent(bool has_compile_error, Handle<Script> script) { ...@@ -1949,14 +1864,6 @@ void Debug::ProcessCompileEvent(bool has_compile_error, Handle<Script> script) {
running_live_edit_, has_compile_error); running_live_edit_, has_compile_error);
} }
Handle<Context> Debug::GetDebugContext() {
if (!is_loaded()) return Handle<Context>();
DebugScope debug_scope(this);
if (debug_scope.failed()) return Handle<Context>();
// The global handle may be destroyed soon after. Return it reboxed.
return handle(*debug_context(), isolate_);
}
int Debug::CurrentFrameCount() { int Debug::CurrentFrameCount() {
StackTraceFrameIterator it(isolate_); StackTraceFrameIterator it(isolate_);
if (break_frame_id() != StackFrame::NO_ID) { if (break_frame_id() != StackFrame::NO_ID) {
...@@ -1978,31 +1885,21 @@ int Debug::CurrentFrameCount() { ...@@ -1978,31 +1885,21 @@ int Debug::CurrentFrameCount() {
return counter; return counter;
} }
void Debug::SetDebugDelegate(debug::DebugDelegate* delegate, void Debug::SetDebugDelegate(debug::DebugDelegate* delegate) {
bool pass_ownership) {
RemoveDebugDelegate();
debug_delegate_ = delegate; debug_delegate_ = delegate;
owns_debug_delegate_ = pass_ownership;
UpdateState(); UpdateState();
} }
void Debug::RemoveDebugDelegate() {
if (debug_delegate_ == nullptr) return;
if (owns_debug_delegate_) {
owns_debug_delegate_ = false;
delete debug_delegate_;
}
debug_delegate_ = nullptr;
}
void Debug::UpdateState() { void Debug::UpdateState() {
bool is_active = debug_delegate_ != nullptr; bool is_active = debug_delegate_ != nullptr;
if (is_active || in_debug_scope()) { if (is_active == is_active_) return;
if (is_active) {
// Note that the debug context could have already been loaded to // Note that the debug context could have already been loaded to
// bootstrap test cases. // bootstrap test cases.
isolate_->compilation_cache()->Disable(); isolate_->compilation_cache()->Disable();
is_active = Load(); is_active = true;
} else if (is_loaded()) { feature_tracker()->Track(DebugFeatureTracker::kActive);
} else {
isolate_->compilation_cache()->Enable(); isolate_->compilation_cache()->Enable();
Unload(); Unload();
} }
...@@ -2045,9 +1942,6 @@ void Debug::HandleDebugBreak(IgnoreBreakMode ignore_break_mode) { ...@@ -2045,9 +1942,6 @@ void Debug::HandleDebugBreak(IgnoreBreakMode ignore_break_mode) {
? IsBlackboxed(shared) ? IsBlackboxed(shared)
: AllFramesOnStackAreBlackboxed(); : AllFramesOnStackAreBlackboxed();
if (ignore_break) return; if (ignore_break) return;
JSGlobalObject* global = function->context()->global_object();
// Don't stop in debugger functions.
if (IsDebugGlobal(global)) return;
// Don't stop if the break location is muted. // Don't stop if the break location is muted.
if (IsMutedAtCurrentLocation(it.frame())) return; if (IsMutedAtCurrentLocation(it.frame())) return;
} }
...@@ -2058,7 +1952,6 @@ void Debug::HandleDebugBreak(IgnoreBreakMode ignore_break_mode) { ...@@ -2058,7 +1952,6 @@ void Debug::HandleDebugBreak(IgnoreBreakMode ignore_break_mode) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
DebugScope debug_scope(this); DebugScope debug_scope(this);
if (debug_scope.failed()) return;
OnDebugBreak(isolate_->factory()->empty_fixed_array()); OnDebugBreak(isolate_->factory()->empty_fixed_array());
} }
...@@ -2125,9 +2018,6 @@ DebugScope::DebugScope(Debug* debug) ...@@ -2125,9 +2018,6 @@ DebugScope::DebugScope(Debug* debug)
debug_->SetNextBreakId(); debug_->SetNextBreakId();
debug_->UpdateState(); debug_->UpdateState();
// Make sure that debugger is loaded and enter the debugger context.
// The previous context is kept in save_.
failed_ = !debug_->is_loaded();
} }
......
...@@ -224,11 +224,8 @@ class Debug { ...@@ -224,11 +224,8 @@ class Debug {
void OnCompileError(Handle<Script> script); void OnCompileError(Handle<Script> script);
void OnAfterCompile(Handle<Script> script); void OnAfterCompile(Handle<Script> script);
Handle<Context> GetDebugContext();
void HandleDebugBreak(IgnoreBreakMode ignore_break_mode); void HandleDebugBreak(IgnoreBreakMode ignore_break_mode);
// Internal logic
bool Load();
// The break target may not be the top-most frame, since we may be // The break target may not be the top-most frame, since we may be
// breaking before entering a function that cannot contain break points. // breaking before entering a function that cannot contain break points.
void Break(JavaScriptFrame* frame, Handle<JSFunction> break_target); void Break(JavaScriptFrame* frame, Handle<JSFunction> break_target);
...@@ -276,7 +273,7 @@ class Debug { ...@@ -276,7 +273,7 @@ class Debug {
bool CanBreakAtEntry(Handle<SharedFunctionInfo> shared); bool CanBreakAtEntry(Handle<SharedFunctionInfo> shared);
void SetDebugDelegate(debug::DebugDelegate* delegate, bool pass_ownership); void SetDebugDelegate(debug::DebugDelegate* delegate);
// Returns whether the operation succeeded. // Returns whether the operation succeeded.
bool EnsureBreakInfo(Handle<SharedFunctionInfo> shared); bool EnsureBreakInfo(Handle<SharedFunctionInfo> shared);
...@@ -287,9 +284,6 @@ class Debug { ...@@ -287,9 +284,6 @@ class Debug {
Handle<CoverageInfo> coverage_info); Handle<CoverageInfo> coverage_info);
void RemoveAllCoverageInfos(); void RemoveAllCoverageInfos();
template <typename C>
bool CompileToRevealInnerFunctions(C* compilable);
// This function is used in FunctionNameUsing* tests. // This function is used in FunctionNameUsing* tests.
Handle<Object> FindSharedFunctionInfoInScript(Handle<Script> script, Handle<Object> FindSharedFunctionInfoInScript(Handle<Script> script,
int position); int position);
...@@ -297,9 +291,6 @@ class Debug { ...@@ -297,9 +291,6 @@ class Debug {
static Handle<Object> GetSourceBreakLocations( static Handle<Object> GetSourceBreakLocations(
Isolate* isolate, Handle<SharedFunctionInfo> shared); Isolate* isolate, Handle<SharedFunctionInfo> shared);
// Check whether a global object is the debug global object.
bool IsDebugGlobal(JSGlobalObject* global);
// Check whether this frame is just about to return. // Check whether this frame is just about to return.
bool IsBreakAtReturn(JavaScriptFrame* frame); bool IsBreakAtReturn(JavaScriptFrame* frame);
...@@ -324,9 +315,7 @@ class Debug { ...@@ -324,9 +315,7 @@ class Debug {
void FreeThreadResources() { } void FreeThreadResources() { }
void Iterate(RootVisitor* v); void Iterate(RootVisitor* v);
bool CheckExecutionState() { bool CheckExecutionState() { return is_active() && break_id() != 0; }
return is_active() && !debug_context().is_null() && break_id() != 0;
}
void StartSideEffectCheckMode(); void StartSideEffectCheckMode();
void StopSideEffectCheckMode(); void StopSideEffectCheckMode();
...@@ -345,10 +334,8 @@ class Debug { ...@@ -345,10 +334,8 @@ class Debug {
return reinterpret_cast<DebugScope*>( return reinterpret_cast<DebugScope*>(
base::Relaxed_Load(&thread_local_.current_debug_scope_)); base::Relaxed_Load(&thread_local_.current_debug_scope_));
} }
inline Handle<Context> debug_context() { return debug_context_; }
inline bool is_active() const { return is_active_; } inline bool is_active() const { return is_active_; }
inline bool is_loaded() const { return !debug_context_.is_null(); }
inline bool in_debug_scope() const { inline bool in_debug_scope() const {
return !!base::Relaxed_Load(&thread_local_.current_debug_scope_); return !!base::Relaxed_Load(&thread_local_.current_debug_scope_);
} }
...@@ -405,7 +392,6 @@ class Debug { ...@@ -405,7 +392,6 @@ class Debug {
void UpdateDebugInfosForExecutionMode(); void UpdateDebugInfosForExecutionMode();
void UpdateState(); void UpdateState();
void UpdateHookOnFunctionCall(); void UpdateHookOnFunctionCall();
void RemoveDebugDelegate();
void Unload(); void Unload();
void SetNextBreakId() { void SetNextBreakId() {
thread_local_.break_id_ = ++thread_local_.break_count_; thread_local_.break_id_ = ++thread_local_.break_count_;
...@@ -458,9 +444,6 @@ class Debug { ...@@ -458,9 +444,6 @@ class Debug {
// Check whether a BreakPoint object is hit. Evaluate condition depending // Check whether a BreakPoint object is hit. Evaluate condition depending
// on whether this is a regular break location or a break at function entry. // on whether this is a regular break location or a break at function entry.
bool CheckBreakPoint(Handle<BreakPoint> break_point, bool is_break_at_entry); bool CheckBreakPoint(Handle<BreakPoint> break_point, bool is_break_at_entry);
MaybeHandle<Object> CallFunction(const char* name, int argc,
Handle<Object> args[],
MaybeHandle<Object>* maybe_exception);
inline void AssertDebugContext() { inline void AssertDebugContext() {
DCHECK(in_debug_scope()); DCHECK(in_debug_scope());
...@@ -480,11 +463,7 @@ class Debug { ...@@ -480,11 +463,7 @@ class Debug {
DebugInfoListNode** curr); DebugInfoListNode** curr);
void FreeDebugInfoListNode(DebugInfoListNode* prev, DebugInfoListNode* node); void FreeDebugInfoListNode(DebugInfoListNode* prev, DebugInfoListNode* node);
// Global handles.
Handle<Context> debug_context_;
debug::DebugDelegate* debug_delegate_ = nullptr; debug::DebugDelegate* debug_delegate_ = nullptr;
bool owns_debug_delegate_ = false;
// Debugger is active, i.e. there is a debug event listener attached. // Debugger is active, i.e. there is a debug event listener attached.
bool is_active_; bool is_active_;
...@@ -579,7 +558,6 @@ class Debug { ...@@ -579,7 +558,6 @@ class Debug {
friend class DisableBreak; friend class DisableBreak;
friend class LiveEdit; friend class LiveEdit;
friend class SuppressDebug; friend class SuppressDebug;
friend class NoSideEffectScope;
friend Handle<FixedArray> GetDebuggedFunctions(); // In test-debug.cc friend Handle<FixedArray> GetDebuggedFunctions(); // In test-debug.cc
friend void CheckDebuggerUnloaded(); // In test-debug.cc friend void CheckDebuggerUnloaded(); // In test-debug.cc
...@@ -589,15 +567,11 @@ class Debug { ...@@ -589,15 +567,11 @@ class Debug {
// This scope is used to load and enter the debug context and create a new // This scope is used to load and enter the debug context and create a new
// break state. Leaving the scope will restore the previous state. // break state. Leaving the scope will restore the previous state.
// On failure to load, FailedToEnter returns true.
class DebugScope BASE_EMBEDDED { class DebugScope BASE_EMBEDDED {
public: public:
explicit DebugScope(Debug* debug); explicit DebugScope(Debug* debug);
~DebugScope(); ~DebugScope();
// Check whether loading was successful.
inline bool failed() { return failed_; }
private: private:
Isolate* isolate() { return debug_->isolate_; } Isolate* isolate() { return debug_->isolate_; }
...@@ -605,7 +579,6 @@ class DebugScope BASE_EMBEDDED { ...@@ -605,7 +579,6 @@ class DebugScope BASE_EMBEDDED {
DebugScope* prev_; // Previous scope if entered recursively. DebugScope* prev_; // Previous scope if entered recursively.
StackFrame::Id break_frame_id_; // Previous break frame id. StackFrame::Id break_frame_id_; // Previous break frame id.
int break_id_; // Previous break id. int break_id_; // Previous break id.
bool failed_; // Did the debug context fail to load?
PostponeInterruptsScope no_termination_exceptons_; PostponeInterruptsScope no_termination_exceptons_;
}; };
......
...@@ -2245,24 +2245,8 @@ void Isolate::SetAbortOnUncaughtExceptionCallback( ...@@ -2245,24 +2245,8 @@ void Isolate::SetAbortOnUncaughtExceptionCallback(
abort_on_uncaught_exception_callback_ = callback; abort_on_uncaught_exception_callback_ = callback;
} }
namespace {
void AdvanceWhileDebugContext(JavaScriptFrameIterator& it, Debug* debug) {
if (!debug->in_debug_scope()) return;
while (!it.done()) {
Context* context = Context::cast(it.frame()->context());
if (context->native_context() == *debug->debug_context()) {
it.Advance();
} else {
break;
}
}
}
} // namespace
Handle<Context> Isolate::GetCallingNativeContext() { Handle<Context> Isolate::GetCallingNativeContext() {
JavaScriptFrameIterator it(this); JavaScriptFrameIterator it(this);
AdvanceWhileDebugContext(it, debug_);
if (it.done()) return Handle<Context>::null(); if (it.done()) return Handle<Context>::null();
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
Context* context = Context::cast(frame->context()); Context* context = Context::cast(frame->context());
...@@ -2271,7 +2255,6 @@ Handle<Context> Isolate::GetCallingNativeContext() { ...@@ -2271,7 +2255,6 @@ Handle<Context> Isolate::GetCallingNativeContext() {
Handle<Context> Isolate::GetIncumbentContext() { Handle<Context> Isolate::GetIncumbentContext() {
JavaScriptFrameIterator it(this); JavaScriptFrameIterator it(this);
AdvanceWhileDebugContext(it, debug_);
// 1st candidate: most-recently-entered author function's context // 1st candidate: most-recently-entered author function's context
// if it's newer than the last Context::BackupIncumbentScope entry. // if it's newer than the last Context::BackupIncumbentScope entry.
......
...@@ -1850,7 +1850,6 @@ void V8HeapExplorer::SetGcSubrootReference(Root root, const char* description, ...@@ -1850,7 +1850,6 @@ void V8HeapExplorer::SetGcSubrootReference(Root root, const char* description,
JSGlobalObject* global = Context::cast(child_obj)->global_object(); JSGlobalObject* global = Context::cast(child_obj)->global_object();
if (!global->IsJSGlobalObject()) return; if (!global->IsJSGlobalObject()) return;
if (heap_->isolate()->debug()->IsDebugGlobal(global)) return;
if (user_roots_.Contains(global)) return; if (user_roots_.Contains(global)) return;
user_roots_.Insert(global); user_roots_.Insert(global);
......
...@@ -418,10 +418,6 @@ RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { ...@@ -418,10 +418,6 @@ RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) {
Handle<FixedArray> instances; Handle<FixedArray> instances;
{ {
DebugScope debug_scope(isolate->debug()); DebugScope debug_scope(isolate->debug());
if (debug_scope.failed()) {
DCHECK(isolate->has_pending_exception());
return ReadOnlyRoots(isolate).exception();
}
// Fill the script objects. // Fill the script objects.
instances = isolate->debug()->GetLoadedScripts(); instances = isolate->debug()->GetLoadedScripts();
} }
...@@ -455,24 +451,6 @@ RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { ...@@ -455,24 +451,6 @@ RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) {
} }
RUNTIME_FUNCTION(Runtime_GetDebugContext) {
HandleScope scope(isolate);
DCHECK_EQ(0, args.length());
Handle<Context> context;
{
DebugScope debug_scope(isolate->debug());
if (debug_scope.failed()) {
DCHECK(isolate->has_pending_exception());
return ReadOnlyRoots(isolate).exception();
}
context = isolate->debug()->GetDebugContext();
}
if (context.is_null()) return ReadOnlyRoots(isolate).undefined_value();
context->set_security_token(isolate->native_context()->security_token());
return context->global_proxy();
}
// Performs a GC. // Performs a GC.
// Presently, it only does a full GC. // Presently, it only does a full GC.
RUNTIME_FUNCTION(Runtime_CollectGarbage) { RUNTIME_FUNCTION(Runtime_CollectGarbage) {
......
...@@ -141,7 +141,6 @@ namespace internal { ...@@ -141,7 +141,6 @@ namespace internal {
F(DebugTogglePreciseCoverage, 1, 1) \ F(DebugTogglePreciseCoverage, 1, 1) \
F(FunctionGetInferredName, 1, 1) \ F(FunctionGetInferredName, 1, 1) \
F(GetBreakLocations, 1, 1) \ F(GetBreakLocations, 1, 1) \
F(GetDebugContext, 0, 1) \
F(GetGeneratorScopeCount, 1, 1) \ F(GetGeneratorScopeCount, 1, 1) \
F(GetGeneratorScopeDetails, 2, 1) \ F(GetGeneratorScopeDetails, 2, 1) \
F(GetHeapUsage, 0, 1) \ F(GetHeapUsage, 0, 1) \
......
...@@ -57,7 +57,7 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize( ...@@ -57,7 +57,7 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize(
// TODO(7110): Enable serialization of Asm modules once the AsmWasmData is // TODO(7110): Enable serialization of Asm modules once the AsmWasmData is
// context independent. // context independent.
if (script->ContainsAsmModule()) return nullptr; if (script->ContainsAsmModule()) return nullptr;
if (isolate->debug()->is_loaded()) return nullptr; if (isolate->debug()->is_active()) return nullptr;
isolate->heap()->read_only_space()->ClearStringPaddingIfNeeded(); isolate->heap()->read_only_space()->ClearStringPaddingIfNeeded();
......
...@@ -299,8 +299,6 @@ class InterpreterHandle { ...@@ -299,8 +299,6 @@ class InterpreterHandle {
void NotifyDebugEventListeners(WasmInterpreter::Thread* thread) { void NotifyDebugEventListeners(WasmInterpreter::Thread* thread) {
// Enter the debugger. // Enter the debugger.
DebugScope debug_scope(isolate_->debug()); DebugScope debug_scope(isolate_->debug());
if (debug_scope.failed()) return;
// Postpone interrupt during breakpoint processing. // Postpone interrupt during breakpoint processing.
PostponeInterruptsScope postpone(isolate_); PostponeInterruptsScope postpone(isolate_);
......
...@@ -156,7 +156,6 @@ Handle<FixedArray> GetDebuggedFunctions() { ...@@ -156,7 +156,6 @@ Handle<FixedArray> GetDebuggedFunctions() {
void CheckDebuggerUnloaded() { void CheckDebuggerUnloaded() {
// Check that the debugger context is cleared and that there is no debug // Check that the debugger context is cleared and that there is no debug
// information stored for the debugger. // information stored for the debugger.
CHECK(CcTest::i_isolate()->debug()->debug_context().is_null());
CHECK(!CcTest::i_isolate()->debug()->debug_info_list_); CHECK(!CcTest::i_isolate()->debug()->debug_info_list_);
// Collect garbage to ensure weak handles are cleared. // Collect garbage to ensure weak handles are cleared.
...@@ -2670,7 +2669,7 @@ TEST(PauseInScript) { ...@@ -2670,7 +2669,7 @@ TEST(PauseInScript) {
// Register a debug event listener which counts. // Register a debug event listener which counts.
DebugEventCounter event_counter; DebugEventCounter event_counter;
SetDebugDelegate(env->GetIsolate(), &event_counter); v8::debug::SetDebugDelegate(env->GetIsolate(), &event_counter);
v8::Local<v8::Context> context = env.local(); v8::Local<v8::Context> context = env.local();
// Create a script that returns a function. // Create a script that returns a function.
...@@ -3041,8 +3040,6 @@ TEST(DebugScriptLineEndsAreAscending) { ...@@ -3041,8 +3040,6 @@ TEST(DebugScriptLineEndsAreAscending) {
Handle<v8::internal::FixedArray> instances; Handle<v8::internal::FixedArray> instances;
{ {
v8::internal::Debug* debug = CcTest::i_isolate()->debug(); v8::internal::Debug* debug = CcTest::i_isolate()->debug();
v8::internal::DebugScope debug_scope(debug);
CHECK(!debug_scope.failed());
instances = debug->GetLoadedScripts(); instances = debug->GetLoadedScripts();
} }
...@@ -3632,35 +3629,6 @@ TEST(Regress131642) { ...@@ -3632,35 +3629,6 @@ TEST(Regress131642) {
v8::debug::SetDebugDelegate(env->GetIsolate(), nullptr); v8::debug::SetDebugDelegate(env->GetIsolate(), nullptr);
} }
// Import from test-heap.cc
namespace v8 {
namespace internal {
namespace heap {
int CountNativeContexts();
} // namespace heap
} // namespace internal
} // namespace v8
class NopListener : public v8::debug::DebugDelegate {};
TEST(DebuggerCreatesContextIffActive) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
CHECK_EQ(1, v8::internal::heap::CountNativeContexts());
v8::debug::SetDebugDelegate(env->GetIsolate(), nullptr);
CompileRun("debugger;");
CHECK_EQ(1, v8::internal::heap::CountNativeContexts());
NopListener delegate;
v8::debug::SetDebugDelegate(env->GetIsolate(), &delegate);
CompileRun("debugger;");
CHECK_EQ(2, v8::internal::heap::CountNativeContexts());
v8::debug::SetDebugDelegate(env->GetIsolate(), nullptr);
}
class DebugBreakStackTraceListener : public v8::debug::DebugDelegate { class DebugBreakStackTraceListener : public v8::debug::DebugDelegate {
public: public:
void BreakProgramRequested(v8::Local<v8::Context> paused_context, void BreakProgramRequested(v8::Local<v8::Context> paused_context,
......
...@@ -2185,31 +2185,6 @@ TEST(SfiAndJsFunctionWeakRefs) { ...@@ -2185,31 +2185,6 @@ TEST(SfiAndJsFunctionWeakRefs) {
} }
TEST(NoDebugObjectInSnapshot) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
CHECK(CcTest::i_isolate()->debug()->Load());
CompileRun("foo = {};");
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
CHECK(ValidateSnapshot(snapshot));
const v8::HeapGraphNode* root = snapshot->GetRoot();
int globals_count = 0;
for (int i = 0; i < root->GetChildrenCount(); ++i) {
const v8::HeapGraphEdge* edge = root->GetChild(i);
if (edge->GetType() == v8::HeapGraphEdge::kShortcut) {
++globals_count;
const v8::HeapGraphNode* global = edge->GetToNode();
const v8::HeapGraphNode* foo = GetProperty(
env->GetIsolate(), global, v8::HeapGraphEdge::kProperty, "foo");
CHECK(foo);
}
}
CHECK_EQ(1, globals_count);
}
TEST(AllStrongGcRootsHaveNames) { TEST(AllStrongGcRootsHaveNames) {
LocalContext env; LocalContext env;
v8::HandleScope scope(env->GetIsolate()); v8::HandleScope scope(env->GetIsolate());
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --stress-compaction --verify-heap
// Flags: --stack-size=100
// Load the debug context to fill up code space.
%GetDebugContext();
%GetDebugContext();
// Recurse and run regexp code.
assertThrows(function f() { f(/./.test("a")); }, RangeError);
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --stack-size=100 --allow-natives-syntax
var count = 0;
function f() {
try {
f();
} catch(e) {
if (count < 100) {
count++;
%GetDebugContext();
}
}
}
f();
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --opt --no-always-opt
assertSame = function assertSame() {
if (found === expected) {
if (1 / expected) return;
} else if ((expected !== expected) && (found !== found)) {
return;
};
};
assertEquals = function assertEquals() {
if (expected) {;
}
};
assertArrayEquals = function assertArrayEquals() {
var start = "";
if (name_opt) {
start = name_opt + " - ";
};
if (expected.length == found.length) {
for (var i = 0; i < expected.length; ++i) {;
}
}
};
assertPropertiesEqual = function assertPropertiesEqual() {
if (found) {;
}
};
assertToStringEquals = function assertToStringEquals() {
if (found) {;
}
};
assertTrue = function assertTrue() {;
};
assertFalse = function assertFalse() {;
};
assertUnreachable = function assertUnreachable() {
var message = "Fail" + "ure: unreachable";
if (name_opt) {
message += " - " + name_opt;
}
};
OptimizationStatus = function() {}
assertUnoptimized = function assertUnoptimized() {;
}
assertOptimized = function assertOptimized() {;
}
triggerAssertFalse = function() {}
var __v_2 = {};
var __v_3 = {};
var __v_4 = {};
var __v_5 = {};
var __v_6 = 1073741823;
var __v_7 = {};
var __v_8 = {};
var __v_9 = {};
var __v_10 = {};
var __v_11 = 2147483648;
var __v_12 = 1073741823;
var __v_13 = {};
var __v_14 = {};
var __v_15 = -2147483648;
var __v_16 = {};
var __v_17 = {};
var __v_19 = {};
var __v_20 = {};
var __v_21 = {};
var __v_22 = {};
var __v_23 = {};
var __v_24 = {};
try {
(function() {
var Debug = %GetDebugContext().Debug;
function __f_0() {}
for (var __v_0 = 0; __v_0 < 3; __v_0++) {
var __v_2 = function() {
a = 1;
}
Debug.setListener(__f_0);
if (__v_0 < 2) Debug.setBreakPoint(__v_2);
}
})();
} catch (e) {
print();
}
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