Skip to content

Commit

Permalink
Backed out changeset bcad241e5c22
Browse files Browse the repository at this point in the history
  • Loading branch information
iangilman committed Nov 2, 2010
1 parent d457292 commit 5fca901
Show file tree
Hide file tree
Showing 106 changed files with 4,223 additions and 21 deletions.
27 changes: 6 additions & 21 deletions browser/base/content/test/tabview/browser_tabview_launch.js
Expand Up @@ -55,28 +55,13 @@ function test() {
function onTabViewLoadedAndShown() {
window.removeEventListener("tabviewshown", onTabViewLoadedAndShown, false);

// Evidently sometimes isVisible (which is based on the selectedIndex of the
// tabview deck) isn't updated immediately when called from button.doCommand,
// so we add a little timeout here to get outside of the doCommand call.
// If the initial timeout isn't enough, we keep waiting in case it's taking
// longer than expected.
// See bug 594909.
let deck = document.getElementById("tab-view-deck");
function waitForSwitch() {
if (deck.selectedIndex == 1) {
ok(TabView.isVisible(), "Tab View is visible. Count: " + tabViewShownCount);
tabViewShownCount++;

// kick off the series
window.addEventListener("tabviewshown", onTabViewShown, false);
window.addEventListener("tabviewhidden", onTabViewHidden, false);
TabView.toggle();
} else {
setTimeout(waitForSwitch, 10);
}
}
ok(TabView.isVisible(), "Tab View is visible. Count: " + tabViewShownCount);
tabViewShownCount++;

setTimeout(waitForSwitch, 1);
// kick off the series
window.addEventListener("tabviewshown", onTabViewShown, false);
window.addEventListener("tabviewhidden", onTabViewHidden, false);
TabView.toggle();
}

// ----------
Expand Down
74 changes: 74 additions & 0 deletions js/src/jit-test/README
@@ -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
48 changes: 48 additions & 0 deletions js/src/jit-test/lib/prolog.js
@@ -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() { }
}

22 changes: 22 additions & 0 deletions js/src/jit-test/tests/arguments/args6.js
@@ -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)
14 changes: 14 additions & 0 deletions js/src/jit-test/tests/arguments/args8.js
@@ -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)
23 changes: 23 additions & 0 deletions js/src/jit-test/tests/arguments/argsx-4.js
@@ -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)
11 changes: 11 additions & 0 deletions js/src/jit-test/tests/basic/arith.js
@@ -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);
9 changes: 9 additions & 0 deletions js/src/jit-test/tests/basic/bug520498.js
@@ -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");

10 changes: 10 additions & 0 deletions js/src/jit-test/tests/basic/bug522136.js
@@ -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);

16 changes: 16 additions & 0 deletions js/src/jit-test/tests/basic/bug528644.js
@@ -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());
3 changes: 3 additions & 0 deletions js/src/jit-test/tests/basic/bug578041.js
@@ -0,0 +1,3 @@
__defineGetter__('x', Float32Array);
with(this)
x;
10 changes: 10 additions & 0 deletions js/src/jit-test/tests/basic/bug584565.js
@@ -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;
}
17 changes: 17 additions & 0 deletions js/src/jit-test/tests/basic/delete-named-names.js
@@ -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
});
14 changes: 14 additions & 0 deletions js/src/jit-test/tests/basic/jitstatsArchFlags.js
@@ -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);
}
23 changes: 23 additions & 0 deletions js/src/jit-test/tests/basic/parseIntTests.js
@@ -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);
16 changes: 16 additions & 0 deletions js/src/jit-test/tests/basic/strictParseIntOctal.js
@@ -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);
}
@@ -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");
}
19 changes: 19 additions & 0 deletions js/src/jit-test/tests/basic/testBug458838.js
@@ -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
});

0 comments on commit 5fca901

Please sign in to comment.