From f820041aba63d9df8cb8a9241d573d99ff1d89a6 Mon Sep 17 00:00:00 2001 From: Mythri A Date: Fri, 3 May 2019 15:32:12 +0100 Subject: [PATCH] Reland "[Test] Update tests to work with lazy feedback allocation." This is a reland of 289b25765aa6bcfc76bdd45ce7018a5570cedf58. The fix for failures landed here: https://chromium-review.googlesource.com/c/v8/v8/+/1599388 Original change's description: > [Test] Update tests to work with lazy feedback allocation. > > This adds either %EnsureFeedbackVectorForFunction or > %PrepareFunctionForOptimization to allocate feedback vectors when testing > optimization, allocation sites, IC transitions etc., > > Bug: v8:8394 > Change-Id: I6ad1b6d460e4abda693b326cddb87754e080a0a1 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1593303 > Commit-Queue: Mythri Alle > Auto-Submit: Mythri Alle > Reviewed-by: Ross McIlroy > Cr-Commit-Position: refs/heads/master@{#61212} Bug: v8:8394 Change-Id: Idb5bba221d138e6fd73155f959b9e16fc948c709 TBR: rmcilroy@chromium.org Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1599607 Reviewed-by: Mythri Alle Commit-Queue: Mythri Alle Auto-Submit: Mythri Alle Cr-Commit-Position: refs/heads/master@{#61332} --- test/cctest/test-compiler.cc | 2 + .../debug/compiler/osr-typing-debug-change.js | 4 + test/debugger/debug/regress/regress-5279.js | 12 +- .../debug/regress/regress-crbug-387599.js | 1 + test/debugger/regress/regress-7421.js | 1 + test/mjsunit/array-constructor-feedback.js | 8 +- test/mjsunit/array-literal-transitions.js | 5 + test/mjsunit/array-shift4.js | 1 + test/mjsunit/array-store-and-grow.js | 3 + test/mjsunit/compiler/array-slice-clone.js | 8 +- ...ative-context-specialization-hole-check.js | 1 + .../compiler/number-comparison-truncations.js | 3 + test/mjsunit/compiler/optimized-for-in.js | 3 + test/mjsunit/compiler/osr-alignment.js | 3 + test/mjsunit/compiler/osr-array-len.js | 1 + test/mjsunit/compiler/osr-assert.js | 1 + test/mjsunit/compiler/osr-block-scope-id.js | 1 + test/mjsunit/compiler/osr-block-scope.js | 7 + test/mjsunit/compiler/osr-for-let.js | 5 + test/mjsunit/compiler/osr-forin-nested.js | 2 + test/mjsunit/compiler/osr-infinite.js | 8 + test/mjsunit/compiler/osr-labeled.js | 2 + test/mjsunit/compiler/osr-literals-adapted.js | 5 + test/mjsunit/compiler/osr-literals.js | 5 + test/mjsunit/compiler/osr-manual1.js | 2 + test/mjsunit/compiler/osr-manual2.js | 1 + test/mjsunit/compiler/osr-maze1.js | 1 + test/mjsunit/compiler/osr-maze2.js | 1 + test/mjsunit/compiler/osr-nested.js | 1 + test/mjsunit/compiler/osr-nested2b.js | 2 +- test/mjsunit/compiler/osr-one.js | 1 + test/mjsunit/compiler/osr-regex-id.js | 4 + test/mjsunit/compiler/osr-simple.js | 1 + test/mjsunit/compiler/osr-try-catch.js | 3 + test/mjsunit/compiler/osr-two.js | 1 + test/mjsunit/compiler/osr-while-let.js | 2 + test/mjsunit/compiler/regress-607493.js | 2 + test/mjsunit/compiler/regress-645851.js | 1 + test/mjsunit/compiler/regress-650215.js | 1 + test/mjsunit/compiler/regress-669517.js | 6 +- test/mjsunit/compiler/regress-673244.js | 1 + test/mjsunit/compiler/regress-803022.js | 1 + test/mjsunit/compiler/regress-919754.js | 1 + test/mjsunit/compiler/regress-958350.js | 1 + test/mjsunit/compiler/try-osr.js | 4 + .../concurrent-initial-prototype-change.js | 1 + test/mjsunit/const-field-tracking.js | 1 + test/mjsunit/deopt-recursive-eager-once.js | 1 + test/mjsunit/deopt-recursive-lazy-once.js | 1 + test/mjsunit/deopt-recursive-soft-once.js | 1 + test/mjsunit/deopt-with-fp-regs.js | 1 + test/mjsunit/deserialize-optimize-inner.js | 1 + test/mjsunit/div-mul-minus-one.js | 3 +- test/mjsunit/elements-transition-hoisting.js | 7 + test/mjsunit/ensure-growing-store-learns.js | 1 + test/mjsunit/field-type-tracking.js | 12 + .../fixed-context-shapes-when-recompiling.js | 481 ++++++++++++------ test/mjsunit/ignition/osr-from-bytecode.js | 1 + test/mjsunit/ignition/osr-from-generator.js | 4 + test/mjsunit/ignition/throw-if-hole.js | 4 + test/mjsunit/ignition/throw-if-not-hole.js | 6 + .../ignition/throw-super-not-called.js | 4 + test/mjsunit/interrupt-budget-override.js | 2 +- test/mjsunit/keyed-load-hole-to-undefined.js | 1 + test/mjsunit/keyed-load-with-string-key.js | 1 + test/mjsunit/keyed-load-with-symbol-key.js | 1 + test/mjsunit/math-floor-of-div-minus-zero.js | 1 + test/mjsunit/never-optimize.js | 3 + test/mjsunit/object-seal.js | 6 +- test/mjsunit/optimized-map.js | 34 +- test/mjsunit/parallel-optimize-disabled.js | 2 + .../regress/binop-in-effect-context-deopt.js | 2 + .../call-function-in-effect-context-deopt.js | 1 + test/mjsunit/regress/regress-1118.js | 4 + test/mjsunit/regress/regress-1257.js | 1 + test/mjsunit/regress/regress-2132.js | 2 + test/mjsunit/regress/regress-2339.js | 2 + test/mjsunit/regress/regress-2451.js | 1 + test/mjsunit/regress/regress-252797.js | 1 + test/mjsunit/regress/regress-2618.js | 4 +- test/mjsunit/regress/regress-298269.js | 1 + test/mjsunit/regress/regress-2989.js | 2 +- test/mjsunit/regress/regress-3032.js | 10 +- test/mjsunit/regress/regress-3650-3.js | 1 + test/mjsunit/regress/regress-3709.js | 1 + test/mjsunit/regress/regress-379770.js | 1 + test/mjsunit/regress/regress-385565.js | 1 + test/mjsunit/regress/regress-4121.js | 1 + test/mjsunit/regress/regress-4380.js | 1 + test/mjsunit/regress/regress-5252.js | 2 + test/mjsunit/regress/regress-5262.js | 1 + test/mjsunit/regress/regress-612412.js | 1 + test/mjsunit/regress/regress-6607-1.js | 1 + test/mjsunit/regress/regress-6607-2.js | 1 + test/mjsunit/regress/regress-6941.js | 1 + test/mjsunit/regress/regress-6948.js | 1 + test/mjsunit/regress/regress-6989.js | 8 + test/mjsunit/regress/regress-6991.js | 1 + test/mjsunit/regress/regress-7014-1.js | 2 + test/mjsunit/regress/regress-7014-2.js | 2 + test/mjsunit/regress/regress-7135.js | 2 + test/mjsunit/regress/regress-8913.js | 1 + test/mjsunit/regress/regress-902552.js | 12 +- test/mjsunit/regress/regress-903697.js | 14 +- test/mjsunit/regress/regress-crbug-150545.js | 2 + test/mjsunit/regress/regress-crbug-480807.js | 2 + test/mjsunit/regress/regress-crbug-513507.js | 2 + test/mjsunit/regress/regress-crbug-522895.js | 4 +- test/mjsunit/regress/regress-crbug-554831.js | 1 + test/mjsunit/regress/regress-crbug-587068.js | 1 + test/mjsunit/regress/regress-crbug-594183.js | 3 + test/mjsunit/regress/regress-crbug-638551.js | 2 + test/mjsunit/regress/regress-crbug-640369.js | 2 + test/mjsunit/regress/regress-crbug-645888.js | 1 + test/mjsunit/regress/regress-crbug-662830.js | 1 + test/mjsunit/regress/regress-crbug-665587.js | 1 + test/mjsunit/regress/regress-crbug-668795.js | 1 + .../mjsunit/regress/regress-crbug-882233-2.js | 2 + test/mjsunit/regress/regress-crbug-934166.js | 22 +- test/mjsunit/regress/regress-osr-context.js | 1 + .../regress/regress-param-local-type.js | 2 + .../regress/regress-store-uncacheable.js | 1 + .../regress/regress-sync-optimized-lists.js | 2 +- .../regress-trap-allocation-memento.js | 5 + test/mjsunit/shift-for-integer-div.js | 6 + test/mjsunit/sin-cos.js | 1 + test/mjsunit/smi-mul-const.js | 1 + test/mjsunit/strong-rooted-literals.js | 13 +- test/mjsunit/unary-minus-deopt.js | 2 + 129 files changed, 667 insertions(+), 212 deletions(-) diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc index 2a947b1d4b..71b47ebe84 100644 --- a/test/cctest/test-compiler.cc +++ b/test/cctest/test-compiler.cc @@ -784,7 +784,9 @@ TEST(InvocationCount) { CompileRun( "function bar() {};" + "%EnsureFeedbackVectorForFunction(bar);" "function foo() { return bar(); };" + "%EnsureFeedbackVectorForFunction(foo);" "foo();"); Handle foo = Handle::cast(GetGlobalProperty("foo")); CHECK_EQ(1, foo->feedback_vector()->invocation_count()); diff --git a/test/debugger/debug/compiler/osr-typing-debug-change.js b/test/debugger/debug/compiler/osr-typing-debug-change.js index 92eb899036..e0346dd358 100644 --- a/test/debugger/debug/compiler/osr-typing-debug-change.js +++ b/test/debugger/debug/compiler/osr-typing-debug-change.js @@ -37,6 +37,7 @@ function ChangeSmiConstantAndOsr() { } return j; } +%PrepareFunctionForOptimization(ChangeSmiConstantAndOsr); var r1 = ChangeSmiConstantAndOsr(); if (changed) { assertEquals("result", r1); @@ -54,6 +55,7 @@ function ChangeFloatConstantAndOsr() { } return j; } +%PrepareFunctionForOptimization(ChangeFloatConstantAndOsr); var r2 = ChangeFloatConstantAndOsr(); if (changed) { assertEquals("result", r2); @@ -72,6 +74,7 @@ function ChangeFloatVarAndOsr() { } return j; } +%PrepareFunctionForOptimization(ChangeFloatVarAndOsr); var r3 = ChangeFloatVarAndOsr(); if (changed) { assertEquals("result0.1", r3); @@ -105,6 +108,7 @@ function ChangeIntVarAndOsr() { } return j; } +%PrepareFunctionForOptimization(ChangeIntVarAndOsr); var r4 = ChangeIntVarAndOsr(); if (changed) { diff --git a/test/debugger/debug/regress/regress-5279.js b/test/debugger/debug/regress/regress-5279.js index 4a30ac5f1c..f2031dc518 100644 --- a/test/debugger/debug/regress/regress-5279.js +++ b/test/debugger/debug/regress/regress-5279.js @@ -7,9 +7,13 @@ var Debug = debug.Debug; Debug.setListener(() => undefined); -const myObj = {}; +function f() { + const myObj = {}; -for (let i = 0; i < 10; i++) { - %OptimizeOsr(); - %ScheduleBreak(); + for (let i = 0; i < 10; i++) { + %OptimizeOsr(); + %ScheduleBreak(); + } } +%PrepareFunctionForOptimization(f); +f() diff --git a/test/debugger/debug/regress/regress-crbug-387599.js b/test/debugger/debug/regress/regress-crbug-387599.js index bf15cbaec4..985f62ea8c 100644 --- a/test/debugger/debug/regress/regress-crbug-387599.js +++ b/test/debugger/debug/regress/regress-crbug-387599.js @@ -9,6 +9,7 @@ Debug.setListener(function() {}); function f() { for (var i = 0; i < 100; i++) %OptimizeOsr(); } +%PrepareFunctionForOptimization(f); Debug.setBreakPoint(f, 0, 0); f(); diff --git a/test/debugger/regress/regress-7421.js b/test/debugger/regress/regress-7421.js index 3a1ff45ec2..cb1e612d8b 100644 --- a/test/debugger/regress/regress-7421.js +++ b/test/debugger/regress/regress-7421.js @@ -23,6 +23,7 @@ function wrapper1() { } f1(); } +%PrepareFunctionForOptimization(wrapper1); function f2() { counter++; diff --git a/test/mjsunit/array-constructor-feedback.js b/test/mjsunit/array-constructor-feedback.js index aa6fbbed54..f26781ee95 100644 --- a/test/mjsunit/array-constructor-feedback.js +++ b/test/mjsunit/array-constructor-feedback.js @@ -67,6 +67,7 @@ function assertKind(expected, obj, name_opt) { function bar0(t) { return new t(); } + %PrepareFunctionForOptimization(bar0); a = bar0(Array); a[0] = 3.5; b = bar0(Array); @@ -77,7 +78,8 @@ function assertKind(expected, obj, name_opt) { assertOptimized(bar0); // bar0 should deopt b = bar0(Object); - assertUnoptimized(bar0) + assertUnoptimized(bar0); + %PrepareFunctionForOptimization(bar0); // When it's re-optimized, we should call through the full stub bar0(Array); %OptimizeFunctionOnNextCall(bar0); @@ -99,6 +101,7 @@ function assertKind(expected, obj, name_opt) { function bar() { return new Array(); } + %PrepareFunctionForOptimization(bar); a = bar(); bar(); %OptimizeFunctionOnNextCall(bar); @@ -115,6 +118,7 @@ function assertKind(expected, obj, name_opt) { // map for Array in that context will be used. (function() { function bar() { return new Array(); } + %PrepareFunctionForOptimization(bar); bar(); bar(); %OptimizeFunctionOnNextCall(bar); @@ -134,6 +138,7 @@ function assertKind(expected, obj, name_opt) { // should deal with arguments that create holey arrays. (function() { function bar(len) { return new Array(len); } + %PrepareFunctionForOptimization(bar); bar(0); bar(0); %OptimizeFunctionOnNextCall(bar); @@ -153,6 +158,7 @@ function assertKind(expected, obj, name_opt) { // Test: Make sure that crankshaft continues with feedback for large arrays. (function() { function bar(len) { return new Array(len); } + %PrepareFunctionForOptimization(bar); var size = 100001; // Perform a gc, because we are allocating a very large array and if a gc // happens during the allocation we could lose our memento. diff --git a/test/mjsunit/array-literal-transitions.js b/test/mjsunit/array-literal-transitions.js index f2f4d74900..84fbc27c54 100644 --- a/test/mjsunit/array-literal-transitions.js +++ b/test/mjsunit/array-literal-transitions.js @@ -79,6 +79,7 @@ function array_literal_test() { assertEquals(2, f0[1]); assertEquals(1, f0[0]); } +%PrepareFunctionForOptimization(array_literal_test); %PrepareFunctionForOptimization(array_literal_test); for (var i = 0; i < 3; i++) { @@ -109,6 +110,7 @@ function test_large_literal() { [0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, new Object(), new Object(), new Object(), new Object()]); } +%PrepareFunctionForOptimization(test_large_literal); %PrepareFunctionForOptimization(test_large_literal); for (var i = 0; i < 3; i++) { @@ -124,6 +126,7 @@ function deopt_array(use_literal) { return new Array(); } } +%PrepareFunctionForOptimization(deopt_array); %PrepareFunctionForOptimization(deopt_array); deopt_array(false); @@ -142,6 +145,7 @@ assertOptimized(deopt_array); function deopt_array_literal_all_smis(a) { return [0, 1, a]; } +%PrepareFunctionForOptimization(deopt_array_literal_all_smis); %PrepareFunctionForOptimization(deopt_array_literal_all_smis); deopt_array_literal_all_smis(2); @@ -168,6 +172,7 @@ assertEquals(.5, array[2]); function deopt_array_literal_all_doubles(a) { return [0.5, 1, a]; } +%PrepareFunctionForOptimization(deopt_array_literal_all_doubles); %PrepareFunctionForOptimization(deopt_array_literal_all_doubles); deopt_array_literal_all_doubles(.5); diff --git a/test/mjsunit/array-shift4.js b/test/mjsunit/array-shift4.js index 5d28fd306a..40378ae554 100644 --- a/test/mjsunit/array-shift4.js +++ b/test/mjsunit/array-shift4.js @@ -17,6 +17,7 @@ function makeArray() { return a; } +%PrepareFunctionForOptimization(doShift); doShift(makeArray()); doShift(makeArray()); %OptimizeFunctionOnNextCall(doShift); diff --git a/test/mjsunit/array-store-and-grow.js b/test/mjsunit/array-store-and-grow.js index ee831ad061..d717c6dfa6 100644 --- a/test/mjsunit/array-store-and-grow.js +++ b/test/mjsunit/array-store-and-grow.js @@ -197,6 +197,7 @@ assertEquals(0.5, array_store_1([], 0, 0.5)); a[b] = c; } + %PrepareFunctionForOptimization(grow_store); a = new Array(1); grow_store(a,1,1); grow_store(a,2,1); @@ -216,6 +217,7 @@ assertEquals(0.5, array_store_1([], 0, 0.5)); function f(o, k, v) { o[k] = v; } + %PrepareFunctionForOptimization(f); a = [3.5]; f(a, 1, "hi"); // DOUBLE packed array -> tagged packed grow @@ -238,6 +240,7 @@ assertEquals(0.5, array_store_1([], 0, 0.5)); function f(o, k, v) { o[k] = v; } + %PrepareFunctionForOptimization(f); a = [3.5]; f(a, 0, "hi"); // DOUBLE packed array -> tagged packed grow diff --git a/test/mjsunit/compiler/array-slice-clone.js b/test/mjsunit/compiler/array-slice-clone.js index d15acfaa3b..fc002da2c3 100644 --- a/test/mjsunit/compiler/array-slice-clone.js +++ b/test/mjsunit/compiler/array-slice-clone.js @@ -21,6 +21,7 @@ } %PrepareFunctionForOptimization(slice0); + %PrepareFunctionForOptimization(slice); assertEquals(arr, slice()); assertFalse(arr === slice()); @@ -29,7 +30,6 @@ %OptimizeFunctionOnNextCall(slice0); assertEquals(slice(), slice0()); - %PrepareFunctionForOptimization(slice); %OptimizeFunctionOnNextCall(slice); assertEquals(slice(), slice0()); @@ -415,6 +415,7 @@ function test() { %PrepareFunctionForOptimization(slice0); + %PrepareFunctionForOptimization(slice); assertEquals(arr, slice()); assertFalse(arr === slice()); @@ -423,7 +424,6 @@ %OptimizeFunctionOnNextCall(slice0); assertEquals(slice(), slice0()); - %PrepareFunctionForOptimization(slice); %OptimizeFunctionOnNextCall(slice); assertEquals(slice(), slice0()); @@ -455,13 +455,13 @@ } function test() { + %PrepareFunctionForOptimization(slice0); + %PrepareFunctionForOptimization(slice); assertEquals(arr, slice()); assertFalse(arr === slice()); assertEquals(slice(), slice0()); assertEquals(slice0(), slice()); - %PrepareFunctionForOptimization(slice0); - %PrepareFunctionForOptimization(slice); %OptimizeFunctionOnNextCall(slice0); assertEquals(slice(), slice0()); %OptimizeFunctionOnNextCall(slice); diff --git a/test/mjsunit/compiler/native-context-specialization-hole-check.js b/test/mjsunit/compiler/native-context-specialization-hole-check.js index b0b0cb28d0..7ccdfffa05 100644 --- a/test/mjsunit/compiler/native-context-specialization-hole-check.js +++ b/test/mjsunit/compiler/native-context-specialization-hole-check.js @@ -38,6 +38,7 @@ function f() { arr[500] = 20; arr[10] = arr[50]; } +%EnsureFeedbackVectorForFunction(f); function g() { f(); diff --git a/test/mjsunit/compiler/number-comparison-truncations.js b/test/mjsunit/compiler/number-comparison-truncations.js index 8ca710a5ef..f0df98a0cd 100644 --- a/test/mjsunit/compiler/number-comparison-truncations.js +++ b/test/mjsunit/compiler/number-comparison-truncations.js @@ -32,6 +32,7 @@ (function() { // Produce a SpeculativeNumberEqual with Number feedback. function bar(x, y) { return x === y; } + %EnsureFeedbackVectorForFunction(bar); bar(0.1, 0.5); bar(-0, 100); @@ -83,6 +84,7 @@ (function() { // Produce a SpeculativeNumberLessThan with Number feedback. function bar(x, y) { return x < y; } + %EnsureFeedbackVectorForFunction(bar); bar(0.1, 0.5); bar(-0, 100); @@ -134,6 +136,7 @@ (function() { // Produce a SpeculativeNumberLessThanOrEqual with Number feedback. function bar(x, y) { return x <= y; } + %EnsureFeedbackVectorForFunction(bar); bar(0.1, 0.5); bar(-0, 100); diff --git a/test/mjsunit/compiler/optimized-for-in.js b/test/mjsunit/compiler/optimized-for-in.js index 5af7caaef2..70c45cecfe 100644 --- a/test/mjsunit/compiler/optimized-for-in.js +++ b/test/mjsunit/compiler/optimized-for-in.js @@ -269,6 +269,7 @@ function osr_inner(t, limit) { } return r; } +%PrepareFunctionForOptimization(osr_inner); function osr_outer(t, osr_after) { var r = 1; @@ -281,6 +282,7 @@ function osr_outer(t, osr_after) { } return r; } +%PrepareFunctionForOptimization(osr_outer); function osr_outer_and_deopt(t, osr_after) { var r = 1; @@ -290,6 +292,7 @@ function osr_outer_and_deopt(t, osr_after) { } return r; } +%PrepareFunctionForOptimization(osr_outer_and_deopt); function test_osr() { with ({}) {} // Disable optimizations of this function. diff --git a/test/mjsunit/compiler/osr-alignment.js b/test/mjsunit/compiler/osr-alignment.js index f815e712ee..7a348ca377 100644 --- a/test/mjsunit/compiler/osr-alignment.js +++ b/test/mjsunit/compiler/osr-alignment.js @@ -38,6 +38,7 @@ function f1() { } return sum; } +%PrepareFunctionForOptimization(f1); function f2() { var sum = 0; @@ -50,6 +51,7 @@ function f2() { } return sum; } +%PrepareFunctionForOptimization(f2); function f3() { var sum = 0; @@ -62,6 +64,7 @@ function f3() { } return sum; } +%PrepareFunctionForOptimization(f3); function test1() { var j = 11; diff --git a/test/mjsunit/compiler/osr-array-len.js b/test/mjsunit/compiler/osr-array-len.js index aaee860d61..f691380e6a 100644 --- a/test/mjsunit/compiler/osr-array-len.js +++ b/test/mjsunit/compiler/osr-array-len.js @@ -14,6 +14,7 @@ function fastaRandom(n, table) { n--; } } +%PrepareFunctionForOptimization(fastaRandom); print("---BEGIN 1"); assertEquals(undefined, fastaRandom(6, null)); diff --git a/test/mjsunit/compiler/osr-assert.js b/test/mjsunit/compiler/osr-assert.js index c67ad536ad..5a0ff2e71c 100644 --- a/test/mjsunit/compiler/osr-assert.js +++ b/test/mjsunit/compiler/osr-assert.js @@ -41,4 +41,5 @@ function f(x, b, c) { return a + 4; } +%PrepareFunctionForOptimization(f); assertEquals(55, f(5, "122", "1221")); diff --git a/test/mjsunit/compiler/osr-block-scope-id.js b/test/mjsunit/compiler/osr-block-scope-id.js index bcc7cdd47d..ed5bbf1b57 100644 --- a/test/mjsunit/compiler/osr-block-scope-id.js +++ b/test/mjsunit/compiler/osr-block-scope-id.js @@ -24,6 +24,7 @@ function foo() { result.push(out); return result; } +%PrepareFunctionForOptimization(foo); function check() { diff --git a/test/mjsunit/compiler/osr-block-scope.js b/test/mjsunit/compiler/osr-block-scope.js index c60f8af6c9..7593909673 100644 --- a/test/mjsunit/compiler/osr-block-scope.js +++ b/test/mjsunit/compiler/osr-block-scope.js @@ -28,6 +28,7 @@ function test(expected, func, depth) { for (var depth = 1; depth < 4; depth++) { var body = nest(orig, name, depth); func = eval("(" + body + ")"); + %PrepareFunctionForOptimization(func); assertEquals(expected, func()); assertEquals(expected, func()); @@ -47,6 +48,7 @@ function foo() { } return result; } +%PrepareFunctionForOptimization(foo); test(45, foo); @@ -58,6 +60,7 @@ function bar() { } return sum; } +%PrepareFunctionForOptimization(bar); test(45, bar); @@ -71,6 +74,7 @@ function bon() { return sum; } } +%PrepareFunctionForOptimization(bon); test(45, bon); @@ -87,6 +91,7 @@ function row() { } return 11; } +%PrepareFunctionForOptimization(row); test(7, row); @@ -98,6 +103,7 @@ function nub() { } return i; } +%PrepareFunctionForOptimization(nub); test(2, nub); @@ -112,5 +118,6 @@ function kub() { } return result; } +%PrepareFunctionForOptimization(kub); test(1, kub); diff --git a/test/mjsunit/compiler/osr-for-let.js b/test/mjsunit/compiler/osr-for-let.js index b8cef780b5..3ecbe04ed2 100644 --- a/test/mjsunit/compiler/osr-for-let.js +++ b/test/mjsunit/compiler/osr-for-let.js @@ -24,6 +24,7 @@ function bar() { } return result; } +%PrepareFunctionForOptimization(bar); test(4005, bar); @@ -35,6 +36,7 @@ function baz() { } return sum; } +%PrepareFunctionForOptimization(baz); test(2, baz); @@ -46,6 +48,7 @@ function qux() { } return result; } +%PrepareFunctionForOptimization(qux); test(1, qux); @@ -60,6 +63,7 @@ function nux() { } return result; } +%PrepareFunctionForOptimization(nux); test(1, nux); @@ -78,5 +82,6 @@ function blo() { } return result; } +%PrepareFunctionForOptimization(blo); test(4005, blo()); diff --git a/test/mjsunit/compiler/osr-forin-nested.js b/test/mjsunit/compiler/osr-forin-nested.js index dd810897e0..d3e0c19721 100644 --- a/test/mjsunit/compiler/osr-forin-nested.js +++ b/test/mjsunit/compiler/osr-forin-nested.js @@ -18,6 +18,7 @@ function foo(t) { } return 5; } +%PrepareFunctionForOptimization(foo); test(5, foo, {x:20}); @@ -31,5 +32,6 @@ function bar(t) { } return sum; } +%PrepareFunctionForOptimization(bar); test(62, bar, {x:20,y:11}); diff --git a/test/mjsunit/compiler/osr-infinite.js b/test/mjsunit/compiler/osr-infinite.js index 24c7add272..bfd4b7e3c8 100644 --- a/test/mjsunit/compiler/osr-infinite.js +++ b/test/mjsunit/compiler/osr-infinite.js @@ -11,6 +11,7 @@ function thrower() { if (x == 5) %OptimizeOsr(1); if (x == 10) throw "terminate"; } +%PrepareFunctionForOptimization(thrower); %NeverOptimizeFunction(thrower); // Don't want to inline the thrower. %NeverOptimizeFunction(test); // Don't want to inline the func into test. @@ -25,18 +26,22 @@ function test(func) { function n1() { while (true) thrower(); } +%PrepareFunctionForOptimization(n1); function n2() { while (true) while (true) thrower(); } +%PrepareFunctionForOptimization(n2); function n3() { while (true) while (true) while (true) thrower(); } +%PrepareFunctionForOptimization(n3); function n4() { while (true) while (true) while (true) while (true) thrower(); } +%PrepareFunctionForOptimization(n4); function b1(a) { while (true) { @@ -44,6 +49,7 @@ function b1(a) { if (a) break } } +%PrepareFunctionForOptimization(b1); function b2(a) { @@ -54,6 +60,7 @@ function b2(a) { } } } +%PrepareFunctionForOptimization(b2); function b3(a) { @@ -67,6 +74,7 @@ function b3(a) { } } } +%PrepareFunctionForOptimization(b3); test(n1); diff --git a/test/mjsunit/compiler/osr-labeled.js b/test/mjsunit/compiler/osr-labeled.js index 1384e9a715..ba905f394e 100644 --- a/test/mjsunit/compiler/osr-labeled.js +++ b/test/mjsunit/compiler/osr-labeled.js @@ -17,6 +17,7 @@ function foo() { } return sum; } +%PrepareFunctionForOptimization(foo); assertEquals(30, foo()); assertEquals(30, foo()); @@ -36,6 +37,7 @@ function bar(a) { } return sum; } +%PrepareFunctionForOptimization(bar); assertEquals(1, bar(1)); assertEquals(1, bar(1)); diff --git a/test/mjsunit/compiler/osr-literals-adapted.js b/test/mjsunit/compiler/osr-literals-adapted.js index 4d1798c929..4b6fd766f7 100644 --- a/test/mjsunit/compiler/osr-literals-adapted.js +++ b/test/mjsunit/compiler/osr-literals-adapted.js @@ -11,6 +11,7 @@ function mod() { } return {blah: i}; } + %PrepareFunctionForOptimization(f0); function f1(a) { for (var i = 0; i < 3; i = i + 1 | 0) { @@ -18,6 +19,7 @@ function mod() { } return {blah: i}; } + %PrepareFunctionForOptimization(f1); function f2(a,b) { for (var i = 0; i < 3; i = i + 1 | 0) { @@ -25,6 +27,7 @@ function mod() { } return {blah: i}; } + %PrepareFunctionForOptimization(f2); function f3(a,b,c) { for (var i = 0; i < 3; i = i + 1 | 0) { @@ -32,6 +35,7 @@ function mod() { } return {blah: i}; } + %PrepareFunctionForOptimization(f3); function f4(a,b,c,d) { for (var i = 0; i < 3; i = i + 1 | 0) { @@ -39,6 +43,7 @@ function mod() { } return {blah: i}; } + %PrepareFunctionForOptimization(f4); function bar() { assertEquals(3, f0().blah); diff --git a/test/mjsunit/compiler/osr-literals.js b/test/mjsunit/compiler/osr-literals.js index f2051dced7..c5179d0e18 100644 --- a/test/mjsunit/compiler/osr-literals.js +++ b/test/mjsunit/compiler/osr-literals.js @@ -11,6 +11,7 @@ function mod() { } return {blah: i}; } + %PrepareFunctionForOptimization(f0); function f1(a) { for (var i = 0; i < 3; i = i + 1 | 0) { @@ -18,6 +19,7 @@ function mod() { } return {blah: i}; } + %PrepareFunctionForOptimization(f1); function f2(a,b) { for (var i = 0; i < 3; i = i + 1 | 0) { @@ -25,6 +27,7 @@ function mod() { } return {blah: i}; } + %PrepareFunctionForOptimization(f2); function f3(a,b,c) { for (var i = 0; i < 3; i = i + 1 | 0) { @@ -32,6 +35,7 @@ function mod() { } return {blah: i}; } + %PrepareFunctionForOptimization(f3); function f4(a,b,c,d) { for (var i = 0; i < 3; i = i + 1 | 0) { @@ -39,6 +43,7 @@ function mod() { } return {blah: i}; } + %PrepareFunctionForOptimization(f4); function bar() { assertEquals(3, f0().blah); diff --git a/test/mjsunit/compiler/osr-manual1.js b/test/mjsunit/compiler/osr-manual1.js index c3db796f11..0a24ba6d3e 100644 --- a/test/mjsunit/compiler/osr-manual1.js +++ b/test/mjsunit/compiler/osr-manual1.js @@ -22,10 +22,12 @@ function gen(w) { // defeat compiler cache. "} f" + num; return eval(src); } +%PrepareFunctionForOptimization(gen); function check(x,a,b,c) { for (var i = 0; i < 3; i++) { var f = gen(i); + %PrepareFunctionForOptimization(f); assertEquals(x, f(a, b, c)); } } diff --git a/test/mjsunit/compiler/osr-manual2.js b/test/mjsunit/compiler/osr-manual2.js index de7ec243fe..3359e83d2e 100644 --- a/test/mjsunit/compiler/osr-manual2.js +++ b/test/mjsunit/compiler/osr-manual2.js @@ -26,6 +26,7 @@ function gen(w) { // defeat compiler cache. function check(x,a,b,c) { for (var i = 0; i < 3; i++) { var f = gen(i); + %PrepareFunctionForOptimization(f); assertEquals(x, f(a, b, c)); } } diff --git a/test/mjsunit/compiler/osr-maze1.js b/test/mjsunit/compiler/osr-maze1.js index da17282742..2f51d3de21 100644 --- a/test/mjsunit/compiler/osr-maze1.js +++ b/test/mjsunit/compiler/osr-maze1.js @@ -44,6 +44,7 @@ function bar(goal) { } return sum; } +%PrepareFunctionForOptimization(bar); for (var i = 0; i < 13; i++) { %DeoptimizeFunction(bar); diff --git a/test/mjsunit/compiler/osr-maze2.js b/test/mjsunit/compiler/osr-maze2.js index 1fc1cd2db1..5255dab191 100644 --- a/test/mjsunit/compiler/osr-maze2.js +++ b/test/mjsunit/compiler/osr-maze2.js @@ -59,5 +59,6 @@ function gen(i) { for (var i = 1; i < 10; i++) { var f = gen(i); + %PrepareFunctionForOptimization(f); assertEquals(1979, f()); } diff --git a/test/mjsunit/compiler/osr-nested.js b/test/mjsunit/compiler/osr-nested.js index 28c42c8f73..7add40ed53 100644 --- a/test/mjsunit/compiler/osr-nested.js +++ b/test/mjsunit/compiler/osr-nested.js @@ -40,6 +40,7 @@ function f() { } return sum; } +%PrepareFunctionForOptimization(f); assertEquals(1450, f()); diff --git a/test/mjsunit/compiler/osr-nested2b.js b/test/mjsunit/compiler/osr-nested2b.js index 18088114a4..390979dda7 100644 --- a/test/mjsunit/compiler/osr-nested2b.js +++ b/test/mjsunit/compiler/osr-nested2b.js @@ -19,7 +19,7 @@ function f() { return sum; } - +%PrepareFunctionForOptimization(f); assertEquals(15000, f()); assertEquals(15000, f()); assertEquals(15000, f()); diff --git a/test/mjsunit/compiler/osr-one.js b/test/mjsunit/compiler/osr-one.js index d52a1c8089..3b38715a31 100644 --- a/test/mjsunit/compiler/osr-one.js +++ b/test/mjsunit/compiler/osr-one.js @@ -16,5 +16,6 @@ function f(x) { } return sum; } +%PrepareFunctionForOptimization(f); assertEquals(50, f(5)); diff --git a/test/mjsunit/compiler/osr-regex-id.js b/test/mjsunit/compiler/osr-regex-id.js index e0b4dad1dc..1f66297ccd 100644 --- a/test/mjsunit/compiler/osr-regex-id.js +++ b/test/mjsunit/compiler/osr-regex-id.js @@ -13,6 +13,7 @@ function foo(a) { } return r; } +%PrepareFunctionForOptimization(foo); function bar(a) { for (var i = 0; i < 10; i++) { @@ -21,6 +22,7 @@ function bar(a) { } return r; } +%PrepareFunctionForOptimization(bar); function baz(a) { for (var i = 0; i < 10; i++) { @@ -28,6 +30,7 @@ function baz(a) { } return /\0/; } +%PrepareFunctionForOptimization(baz); function qux(a) { for (var i = 0; i < 10; i++) { @@ -39,6 +42,7 @@ function qux(a) { } return r; } +%PrepareFunctionForOptimization(qux); function test(f) { // Test the reference equality of regex's created in OSR'd function. diff --git a/test/mjsunit/compiler/osr-simple.js b/test/mjsunit/compiler/osr-simple.js index ddbc5f8867..c8585f2991 100644 --- a/test/mjsunit/compiler/osr-simple.js +++ b/test/mjsunit/compiler/osr-simple.js @@ -15,6 +15,7 @@ function f() { } return sum; } +%PrepareFunctionForOptimization(f); for (var i = 0; i < 2; i++) { diff --git a/test/mjsunit/compiler/osr-try-catch.js b/test/mjsunit/compiler/osr-try-catch.js index 9924e88d55..79389fd8ca 100644 --- a/test/mjsunit/compiler/osr-try-catch.js +++ b/test/mjsunit/compiler/osr-try-catch.js @@ -19,6 +19,7 @@ function SingleLoop() { } } } +%PrepareFunctionForOptimization(SingleLoop); // These function could also fail if the exception handlers are not updated at @@ -38,6 +39,7 @@ function EmptyBody() { a++; } } +%PrepareFunctionForOptimization(EmptyBody); function NestedLoops() { for (var a = 0; a < 2; a++) { @@ -52,6 +54,7 @@ function NestedLoops() { } } } +%PrepareFunctionForOptimization(NestedLoops); SingleLoop(); diff --git a/test/mjsunit/compiler/osr-two.js b/test/mjsunit/compiler/osr-two.js index 36842b4beb..4409dc3bae 100644 --- a/test/mjsunit/compiler/osr-two.js +++ b/test/mjsunit/compiler/osr-two.js @@ -20,5 +20,6 @@ function f(x) { } return sum; } +%PrepareFunctionForOptimization(f); assertEquals(500, f(5)); diff --git a/test/mjsunit/compiler/osr-while-let.js b/test/mjsunit/compiler/osr-while-let.js index 11ebc4bb35..906e92bb21 100644 --- a/test/mjsunit/compiler/osr-while-let.js +++ b/test/mjsunit/compiler/osr-while-let.js @@ -35,6 +35,7 @@ function foo() { } return result; } +%PrepareFunctionForOptimization(foo); test(1, foo); @@ -54,5 +55,6 @@ function smo() { } return result; } +%PrepareFunctionForOptimization(smo); test(11, smo); diff --git a/test/mjsunit/compiler/regress-607493.js b/test/mjsunit/compiler/regress-607493.js index 540b47e2d2..adfef8a6ee 100644 --- a/test/mjsunit/compiler/regress-607493.js +++ b/test/mjsunit/compiler/regress-607493.js @@ -18,6 +18,7 @@ } } + %PrepareFunctionForOptimization(g); g(); })(); @@ -33,5 +34,6 @@ } } + %PrepareFunctionForOptimization(g); g(); })(); diff --git a/test/mjsunit/compiler/regress-645851.js b/test/mjsunit/compiler/regress-645851.js index 0ea70bd71e..f79a942405 100644 --- a/test/mjsunit/compiler/regress-645851.js +++ b/test/mjsunit/compiler/regress-645851.js @@ -16,4 +16,5 @@ function f() { return sum; } +%PrepareFunctionForOptimization(f); f(); diff --git a/test/mjsunit/compiler/regress-650215.js b/test/mjsunit/compiler/regress-650215.js index 95ae6cfed1..67ac3d99a9 100644 --- a/test/mjsunit/compiler/regress-650215.js +++ b/test/mjsunit/compiler/regress-650215.js @@ -13,4 +13,5 @@ function f() { return x; } +%PrepareFunctionForOptimization(f); assertEquals(0, f()); diff --git a/test/mjsunit/compiler/regress-669517.js b/test/mjsunit/compiler/regress-669517.js index 1905260978..d6bbfd8cd1 100644 --- a/test/mjsunit/compiler/regress-669517.js +++ b/test/mjsunit/compiler/regress-669517.js @@ -6,12 +6,14 @@ (function() { "use asm"; - return function() { + var f = function() { for (var i = 0; i < 10; i++) { if (i == 5) { %OptimizeOsr(); } } with (Object()); - } + }; + %PrepareFunctionForOptimization(f); + return f; })()(); diff --git a/test/mjsunit/compiler/regress-673244.js b/test/mjsunit/compiler/regress-673244.js index b18d47b8dd..b962e6a517 100644 --- a/test/mjsunit/compiler/regress-673244.js +++ b/test/mjsunit/compiler/regress-673244.js @@ -12,4 +12,5 @@ function f() { } } +%PrepareFunctionForOptimization(f); f(); diff --git a/test/mjsunit/compiler/regress-803022.js b/test/mjsunit/compiler/regress-803022.js index 30e13cf032..eea754544f 100644 --- a/test/mjsunit/compiler/regress-803022.js +++ b/test/mjsunit/compiler/regress-803022.js @@ -13,4 +13,5 @@ function foo() { } } +%PrepareFunctionForOptimization(foo); foo(); diff --git a/test/mjsunit/compiler/regress-919754.js b/test/mjsunit/compiler/regress-919754.js index 5f20aad928..25d76a0615 100644 --- a/test/mjsunit/compiler/regress-919754.js +++ b/test/mjsunit/compiler/regress-919754.js @@ -12,4 +12,5 @@ function f(get, ...a) { } return get(); } +%PrepareFunctionForOptimization(f); assertThrows(f); diff --git a/test/mjsunit/compiler/regress-958350.js b/test/mjsunit/compiler/regress-958350.js index ee9d5c098b..5f6d9162c3 100644 --- a/test/mjsunit/compiler/regress-958350.js +++ b/test/mjsunit/compiler/regress-958350.js @@ -11,6 +11,7 @@ function foo(o) { } } +%PrepareFunctionForOptimization(foo); foo([1]); foo([1]); %OptimizeFunctionOnNextCall(foo); diff --git a/test/mjsunit/compiler/try-osr.js b/test/mjsunit/compiler/try-osr.js index c0ef27add3..fc6c9e43b0 100644 --- a/test/mjsunit/compiler/try-osr.js +++ b/test/mjsunit/compiler/try-osr.js @@ -13,6 +13,7 @@ function OSRInsideTry(x) { } return x + 2; } +%PrepareFunctionForOptimization(OSRInsideTry); assertEquals(24, OSRInsideTry(23)); @@ -25,6 +26,7 @@ function OSRInsideCatch(x) { } return x + 2; } +%PrepareFunctionForOptimization(OSRInsideCatch); assertEquals(24, OSRInsideCatch(23)); @@ -37,6 +39,7 @@ function OSRInsideFinally_Return(x) { } return x + 2; } +%PrepareFunctionForOptimization(OSRInsideFinally_Return); assertEquals(24, OSRInsideFinally_Return(23)); @@ -48,4 +51,5 @@ function OSRInsideFinally_ReThrow(x) { } return x + 2; } +%PrepareFunctionForOptimization(OSRInsideFinally_ReThrow); assertThrows("OSRInsideFinally_ReThrow(new Error)", Error); diff --git a/test/mjsunit/concurrent-initial-prototype-change.js b/test/mjsunit/concurrent-initial-prototype-change.js index 245aedc8af..f4edee5907 100644 --- a/test/mjsunit/concurrent-initial-prototype-change.js +++ b/test/mjsunit/concurrent-initial-prototype-change.js @@ -44,6 +44,7 @@ if (!%IsConcurrentRecompilationSupported()) { function f1(a, i) { return a[i] + 0.5; } +%PrepareFunctionForOptimization(f1); %PrepareFunctionForOptimization(f1); var arr = [0.0,,2.5]; diff --git a/test/mjsunit/const-field-tracking.js b/test/mjsunit/const-field-tracking.js index 633ef70feb..bc979b80b4 100644 --- a/test/mjsunit/const-field-tracking.js +++ b/test/mjsunit/const-field-tracking.js @@ -99,6 +99,7 @@ function TestLoadFromConstantFieldOfAPrototype(the_value, other_value) { // Ensure O.prototype is in fast mode by loading from its field. function warmup() { return new O().v; } + %EnsureFeedbackVectorForFunction(warmup); warmup(); warmup(); warmup(); assertTrue(%HasFastProperties(O.prototype)); diff --git a/test/mjsunit/deopt-recursive-eager-once.js b/test/mjsunit/deopt-recursive-eager-once.js index 23bddc067b..5fa2c3c4f8 100644 --- a/test/mjsunit/deopt-recursive-eager-once.js +++ b/test/mjsunit/deopt-recursive-eager-once.js @@ -14,6 +14,7 @@ function foo(i, deopt = false) { foo(i - 1, deopt); } } +%PrepareFunctionForOptimization(foo); assertEquals(0, %GetDeoptCount(foo)); diff --git a/test/mjsunit/deopt-recursive-lazy-once.js b/test/mjsunit/deopt-recursive-lazy-once.js index fffa2c84b2..19acdd77c6 100644 --- a/test/mjsunit/deopt-recursive-lazy-once.js +++ b/test/mjsunit/deopt-recursive-lazy-once.js @@ -14,6 +14,7 @@ function foo(i, deopt = false) { foo(i - 1, deopt); } } +%PrepareFunctionForOptimization(foo); %PrepareFunctionForOptimization(foo); assertEquals(0, %GetDeoptCount(foo)); diff --git a/test/mjsunit/deopt-recursive-soft-once.js b/test/mjsunit/deopt-recursive-soft-once.js index f2cadf2e54..9ee761042c 100644 --- a/test/mjsunit/deopt-recursive-soft-once.js +++ b/test/mjsunit/deopt-recursive-soft-once.js @@ -18,6 +18,7 @@ function foo(i, deopt = false, deoptobj = null) { assertEquals(0, %GetDeoptCount(foo)); +%PrepareFunctionForOptimization(foo); foo(10); foo(10); %OptimizeFunctionOnNextCall(foo); diff --git a/test/mjsunit/deopt-with-fp-regs.js b/test/mjsunit/deopt-with-fp-regs.js index bdb08053ae..d5f02ac363 100644 --- a/test/mjsunit/deopt-with-fp-regs.js +++ b/test/mjsunit/deopt-with-fp-regs.js @@ -75,6 +75,7 @@ function test(a, b, c, d, e, v) { assertEquals(24, d); assertEquals(37.5, e); } +%PrepareFunctionForOptimization(test); test(10.0, 20.0, 30.0, 40.0, 50.0, 1.5); diff --git a/test/mjsunit/deserialize-optimize-inner.js b/test/mjsunit/deserialize-optimize-inner.js index ca78b8a4b0..50976bce11 100644 --- a/test/mjsunit/deserialize-optimize-inner.js +++ b/test/mjsunit/deserialize-optimize-inner.js @@ -6,6 +6,7 @@ function f(x, y) { return x + y; } +%PrepareFunctionForOptimization(f); assertEquals(1, f(0, 1)); assertEquals(5, f(2, 3)); %OptimizeFunctionOnNextCall(f); diff --git a/test/mjsunit/div-mul-minus-one.js b/test/mjsunit/div-mul-minus-one.js index 71ad299610..da6f8e3c30 100644 --- a/test/mjsunit/div-mul-minus-one.js +++ b/test/mjsunit/div-mul-minus-one.js @@ -30,7 +30,7 @@ function div(g) { return (g/-1) ^ 1 } - +%PrepareFunctionForOptimization(div); var kMinInt = 1 << 31; var expected_MinInt = div(kMinInt); var expected_minus_zero = div(0); @@ -42,6 +42,7 @@ function mul(g) { return (g * -1) ^ 1 } +%PrepareFunctionForOptimization(mul); expected_MinInt = mul(kMinInt); expected_minus_zero = mul(0); %OptimizeFunctionOnNextCall(mul); diff --git a/test/mjsunit/elements-transition-hoisting.js b/test/mjsunit/elements-transition-hoisting.js index dcd742e621..0406dc7f17 100644 --- a/test/mjsunit/elements-transition-hoisting.js +++ b/test/mjsunit/elements-transition-hoisting.js @@ -45,6 +45,7 @@ function test_wrapper() { } while (--count > 0); } + %PrepareFunctionForOptimization(testDoubleConversion4); testDoubleConversion4(new Array(5)); testDoubleConversion4(new Array(5)); // Call twice to make sure that second // store is a transition and not @@ -71,6 +72,7 @@ function test_wrapper() { } while (--count > 0); } + %PrepareFunctionForOptimization(testExactMapHoisting); testExactMapHoisting(new Array(5)); testExactMapHoisting(new Array(5)); // Call twice to make sure that second // store is a transition and not @@ -102,6 +104,7 @@ function test_wrapper() { } while (--count > 0); } + %PrepareFunctionForOptimization(testExactMapHoisting2); testExactMapHoisting2(new Array(5)); testExactMapHoisting2(new Array(5)); // Call twice to make sure that second // store is a transition and not @@ -129,6 +132,7 @@ function test_wrapper() { } while (--count > 0); } + %PrepareFunctionForOptimization(testExactMapHoisting3); var add_transition = new Array(5); add_transition.foo = 0; add_transition[0] = new Object(); // For FAST_ELEMENT transition to be created @@ -155,6 +159,7 @@ function test_wrapper() { } /* + %PrepareFunctionForOptimization(testDominatingTransitionHoisting1); testDominatingTransitionHoisting1(new Array(5)); testDominatingTransitionHoisting1(new Array(5)); // Call twice to make sure // that second store is a @@ -180,6 +185,7 @@ function test_wrapper() { } while (--count > 3); } + %PrepareFunctionForOptimization(testHoistingWithSideEffect); testHoistingWithSideEffect(new Array(5)); testHoistingWithSideEffect(new Array(5)); // Call twice to make sure that // second store is a transition and @@ -203,6 +209,7 @@ function test_wrapper() { } while (--count > 3); } + %PrepareFunctionForOptimization(testStraightLineDupeElinination); testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,0,.5); testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,.5,0); testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,.5,0,0); diff --git a/test/mjsunit/ensure-growing-store-learns.js b/test/mjsunit/ensure-growing-store-learns.js index 95e28937b1..5340919472 100644 --- a/test/mjsunit/ensure-growing-store-learns.js +++ b/test/mjsunit/ensure-growing-store-learns.js @@ -30,6 +30,7 @@ assertUnoptimized(foo); assertTrue(%HasDictionaryElements(a)); + %PrepareFunctionForOptimization(foo); var b = []; foo(b, 1); foo(b, 2); diff --git a/test/mjsunit/field-type-tracking.js b/test/mjsunit/field-type-tracking.js index 4ffa76a58b..1ff336a6b3 100644 --- a/test/mjsunit/field-type-tracking.js +++ b/test/mjsunit/field-type-tracking.js @@ -15,6 +15,7 @@ function readA(x) { return x.a; } + %PrepareFunctionForOptimization(readA); var a = new A(); assertUnoptimized(readA); readA(a); readA(a); readA(a); @@ -26,6 +27,7 @@ b.b = o; assertEquals(readA(b), o); assertUnoptimized(readA); + %PrepareFunctionForOptimization(readA); %OptimizeFunctionOnNextCall(readA); assertEquals(readA(a), o); assertOptimized(readA); @@ -37,6 +39,7 @@ return x.a; } assertUnoptimized(readAFromB); + %PrepareFunctionForOptimization(readAFromB); readAFromB(b); readAFromB(b); readAFromB(b); %OptimizeFunctionOnNextCall(readAFromB); assertEquals(readAFromB(b), o); @@ -49,6 +52,8 @@ c.a = [1]; assertUnoptimized(readA); assertUnoptimized(readAFromB); + %PrepareFunctionForOptimization(readA); + %PrepareFunctionForOptimization(readAFromB); assertEquals(readA(a), o); assertEquals(readA(b), o); assertEquals(readA(c), [1]); @@ -77,7 +82,9 @@ A.prototype = {y: 20}; function B(o) { return o.a.y; } function C() { this.a = new A(); } + %EnsureFeedbackVectorForFunction(C); + %PrepareFunctionForOptimization(B); B(new C()); B(new C()); %OptimizeFunctionOnNextCall(B); @@ -88,6 +95,7 @@ assertEquals(10, B(c)); assertUnoptimized(B); + %PrepareFunctionForOptimization(B); var c = new C(); %OptimizeFunctionOnNextCall(B); assertEquals(20, B(c)); @@ -116,6 +124,7 @@ var f2 = new Foo({x: 2}); var f3 = new Foo({x: 3}); function readX(f) { return f.x.x; } + %PrepareFunctionForOptimization(readX); assertEquals(readX(f1), 1); assertEquals(readX(f2), 2); assertUnoptimized(readX); @@ -123,6 +132,7 @@ assertEquals(readX(f3), 3); assertOptimized(readX); function writeX(f, x) { f.x = x; } + %PrepareFunctionForOptimization(writeX); writeX(f1, {x: 11}); writeX(f2, {x: 22}); assertUnoptimized(writeX); @@ -146,6 +156,7 @@ var f2 = new Narf(2); var f3 = new Narf(3); function baz(f, y) { f.y = y; } + %PrepareFunctionForOptimization(baz); baz(f1, {b: 9}); baz(f2, {b: 9}); baz(f2, {b: 9}); @@ -161,6 +172,7 @@ function readA(o) { return o.x.a; } var f = new Foo({a:1}); var b = new Bar({a:2}); + %PrepareFunctionForOptimization(readA); assertEquals(readA(f), 1); assertEquals(readA(b), 2); assertEquals(readA(f), 1); diff --git a/test/mjsunit/fixed-context-shapes-when-recompiling.js b/test/mjsunit/fixed-context-shapes-when-recompiling.js index 8221665ccb..3289db7fc8 100644 --- a/test/mjsunit/fixed-context-shapes-when-recompiling.js +++ b/test/mjsunit/fixed-context-shapes-when-recompiling.js @@ -7,7 +7,7 @@ // Test that the information on which variables to allocate in context doesn't // change when recompiling. -(function TestVarInInnerFunction() { +function TestVarInInnerFunction() { // Introduce variables which would potentially be context allocated, depending // on whether an inner function refers to them or not. var a = 1; @@ -26,13 +26,15 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestVarInInnerFunction); +TestVarInInnerFunction(); // Other tests are the same, except that the shadowing variable "a" in inner // functions is declared differently. -(function TestLetInInnerFunction() { +function TestLetInInnerFunction() { var a = 1; var b = 2; var c = 3; @@ -48,9 +50,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestLetInInnerFunction); +TestLetInInnerFunction(); -(function TestConstInInnerFunction() { +function TestConstInInnerFunction() { var a = 1; var b = 2; var c = 3; @@ -66,9 +70,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestConstInInnerFunction); +TestConstInInnerFunction(); -(function TestInnerFunctionParameter() { +function TestInnerFunctionParameter() { var a = 1; var b = 2; var c = 3; @@ -83,9 +89,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionParameter); +TestInnerFunctionParameter(); -(function TestInnerFunctionRestParameter() { +function TestInnerFunctionRestParameter() { var a = 1; var b = 2; var c = 3; @@ -100,9 +108,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionRestParameter); +TestInnerFunctionRestParameter(); -(function TestInnerFunctionDestructuredParameter_1() { +function TestInnerFunctionDestructuredParameter_1() { var a = 1; var b = 2; var c = 3; @@ -117,9 +127,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuredParameter_1); +TestInnerFunctionDestructuredParameter_1(); -(function TestInnerFunctionDestructuredParameter_2() { +function TestInnerFunctionDestructuredParameter_2() { var a = 1; var b = 2; var c = 3; @@ -134,9 +146,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuredParameter_2); +TestInnerFunctionDestructuredParameter_2(); -(function TestInnerArrowFunctionParameter() { +function TestInnerArrowFunctionParameter() { var a = 1; var b = 2; var c = 3; @@ -149,9 +163,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerArrowFunctionParameter); +TestInnerArrowFunctionParameter(); -(function TestInnerArrowFunctionRestParameter() { +function TestInnerArrowFunctionRestParameter() { var a = 1; var b = 2; var c = 3; @@ -164,9 +180,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerArrowFunctionRestParameter); +TestInnerArrowFunctionRestParameter(); -(function TestInnerArrowFunctionDestructuredParameter_1() { +function TestInnerArrowFunctionDestructuredParameter_1() { var a = 1; var b = 2; var c = 3; @@ -179,9 +197,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerArrowFunctionDestructuredParameter_1); +TestInnerArrowFunctionDestructuredParameter_1(); -(function TestInnerArrowFunctionDestructuredParameter_2() { +function TestInnerArrowFunctionDestructuredParameter_2() { var a = 1; var b = 2; var c = 3; @@ -194,9 +214,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerArrowFunctionDestructuredParameter_2); +TestInnerArrowFunctionDestructuredParameter_2(); -(function TestInnerInnerFunctionParameter() { +function TestInnerInnerFunctionParameter() { var a = 1; var b = 2; var c = 3; @@ -211,9 +233,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerInnerFunctionParameter); +TestInnerInnerFunctionParameter(); -(function TestInnerInnerFunctionRestParameter() { +function TestInnerInnerFunctionRestParameter() { var a = 1; var b = 2; var c = 3; @@ -228,9 +252,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerInnerFunctionRestParameter); +TestInnerInnerFunctionRestParameter(); -(function TestInnerInnerFunctionDestructuredParameter_1() { +function TestInnerInnerFunctionDestructuredParameter_1() { var a = 1; var b = 2; var c = 3; @@ -245,9 +271,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerInnerFunctionDestructuredParameter_1); +TestInnerInnerFunctionDestructuredParameter_1(); -(function TestInnerInnerFunctionDestructuredParameter_2() { +function TestInnerInnerFunctionDestructuredParameter_2() { var a = 1; var b = 2; var c = 3; @@ -262,9 +290,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerInnerFunctionDestructuredParameter_2); +TestInnerInnerFunctionDestructuredParameter_2(); -(function TestInnerInnerArrowFunctionParameter() { +function TestInnerInnerArrowFunctionParameter() { var a = 1; var b = 2; var c = 3; @@ -279,9 +309,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerInnerArrowFunctionParameter); +TestInnerInnerArrowFunctionParameter(); -(function TestInnerInnerArrowFunctionRestParameter() { +function TestInnerInnerArrowFunctionRestParameter() { var a = 1; var b = 2; var c = 3; @@ -296,9 +328,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerInnerArrowFunctionRestParameter); +TestInnerInnerArrowFunctionRestParameter(); -(function TestInnerInnerArrowFunctionDestructuredParameter_1() { +function TestInnerInnerArrowFunctionDestructuredParameter_1() { var a = 1; var b = 2; var c = 3; @@ -313,9 +347,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerInnerArrowFunctionDestructuredParameter_1); +TestInnerInnerArrowFunctionDestructuredParameter_1(); -(function TestInnerInnerArrowFunctionDestructuredParameter_2() { +function TestInnerInnerArrowFunctionDestructuredParameter_2() { var a = 1; var b = 2; var c = 3; @@ -330,9 +366,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerInnerArrowFunctionDestructuredParameter_2); +TestInnerInnerArrowFunctionDestructuredParameter_2(); -(function TestInnerFunctionInnerFunction() { +function TestInnerFunctionInnerFunction() { var a = 1; var b = 2; var c = 3; @@ -348,9 +386,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionInnerFunction); +TestInnerFunctionInnerFunction(); -(function TestInnerFunctionSloppyBlockFunction() { +function TestInnerFunctionSloppyBlockFunction() { var a = 1; var b = 2; var c = 3; @@ -366,9 +406,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionSloppyBlockFunction); +TestInnerFunctionSloppyBlockFunction(); -(function TestInnerFunctionCatchVariable() { +function TestInnerFunctionCatchVariable() { var a = 1; var b = 2; var c = 3; @@ -387,9 +429,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +}; +%PrepareFunctionForOptimization(TestInnerFunctionCatchVariable); +TestInnerFunctionCatchVariable(); -(function TestInnerFunctionLoopVariable1() { +function TestInnerFunctionLoopVariable1() { var a = 1; var b = 2; var c = 3; @@ -406,9 +450,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionLoopVariable1); +TestInnerFunctionLoopVariable1(); -(function TestInnerFunctionLoopVariable2() { +function TestInnerFunctionLoopVariable2() { var a = 1; var b = 2; var c = 3; @@ -425,9 +471,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionLoopVariable2); +TestInnerFunctionLoopVariable2(); -(function TestInnerFunctionLoopVariable3() { +function TestInnerFunctionLoopVariable3() { var a = 1; var b = 2; var c = 3; @@ -444,9 +492,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionLoopVariable3); +TestInnerFunctionLoopVariable3(); -(function TestInnerFunctionLoopVariable4() { +function TestInnerFunctionLoopVariable4() { var a = 1; var b = 2; var c = 3; @@ -463,9 +513,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionLoopVariable4); +TestInnerFunctionLoopVariable4(); -(function TestInnerFunctionClass() { +function TestInnerFunctionClass() { var a = 1; var b = 2; var c = 3; @@ -481,9 +533,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionClass); +TestInnerFunctionClass(); -(function TestInnerFunctionDestructuring1() { +function TestInnerFunctionDestructuring1() { var a = 1; var b = 2; var c = 3; @@ -499,9 +553,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuring1); +TestInnerFunctionDestructuring1(); -(function TestInnerFunctionDestructuring2() { +function TestInnerFunctionDestructuring2() { var a = 1; var b = 2; var c = 3; @@ -517,9 +573,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuring2); +TestInnerFunctionDestructuring2(); -(function TestInnerFunctionDestructuring3() { +function TestInnerFunctionDestructuring3() { var a = 1; var b = 2; var c = 3; @@ -535,9 +593,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuring3); +TestInnerFunctionDestructuring3(); -(function TestInnerFunctionDestructuring4() { +function TestInnerFunctionDestructuring4() { var a = 1; var b = 2; var c = 3; @@ -553,9 +613,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuring4); +TestInnerFunctionDestructuring4(); -(function TestInnerFunctionDestructuring5() { +function TestInnerFunctionDestructuring5() { var a = 1; var b = 2; var c = 3; @@ -571,9 +633,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuring5); +TestInnerFunctionDestructuring5(); -(function TestInnerFunctionDestructuring6() { +function TestInnerFunctionDestructuring6() { var a = 1; var b = 2; var c = 3; @@ -589,9 +653,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuring6); +TestInnerFunctionDestructuring6(); -(function TestInnerFunctionDestructuring7() { +function TestInnerFunctionDestructuring7() { var a = 1; var b = 2; var c = 3; @@ -607,9 +673,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuring7); +TestInnerFunctionDestructuring7(); -(function TestInnerFunctionDestructuring8() { +function TestInnerFunctionDestructuring8() { var a = 1; var b = 2; var c = 3; @@ -625,9 +693,11 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuring8); +TestInnerFunctionDestructuring8(); -(function TestInnerFunctionDestructuring9() { +function TestInnerFunctionDestructuring9() { var a = 1; var b = 2; var c = 3; @@ -643,11 +713,13 @@ assertEquals(2, b); assertEquals(3, c); } -})(); +} +%PrepareFunctionForOptimization(TestInnerFunctionDestructuring9); +TestInnerFunctionDestructuring9(); // A cluster of similar tests where the inner function only declares a variable // whose name clashes with an outer function variable name, but doesn't use it. -(function TestRegress650969_1_var() { +function TestRegress650969_1_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -657,9 +729,11 @@ var a; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_1_var); +TestRegress650969_1_var(); -(function TestRegress650969_1_let() { +function TestRegress650969_1_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -669,9 +743,11 @@ let a; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_1_let); +TestRegress650969_1_let(); -(function TestRegress650969_2_var() { +function TestRegress650969_2_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -681,9 +757,11 @@ var a = 6; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_2_var); +TestRegress650969_2_var(); -(function TestRegress650969_2_let() { +function TestRegress650969_2_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -693,9 +771,11 @@ let a = 6; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_2_let); +TestRegress650969_2_let(); -(function TestRegress650969_2_const() { +function TestRegress650969_2_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -705,9 +785,11 @@ const a = 6; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_2_const); +TestRegress650969_2_const(); -(function TestRegress650969_3_var() { +function TestRegress650969_3_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -717,9 +799,11 @@ var a, b; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_3_var); +TestRegress650969_3_var(); -(function TestRegress650969_3_let() { +function TestRegress650969_3_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -729,9 +813,11 @@ let a, b; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_3_let); +TestRegress650969_3_let(); -(function TestRegress650969_4_var() { +function TestRegress650969_4_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -741,9 +827,11 @@ var a = 6, b; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_4_var); +TestRegress650969_4_var(); -(function TestRegress650969_4_let() { +function TestRegress650969_4_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -753,9 +841,11 @@ let a = 6, b; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_4_let); +TestRegress650969_4_let(); -(function TestRegress650969_4_const() { +function TestRegress650969_4_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -765,9 +855,11 @@ const a = 0, b = 0; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_4_const); +TestRegress650969_4_const(); -(function TestRegress650969_9_parameter() { +function TestRegress650969_9_parameter() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -775,9 +867,11 @@ var a; function inner(a) {} } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_9_parameter); +TestRegress650969_9_parameter(); -(function TestRegress650969_9_restParameter() { +function TestRegress650969_9_restParameter() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -785,9 +879,11 @@ var a; function inner(...a) {} } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_9_restParameter); +TestRegress650969_9_restParameter(); -(function TestRegress650969_9_destructuredParameter_1() { +function TestRegress650969_9_destructuredParameter_1() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -795,9 +891,11 @@ var a; function inner([d, a]) {} } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_9_destructuredParameter_1); +TestRegress650969_9_destructuredParameter_1(); -(function TestRegress650969_9_destructuredParameter_2() { +function TestRegress650969_9_destructuredParameter_2() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -805,9 +903,11 @@ var a; function inner({d, a}) {} } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_9_destructuredParameter_2); +TestRegress650969_9_destructuredParameter_2(); -(function TestRegress650969_10_parameter() { +function TestRegress650969_10_parameter() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -817,9 +917,11 @@ function innerinner(a) {} } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_10_parameter); +TestRegress650969_10_parameter(); -(function TestRegress650969_10_restParameter() { +function TestRegress650969_10_restParameter() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -829,9 +931,11 @@ function innerinner(...a) {} } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_10_restParameter); +TestRegress650969_10_restParameter(); -(function TestRegress650969_10_destructuredParameter_1() { +function TestRegress650969_10_destructuredParameter_1() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -841,9 +945,11 @@ function innerinner([d, a]) {} } } -})(); +} +%PrepareFunctionForOptimization( TestRegress650969_10_destructuredParameter_1); +TestRegress650969_10_destructuredParameter_1(); -(function TestRegress650969_10_destructuredParameter_2() { +function TestRegress650969_10_destructuredParameter_2() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -853,9 +959,11 @@ function innerinner({d, a}) {} } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_10_destructuredParameter_2); +TestRegress650969_10_destructuredParameter_2(); -(function TestRegress650969_11_var() { +function TestRegress650969_11_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -865,9 +973,12 @@ var [a, b] = [1, 2]; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_11_var); +TestRegress650969_11_var(); -(function TestRegress650969_11_let() { + +function TestRegress650969_11_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -877,9 +988,11 @@ let [a, b] = [1, 2]; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_11_let); +TestRegress650969_11_let(); -(function TestRegress650969_11_const() { +function TestRegress650969_11_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -889,9 +1002,11 @@ const [a, b] = [1, 2]; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_11_const); +TestRegress650969_11_const(); -(function TestRegress650969_12_var() { +function TestRegress650969_12_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -901,9 +1016,11 @@ var [b, a] = [1, 2]; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_12_var); +TestRegress650969_12_var(); -(function TestRegress650969_12_let() { +function TestRegress650969_12_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -913,9 +1030,11 @@ let [b, a] = [1, 2]; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_12_let); +TestRegress650969_12_let(); -(function TestRegress650969_12_const() { +function TestRegress650969_12_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -925,9 +1044,11 @@ const [b, a] = [1, 2]; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_12_const); +TestRegress650969_12_const(); -(function TestRegress650969_13_var() { +function TestRegress650969_13_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -937,9 +1058,11 @@ var [b, ...a] = [1, 2]; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_13_var); +TestRegress650969_13_var(); -(function TestRegress650969_13_let() { +function TestRegress650969_13_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -949,9 +1072,11 @@ let [b, ...a] = [1, 2]; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_13_let); +TestRegress650969_13_let(); -(function TestRegress650969_13_const() { +function TestRegress650969_13_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -961,9 +1086,11 @@ const [b, ...a] = [1, 2]; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_13_const); +TestRegress650969_13_const(); -(function TestRegress650969_14_var() { +function TestRegress650969_14_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -973,9 +1100,11 @@ var {a, b} = {a: 1, b: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_14_var); +TestRegress650969_14_var(); -(function TestRegress650969_14_let() { +function TestRegress650969_14_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -985,9 +1114,11 @@ let {a, b} = {a: 1, b: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_14_let); +TestRegress650969_14_let(); -(function TestRegress650969_14_const() { +function TestRegress650969_14_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -997,9 +1128,11 @@ const {a, b} = {a: 1, b: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_14_const); +TestRegress650969_14_const(); -(function TestRegress650969_15_var() { +function TestRegress650969_15_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1009,9 +1142,11 @@ var {b: {a}, c} = {b: {a: 1}, c: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_15_var); +TestRegress650969_15_var(); -(function TestRegress650969_15_let() { +function TestRegress650969_15_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1021,9 +1156,11 @@ let {b: {a}, c} = {b: {a: 1}, c: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_15_let); +TestRegress650969_15_let(); -(function TestRegress650969_15_const() { +function TestRegress650969_15_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1033,9 +1170,11 @@ const {b: {a}, c} = {b: {a: 1}, c: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_15_const); +TestRegress650969_15_const(); -(function TestRegress650969_16_var() { +function TestRegress650969_16_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1045,9 +1184,11 @@ var {a: {b}, c} = {a: {b: 1}, c: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_16_var); +TestRegress650969_16_var(); -(function TestRegress650969_16_let() { +function TestRegress650969_16_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1057,9 +1198,11 @@ let {a: {b}, c} = {a: {b: 1}, c: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_16_let); +TestRegress650969_16_let(); -(function TestRegress650969_16_const() { +function TestRegress650969_16_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1069,9 +1212,11 @@ const {a: {b}, c} = {a: {b: 1}, c: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_16_const); +TestRegress650969_16_const(); -(function TestRegress650969_17_var() { +function TestRegress650969_17_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1081,9 +1226,11 @@ for (var a = 0; 0 == 1; ) { } } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_17_var); +TestRegress650969_17_var(); -(function TestRegress650969_17_let() { +function TestRegress650969_17_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1093,9 +1240,11 @@ for (let a = 0; 0 == 1; ) { } } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_17_let); +TestRegress650969_17_let(); -(function TestRegress650969_17_const() { +function TestRegress650969_17_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1105,9 +1254,11 @@ for (const a = 0; 0 == 1; ) { } } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_17_const); +TestRegress650969_17_const(); -(function TestRegress650969_18() { +function TestRegress650969_18() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1117,9 +1268,11 @@ function innerinner([a, b]) {} } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_18); +TestRegress650969_18(); -(function TestRegress650969_18() { +function TestRegress650969_18() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1129,11 +1282,13 @@ function innerinner(a) {} } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_18); +TestRegress650969_18(); // Regression tests for an intermediate stage where unresolved references were // discarded too aggressively. -(function TestRegress650969_sidetrack_var() { +function TestRegress650969_sidetrack_var() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1144,9 +1299,11 @@ var {b: {a}, c} = {b: {a: 1}, c: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_sidetrack_var); +TestRegress650969_sidetrack_var(); -(function TestRegress650969_sidetrack_let() { +function TestRegress650969_sidetrack_let() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1157,9 +1314,11 @@ let {b: {a}, c} = {b: {a: 1}, c: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_sidetrack_let); +TestRegress650969_sidetrack_let(); -(function TestRegress650969_sidetrack_const() { +function TestRegress650969_sidetrack_const() { for (var i = 0; i < 3; ++i) { if (i == 1) { %OptimizeOsr(); @@ -1170,4 +1329,6 @@ const {b: {a}, c} = {b: {a: 1}, c: 2}; } } -})(); +} +%PrepareFunctionForOptimization(TestRegress650969_sidetrack_const); +TestRegress650969_sidetrack_const(); diff --git a/test/mjsunit/ignition/osr-from-bytecode.js b/test/mjsunit/ignition/osr-from-bytecode.js index a0c80f8e3b..ae9286b100 100644 --- a/test/mjsunit/ignition/osr-from-bytecode.js +++ b/test/mjsunit/ignition/osr-from-bytecode.js @@ -9,4 +9,5 @@ function f() { if (i == 5) %OptimizeOsr(); } } +%EnsureFeedbackVectorForFunction(f); f(); diff --git a/test/mjsunit/ignition/osr-from-generator.js b/test/mjsunit/ignition/osr-from-generator.js index 2344a31ce4..e2d628819f 100644 --- a/test/mjsunit/ignition/osr-from-generator.js +++ b/test/mjsunit/ignition/osr-from-generator.js @@ -11,6 +11,7 @@ } return 23; } + %PrepareFunctionForOptimization(gen1); var g = gen1(); assertEquals({ value:23, done:true }, g.next()); })(); @@ -23,6 +24,7 @@ } return 23; } + %PrepareFunctionForOptimization(gen2); var g = gen2(); assertEquals({ value:0, done:false }, g.next()); assertEquals({ value:1, done:false }, g.next()); @@ -38,6 +40,7 @@ } return 23; } + %PrepareFunctionForOptimization(gen3); var g = gen3(); assertEquals({ value:0, done:false }, g.next()); assertEquals({ value:1, done:false }, g.next()); @@ -57,6 +60,7 @@ } return 23; } + %PrepareFunctionForOptimization(gen4); var g = gen4(); assertEquals({ value:0, done:false }, g.next()); assertEquals({ value:1, done:false }, g.next()); diff --git a/test/mjsunit/ignition/throw-if-hole.js b/test/mjsunit/ignition/throw-if-hole.js index ee7e4c8872..c9578a5228 100644 --- a/test/mjsunit/ignition/throw-if-hole.js +++ b/test/mjsunit/ignition/throw-if-hole.js @@ -10,6 +10,10 @@ function f(b) { } } +f(0); +assertThrows(() => {f(1)}, ReferenceError); + +%PrepareFunctionForOptimization(f); f(0); f(0); %OptimizeFunctionOnNextCall(f); diff --git a/test/mjsunit/ignition/throw-if-not-hole.js b/test/mjsunit/ignition/throw-if-not-hole.js index c14972a859..554b622bd8 100644 --- a/test/mjsunit/ignition/throw-if-not-hole.js +++ b/test/mjsunit/ignition/throw-if-not-hole.js @@ -15,7 +15,13 @@ class B extends A { } } } +// No feedback case +test = new B(0); +assertThrows(() => {new B(1)}, ReferenceError); +// Ensure Feedback +%PrepareFunctionForOptimization(B); +%EnsureFeedbackVectorForFunction(A); test = new B(0); test = new B(0); assertThrows(() => {new B(1)}, ReferenceError); diff --git a/test/mjsunit/ignition/throw-super-not-called.js b/test/mjsunit/ignition/throw-super-not-called.js index ec60de8599..ee85129d2f 100644 --- a/test/mjsunit/ignition/throw-super-not-called.js +++ b/test/mjsunit/ignition/throw-super-not-called.js @@ -15,6 +15,10 @@ class B extends A { } } +test = new B(1); +assertThrows(() => {new B(0)}, ReferenceError); + +%PrepareFunctionForOptimization(B); test = new B(1); test = new B(1); %OptimizeFunctionOnNextCall(B); diff --git a/test/mjsunit/interrupt-budget-override.js b/test/mjsunit/interrupt-budget-override.js index acbe837c56..6dbf0785a7 100644 --- a/test/mjsunit/interrupt-budget-override.js +++ b/test/mjsunit/interrupt-budget-override.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --opt --interrupt-budget=100 --allow-natives-syntax +// Flags: --opt --interrupt-budget=100 --budget-for-feedback-vector-allocation=10 --allow-natives-syntax function f() { let s = 0; diff --git a/test/mjsunit/keyed-load-hole-to-undefined.js b/test/mjsunit/keyed-load-hole-to-undefined.js index ffac5488c0..0f2d3b933f 100644 --- a/test/mjsunit/keyed-load-hole-to-undefined.js +++ b/test/mjsunit/keyed-load-hole-to-undefined.js @@ -11,6 +11,7 @@ function foo(a, i) { return a[i]; } +%PrepareFunctionForOptimization(foo); var a = ['one', , 'three']; foo(a, 0); foo(a, 0); diff --git a/test/mjsunit/keyed-load-with-string-key.js b/test/mjsunit/keyed-load-with-string-key.js index ee055e4790..bb2a24246b 100644 --- a/test/mjsunit/keyed-load-with-string-key.js +++ b/test/mjsunit/keyed-load-with-string-key.js @@ -36,6 +36,7 @@ function get(obj, key) { return obj[key]; } +%PrepareFunctionForOptimization(get); get(o, "foo"); get(o, "foo"); get(o, "foo"); diff --git a/test/mjsunit/keyed-load-with-symbol-key.js b/test/mjsunit/keyed-load-with-symbol-key.js index d0be0a0545..8015cdf7b2 100644 --- a/test/mjsunit/keyed-load-with-symbol-key.js +++ b/test/mjsunit/keyed-load-with-symbol-key.js @@ -37,6 +37,7 @@ function get(obj, key) { return obj[key]; } +%PrepareFunctionForOptimization(get); assertEquals("bar", get(o, s)); get(o, s); get(o, s); diff --git a/test/mjsunit/math-floor-of-div-minus-zero.js b/test/mjsunit/math-floor-of-div-minus-zero.js index a721467b5a..0c424c5d0c 100644 --- a/test/mjsunit/math-floor-of-div-minus-zero.js +++ b/test/mjsunit/math-floor-of-div-minus-zero.js @@ -34,6 +34,7 @@ function test_div_no_deopt_minus_zero() { assertTrue(0 === (Math.floor((zero_in_array[0] | 0) / -1) | 0)); } +%PrepareFunctionForOptimization(test_div_no_deopt_minus_zero); test_div_no_deopt_minus_zero(); test_div_no_deopt_minus_zero(); %OptimizeFunctionOnNextCall(test_div_no_deopt_minus_zero); diff --git a/test/mjsunit/never-optimize.js b/test/mjsunit/never-optimize.js index 5efaa47de3..f2b764e16c 100644 --- a/test/mjsunit/never-optimize.js +++ b/test/mjsunit/never-optimize.js @@ -29,6 +29,7 @@ function o1() { } +%PrepareFunctionForOptimization(o1); o1(); o1(); %OptimizeFunctionOnNextCall(o1); @@ -45,6 +46,8 @@ function u1() { function u2() { u1(); } +%PrepareFunctionForOptimization(u1); +%PrepareFunctionForOptimization(u2); u1(); u1(); u2(); u2(); diff --git a/test/mjsunit/object-seal.js b/test/mjsunit/object-seal.js index ab7606e8a4..05635579bb 100644 --- a/test/mjsunit/object-seal.js +++ b/test/mjsunit/object-seal.js @@ -220,9 +220,11 @@ assertDoesNotThrow(function() { objControl.splice(0, 0, 100, 101, 102); }); // Verify that crankshaft still does the right thing. obj = [1, 2, 3]; -push_call = function(a) { a.push(1000); return a; } +push_call = function(a) { a.push(1000); return a; }; +%PrepareFunctionForOptimization(push_call); // Include a call site that doesn't have a custom built-in. -var shift_call = function(a) { a.shift(1000); return a; } +var shift_call = function(a) { a.shift(1000); return a; }; +%PrepareFunctionForOptimization(shift_call); for (var i = 0; i < 3; i++) { push_call(obj); shift_call(obj); diff --git a/test/mjsunit/optimized-map.js b/test/mjsunit/optimized-map.js index 762eacd395..1095f7baf2 100644 --- a/test/mjsunit/optimized-map.js +++ b/test/mjsunit/optimized-map.js @@ -20,7 +20,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; a.abc = 25; } return v; - } + }; + %EnsureFeedbackVectorForFunction(callback); a.map(callback); }; %PrepareFunctionForOptimization(eagerDeoptInCalled); @@ -41,7 +42,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; result += v; a.length = (i == 13 && deopt) ? 25 : 27; return v; - } + }; + %EnsureFeedbackVectorForFunction(callback); a.map(callback); }; %PrepareFunctionForOptimization(eagerDeoptInCalled); @@ -65,7 +67,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; a_noescape.length = 25; } return v; - } + }; + %EnsureFeedbackVectorForFunction(callback); a_noescape.map(callback); }; %PrepareFunctionForOptimization(eagerDeoptInCalled); @@ -93,6 +96,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; gc(); gc(); return v; }; + %EnsureFeedbackVectorForFunction(callback); %NeverOptimizeFunction(callback); b.map(callback); }; @@ -117,6 +121,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; } return 2 * v; }; + %EnsureFeedbackVectorForFunction(callback); %NeverOptimizeFunction(callback); return b.map(callback); }; @@ -137,7 +142,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; %DeoptimizeNow(); } return v; - } + }; + %EnsureFeedbackVectorForFunction(callback); b.map(callback); }; %PrepareFunctionForOptimization(lazyDeopt); @@ -161,6 +167,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; } return v; }; + %EnsureFeedbackVectorForFunction(callback); %NeverOptimizeFunction(callback); b.map(callback); }; @@ -186,7 +193,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; gc(); } return v; - } + }; + %EnsureFeedbackVectorForFunction(callback); c.map(callback); }; %PrepareFunctionForOptimization(lazyDeopt); @@ -211,7 +219,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; throw("a"); } return v; - } + }; + %EnsureFeedbackVectorForFunction(callback); try { c.map(callback); } catch (e) { @@ -241,6 +250,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; } return v; }; + %EnsureFeedbackVectorForFunction(callback); %NeverOptimizeFunction(callback); try { c.map(callback); @@ -270,6 +280,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; } return 2 * v; }; + %EnsureFeedbackVectorForFunction(callback); %NeverOptimizeFunction(callback); var result = 0; try { @@ -303,6 +314,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; } return v; }; + %EnsureFeedbackVectorForFunction(callback); var o = [1,2,3]; b.map(callback); }; @@ -326,6 +338,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; } return v; }; + %EnsureFeedbackVectorForFunction(callback); %NeverOptimizeFunction(callback); var o = [1,2,3]; b.map(callback); @@ -352,6 +365,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; } return v; }; + %EnsureFeedbackVectorForFunction(callback); var o = [1,2,3]; b.map(callback); }; @@ -375,6 +389,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; } return v; }; + %EnsureFeedbackVectorForFunction(callback); a.map(callback); }; %PrepareFunctionForOptimization(lazyDeopt); @@ -408,7 +423,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; // array. return v; } - } + }; + %EnsureFeedbackVectorForFunction(callback); return c.map(callback); }; %PrepareFunctionForOptimization(to_double); @@ -439,7 +455,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; // Later, to PACKED_ELEMENTS. return v + 'hello'; } - } + }; + %EnsureFeedbackVectorForFunction(callback); return c.map(callback); }; %PrepareFunctionForOptimization(to_fast); @@ -460,6 +477,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]; function double_results() { // TurboFan recognizes the result is a double. var callback = v => v + 0.5; + %EnsureFeedbackVectorForFunction(callback); return a.map(callback); } %PrepareFunctionForOptimization(double_results); diff --git a/test/mjsunit/parallel-optimize-disabled.js b/test/mjsunit/parallel-optimize-disabled.js index 83970ae096..631c3817d0 100644 --- a/test/mjsunit/parallel-optimize-disabled.js +++ b/test/mjsunit/parallel-optimize-disabled.js @@ -43,6 +43,8 @@ function f(x) { g(); } +%PrepareFunctionForOptimization(f); +%PrepareFunctionForOptimization(g); f(); f(); %OptimizeFunctionOnNextCall(f); diff --git a/test/mjsunit/regress/binop-in-effect-context-deopt.js b/test/mjsunit/regress/binop-in-effect-context-deopt.js index 8d60e9015e..a935a49c10 100644 --- a/test/mjsunit/regress/binop-in-effect-context-deopt.js +++ b/test/mjsunit/regress/binop-in-effect-context-deopt.js @@ -34,6 +34,7 @@ for (var i = 0; osr && i < 2; i++) %OptimizeOsr(); return result; } + %PrepareFunctionForOptimization(f); assertEquals("result", f(true, 3, false)); assertEquals("result", f(true, 3, false)); @@ -58,6 +59,7 @@ function f() { return g(void(h() + "")); }; + %PrepareFunctionForOptimization(f); f(); %OptimizeFunctionOnNextCall(f); diff --git a/test/mjsunit/regress/call-function-in-effect-context-deopt.js b/test/mjsunit/regress/call-function-in-effect-context-deopt.js index 72d3938511..b20645ce22 100644 --- a/test/mjsunit/regress/call-function-in-effect-context-deopt.js +++ b/test/mjsunit/regress/call-function-in-effect-context-deopt.js @@ -35,6 +35,7 @@ function f(deopt, osr) { return result; } +%PrepareFunctionForOptimization(f); assertEquals("result", f(3, false)); assertEquals("result", f(3, false)); %OptimizeFunctionOnNextCall(f); diff --git a/test/mjsunit/regress/regress-1118.js b/test/mjsunit/regress/regress-1118.js index 05b192d6f3..08b7239e33 100644 --- a/test/mjsunit/regress/regress-1118.js +++ b/test/mjsunit/regress/regress-1118.js @@ -31,21 +31,25 @@ // should be able to construct a receiver from all optimized stack frames. function A() { } +%EnsureFeedbackVectorForFunction(A); A.prototype.f = function() { } function B() { } +%EnsureFeedbackVectorForFunction(B); var o = new A(); // This function throws if o does not have an f property, and should not be // inlined. function g() { try { return o.f(); } finally { }} +%EnsureFeedbackVectorForFunction(g); // This function should be optimized via OSR. function h() { for (var i = 0; i < 10; i++) %OptimizeOsr(); g(); } +%PrepareFunctionForOptimization(h); h(); o = new B(); diff --git a/test/mjsunit/regress/regress-1257.js b/test/mjsunit/regress/regress-1257.js index c5ed14dd3b..4ea42c9b0e 100644 --- a/test/mjsunit/regress/regress-1257.js +++ b/test/mjsunit/regress/regress-1257.js @@ -31,4 +31,5 @@ function foo () { }; } +%PrepareFunctionForOptimization(foo); foo(); diff --git a/test/mjsunit/regress/regress-2132.js b/test/mjsunit/regress/regress-2132.js index c2f6c297b4..9df1c1ba44 100644 --- a/test/mjsunit/regress/regress-2132.js +++ b/test/mjsunit/regress/regress-2132.js @@ -31,6 +31,7 @@ function mul(x, y) { return (x * y) | 0; } +%PrepareFunctionForOptimization(mul); mul(0, 0); mul(0, 0); %OptimizeFunctionOnNextCall(mul); @@ -41,6 +42,7 @@ function div(x, y) { return (x / y) | 0; } +%PrepareFunctionForOptimization(div); div(4, 2); div(4, 2); %OptimizeFunctionOnNextCall(div); diff --git a/test/mjsunit/regress/regress-2339.js b/test/mjsunit/regress/regress-2339.js index d7d2bb398a..abad9fda96 100644 --- a/test/mjsunit/regress/regress-2339.js +++ b/test/mjsunit/regress/regress-2339.js @@ -35,8 +35,10 @@ function simple_two_args(always_zero, always_undefined) { var always_five = always_undefined || 5; return always_zero * always_five * .5; } +%EnsureFeedbackVectorForFunction(simple_two_args); +%PrepareFunctionForOptimization(simple); simple(); simple(); %OptimizeFunctionOnNextCall(simple); diff --git a/test/mjsunit/regress/regress-2451.js b/test/mjsunit/regress/regress-2451.js index 08efda2325..0e63cfebd6 100644 --- a/test/mjsunit/regress/regress-2451.js +++ b/test/mjsunit/regress/regress-2451.js @@ -33,6 +33,7 @@ function f() { assertEquals(-1.0, Math.round(-0.5000000000000001)); } +%PrepareFunctionForOptimization(f); f(); f(); %OptimizeFunctionOnNextCall(f); diff --git a/test/mjsunit/regress/regress-252797.js b/test/mjsunit/regress/regress-252797.js index 08b22176af..4d68ff8b29 100644 --- a/test/mjsunit/regress/regress-252797.js +++ b/test/mjsunit/regress/regress-252797.js @@ -55,6 +55,7 @@ function callConstantFunctionOnPrototype(obj) { obj.holderMethod(); } +%PrepareFunctionForOptimization(callConstantFunctionOnPrototype); callConstantFunctionOnPrototype(receiver); callConstantFunctionOnPrototype(receiver); %OptimizeFunctionOnNextCall(callConstantFunctionOnPrototype); diff --git a/test/mjsunit/regress/regress-2618.js b/test/mjsunit/regress/regress-2618.js index 551605c6b3..6b80fbc2af 100644 --- a/test/mjsunit/regress/regress-2618.js +++ b/test/mjsunit/regress/regress-2618.js @@ -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: --use-osr --allow-natives-syntax --ignition-osr --opt +// Flags: --use-osr --allow-natives-syntax --opt // Flags: --no-always-opt // Can't OSR with always-opt or in Lite mode. @@ -50,6 +50,7 @@ function f() { } while (false); } +%PrepareFunctionForOptimization(f); f(); function g() { @@ -85,4 +86,5 @@ function g() { } while (false); } +%PrepareFunctionForOptimization(g); g(); diff --git a/test/mjsunit/regress/regress-298269.js b/test/mjsunit/regress/regress-298269.js index 46f525edb8..dd6b6a00fc 100644 --- a/test/mjsunit/regress/regress-298269.js +++ b/test/mjsunit/regress/regress-298269.js @@ -14,6 +14,7 @@ function Cb(a, trigger) { } return g; } +%PrepareFunctionForOptimization(Cb); var s1 = "long string to make cons string 1"; var s2 = "long string to make cons string 2"; diff --git a/test/mjsunit/regress/regress-2989.js b/test/mjsunit/regress/regress-2989.js index ff09c08a41..213c0df7b5 100644 --- a/test/mjsunit/regress/regress-2989.js +++ b/test/mjsunit/regress/regress-2989.js @@ -33,7 +33,7 @@ if (isNeverOptimizeLiteMode()) { x = 42; return f.arguments[0]; } - + %EnsureFeedbackVectorForFunction(f); f(0); %OptimizeFunctionOnNextCall(f); assertEquals(42, f(0)); diff --git a/test/mjsunit/regress/regress-3032.js b/test/mjsunit/regress/regress-3032.js index 9b18e146ce..e7cd58dc25 100644 --- a/test/mjsunit/regress/regress-3032.js +++ b/test/mjsunit/regress/regress-3032.js @@ -27,6 +27,10 @@ // Flags: --allow-natives-syntax -for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); } -var xl = 4096; -var z = i % xl; +function f() { + for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); } + var xl = 4096; + var z = i % xl; +} +%PrepareFunctionForOptimization(f); +f(); diff --git a/test/mjsunit/regress/regress-3650-3.js b/test/mjsunit/regress/regress-3650-3.js index 6195b12441..e613235428 100644 --- a/test/mjsunit/regress/regress-3650-3.js +++ b/test/mjsunit/regress/regress-3650-3.js @@ -10,6 +10,7 @@ function foo(a) { } } +%PrepareFunctionForOptimization(foo); foo([1,2,3]); foo([2,3,4]); %OptimizeFunctionOnNextCall(foo); diff --git a/test/mjsunit/regress/regress-3709.js b/test/mjsunit/regress/regress-3709.js index ecb906a908..17b4612809 100644 --- a/test/mjsunit/regress/regress-3709.js +++ b/test/mjsunit/regress/regress-3709.js @@ -18,6 +18,7 @@ function foo() { } } +%PrepareFunctionForOptimization(foo); foo(); foo(); %OptimizeFunctionOnNextCall(foo); diff --git a/test/mjsunit/regress/regress-379770.js b/test/mjsunit/regress/regress-379770.js index ab1b339f7d..6234899c05 100644 --- a/test/mjsunit/regress/regress-379770.js +++ b/test/mjsunit/regress/regress-379770.js @@ -10,6 +10,7 @@ function foo(obj) { counter += obj; return counter; } +%PrepareFunctionForOptimization(foo); function bar() { var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; diff --git a/test/mjsunit/regress/regress-385565.js b/test/mjsunit/regress/regress-385565.js index 12f0c229a0..4281fe0f8e 100644 --- a/test/mjsunit/regress/regress-385565.js +++ b/test/mjsunit/regress/regress-385565.js @@ -59,6 +59,7 @@ assertEquals(1, r1); assertTrue(r1 === r2); assertTrue(r2 === r3); +%OptimizeFunctionOnNextCall(callsFReceiver); r1 = callsFReceiver(o1); callsFReceiver(o1); %OptimizeFunctionOnNextCall(callsFReceiver); diff --git a/test/mjsunit/regress/regress-4121.js b/test/mjsunit/regress/regress-4121.js index 0f03e79cf2..fcf625a061 100644 --- a/test/mjsunit/regress/regress-4121.js +++ b/test/mjsunit/regress/regress-4121.js @@ -23,6 +23,7 @@ function literals_sharing_test(warmup, optimize) { // propagated to the next closure. assertTrue(%HasDoubleElements(a)); }; + %EnsureFeedbackVectorForFunction(closure); if (optimize) %OptimizeFunctionOnNextCall(closure); closure(); } diff --git a/test/mjsunit/regress/regress-4380.js b/test/mjsunit/regress/regress-4380.js index 06a64790ef..5eb773fc1e 100644 --- a/test/mjsunit/regress/regress-4380.js +++ b/test/mjsunit/regress/regress-4380.js @@ -9,6 +9,7 @@ function bar(a) { return x == undefined; } +%PrepareFunctionForOptimization(bar); // Make the keyed load be polymorphic on holey smi and holey fast. bar([, 2, 3]); bar([, 'two', 'three']); diff --git a/test/mjsunit/regress/regress-5252.js b/test/mjsunit/regress/regress-5252.js index 41f3feeec2..5dd0310637 100644 --- a/test/mjsunit/regress/regress-5252.js +++ b/test/mjsunit/regress/regress-5252.js @@ -11,6 +11,7 @@ return 23; } while(false) } + %PrepareFunctionForOptimization(f); assertEquals(23, f()); assertEquals(23, f()); })(); @@ -24,6 +25,7 @@ } while(false) return 999; } + %PrepareFunctionForOptimization(g); var gen = g(); assertEquals({ value:23, done:false }, gen.next()); assertEquals({ value:42, done:false }, gen.next()); diff --git a/test/mjsunit/regress/regress-5262.js b/test/mjsunit/regress/regress-5262.js index 06932a2f0f..d980ba8e91 100644 --- a/test/mjsunit/regress/regress-5262.js +++ b/test/mjsunit/regress/regress-5262.js @@ -20,6 +20,7 @@ function f(osr_and_recurse) { } return 65; } +%PrepareFunctionForOptimization(f); assertEquals(65, f(false)); assertEquals(65, f(false)); assertEquals(42, f(true)); diff --git a/test/mjsunit/regress/regress-612412.js b/test/mjsunit/regress/regress-612412.js index 3debe66f32..4cd9b9f83e 100644 --- a/test/mjsunit/regress/regress-612412.js +++ b/test/mjsunit/regress/regress-612412.js @@ -15,6 +15,7 @@ var f = (function() { } } })(); +%PrepareFunctionForOptimization(f); g = (function() { f((Array), counter()); }); g(); diff --git a/test/mjsunit/regress/regress-6607-1.js b/test/mjsunit/regress/regress-6607-1.js index 74b702b228..92177dfbc9 100644 --- a/test/mjsunit/regress/regress-6607-1.js +++ b/test/mjsunit/regress/regress-6607-1.js @@ -8,6 +8,7 @@ function get(a, i) { return a[i]; } +%PrepareFunctionForOptimization(get); get([1,,3], 0); get([1,,3], 2); %OptimizeFunctionOnNextCall(get); diff --git a/test/mjsunit/regress/regress-6607-2.js b/test/mjsunit/regress/regress-6607-2.js index cfb0009845..26aafa3a02 100644 --- a/test/mjsunit/regress/regress-6607-2.js +++ b/test/mjsunit/regress/regress-6607-2.js @@ -8,6 +8,7 @@ function get(a, i) { return a[i]; } +%PrepareFunctionForOptimization(get); get([1,,3], 0); get([1,,3], 2); %OptimizeFunctionOnNextCall(get); diff --git a/test/mjsunit/regress/regress-6941.js b/test/mjsunit/regress/regress-6941.js index a8370831f8..aba4d5cdbc 100644 --- a/test/mjsunit/regress/regress-6941.js +++ b/test/mjsunit/regress/regress-6941.js @@ -7,6 +7,7 @@ function foo(x) { return Symbol.iterator == x; } +%PrepareFunctionForOptimization(foo); function main() { foo(Symbol()); diff --git a/test/mjsunit/regress/regress-6948.js b/test/mjsunit/regress/regress-6948.js index c7e0fae28f..4ebf6e1010 100644 --- a/test/mjsunit/regress/regress-6948.js +++ b/test/mjsunit/regress/regress-6948.js @@ -8,6 +8,7 @@ var o = {}; function foo(s) { return o[s]; } +%PrepareFunctionForOptimization(foo); var s = 'c' + 'c'; foo(s); foo(s); diff --git a/test/mjsunit/regress/regress-6989.js b/test/mjsunit/regress/regress-6989.js index b4a33c59c9..26035dd6fd 100644 --- a/test/mjsunit/regress/regress-6989.js +++ b/test/mjsunit/regress/regress-6989.js @@ -7,6 +7,7 @@ (function() { function foo(o) { o["x"] = 1; } + %PrepareFunctionForOptimization(foo); assertThrows(() => foo(undefined)); assertThrows(() => foo(undefined)); %OptimizeFunctionOnNextCall(foo); @@ -17,6 +18,7 @@ (function() { function foo(o) { o["x"] = 1; } + %PrepareFunctionForOptimization(foo); assertThrows(() => foo(null)); assertThrows(() => foo(null)); %OptimizeFunctionOnNextCall(foo); @@ -27,6 +29,7 @@ (function() { function foo(o) { return o["x"]; } + %PrepareFunctionForOptimization(foo); assertThrows(() => foo(undefined)); assertThrows(() => foo(undefined)); %OptimizeFunctionOnNextCall(foo); @@ -37,6 +40,7 @@ (function() { function foo(o) { return o["x"]; } + %PrepareFunctionForOptimization(foo); assertThrows(() => foo(null)); assertThrows(() => foo(null)); %OptimizeFunctionOnNextCall(foo); @@ -47,6 +51,7 @@ (function() { function foo(o) { o.x = 1; } + %PrepareFunctionForOptimization(foo); assertThrows(() => foo(undefined)); assertThrows(() => foo(undefined)); %OptimizeFunctionOnNextCall(foo); @@ -57,6 +62,7 @@ (function() { function foo(o) { o.x = 1; } + %PrepareFunctionForOptimization(foo); assertThrows(() => foo(null)); assertThrows(() => foo(null)); %OptimizeFunctionOnNextCall(foo); @@ -67,6 +73,7 @@ (function() { function foo(o) { return o.x; } + %PrepareFunctionForOptimization(foo); assertThrows(() => foo(undefined)); assertThrows(() => foo(undefined)); %OptimizeFunctionOnNextCall(foo); @@ -77,6 +84,7 @@ (function() { function foo(o) { return o.x; } + %PrepareFunctionForOptimization(foo); assertThrows(() => foo(null)); assertThrows(() => foo(null)); %OptimizeFunctionOnNextCall(foo); diff --git a/test/mjsunit/regress/regress-6991.js b/test/mjsunit/regress/regress-6991.js index 1c6b976977..e88b5e3825 100644 --- a/test/mjsunit/regress/regress-6991.js +++ b/test/mjsunit/regress/regress-6991.js @@ -6,6 +6,7 @@ function foo(o) { return o.x; } +%PrepareFunctionForOptimization(foo); assertEquals(undefined, foo({})); assertEquals(undefined, foo(1)); assertEquals(undefined, foo({})); diff --git a/test/mjsunit/regress/regress-7014-1.js b/test/mjsunit/regress/regress-7014-1.js index 6aadf91aa2..c678087738 100644 --- a/test/mjsunit/regress/regress-7014-1.js +++ b/test/mjsunit/regress/regress-7014-1.js @@ -8,6 +8,7 @@ function foo(s) { return s[5]; } +%PrepareFunctionForOptimization(foo); assertEquals("f", foo("abcdef")); assertEquals(undefined, foo("a")); %OptimizeFunctionOnNextCall(foo); @@ -19,6 +20,7 @@ assertOptimized(foo); String.prototype[5] = "5"; assertEquals("f", foo("abcdef")); +%PrepareFunctionForOptimization(foo); assertEquals("5", foo("a")); %OptimizeFunctionOnNextCall(foo); assertEquals("f", foo("abcdef")); diff --git a/test/mjsunit/regress/regress-7014-2.js b/test/mjsunit/regress/regress-7014-2.js index 057e170d90..6ec6df6b3f 100644 --- a/test/mjsunit/regress/regress-7014-2.js +++ b/test/mjsunit/regress/regress-7014-2.js @@ -8,6 +8,7 @@ function foo(s) { return s[5]; } +%PrepareFunctionForOptimization(foo); assertEquals("f", foo("abcdef")); assertEquals(undefined, foo("a")); %OptimizeFunctionOnNextCall(foo); @@ -23,6 +24,7 @@ String.prototype.__proto__ = new Proxy(String.prototype.__proto__, { }); assertEquals("f", foo("abcdef")); +%PrepareFunctionForOptimization(foo); assertEquals("5", foo("a")); %OptimizeFunctionOnNextCall(foo); assertEquals("f", foo("abcdef")); diff --git a/test/mjsunit/regress/regress-7135.js b/test/mjsunit/regress/regress-7135.js index 2387241eee..3621dec5ce 100644 --- a/test/mjsunit/regress/regress-7135.js +++ b/test/mjsunit/regress/regress-7135.js @@ -5,12 +5,14 @@ // Flags: --allow-natives-syntax --opt function foo() { return -"0" } +%PrepareFunctionForOptimization(foo); foo(); %OptimizeFunctionOnNextCall(foo); foo(); assertOptimized(foo); function bar() { return -"1" } +%PrepareFunctionForOptimization(bar); bar(); %OptimizeFunctionOnNextCall(bar); bar(); diff --git a/test/mjsunit/regress/regress-8913.js b/test/mjsunit/regress/regress-8913.js index 9403334d72..7ebdd063f5 100644 --- a/test/mjsunit/regress/regress-8913.js +++ b/test/mjsunit/regress/regress-8913.js @@ -6,6 +6,7 @@ function foo(t) { return 'a'.concat(t); } +%PrepareFunctionForOptimization(foo); foo(1); foo(1); %OptimizeFunctionOnNextCall(foo); diff --git a/test/mjsunit/regress/regress-902552.js b/test/mjsunit/regress/regress-902552.js index 081df058e2..41a6ea86e7 100644 --- a/test/mjsunit/regress/regress-902552.js +++ b/test/mjsunit/regress/regress-902552.js @@ -4,8 +4,12 @@ // Flags: --allow-natives-syntax -var C = class {}; -for (var i = 0; i < 4; ++i) { - if (i == 2) %OptimizeOsr(); - C.prototype.foo = 42; +function f() { + var C = class {}; + for (var i = 0; i < 4; ++i) { + if (i == 2) %OptimizeOsr(); + C.prototype.foo = 42; + } } +%PrepareFunctionForOptimization(f); +f(); diff --git a/test/mjsunit/regress/regress-903697.js b/test/mjsunit/regress/regress-903697.js index 85f970fe8e..ad2f56058d 100644 --- a/test/mjsunit/regress/regress-903697.js +++ b/test/mjsunit/regress/regress-903697.js @@ -4,9 +4,13 @@ // Flags: --allow-natives-syntax --expose-gc --verify-heap -C = class {}; -for (var i = 0; i < 5; ++i) { - gc(); - if (i == 2) %OptimizeOsr(); - C.prototype.foo = i + 9000000000000000; +function f() { + C = class {}; + for (var i = 0; i < 5; ++i) { + gc(); + if (i == 2) %OptimizeOsr(); + C.prototype.foo = i + 9000000000000000; + } } +%PrepareFunctionForOptimization(f); +f(); diff --git a/test/mjsunit/regress/regress-crbug-150545.js b/test/mjsunit/regress/regress-crbug-150545.js index cfee0618ec..fb21f3d57d 100644 --- a/test/mjsunit/regress/regress-crbug-150545.js +++ b/test/mjsunit/regress/regress-crbug-150545.js @@ -42,11 +42,13 @@ assertSame(2, arguments[1]); assertSame(3, arguments[2]); } + %EnsureFeedbackVectorForFunction(inner); function outer() { inner(1,2,3); for (var i = 0; i < 3; i++) %OptimizeOsr(); } + %PrepareFunctionForOptimization(outer); outer(); })(); diff --git a/test/mjsunit/regress/regress-crbug-480807.js b/test/mjsunit/regress/regress-crbug-480807.js index a1448d6de6..7913a3a8bf 100644 --- a/test/mjsunit/regress/regress-crbug-480807.js +++ b/test/mjsunit/regress/regress-crbug-480807.js @@ -16,6 +16,8 @@ function foo() { } return c; } +%PrepareFunctionForOptimization(foo); + try { foo(); } catch (e) { diff --git a/test/mjsunit/regress/regress-crbug-513507.js b/test/mjsunit/regress/regress-crbug-513507.js index ae321ba906..87ba8b9606 100644 --- a/test/mjsunit/regress/regress-crbug-513507.js +++ b/test/mjsunit/regress/regress-crbug-513507.js @@ -16,8 +16,10 @@ function makeFun() { if (i == osr_fuse) %OptimizeOsr(); } } + %PrepareFunctionForOptimization(fun); return fun; } +%PrepareFunctionForOptimization(makeFun); makeFun()(7); // Warm up. makeFun()(4); // Optimize once. diff --git a/test/mjsunit/regress/regress-crbug-522895.js b/test/mjsunit/regress/regress-crbug-522895.js index f28f3a1cb9..b2c9dc929c 100644 --- a/test/mjsunit/regress/regress-crbug-522895.js +++ b/test/mjsunit/regress/regress-crbug-522895.js @@ -19,4 +19,6 @@ function gen() { return eval("(" + body + ")"); } -gen()(); +var f = gen(); +%PrepareFunctionForOptimization(f); +f(); diff --git a/test/mjsunit/regress/regress-crbug-554831.js b/test/mjsunit/regress/regress-crbug-554831.js index 3d022b257b..27106d5efa 100644 --- a/test/mjsunit/regress/regress-crbug-554831.js +++ b/test/mjsunit/regress/regress-crbug-554831.js @@ -7,6 +7,7 @@ (function() { var key = "s"; function f(object) { return object[key]; }; + %PrepareFunctionForOptimization(f); f(""); f(""); %OptimizeFunctionOnNextCall(f); diff --git a/test/mjsunit/regress/regress-crbug-587068.js b/test/mjsunit/regress/regress-crbug-587068.js index 864f8ce7d2..8704d7230a 100644 --- a/test/mjsunit/regress/regress-crbug-587068.js +++ b/test/mjsunit/regress/regress-crbug-587068.js @@ -7,6 +7,7 @@ // The Crankshaft fast case for String.fromCharCode used to unconditionally // deoptimize on non int32 indices. function foo(i) { return String.fromCharCode(i); } +%PrepareFunctionForOptimization(foo); foo(33); foo(33); %OptimizeFunctionOnNextCall(foo); diff --git a/test/mjsunit/regress/regress-crbug-594183.js b/test/mjsunit/regress/regress-crbug-594183.js index cb8003404d..ddf515907e 100644 --- a/test/mjsunit/regress/regress-crbug-594183.js +++ b/test/mjsunit/regress/regress-crbug-594183.js @@ -24,6 +24,7 @@ function load() { return sum; } +%PrepareFunctionForOptimization(load); load(); load(); %OptimizeFunctionOnNextCall(load); @@ -37,6 +38,7 @@ function store() { } } +%PrepareFunctionForOptimization(store); store(); store(); %OptimizeFunctionOnNextCall(store); @@ -70,6 +72,7 @@ function inferrable_store(key) { store_element(o5, key); } +%PrepareFunctionForOptimization(inferrable_store); inferrable_store(0); inferrable_store(0); %OptimizeFunctionOnNextCall(inferrable_store); diff --git a/test/mjsunit/regress/regress-crbug-638551.js b/test/mjsunit/regress/regress-crbug-638551.js index f812359d8d..46f307e559 100644 --- a/test/mjsunit/regress/regress-crbug-638551.js +++ b/test/mjsunit/regress/regress-crbug-638551.js @@ -7,9 +7,11 @@ function f() { for (var i = 0; i < 10; i++) if (i == 5) %OptimizeOsr(); function g() {} + %PrepareFunctionForOptimization(g); %OptimizeFunctionOnNextCall(g); g(); } +%PrepareFunctionForOptimization(f); f(); gc(); // Make sure that ... gc(); // ... code flushing ... diff --git a/test/mjsunit/regress/regress-crbug-640369.js b/test/mjsunit/regress/regress-crbug-640369.js index 97982d1224..3ca396bb93 100644 --- a/test/mjsunit/regress/regress-crbug-640369.js +++ b/test/mjsunit/regress/regress-crbug-640369.js @@ -8,8 +8,10 @@ function A() { this.x = 0; for (var i = 0; i < max; ) {} } +%EnsureFeedbackVectorForFunction(A); function foo() { for (var i = 0; i < 1; i = 2) %OptimizeOsr(); return new A(); } +%PrepareFunctionForOptimization(foo); try { foo(); } catch (e) { } diff --git a/test/mjsunit/regress/regress-crbug-645888.js b/test/mjsunit/regress/regress-crbug-645888.js index 06879723ea..f29dbebcc0 100644 --- a/test/mjsunit/regress/regress-crbug-645888.js +++ b/test/mjsunit/regress/regress-crbug-645888.js @@ -15,4 +15,5 @@ function f() { throw "no loop, thank you"; } } +%PrepareFunctionForOptimization(f); assertThrows(f); diff --git a/test/mjsunit/regress/regress-crbug-662830.js b/test/mjsunit/regress/regress-crbug-662830.js index 3126978d7d..eec1da2193 100644 --- a/test/mjsunit/regress/regress-crbug-662830.js +++ b/test/mjsunit/regress/regress-crbug-662830.js @@ -14,6 +14,7 @@ function g() { for (var i = 0; i < 3; ++i) if (i === 1) %OptimizeOsr(); %_DeoptimizeNow(); } +%PrepareFunctionForOptimization(g); %OptimizeFunctionOnNextCall(g); g(); diff --git a/test/mjsunit/regress/regress-crbug-665587.js b/test/mjsunit/regress/regress-crbug-665587.js index a9b3841218..48f31c576c 100644 --- a/test/mjsunit/regress/regress-crbug-665587.js +++ b/test/mjsunit/regress/regress-crbug-665587.js @@ -13,4 +13,5 @@ function f() { gc(); } } +%PrepareFunctionForOptimization(f); f(); diff --git a/test/mjsunit/regress/regress-crbug-668795.js b/test/mjsunit/regress/regress-crbug-668795.js index b85d222080..42c2d5243b 100644 --- a/test/mjsunit/regress/regress-crbug-668795.js +++ b/test/mjsunit/regress/regress-crbug-668795.js @@ -17,5 +17,6 @@ function f() { } return result; } +%PrepareFunctionForOptimization(f); assertEquals("R:121212", f()); diff --git a/test/mjsunit/regress/regress-crbug-882233-2.js b/test/mjsunit/regress/regress-crbug-882233-2.js index 565e5fbc23..b79ac2ab29 100644 --- a/test/mjsunit/regress/regress-crbug-882233-2.js +++ b/test/mjsunit/regress/regress-crbug-882233-2.js @@ -12,6 +12,7 @@ function shift_array() { return array.shift(); } +%PrepareFunctionForOptimization(shift_array); assertThrows(shift_array); assertThrows(shift_array); %OptimizeFunctionOnNextCall(shift_array); @@ -25,6 +26,7 @@ function shift_object() { return object.shift(); } +%PrepareFunctionForOptimization(shift_object); assertThrows(shift_object); assertThrows(shift_object); %OptimizeFunctionOnNextCall(shift_object); diff --git a/test/mjsunit/regress/regress-crbug-934166.js b/test/mjsunit/regress/regress-crbug-934166.js index d6fae7136b..b23026f8f0 100644 --- a/test/mjsunit/regress/regress-crbug-934166.js +++ b/test/mjsunit/regress/regress-crbug-934166.js @@ -5,14 +5,18 @@ // Flags: --allow-natives-syntax { - for(let i = 0; i < 10; ++i){ - try{ - // Carefully constructed by a fuzzer to use a new register for s(), whose - // write is dead due to the unconditional throw after s()=N, but which is - // read in the ({...g}) call, which therefore must also be marked dead and - // elided. - with(f&&g&&(s()=N)({...g})){} - } catch {} - %OptimizeOsr(); + function f() { + for(let i = 0; i < 10; ++i){ + try{ + // Carefully constructed by a fuzzer to use a new register for s(), whose + // write is dead due to the unconditional throw after s()=N, but which is + // read in the ({...g}) call, which therefore must also be marked dead and + // elided. + with(f&&g&&(s()=N)({...g})){} + } catch {} + %OptimizeOsr(); + } } + %PrepareFunctionForOptimization(f); + f(); } diff --git a/test/mjsunit/regress/regress-osr-context.js b/test/mjsunit/regress/regress-osr-context.js index a73954156c..7df16bb5eb 100644 --- a/test/mjsunit/regress/regress-osr-context.js +++ b/test/mjsunit/regress/regress-osr-context.js @@ -16,5 +16,6 @@ } return a; } + %PrepareFunctionForOptimization(f); assertEquals(18, f()); })(); diff --git a/test/mjsunit/regress/regress-param-local-type.js b/test/mjsunit/regress/regress-param-local-type.js index 0eaca50af5..99f2b3f520 100644 --- a/test/mjsunit/regress/regress-param-local-type.js +++ b/test/mjsunit/regress/regress-param-local-type.js @@ -37,6 +37,7 @@ function f(a) { // First parameter is tagged. n = i + a; } +%PrepareFunctionForOptimization(f); f(1); f(1); %OptimizeFunctionOnNextCall(f); @@ -51,6 +52,7 @@ function g() { // 0th parameter (receiver) is tagged. n = i + this; } +%PrepareFunctionForOptimization(g); g.call(1); g.call(1); %OptimizeFunctionOnNextCall(g); diff --git a/test/mjsunit/regress/regress-store-uncacheable.js b/test/mjsunit/regress/regress-store-uncacheable.js index 4baedbacae..8a31f2c087 100644 --- a/test/mjsunit/regress/regress-store-uncacheable.js +++ b/test/mjsunit/regress/regress-store-uncacheable.js @@ -32,6 +32,7 @@ function f() { o[""] = 123; } +%PrepareFunctionForOptimization(f); f(); f(); f(); diff --git a/test/mjsunit/regress/regress-sync-optimized-lists.js b/test/mjsunit/regress/regress-sync-optimized-lists.js index 9297c2df54..c51fa8f98b 100644 --- a/test/mjsunit/regress/regress-sync-optimized-lists.js +++ b/test/mjsunit/regress/regress-sync-optimized-lists.js @@ -19,7 +19,7 @@ function get_closure() { return x; } } - +%PrepareFunctionForOptimization(get_closure); var f1 = get_closure(); f1(new Ctor(), false); f1(new Ctor(), false); diff --git a/test/mjsunit/regress/regress-trap-allocation-memento.js b/test/mjsunit/regress/regress-trap-allocation-memento.js index e31fb88354..185f908586 100644 --- a/test/mjsunit/regress/regress-trap-allocation-memento.js +++ b/test/mjsunit/regress/regress-trap-allocation-memento.js @@ -27,6 +27,10 @@ function assertKind(expected, obj, name_opt) { function make2() { return new Array(); } function make3() { return new Array(); } function foo(a, i) { a[0] = i; } + %EnsureFeedbackVectorForFunction(make1); + %EnsureFeedbackVectorForFunction(make2); + %EnsureFeedbackVectorForFunction(make3); + %EnsureFeedbackVectorForFunction(foo); function run_test(maker_function) { var one = maker_function(); @@ -37,6 +41,7 @@ function assertKind(expected, obj, name_opt) { var two = maker_function(); assertKind(elements_kind.fast_double, two); } + %EnsureFeedbackVectorForFunction(run_test); // Initialize the KeyedStoreIC in foo; the actual operation will be done // in the runtime. diff --git a/test/mjsunit/shift-for-integer-div.js b/test/mjsunit/shift-for-integer-div.js index 9264242879..353f79bec8 100644 --- a/test/mjsunit/shift-for-integer-div.js +++ b/test/mjsunit/shift-for-integer-div.js @@ -31,6 +31,7 @@ function divp4(x) { return x / 4; } +%PrepareFunctionForOptimization(divp4); divp4(8); divp4(8); %OptimizeFunctionOnNextCall(divp4); @@ -42,6 +43,7 @@ function divn4(x) { return x / (-4); } +%PrepareFunctionForOptimization(divn4); divn4(8); divn4(8); %OptimizeFunctionOnNextCall(divn4); @@ -55,6 +57,7 @@ function divn1(x) { return x / (-1); } +%PrepareFunctionForOptimization(divn1); var two_31 = 1 << 31; divn1(2); divn1(2); @@ -68,6 +71,7 @@ function divp4t(x) { return (x / 4) | 0; } +%PrepareFunctionForOptimization(divp4t); divp4t(8); divp4t(8); %OptimizeFunctionOnNextCall(divp4t); @@ -79,6 +83,7 @@ function divn4t(x) { return (x / -4) | 0; } +%PrepareFunctionForOptimization(divn4t); divn4t(8); divn4t(8); %OptimizeFunctionOnNextCall(divn4t); @@ -91,6 +96,7 @@ function div_by_two(x) { return (x / 2) | 0; } +%PrepareFunctionForOptimization(div_by_two); div_by_two(12); div_by_two(34); %OptimizeFunctionOnNextCall(div_by_two); diff --git a/test/mjsunit/sin-cos.js b/test/mjsunit/sin-cos.js index 7af471d3c0..17d48ce068 100644 --- a/test/mjsunit/sin-cos.js +++ b/test/mjsunit/sin-cos.js @@ -38,6 +38,7 @@ function no_deopt_on_minus_zero(x) { return Math.sin(x) + Math.cos(x) + Math.tan(x); } +%PrepareFunctionForOptimization(no_deopt_on_minus_zero); no_deopt_on_minus_zero(1); no_deopt_on_minus_zero(1); %OptimizeFunctionOnNextCall(no_deopt_on_minus_zero); diff --git a/test/mjsunit/smi-mul-const.js b/test/mjsunit/smi-mul-const.js index e5255014dc..1501231ff5 100644 --- a/test/mjsunit/smi-mul-const.js +++ b/test/mjsunit/smi-mul-const.js @@ -28,6 +28,7 @@ // Flags: --allow-natives-syntax --opt --noalways-opt function check(func, input, expected) { + %PrepareFunctionForOptimization(func); func(-1); func(-1); %OptimizeFunctionOnNextCall(func); diff --git a/test/mjsunit/strong-rooted-literals.js b/test/mjsunit/strong-rooted-literals.js index 68804e5a32..92dfb0e9c4 100644 --- a/test/mjsunit/strong-rooted-literals.js +++ b/test/mjsunit/strong-rooted-literals.js @@ -13,6 +13,7 @@ return a; } + %PrepareFunctionForOptimization(foo); foo(); foo(); %OptimizeFunctionOnNextCall(foo); @@ -26,9 +27,13 @@ return o.x + o.y; } function mapPlus(a, y) { - return a.map(x => hot({x, y})); + var f = (x => hot({x, y})); + %EnsureFeedbackVectorForFunction(f); + return a.map(f); } + %EnsureFeedbackVectorForFunction(mapPlus); + %PrepareFunctionForOptimization(hot); var a = [1, 2, 3]; print(mapPlus(a, 1)); print(mapPlus(a, 2)); @@ -44,10 +49,12 @@ (function() { var sopen = 'function wrapper() { '; var s1 = 'function foo() { return bar(5); } '; - var s2 = 'foo(); foo(); %OptimizeFunctionOnNextCall(foo); foo(); '; + var s2 = '%PrepareFunctionForOptimization(foo); '; + var s3 = 'foo(); foo(); %OptimizeFunctionOnNextCall(foo); foo(); '; var sclose = '} wrapper(); '; - var s = sopen + s1 + s2 + sclose; + var s = sopen + s1 + s2 + s3 + sclose; function bar(i){return i + 3}; + %EnsureFeedbackVectorForFunction(bar); for (var i = 0; i < 4; i++) { eval(s); diff --git a/test/mjsunit/unary-minus-deopt.js b/test/mjsunit/unary-minus-deopt.js index 07f7e0e497..dc60d07375 100644 --- a/test/mjsunit/unary-minus-deopt.js +++ b/test/mjsunit/unary-minus-deopt.js @@ -37,6 +37,7 @@ function unaryMinusTest(x) { return (g & -g) - 1 | 0; } +%PrepareFunctionForOptimization(unaryMinusTest); unaryMinusTest(3); unaryMinusTest(3); %OptimizeFunctionOnNextCall(unaryMinusTest); @@ -47,6 +48,7 @@ assertOptimized(unaryMinusTest); unaryMinusTest(31); // The following is normally true, but not with --stress-opt. :-/ // assertUnoptimized(unaryMinusTest); +%PrepareFunctionForOptimization(unaryMinusTest); // We should have learned something from the deopt. unaryMinusTest(31);