diff options
Diffstat (limited to 'src/3rdparty/v8/test/mjsunit/compiler')
11 files changed, 1059 insertions, 49 deletions
diff --git a/src/3rdparty/v8/test/mjsunit/compiler/alloc-object-huge.js b/src/3rdparty/v8/test/mjsunit/compiler/alloc-object-huge.js index 0b202f7..b0a981d 100644 --- a/src/3rdparty/v8/test/mjsunit/compiler/alloc-object-huge.js +++ b/src/3rdparty/v8/test/mjsunit/compiler/alloc-object-huge.js @@ -25,7 +25,9 @@ // (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 --inline-construct --max-inlined-source-size=999999 --max-inlined-nodes=999999 --max-inlined-nodes-cumulative=999999 +// Flags: --allow-natives-syntax --inline-construct +// Flags: --max-inlined-source-size=999999 --max-inlined-nodes=999999 +// Flags: --max-inlined-nodes-cumulative=999999 // Test that huge constructors (more than 256 this assignments) are // handled correctly. diff --git a/src/3rdparty/v8/test/mjsunit/compiler/inline-accessors.js b/src/3rdparty/v8/test/mjsunit/compiler/inline-accessors.js new file mode 100644 index 0000000..a4cf7ae --- /dev/null +++ b/src/3rdparty/v8/test/mjsunit/compiler/inline-accessors.js @@ -0,0 +1,368 @@ +// Copyright 2012 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. + +// Flags: --allow-natives-syntax --inline-accessors --max-opt-count=100 + +var accessorCallCount, setterArgument, setterValue, obj, forceDeopt; + +// ----------------------------------------------------------------------------- +// Helpers for testing inlining of getters. + +function TestInlinedGetter(context, obj, expected) { + forceDeopt = { deopt: 0 }; + accessorCallCount = 0; + + assertEquals(expected, context(obj)); + assertEquals(1, accessorCallCount); + + assertEquals(expected, context(obj)); + assertEquals(2, accessorCallCount); + + %OptimizeFunctionOnNextCall(context); + assertEquals(expected, context(obj)); + assertEquals(3, accessorCallCount); + + forceDeopt = { /* empty*/ }; + assertEquals(expected, context(obj)); + assertEquals(4, accessorCallCount); +} + + +function value_context_for_getter(obj) { + return obj.getterProperty; +} + +function test_context_for_getter(obj) { + if (obj.getterProperty) { + return 111; + } else { + return 222; + } +} + +function effect_context_for_getter(obj) { + obj.getterProperty; + return 5678; +} + +function TryGetter(context, getter, obj, expected, expectException) { + try { + TestInlinedGetter(context, obj, expected); + assertFalse(expectException); + } catch (exception) { + assertTrue(expectException); + assertEquals(7, exception.stack.split('\n').length); + } + %DeoptimizeFunction(context); + %ClearFunctionTypeFeedback(context); + %ClearFunctionTypeFeedback(getter); +} + +function TestGetterInAllContexts(getter, obj, expected, expectException) { + TryGetter(value_context_for_getter, getter, obj, expected, expectException); + TryGetter(test_context_for_getter, getter, obj, expected ? 111 : 222, + expectException); + TryGetter(effect_context_for_getter, getter, obj, 5678, expectException); +} + +// ----------------------------------------------------------------------------- +// Test getter returning something 'true'ish in all contexts. + +function getter1() { + assertSame(obj, this); + accessorCallCount++; + forceDeopt.deopt; + return 1234; +} + +function ConstrG1() { } +obj = Object.defineProperty(new ConstrG1(), "getterProperty", { get: getter1 }); +TestGetterInAllContexts(getter1, obj, 1234, false); +obj = Object.create(obj); +TestGetterInAllContexts(getter1, obj, 1234, false); + +// ----------------------------------------------------------------------------- +// Test getter returning false in all contexts. + +function getter2() { + assertSame(obj, this); + accessorCallCount++; + forceDeopt.deopt; + return false; +} + +function ConstrG2() { } +obj = Object.defineProperty(new ConstrG2(), "getterProperty", { get: getter2 }); +TestGetterInAllContexts(getter2, obj, false, false); +obj = Object.create(obj); +TestGetterInAllContexts(getter2, obj, false, false); + +// ----------------------------------------------------------------------------- +// Test getter without a return in all contexts. + +function getter3() { + assertSame(obj, this); + accessorCallCount++; + forceDeopt.deopt; +} + +function ConstrG3() { } +obj = Object.defineProperty(new ConstrG3(), "getterProperty", { get: getter3 }); +TestGetterInAllContexts(getter3, obj, undefined, false); +obj = Object.create(obj); +TestGetterInAllContexts(getter3, obj, undefined, false); + +// ----------------------------------------------------------------------------- +// Test getter with too many arguments without a return in all contexts. + +function getter4(a) { + assertSame(obj, this); + assertEquals(undefined, a); + accessorCallCount++; + forceDeopt.deopt; +} + +function ConstrG4() { } +obj = Object.defineProperty(new ConstrG4(), "getterProperty", { get: getter4 }); +TestGetterInAllContexts(getter4, obj, undefined, false); +obj = Object.create(obj); +TestGetterInAllContexts(getter4, obj, undefined, false); + +// ----------------------------------------------------------------------------- +// Test getter with too many arguments with a return in all contexts. + +function getter5(a) { + assertSame(obj, this); + assertEquals(undefined, a); + accessorCallCount++; + forceDeopt.deopt; + return 9876; +} + +function ConstrG5() { } +obj = Object.defineProperty(new ConstrG5(), "getterProperty", { get: getter5 }); +TestGetterInAllContexts(getter5, obj, 9876, false); +obj = Object.create(obj); +TestGetterInAllContexts(getter5, obj, 9876, false); + +// ----------------------------------------------------------------------------- +// Test getter which throws from optimized code. + +function getter6() { + assertSame(obj, this); + accessorCallCount++; + forceDeopt.deopt; + if (accessorCallCount == 4) { 123 in null; } + return 13579; +} + +function ConstrG6() { } +obj = Object.defineProperty(new ConstrG6(), "getterProperty", { get: getter6 }); +TestGetterInAllContexts(getter6, obj, 13579, true); +obj = Object.create(obj); +TestGetterInAllContexts(getter6, obj, 13579, true); + +// ----------------------------------------------------------------------------- +// Helpers for testing inlining of setters. + +function TestInlinedSetter(context, obj, value, expected) { + forceDeopt = { deopt: 0 }; + accessorCallCount = 0; + setterArgument = value; + + assertEquals(expected, context(obj, value)); + assertEquals(value, setterValue); + assertEquals(1, accessorCallCount); + + assertEquals(expected, context(obj, value)); + assertEquals(value, setterValue); + assertEquals(2, accessorCallCount); + + %OptimizeFunctionOnNextCall(context); + assertEquals(expected, context(obj, value)); + assertEquals(value, setterValue); + assertEquals(3, accessorCallCount); + + forceDeopt = { /* empty*/ }; + assertEquals(expected, context(obj, value)); + assertEquals(value, setterValue); + assertEquals(4, accessorCallCount); +} + +function value_context_for_setter(obj, value) { + return obj.setterProperty = value; +} + +function test_context_for_setter(obj, value) { + if (obj.setterProperty = value) { + return 333; + } else { + return 444; + } +} + +function effect_context_for_setter(obj, value) { + obj.setterProperty = value; + return 666; +} + +function TrySetter(context, setter, obj, expectException, value, expected) { + try { + TestInlinedSetter(context, obj, value, expected); + assertFalse(expectException); + } catch (exception) { + assertTrue(expectException); + assertEquals(7, exception.stack.split('\n').length); + } + %DeoptimizeFunction(context); + %ClearFunctionTypeFeedback(context); + %ClearFunctionTypeFeedback(setter); +} + +function TestSetterInAllContexts(setter, obj, expectException) { + TrySetter(value_context_for_setter, setter, obj, expectException, 111, 111); + TrySetter(test_context_for_setter, setter, obj, expectException, true, 333); + TrySetter(test_context_for_setter, setter, obj, expectException, false, 444); + TrySetter(effect_context_for_setter, setter, obj, expectException, 555, 666); +} + +// ----------------------------------------------------------------------------- +// Test setter without a return in all contexts. + +function setter1(value) { + assertSame(obj, this); + accessorCallCount++; + forceDeopt.deopt; + setterValue = value; +} + +function ConstrS1() { } +obj = Object.defineProperty(new ConstrS1(), "setterProperty", { set: setter1 }); +TestSetterInAllContexts(setter1, obj, false); +obj = Object.create(obj); +TestSetterInAllContexts(setter1, obj, false); + +// ----------------------------------------------------------------------------- +// Test setter returning something different than the RHS in all contexts. + +function setter2(value) { + assertSame(obj, this); + accessorCallCount++; + forceDeopt.deopt; + setterValue = value; + return 1000000; +} + +function ConstrS2() { } +obj = Object.defineProperty(new ConstrS2(), "setterProperty", { set: setter2 }); +TestSetterInAllContexts(setter2, obj, false); +obj = Object.create(obj); +TestSetterInAllContexts(setter2, obj, false); + +// ----------------------------------------------------------------------------- +// Test setter with too few arguments without a return in all contexts. + +function setter3() { + assertSame(obj, this); + accessorCallCount++; + forceDeopt.deopt; + setterValue = setterArgument; +} + +function ConstrS3() { } +obj = Object.defineProperty(new ConstrS3(), "setterProperty", { set: setter3 }); +TestSetterInAllContexts(setter3, obj, false); +obj = Object.create(obj); +TestSetterInAllContexts(setter3, obj, false); + +// ----------------------------------------------------------------------------- +// Test setter with too few arguments with a return in all contexts. + +function setter4() { + assertSame(obj, this); + accessorCallCount++; + forceDeopt.deopt; + setterValue = setterArgument; + return 2000000; +} + +function ConstrS4() { } +obj = Object.defineProperty(new ConstrS4(), "setterProperty", { set: setter4 }); +TestSetterInAllContexts(setter4, obj, false); +obj = Object.create(obj); +TestSetterInAllContexts(setter4, obj, false); + +// ----------------------------------------------------------------------------- +// Test setter with too many arguments without a return in all contexts. + +function setter5(value, foo) { + assertSame(obj, this); + assertEquals(undefined, foo); + accessorCallCount++; + forceDeopt.deopt; + setterValue = value; +} + +function ConstrS5() { } +obj = Object.defineProperty(new ConstrS5(), "setterProperty", { set: setter5 }); +TestSetterInAllContexts(setter5, obj, false); +obj = Object.create(obj); +TestSetterInAllContexts(setter5, obj, false); + +// ----------------------------------------------------------------------------- +// Test setter with too many arguments with a return in all contexts. + +function setter6(value, foo) { + assertSame(obj, this); + assertEquals(undefined, foo); + accessorCallCount++; + forceDeopt.deopt; + setterValue = value; + return 3000000; +} + +function ConstrS6() { } +obj = Object.defineProperty(new ConstrS6(), "setterProperty", { set: setter6 }); +TestSetterInAllContexts(setter6, obj, false); +obj = Object.create(obj); +TestSetterInAllContexts(setter6, obj, false); + +// ----------------------------------------------------------------------------- +// Test setter which throws from optimized code. + +function setter7(value) { + accessorCallCount++; + forceDeopt.deopt; + if (accessorCallCount == 4) { 123 in null; } + setterValue = value; +} + +function ConstrS7() { } +obj = Object.defineProperty(new ConstrS7(), "setterProperty", { set: setter7 }); +TestSetterInAllContexts(setter7, obj, true); +obj = Object.create(obj); +TestSetterInAllContexts(setter7, obj, true); diff --git a/src/3rdparty/v8/test/mjsunit/compiler/inline-arguments.js b/src/3rdparty/v8/test/mjsunit/compiler/inline-arguments.js index f8a2476..df1bd22 100644 --- a/src/3rdparty/v8/test/mjsunit/compiler/inline-arguments.js +++ b/src/3rdparty/v8/test/mjsunit/compiler/inline-arguments.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 --max-opt-count=100 function A() { } @@ -157,6 +157,7 @@ function test_toarr(toarr) { test_toarr(toarr1); test_toarr(toarr2); + // Test that arguments access from inlined function uses correct values. (function () { function inner(x, y) { @@ -174,9 +175,94 @@ test_toarr(toarr2); return inner(x, y); } + %OptimizeFunctionOnNextCall(outer); + %OptimizeFunctionOnNextCall(inner); + assertEquals(2, outer(1, 2)); +})(); + + +(function () { + function inner(x, y) { + "use strict"; + x = 10; + y = 20; + for (var i = 0; i < 1; i++) { + for (var j = 1; j <= arguments.length; j++) { + return arguments[arguments.length - j]; + } + } + } + + function outer(x, y) { + return inner(x, y); + } + assertEquals(2, outer(1, 2)); assertEquals(2, outer(1, 2)); assertEquals(2, outer(1, 2)); %OptimizeFunctionOnNextCall(outer); assertEquals(2, outer(1, 2)); })(); + + +// Test inlining and deoptimization of functions accessing and modifying +// the arguments object in strict mode with mismatched arguments count. +(function () { + "use strict"; + function test(outerCount, middleCount, innerCount) { + var forceDeopt = { deopt:false }; + function inner(x,y) { + x = 0; y = 0; + forceDeopt.deopt; + assertSame(innerCount, arguments.length); + for (var i = 0; i < arguments.length; i++) { + assertSame(30 + i, arguments[i]); + } + } + + function middle(x,y) { + x = 0; y = 0; + if (innerCount == 1) inner(30); + if (innerCount == 2) inner(30, 31); + if (innerCount == 3) inner(30, 31, 32); + assertSame(middleCount, arguments.length); + for (var i = 0; i < arguments.length; i++) { + assertSame(20 + i, arguments[i]); + } + } + + function outer(x,y) { + x = 0; y = 0; + if (middleCount == 1) middle(20); + if (middleCount == 2) middle(20, 21); + if (middleCount == 3) middle(20, 21, 22); + assertSame(outerCount, arguments.length); + for (var i = 0; i < arguments.length; i++) { + assertSame(10 + i, arguments[i]); + } + } + + for (var step = 0; step < 4; step++) { + if (outerCount == 1) outer(10); + if (outerCount == 2) outer(10, 11); + if (outerCount == 3) outer(10, 11, 12); + if (step == 1) %OptimizeFunctionOnNextCall(outer); + if (step == 2) delete forceDeopt.deopt; + } + + %DeoptimizeFunction(outer); + %DeoptimizeFunction(middle); + %DeoptimizeFunction(inner); + %ClearFunctionTypeFeedback(outer); + %ClearFunctionTypeFeedback(middle); + %ClearFunctionTypeFeedback(inner); + } + + for (var a = 1; a <= 3; a++) { + for (var b = 1; b <= 3; b++) { + for (var c = 1; c <= 3; c++) { + test(a,b,c); + } + } + } +})(); diff --git a/src/3rdparty/v8/test/mjsunit/compiler/inline-construct.js b/src/3rdparty/v8/test/mjsunit/compiler/inline-construct.js index 7a3f1e4..fa784cf 100644 --- a/src/3rdparty/v8/test/mjsunit/compiler/inline-construct.js +++ b/src/3rdparty/v8/test/mjsunit/compiler/inline-construct.js @@ -29,63 +29,72 @@ // Test inlining of constructor calls. -function TestInlinedConstructor(closure) { +function TestInlinedConstructor(constructor, closure) { var result; var counter = { value:0 }; - result = closure(11, 12, counter); - assertEquals(23, result); + var noDeopt = { deopt:0 }; + var forceDeopt = { /*empty*/ }; + + result = closure(constructor, 11, noDeopt, counter); + assertEquals(11, result); assertEquals(1, counter.value); - result = closure(23, 19, counter); - assertEquals(42, result); + + result = closure(constructor, 23, noDeopt, counter); + assertEquals(23, result); assertEquals(2, counter.value); + %OptimizeFunctionOnNextCall(closure); - result = closure(1, 42, counter) - assertEquals(43, result); + result = closure(constructor, 42, noDeopt, counter); + assertEquals(42, result); assertEquals(3, counter.value); - result = closure("foo", "bar", counter) - assertEquals("foobar", result) + + result = closure(constructor, 127, forceDeopt, counter); + assertEquals(127, result) assertEquals(4, counter.value); + + %DeoptimizeFunction(closure); + %ClearFunctionTypeFeedback(closure); + %ClearFunctionTypeFeedback(constructor); } -function TestInAllContexts(constructor) { - function value_context(a, b, counter) { - var obj = new constructor(a, b, counter); - return obj.x; - } - function test_context(a, b, counter) { - if (!new constructor(a, b, counter)) { - assertUnreachable("should not happen"); - } - return a + b; - } - function effect_context(a, b, counter) { - new constructor(a, b, counter); - return a + b; +function value_context(constructor, val, deopt, counter) { + var obj = new constructor(val, deopt, counter); + return obj.x; +} + +function test_context(constructor, val, deopt, counter) { + if (!new constructor(val, deopt, counter)) { + assertUnreachable("should not happen"); } - TestInlinedConstructor(value_context); - TestInlinedConstructor(test_context); - TestInlinedConstructor(effect_context); - %DeoptimizeFunction(value_context); - %DeoptimizeFunction(test_context); - %DeoptimizeFunction(effect_context); - %ClearFunctionTypeFeedback(value_context); - %ClearFunctionTypeFeedback(test_context); - %ClearFunctionTypeFeedback(effect_context); + return val; +} + +function effect_context(constructor, val, deopt, counter) { + new constructor(val, deopt, counter); + return val; +} + +function TestInAllContexts(constructor) { + TestInlinedConstructor(constructor, value_context); + TestInlinedConstructor(constructor, test_context); + TestInlinedConstructor(constructor, effect_context); } // Test constructor returning nothing in all contexts. -function c1(a, b, counter) { - this.x = a + b; +function c1(val, deopt, counter) { + deopt.deopt; + this.x = val; counter.value++; } TestInAllContexts(c1); // Test constructor returning an object in all contexts. -function c2(a, b, counter) { - var obj = new Object(); - obj.x = a + b; +function c2(val, deopt, counter) { + var obj = {}; + deopt.deopt; + obj.x = val; counter.value++; return obj; } @@ -93,8 +102,9 @@ TestInAllContexts(c2); // Test constructor returning a primitive value in all contexts. -function c3(a, b, counter) { - this.x = a + b; +function c3(val, deopt, counter) { + deopt.deopt; + this.x = val; counter.value++; return "not an object"; } @@ -133,9 +143,10 @@ assertEquals("foo1", f_too_few("foo")) // Test constructor that cannot be inlined. -function c_unsupported_syntax(a, b, counter) { +function c_unsupported_syntax(val, deopt, counter) { try { - this.x = a + b; + deopt.deopt; + this.x = val; counter.value++; } catch(e) { throw new Error(); @@ -146,9 +157,10 @@ TestInAllContexts(c_unsupported_syntax); // Regression test: Inlined constructors called as functions do not get their // implicit receiver object set to undefined, even in strict mode. -function c_strict(a, b, counter) { +function c_strict(val, deopt, counter) { "use strict"; - this.x = a + b; + deopt.deopt; + this.x = val; counter.value++; } TestInAllContexts(c_strict); diff --git a/src/3rdparty/v8/test/mjsunit/compiler/inline-literals.js b/src/3rdparty/v8/test/mjsunit/compiler/inline-literals.js index f78abe8..1422586 100644 --- a/src/3rdparty/v8/test/mjsunit/compiler/inline-literals.js +++ b/src/3rdparty/v8/test/mjsunit/compiler/inline-literals.js @@ -29,6 +29,26 @@ // Test that we can inline functions containing materialized literals. +function a2(b, c) { + return [b, c, b + c]; +} + +function a1(a, b, c) { + return [a, a2(b, c)]; +} + +function TestArrayLiteral(a, b, c) { + var expected = [a, [b, c, b + c]]; + var result = a1(a, b, c); + assertEquals(expected, result, "TestArrayLiteral"); +} + +TestArrayLiteral(1, 2, 3); +TestArrayLiteral(1, 2, 3); +%OptimizeFunctionOnNextCall(TestArrayLiteral); +TestArrayLiteral(1, 2, 3); +TestArrayLiteral('a', 'b', 'c'); + function o2(b, c) { return { 'b':b, 'c':c, 'y':b + c }; } @@ -48,3 +68,22 @@ TestObjectLiteral(1, 2, 3); %OptimizeFunctionOnNextCall(TestObjectLiteral); TestObjectLiteral(1, 2, 3); TestObjectLiteral('a', 'b', 'c'); + +function r2(s, x, y) { + return s.replace(/a/, x + y); +} + +function r1(s, x, y) { + return r2(s, x, y).replace(/b/, y + x); +} + +function TestRegExpLiteral(s, x, y, expected) { + var result = r1(s, x, y); + assertEquals(expected, result, "TestRegExpLiteral"); +} + +TestRegExpLiteral("a-", "reg", "exp", "regexp-"); +TestRegExpLiteral("-b", "reg", "exp", "-expreg"); +%OptimizeFunctionOnNextCall(TestRegExpLiteral); +TestRegExpLiteral("ab", "reg", "exp", "regexpexpreg"); +TestRegExpLiteral("ab", 12345, 54321, "6666666666"); diff --git a/src/3rdparty/v8/test/mjsunit/compiler/optimized-closures.js b/src/3rdparty/v8/test/mjsunit/compiler/optimized-closures.js new file mode 100644 index 0000000..eaf75f8 --- /dev/null +++ b/src/3rdparty/v8/test/mjsunit/compiler/optimized-closures.js @@ -0,0 +1,57 @@ +// Copyright 2012 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. + +// Flags: --allow-natives-syntax + +// Test optimized closures. + +var a = new Array(100); + +function f() { + var x=0; + for (var i=0; i<100; i++) { + var g = function goo(y) { + function h() { + if (goo.arguments[0] == 23) return -42; + return 42; + } + return x + y + h(y); + } + g(0); + %OptimizeFunctionOnNextCall(g); + a[i] = g(i); + } +} + +f(); +assertEquals(42, a[0]); +assertEquals(49, a[7]); +assertEquals(-19, a[23]); + + + + diff --git a/src/3rdparty/v8/test/mjsunit/compiler/proto-chain-load.js b/src/3rdparty/v8/test/mjsunit/compiler/proto-chain-load.js new file mode 100644 index 0000000..60c6431 --- /dev/null +++ b/src/3rdparty/v8/test/mjsunit/compiler/proto-chain-load.js @@ -0,0 +1,44 @@ +// Copyright 2012 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. + +// Flags: --allow-natives-syntax + +// Test HLoadNamedField on the proto chain. + +var obj4 = Object.create(null, { f4: {value: 4} }); +var obj3 = Object.create(obj4, { f3: {value: 3} }); +var obj2 = Object.create(obj3, { f2: {value: 2} }); +var obj1 = Object.create(obj2, { f1: {value: 1} }); +var obj0 = Object.create(obj1, { f0: {value: 0} }); + +function get4(obj) { return obj.f4; } + +assertEquals(4, get4(obj0)); +assertEquals(4, get4(obj0)); +%OptimizeFunctionOnNextCall(get4); +assertEquals(4, get4(obj0)); +assertEquals(4, get4(obj0)); diff --git a/src/3rdparty/v8/test/mjsunit/compiler/regress-gvn.js b/src/3rdparty/v8/test/mjsunit/compiler/regress-gvn.js index 358daf7..01b1aa9 100644 --- a/src/3rdparty/v8/test/mjsunit/compiler/regress-gvn.js +++ b/src/3rdparty/v8/test/mjsunit/compiler/regress-gvn.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: --noalways-opt +// Flags: --noalways-opt --allow-natives-syntax // // Regression test for global value numbering. @@ -39,10 +39,11 @@ function test(a) { var a = new Array(); -var n = 100000000; +var n = 100; var result = 0; for (var i = 0; i < n; ++i) { + if (i == 10) %OptimizeFunctionOnNextCall(test); a[0] = 0; result += test(a); } diff --git a/src/3rdparty/v8/test/mjsunit/compiler/regress-or.js b/src/3rdparty/v8/test/mjsunit/compiler/regress-or.js index 89f7802..939f2c3 100644 --- a/src/3rdparty/v8/test/mjsunit/compiler/regress-or.js +++ b/src/3rdparty/v8/test/mjsunit/compiler/regress-or.js @@ -25,6 +25,8 @@ // (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 + // Test deoptimization inside short-circuited expressions. function f1(x) { var c = "fail"; @@ -36,7 +38,8 @@ function f1(x) { function g1() { try { return 1; } finally {} } -for (var i=0; i<10000000; i++) f1(42); +for (var i = 0; i < 5; i++) f1(42); +%OptimizeFunctionOnNextCall(f1); assertEquals(-1, f1(0)); assertEquals(-43, f1(42)); @@ -52,6 +55,7 @@ function f2(x) { function g2() { try { return 0; } finally {} } -for (var i=0; i<10000000; i++) f2(42); +for (var i = 0; i < 5; i++) f2(42); +%OptimizeFunctionOnNextCall(f2); assertEquals(-1, f2("")); diff --git a/src/3rdparty/v8/test/mjsunit/compiler/rotate.js b/src/3rdparty/v8/test/mjsunit/compiler/rotate.js new file mode 100644 index 0000000..14fe9da --- /dev/null +++ b/src/3rdparty/v8/test/mjsunit/compiler/rotate.js @@ -0,0 +1,224 @@ +// Copyright 2012 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. + +// Flags: --allow-natives-syntax --expose-gc + +// Test shift operations that can be replaced by rotate operation. + +function SideEffect() { + with ({}) { } // not inlinable +} + +function Twenty() { + SideEffect(); + return 20; +} + +function Twelve() { + SideEffect(); + return 12; +} + + +function ROR(x, sa) { + return (x >>> sa) | (x << (32 - sa)); +} + +function ROR1(x, sa) { + return (x >>> sa) | (x << (32 - sa)); +} + +function ROR2(x, sa) { + return (x >>> (32 - sa)) | (x << (sa)); +} + +function ROR3(x, sa) { + return (x << (32 - sa)) | (x >>> sa); +} + +function ROR4(x, sa) { + return (x << (sa)) | (x >>> (32 - sa)); +} + +assertEquals(1 << ((2 % 32)), ROR(1, 30)); +assertEquals(1 << ((2 % 32)), ROR(1, 30)); +%OptimizeFunctionOnNextCall(ROR); +assertEquals(1 << ((2 % 32)), ROR(1, 30)); + +assertEquals(0xF0000FFF | 0, ROR1(0x0000FFFF, 4)); +assertEquals(0xF0000FFF | 0, ROR1(0x0000FFFF, 4)); +%OptimizeFunctionOnNextCall(ROR1); +assertEquals(0xF0000FFF | 0, ROR1(0x0000FFFF, 4)); + +assertEquals(0x0FFFF000 | 0, ROR1(0x0000FFFF, 20)); +assertEquals(0x0FFFF000 | 0, ROR1(0x0000FFFF, 20)); +%OptimizeFunctionOnNextCall(ROR1); +assertEquals(0x0FFFF000 | 0, ROR1(0x0000FFFF, 20)); + +assertEquals(0x0FFFF000 | 0, ROR1(0x0000FFFF, Twenty())); +assertEquals(0x0FFFF000 | 0, ROR1(0x0000FFFF, Twenty())); +%OptimizeFunctionOnNextCall(ROR1); +assertEquals(0x0FFFF000 | 0, ROR1(0x0000FFFF, Twenty())); + +for (var i = 0; i <= 100; i++) { + assertEquals(0xFFFFFFFF | 0, ROR1(0xFFFFFFFF, i)); + assertEquals(0xFFFFFFFF | 0, ROR1(0xFFFFFFFF, i)); + %OptimizeFunctionOnNextCall(ROR1); + assertEquals(0xFFFFFFFF | 0, ROR1(0xFFFFFFFF, i)); +} + +for (var i = 0; i <= 100; i++) { + assertEquals(-1, ROR1(-1, i)); + assertEquals(-1, ROR1(-1, i)); + %OptimizeFunctionOnNextCall(ROR1); + assertEquals(-1, ROR1(-1, i)); +} + +for (var i = 0; i <= 100; i++) { + assertEquals(1 << (32 - (i % 32)), ROR1(1, i)); + assertEquals(1 << (32 - (i % 32)), ROR1(1, i)); + %OptimizeFunctionOnNextCall(ROR1); + assertEquals(1 << (32 - (i % 32)), ROR1(1, i)); +} + +for (var i = 0; i <= 100; i++) { + assertEquals(1 << (32 - (i % 32)), ROR1(1.4, i)); + assertEquals(1 << (32 - (i % 32)), ROR1(1.4, i)); + %OptimizeFunctionOnNextCall(ROR1); + assertEquals(1 << (32 - (i % 32)), ROR1(1.4, i)); +} + + + +assertEquals(0xF0000FFF | 0, ROR2(0x0000FFFF, 28)); +assertEquals(0xF0000FFF | 0, ROR2(0x0000FFFF, 28)); +%OptimizeFunctionOnNextCall(ROR2); +assertEquals(0xF0000FFF | 0, ROR2(0x0000FFFF, 28)); + +assertEquals(0x0FFFF000 | 0, ROR2(0x0000FFFF, 12)); +assertEquals(0x0FFFF000 | 0, ROR2(0x0000FFFF, 12)); +%OptimizeFunctionOnNextCall(ROR2); +assertEquals(0x0FFFF000 | 0, ROR2(0x0000FFFF, 12)); + +assertEquals(0x0FFFF000 | 0, ROR2(0x0000FFFF, Twelve())); +assertEquals(0x0FFFF000 | 0, ROR2(0x0000FFFF, Twelve())); +%OptimizeFunctionOnNextCall(ROR2); +assertEquals(0x0FFFF000 | 0, ROR2(0x0000FFFF, Twelve())); + +for (var i = 0; i <= 100; i++) { + assertEquals(0xFFFFFFFF | 0, ROR2(0xFFFFFFFF, i)); + assertEquals(0xFFFFFFFF | 0, ROR2(0xFFFFFFFF, i)); + %OptimizeFunctionOnNextCall(ROR2); + assertEquals(0xFFFFFFFF | 0, ROR2(0xFFFFFFFF, i)); +} + +for (var i = 0; i <= 100; i++) { + assertEquals(-1, ROR2(-1, i)); + assertEquals(-1, ROR2(-1, i)); + %OptimizeFunctionOnNextCall(ROR2); + assertEquals(-1, ROR2(-1, i)); +} + +for (var i = 0; i <= 100; i++) { + assertEquals(1 << ((i % 32)), ROR2(1, i)); + assertEquals(1 << ((i % 32)), ROR2(1, i)); + %OptimizeFunctionOnNextCall(ROR2); + assertEquals(1 << ((i % 32)), ROR2(1, i)); +} + +assertEquals(0xF0000FFF | 0, ROR3(0x0000FFFF, 4)); +assertEquals(0xF0000FFF | 0, ROR3(0x0000FFFF, 4)); +%OptimizeFunctionOnNextCall(ROR3); +assertEquals(0xF0000FFF | 0, ROR3(0x0000FFFF, 4)); + +assertEquals(0x0FFFF000 | 0, ROR3(0x0000FFFF, 20)); +assertEquals(0x0FFFF000 | 0, ROR3(0x0000FFFF, 20)); +%OptimizeFunctionOnNextCall(ROR3); +assertEquals(0x0FFFF000 | 0, ROR3(0x0000FFFF, 20)); + +assertEquals(0x0FFFF000 | 0, ROR3(0x0000FFFF, Twenty())); +assertEquals(0x0FFFF000 | 0, ROR3(0x0000FFFF, Twenty())); +%OptimizeFunctionOnNextCall(ROR3); +assertEquals(0x0FFFF000 | 0, ROR3(0x0000FFFF, Twenty())); + +for (var i = 0; i <= 100; i++) { + assertEquals(0xFFFFFFFF | 0, ROR3(0xFFFFFFFF, i)); + assertEquals(0xFFFFFFFF | 0, ROR3(0xFFFFFFFF, i)); + %OptimizeFunctionOnNextCall(ROR3); + assertEquals(0xFFFFFFFF | 0, ROR3(0xFFFFFFFF, i)); +} + +for (var i = 0; i <= 100; i++) { + assertEquals(-1, ROR3(-1, i)); + assertEquals(-1, ROR3(-1, i)); + %OptimizeFunctionOnNextCall(ROR3); + assertEquals(-1, ROR3(-1, i)); +} + +for (var i = 0; i <= 100; i++) { + assertEquals(1 << (32 - (i % 32)), ROR3(1, i)); + assertEquals(1 << (32 - (i % 32)), ROR3(1, i)); + %OptimizeFunctionOnNextCall(ROR3); + assertEquals(1 << (32 - (i % 32)), ROR3(1, i)); +} + +assertEquals(0xF0000FFF | 0, ROR4(0x0000FFFF, 28)); +assertEquals(0xF0000FFF | 0, ROR4(0x0000FFFF, 28)); +%OptimizeFunctionOnNextCall(ROR4); +assertEquals(0xF0000FFF | 0, ROR4(0x0000FFFF, 28)); + +assertEquals(0x0FFFF000 | 0, ROR4(0x0000FFFF, 12)); +assertEquals(0x0FFFF000 | 0, ROR4(0x0000FFFF, 12)); +%OptimizeFunctionOnNextCall(ROR4); +assertEquals(0x0FFFF000 | 0, ROR4(0x0000FFFF, 12)); + +assertEquals(0x0FFFF000 | 0, ROR4(0x0000FFFF, Twelve())); +assertEquals(0x0FFFF000 | 0, ROR4(0x0000FFFF, Twelve())); +%OptimizeFunctionOnNextCall(ROR4); +assertEquals(0x0FFFF000 | 0, ROR4(0x0000FFFF, Twelve())); + +for (var i = 0; i <= 100; i++) { + assertEquals(0xFFFFFFFF | 0, ROR4(0xFFFFFFFF, i)); + assertEquals(0xFFFFFFFF | 0, ROR4(0xFFFFFFFF, i)); + %OptimizeFunctionOnNextCall(ROR4); + assertEquals(0xFFFFFFFF | 0, ROR4(0xFFFFFFFF, i)); +} + +for (var i = 0; i <= 100; i++) { + assertEquals(-1, ROR4(-1, i)); + assertEquals(-1, ROR4(-1, i)); + %OptimizeFunctionOnNextCall(ROR4); + assertEquals(-1, ROR4(-1, i)); +} + +for (var i = 0; i <= 100; i++) { + assertEquals(1 << ((i % 32)), ROR4(1, i)); + assertEquals(1 << ((i % 32)), ROR4(1, i)); + %OptimizeFunctionOnNextCall(ROR4); + assertEquals(1 << ((i % 32)), ROR4(1, i)); +} + diff --git a/src/3rdparty/v8/test/mjsunit/compiler/uint32.js b/src/3rdparty/v8/test/mjsunit/compiler/uint32.js new file mode 100644 index 0000000..abed285 --- /dev/null +++ b/src/3rdparty/v8/test/mjsunit/compiler/uint32.js @@ -0,0 +1,173 @@ +// Copyright 2012 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. + +// Flags: --allow-natives-syntax --expose-gc + +// Test uint32 handing in optimized frames. + +var K1 = 0x7fffffff; +var K2 = 0xffffffff; + +var uint32_array = new Uint32Array(2); +uint32_array[0] = K1; +uint32_array[1] = K2; + +function ChangeI2T(arr, i) { + return uint32_array[i]; +} + +assertEquals(K1, ChangeI2T(uint32_array, 0)); +assertEquals(K2, ChangeI2T(uint32_array, 1)); +%OptimizeFunctionOnNextCall(ChangeI2T); +assertEquals(K1, ChangeI2T(uint32_array, 0)); +// Loop to force inline allocation failure and a call into runtime. +for (var i = 0; i < 80000; i++) { + assertEquals(K2, ChangeI2T(uint32_array, 1)); +} + +function SideEffect() { + with ({}) { } // not inlinable +} + +function Deopt(obj, arr, i) { + var x = arr[i]; + SideEffect(); // x will be used by HSimulate. + obj.x; + return x; +} + +assertEquals(K1, Deopt({x: 0}, uint32_array, 0)); +assertEquals(K2, Deopt({x: 0}, uint32_array, 1)); +%OptimizeFunctionOnNextCall(Deopt); +assertEquals(K2, Deopt({}, uint32_array, 1)); + +function ChangeI2D(arr) { + // This addition will have a double type feedback so ChangeI2D will + // be generated for its operands. + return arr[0] + arr[1]; +} + +assertEquals(K1 + K2, ChangeI2D(uint32_array)); +assertEquals(K1 + K2, ChangeI2D(uint32_array)); +%OptimizeFunctionOnNextCall(ChangeI2D); +assertEquals(K1 + K2, ChangeI2D(uint32_array)); + +function ShrShr(val) { + return (val >>> 0) >>> 1; +} + +assertEquals(K1, ShrShr(K2 | 0)); +assertEquals(K1, ShrShr(K2 | 0)); +%OptimizeFunctionOnNextCall(ShrShr); +assertEquals(K1, ShrShr(K2 | 0)); + +function SarShr(val) { + return val >> (-2 >>> 0); +} + +var K3 = 0x80000000; +assertEquals(-2, SarShr(K3 | 0)); +assertEquals(-2, SarShr(K3 | 0)); +%OptimizeFunctionOnNextCall(SarShr); +assertEquals(-2, SarShr(K3 | 0)); + +function Uint32Phi(a, b, c) { + var i = a ? (b >>> 0) : (c >>> 0); + return (i | 0); +} + +var K4 = 0x80000001; +assertEquals(K3 | 0, Uint32Phi(true, K3, K4)); +assertEquals(K4 | 0, Uint32Phi(false, K3, K4)); +assertEquals(K3 | 0, Uint32Phi(true, K3, K4)); +assertEquals(K4 | 0, Uint32Phi(false, K3, K4)); +%OptimizeFunctionOnNextCall(Uint32Phi); +assertEquals(K3 | 0, Uint32Phi(true, K3, K4)); +assertEquals(K4 | 0, Uint32Phi(false, K3, K4)); + +function NonUint32Phi(a, b, c) { + var i = a ? (b >>> 0) : c; + return (i | 0); +} + +assertEquals(K3 | 0, NonUint32Phi(true, K3, K4)); +assertEquals(K4 | 0, NonUint32Phi(false, K3, K4)); +assertEquals(K3 | 0, NonUint32Phi(true, K3, K4)); +assertEquals(K4 | 0, NonUint32Phi(false, K3, K4)); +%OptimizeFunctionOnNextCall(NonUint32Phi); +assertEquals(K3 | 0, NonUint32Phi(true, K3, K4)); +assertEquals(K4 | 0, NonUint32Phi(false, K3, K4)); + +function PhiOfPhi(x) { + var a = (x >>> 0); + for (var i = 0; i < 2; i++) { + for (var j = 0; j < 2; j++) { + a = (a >>> 0); + } + } + return (a | 0); +} + +assertEquals(1, PhiOfPhi(1)); +assertEquals(1, PhiOfPhi(1)); +%OptimizeFunctionOnNextCall(PhiOfPhi); +assertEquals(K3 | 0, PhiOfPhi(K3)); + +function PhiOfPhiUnsafe(x) { + var a = x >>> 0; + for (var i = 0; i < 2; i++) { + for (var j = 0; j < 2; j++) { + a = (a >>> 0); + } + } + return a + a; +} + +assertEquals(2, PhiOfPhiUnsafe(1)); +assertEquals(2, PhiOfPhiUnsafe(1)); +%OptimizeFunctionOnNextCall(PhiOfPhiUnsafe); +assertEquals(2 * K3, PhiOfPhiUnsafe(K3)); + +var old_array = new Array(1000); + +for (var i = 0; i < old_array.length; i++) old_array[i] = null; + +// Force promotion. +gc(); +gc(); + +function FillOldArrayWithHeapNumbers(N) { + for (var i = 0; i < N; i++) { + old_array[i] = uint32_array[1]; + } +} + +FillOldArrayWithHeapNumbers(1); +FillOldArrayWithHeapNumbers(1); +%OptimizeFunctionOnNextCall(FillOldArrayWithHeapNumbers); +FillOldArrayWithHeapNumbers(old_array.length); +gc(); |