From 44af1850239036d8ee5a173dad8048c73e72cf5e Mon Sep 17 00:00:00 2001 From: "rmcilroy@chromium.org" Date: Thu, 8 May 2014 18:00:26 +0000 Subject: [PATCH] Restore behavior of PrepareForBreakpoints which was broken by r21145. Rename Debug::MaybeRecompileFunctionForDebugging to EnsureFunctionHasDebugBreakSlots and ensure that it does nothing if the function is unoptimized code with debug break slots, otherwise, if the shared code has no debug break slots, it recompile that shared code and sets the function code to that shared code. Also removes two incorrect ASSERTs. R=yangguo@chromium.org Review URL: https://codereview.chromium.org/271873003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21201 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/debug.cc | 31 +++++++++++++++++++------------ src/debug.h | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/debug.cc b/src/debug.cc index 6ec7ad6..4e633c9 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -2037,18 +2037,25 @@ class ForceDebuggerActive { }; -void Debug::MaybeRecompileFunctionForDebugging(Handle function) { - ASSERT_EQ(Code::FUNCTION, function->code()->kind()); - ASSERT_EQ(function->code(), function->shared()->code()); +void Debug::EnsureFunctionHasDebugBreakSlots(Handle function) { + if (function->code()->kind() == Code::FUNCTION && + function->code()->has_debug_break_slots()) { + // Nothing to do. Function code already had debug break slots. + return; + } - if (function->code()->has_debug_break_slots()) return; + // Make sure that the shared full code is compiled with debug + // break slots. + if (!function->shared()->code()->has_debug_break_slots()) { + ForceDebuggerActive force_debugger_active(isolate_); + MaybeHandle code = Compiler::GetCodeForDebugging(function); + // Recompilation can fail. In that case leave the code as it was. + if (!code.is_null()) + function->ReplaceCode(*code.ToHandleChecked()); + } - ForceDebuggerActive force_debugger_active(isolate_); - MaybeHandle code = Compiler::GetCodeForDebugging(function); - // Recompilation can fail. In that case leave the code as it was. - if (!code.is_null()) - function->ReplaceCode(*code.ToHandleChecked()); - ASSERT_EQ(function->code(), function->shared()->code()); + // Keep function code in sync with shared function info. + function->ReplaceCode(function->shared()->code()); } @@ -2057,7 +2064,7 @@ void Debug::RecompileAndRelocateSuspendedGenerators( for (int i = 0; i < generators.length(); i++) { Handle fun(generators[i]->function()); - MaybeRecompileFunctionForDebugging(fun); + EnsureFunctionHasDebugBreakSlots(fun); int code_offset = generators[i]->continuation(); int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); @@ -2217,7 +2224,7 @@ void Debug::PrepareForBreakPoints() { if (!shared->allows_lazy_compilation()) continue; if (shared->code()->kind() == Code::BUILTIN) continue; - MaybeRecompileFunctionForDebugging(function); + EnsureFunctionHasDebugBreakSlots(function); } RedirectActivationsToRecompiledCodeOnThread(isolate_, diff --git a/src/debug.h b/src/debug.h index 4d7b5c3..21fcb51 100644 --- a/src/debug.h +++ b/src/debug.h @@ -511,7 +511,7 @@ class Debug { Handle CheckBreakPoints(Handle break_point); bool CheckBreakPoint(Handle break_point_object); - void MaybeRecompileFunctionForDebugging(Handle function); + void EnsureFunctionHasDebugBreakSlots(Handle function); void RecompileAndRelocateSuspendedGenerators( const List > &suspended_generators); -- 2.7.4