From 292e007cf3542103f0965be892f494d08407014d Mon Sep 17 00:00:00 2001 From: "erik.corry@gmail.com" Date: Thu, 26 Apr 2012 13:44:18 +0000 Subject: [PATCH] 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. Review URL: https://chromiumcodereview.appspot.com/10234007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11455 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/runtime.cc | 7 +++++-- test/mjsunit/debug-evaluate-locals-optimized-double.js | 15 --------------- test/mjsunit/debug-evaluate-locals-optimized.js | 15 --------------- test/mjsunit/debug-scripts-request.js | 6 ++++-- 4 files changed, 9 insertions(+), 34 deletions(-) diff --git a/src/runtime.cc b/src/runtime.cc index 7b7a3e4..7d52fbd 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -8316,10 +8316,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { 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) // 3 == "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". } diff --git a/test/mjsunit/debug-evaluate-locals-optimized-double.js b/test/mjsunit/debug-evaluate-locals-optimized-double.js index 242276d..efbb2cc 100644 --- a/test/mjsunit/debug-evaluate-locals-optimized-double.js +++ b/test/mjsunit/debug-evaluate-locals-optimized-double.js @@ -56,11 +56,6 @@ function arraySum(arr) { 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 @@ function listener(event, exec_state, event_data, data) { } } - // 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; } diff --git a/test/mjsunit/debug-evaluate-locals-optimized.js b/test/mjsunit/debug-evaluate-locals-optimized.js index 4dca463..9c56a12 100644 --- a/test/mjsunit/debug-evaluate-locals-optimized.js +++ b/test/mjsunit/debug-evaluate-locals-optimized.js @@ -46,11 +46,6 @@ function arraySum(arr) { 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 @@ function listener(event, exec_state, event_data, data) { } } - // 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; } diff --git a/test/mjsunit/debug-scripts-request.js b/test/mjsunit/debug-scripts-request.js index faa732e..e027563 100644 --- a/test/mjsunit/debug-scripts-request.js +++ b/test/mjsunit/debug-scripts-request.js @@ -78,8 +78,10 @@ function listener(event, exec_state, event_data, data) { 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 + ']}}'; -- 2.7.4