diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2015-03-27 12:04:12 +0100 |
---|---|---|
committer | Chris Dickinson <christopher.s.dickinson@gmail.com> | 2015-04-28 14:38:16 -0700 |
commit | 36cd5fb9d27b830320e57213f5b8829ffbb93324 (patch) | |
tree | bbab4215d26f8597019135206426fccf27a3089e /deps/v8/test/mjsunit/compiler | |
parent | b57cc51d8d3f4ad279591ae8fa6584ee22773b97 (diff) | |
download | node-new-36cd5fb9d27b830320e57213f5b8829ffbb93324.tar.gz |
deps: upgrade v8 to 4.2.77.13
This commit applies some secondary changes in order to make `make test`
pass cleanly:
* disable broken postmortem debugging in common.gypi
* drop obsolete strict mode test in parallel/test-repl
* drop obsolete test parallel/test-v8-features
PR-URL: https://github.com/iojs/io.js/pull/1232
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'deps/v8/test/mjsunit/compiler')
42 files changed, 1294 insertions, 46 deletions
diff --git a/deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js b/deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js new file mode 100644 index 0000000000..d4beff9f6e --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js @@ -0,0 +1,22 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --turbo-filter=* + +function foo() { + with ({ value:"fooed" }) { return value; } +} + +%OptimizeFunctionOnNextCall(foo); +assertEquals("fooed", foo()); +assertOptimized(foo); + +function bar() { + with ({ value:"bared" }) { return value; } +} + +assertEquals("bared", bar()); +%OptimizeFunctionOnNextCall(bar); +assertEquals("bared", bar()); +assertOptimized(bar); diff --git a/deps/v8/test/mjsunit/compiler/opt-next-call.js b/deps/v8/test/mjsunit/compiler/opt-next-call.js index 6366c7d72e..3d7e74f626 100644 --- a/deps/v8/test/mjsunit/compiler/opt-next-call.js +++ b/deps/v8/test/mjsunit/compiler/opt-next-call.js @@ -11,3 +11,12 @@ function foo() { %OptimizeFunctionOnNextCall(foo); assertEquals("fooed", foo()); assertOptimized(foo); + +function bar() { + return "bared"; +} + +assertEquals("bared", bar()); +%OptimizeFunctionOnNextCall(bar); +assertEquals("bared", bar()); +assertOptimized(bar); diff --git a/deps/v8/test/mjsunit/compiler/optimized-for-in.js b/deps/v8/test/mjsunit/compiler/optimized-for-in.js index 9c756aafa7..f3ff6beb05 100644 --- a/deps/v8/test/mjsunit/compiler/optimized-for-in.js +++ b/deps/v8/test/mjsunit/compiler/optimized-for-in.js @@ -251,9 +251,7 @@ function osr_inner(t, limit) { if (t.hasOwnProperty(x)) { for (var i = 0; i < t[x].length; i++) { r += t[x][i]; - if (i === limit) { - %OptimizeFunctionOnNextCall(osr_inner, "osr"); - } + if (i === limit) %OptimizeOsr(); } r += x; } @@ -267,9 +265,7 @@ function osr_outer(t, osr_after) { for (var i = 0; i < t[x].length; i++) { r += t[x][i]; } - if (x === osr_after) { - %OptimizeFunctionOnNextCall(osr_outer, "osr"); - } + if (x === osr_after) %OptimizeOsr(); r += x; } return r; @@ -279,9 +275,7 @@ function osr_outer_and_deopt(t, osr_after) { var r = 1; for (var x in t) { r += x; - if (x == osr_after) { - %OptimizeFunctionOnNextCall(osr_outer_and_deopt, "osr"); - } + if (x == osr_after) %OptimizeOsr(); } return r; } diff --git a/deps/v8/test/mjsunit/compiler/osr-alignment.js b/deps/v8/test/mjsunit/compiler/osr-alignment.js index 30d72d0614..085d6c4d68 100644 --- a/deps/v8/test/mjsunit/compiler/osr-alignment.js +++ b/deps/v8/test/mjsunit/compiler/osr-alignment.js @@ -25,37 +25,40 @@ // (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 +// Flags: --allow-natives-syntax --use-osr --turbo-osr function f1() { var sum = 0; - for (var i = 0; i < 1000000; i++) { + for (var i = 0; i < 1000; i++) { var x = i + 2; var y = x + 5; var z = y + 3; sum += z; + if (i == 18) %OptimizeOsr(); } return sum; } function f2() { var sum = 0; - for (var i = 0; i < 1000000; i++) { + for (var i = 0; i < 1000; i++) { var x = i + 2; var y = x + 5; var z = y + 3; sum += z; + if (i == 19) %OptimizeOsr(); } return sum; } function f3() { var sum = 0; - for (var i = 0; i < 1000000; i++) { + for (var i = 0; i < 1000; i++) { var x = i + 2; var y = x + 5; var z = y + 3; sum += z; + if (i == 20) %OptimizeOsr(); } return sum; } @@ -63,21 +66,21 @@ function f3() { function test1() { var j = 11; for (var i = 0; i < 2; i++) { - assertEquals(500009500000, f1()); + assertEquals(509500, f1()); } } function test2() { for (var i = 0; i < 2; i++) { var j = 11, k = 12; - assertEquals(500009500000, f2()); + assertEquals(509500, f2()); } } function test3() { for (var i = 0; i < 2; i++) { var j = 11, k = 13, m = 14; - assertEquals(500009500000, f3()); + assertEquals(509500, f3()); } } diff --git a/deps/v8/test/mjsunit/compiler/osr-backedges1.js b/deps/v8/test/mjsunit/compiler/osr-backedges1.js new file mode 100644 index 0000000000..d415f4a107 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-backedges1.js @@ -0,0 +1,31 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +function foo(a) { + var i = a | 0; + while (true) { + if (i == 0) { i = 1; continue; } + if (i == 1) { i = 2; continue; } + if (i == 2) { i = 3; continue; } + if (i == 3) { i = 4; continue; } + if (i == 4) { i = 5; continue; } + if (i == 5) { i = 6; continue; } + if (i == 6) { i = 7; continue; } + if (i == 7) { i = 8; continue; } + for (var j = 0; j < 10; j++) { if (i == 5) %OptimizeOsr(); } + break; + } + return j; +} + +function test(func, tv, fv) { + assertEquals(tv, func(0)); + assertEquals(tv, func(0)); + assertEquals(fv, func(9)); + assertEquals(fv, func(9)); +} + +test(foo, 10, 10); diff --git a/deps/v8/test/mjsunit/compiler/osr-block-scope-func.js b/deps/v8/test/mjsunit/compiler/osr-block-scope-func.js new file mode 100644 index 0000000000..df4076c411 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-block-scope-func.js @@ -0,0 +1,27 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +"use strict"; + +function foo() { + var result; + { + let sum = 0; + for (var i = 0; i < 100; i++) { + if (i == 50) %OptimizeOsr(); + sum += i; + } + result = ret; + function ret() { + return sum; + } + } + return result; +} + +assertEquals(4950, foo()()); +assertEquals(4950, foo()()); +assertEquals(4950, foo()()); diff --git a/deps/v8/test/mjsunit/compiler/osr-block-scope-id.js b/deps/v8/test/mjsunit/compiler/osr-block-scope-id.js new file mode 100644 index 0000000000..923c72f422 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-block-scope-id.js @@ -0,0 +1,40 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +"use strict"; + +function foo() { + var result = new Array(); + var out; + { + let sum = 0; + for (var i = 0; i < 10; i++) { + { + let x = i; + if (i == 5) %OptimizeOsr(); + sum += i; + result.push(function() { return x; }); + } + } + out = sum; + } + result.push(out); + return result; +} + + +function check() { + var r = foo(); + assertEquals(45, r.pop()); + for (var i = 9; i >= 0; i--) { + assertEquals(i, r.pop()()); + } + assertEquals(0, r.length); +} + +check(); +check(); +check(); diff --git a/deps/v8/test/mjsunit/compiler/osr-block-scope.js b/deps/v8/test/mjsunit/compiler/osr-block-scope.js new file mode 100644 index 0000000000..0d78cdcb64 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-block-scope.js @@ -0,0 +1,116 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +"use strict"; + +function nest(body, name, depth) { + var header = ""; + for (var i = 0; i < depth; i++) { + var x = "x" + (i + 1); + header += " for(var " + x + " = 0; " + x + " < 2; " + x + " = " + x + " + 1 | 0) {\n"; + body = body + "}" + } + + return body.replace(new RegExp("function " + name + "\\(\\) {"), + "function " + name + "_" + x + "() {\n" + header); +} + +function test(expected, func, depth) { + assertEquals(expected, func()); + assertEquals(expected, func()); + assertEquals(expected, func()); + + var orig = func.toString(); + var name = func.name; + for (var depth = 1; depth < 4; depth++) { + var body = nest(orig, name, depth); + func = eval("(" + body + ")"); + + assertEquals(expected, func()); + assertEquals(expected, func()); + assertEquals(expected, func()); + } +} + +function foo() { + var result; + { + let sum = 0; + for (var i = 0; i < 10; i++) { + %OptimizeOsr(); + sum += i; + } + result = sum; + } + return result; +} + +test(45, foo); + +function bar() { + let sum = 0; + for (var i = 0; i < 10; i++) { + %OptimizeOsr(); + sum += i; + } + return sum; +} + +test(45, bar); + +function bon() { + { + let sum = 0; + for (var i = 0; i < 10; i++) { + if (i == 5) %OptimizeOsr(); + sum += i; + } + return sum; + } +} + +test(45, bon); + +function row() { + var i = 0; + { + let sum = 0; + while (true) { + if (i == 8) return sum; + %OptimizeOsr(); + sum = i; + i = i + 1 | 0; + } + } + return 11; +} + +test(7, row); + +function nub() { + let i = 0; + while (i < 2) { + %OptimizeOsr(); + i++; + } + return i; +} + +test(2, nub); + +function kub() { + var result = 0; + let i = 0; + while (i < 2) { + let x = i; + %OptimizeOsr(); + i++; + result = x; + } + return result; +} + +test(1, kub); diff --git a/deps/v8/test/mjsunit/compiler/osr-follow.js b/deps/v8/test/mjsunit/compiler/osr-follow.js new file mode 100644 index 0000000000..b6a2e8e4be --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-follow.js @@ -0,0 +1,61 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr --turbo-osr + +function foo(a) { + var sum = 0; + var inc = a ? 100 : 200; + for (var i = 0; i < 100000; i++) { + sum += inc; + } + return sum + inc; +} + +function bar(a) { + var sum = 0; + var inc = a ? 100 : 200; + var x = a ? 5 : 6; + var y = a ? 7 : 8; + for (var i = 0; i < 100000; i++) { + sum += inc; + } + return sum ? x : y; +} + +function baz(a) { + var limit = a ? 100001 : 100002; + var r = 1; + var x = a ? 1 : 2; + var y = a ? 3 : 4; + for (var i = 0; i < limit; i++) { + r = r * -1; + } + return r > 0 ? x == y : x != y; +} + +function qux(a) { + var limit = a ? 100001 : 100002; + var r = 1; + var x = a ? 1 : 2; + var y = a ? 3 : 4; + for (var i = 0; i < limit; i++) { + r = r * -1; + } + var w = r > 0 ? x : y; + var z = r > 0 ? y : x; + return w === z; +} + +function test(func, tv, fv) { + assertEquals(tv, func(true)); + assertEquals(fv, func(false)); + assertEquals(tv, func(true)); + assertEquals(fv, func(false)); +} + +test(foo, 10000100, 20000200); +test(bar, 5, 6); +test(baz, true, false); +test(qux, false, false); diff --git a/deps/v8/test/mjsunit/compiler/osr-for-let.js b/deps/v8/test/mjsunit/compiler/osr-for-let.js new file mode 100644 index 0000000000..4b2fa3e532 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-for-let.js @@ -0,0 +1,82 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +"use strict"; + +function test(expected, func) { + assertEquals(expected, func()); + assertEquals(expected, func()); + assertEquals(expected, func()); +} + +function bar() { + var result; + { + let sum = 0; + for (let i = 0; i < 90; i++) { + sum += i; + if (i == 45) %OptimizeOsr(); + } + result = sum; + } + return result; +} + +test(4005, bar); + +function baz() { + let sum = 0; + for (let i = 0; i < 2; i++) { + sum = 2; + %OptimizeOsr(); + } + return sum; +} + +test(2, baz); + +function qux() { + var result = 0; + for (let i = 0; i < 2; i++) { + result = i; + %OptimizeOsr(); + } + return result; +} + +test(1, qux); + +function nux() { + var result = 0; + for (let i = 0; i < 2; i++) { + { + let sum = i; + %OptimizeOsr(); + result = sum; + } + } + return result; +} + +test(1, nux); + +function blo() { + var result; + { + let sum = 0; + for (let i = 0; i < 90; i++) { + sum += i; + if (i == 45) %OptimizeOsr(); + } + result = ret; + function ret() { + return sum; + } + } + return result; +} + +test(4005, blo()); diff --git a/deps/v8/test/mjsunit/compiler/osr-forin.js b/deps/v8/test/mjsunit/compiler/osr-forin.js new file mode 100644 index 0000000000..8d1678224c --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-forin.js @@ -0,0 +1,26 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr --turbo-osr + +function f(a) { + var sum = 0; + for (var j in a) { + var i = a[j]; + var x = i + 2; + var y = x + 5; + var z = y + 3; + sum += z; + } + return sum; +} + +var a = new Array(10000); +for (var i = 0; i < 10000; i++) { + a[i] = (i * 999) % 77; +} + +for (var i = 0; i < 3; i++) { + assertEquals(480270, f(a)); +} diff --git a/deps/v8/test/mjsunit/compiler/osr-forof.js b/deps/v8/test/mjsunit/compiler/osr-forof.js new file mode 100644 index 0000000000..36bff09c58 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-forof.js @@ -0,0 +1,35 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr --turbo-osr + +function f(a) { + var sum = 0; + for (var i of a) { + var x = i + 2; + var y = x + 5; + var z = y + 3; + sum += z; + } + return sum; +} + +var a = new Array(10000); +for (var i = 0; i < 10000; i++) { + a[i] = (i * 999) % 77; +} + +for (var i = 0; i < 3; i++) { + assertEquals(480270, f(wrap(a))); +} + +function wrap(array) { + var iterable = {}; + var i = 0; + function next() { + return { done: i >= array.length, value: array[i++] }; + }; + iterable[Symbol.iterator] = function() { return { next:next }; }; + return iterable; +} diff --git a/deps/v8/test/mjsunit/compiler/osr-function-id.js b/deps/v8/test/mjsunit/compiler/osr-function-id.js new file mode 100644 index 0000000000..c506ae8282 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-function-id.js @@ -0,0 +1,33 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr --turbo-osr + +function id(f) { return f; } + +function foo() { + var sum = 0; + var r = id(foo); + for (var i = 0; i < 100000; i++) { + sum += i; + } + return foo == r; +} + +assertEquals(true, foo()); +assertEquals(true, foo()); +assertEquals(true, foo()); + + +function bar() { + var sum = 0; + for (var i = 0; i < 90000; i++) { + sum += i; + } + return id(bar,sum); +} + +assertEquals(bar, bar()); +assertEquals(bar, bar()); +assertEquals(bar, bar()); diff --git a/deps/v8/test/mjsunit/compiler/osr-function-id2.js b/deps/v8/test/mjsunit/compiler/osr-function-id2.js new file mode 100644 index 0000000000..561c62e1bc --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-function-id2.js @@ -0,0 +1,28 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr --turbo-osr + +function id(f) { return f; } + +var x = (function foo() { + var sum = 0; + var r = id(foo); + for (var i = 0; i < 100000; i++) { + sum += i; + } + return foo == r; +})(); + +assertEquals(true, x); + +var x = (function bar() { + var sum = 0; + for (var i = 0; i < 90000; i++) { + sum += i; + } + return bar; +})(); + +assertEquals("function", typeof x); diff --git a/deps/v8/test/mjsunit/compiler/osr-function.js b/deps/v8/test/mjsunit/compiler/osr-function.js new file mode 100644 index 0000000000..06d137b62c --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-function.js @@ -0,0 +1,31 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr --turbo-osr + +function foo() { + var sum = 0; + for (var i = 0; i < 100000; i++) { + sum += i; + } + return function() { return sum; } +} + +assertEquals(4999950000, foo()()); +assertEquals(4999950000, foo()()); +assertEquals(4999950000, foo()()); + +function bar() { + var sum = 0; + var ret = 0; + for (var i = 0; i < 90000; i++) { + sum += i; + if (i == 0) ret = function() { return sum; } + } + return ret; +} + +assertEquals(4049955000, bar()()); +assertEquals(4049955000, bar()()); +assertEquals(4049955000, bar()()); diff --git a/deps/v8/test/mjsunit/compiler/osr-manual1.js b/deps/v8/test/mjsunit/compiler/osr-manual1.js new file mode 100644 index 0000000000..29a4948a65 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-manual1.js @@ -0,0 +1,35 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +var counter = 111; + +function gen(w) { // defeat compiler cache. + var num = counter++; + var Z = [ "", "", "", ]; + Z[w] = "%OptimizeOsr()"; + var src = + "function f" + num + "(a,b,c) {" + + " var x = 0;" + + " var y = 0;" + + " var z = 0;" + + " while (a > 0) { " + Z[0] + "; x += 19; a--; }" + + " while (b > 0) { " + Z[1] + "; y += 23; b--; }" + + " while (c > 0) { " + Z[2] + "; z += 29; c--; }" + + " return x + y + z;" + + "} f" + num; + return eval(src); +} + +function check(x,a,b,c) { + for (var i = 0; i < 3; i++) { + var f = gen(i); + assertEquals(x, f(a, b, c)); + } +} + +check(213, 3,3,3); +check(365, 4,5,6); +check(6948, 99,98,97); diff --git a/deps/v8/test/mjsunit/compiler/osr-manual2.js b/deps/v8/test/mjsunit/compiler/osr-manual2.js new file mode 100644 index 0000000000..8aa5d69db3 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-manual2.js @@ -0,0 +1,35 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +var counter = 188; + +function gen(w) { // defeat compiler cache. + var num = counter++; + var Z = [ "", "", "", ]; + Z[w] = "%OptimizeOsr()"; + var src = + "function f" + num + "(a,b,c) {" + + " var x = 0;" + + " var y = 0;" + + " var z = 0;" + + " while (a > 0) { " + Z[0] + "; x += 19; a--; var j=2; while(j--); }" + + " while (b > 0) { " + Z[1] + "; y += 23; b--; var j=2; while(j--); }" + + " while (c > 0) { " + Z[2] + "; z += 29; c--; var j=2; while(j--); }" + + " return x + y + z;" + + "} f" + num; + return eval(src); +} + +function check(x,a,b,c) { + for (var i = 0; i < 3; i++) { + var f = gen(i); + assertEquals(x, f(a, b, c)); + } +} + +check(213, 3,3,3); +check(365, 4,5,6); +check(6948, 99,98,97); diff --git a/deps/v8/test/mjsunit/compiler/osr-maze1.js b/deps/v8/test/mjsunit/compiler/osr-maze1.js new file mode 100644 index 0000000000..6e192c17b7 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-maze1.js @@ -0,0 +1,51 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-deoptimization + +function bar(goal) { + var count = 0; + var sum = 11; + var i = 35; + while (i-- > 33) { + if (count++ == goal) %OptimizeOsr(); + sum = sum + i; + } + while (i-- > 31) { + if (count++ == goal) %OptimizeOsr(); + j = 9; + while (j-- > 7) { + if (count++ == goal) %OptimizeOsr(); + sum = sum + j * 3; + } + while (j-- > 5) { + if (count++ == goal) %OptimizeOsr(); + sum = sum + j * 5; + } + } + while (i-- > 29) { + if (count++ == goal) %OptimizeOsr(); + while (j-- > 3) { + var k = 10; + if (count++ == goal) %OptimizeOsr(); + while (k-- > 8) { + if (count++ == goal) %OptimizeOsr(); + sum = sum + k * 11; + } + } + while (j-- > 1) { + if (count++ == goal) %OptimizeOsr(); + while (k-- > 6) { + if (count++ == goal) %OptimizeOsr(); + sum = sum + j * 13; + } + } + } + return sum; +} + +for (var i = 0; i < 13; i++) { + %DeoptimizeFunction(bar); + assertEquals(348, bar(i)); +} diff --git a/deps/v8/test/mjsunit/compiler/osr-maze2.js b/deps/v8/test/mjsunit/compiler/osr-maze2.js new file mode 100644 index 0000000000..96838a4c34 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-maze2.js @@ -0,0 +1,63 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-deoptimization + +function bar() { + var sum = 11; + var i = 35; + while (i-- > 31) { + LOOP1(); + j = 9; + while (j-- > 7) { + LOOP2(); + sum = sum + j * 5; + var k = 7; + while (k-- > 5) { + LOOP3(); + sum = sum + j * 5; + } + } + } + while (i-- > 29) { + LOOP4(); + while (j-- > 3) { + LOOP5(); + var k = 10; + while (k-- > 8) { + LOOP6(); + sum = sum + k * 11; + } + } + while (j-- > 1) { + LOOP7(); + var k = 8; + while (k-- > 6) { + LOOP8(); + var m = 9; + while (m-- > 6) { + LOOP9(); + sum = sum + k * 13; + } + } + } + } + return sum; +} + +function gen(i) { + var body = bar.toString(); + body = body.replace(new RegExp("bar"), "bar" + i); + for (var j = 1; j < 10; j++) { + var r = new RegExp("LOOP" + j + "\\(\\);"); + if (i == j) body = body.replace(r, "%OptimizeOsr();"); + else body = body.replace(r, ""); + } + return eval("(" + body + ")"); +} + +for (var i = 1; i < 10; i++) { + var f = gen(i); + assertEquals(1979, f()); +} diff --git a/deps/v8/test/mjsunit/compiler/osr-multiple.js b/deps/v8/test/mjsunit/compiler/osr-multiple.js new file mode 100644 index 0000000000..c318645d32 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-multiple.js @@ -0,0 +1,44 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr --turbo-osr + +function f1(a,b,c) { + var x = 0; + var y = 0; + var z = 0; + while (a > 0) { x += 19; a--; } + while (b > 0) { y += 23; b--; } + while (c > 0) { z += 29; c--; } + return x + y + z; +} + +function f2(a,b,c) { + var x = 0; + var y = 0; + var z = 0; + while (a > 0) { x += 19; a--; } + while (b > 0) { y += 23; b--; } + while (c > 0) { z += 29; c--; } + return x + y + z; +} + + +function f3(a,b,c) { + var x = 0; + var y = 0; + var z = 0; + while (a > 0) { x += 19; a--; } + while (b > 0) { y += 23; b--; } + while (c > 0) { z += 29; c--; } + return x + y + z; +} + +function check(f,a,b,c) { + assertEquals(a * 19 + b * 23 + c * 29, f(a,b,c)); +} + +check(f1, 50000, 5, 6); +check(f2, 4, 50000, 6); +check(f3, 11, 12, 50000); diff --git a/deps/v8/test/mjsunit/compiler/osr-multiple2.js b/deps/v8/test/mjsunit/compiler/osr-multiple2.js new file mode 100644 index 0000000000..9a81bfb658 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-multiple2.js @@ -0,0 +1,51 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr +// TODO(titzer): enable --turbo-osr when nested OSR works. + +function f1(a,b,c) { + var x = 0; + var y = 0; + var z = 0; + for (var i = 0; i < 2; i++) { + while (a > 0) { x += 19; a--; } + while (b > 0) { y += 23; b--; } + while (c > 0) { z += 29; c--; } + } + return x + y + z; +} + +function f2(a,b,c) { + var x = 0; + var y = 0; + var z = 0; + for (var i = 0; i < 2; i++) { + while (a > 0) { x += 19; a--; } + while (b > 0) { y += 23; b--; } + while (c > 0) { z += 29; c--; } + } + return x + y + z; +} + + +function f3(a,b,c) { + var x = 0; + var y = 0; + var z = 0; + for (var i = 0; i < 2; i++) { + while (a > 0) { x += 19; a--; } + while (b > 0) { y += 23; b--; } + while (c > 0) { z += 29; c--; } + } + return x + y + z; +} + +function check(f,a,b,c) { + assertEquals(a * 19 + b * 23 + c * 29, f(a,b,c)); +} + +check(f1, 50000, 5, 6); +check(f2, 4, 50000, 6); +check(f3, 11, 12, 50000); diff --git a/deps/v8/test/mjsunit/compiler/osr-multiple3.js b/deps/v8/test/mjsunit/compiler/osr-multiple3.js new file mode 100644 index 0000000000..0fb1ac73a3 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-multiple3.js @@ -0,0 +1,57 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr +// TODO(titzer): enable --turbo-osr when nested OSR works. + +function f1(a,b,c) { + var x = 0; + var y = 0; + var z = 0; + for (var i = 0; i < 2; i++) { + for (var j = 0; j < 2; j++) { + while (a > 0) { x += 19; a--; } + while (b > 0) { y += 23; b--; } + while (c > 0) { z += 29; c--; } + } + } + return x + y + z; +} + +function f2(a,b,c) { + var x = 0; + var y = 0; + var z = 0; + for (var i = 0; i < 2; i++) { + for (var j = 0; j < 2; j++) { + while (a > 0) { x += 19; a--; } + while (b > 0) { y += 23; b--; } + while (c > 0) { z += 29; c--; } + } + } + return x + y + z; +} + + +function f3(a,b,c) { + var x = 0; + var y = 0; + var z = 0; + for (var i = 0; i < 2; i++) { + for (var j = 0; j < 2; j++) { + while (a > 0) { x += 19; a--; } + while (b > 0) { y += 23; b--; } + while (c > 0) { z += 29; c--; } + } + } + return x + y + z; +} + +function check(f,a,b,c) { + assertEquals(a * 19 + b * 23 + c * 29, f(a,b,c)); +} + +check(f1, 50000, 5, 6); +check(f2, 4, 50000, 6); +check(f3, 11, 12, 50000); diff --git a/deps/v8/test/mjsunit/compiler/osr-nested2.js b/deps/v8/test/mjsunit/compiler/osr-nested2.js new file mode 100644 index 0000000000..41bd9b247b --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-nested2.js @@ -0,0 +1,24 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +function f() { + var sum = 0; + for (var i = 5; i < 6; i++) { + for (var j = 0; j < 1000; j++) { + var x = i + 2; + var y = x + 5; + var z = y + 3; + sum += z; + if (i == 21) %OptimizeOsr(); + } + } + return sum; +} + + +assertEquals(15000, f()); +assertEquals(15000, f()); +assertEquals(15000, f()); diff --git a/deps/v8/test/mjsunit/compiler/osr-nested2b.js b/deps/v8/test/mjsunit/compiler/osr-nested2b.js new file mode 100644 index 0000000000..e64c10ccb4 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-nested2b.js @@ -0,0 +1,25 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +function f() { + var sum = 0; + for (var i = 5; i < 6; i++) { + for (var j = 0; j < 1000; j++) { + var x = i + 2; + var y = x + 5; + var z = y + 3; + sum += z; + if (i == 25) %OptimizeOsr(); + } + if (true) break; + } + return sum; +} + + +assertEquals(15000, f()); +assertEquals(15000, f()); +assertEquals(15000, f()); diff --git a/deps/v8/test/mjsunit/compiler/osr-nested3.js b/deps/v8/test/mjsunit/compiler/osr-nested3.js new file mode 100644 index 0000000000..f5d09ba166 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-nested3.js @@ -0,0 +1,26 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +function f() { + var sum = 0; + for (var m = 99; m < 100; m++) { + for (var i = 5; i < 6; i++) { + for (var j = 0; j < 1000; j++) { + var x = i + 2; + var y = x + 5; + var z = y + 3; + sum += z; + if (i == 19) %OptimizeOsr(); + } + } + } + return sum; +} + + +assertEquals(15000, f()); +assertEquals(15000, f()); +assertEquals(15000, f()); diff --git a/deps/v8/test/mjsunit/compiler/osr-nested3b.js b/deps/v8/test/mjsunit/compiler/osr-nested3b.js new file mode 100644 index 0000000000..32ac2a7058 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-nested3b.js @@ -0,0 +1,28 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +function f() { + var sum = 0; + for (var m = 99; m < 100; m++) { + for (var i = 5; i < 6; i++) { + for (var j = 0; j < 1000; j++) { + var x = i + 2; + var y = x + 5; + var z = y + 3; + sum += z; + if (i == 25) %OptimizeOsr(); + } + if (true) break; + } + if (true) break; + } + return sum; +} + + +assertEquals(15000, f()); +assertEquals(15000, f()); +assertEquals(15000, f()); diff --git a/deps/v8/test/mjsunit/compiler/osr-regex-id.js b/deps/v8/test/mjsunit/compiler/osr-regex-id.js new file mode 100644 index 0000000000..7831b14840 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-regex-id.js @@ -0,0 +1,54 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +function id(f) { return f; } + +function foo(a) { + var r = /\0/; + for (var i = 0; i < 10; i++) { + if (a) %OptimizeOsr(); + } + return r; +} + +function bar(a) { + for (var i = 0; i < 10; i++) { + if (a) %OptimizeOsr(); + var r = /\0/; + } + return r; +} + +function baz(a) { + for (var i = 0; i < 10; i++) { + if (a) %OptimizeOsr(); + } + return /\0/; +} + +function qux(a) { + for (var i = 0; i < 10; i++) { + if (i > 5 && a) { + %OptimizeOsr(); + } else { + var r = /\0/; + } + } + return r; +} + +function test(f) { + // Test the reference equality of regex's created in OSR'd function. + var x = f(false); + assertEquals(x, f(true)); + assertEquals(x, f(true)); + assertEquals(x, f(true)); +} + +test(foo); +test(bar); +test(baz); +test(qux); diff --git a/deps/v8/test/mjsunit/compiler/osr-sar.js b/deps/v8/test/mjsunit/compiler/osr-sar.js index fd68b98a45..cc04adca8a 100644 --- a/deps/v8/test/mjsunit/compiler/osr-sar.js +++ b/deps/v8/test/mjsunit/compiler/osr-sar.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: --allow-natives-syntax +// Flags: --allow-natives-syntax --use-osr --turbo-osr function test() { // Loop to force OSR. diff --git a/deps/v8/test/mjsunit/compiler/osr-simple.js b/deps/v8/test/mjsunit/compiler/osr-simple.js index 8ec1b2b936..ddbc5f8867 100644 --- a/deps/v8/test/mjsunit/compiler/osr-simple.js +++ b/deps/v8/test/mjsunit/compiler/osr-simple.js @@ -1,44 +1,22 @@ // Copyright 2010 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. -// Flags: --use-osr +// Flags: --allow-natives-syntax --use-osr function f() { var sum = 0; - for (var i = 0; i < 1000000; i++) { + for (var i = 0; i < 1000; i++) { var x = i + 2; var y = x + 5; var z = y + 3; sum += z; + if (i == 11) %OptimizeOsr(); } return sum; } for (var i = 0; i < 2; i++) { - assertEquals(500009500000, f()); + assertEquals(509500, f()); } diff --git a/deps/v8/test/mjsunit/compiler/osr-top1.js b/deps/v8/test/mjsunit/compiler/osr-top1.js new file mode 100644 index 0000000000..742b71d86e --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-top1.js @@ -0,0 +1,16 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr --allow-natives-syntax + +var sum = 0; +for (var i = 0; i < 10000; i++) { + if (i == 100) %OptimizeOsr(); + var x = i + 2; + var y = x + 5; + var z = y + 3; + sum += z; +} + +assertEquals(50095000, sum); diff --git a/deps/v8/test/mjsunit/compiler/osr-top2.js b/deps/v8/test/mjsunit/compiler/osr-top2.js new file mode 100644 index 0000000000..a15aa15d04 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-top2.js @@ -0,0 +1,19 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr --allow-natives-syntax + +for (var j = 0; j < 3; j++) { + var sum = 0; + for (var i = 0; i < 1000; i++) { + if (i == 100) %OptimizeOsr(); + var x = i + 2; + var y = x + 5; + var z = y + 3; + sum += z; + } + assertEquals(509500, sum); +} + +assertEquals(509500, sum); diff --git a/deps/v8/test/mjsunit/compiler/osr-top3.js b/deps/v8/test/mjsunit/compiler/osr-top3.js new file mode 100644 index 0000000000..4c4a364be0 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-top3.js @@ -0,0 +1,22 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --use-osr --allow-natives-syntax + +for (var k = 0; k < 2; k++) { + for (var j = 0; j < 3; j++) { + var sum = 0; + for (var i = 0; i < 1000; i++) { + if (i == 100) %OptimizeOsr(); + var x = i + 2; + var y = x + 5; + var z = y + 3; + sum += z; + } + assertEquals(509500, sum); + } + assertEquals(509500, sum); +} + +assertEquals(509500, sum); diff --git a/deps/v8/test/mjsunit/compiler/osr-warm.js b/deps/v8/test/mjsunit/compiler/osr-warm.js index 73e1fd5cd2..7c30c07f20 100644 --- a/deps/v8/test/mjsunit/compiler/osr-warm.js +++ b/deps/v8/test/mjsunit/compiler/osr-warm.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 +// Flags: --use-osr --turbo-osr function f1(x) { while (x > 0) { diff --git a/deps/v8/test/mjsunit/compiler/osr-while-let.js b/deps/v8/test/mjsunit/compiler/osr-while-let.js new file mode 100644 index 0000000000..c19cf6cb24 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/osr-while-let.js @@ -0,0 +1,58 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --use-osr --turbo-osr + +"use strict"; + +function test(expected, func) { + assertEquals(expected, func()); + assertEquals(expected, func()); + assertEquals(expected, func()); +} + +function foo() { + var result = 0; + { + let x = 0; + var temp_x = x; + var first = 1; + outer: while (true) { + let x = temp_x; + if (first == 1) first = 0; + else x = x + 1 | 0; + var flag = 1; + for (; flag == 1; (flag = 0, temp_x = x)) { + if (x < 2) { + result = x; %OptimizeOsr(); + } else { + break outer; + } + } + if (flag == 1) break; + } + } + return result; +} + +test(1, foo); + + +function smo() { + var result = 0; + { + let x = 11; + outer: while (true) { + let y = x; + for (var i = 0; i < 5; i++) { + %OptimizeOsr(); + if (i) break outer; + else result = y; + } + } + } + return result; +} + +test(11, smo); diff --git a/deps/v8/test/mjsunit/compiler/regress-3812.js b/deps/v8/test/mjsunit/compiler/regress-3812.js new file mode 100644 index 0000000000..cfc8febc9a --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-3812.js @@ -0,0 +1,19 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var stdlib = this; +var buffer = new ArrayBuffer(64 * 1024); +var foreign = {} + +var foo = (function Module(stdlib, foreign, heap) { + "use asm"; + function foo(i) { + var x = i ? (i&1) : true; + if (x) return x; + return false; + } + return {foo:foo}; +})(stdlib, foreign, buffer).foo; + +assertEquals(1, foo(1)); diff --git a/deps/v8/test/mjsunit/compiler/regress-416359.js b/deps/v8/test/mjsunit/compiler/regress-416359.js new file mode 100644 index 0000000000..18cdc5e728 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-416359.js @@ -0,0 +1,10 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +"use strict" +function f() { + for (x in {a:0}); +} + +assertThrows(f); diff --git a/deps/v8/test/mjsunit/compiler/regress-445907.js b/deps/v8/test/mjsunit/compiler/regress-445907.js new file mode 100644 index 0000000000..c820753eec --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-445907.js @@ -0,0 +1,14 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --turbo-deoptimization + +v = []; +v.length = (1 << 30); + +function f() { + v++; +} + +assertThrows(f); diff --git a/deps/v8/test/mjsunit/compiler/regress-446647.js b/deps/v8/test/mjsunit/compiler/regress-446647.js new file mode 100644 index 0000000000..77757abd66 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-446647.js @@ -0,0 +1,11 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --always-opt --turbo-filter=* --turbo-deoptimization --allow-natives-syntax + +function f(a,b) { + a%b +}; + +f({ toString : function() { %DeoptimizeFunction(f); }}); diff --git a/deps/v8/test/mjsunit/compiler/regress-447567.js b/deps/v8/test/mjsunit/compiler/regress-447567.js new file mode 100644 index 0000000000..b6dc653709 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-447567.js @@ -0,0 +1,15 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --turbo-deoptimization + +assertThrows(function() { + [0].every(function(){ Object.seal((new Int8Array())); }); +}) + +assertThrows(function() { + "use strict"; + const v = 42; + v += 1; +}); diff --git a/deps/v8/test/mjsunit/compiler/regress-451012.js b/deps/v8/test/mjsunit/compiler/regress-451012.js new file mode 100644 index 0000000000..bffc8bc5bd --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-451012.js @@ -0,0 +1,12 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +"use strict"; +function f() { + for (let v; v; ) { + let x; + } +} + +f(); diff --git a/deps/v8/test/mjsunit/compiler/regress-452427.js b/deps/v8/test/mjsunit/compiler/regress-452427.js new file mode 100644 index 0000000000..f798b9cc79 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-452427.js @@ -0,0 +1,18 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var stdlib = {}; +var foreign = {}; +var heap = new ArrayBuffer(64 * 1024); + +var rol = (function Module(stdlib, foreign, heap) { + "use asm"; + function rol() { + y = "a" > false; + return y + (1 - y); + } + return { rol: rol }; +})(stdlib, foreign, heap).rol; + +assertEquals(1, rol()); diff --git a/deps/v8/test/mjsunit/compiler/regress-to-number-binop-deopt.js b/deps/v8/test/mjsunit/compiler/regress-to-number-binop-deopt.js new file mode 100644 index 0000000000..f6b77d9082 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-to-number-binop-deopt.js @@ -0,0 +1,25 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function deopt(f) { + return { valueOf : function() { %DeoptimizeFunction(f); return 1.1; } }; +} + +function or_zero(o) { + return o|0; +} + +function multiply_one(o) { + return +o; +} + +function multiply_one_symbol() { + return +Symbol(); +} + +assertThrows(multiply_one_symbol, TypeError); +assertEquals(1, or_zero(deopt(or_zero))); +assertEquals(1.1, multiply_one(deopt(multiply_one))); |