Commit cd41cb9b authored by yangguo@chromium.org's avatar yangguo@chromium.org

Turn on parallel recompilation for tests that assert optimization status.

R=mvstanton@chromium.org
BUG=

Review URL: https://codereview.chromium.org/19807002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15793 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ce81b0d3
......@@ -8445,15 +8445,21 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) {
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_CompleteOptimization) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) {
HandleScope scope(isolate);
ASSERT(args.length() == 1);
RUNTIME_ASSERT(args.length() == 1 || args.length() == 2);
if (!V8::UseCrankshaft()) {
return Smi::FromInt(4); // 4 == "never".
}
bool sync_with_compiler_thread = true;
if (args.length() == 2) {
CONVERT_ARG_HANDLE_CHECKED(String, sync, 1);
if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) {
sync_with_compiler_thread = false;
}
}
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
if (FLAG_parallel_recompilation && V8::UseCrankshaft()) {
// While function is in optimization pipeline, it is marked accordingly.
// Note that if the debugger is activated during parallel recompilation,
// the function will be marked with the lazy-recompile builtin, which is
// not related to parallel recompilation.
if (FLAG_parallel_recompilation && sync_with_compiler_thread) {
while (function->IsMarkedForParallelRecompilation() ||
function->IsInRecompileQueue() ||
function->IsMarkedForInstallingRecompiledCode()) {
......@@ -8461,22 +8467,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompleteOptimization) {
OS::Sleep(50);
}
}
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) {
HandleScope scope(isolate);
ASSERT(args.length() == 1);
if (!V8::UseCrankshaft()) {
return Smi::FromInt(4); // 4 == "never".
}
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
if (FLAG_parallel_recompilation) {
if (function->IsMarkedForLazyRecompilation()) {
return Smi::FromInt(5); // 5 == "parallel recompilation".
}
}
if (FLAG_always_opt) {
// 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.
......
......@@ -98,8 +98,7 @@ namespace internal {
F(IsParallelRecompilationSupported, 0, 1) \
F(OptimizeFunctionOnNextCall, -1, 1) \
F(NeverOptimizeFunction, 1, 1) \
F(CompleteOptimization, 1, 1) \
F(GetOptimizationStatus, 1, 1) \
F(GetOptimizationStatus, -1, 1) \
F(GetOptimizationCount, 1, 1) \
F(CompileForOnStackReplacement, 1, 1) \
F(AllocateInNewSpace, 1, 1) \
......
......@@ -362,9 +362,9 @@ if (support_smi_only_arrays) {
// No de-opt will occur because HCallNewArray wasn't selected, on account of
// the call site not being monomorphic to Array.
instanceof_check(Array);
assertTrue(2 != %GetOptimizationStatus(instanceof_check));
assertOptimized(instanceof_check);
instanceof_check(realmBArray);
assertTrue(2 != %GetOptimizationStatus(instanceof_check));
assertOptimized(instanceof_check);
// Try to optimize again, but first clear all type feedback, and allow it
// to be monomorphic on first call. Only after crankshafting do we introduce
......@@ -375,8 +375,8 @@ if (support_smi_only_arrays) {
instanceof_check(Array);
%OptimizeFunctionOnNextCall(instanceof_check);
instanceof_check(Array);
assertTrue(2 != %GetOptimizationStatus(instanceof_check));
assertOptimized(instanceof_check);
instanceof_check(realmBArray);
assertTrue(1 != %GetOptimizationStatus(instanceof_check));
assertUnoptimized(instanceof_check);
}
......@@ -105,7 +105,7 @@ test_base(dictionary_map_array, 5, false);
test_base(dictionary_map_array, 6, false);
%OptimizeFunctionOnNextCall(test_base);
test_base(dictionary_map_array, -2, true);
assertTrue(%GetOptimizationStatus(test_base) != 1);
assertUnoptimized(test_base);
// Forget about the dictionary_map_array's map.
%ClearFunctionTypeFeedback(test_base);
......@@ -116,7 +116,7 @@ test_base(a, 5, false);
test_base(a, 6, false);
%OptimizeFunctionOnNextCall(test_base);
test_base(a, 2048, true);
assertTrue(%GetOptimizationStatus(test_base) != 1);
assertUnoptimized(test_base);
function test_minus(base,cond) {
a[base - 1] = 1;
......@@ -173,7 +173,7 @@ short_test(short_a, 50);
%OptimizeFunctionOnNextCall(short_test);
short_a.length = 10;
short_test(short_a, 0);
assertTrue(%GetOptimizationStatus(short_test) != 1);
assertUnoptimized(test_base);
// A test for when we would modify a phi index.
......
......@@ -120,10 +120,10 @@ if (support_smi_only_arrays) {
%OptimizeFunctionOnNextCall(bar0);
b = bar0(Array);
assertKind(elements_kind.fast_double, b);
assertTrue(2 != %GetOptimizationStatus(bar0));
assertOptimized(bar0);
// bar0 should deopt
b = bar0(Object);
assertTrue(1 != %GetOptimizationStatus(bar0));
assertUnoptimized(bar0)
// When it's re-optimized, we should call through the full stub
bar0(Array);
%OptimizeFunctionOnNextCall(bar0);
......@@ -131,7 +131,7 @@ if (support_smi_only_arrays) {
// We also lost our ability to record kind feedback, as the site
// is megamorphic now.
assertKind(elements_kind.fast_smi_only, b);
assertTrue(2 != %GetOptimizationStatus(bar0));
assertOptimized(bar0);
b[0] = 3.5;
c = bar0(Array);
assertKind(elements_kind.fast_smi_only, c);
......@@ -151,15 +151,15 @@ if (support_smi_only_arrays) {
%OptimizeFunctionOnNextCall(bar);
a = bar(10);
assertKind(elements_kind.fast, a);
assertTrue(2 != %GetOptimizationStatus(bar));
assertOptimized(bar);
// The stub bails out, but the method call should be fine.
a = bar(100000);
assertTrue(2 != %GetOptimizationStatus(bar));
assertOptimized(bar);
assertKind(elements_kind.dictionary, a);
// If the argument isn't a smi, it bails out as well
a = bar("oops");
assertTrue(2 != %GetOptimizationStatus(bar));
assertOptimized(bar);
assertKind(elements_kind.fast, a);
function barn(one, two, three) {
......@@ -170,11 +170,11 @@ if (support_smi_only_arrays) {
barn(1, 2, 3);
%OptimizeFunctionOnNextCall(barn);
barn(1, 2, 3);
assertTrue(2 != %GetOptimizationStatus(barn));
assertOptimized(barn);
a = barn(1, "oops", 3);
// The stub should bail out but the method should remain optimized.
assertKind(elements_kind.fast, a);
assertTrue(2 != %GetOptimizationStatus(barn));
assertOptimized(barn);
})();
......@@ -191,12 +191,12 @@ if (support_smi_only_arrays) {
b = bar();
// This only makes sense to test if we allow crankshafting
if (4 != %GetOptimizationStatus(bar)) {
assertTrue(2 != %GetOptimizationStatus(bar));
assertOptimized(bar);
%DebugPrint(3);
b[0] = 3.5;
c = bar();
assertKind(elements_kind.fast_smi_only, c);
assertTrue(2 != %GetOptimizationStatus(bar));
assertOptimized(bar);
}
})();
......
......@@ -192,7 +192,7 @@ if (support_smi_only_arrays) {
b[0] = 3.5;
c = create0();
assertKind(elements_kind.fast_double, c);
assertTrue(2 != %GetOptimizationStatus(create0));
assertOptimized(create0);
}
})();
......
......@@ -55,7 +55,7 @@ if (support_smi_only_arrays) {
get_literal(3);
%OptimizeFunctionOnNextCall(get_literal);
a = get_literal(3);
assertTrue(2 != %GetOptimizationStatus(get_literal));
assertOptimized(get_literal);
assertTrue(%HasFastSmiElements(a));
a[0] = 3.5;
......@@ -64,12 +64,12 @@ if (support_smi_only_arrays) {
b = get_literal(3);
assertTrue(%HasFastDoubleElements(b));
assertEquals([1, 2, 3], b);
assertTrue(1 != %GetOptimizationStatus(get_literal));
assertUnoptimized(get_literal);
// Optimize again
get_literal(3);
%OptimizeFunctionOnNextCall(get_literal);
b = get_literal(3);
assertTrue(%HasFastDoubleElements(b));
assertTrue(2 != %GetOptimizationStatus(get_literal));
assertOptimized(get_literal);
}
......@@ -26,7 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
// Flags: --noparallel-recompilation
// Test element kind of objects.
// Since --smi-only-arrays affects builtins, its default setting at compile
......@@ -144,11 +143,11 @@ if (support_smi_only_arrays) {
deopt_array(false);
%OptimizeFunctionOnNextCall(deopt_array);
var array = deopt_array(false);
assertTrue(2 != %GetOptimizationStatus(deopt_array));
assertOptimized(deopt_array);
deopt_array(true);
assertTrue(2 != %GetOptimizationStatus(deopt_array));
assertOptimized(deopt_array);
array = deopt_array(false);
assertTrue(2 != %GetOptimizationStatus(deopt_array));
assertOptimized(deopt_array);
// Check that unexpected changes in the objects stored into the boilerplate
// also force a deopt.
......@@ -166,13 +165,13 @@ if (support_smi_only_arrays) {
%OptimizeFunctionOnNextCall(deopt_array_literal_all_smis);
array = deopt_array_literal_all_smis(5);
array = deopt_array_literal_all_smis(6);
assertTrue(2 != %GetOptimizationStatus(deopt_array_literal_all_smis));
assertOptimized(deopt_array_literal_all_smis);
assertEquals(0, array[0]);
assertEquals(1, array[1]);
assertEquals(6, array[2]);
array = deopt_array_literal_all_smis(.5);
assertTrue(1 != %GetOptimizationStatus(deopt_array_literal_all_smis));
assertUnoptimized(deopt_array_literal_all_smis);
assertEquals(0, array[0]);
assertEquals(1, array[1]);
assertEquals(.5, array[2]);
......@@ -191,14 +190,14 @@ if (support_smi_only_arrays) {
%OptimizeFunctionOnNextCall(deopt_array_literal_all_doubles);
array = deopt_array_literal_all_doubles(5);
array = deopt_array_literal_all_doubles(6);
assertTrue(2 != %GetOptimizationStatus(deopt_array_literal_all_doubles));
assertOptimized(deopt_array_literal_all_doubles);
assertEquals(0.5, array[0]);
assertEquals(1, array[1]);
assertEquals(6, array[2]);
var foo = new Object();
array = deopt_array_literal_all_doubles(foo);
assertTrue(1 != %GetOptimizationStatus(deopt_array_literal_all_doubles));
assertUnoptimized(deopt_array_literal_all_doubles);
assertEquals(0.5, array[0]);
assertEquals(1, array[1]);
assertEquals(foo, array[2]);
......@@ -207,6 +206,6 @@ if (support_smi_only_arrays) {
(function literals_after_osr() {
var color = [0];
// Trigger OSR.
while (%GetOptimizationStatus(literals_after_osr) == 2) {}
while (%GetOptimizationStatus(literals_after_osr, "no sync") == 2) {}
return [color[0]];
})();
......@@ -26,7 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays
// Flags: --noparallel-recompilation
// Flags: --notrack-allocation-sites
// Test element kind of objects.
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --noparallel-recompilation
// Flags: --allow-natives-syntax
if (%IsParallelRecompilationSupported()) {
print("Parallel recompilation is turned on after all. Skipping this test.");
......
......@@ -33,10 +33,6 @@ if (!%IsParallelRecompilationSupported()) {
quit();
}
function assertUnoptimized(fun) {
assertTrue(%GetOptimizationStatus(fun) != 1);
}
function f(foo) { return foo.bar(); }
var o = {};
......@@ -45,11 +41,14 @@ o.__proto__ = { __proto__: { bar: function() { return 1; } } };
assertEquals(1, f(o));
assertEquals(1, f(o));
// Mark for parallel optimization.
%OptimizeFunctionOnNextCall(f, "parallel");
assertEquals(1, f(o)); // Trigger optimization.
assertUnoptimized(f); // Optimization not yet done.
// Trigger optimization in the parallel thread.
assertEquals(1, f(o));
// While parallel recompilation is running, optimization not yet done.
assertUnoptimized(f, "no sync");
// Change the prototype chain during optimization to trigger map invalidation.
o.__proto__.__proto__ = { bar: function() { return 2; } };
%CompleteOptimization(f); // Conclude optimization with...
assertUnoptimized(f); // ... bailing out due to map dependency.
// Optimization eventually bails out due to map dependency.
assertUnoptimized(f, "sync");
assertEquals(2, f(o));
......@@ -34,7 +34,7 @@ function test(f) {
%OptimizeFunctionOnNextCall(f);
f();
// Assert that there has been no deopt.
assertTrue(%GetOptimizationStatus(f) != 2);
assertOptimized(f);
}
test(function add() {
......
......@@ -26,14 +26,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --count-based-interrupts --interrupt-budget=10 --weighted-back-edges
// Flags: --allow-natives-syntax --noparallel-recompilation
// Flags: --allow-natives-syntax
// Test that OSR works properly when using count-based interrupting/profiling.
function osr_this() {
var a = 1;
// Trigger OSR.
while (%GetOptimizationStatus(osr_this) == 2) {}
while (%GetOptimizationStatus(osr_this, "no sync") == 2) {}
return a;
}
assertEquals(1, osr_this());
......@@ -333,11 +333,10 @@ date.getTime();
date.getTime();
%OptimizeFunctionOnNextCall(Date.prototype.getTime);
assertThrows(function() { Date.prototype.getTime.call(""); }, TypeError);
assertTrue(%GetOptimizationStatus(Date.prototype.getTime) != 1);
assertUnoptimized(Date.prototype.getTime);
date.getYear();
date.getYear();
%OptimizeFunctionOnNextCall(Date.prototype.getYear);
assertThrows(function() { Date.prototype.getYear.call(""); }, TypeError);
opt_status = %GetOptimizationStatus(Date.prototype.getYear);
assertTrue(%GetOptimizationStatus(Date.prototype.getTime) != 1);
assertUnoptimized(Date.prototype.getYear);
......@@ -26,7 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --noparallel-recompilation
// This test tests that deoptimization due to debug breaks works for
// inlined functions where the full-code is generated before the
......
......@@ -25,8 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --expose-gc --noparallel-recompilation
// Flags: --send-idle-notification
// Flags: --expose-debug-as debug --expose-gc --send-idle-notification
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug;
......
......@@ -27,17 +27,6 @@
// Flags: --allow-natives-syntax --expose-gc
/**
* The possible optimization states of a function. Must be in sync with the
* return values of Runtime_GetOptimizationStatus() in runtime.cc!
*/
var OptimizationState = {
YES: 1,
NO: 2,
ALWAYS: 3,
NEVER: 4
};
function mul (a, b) {
return a * b;
}
......@@ -50,7 +39,5 @@ mul(0, -1);
%OptimizeFunctionOnNextCall(mul);
mul(0, -1);
var raw_optimized = %GetOptimizationStatus(mul);
assertFalse(raw_optimized == OptimizationState.NO);
assertOptimized(mul);
gc();
......@@ -25,8 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --noparallel-recompilation
// Flags: --notrack-allocation-sites
// Flags: --allow-natives-syntax --smi-only-arrays --notrack-allocation-sites
// No tracking of allocation sites because it interfers with the semantics
// the test is trying to ensure.
......@@ -63,7 +62,7 @@ if (support_smi_only_arrays) {
%OptimizeFunctionOnNextCall(testDoubleConversion4);
testDoubleConversion4(new Array(5));
testDoubleConversion4(new Array(5));
assertTrue(2 != %GetOptimizationStatus(testDoubleConversion4));
assertOptimized(testDoubleConversion4);
%ClearFunctionTypeFeedback(testDoubleConversion4);
// Make sure that non-element related map checks that are not preceded by
......@@ -89,7 +88,7 @@ if (support_smi_only_arrays) {
%OptimizeFunctionOnNextCall(testExactMapHoisting);
testExactMapHoisting(new Array(5));
testExactMapHoisting(new Array(5));
assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting));
assertOptimized(testExactMapHoisting);
%ClearFunctionTypeFeedback(testExactMapHoisting);
// Make sure that non-element related map checks do NOT get hoisted if they
......@@ -121,7 +120,7 @@ if (support_smi_only_arrays) {
testExactMapHoisting2(new Array(5));
testExactMapHoisting2(new Array(5));
// Temporarily disabled - see bug 2176.
// assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting2));
// assertOptimized(testExactMapHoisting2);
%ClearFunctionTypeFeedback(testExactMapHoisting2);
// Make sure that non-element related map checks do get hoisted if they use
......@@ -150,7 +149,7 @@ if (support_smi_only_arrays) {
%OptimizeFunctionOnNextCall(testExactMapHoisting3);
testExactMapHoisting3(new Array(5));
testExactMapHoisting3(new Array(5));
assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting3));
assertOptimized(testExactMapHoisting3);
%ClearFunctionTypeFeedback(testExactMapHoisting3);
function testDominatingTransitionHoisting1(a) {
......@@ -177,7 +176,7 @@ if (support_smi_only_arrays) {
// TODO(verwaest) With current changes the elements transition gets hoisted
// above the access, causing a deopt. We should update the type of access
// rather than forbid hoisting the transition.
assertTrue(2 != %GetOptimizationStatus(testDominatingTransitionHoisting1));
assertOptimized(testDominatingTransitionHoisting1);
%ClearFunctionTypeFeedback(testDominatingTransitionHoisting1);
*/
......@@ -198,7 +197,7 @@ if (support_smi_only_arrays) {
%OptimizeFunctionOnNextCall(testHoistingWithSideEffect);
testHoistingWithSideEffect(new Array(5));
testHoistingWithSideEffect(new Array(5));
assertTrue(2 != %GetOptimizationStatus(testHoistingWithSideEffect));
assertOptimized(testHoistingWithSideEffect);
%ClearFunctionTypeFeedback(testHoistingWithSideEffect);
function testStraightLineDupeElinination(a,b,c,d,e,f) {
......@@ -237,6 +236,6 @@ if (support_smi_only_arrays) {
%OptimizeFunctionOnNextCall(testStraightLineDupeElinination);
testStraightLineDupeElinination(new Array(5),0,0,0,0,0);
testStraightLineDupeElinination(new Array(5),0,0,0,0,0);
assertTrue(2 != %GetOptimizationStatus(testStraightLineDupeElinination));
assertOptimized(testStraightLineDupeElinination);
%ClearFunctionTypeFeedback(testStraightLineDupeElinination);
}
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-scoping --allow-natives-syntax --noparallel-recompilation
// Flags: --harmony-scoping --allow-natives-syntax
// TODO(ES6): properly activate extended mode
"use strict";
......@@ -43,7 +43,7 @@ for (var i = 0; i < functions.length; ++i) {
}
%OptimizeFunctionOnNextCall(func);
func(12);
assertTrue(%GetOptimizationStatus(func) != 2);
assertOptimized(func);
}
function f1() { }
......
......@@ -33,14 +33,6 @@ if (!%IsParallelRecompilationSupported()) {
quit();
}
function assertUnoptimized(fun) {
assertTrue(%GetOptimizationStatus(fun) != 1);
}
function assertOptimized(fun) {
assertTrue(%GetOptimizationStatus(fun) != 2);
}
function f(x) {
var xx = x * x;
var xxstr = xx.toString();
......@@ -65,11 +57,8 @@ assertUnoptimized(g);
%OptimizeFunctionOnNextCall(g, "parallel");
f(g(2)); // Trigger optimization.
assertUnoptimized(f); // Not yet optimized.
assertUnoptimized(g);
%CompleteOptimization(f); // Wait till optimized code is installed.
%CompleteOptimization(g);
assertUnoptimized(f, "no sync"); // Not yet optimized while parallel thread
assertUnoptimized(g, "no sync"); // is running.
assertOptimized(f); // Optimized now.
assertOptimized(g);
assertOptimized(f, "sync"); // Optimized once we sync with the parallel thread.
assertOptimized(g, "sync");
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --nouse_inlining --noparallel-recompilation
// Flags: --allow-natives-syntax --nouse_inlining
// Test for negative zero that doesn't need bail out
......@@ -38,4 +38,4 @@ test_div_no_deopt_minus_zero();
test_div_no_deopt_minus_zero();
%OptimizeFunctionOnNextCall(test_div_no_deopt_minus_zero);
test_div_no_deopt_minus_zero();
assertTrue(2 != %GetOptimizationStatus(test_div_no_deopt_minus_zero));
assertOptimized(test_div_no_deopt_minus_zero);
......@@ -99,6 +99,14 @@ var assertInstanceof;
// Assert that this code is never executed (i.e., always fails if executed).
var assertUnreachable;
// Assert that the function code is (not) optimized. If "no sync" is passed
// as second argument, we do not wait for the parallel optimization thread to
// finish when polling for optimization status.
// Only works with --allow-natives-syntax.
var assertOptimized;
var assertUnoptimized;
(function () { // Scope for utility functions.
function classOf(object) {
......@@ -353,5 +361,26 @@ var assertUnreachable;
throw new MjsUnitAssertionError(message);
};
var OptimizationStatus;
try {
OptimizationStatus =
new Function("fun", "sync", "return %GetOptimizationStatus(fun, sync);");
} catch (e) {
OptimizationStatus = function() {
throw new Error("natives syntax not allowed");
}
}
assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) {
if (sync_opt === undefined) sync_opt = "";
assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt);
}
assertOptimized = function assertOptimized(fun, sync_opt, name_opt) {
if (sync_opt === undefined) sync_opt = "";
assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt);
}
})();
......@@ -37,10 +37,7 @@ if (%GetOptimizationStatus(o1) != 4) {
o1();
// Check that the given function was optimized.
var o1_status = %GetOptimizationStatus(o1);
assertTrue(o1_status == 1 // optimized
|| o1_status == 3 // optimized (always opt)
|| o1_status == 5); // lazy recompile requested
assertOptimized(o1);
// Test the %NeverOptimizeFunction runtime call.
%NeverOptimizeFunction(u1);
......@@ -61,6 +58,6 @@ if (%GetOptimizationStatus(o1) != 4) {
u2(); u2();
// 2 => not optimized.
assertTrue(%GetOptimizationStatus(u1) == 2);
assertFalse(%GetOptimizationStatus(u2) == 2);
assertUnoptimized(u1);
assertOptimized(u2);
}
\ No newline at end of file
......@@ -26,17 +26,13 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax
// Flags: --parallel-recompilation --parallel-recompilation-delay=50
// Flags: --parallel-recompilation --parallel-recompilation-delay=100
if (!%IsParallelRecompilationSupported()) {
print("Parallel recompilation is disabled. Skipping this test.");
quit();
}
function assertUnoptimized(fun) {
assertTrue(%GetOptimizationStatus(fun) != 1);
}
function f1(a, i) {
return a[i] + 0.5;
}
......@@ -47,9 +43,12 @@ assertEquals(0.5, f1(arr, 0));
// Optimized code of f1 depends on initial object and array maps.
%OptimizeFunctionOnNextCall(f1, "parallel");
// Trigger optimization in the background thread
assertEquals(0.5, f1(arr, 0));
assertUnoptimized(f1); // Not yet optimized.
Object.prototype[1] = 1.5; // Invalidate current initial object map.
assertEquals(2, f1(arr, 1));
%CompleteOptimization(f1); // Conclude optimization with...
assertUnoptimized(f1); // ... bailing out due to map dependency.
// Not yet optimized while background thread is running.
assertUnoptimized(f1, "no sync");
// Sync with background thread to conclude optimization, which bails out
// due to map dependency.
assertUnoptimized(f1, "sync");
......@@ -26,17 +26,13 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --track-fields --track-double-fields --allow-natives-syntax
// Flags: --parallel-recompilation --parallel-recompilation-delay=50
// Flags: --parallel-recompilation --parallel-recompilation-delay=100
if (!%IsParallelRecompilationSupported()) {
print("Parallel recompilation is disabled. Skipping this test.");
quit();
}
function assertUnoptimized(fun) {
assertTrue(%GetOptimizationStatus(fun) != 1);
}
function new_object() {
var o = {};
o.a = 1;
......@@ -53,9 +49,9 @@ add_field(new_object());
%OptimizeFunctionOnNextCall(add_field, "parallel");
var o = new_object();
add_field(o); // Trigger optimization.
assertUnoptimized(add_field); // Not yet optimized.
o.c = 2.2; // Invalidate transition map.
%CompleteOptimization(add_field); // Conclude optimization with...
assertUnoptimized(add_field); // ... bailing out due to map dependency.
// Trigger optimization in the background thread.
add_field(o);
// Invalidate transition map while optimization is underway.
o.c = 2.2;
// Sync with background thread to conclude optimization that bailed out.
assertUnoptimized(add_field, "sync");
......@@ -48,4 +48,4 @@ f();
%OptimizeFunctionOnNextCall(g, "parallel");
f(0); // g() is disabled for optimization on inlining attempt.
// Attempt to optimize g() should not run into any assertion.
%CompleteOptimization(g);
assertUnoptimized(g, "sync");
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --noparallel-recompilation
// Flags: --allow-natives-syntax
// An exception thrown in a function optimized by on-stack replacement (OSR)
// should be able to construct a receiver from all optimized stack frames.
......@@ -52,7 +52,7 @@ function h() {
g();
} else {
// Run for a bit as long as h is unoptimized.
while (%GetOptimizationStatus(h) == 2) {
while (%GetOptimizationStatus(h, "no sync") == 2) {
for (var j = 0; j < 100; j++) g();
}
g();
......
......@@ -35,7 +35,7 @@ mul(0, 0);
mul(0, 0);
%OptimizeFunctionOnNextCall(mul);
assertEquals(0, mul(0, -1));
assertTrue(%GetOptimizationStatus(mul) != 2);
assertOptimized(mul);
function div(x, y) {
return (x / y) | 0;
......@@ -45,4 +45,4 @@ div(4, 2);
div(4, 2);
%OptimizeFunctionOnNextCall(div);
assertEquals(1, div(5, 3));
assertTrue(%GetOptimizationStatus(div) != 2);
assertOptimized(div);
......@@ -64,5 +64,5 @@ test();
// Second compilation should have noticed that LICM wasn't a good idea, and now
// function should no longer deopt when called.
test();
assertTrue(2 != %GetOptimizationStatus(test));
assertOptimized(test);
......@@ -36,5 +36,4 @@ foo();
%OptimizeFunctionOnNextCall(foo);
foo();
// Function should be optimized now.
assertTrue(%GetOptimizationStatus(foo) != 2);
assertOptimized(foo);
......@@ -27,18 +27,6 @@
// Flags: --allow-natives-syntax --expose-gc
/**
* The possible optimization states of a function. Must be in sync with the
* return values of Runtime_GetOptimizationStatus() in runtime.cc!
*/
var OptimizationState = {
YES: 1,
NO: 2,
ALWAYS: 3,
NEVER: 4
};
function simple() {
return simple_two_args(0, undefined);
}
......@@ -53,7 +41,5 @@ simple();
simple();
%OptimizeFunctionOnNextCall(simple);
simple();
var raw_optimized = %GetOptimizationStatus(simple);
assertFalse(raw_optimized == OptimizationState.NO);
assertOptimized(simple);
gc();
......@@ -37,5 +37,4 @@ f();
f();
%OptimizeFunctionOnNextCall(f);
f();
assertTrue(%GetOptimizationStatus(f) != 2);
assertOptimized(f);
......@@ -54,4 +54,4 @@ callConstantFunctionOnPrototype(receiver);
callConstantFunctionOnPrototype(receiver);
// Make sure that the function is still optimized.
assertTrue(2 != %GetOptimizationStatus(callConstantFunctionOnPrototype));
assertOptimized(callConstantFunctionOnPrototype);
......@@ -38,7 +38,7 @@ function f() {
}
f();
assertTrue(%GetOptimizationStatus(f) != 2);
assertOptimized(f);
function g() {
......@@ -70,5 +70,4 @@ function g() {
}
g();
assertTrue(%GetOptimizationStatus(g) != 2);
assertOptimized(g);
......@@ -46,7 +46,7 @@
function outer() {
inner(1,2,3);
// Trigger OSR.
while (%GetOptimizationStatus(outer) == 2) {}
while (%GetOptimizationStatus(outer, "no sync") == 2) {}
}
outer();
......
......@@ -34,19 +34,21 @@ if (!%IsParallelRecompilationSupported()) {
quit();
}
function assertUnoptimized(fun) {
assertTrue(%GetOptimizationStatus(fun) != 1);
}
function test(fun) {
fun();
fun();
// Mark for parallel optimization.
%OptimizeFunctionOnNextCall(fun, "parallel");
fun(); // Trigger optimization in the background.
gc(); // Tenure cons string.
assertUnoptimized(fun); // Compilation not complete yet.
%CompleteOptimization(fun); // Compilation embeds tenured cons string.
gc(); // Visit embedded cons string during mark compact.
//Trigger optimization in the background.
fun();
//Tenure cons string.
gc();
// In the mean time, parallel recompiling is not complete yet.
assertUnoptimized(fun, "no sync");
// Parallel recompilation eventually finishes and embeds tenured cons string.
assertOptimized(fun, "sync");
//Visit embedded cons string during mark compact.
gc();
}
function f() {
......
......@@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --parallel-recompilation --parallel-recompilation-delay=300
// Flags: --parallel-recompilation --parallel-recompilation-delay=100
if (!%IsParallelRecompilationSupported()) {
print("Parallel recompilation is disabled. Skipping this test.");
......@@ -62,7 +62,8 @@ f(); // Kick off parallel recompilation.
Debug.setListener(listener); // Activate debugger.
Debug.setBreakPoint(f, 2, 0); // Force deopt.
%CompleteOptimization(f); // Install optimized code.
// Sync with parallel optimization thread. But no optimized code is installed.
assertUnoptimized(f, "sync");
f(); // Trigger break point.
assertEquals(1, listened);
......
......@@ -28,7 +28,6 @@
// Test dictionary -> double elements -> dictionary elements round trip
// Flags: --allow-natives-syntax --unbox-double-arrays --expose-gc
// Flags: --noparallel-recompilation
var large_array_size = 100000;
var approx_dict_to_elements_threshold = 70000;
......@@ -346,7 +345,7 @@ function testOneArrayType(allocator) {
-Infinity,
expected_array_value(7));
assertTrue(%GetOptimizationStatus(test_various_stores) != 2);
assertOptimized(test_various_stores);
// Make sure that we haven't converted from fast double.
assertTrue(%HasFastDoubleElements(large_array));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment