Reviewers: Yang,

Description:
Remove more assumptions from debug tests.  Even though a function
is optimized, does not mean all frames on the stack are optimized.
Also, when we ask for the list of scripts we may get more or less
depending on GC timing.  Also fixed a presubmit error and made
%GetOptimizationStatus a little more honest.

Please review this at https://chromiumcodereview.appspot.com/10234007/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/runtime.cc
  M     test/mjsunit/debug-evaluate-locals-optimized-double.js
  M     test/mjsunit/debug-evaluate-locals-optimized.js
  M     test/mjsunit/debug-scripts-request.js


Index: src/runtime.cc
===================================================================
--- src/runtime.cc      (revision 11446)
+++ src/runtime.cc      (working copy)
@@ -8316,10 +8316,13 @@
   if (!V8::UseCrankshaft()) {
     return Smi::FromInt(4);  // 4 == "never".
   }
+  CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
   if (FLAG_always_opt) {
-    return Smi::FromInt(3);  // 3 == "always".
+    // We may have always opt, but that is more best-effort than a real
+    // promise, so we still say "no" if it is not optimized.
+    return function->IsOptimized() ? Smi::FromInt(3)   // 1 == "always".
+                                   : Smi::FromInt(2);  // 2 == "no".
   }
-  CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
   return function->IsOptimized() ? Smi::FromInt(1)   // 1 == "yes".
                                  : Smi::FromInt(2);  // 2 == "no".
 }
Index: test/mjsunit/debug-evaluate-locals-optimized-double.js
===================================================================
--- test/mjsunit/debug-evaluate-locals-optimized-double.js      (revision 11449)
+++ test/mjsunit/debug-evaluate-locals-optimized-double.js      (working copy)
@@ -56,11 +56,6 @@
   return arr.reduce(function (a, b) { return a + b; }, 0);
 }

-function isCurrentlyOptimized(fun) {
-  // See runtime.cc.
-  return (%GetOptimizationStatus(fun) & 1) != 0;
-}
-
 function listener(event, exec_state, event_data, data) {
   try {
     if (event == Debug.DebugEvent.Break)
@@ -159,16 +154,6 @@
         }
       }

- // When function f is optimized we expect an optimized frame for f. We
-      // can't say whether or not the top 3 frames (g1, g2 and g3) are
-      // optimized and inlined.
-      var frame4 = exec_state.frame(4);
-
-      if (isCurrentlyOptimized(f)) {
-        assertTrue(frame4.isOptimizedFrame());
-        assertFalse(frame4.isInlinedFrame());
-      }
-
       // Indicate that all was processed.
       listenerComplete = true;
     }
Index: test/mjsunit/debug-evaluate-locals-optimized.js
===================================================================
--- test/mjsunit/debug-evaluate-locals-optimized.js     (revision 11449)
+++ test/mjsunit/debug-evaluate-locals-optimized.js     (working copy)
@@ -46,11 +46,6 @@
   return arr.reduce(function (a, b) { return a + b; }, 0);
 }

-function isCurrentlyOptimized(fun) {
-  // See runtime.cc.
-  return (%GetOptimizationStatus(fun) & 1) != 0;
-}
-
 function listener(event, exec_state, event_data, data) {
   try {
     if (event == Debug.DebugEvent.Break)
@@ -149,16 +144,6 @@
         }
       }

- // When function f is optimized we expect an optimized frame for f. We
-      // can't say whether or not the top 3 frames (g1, g2 and g3) are
-      // optimized and inlined.
-      var frame4 = exec_state.frame(4);
-
-      if (isCurrentlyOptimized(f)) {
-        assertTrue(frame4.isOptimizedFrame());
-        assertFalse(frame4.isInlinedFrame());
-      }
-
       // Indicate that all was processed.
       listenerComplete = true;
     }
Index: test/mjsunit/debug-scripts-request.js
===================================================================
--- test/mjsunit/debug-scripts-request.js       (revision 11446)
+++ test/mjsunit/debug-scripts-request.js       (working copy)
@@ -78,8 +78,10 @@
     var response = safeEval(dcp.processDebugJSONRequest(request));
     assertTrue(response.success);

-    // Test filtering by id.
-    assertEquals(2, response.body.length);
+    // Test filtering by id.  We have to get at least one script back, but
+    // the exact number depends on the timing of GC.
+    assertTrue(response.body.length >= 1);
+
     var script = response.body[0];
     var request = '{' + base_request + ',"arguments":{"ids":[' +
                   script.id + ']}}';


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to