Reviewers: Sven,
Description:
Add inspection of whether frame is a construct frame to optimized frames
Also avoid that calling Debug::IsBreakAtReturn causes a full doptimization
when
there are no break points set. The full deoptimization is caused by
Debug::IsBreakAtReturn calling Debug::EnsureDebugInfo which will assume
that a
break point is now set.
[email protected]
BUG=v8:1140
TEST=test/mjsunit/debug-evaluate-locals-optimized.js,test/mjsunit/debug-
evaluate-locals-optimized-doubles.js
Please review this at http://codereview.chromium.org/7307035/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/debug.cc
M src/runtime.cc
M test/mjsunit/debug-evaluate-locals-optimized-double.js
M test/mjsunit/debug-evaluate-locals-optimized.js
Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index
f341fc6f1f1657f9eec848d011958f4224c8559a..c48e514ab8a0677b171379a79491e2f35e84c8de
100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -1821,6 +1821,13 @@ void Debug::SetAfterBreakTarget(JavaScriptFrame*
frame) {
bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) {
HandleScope scope(isolate_);
+ // If there are no break points this cannot be break at return, as
+ // the debugger statement and stack guard bebug break cannot be at
+ // return.
+ if (!has_break_points_) {
+ return false;
+ }
+
// Get the executing function in which the debug break occurred.
Handle<SharedFunctionInfo> shared =
Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared());
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
2e0df5001bcfd9435bf5d1e8e62b5cc79ae473ac..5545a55105bc07454921fb10fcdf8bed1563ae89
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -10060,7 +10060,13 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_GetFrameDetails) {
it.frame()->LookupCode()->SourcePosition(it.frame()->pc());
// Check for constructor frame.
- bool constructor = it.frame()->IsConstructor();
+ bool constructor;
+ if (it.frame()->is_optimized() && deoptimized_frame_index != 0) {
+ // Inlined frames cannot be construct calls.
+ constructor = false;
+ } else {
+ constructor = it.frame()->IsConstructor();
+ }
// Get scope info and read from it for local variable information.
Handle<JSFunction> function(JSFunction::cast(it.frame()->function()));
Index: test/mjsunit/debug-evaluate-locals-optimized-double.js
diff --git a/test/mjsunit/debug-evaluate-locals-optimized-double.js
b/test/mjsunit/debug-evaluate-locals-optimized-double.js
index
bbe78d62360abdf83258b25bb53f9e28d6f981ac..584d1afdab5a0133c2563e10c1f973aa1968941a
100644
--- a/test/mjsunit/debug-evaluate-locals-optimized-double.js
+++ b/test/mjsunit/debug-evaluate-locals-optimized-double.js
@@ -29,8 +29,10 @@
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
-listenerComplete = false;
-exception = false;
+var listenerComplete = false;
+var exception = false;
+
+var testingConstructCall = false;
function listener(event, exec_state, event_data, data) {
@@ -70,6 +72,9 @@ function listener(event, exec_state, event_data, data) {
default: assertUnreachable();
}
+ // Check for construct call.
+ assertEquals(testingConstructCall && i == 4,
frame.isConstructCall());
+
// When function f is optimized (2 means YES, see runtime.cc) we
// expect an optimized frame for f with g1, g2 and g3 inlined.
if (%GetOptimizationStatus(f) == 2) {
@@ -142,7 +147,10 @@ function f(x, y) {
g1(a, b);
};
+// Test calling f normally and as a constructor.
f(11.11, 12.12);
+testingConstructCall = true;
+new f(11.11, 12.12);
// Make sure that the debug event listener vas invoked.
assertFalse(exception, "exception in listener " + exception)
Index: test/mjsunit/debug-evaluate-locals-optimized.js
diff --git a/test/mjsunit/debug-evaluate-locals-optimized.js
b/test/mjsunit/debug-evaluate-locals-optimized.js
index
7a77c0d32a55bf62f2707eed922ba6331dc6254f..1aaf29633c321f43548cc1be749768e0f1b89f7c
100644
--- a/test/mjsunit/debug-evaluate-locals-optimized.js
+++ b/test/mjsunit/debug-evaluate-locals-optimized.js
@@ -29,8 +29,10 @@
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
-listenerComplete = false;
-exception = false;
+var listenerComplete = false;
+var exception = false;
+
+var testingConstructCall = false;
function listener(event, exec_state, event_data, data) {
@@ -66,6 +68,9 @@ function listener(event, exec_state, event_data, data) {
default: assertUnreachable();
}
+ // Check for construct call.
+ assertEquals(testingConstructCall && i == 4,
frame.isConstructCall());
+
// When function f is optimized (2 means YES, see runtime.cc) we
// expect an optimized frame for f with g1, g2 and g3 inlined.
if (%GetOptimizationStatus(f) == 2) {
@@ -127,7 +132,10 @@ function f(x, y) {
g1(a, b);
};
+// Test calling f normally and as a constructor.
f(11, 12);
+testingConstructCall = true;
+new f(11, 12);
// Make sure that the debug event listener vas invoked.
assertFalse(exception, "exception in listener " + exception)
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev