--- a/js/src/trace-test.js
+++ b/js/src/trace-test.js
@@ -15,19 +15,19 @@ const RUNLOOP = HOTLOOP + 1;
var testName = null;
if ("arguments" in this && arguments.length > 0)
testName = arguments[0];
var fails = [], passes=[];
function jitstatHandler(f)
{
- if (!haveTracemonkey) {
- return;
- }
+ if (!haveTracemonkey)
+ return;
+
// XXXbz this is a nasty hack, but I can't figure out a way to
// just use jitstats.tbl here
f("recorderStarted");
f("recorderAborted");
f("traceCompleted");
f("sideExitIntoInterpreter");
f("typeMapMismatchAtEntry");
f("returnToDifferentLoopHeader");
@@ -130,20 +130,20 @@ function check(desc, actual, expected, o
if (actualStats)
actualStats += " ";
actualStats += prop + ": " + (tracemonkey[prop]-oldJITstats[prop]);
}
});
}
print(desc, ": FAILED: expected", typeof(expected),
"(", uneval(expected), ")",
- (expectedStats ? " [" + expectedStats + "] " : ""),
- "!= actual",
- typeof(actual), "(", uneval(actual), ")",
- (actualStats ? " [" + actualStats + "] " : ""));
+ (expectedStats ? " [" + expectedStats + "] " : ""),
+ "!= actual",
+ typeof(actual), "(", uneval(actual), ")",
+ (actualStats ? " [" + actualStats + "] " : ""));
}
function ifInsideLoop()
{
var cond = true, intCond = 5, count = 0;
for (var i = 0; i < 100; i++) {
if (cond)
count++;
@@ -304,17 +304,17 @@ function ursh_inner(n)
r = -55 >>> n;
return r;
}
map_test (ursh_inner,
[{input: 8, expected: 16777215},
{input: 33, expected: 2147483620},
{input: 0, expected: 4294967241},
{input: 1, expected: 2147483620}]);
-
+
function doMath_inner(cos)
{
var s = 0;
var sin = Math.sin;
for (var i = 0; i < 200; i++)
s = -Math.pow(sin(i) + cos(i * 0.75), 4);
return s;
}
@@ -425,23 +425,23 @@ function setprop()
obj2.b = obj.a = i;
}
return [obj.a, obj2.a, obj2.b].toString();
}
setprop.expected = "19,-1,19";
test(setprop);
function testif() {
- var q = 0;
- for (var i = 0; i < 100; i++) {
- if ((i & 1) == 0)
- q++;
- else
- q--;
- }
+ var q = 0;
+ for (var i = 0; i < 100; i++) {
+ if ((i & 1) == 0)
+ q++;
+ else
+ q--;
+ }
return q;
}
testif.expected = 0;
test(testif);
var globalinc = 0;
function testincops(n) {
var i = 0, o = {p:0}, a = [0];
@@ -479,17 +479,17 @@ function trees() {
}
trees.expected = "50,25,25";
test(trees);
function unboxint() {
var q = 0;
var o = [4];
for (var i = 0; i < 100; ++i)
- q = o[0] << 1;
+ q = o[0] << 1;
return q;
}
unboxint.expected = 8;
test(unboxint);
function strings()
{
var a = [], b = -1;
@@ -584,29 +584,29 @@ if (!testName || testName == "truthies")
var truthies = [{}, true, 1, 42, 1/0, -1/0, "blah"];
var boolies = [falsies, truthies];
// The for each here should abort tracing, so that this test framework
// relies only on the interpreter while the orTestHelper and andTestHelper
// functions get trace-JITed.
for each (var op in opsies) {
for (var i in boolies) {
- for (var j in boolies[i]) {
+ for (var j in boolies[i]) {
var x = uneval(boolies[i][j]);
for (var k in boolies) {
for (var l in boolies[k]) {
var y = uneval(boolies[k][l]);
var prefix = (op == "||") ? "or" : "and";
var f = new Function("return " + prefix + "TestHelper(" + x + "," + y + ",10)");
f.name = prefix + "Test(" + x + "," + y + ")";
f.expected = eval(x + op + y) ? 45 : 0;
test(f);
}
}
- }
+ }
}
}
})();
}
function nonEmptyStack1Helper(o, farble) {
var a = [];
var j = 0;
@@ -817,22 +817,24 @@ function deepForInLoop() {
return a.join("");
}
deepForInLoop.expected = "pqrst";
test(deepForInLoop);
function nestedExit(x) {
var q = 0;
for (var i = 0; i < 10; ++i)
- if (x)
- ++q;
+ {
+ if (x)
+ ++q;
+ }
}
function nestedExitLoop() {
for (var j = 0; j < 10; ++j)
- nestedExit(j < 7);
+ nestedExit(j < 7);
return "ok";
}
nestedExitLoop.expected = "ok";
test(nestedExitLoop);
function bitsinbyte(b) {
var m = 1, c = 0;
while(m<0x100) {
@@ -859,24 +861,24 @@ function parsingNumbers() {
var s2z = "123.456zzz";
var e1 = 123;
var e2 = 123.456;
var r1, r1z, r2, r2z;
for (var i = 0; i < 10; i++) {
- r1 = parseInt(s1);
- r1z = parseInt(s1z);
- r2 = parseFloat(s2);
- r2z = parseFloat(s2z);
+ r1 = parseInt(s1);
+ r1z = parseInt(s1z);
+ r2 = parseFloat(s2);
+ r2z = parseFloat(s2z);
}
if (r1 == e1 && r1z == e1 && r2 == e2 && r2z == e2)
- return "ok";
+ return "ok";
return "fail";
}
parsingNumbers.expected = "ok";
test(parsingNumbers);
function matchInLoop() {
var k = "hi";
for (var i = 0; i < 10; i++) {
@@ -893,43 +895,43 @@ function testMatchAsCondition() {
"x".q;
for (var z = 0; z < 4; z++)
a[z].match(r) ? 1 : 2;
}
test(testMatchAsCondition);
function deep1(x) {
if (x > 90)
- return 1;
+ return 1;
return 2;
}
function deep2() {
for (var i = 0; i < 100; ++i)
- deep1(i);
+ deep1(i);
return "ok";
}
deep2.expected = "ok";
test(deep2);
var merge_type_maps_x = 0, merge_type_maps_y = 0;
function merge_type_maps() {
for (merge_type_maps_x = 0; merge_type_maps_x < 50; ++merge_type_maps_x)
if ((merge_type_maps_x & 1) == 1)
- ++merge_type_maps_y;
+ ++merge_type_maps_y;
return [merge_type_maps_x,merge_type_maps_y].join(",");
}
merge_type_maps.expected = "50,25";
test(merge_type_maps)
function inner_double_outer_int() {
function f(i) {
- for (var m = 0; m < 20; ++m)
- for (var n = 0; n < 100; n += i)
- ;
- return n;
+ for (var m = 0; m < 20; ++m)
+ for (var n = 0; n < 100; n += i)
+ ;
+ return n;
}
return f(.5);
}
inner_double_outer_int.expected = 100;
test(inner_double_outer_int);
function newArrayTest()
{
@@ -1001,34 +1003,38 @@ function inArrayTest() {
return i;
}
inArrayTest.expected = 10;
test(inArrayTest);
function innerLoopIntOuterDouble() {
var n = 10000, i=0, j=0, count=0, limit=0;
for (i = 1; i <= n; ++i) {
- limit = i * 1;
- for (j = 0; j < limit; ++j) {
- ++count;
- }
+ limit = i * 1;
+ for (j = 0; j < limit; ++j) {
+ ++count;
+ }
}
return "" + count;
}
innerLoopIntOuterDouble.expected="50005000";
test(innerLoopIntOuterDouble);
function outerline(){
var i=0;
var j=0;
for (i = 3; i<= 100000; i+=2)
- for (j = 3; j < 1000; j+=2)
- if ((i & 1) == 1)
- break;
+ {
+ for (j = 3; j < 1000; j+=2)
+ {
+ if ((i & 1) == 1)
+ break;
+ }
+ }
return "ok";
}
outerline.expected="ok";
test(outerline);
function addAccumulations(f) {
var a = f();
var b = f();
@@ -1041,18 +1047,18 @@ function loopingAccumulator() {
for (var i = 0; i < 10; ++i) {
++x;
}
return x;
}
}
function testLoopingAccumulator() {
- var x = addAccumulations(loopingAccumulator);
- return x;
+ var x = addAccumulations(loopingAccumulator);
+ return x;
}
testLoopingAccumulator.expected = 20;
test(testLoopingAccumulator);
function testBranchingLoop() {
var x = 0;
for (var i=0; i < 100; ++i) {
if (i == 51) {
@@ -1079,17 +1085,17 @@ testBranchingUnstableLoop.expected = 110
test(testBranchingUnstableLoop);
function testBranchingUnstableLoopCounter() {
var x = 0;
for (var i=0; i < 100; ++i) {
if (i == 51) {
i += 1.1;
}
- x++;
+ x++;
}
return x;
}
testBranchingUnstableLoopCounter.expected = 99;
test(testBranchingUnstableLoopCounter);
function testBranchingUnstableObject() {
@@ -1142,95 +1148,94 @@ function testNumberToString() {
for (var i = 0; i < 4; i++)
x.toString();
}
test(testNumberToString);
function testDecayingInnerLoop() {
var i, j, k = 10;
for (i = 0; i < 5000; ++i) {
- for (j = 0; j < k; ++j);
- --k;
+ for (j = 0; j < k; ++j);
+ --k;
}
return i;
}
testDecayingInnerLoop.expected = 5000;
test(testDecayingInnerLoop);
function testContinue() {
var i;
var total = 0;
for (i = 0; i < 20; ++i) {
- if (i == 11)
- continue;
- total++;
+ if (i == 11)
+ continue;
+ total++;
}
return total;
}
testContinue.expected = 19;
test(testContinue);
function testContinueWithLabel() {
var i = 0;
var j = 20;
checkiandj :
while (i<10) {
- i+=1;
- checkj :
- while (j>10) {
- j-=1;
- if ((j%2)==0)
- continue checkj;
- }
+ i+=1;
+ checkj :
+ while (j>10) {
+ j-=1;
+ if ((j%2)==0)
+ continue checkj;
+ }
}
return i + j;
}
testContinueWithLabel.expected = 20;
test(testContinueWithLabel);
function testDivision() {
var a = 32768;
var b;
while (b !== 1) {
- b = a / 2;
- a = b;
+ b = a / 2;
+ a = b;
}
return a;
}
testDivision.expected = 1;
test(testDivision);
function testDivisionFloat() {
var a = 32768.0;
var b;
while (b !== 1) {
- b = a / 2.0;
- a = b;
+ b = a / 2.0;
+ a = b;
}
return a === 1.0;
}
testDivisionFloat.expected = true;
test(testDivisionFloat);
function testToUpperToLower() {
var s = "Hello", s1, s2;
for (i = 0; i < 100; ++i) {
- s1 = s.toLowerCase();
- s2 = s.toUpperCase();
+ s1 = s.toLowerCase();
+ s2 = s.toUpperCase();
}
return s1 + s2;
}
testToUpperToLower.expected = "helloHELLO";
test(testToUpperToLower);
function testReplace2() {
var s = "H e l l o", s1;
- for (i = 0; i < 100; ++i) {
- s1 = s.replace(" ", "");
- }
+ for (i = 0; i < 100; ++i)
+ s1 = s.replace(" ", "");
return s1;
}
testReplace2.expected = "He l l o";
test(testReplace2);
function testBitwise() {
var x = 10000;
var y = 123456;
@@ -1308,17 +1313,17 @@ function testNegZero1Helper(z) {
}
var testNegZero1 = function() { return testNegZero1Helper(0); }
testNegZero1.expected = true;
testNegZero1.name = 'testNegZero1';
testNegZero1Helper(1);
test(testNegZero1);
-// No test case, just make sure this doesn't assert.
+// No test case, just make sure this doesn't assert.
function testNegZero2() {
var z = 0;
for (let j = 0; j < 5; ++j) { ({p: (-z)}); }
}
testNegZero2();
function testConstSwitch() {
var x;
@@ -1442,31 +1447,31 @@ function testNativeMax() {
return out.join(",");
}
testNativeMax.expected = "NaN,4,false";
test(testNativeMax);
function testFloatArrayIndex() {
var a = [];
for (var i = 0; i < 10; ++i) {
- a[3] = 5;
- a[3.5] = 7;
+ a[3] = 5;
+ a[3.5] = 7;
}
return a[3] + "," + a[3.5];
}
testFloatArrayIndex.expected = "5,7";
test(testFloatArrayIndex);
function testStrict() {
var n = 10, a = [];
for (var i = 0; i < 10; ++i) {
- a[0] = (n === 10);
- a[1] = (n !== 10);
- a[2] = (n === null);
- a[3] = (n == null);
+ a[0] = (n === 10);
+ a[1] = (n !== 10);
+ a[2] = (n === null);
+ a[3] = (n == null);
}
return a.join(",");
}
testStrict.expected = "true,false,false,false";
test(testStrict);
function testSetPropNeitherMissNorHit() {
for (var j = 0; j < 5; ++j) { if (({}).__proto__ = 1) { } }
@@ -1475,64 +1480,64 @@ function testSetPropNeitherMissNorHit()
testSetPropNeitherMissNorHit.expected = "ok";
test(testSetPropNeitherMissNorHit);
function testPrimitiveConstructorPrototype() {
var f = function(){};
f.prototype = false;
for (let j=0;j<5;++j) { new f; }
return "ok";
-}
+}
testPrimitiveConstructorPrototype.expected = "ok";
test(testPrimitiveConstructorPrototype);
function testSideExitInConstructor() {
var FCKConfig = {};
FCKConfig.CoreStyles =
- {
- 'Bold': { },
- 'Italic': { },
- 'FontFace': { },
- 'Size' :
- {
- Overrides: [ ]
- },
-
- 'Color' :
- {
- Element: '',
- Styles: { },
- Overrides: [ ]
- },
- 'BackColor': {
- Element : '',
- Styles : { 'background-color' : '' }
- },
-
- };
+ {
+ 'Bold': { },
+ 'Italic': { },
+ 'FontFace': { },
+ 'Size' :
+ {
+ Overrides: [ ]
+ },
+
+ 'Color' :
+ {
+ Element: '',
+ Styles: { },
+ Overrides: [ ]
+ },
+ 'BackColor': {
+ Element : '',
+ Styles : { 'background-color' : '' }
+ },
+
+ };
var FCKStyle = function(A) {
- A.Element;
+ A.Element;
};
-
+
var pass = true;
for (var s in FCKConfig.CoreStyles) {
- var x = new FCKStyle(FCKConfig.CoreStyles[s]);
- if (!x) pass = false;
+ var x = new FCKStyle(FCKConfig.CoreStyles[s]);
+ if (!x)
+ pass = false;
}
return pass;
}
testSideExitInConstructor.expected = true;
test(testSideExitInConstructor);
function testNot() {
var a = new Object(), b = null, c = "foo", d = "", e = 5, f = 0, g = 5.5, h = -0, i = true, j = false, k = undefined;
var r;
- for (var i = 0; i < 10; ++i) {
- r = [!a, !b, !c, !d, !e, !f, !g, !h, !i, !j, !k];
- }
+ for (var i = 0; i < 10; ++i)
+ r = [!a, !b, !c, !d, !e, !f, !g, !h, !i, !j, !k];
return r.join(",");
}
testNot.expected = "false,true,false,true,false,true,false,true,false,true,true";
test(testNot);
function doTestDifferingArgc(a, b)
{
var k = 0;
@@ -1609,19 +1614,18 @@ function testHOTLOOPSize() {
return HOTLOOP > 1;
}
testHOTLOOPSize.expected = true;
test(testHOTLOOPSize);
function testMatchStringObject() {
var a = new String("foo");
var b;
- for (i = 0; i < 300; i++) {
- b = a.match(/bar/);
- }
+ for (i = 0; i < 300; i++)
+ b = a.match(/bar/);
return b;
}
testMatchStringObject.expected = null;
test(testMatchStringObject);
function innerSwitch(k)
{
var m = 0;
@@ -1643,17 +1647,17 @@ function testInnerSwitchBreak()
r[i] = innerSwitch(0);
}
return r.join(",");
}
testInnerSwitchBreak.expected = "1,1,1,1,1";
test(testInnerSwitchBreak);
-function testArrayNaNIndex()
+function testArrayNaNIndex()
{
for (var j = 0; j < 4; ++j) { [this[NaN]]; }
for (var j = 0; j < 5; ++j) { if([1][-0]) { } }
return "ok";
}
testArrayNaNIndex.expected = "ok";
test(testArrayNaNIndex);
@@ -1690,35 +1694,34 @@ function regexpLastIndex()
}
return n;
}
regexpLastIndex.expected = 0; // 30;
test(regexpLastIndex);
function testHOTLOOPCorrectness() {
var b = 0;
- for (var i = 0; i < HOTLOOP; ++i) {
- ++b;
- }
+ for (var i = 0; i < HOTLOOP; ++i)
+ ++b;
return b;
}
testHOTLOOPCorrectness.expected = HOTLOOP;
testHOTLOOPCorrectness.jitstats = {
recorderStarted: 1,
recorderAborted: 0,
traceTriggered: 0
};
// Change the global shape right before doing the test
this.testHOTLOOPCorrectnessVar = 1;
test(testHOTLOOPCorrectness);
function testRUNLOOPCorrectness() {
var b = 0;
for (var i = 0; i < RUNLOOP; ++i) {
- ++b;
+ ++b;
}
return b;
}
testRUNLOOPCorrectness.expected = RUNLOOP;
testRUNLOOPCorrectness.jitstats = {
recorderStarted: 1,
recorderAborted: 0,
traceTriggered: 1
@@ -1727,59 +1730,58 @@ testRUNLOOPCorrectness.jitstats = {
this.testRUNLOOPCorrectnessVar = 1;
test(testRUNLOOPCorrectness);
function testDateNow() {
// Accessing global.Date for the first time will change the global shape,
// so do it before the loop starts; otherwise we have to loop an extra time
// to pick things up.
var time = Date.now();
- for (var j = 0; j < RUNLOOP; ++j) {
- time = Date.now();
- }
+ for (var j = 0; j < RUNLOOP; ++j)
+ time = Date.now();
return "ok";
}
testDateNow.expected = "ok";
testDateNow.jitstats = {
recorderStarted: 1,
recorderAborted: 0,
traceTriggered: 1
};
test(testDateNow);
-function testINITELEM()
+function testINITELEM()
{
var x;
for (var i = 0; i < 10; ++i)
- x = { 0: 5, 1: 5 };
+ x = { 0: 5, 1: 5 };
return x[0] + x[1];
}
testINITELEM.expected = 10;
test(testINITELEM);
-function testUndefinedBooleanCmp()
+function testUndefinedBooleanCmp()
{
var t = true, f = false, x = [];
for (var i = 0; i < 10; ++i) {
- x[0] = t == undefined;
- x[1] = t != undefined;
- x[2] = t === undefined;
- x[3] = t !== undefined;
- x[4] = t < undefined;
- x[5] = t > undefined;
- x[6] = t <= undefined;
- x[7] = t >= undefined;
- x[8] = f == undefined;
- x[9] = f != undefined;
- x[10] = f === undefined;
- x[11] = f !== undefined;
- x[12] = f < undefined;
- x[13] = f > undefined;
- x[14] = f <= undefined;
- x[15] = f >= undefined;
+ x[0] = t == undefined;
+ x[1] = t != undefined;
+ x[2] = t === undefined;
+ x[3] = t !== undefined;
+ x[4] = t < undefined;
+ x[5] = t > undefined;
+ x[6] = t <= undefined;
+ x[7] = t >= undefined;
+ x[8] = f == undefined;
+ x[9] = f != undefined;
+ x[10] = f === undefined;
+ x[11] = f !== undefined;
+ x[12] = f < undefined;
+ x[13] = f > undefined;
+ x[14] = f <= undefined;
+ x[15] = f >= undefined;
}
return x.join(",");
}
testUndefinedBooleanCmp.expected = "false,true,false,true,false,false,false,false,false,true,false,true,false,false,false,false";
test(testUndefinedBooleanCmp);
function testConstantBooleanExpr()
{
@@ -1796,17 +1798,17 @@ function testNegativeGETELEMIndex()
}
testNegativeGETELEMIndex.expected = "ok";
test(testNegativeGETELEMIndex);
function doTestInvalidCharCodeAt(input)
{
var q = "";
for (var i = 0; i < 10; i++)
- q += input.charCodeAt(i);
+ q += input.charCodeAt(i);
return q;
}
function testInvalidCharCodeAt()
{
return doTestInvalidCharCodeAt("");
}
testInvalidCharCodeAt.expected = "NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN";
test(testInvalidCharCodeAt);
@@ -1843,17 +1845,17 @@ function testLoopWithUndefined1() {
};
testLoopWithUndefined1.expected = "false,false,false,false,false,false";
test(testLoopWithUndefined1);
function loopWithUndefined2(t, dostuff, val) {
var a = new Array(6);
for (var i = 0; i < 6; i++) {
if (dostuff) {
- val = 1;
+ val = 1;
a[i] = (t > val);
} else {
a[i] = (val == undefined);
}
}
return a;
}
function testLoopWithUndefined2() {
@@ -1914,22 +1916,22 @@ function testClosingRecursion() {
shortRecursiveLoop(true, 3);
return true;
}
testClosingRecursion.expected = true;
test(testClosingRecursion);
// Test no assert or crash from outer recorders (bug 465145)
function testBug465145() {
- this.__defineSetter__("x", function(){});
- this.watch("x", function(){});
- y = this;
- for (var z = 0; z < 2; ++z) { x = y };
- this.__defineSetter__("x", function(){});
- for (var z = 0; z < 2; ++z) { x = y };
+ this.__defineSetter__("x", function(){});
+ this.watch("x", function(){});
+ y = this;
+ for (var z = 0; z < 2; ++z) { x = y };
+ this.__defineSetter__("x", function(){});
+ for (var z = 0; z < 2; ++z) { x = y };
}
function testTrueShiftTrue() {
var a = new Array(5);
for (var i=0;i<5;++i) a[i] = "" + (true << true);
return a.join(",");
}
testTrueShiftTrue.expected = "2,2,2,2,2";
@@ -1948,20 +1950,20 @@ function testBug465272() {
var a = new Array(5);
for (j=0;j<5;++j) a[j] = "" + ((5) - 2);
return a.join(",");
}
testBug465272.expected = "3,3,3,3,3"
test(testBug465272);
function testBug465483() {
- var a = new Array(4);
- var c = 0;
- for each (i in [4, 'a', 'b', (void 0)]) a[c++] = '' + (i + i);
- return a.join(',');
+ var a = new Array(4);
+ var c = 0;
+ for each (i in [4, 'a', 'b', (void 0)]) a[c++] = '' + (i + i);
+ return a.join(',');
}
testBug465483.expected = '8,aa,bb,NaN';
test(testBug465483);
function testNullCallee() {
try {
function f() {
var x = new Array(5);
@@ -1976,17 +1978,17 @@ function testNullCallee() {
}
return false;
}
testNullCallee.expected = true;
test(testNullCallee);
//test no multitrees assert
function testBug466128() {
- for (let a = 0; a < 3; ++a) {
+ for (let a = 0; a < 3; ++a) {
for each (let b in [1, 2, "three", 4, 5, 6, 7, 8]) {
}
}
return true;
}
testBug466128.expected = true;
test(testBug466128);
@@ -1995,53 +1997,52 @@ function testBug465688() {
for each (let d in [-0x80000000, -0x80000000]) - -d;
return true;
}
testBug465688.expected = true;
test(testBug465688);
//test no assert
function testBug466262() {
- var e = 1;
- for (var d = 0; d < 3; ++d) {
- if (d == 2) {
- e = "";
- }
- }
- return true;
+ var e = 1;
+ for (var d = 0; d < 3; ++d) {
+ if (d == 2) {
+ e = "";
+ }
+ }
+ return true;
}
testBug466262.expected = true;
test(testBug466262);
function testNewDate()
{
// Accessing global.Date for the first time will change the global shape,
// so do it before the loop starts; otherwise we have to loop an extra time
// to pick things up.
var start = new Date();
var time = new Date();
- for (var j = 0; j < RUNLOOP; ++j) {
- time = new Date();
- }
+ for (var j = 0; j < RUNLOOP; ++j)
+ time = new Date();
return time > 0 && time >= start;
}
testNewDate.expected = true;
testNewDate.jitstats = {
recorderStarted: 1,
recorderAborted: 0,
traceTriggered: 1
};
test(testNewDate);
function testArrayPushPop() {
var a = [], sum1 = 0, sum2 = 0;
for (var i = 0; i < 10; ++i)
- sum1 += a.push(i);
+ sum1 += a.push(i);
for (var i = 0; i < 10; ++i)
- sum2 += a.pop();
+ sum2 += a.pop();
a.push(sum1);
a.push(sum2);
return a.join(",");
}
testArrayPushPop.expected = "55,45";
test(testArrayPushPop);
function testResumeOp() {
@@ -2101,36 +2102,36 @@ function testReallyDeepNestedExit()
}
testReallyDeepNestedExit.expected = 198;
test(testReallyDeepNestedExit);
function testRegExpTest() {
var r = /abc/;
var flag = false;
for (var i = 0; i < 10; ++i)
- flag = r.test("abc");
+ flag = r.test("abc");
return flag;
}
testRegExpTest.expected = true;
test(testRegExpTest);
function testNumToString() {
var r = [];
var d = 123456789;
for (var i = 0; i < 10; ++i) {
- r = [
- d.toString(),
- (-d).toString(),
- d.toString(10),
- (-d).toString(10),
- d.toString(16),
- (-d).toString(16),
- d.toString(36),
- (-d).toString(36)
- ];
+ r = [
+ d.toString(),
+ (-d).toString(),
+ d.toString(10),
+ (-d).toString(10),
+ d.toString(16),
+ (-d).toString(16),
+ d.toString(36),
+ (-d).toString(36)
+ ];
}
return r.join(",");
}
testNumToString.expected = "123456789,-123456789,123456789,-123456789,75bcd15,-75bcd15,21i3v9,-21i3v9";
test(testNumToString);
function testSubstring() {
for (var i = 0; i < 5; ++i) {
@@ -2152,17 +2153,17 @@ function testForInLoopChangeIteratorType
return "ok";
}
testForInLoopChangeIteratorType.expected = "ok";
test(testForInLoopChangeIteratorType);
function testGrowDenseArray() {
var a = new Array();
for (var i = 0; i < 10; ++i)
- a[i] |= 5;
+ a[i] |= 5;
return a.join(",");
}
testGrowDenseArray.expected = "5,5,5,5,5,5,5,5,5,5";
test(testGrowDenseArray);
function testCallProtoMethod() {
function X() { this.x = 1; }
X.prototype.getName = function () { return "X"; }
@@ -2196,28 +2197,28 @@ function testAddUndefined() {
(0 + void 0) && 0;
}
test(testAddUndefined);
function testStringify() {
var t = true, f = false, u = undefined, n = 5, d = 5.5, s = "x";
var a = [];
for (var i = 0; i < 10; ++i) {
- a[0] = "" + t;
- a[1] = t + "";
- a[2] = "" + f;
- a[3] = f + "";
- a[4] = "" + u;
- a[5] = u + "";
- a[6] = "" + n;
- a[7] = n + "";
- a[8] = "" + d;
- a[9] = d + "";
- a[10] = "" + s;
- a[11] = s + "";
+ a[0] = "" + t;
+ a[1] = t + "";
+ a[2] = "" + f;
+ a[3] = f + "";
+ a[4] = "" + u;
+ a[5] = u + "";
+ a[6] = "" + n;
+ a[7] = n + "";
+ a[8] = "" + d;
+ a[9] = d + "";
+ a[10] = "" + s;
+ a[11] = s + "";
}
return a.join(",");
}
testStringify.expected = "true,true,false,false,undefined,undefined,5,5,5.5,5.5,x,x";
test(testStringify);
function testObjectToString() {
var o = {toString: function()"foo"};
@@ -2329,21 +2330,21 @@ function testIn() {
var obj = { "-1": 5, "1.7": 3, "foo": 5, "1": 7 };
var a = [];
for (let j = 0; j < 5; ++j) {
a.push("0" in array);
a.push(-1 in obj);
a.push(1.7 in obj);
a.push("foo" in obj);
a.push(1 in obj);
- a.push("1" in array);
+ a.push("1" in array);
a.push(-2 in obj);
a.push(2.7 in obj);
a.push("bar" in obj);
- a.push(2 in obj);
+ a.push(2 in obj);
}
return a.join(",");
}
testIn.expected = "true,true,true,true,true,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false,true,true,true,true,true,false,false,false,false,false";
test(testIn);
function testBranchCse() {
empty = [];
@@ -2384,31 +2385,30 @@ testThinLoopDemote.jitstats = {
};
test(testThinLoopDemote);
var global = this;
function testWeirdDateParseOuter()
{
var vDateParts = ["11", "17", "2008"];
var out = [];
- for (var vI = 0; vI < vDateParts.length; vI++) {
- out.push(testWeirdDateParseInner(vDateParts[vI]));
- }
+ for (var vI = 0; vI < vDateParts.length; vI++)
+ out.push(testWeirdDateParseInner(vDateParts[vI]));
/* Mutate the global shape so we fall off trace; this causes
* additional oddity */
global.x = Math.random();
return out;
-}
+}
function testWeirdDateParseInner(pVal)
{
var vR = 0;
for (var vI = 0; vI < pVal.length; vI++) {
- var vC = pVal.charAt(vI);
- if ((vC >= '0') && (vC <= '9'))
- vR = (vR * 10) + parseInt(vC);
+ var vC = pVal.charAt(vI);
+ if ((vC >= '0') && (vC <= '9'))
+ vR = (vR * 10) + parseInt(vC);
}
return vR;
}
function testWeirdDateParse() {
var result = [];
result.push(testWeirdDateParseInner("11"));
result.push(testWeirdDateParseInner("17"));
result.push(testWeirdDateParseInner("2008"));
@@ -2454,26 +2454,26 @@ function testEqFalseEmptyString() {
for (var i=0;i<5;++i) x.push(false == "");
return x.join(",");
}
testEqFalseEmptyString.expected = "true,true,true,true,true";
test(testEqFalseEmptyString);
function testIncDec2(ii) {
var x = [];
- for (let j=0;j<5;++j) {
- ii=j;
- jj=j;
- var kk=j;
- x.push(ii--);
- x.push(jj--);
- x.push(kk--);
- x.push(++ii);
- x.push(++jj);
- x.push(++kk);
+ for (let j=0;j<5;++j) {
+ ii=j;
+ jj=j;
+ var kk=j;
+ x.push(ii--);
+ x.push(jj--);
+ x.push(kk--);
+ x.push(++ii);
+ x.push(++jj);
+ x.push(++kk);
}
return x.join(",");
}
function testIncDec() {
return testIncDec2(0);
}
testIncDec.expected = "0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4";
test(testIncDec);
@@ -3410,17 +3410,17 @@ function testComparisons()
"{}": notEqualLessThan,
"{ valueOf: undefined }": notEqualLessThan,
"[]": notEqualGreaterThan,
'[""]': notEqualGreaterThan,
'["a"]': notEqualLessThan,
"[0]": notEqualNorDifferent
}
};
-
+
var failures = [];
function fail(a, ta, b, tb, ex, ac, op)
{
failures.push("(" + a + " " + op + " " + b + ") wrong: " +
"expected " + ex + ", got " + ac +
" (types " + types[ta] + ", " + types[tb] + ")");
@@ -3493,16 +3493,120 @@ function testCaseAbort()
return "" + r;
}
testCaseAbort.expected = "10";
testCaseAbort.jitstats = {
recorderAborted: 0
};
test(testCaseAbort);
+function testApplyCallHelper(f) {
+ var r = [];
+ for (var i = 0; i < 10; ++i) f.call();
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.call(this);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.apply(this);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.call(this,0);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.apply(this,[0]);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.call(this,0,1);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.apply(this,[0,1]);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.call(this,0,1,2);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.apply(this,[0,1,2]);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.call(this,0,1,2,3);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.apply(this,[0,1,2,3]);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.call(this,0,1,2,3,4);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.apply(this,[0,1,2,3,4]);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.call(this,0,1,2,3,4,5);
+ r.push(x);
+ for (var i = 0; i < 10; ++i) f.apply(this,[0,1,2,3,4,5])
+ r.push(x);
+ return(r.join(","));
+}
+function testApplyCall() {
+ var r = testApplyCallHelper(function (a0,a1,a2,a3,a4,a5,a6,a7) { x = [a0,a1,a2,a3,a4,a5,a6,a7]; });
+ r += testApplyCallHelper(function (a0,a1,a2,a3,a4,a5,a6,a7) { x = [a0,a1,a2,a3,a4,a5,a6,a7]; });
+ return r;
+}
+testApplyCall.expected =
+",,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,0,1,,,,,,,0,1,,,,,,,0,1,2,,,,,,0,1,2,,,,,,0,1,2,3,,,,,0,1,2,3,,,,,0,1,2,3,4,,,,0,1,2,3,4,,,,0,1,2,3,4,5,,,0,1,2,3,4,5,," +
+",,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,0,1,,,,,,,0,1,,,,,,,0,1,2,,,,,,0,1,2,,,,,,0,1,2,3,,,,,0,1,2,3,,,,,0,1,2,3,4,,,,0,1,2,3,4,,,,0,1,2,3,4,5,,,0,1,2,3,4,5,,";
+test(testApplyCall);
+
+function testApplyUnboxHelper(f,a) {
+ var q;
+ for (var i = 0; i < 10; ++i)
+ q = f.apply(f,a);
+ return q;
+}
+function testApplyUnbox() {
+ var f = function(x) { return x; }
+ return [testApplyUnboxHelper(f,[1]), testApplyUnboxHelper(f,[true])].join(",");
+}
+testApplyUnbox.expected = "1,true";
+test(testApplyUnbox);
+
+function testCallPick() {
+ function g(x,a) {
+ x.f();
+ }
+
+ var x = [];
+ x.f = function() { }
+
+ var y = [];
+ y.f = function() { }
+
+ var z = [x,x,x,x,x,y,y,y,y,y];
+
+ for (var i = 0; i < 10; ++i)
+ g.call(this, z[i], "");
+ return true;
+}
+testCallPick.expected = true;
+test(testCallPick);
+
+/*****************************************************************************
+ * *
+ * _____ _ _ _____ ______ _____ _______ *
+ * |_ _| \ | |/ ____| ____| __ \__ __| *
+ * | | | \| | (___ | |__ | |__) | | | *
+ * | | | . ` |\___ \| __| | _ / | | *
+ * _| |_| |\ |____) | |____| | \ \ | | *
+ * |_____|_| \_|_____/|______|_| \_\ |_| *
+ * *
+ * *
+ * _______ ______ _____ _______ _____ *
+ * |__ __| ____|/ ____|__ __/ ____| *
+ * | | | |__ | (___ | | | (___ *
+ * | | | __| \___ \ | | \___ \ *
+ * | | | |____ ____) | | | ____) | *
+ * |_| |______|_____/ |_| |_____/ *
+ * *
+ * *
+ * ____ ______ ______ ____ _____ ______ _ _ ______ _____ ______ *
+ * | _ \| ____| ____/ __ \| __ \| ____| | | | | ____| __ \| ____| *
+ * | |_) | |__ | |__ | | | | |__) | |__ | |__| | |__ | |__) | |__ *
+ * | _ <| __| | __|| | | | _ /| __| | __ | __| | _ /| __| *
+ * | |_) | |____| | | |__| | | \ \| |____ | | | | |____| | \ \| |____ *
+ * |____/|______|_| \____/|_| \_\______| |_| |_|______|_| \_\______| *
+ * *
+ *****************************************************************************/
+
load("trace-test-math.js");
// BEGIN MANDELBROT STUFF
// XXXbz I would dearly like to wrap it up into a function to avoid polluting
// the global scope, but the function ends up heavyweight, and then we lose on
// the jit.
load("mandelbrot-results.js");
//function testMandelbrotAll() {
@@ -3513,18 +3617,18 @@ load("mandelbrot-results.js");
// Control of iteration numbers and sizing. We'll do
// scaler * colorNames.length iterations or so before deciding that we
// don't escape.
const scaler = 5;
const numRows = 600;
const numCols = 600;
// For now, avoid hitting memory pressure
- gcparam("maxBytes", 1300000000);
- gcparam("maxMallocBytes", 1300000000);
+ gcparam("maxBytes", 1300000000);
+ gcparam("maxMallocBytes", 1300000000);
const colorNames = [
"black",
"green",
"blue",
"red",
"purple",
"orange",
@@ -3734,102 +3838,49 @@ load("mandelbrot-results.js");
// Test all possible storage strategies. Note that we already tested
// doImageData == true with avoidSparseArray == true.
escape = escapeAbsDiff;
colorMap = fuzzyColors; // This part doesn't really matter too much here
computeEscapeSpeed = computeEscapeSpeedDoubles;
doImageData = true;
- avoidSparseArray = false;
+ avoidSparseArray = false;
test(createMandelSet);
escape = escapeNorm2;
doImageData = false; // avoidSparseArray doesn't matter here
test(createMandelSet);
//}
//testMandelbrotAll();
// END MANDELBROT STUFF
-function testApplyCallHelper(f) {
- var r = [];
- for (var i = 0; i < 10; ++i) f.call();
- r.push(x);
- for (var i = 0; i < 10; ++i) f.call(this);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.apply(this);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.call(this,0);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.apply(this,[0]);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.call(this,0,1);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.apply(this,[0,1]);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.call(this,0,1,2);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.apply(this,[0,1,2]);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.call(this,0,1,2,3);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.apply(this,[0,1,2,3]);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.call(this,0,1,2,3,4);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.apply(this,[0,1,2,3,4]);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.call(this,0,1,2,3,4,5);
- r.push(x);
- for (var i = 0; i < 10; ++i) f.apply(this,[0,1,2,3,4,5])
- r.push(x);
- return(r.join(","));
-}
-function testApplyCall() {
- var r = testApplyCallHelper(function (a0,a1,a2,a3,a4,a5,a6,a7) { x = [a0,a1,a2,a3,a4,a5,a6,a7]; });
- r += testApplyCallHelper(function (a0,a1,a2,a3,a4,a5,a6,a7) { x = [a0,a1,a2,a3,a4,a5,a6,a7]; });
- return r;
-}
-testApplyCall.expected =
-",,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,0,1,,,,,,,0,1,,,,,,,0,1,2,,,,,,0,1,2,,,,,,0,1,2,3,,,,,0,1,2,3,,,,,0,1,2,3,4,,,,0,1,2,3,4,,,,0,1,2,3,4,5,,,0,1,2,3,4,5,," +
-",,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,0,1,,,,,,,0,1,,,,,,,0,1,2,,,,,,0,1,2,,,,,,0,1,2,3,,,,,0,1,2,3,,,,,0,1,2,3,4,,,,0,1,2,3,4,,,,0,1,2,3,4,5,,,0,1,2,3,4,5,,";
-test(testApplyCall);
-
-function testApplyUnboxHelper(f,a) {
- var q;
- for (var i = 0; i < 10; ++i)
- q = f.apply(f,a);
- return q;
-}
-function testApplyUnbox() {
- var f = function(x) { return x; }
- return [testApplyUnboxHelper(f,[1]), testApplyUnboxHelper(f,[true])].join(",");
-}
-testApplyUnbox.expected = "1,true";
-test(testApplyUnbox);
-
-function testCallPick() {
- function g(x,a) {
- x.f();
- }
-
- var x = [];
- x.f = function() { }
-
- var y = [];
- y.f = function() { }
-
- var z = [x,x,x,x,x,y,y,y,y,y];
-
- for (var i = 0; i < 10; ++i)
- g.call(this, z[i], "");
- return true;
-}
-testCallPick.expected = true;
-test(testCallPick);
+/*****************************************************************************
+ * _ _ ____ _ __ ____ _____ ______ *
+ * | \ | |/ __ \ | \/ |/ __ \| __ \| ____| *
+ * | \| | | | | | \ / | | | | |__) | |__ *
+ * | . ` | | | | | |\/| | | | | _ /| __| *
+ * | |\ | |__| | | | | | |__| | | \ \| |____ *
+ * |_| \_|\____/ |_| |_|\____/|_| \_\______| *
+ * *
+ * _______ ______ _____ _______ _____ *
+ * |__ __| ____|/ ____|__ __/ ____| *
+ * | | | |__ | (___ | | | (___ *
+ * | | | __| \___ \ | | \___ \ *
+ * | | | |____ ____) | | | ____) | *
+ * |_| |______|_____/ |_| |_____/ *
+ * *
+ * ______ _______ ______ _____ _ _ ______ _____ ______ _ *
+ * /\ | ____|__ __| ____| __ \ | | | | ____| __ \| ____| | *
+ * / \ | |__ | | | |__ | |__) | | |__| | |__ | |__) | |__ | | *
+ * / /\ \ | __| | | | __| | _ / | __ | __| | _ /| __| | | *
+ * / ____ \| | | | | |____| | \ \ | | | | |____| | \ \| |____|_| *
+ * /_/ \_\_| |_| |______|_| \_\ |_| |_|______|_| \_\______(_) *
+ * *
+ *****************************************************************************/
/* NOTE: Keep this test last, since it screws up all for...in loops after it. */
function testGlobalProtoAccess() {
return "ok";
}
this.__proto__.a = 3; for (var j = 0; j < 4; ++j) { [a]; }
testGlobalProtoAccess.expected = "ok";
test(testGlobalProtoAccess);