Index: src/debug/debug.cc |
diff --git a/src/debug/debug.cc b/src/debug/debug.cc |
index d6b4ebb62271092029783e50cdad6c6e698ea53c..9e7fc53ae8cdf8354cb1c6eb8efe565bd9212687 100644 |
--- a/src/debug/debug.cc |
+++ b/src/debug/debug.cc |
@@ -1377,6 +1377,7 @@ class SharedFunctionInfoFinder { |
target_position_(target_position) {} |
void NewCandidate(SharedFunctionInfo* shared, JSFunction* closure = NULL) { |
+ if (!shared->IsSubjectToDebugging()) return; |
int start_position = shared->function_token_position(); |
if (start_position == RelocInfo::kNoPosition) { |
start_position = shared->start_position(); |
@@ -1426,7 +1427,7 @@ class SharedFunctionInfoFinder { |
// cannot be compiled without context (need to find outer compilable SFI etc.) |
Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, |
int position) { |
- while (true) { |
+ for (int iteration = 0;; iteration++) { |
// Go through all shared function infos associated with this script to |
// find the inner most function containing this position. |
// If there is no shared function info for this script at all, there is |
@@ -1444,7 +1445,18 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, |
shared = finder.Result(); |
if (shared == NULL) break; |
// We found it if it's already compiled and has debug code. |
- if (shared->HasDebugCode()) return handle(shared); |
+ if (shared->HasDebugCode()) { |
+ Handle<SharedFunctionInfo> shared_handle(shared); |
+ // If the iteration count is larger than 1, we had to compile the outer |
+ // function in order to create this shared function info. So there can |
+ // be no JSFunction referencing it. We can anticipate creating a debug |
+ // info while bypassing PrepareFunctionForBreakpoints. |
+ if (iteration > 1) { |
+ AllowHeapAllocation allow_before_return; |
+ CreateDebugInfo(shared_handle); |
+ } |
+ return shared_handle; |
+ } |
} |
// If not, compile to reveal inner functions, if possible. |
if (shared->allows_lazy_compilation_without_context()) { |
@@ -1509,6 +1521,13 @@ bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, |
shared->code()->ClearInlineCaches(); |
shared->ClearTypeFeedbackInfo(); |
+ CreateDebugInfo(shared); |
+ |
+ return true; |
+} |
+ |
+ |
+void Debug::CreateDebugInfo(Handle<SharedFunctionInfo> shared) { |
// Create the debug info object. |
DCHECK(shared->HasDebugCode()); |
Handle<DebugInfo> debug_info = isolate_->factory()->NewDebugInfo(shared); |
@@ -1517,8 +1536,6 @@ bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, |
DebugInfoListNode* node = new DebugInfoListNode(*debug_info); |
node->set_next(debug_info_list_); |
debug_info_list_ = node; |
- |
- return true; |
} |