Bug 877965 - Ignore empty statements in var declarations in asm.js mode. r=luke
authorBenjamin Bouvier <bbouvier@mozilla.com>
Fri, 31 May 2013 16:27:00 -0700
changeset 134396 cac9a6c4ab7572bab6b4472f70362cf6d77220ef
parent 134395 a65235fd01464428171e9b5ab91b00546bfa8924
child 134397 d65ae86e598839196d88ea016575af20a5562c96
push id29194
push userryanvm@gmail.com
push dateFri, 07 Jun 2013 19:22:07 +0000
treeherdermozilla-inbound@859ee3960254 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs877965
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 877965 - Ignore empty statements in var declarations in asm.js mode. r=luke
js/src/ion/AsmJS.cpp
js/src/jit-test/tests/asm.js/testBasic.js
--- a/js/src/ion/AsmJS.cpp
+++ b/js/src/ion/AsmJS.cpp
@@ -4592,17 +4592,17 @@ CheckVariableDecl(ModuleCompiler &m, Par
     return true;
 }
 
 static bool
 CheckVariableDecls(ModuleCompiler &m, FunctionCompiler::LocalMap *locals, ParseNode **stmtIter)
 {
     ParseNode *stmt = *stmtIter;
 
-    for (; stmt && stmt->isKind(PNK_VAR); stmt = NextNode(stmt)) {
+    for (; stmt && stmt->isKind(PNK_VAR); stmt = NextNonEmptyStatement(stmt)) {
         for (ParseNode *var = VarListHead(stmt); var; var = NextNode(var)) {
             if (!CheckVariableDecl(m, var, locals))
                 return false;
         }
     }
 
     *stmtIter = stmt;
     return true;
--- a/js/src/jit-test/tests/asm.js/testBasic.js
+++ b/js/src/jit-test/tests/asm.js/testBasic.js
@@ -29,16 +29,17 @@ assertEq(asmLink(asmCompile('x', USE_ASM
 assertEq(asmLink(asmCompile('x','y', USE_ASM + 'function a(){} return a'))(), undefined);
 assertEq(asmLink(asmCompile('x','y','z', USE_ASM + 'function a(){} return a'))(), undefined);
 assertAsmTypeFail('x','y', USE_ASM + 'function y(){} return f');
 assertEq(asmLink(asmCompile('x', USE_ASM + 'function f(){} return f'), 1, 2, 3)(), undefined);
 assertEq(asmLink(asmCompile('x', USE_ASM + 'function f(){} return f'), 1)(), undefined);
 assertEq(asmLink(asmCompile('x','y', USE_ASM + 'function f(){} return f'), 1, 2)(), undefined);
 
 assertEq(asmLink(asmCompile(USE_ASM + 'function f(i) {i=i|0} return f'))(42), undefined);
+assertEq(asmLink(asmCompile(USE_ASM + 'function f() {var i=0;; var j=1;} return f'))(), undefined); // bug 877965 second part
 assertAsmTypeFail(USE_ASM + 'function f(i) {i=i|0;var i} return f');
 assertAsmTypeFail(USE_ASM + 'function f(i) {i=i|0;var i=0} return f');
 
 assertAsmTypeFail('glob', USE_ASM + 'var im=glob.imul; function f() {} return f');
 var code = asmCompile('glob', USE_ASM + 'var im=glob.Math.imul; function f(i,j) {i=i|0;j=j|0; return im(i,j)|0} return f');
 assertAsmLinkAlwaysFail(code, null);
 assertAsmLinkAlwaysFail(code, {});
 assertAsmLinkAlwaysFail(code, {imul:Math.imul});