Add inspection of whether frame is a construct frame to optimized frames
authorsgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 8 Jul 2011 08:55:26 +0000 (08:55 +0000)
committersgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 8 Jul 2011 08:55:26 +0000 (08:55 +0000)
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.

R=svenpanne@chromium.org

BUG=v8:1140
TEST=test/mjsunit/debug-evaluate-locals-optimized.js,test/mjsunit/debug-
evaluate-locals-optimized-doubles.js

Review URL: http://codereview.chromium.org//7307035

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8573 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/debug.cc
src/runtime.cc
test/mjsunit/debug-evaluate-locals-optimized-double.js
test/mjsunit/debug-evaluate-locals-optimized.js

index f341fc6..c48e514 100644 (file)
@@ -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 2e0df50..117e5ab 100644 (file)
@@ -10059,8 +10059,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) {
   int position =
       it.frame()->LookupCode()->SourcePosition(it.frame()->pc());
 
-  // Check for constructor frame.
-  bool constructor = it.frame()->IsConstructor();
+  // Check for constructor frame. Inlined frames cannot be construct calls.
+  bool inlined_frame =
+      it.frame()->is_optimized() && deoptimized_frame_index != 0;
+  bool constructor = !inlined_frame && it.frame()->IsConstructor();
 
   // Get scope info and read from it for local variable information.
   Handle<JSFunction> function(JSFunction::cast(it.frame()->function()));
index bbe78d6..584d1af 100644 (file)
 // 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 7a77c0d..1aaf296 100644 (file)
 // 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)