Bug 882514: Don't try to enable Ion on functions with no script; r=h4writer
authorBenjamin Bouvier <bbouvier@mozilla.com>
Thu, 13 Jun 2013 11:47:09 -0700
changeset 146467 05bf9122d23427ab8667b63ca82627e2df06e96e
parent 146466 03e03ea1a842af36133ad52c290ce1d28071f61d
child 146468 c1c441c9edcefd7f76fb95e107b3e9eaee197732
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs882514
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 882514: Don't try to enable Ion on functions with no script; r=h4writer
js/src/ion/AsmJS.cpp
js/src/jit-test/tests/asm.js/testFFI.js
--- a/js/src/ion/AsmJS.cpp
+++ b/js/src/ion/AsmJS.cpp
@@ -5226,19 +5226,21 @@ GenerateEntries(ModuleCompiler &m)
         if (!GenerateEntry(m, m.module().exportedFunction(i)))
             return false;
     }
 
     return true;
 }
 
 static inline bool
-TryEnablingIon(JSContext *cx, AsmJSModule::ExitDatum *exitDatum, int32_t argc, Value *argv) {
-
-    JSScript *script = exitDatum->fun->nonLazyScript();
+TryEnablingIon(JSContext *cx, AsmJSModule::ExitDatum *exitDatum, int32_t argc, Value *argv)
+{
+    JSScript *script = exitDatum->fun->maybeNonLazyScript();
+    if (!script)
+        return true;
 
     // Test if the function is Ion compiled
     if (!script->hasIonScript())
         return true;
 
     // Currently we can't rectify arguments. Therefore disabling if argc is too low.
     if (exitDatum->fun->nargs > argc)
         return true;
--- a/js/src/jit-test/tests/asm.js/testFFI.js
+++ b/js/src/jit-test/tests/asm.js/testFFI.js
@@ -14,17 +14,17 @@ function add1(x) { return x+1 }
 function add2(x,y) { return x+y }
 function add3(x,y,z) { return x+y+z }
 function addN() {
     var sum = 0;
     for (var i = 0; i < arguments.length; i++)
         sum += arguments[i];
     return sum;
 }
-var imp = { inc:inc, add1:add1, add2:add2, add3:add3, addN:addN };
+var imp = { inc:inc, add1:add1, add2:add2, add3:add3, addN:addN, identity: x => x };
 
 assertAsmTypeFail('glob', 'imp', USE_ASM + 'var inc=imp.inc; function f() { incc() } return f');
 assertAsmTypeFail('glob', 'imp', USE_ASM + 'var inc=imp.inc; function f() { var i = 0; return (i + inc)|0 } return f');
 assertAsmTypeFail('glob', 'imp', USE_ASM + 'var inc=imp.inc; function f() { inc = 0 } return f');
 assertAsmTypeFail('glob', 'imp', USE_ASM + 'var inc=imp.inc; function f() { return (inc() + 1)|0 } return f');
 assertAsmTypeFail('glob', 'imp', USE_ASM + 'var inc=imp.inc; function f() { return +((inc()|0) + 1.1) } return f');
 assertAsmTypeFail('glob', 'imp', USE_ASM + 'var inc=imp.inc; function f() { return +(inc() + 1.1) } return f');
 assertAsmTypeFail('glob', 'imp', USE_ASM + 'var inc=imp.inc; function f() { return (+inc() + 1)|0 } return f');
@@ -85,8 +85,10 @@ assertEq(f(2,0), 3);
 assertEq(f(3,0), 4);
 assertEq(f(4,5), 10);
 
 var recurse = function(i,j) { if (i == 0) throw j; f(i-1,j) }
 var f = asmLink(asmCompile('glob', 'imp', USE_ASM + 'var ffi=imp.ffi; function g(i,j,k) { i=i|0;j=+j;k=k|0; if (!(k|0)) ffi(i|0,j)|0; else g(i, j+1.0, (k-1)|0) } function f(i,j) { i=i|0;j=+j; g(i,j,4) } return f'), null, {ffi:recurse});
 assertThrowsValue(function() { f(0,2.4) }, 2.4+4);
 assertThrowsValue(function() { f(1,2.4) }, 2.4+8);
 assertThrowsValue(function() { f(8,2.4) }, 2.4+36);
+
+assertEq(asmLink(asmCompile('glob', 'imp', USE_ASM + 'var identity=imp.identity; function g(x) { x=+x; return +identity(x) } return g'), null, imp)(13.37), 13.37);