forked from rnewman/services-central-old
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
106 changed files
with
4,223 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
JS Trace Test Suite | ||
|
||
* PURPOSE | ||
|
||
This is a test suite for testing TraceMonkey. All tests are run in the JS shell | ||
with tracing enabled (-j). | ||
|
||
* REQUIREMENTS | ||
|
||
Python 2.5. This is already a standard requirement for building our tree. | ||
|
||
* RUNNING THE TESTS | ||
|
||
Basic usage: | ||
|
||
python jit_test.py <path-to-js-shell> | ||
|
||
The progress bar shows [#tests passed, #tests failed, #tests run] at the left. | ||
If all tests pass, the output is 'PASSED ALL'. The test suite can be interrupted | ||
at any time with Ctrl+C and partial results will be printed. | ||
|
||
To run only the basic tests, not including the slow tests: | ||
|
||
python jit_test.py <path-to-js-shell> basic | ||
|
||
For more options: | ||
|
||
python jit_test.py -h | ||
|
||
* CREATING NEW TESTS | ||
|
||
Simply create a JS file under the 'tests/' directory. Most tests should go in | ||
'tests/basic/'. | ||
|
||
All tests are run with 'lib/prolog.js' included first on the command line. The | ||
command line also creates a global variable 'libdir' that is set to the path | ||
of the 'lib' directory. To include a file 'foo.js' from the lib directory in a | ||
test case: | ||
|
||
load(libdir + 'foo.js') | ||
|
||
* TEST METALINES | ||
|
||
The first line of a test case can contain a special comment controlling how the | ||
test is run. For example: | ||
|
||
// |jit-test| allow-oom; | ||
|
||
The general format in EBNF is: | ||
|
||
metaline ::= cookie { item ";" } | ||
cookie ::= "|jit-test|" | ||
item ::= flag | attribute | ||
|
||
flag ::= "slow" | "allow-oom" | ||
|
||
attribute ::= name ":" value | ||
name ::= "TMFLAGS" | "error" | ||
value ::= <string> | ||
|
||
The metaline may appear anywhere in the first line of the file: this allows it | ||
to be placed inside any kind of comment. | ||
|
||
The meaning of the items: | ||
|
||
slow Test runs slowly. Do not run if the --no-slow option is given. | ||
allow-oom If the test runs out of memory, it counts as passing. | ||
valgrind Run test under valgrind. | ||
|
||
error The test should be considered to pass iff it throws the | ||
given JS exception. | ||
TMFLAGS Set the environment variable TMFLAGS to the given value. | ||
|
||
* END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
|
||
const HAVE_TM = 'tracemonkey' in this; | ||
|
||
const HOTLOOP = HAVE_TM ? tracemonkey.HOTLOOP : 8; | ||
const RECORDLOOP = HOTLOOP; | ||
const RUNLOOP = HOTLOOP + 1; | ||
|
||
var checkStats; | ||
if (HAVE_TM) { | ||
checkStats = function(stats) | ||
{ | ||
// Temporarily disabled while we work on heuristics. | ||
return; | ||
function jit(on) | ||
{ | ||
if (on && !options().match(/tracejit/)) | ||
{ | ||
options('tracejit'); | ||
} | ||
else if (!on && options().match(/tracejit/)) | ||
{ | ||
options('tracejit'); | ||
} | ||
} | ||
|
||
jit(false); | ||
for (var name in stats) { | ||
var expected = stats[name]; | ||
var actual = tracemonkey[name]; | ||
if (expected != actual) { | ||
print('Trace stats check failed: got ' + actual + ', expected ' + expected + ' for ' + name); | ||
} | ||
} | ||
jit(true); | ||
}; | ||
} else { | ||
checkStats = function() {}; | ||
} | ||
|
||
var appendToActual = function(s) { | ||
actual += s + ','; | ||
} | ||
|
||
if (!("gczeal" in this)) { | ||
gczeal = function() { } | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
actual = ''; | ||
expected = '6,'; | ||
|
||
// tracing length | ||
|
||
var g = 0; | ||
|
||
function h(args) { | ||
g = args.length; | ||
} | ||
|
||
function f() { | ||
h(arguments); | ||
} | ||
|
||
for (var i = 0; i < 5; ++i) { | ||
f(10, 20, 30, 40, 50, 60); | ||
} | ||
appendToActual(g); | ||
|
||
|
||
assertEq(actual, expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
actual = ''; | ||
expected = '[object Arguments],[object Arguments],[object Arguments],[object Arguments],[object Arguments],'; | ||
|
||
function h() { | ||
return arguments; | ||
} | ||
|
||
for (var i = 0; i < 5; ++i) { | ||
var p = h(i, i*2); | ||
appendToActual(p); | ||
} | ||
|
||
|
||
assertEq(actual, expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
actual = ''; | ||
expected = '[object Arguments] undefined undefined,[object Arguments] undefined undefined,'; | ||
|
||
function f() { | ||
g(arguments); | ||
} | ||
|
||
function g(a, b, c) { | ||
h(arguments); | ||
a = 1; | ||
b = 2; | ||
c = 3; | ||
h(arguments); | ||
} | ||
|
||
function h(a, b, c) { | ||
appendToActual(a + ' ' + b + ' ' + c); | ||
} | ||
|
||
f(4, 5, 6); | ||
|
||
|
||
assertEq(actual, expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// |jit-test| TMFLAGS: full,fragprofile,treevis | ||
|
||
function arith() | ||
{ | ||
var accum = 0; | ||
for (var i = 0; i < 100; i++) { | ||
accum += (i * 2) - 1; | ||
} | ||
return accum; | ||
} | ||
assertEq(arith(), 9800); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var Q = 0; | ||
try { | ||
(function f(i) { Q = i; if (i == 100000) return; f(i+1); })(1) | ||
} catch (e) { | ||
} | ||
|
||
if (Q == 100000) | ||
assertEq(Q, "fail"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var Q = 0; | ||
try { | ||
(function f(i) { Q = i; if (i == 100000) return; f(i+1); })(1) | ||
} catch (e) { | ||
} | ||
|
||
// Exact behavior of recursion check depends on which JIT we use. | ||
var ok = (Q == 3000 || Q == 3001); | ||
assertEq(ok, true); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Don't crash | ||
|
||
function g(foo) { | ||
for (a in foo) { | ||
} | ||
} | ||
|
||
var makegen = eval("\n\ | ||
(function(b) {\n\ | ||
var h = \n\ | ||
eval(\"new function() { yield print(b) }\" ); \n\ | ||
return h\n\ | ||
})\n\ | ||
"); | ||
|
||
g(makegen()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__defineGetter__('x', Float32Array); | ||
with(this) | ||
x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/licenses/publicdomain/ | ||
// Contributor: Luke Wagner <lw@mozilla.com> | ||
|
||
var x, f; | ||
for (var i = 0; i < 100; i++) { | ||
f = function() {}; | ||
f.foo; | ||
x = f.length; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var a = ['p', 'q', 'r', 's', 't']; | ||
var o = {p:1, q:2, r:3, s:4, t:5}; | ||
for (var i in o) { | ||
delete o.p; | ||
delete o.q; | ||
delete o.r; | ||
delete o.s; | ||
delete o.t; | ||
} | ||
for each (var i in a) | ||
assertEq(o.hasOwnProperty(i), false); | ||
|
||
checkStats({ | ||
recorderAborted:0, | ||
traceCompleted:1, | ||
sideExitIntoInterpreter:1 | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Make sure the arch flags are valid on startup, even if nothing has | ||
// been traced yet. We don't know what arch the user is building on, | ||
// but presumably we want at least 1 flag to be set on all supported | ||
// platforms. | ||
|
||
if (HAVE_TM) { | ||
assertEq(jitstats.archIsIA32 || | ||
jitstats.archIs64BIT || | ||
jitstats.archIsARM || | ||
jitstats.archIsSPARC || | ||
jitstats.archIsPPC || | ||
jitstats.archIsAMD64, | ||
1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
function parseIntHelper(n) { | ||
var a; | ||
for (var i = 0; i < 5; i++) | ||
a = parseInt(n); | ||
return a; | ||
} | ||
function doParseIntTests() { | ||
var inputs = [0, -0, .1, -.1, .7, -.7, 1.3, -1.3]; | ||
var outputs = new Array(8); | ||
//avoid jit, unrolled | ||
outputs[0] = outputs[1] = outputs[2] = outputs[4] = 0; | ||
outputs[3] = outputs[5] = -0; | ||
outputs[6] = 1; | ||
outputs[7] = -1; | ||
for (var i = 0; i < 8; i++) { | ||
var testfn = new Function('return parseIntHelper(' + uneval(inputs[i]) + ');'); | ||
assertEq(testfn(), outputs[i]); | ||
} | ||
} | ||
doParseIntTests(); | ||
|
||
assertEq(parseInt("08"), 0); | ||
assertEq(parseInt("09"), 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
|
||
assertEq(parseInt("08"), 0); | ||
assertEq(parseInt("09"), 0); | ||
assertEq(parseInt("014"), 12); | ||
assertEq(parseInt("0xA"), 10); | ||
assertEq(parseInt("00123"), 83); | ||
|
||
for (var i = 0; i < 5; i++) | ||
{ | ||
assertEq(parseInt("08"), 0); | ||
assertEq(parseInt("09"), 0); | ||
assertEq(parseInt("014"), 12); | ||
assertEq(parseInt("0xA"), 10); | ||
assertEq(parseInt("00123"), 83); | ||
} |
10 changes: 10 additions & 0 deletions
10
js/src/jit-test/tests/basic/testAssignmentThatIgnoresSetterRetval.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var o = { | ||
set x(v) { | ||
return 42; | ||
} | ||
}; | ||
|
||
for (var i = 0; i < 10; ++i) { | ||
var z = o.x = "choose me"; | ||
assertEq(z, "choose me"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var escape; | ||
function testBug458838() { | ||
var a = 1; | ||
function g() { | ||
var b = 0 | ||
for (var i = 0; i < 10; ++i) { | ||
b += a; | ||
} | ||
return b; | ||
} | ||
|
||
return g(); | ||
} | ||
assertEq(testBug458838(), 10); | ||
checkStats({ | ||
recorderStarted: 1, | ||
recorderAborted: 0, | ||
traceCompleted: 1 | ||
}); |
Oops, something went wrong.