Reviewers: Michael Starzinger,
Description:
Debugger: correctly find closure to recompile eval for debugging.
[email protected]
BUG=chromium:517592
LOG=N
Please review this at https://codereview.chromium.org/1285793002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+48, -4 lines):
M src/compiler.cc
M src/debug/debug.cc
A test/mjsunit/regress/regress-crbug-517592.js
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
ede006c04cf27d7cfb4709a31c554efb809a2bc0..a53b42fa0ae00f20931de2b8b96345f9d0361aff
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1016,11 +1016,16 @@ bool CompileForDebugging(CompilationInfo* info) {
}
+static inline bool IsEvalToplevel(Handle<SharedFunctionInfo> shared) {
+ return shared->is_toplevel() && shared->script()->IsScript() &&
+ Script::cast(shared->script())->compilation_type() ==
+ Script::COMPILATION_TYPE_EVAL;
+}
+
+
bool Compiler::CompileDebugCode(Handle<JSFunction> function) {
Handle<SharedFunctionInfo> shared(function->shared());
- if (shared->is_toplevel() && shared->script()->IsScript() &&
- Script::cast(shared->script())->compilation_type() ==
- Script::COMPILATION_TYPE_EVAL) {
+ if (IsEvalToplevel(shared)) {
return CompileEvalForDebugging(function, shared);
} else {
CompilationInfoWithZone info(function);
@@ -1031,6 +1036,7 @@ bool Compiler::CompileDebugCode(Handle<JSFunction>
function) {
bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) {
DCHECK(shared->allows_lazy_compilation_without_context());
+ DCHECK(!IsEvalToplevel(shared));
Zone zone;
ParseInfo parse_info(&zone, shared);
CompilationInfo info(&parse_info);
Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index
891c92e59e30a28492d0ea6d2554db9aa367f4b0..55837342eb9e9547ea300f6d331fbe519ddfc1b9
100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -1528,10 +1528,12 @@ class SharedFunctionInfoFinder {
if (current_candidate_ != NULL) {
if (current_start_position_ == start_position &&
shared->end_position() == current_candidate_->end_position()) {
+ // If we already have a matching closure, do not throw it away.
+ if (current_candidate_closure_ != NULL && closure == NULL) return;
// If a top-level function contains only one function
// declaration the source for the top-level and the function
// is the same. In that case prefer the non top-level function.
- if (shared->is_toplevel()) return;
+ if (!current_candidate_->is_toplevel() && shared->is_toplevel())
return;
} else if (start_position < current_start_position_ ||
current_candidate_->end_position() <
shared->end_position()) {
return;
Index: test/mjsunit/regress/regress-crbug-517592.js
diff --git a/test/mjsunit/regress/regress-crbug-517592.js
b/test/mjsunit/regress/regress-crbug-517592.js
new file mode 100644
index
0000000000000000000000000000000000000000..760d8924397b98d3606e689951df265c9d7969b4
--- /dev/null
+++ b/test/mjsunit/regress/regress-crbug-517592.js
@@ -0,0 +1,36 @@
+// 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: --expose-debug-as debug --min-preparse-length=10
+
+var source =
+ "var foo = function foo() {\n" +
+ " return 1;\n" +
+ "}\n" +
+ "//@ sourceURL=test";
+
+Debug = debug.Debug;
+Debug.setListener(listener);
+var exception = null;
+var break_count = 0;
+
+function listener(event, exec_state, event_data, data) {
+ if (event == Debug.DebugEvent.Break) break_count++;
+ if (event != Debug.DebugEvent.AfterCompile) return;
+ try {
+ var name = event_data.script().name();
+ var id = event_data.script().id();
+ assertEquals("test", name);
+ Debug.setScriptBreakPointById(id, 2);
+ } catch (e) {
+ exception = e;
+ }
+}
+
+eval(source);
+
+assertEquals(0, break_count);
+foo();
+assertEquals(1, break_count);
+assertNull(exception);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.