js/src/jit-test/tests/asm.js/testParallelCompile.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 load(libdir + "asm.js");
michael@0 2
michael@0 3 if (!isAsmJSCompilationAvailable())
michael@0 4 quit();
michael@0 5
michael@0 6 var module = "'use asm';\n";
michael@0 7 for (var i = 0; i < 100; i++) {
michael@0 8 module += "function f" + i + "(i) {\n";
michael@0 9 module += " i=i|0; var j=0; j=(i+1)|0; i=(j-4)|0; i=(i+j)|0; return i|0\n";
michael@0 10 module += "}\n";
michael@0 11 }
michael@0 12 module += "return f0";
michael@0 13 var script = "(function() {\n" + module + "})";
michael@0 14
michael@0 15 for (var i = 0; i < 10; i++) {
michael@0 16 try {
michael@0 17 offThreadCompileScript(script);
michael@0 18 var f = new Function(module);
michael@0 19 var g = runOffThreadScript();
michael@0 20 assertEq(isAsmJSModule(f), true);
michael@0 21 assertEq(isAsmJSModule(g), true);
michael@0 22 } catch (e) {
michael@0 23 // ignore spurious error when offThreadCompileScript can't run in
michael@0 24 // parallel
michael@0 25 }
michael@0 26 }

mercurial