Revision: 8573
Author:   [email protected]
Date:     Fri Jul  8 01:55:26 2011
Log: 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

Review URL: http://codereview.chromium.org//7307035
http://code.google.com/p/v8/source/detail?r=8573

Modified:
 /branches/bleeding_edge/src/debug.cc
 /branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/mjsunit/debug-evaluate-locals-optimized-double.js
 /branches/bleeding_edge/test/mjsunit/debug-evaluate-locals-optimized.js

=======================================
--- /branches/bleeding_edge/src/debug.cc        Fri Jun 10 02:54:04 2011
+++ /branches/bleeding_edge/src/debug.cc        Fri Jul  8 01:55:26 2011
@@ -1820,6 +1820,13 @@

 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 =
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Thu Jul  7 07:29:16 2011
+++ /branches/bleeding_edge/src/runtime.cc      Fri Jul  8 01:55:26 2011
@@ -10059,8 +10059,10 @@
   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()));
=======================================
--- /branches/bleeding_edge/test/mjsunit/debug-evaluate-locals-optimized-double.js Thu Jul 7 07:29:16 2011 +++ /branches/bleeding_edge/test/mjsunit/debug-evaluate-locals-optimized-double.js Fri Jul 8 01:55:26 2011
@@ -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) {
@@ -69,6 +71,9 @@
           case 5: break;
           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.
@@ -142,7 +147,10 @@
   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)
=======================================
--- /branches/bleeding_edge/test/mjsunit/debug-evaluate-locals-optimized.js Thu Jul 7 07:29:16 2011 +++ /branches/bleeding_edge/test/mjsunit/debug-evaluate-locals-optimized.js Fri Jul 8 01:55:26 2011
@@ -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) {
@@ -65,6 +67,9 @@
           case 5: break;
           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.
@@ -127,7 +132,10 @@
   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

Reply via email to