Bug 1300963 - Baldr: remove default import special case (r=bbouvier)
authorLuke Wagner <luke@mozilla.com>
Wed, 07 Sep 2016 09:42:20 -0500
changeset 313013 0954858f2c96aadcc6621bcf26bdb66b986c7eb7
parent 313012 ac6340bb31525900720181c8f2fcc9c6ffbae947
child 313014 5db21f7f4efa2eb6d8e59beef7f97f64001b2b6f
push id20479
push userkwierso@gmail.com
push dateThu, 08 Sep 2016 01:08:46 +0000
treeherderfx-team@fb7c6b034329 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1300963
milestone51.0a1
Bug 1300963 - Baldr: remove default import special case (r=bbouvier) MozReview-Commit-ID: 70z75lLaHEK
js/src/asmjs/WasmCompile.cpp
js/src/asmjs/WasmJS.cpp
js/src/jit-test/tests/wasm/basic-control-flow.js
js/src/jit-test/tests/wasm/basic.js
js/src/jit-test/tests/wasm/binary.js
js/src/jit-test/tests/wasm/start.js
--- a/js/src/asmjs/WasmCompile.cpp
+++ b/js/src/asmjs/WasmCompile.cpp
@@ -608,17 +608,17 @@ DecodeFunctionSection(Decoder& d, Module
 
     if (!d.finishSection(sectionStart, sectionSize))
         return Fail(d, "decls section byte size mismatch");
 
     return true;
 }
 
 static UniqueChars
-MaybeDecodeName(Decoder& d)
+DecodeName(Decoder& d)
 {
     uint32_t numBytes;
     if (!d.readVarU32(&numBytes))
         return nullptr;
 
     const uint8_t* bytes;
     if (!d.readBytes(numBytes, &bytes))
         return nullptr;
@@ -769,38 +769,32 @@ DecodeImport(Decoder& d, bool newFormat,
     if (!newFormat) {
         const SigWithId* sig = nullptr;
         if (!DecodeSignatureIndex(d, *init, &sig))
             return false;
 
         if (!init->funcImports.emplaceBack(sig))
             return false;
 
-        UniqueChars moduleName = MaybeDecodeName(d);
+        UniqueChars moduleName = DecodeName(d);
         if (!moduleName)
             return Fail(d, "expected valid import module name");
 
-        if (!strlen(moduleName.get()))
-            return Fail(d, "module name cannot be empty");
-
-        UniqueChars funcName = MaybeDecodeName(d);
+        UniqueChars funcName = DecodeName(d);
         if (!funcName)
             return Fail(d, "expected valid import func name");
 
         return imports->emplaceBack(Move(moduleName), Move(funcName), DefinitionKind::Function);
     }
 
-    UniqueChars moduleName = MaybeDecodeName(d);
+    UniqueChars moduleName = DecodeName(d);
     if (!moduleName)
         return Fail(d, "expected valid import module name");
 
-    if (!strlen(moduleName.get()))
-        return Fail(d, "module name cannot be empty");
-
-    UniqueChars funcName = MaybeDecodeName(d);
+    UniqueChars funcName = DecodeName(d);
     if (!funcName)
         return Fail(d, "expected valid import func name");
 
     uint32_t importKind;
     if (!d.readVarU32(&importKind))
         return Fail(d, "failed to read import kind");
 
     switch (DefinitionKind(importKind)) {
@@ -1069,17 +1063,17 @@ DecodeGlobalSection(Decoder& d, ModuleGe
     return true;
 }
 
 typedef HashSet<const char*, CStringHasher, SystemAllocPolicy> CStringSet;
 
 static UniqueChars
 DecodeExportName(Decoder& d, CStringSet* dupSet)
 {
-    UniqueChars exportName = MaybeDecodeName(d);
+    UniqueChars exportName = DecodeName(d);
     if (!exportName) {
         Fail(d, "expected valid export name");
         return nullptr;
     }
 
     CStringSet::AddPtr p = dupSet->lookupForAdd(exportName.get());
     if (p) {
         Fail(d, "duplicate export");
--- a/js/src/asmjs/WasmJS.cpp
+++ b/js/src/asmjs/WasmJS.cpp
@@ -101,24 +101,22 @@ GetImports(JSContext* cx,
 
     uint32_t globalIndex = 0;
     const GlobalDescVector& globals = metadata.globals;
     for (const Import& import : imports) {
         RootedValue v(cx);
         if (!GetProperty(cx, importObj, import.module.get(), &v))
             return false;
 
-        if (strlen(import.func.get()) > 0) {
-            if (!v.isObject())
-                return Throw(cx, JSMSG_WASM_BAD_IMPORT_FIELD, "an Object");
+        if (!v.isObject())
+            return Throw(cx, JSMSG_WASM_BAD_IMPORT_FIELD, "an Object");
 
-            RootedObject obj(cx, &v.toObject());
-            if (!GetProperty(cx, obj, import.func.get(), &v))
-                return false;
-        }
+        RootedObject obj(cx, &v.toObject());
+        if (!GetProperty(cx, obj, import.func.get(), &v))
+            return false;
 
         switch (import.kind) {
           case DefinitionKind::Function:
             if (!IsFunctionObject(v))
                 return Throw(cx, JSMSG_WASM_BAD_IMPORT_FIELD, "a Function");
 
             if (!funcImports.append(&v.toObject().as<JSFunction>()))
                 return false;
--- a/js/src/jit-test/tests/wasm/basic-control-flow.js
+++ b/js/src/jit-test/tests/wasm/basic-control-flow.js
@@ -42,73 +42,73 @@ assertEq(wasmEvalText(`(module
             (i32.const 0)
         )
     )
     (export "" 0)
 )`)(), 2);
 
 // The if (resp. else) branch is taken iff the condition is true (resp. false)
 counter = 0;
-var imports = { inc() { counter++ } };
+var imports = { "":{inc() { counter++ }} };
 assertEq(wasmEvalText(`(module
-    (import "inc" "" (result i32))
+    (import "" "inc" (result i32))
     (func
         (result i32)
         (if
             (i32.const 42)
             (i32.const 1)
             (call_import 0)
         )
     )
     (export "" 0)
 )`, imports)(), 1);
 assertEq(counter, 0);
 
 assertEq(wasmEvalText(`(module
-    (import "inc" "" (result i32))
+    (import "" "inc" (result i32))
     (func
         (result i32)
         (if
             (i32.const 0)
             (call_import 0)
             (i32.const 1)
         )
     )
     (export "" 0)
 )`, imports)(), 1);
 assertEq(counter, 0);
 
 assertEq(wasmEvalText(`(module
-    (import "inc" "" (result i32))
+    (import "" "inc" (result i32))
     (func
         (if
             (i32.const 0)
             (call_import 0)
         )
     )
     (export "" 0)
 )`, imports)(), undefined);
 assertEq(counter, 0);
 
 assertEq(wasmEvalText(`(module
-    (import "inc" "" (result i32))
+    (import "" "inc" (result i32))
     (func
         (if
             (i32.const 1)
             (call_import 0)
         )
     )
     (export "" 0)
 )`, imports)(), undefined);
 assertEq(counter, 1);
 
 // One can chain if with if/if
 counter = 0;
 assertEq(wasmEvalText(`(module
-    (import "inc" "" (result i32))
+    (import "" "inc" (result i32))
     (func
         (result i32)
         (if
             (i32.const 1)
             (if
                 (i32.const 2)
                 (if
                     (i32.const 3)
@@ -207,23 +207,23 @@ assertEq(wasmEvalText(`(module (func (re
     )
     (return (i32.const 1))
   )
   (return (i32.const 2))
 ) (export "" 0))`)(), 1);
 
 var notcalled = false;
 var called = false;
-var imports = {
+var imports = {"": {
     notcalled() {notcalled = true},
     called() {called = true}
-};
+}};
 assertEq(wasmEvalText(`(module
-(import "notcalled" "")
-(import "called" "")
+(import "" "notcalled")
+(import "" "called")
 (func
   (block
     (return (br 0))
     (call_import 0)
   )
   (call_import 1)
 ) (export "" 0))`, imports)(), undefined);
 assertEq(notcalled, false);
--- a/js/src/jit-test/tests/wasm/basic.js
+++ b/js/src/jit-test/tests/wasm/basic.js
@@ -98,32 +98,32 @@ var code = '(module (import "a" "b"))';
 assertErrorMessage(() => wasmEvalText(code), TypeError, noImportObj);
 assertErrorMessage(() => wasmEvalText(code, {}), TypeError, notObject);
 assertErrorMessage(() => wasmEvalText(code, {a:1}), TypeError, notObject);
 assertErrorMessage(() => wasmEvalText(code, {a:{}}), TypeError, notFunction);
 assertErrorMessage(() => wasmEvalText(code, {a:{b:1}}), TypeError, notFunction);
 wasmEvalText(code, {a:{b:()=>{}}});
 
 var code = '(module (import "" "b"))';
-assertErrorMessage(() => wasmEvalText(code), TypeError, /module name cannot be empty/);
+wasmEvalText(code, {"":{b:()=>{}}});
 
 var code = '(module (import "a" ""))';
 assertErrorMessage(() => wasmEvalText(code), TypeError, noImportObj);
-assertErrorMessage(() => wasmEvalText(code, {}), TypeError, notFunction);
-assertErrorMessage(() => wasmEvalText(code, {a:1}), TypeError, notFunction);
-wasmEvalText(code, {a:()=>{}});
+assertErrorMessage(() => wasmEvalText(code, {}), TypeError, notObject);
+assertErrorMessage(() => wasmEvalText(code, {a:1}), TypeError, notObject);
+wasmEvalText(code, {a:{"":()=>{}}});
 
 var code = '(module (import "a" "") (import "b" "c") (import "c" ""))';
 assertErrorMessage(() => wasmEvalText(code, {a:()=>{}, b:{c:()=>{}}, c:{}}), TypeError, notFunction);
-wasmEvalText(code, {a:()=>{}, b:{c:()=>{}}, c:()=>{}});
+wasmEvalText(code, {a:{"":()=>{}}, b:{c:()=>{}}, c:{"":()=>{}}});
 
-wasmEvalText('(module (import "a" "" (result i32)))', {a: ()=> {}});
-wasmEvalText('(module (import "a" "" (result f32)))', {a: ()=> {}});
-wasmEvalText('(module (import "a" "" (result f64)))', {a: ()=> {}});
-wasmEvalText('(module (import $foo "a" "" (result f64)))', {a: ()=> {}});
+wasmEvalText('(module (import "a" "" (result i32)))', {a:{"":()=>{}}});
+wasmEvalText('(module (import "a" "" (result f32)))', {a:{"":()=>{}}});
+wasmEvalText('(module (import "a" "" (result f64)))', {a:{"":()=>{}}});
+wasmEvalText('(module (import $foo "a" "" (result f64)))', {a:{"":()=>{}}});
 
 // ----------------------------------------------------------------------------
 // memory
 
 wasmEvalText('(module (memory 0))');
 wasmEvalText('(module (memory 1))');
 assertErrorMessage(() => wasmEvalText('(module (memory 65536))'), TypeError, /initial memory size too big/);
 
@@ -288,60 +288,60 @@ assertThrowsInstanceOf(() => wasmEvalTex
 wasmEvalText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (f32.const nan))))');
 assertErrorMessage(() => wasmEvalText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (i32.const 0))))'), TypeError, mismatchError("i32", "f32"));
 
 assertThrowsInstanceOf(() => wasmEvalText('(module (import "a" "") (func (call_import 0 (i32.const 0))))', {a:()=>{}}), TypeError);
 
 assertThrowsInstanceOf(() => wasmEvalText('(module (import "a" "" (param i32)) (func (call_import 0)))', {a:()=>{}}), TypeError);
 assertThrowsInstanceOf(() => wasmEvalText('(module (import "a" "" (param f32)) (func (call_import 0 (i32.const 0))))', {a:()=>{}}), TypeError);
 assertErrorMessage(() => wasmEvalText('(module (import "a" "") (func (call_import 1)))'), TypeError, /import index out of range/);
-wasmEvalText('(module (import "a" "") (func (call_import 0)))', {a:()=>{}});
-wasmEvalText('(module (import "a" "" (param i32)) (func (call_import 0 (i32.const 0))))', {a:()=>{}});
+wasmEvalText('(module (import "" "a") (func (call_import 0)))', {"":{a:()=>{}}});
+wasmEvalText('(module (import "" "a" (param i32)) (func (call_import 0 (i32.const 0))))', {"":{a:()=>{}}});
 
 function checkF32CallImport(v) {
-    assertEq(wasmEvalText('(module (import "a" "" (result f32)) (func (result f32) (call_import 0)) (export "" 0))', {a:()=>{ return v; }})(), Math.fround(v));
-    wasmEvalText('(module (import "a" "" (param f32)) (func (param f32) (call_import 0 (get_local 0))) (export "" 0))', {a:x=>{ assertEq(Math.fround(v), x); }})(v);
+    assertEq(wasmEvalText('(module (import "" "a" (result f32)) (func (result f32) (call_import 0)) (export "" 0))', {"":{a:()=>{ return v; }}})(), Math.fround(v));
+    wasmEvalText('(module (import "" "a" (param f32)) (func (param f32) (call_import 0 (get_local 0))) (export "" 0))', {"":{a:x=>{ assertEq(Math.fround(v), x); }}})(v);
 }
 checkF32CallImport(13.37);
 checkF32CallImport(NaN);
 checkF32CallImport(-Infinity);
 checkF32CallImport(-0);
 checkF32CallImport(Math.pow(2, 32) - 1);
 
-var f = wasmEvalText('(module (import "inc" "") (func (call_import 0)) (export "" 0))', {inc:()=>counter++});
-var g = wasmEvalText('(module (import "f" "") (func (block (call_import 0) (call_import 0))) (export "" 0))', {f});
+var f = wasmEvalText('(module (import "" "inc") (func (call_import 0)) (export "" 0))', {"":{inc:()=>counter++}});
+var g = wasmEvalText('(module (import "" "f") (func (block (call_import 0) (call_import 0))) (export "" 0))', {"":{f}});
 var counter = 0;
 f();
 assertEq(counter, 1);
 g();
 assertEq(counter, 3);
 
-var f = wasmEvalText('(module (import "callf" "") (func (call_import 0)) (export "" 0))', {callf:()=>f()});
+var f = wasmEvalText('(module (import "" "callf") (func (call_import 0)) (export "" 0))', {"":{callf:()=>f()}});
 assertThrowsInstanceOf(() => f(), InternalError);
 
-var f = wasmEvalText('(module (import "callg" "") (func (call_import 0)) (export "" 0))', {callg:()=>g()});
-var g = wasmEvalText('(module (import "callf" "") (func (call_import 0)) (export "" 0))', {callf:()=>f()});
+var f = wasmEvalText('(module (import "" "callg") (func (call_import 0)) (export "" 0))', {"":{callg:()=>g()}});
+var g = wasmEvalText('(module (import "" "callf") (func (call_import 0)) (export "" 0))', {"":{callf:()=>f()}});
 assertThrowsInstanceOf(() => f(), InternalError);
 
-var code = '(module (import "one" "" (result i32)) (import "two" "" (result i32)) (func (result i32) (i32.const 3)) (func (result i32) (i32.const 4)) (func (result i32) BODY) (export "" 2))';
-var imports = {one:()=>1, two:()=>2};
+var code = '(module (import "" "one" (result i32)) (import "" "two" (result i32)) (func (result i32) (i32.const 3)) (func (result i32) (i32.const 4)) (func (result i32) BODY) (export "" 2))';
+var imports = {"":{one:()=>1, two:()=>2}};
 assertEq(wasmEvalText(code.replace('BODY', '(call_import 0)'), imports)(), 1);
 assertEq(wasmEvalText(code.replace('BODY', '(call_import 1)'), imports)(), 2);
 assertEq(wasmEvalText(code.replace('BODY', '(call 0)'), imports)(), 3);
 assertEq(wasmEvalText(code.replace('BODY', '(call 1)'), imports)(), 4);
 
-assertEq(wasmEvalText(`(module (import "evalcx" "" (param i32) (result i32)) (func (result i32) (call_import 0 (i32.const 0))) (export "" 0))`, {evalcx})(), 0);
+assertEq(wasmEvalText(`(module (import "" "evalcx" (param i32) (result i32)) (func (result i32) (call_import 0 (i32.const 0))) (export "" 0))`, {"":{evalcx}})(), 0);
 
 if (typeof evaluate === 'function')
     evaluate(`Wasm.instantiateModule(wasmTextToBinary('(module)')) `, { fileName: null });
 
 {
     setJitCompilerOption('wasm.test-mode', 1);
 
-    let imp = {
+    let imp = {"":{
         param(i64) {
             assertEqI64(i64, {
                 low: 0x9abcdef0,
                 high: 0x12345678
             });
             return 42;
         },
         result(i32) {
@@ -353,37 +353,37 @@ if (typeof evaluate === 'function')
         paramAndResult(i64) {
             assertEqI64(i64, {
                 low: 0x9abcdef0,
                 high: 0x12345678
             });
             i64.low = 1337;
             return i64;
         }
-    }
+    }}
 
     assertEq(wasmEvalText(`(module
-        (import "param" "" (param i64) (result i32))
+        (import "" "param" (param i64) (result i32))
         (func (result i32) (call_import 0 (i64.const 0x123456789abcdef0)))
         (export "" 0))`, imp)(), 42);
 
     assertEq(wasmEvalText(`(module
-        (import "param" "" (param i64)(param i64)(param i64)(param i64)(param i64)(param i64)(param i64) (param i64) (result i32))
+        (import "" "param" (param i64)(param i64)(param i64)(param i64)(param i64)(param i64)(param i64) (param i64) (result i32))
         (func (result i32) (call_import 0 (i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)(i64.const 0x123456789abcdef0)))
         (export "" 0))`, imp)(), 42);
 
     assertEqI64(wasmEvalText(`(module
-        (import "result" "" (param i32) (result i64))
+        (import "" "result" (param i32) (result i64))
         (func (result i64) (call_import 0 (i32.const 3)))
         (export "" 0))`, imp)(), { low: 0xabcdef01, high: 0x1234567b });
 
     // Ensure the ion exit is never taken.
     let ionThreshold = 2 * getJitCompilerOptions()['ion.warmup.trigger'];
     assertEqI64(wasmEvalText(`(module
-        (import "paramAndResult" "" (param i64) (result i64))
+        (import "" "paramAndResult" (param i64) (result i64))
         (func (result i64) (local i32) (local i64)
          (set_local 0 (i32.const 0))
          (loop $out $in
              (set_local 1 (call_import 0 (i64.const 0x123456789abcdef0)))
              (set_local 0 (i32.add (get_local 0) (i32.const 1)))
              (if (i32.le_s (get_local 0) (i32.const ${ionThreshold})) (br $in))
          )
          (get_local 1)
@@ -439,24 +439,24 @@ assertErrorMessage(() => i2v(5), Error, 
 
 {
     enableSPSProfiling();
 
     var stack;
     assertEq(wasmEvalText(
         `(module
             (type $v2v (func))
-            (import $foo "f" "")
+            (import $foo "" "f")
             (func $a (call_import $foo))
             (func $b (result i32) (i32.const 0))
             (table $a $b)
             (func $bar (call_indirect $v2v (i32.const 0)))
             (export "" $bar)
         )`,
-        {f:() => { stack = new Error().stack }}
+        {"":{f:() => { stack = new Error().stack }}}
     )(), undefined);
 
     disableSPSProfiling();
 
     var inner = stack.indexOf("wasm-function[0]");
     var outer = stack.indexOf("wasm-function[2]");
     assertEq(inner === -1, false);
     assertEq(outer === -1, false);
@@ -466,17 +466,17 @@ assertErrorMessage(() => i2v(5), Error, 
 for (bad of [6, 7, 100, Math.pow(2,31)-1, Math.pow(2,31), Math.pow(2,31)+1, Math.pow(2,32)-2, Math.pow(2,32)-1]) {
     assertThrowsInstanceOf(() => v2i(bad), RangeError);
     assertThrowsInstanceOf(() => i2i(bad, 0), RangeError);
     assertThrowsInstanceOf(() => i2v(bad, 0), RangeError);
 }
 
 wasmEvalText('(module (func $foo (nop)) (func (call $foo)))');
 wasmEvalText('(module (func (call $foo)) (func $foo (nop)))');
-wasmEvalText('(module (import $bar "a" "") (func (call_import $bar)) (func $foo (nop)))', {a:()=>{}});
+wasmEvalText('(module (import $bar "" "a") (func (call_import $bar)) (func $foo (nop)))', {"":{a:()=>{}}});
 
 
 // ----------------------------------------------------------------------------
 // select
 
 assertErrorMessage(() => wasmEvalText('(module (func (select (i32.const 0) (i32.const 0) (f32.const 0))))'), TypeError, mismatchError("f32", "i32"));
 
 assertEq(wasmEvalText('(module (func (select (i32.const 0) (f32.const 0) (i32.const 0))) (export "" 0))')(), undefined);
@@ -486,26 +486,26 @@ assertEq(wasmEvalText('(module (func (i3
 assertEq(wasmEvalText('(module (func (select (if (i32.const 1) (i32.const 0) (f32.const 0)) (i32.const 0) (i32.const 0))) (export "" 0))')(), undefined);
 assertEq(wasmEvalText('(module (func) (func (select (call 0) (call 0) (i32.const 0))) (export "" 0))')(), undefined);
 
 (function testSideEffects() {
 
 var numT = 0;
 var numF = 0;
 
-var imports = {
+var imports = {"": {
     ifTrue: () => 1 + numT++,
     ifFalse: () => -1 + numF++,
-}
+}}
 
 // Test that side-effects are applied on both branches.
 var f = wasmEvalText(`
 (module
- (import "ifTrue" "" (result i32))
- (import "ifFalse" "" (result i32))
+ (import "" "ifTrue" (result i32))
+ (import "" "ifFalse" (result i32))
  (func (result i32) (param i32)
   (select
    (call_import 0)
    (call_import 1)
    (get_local 0)
   )
  )
  (export "" 0)
--- a/js/src/jit-test/tests/wasm/binary.js
+++ b/js/src/jit-test/tests/wasm/binary.js
@@ -224,24 +224,24 @@ assertThrowsInstanceOf(() => wasmEval(mo
 assertThrowsInstanceOf(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([1])])), TypeError, /signature index out of range/);
 assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0])])), TypeError, /expected function bodies/);
 wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([v2vBody])]));
 
 assertThrowsInstanceOf(() => wasmEval(moduleWithSections([sigSection([v2vSig]), {name: importId, body:[]}])), TypeError);
 assertErrorMessage(() => wasmEval(moduleWithSections([importSection([{sigIndex:0, module:"a", func:"b"}])])), TypeError, /signature index out of range/);
 assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), importSection([{sigIndex:1, module:"a", func:"b"}])])), TypeError, /signature index out of range/);
 wasmEval(moduleWithSections([sigSection([v2vSig]), importSection([])]));
-wasmEval(moduleWithSections([sigSection([v2vSig]), importSection([{sigIndex:0, module:"a", func:""}])]), {a:()=>{}});
+wasmEval(moduleWithSections([sigSection([v2vSig]), importSection([{sigIndex:0, module:"a", func:""}])]), {a:{"":()=>{}}});
 
 wasmEval(moduleWithSections([
     sigSection([v2vSig]),
     importSection([{sigIndex:0, module:"a", func:""}]),
     declSection([0]),
     bodySection([v2vBody])
-]), {a:()=>{}});
+]), {a:{"":()=>{}}});
 
 assertErrorMessage(() => wasmEval(moduleWithSections([ {name: dataSegmentsId, body: [], } ])), TypeError, /data section requires a memory section/);
 
 wasmEval(moduleWithSections([tableSection([])]));
 assertErrorMessage(() => wasmEval(moduleWithSections([tableSection([0])])), TypeError, /table element out of range/);
 wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), tableSection([0]), bodySection([v2vBody])]));
 wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), tableSection([0,0]), bodySection([v2vBody])]));
 assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), tableSection([0,1]), bodySection([v2vBody])])), TypeError, /table element out of range/);
--- a/js/src/jit-test/tests/wasm/start.js
+++ b/js/src/jit-test/tests/wasm/start.js
@@ -9,46 +9,46 @@ assertErrorMessage(() => wasmEvalText('(
 assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param f32)) (start 0))'), TypeError, /must be nullary/);
 assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param f32) (param f64)) (start 0))'), TypeError, /must be nullary/);
 
 assertErrorMessage(() => wasmEvalText('(module (func (result f32)) (start 0))'), TypeError, /must not return anything/);
 
 // Basic use case.
 var count = 0;
 function inc() { count++; }
-var exports = wasmEvalText(`(module (import $imp "inc" "") (func $f (param i32)) (func (call_import $imp)) (start $f))`, { inc });
+var exports = wasmEvalText(`(module (import $imp "" "inc") (func $f (param i32)) (func (call_import $imp)) (start $f))`, { "":{inc} });
 assertEq(count, 1);
 assertEq(Object.keys(exports).length, 0);
 
 count = 0;
-exports = wasmEvalText(`(module (import "inc" "") (func $start (call_import 0)) (start $start) (export "" 0))`, { inc });
+exports = wasmEvalText(`(module (import "" "inc") (func $start (call_import 0)) (start $start) (export "" 0))`, { "":{inc} });
 assertEq(count, 1);
 assertEq(typeof exports, 'function');
 assertEq(exports(), undefined);
 assertEq(count, 2);
 
 // New API.
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const textToBinary = str => wasmTextToBinary(str, 'new-format');
 
 count = 0;
-const m = new Module(textToBinary('(module (import $imp "inc" "") (func) (func $start (call $imp)) (start $start) (export "" $start))'));
+const m = new Module(textToBinary('(module (import $imp "" "inc") (func) (func $start (call $imp)) (start $start) (export "" $start))'));
 assertEq(count, 0);
 
 assertErrorMessage(() => new Instance(m), TypeError, /no import object given/);
 assertEq(count, 0);
 
-const i1 = new Instance(m, { inc });
+const i1 = new Instance(m, { "":{inc} });
 assertEq(count, 1);
 i1.exports[""]();
 assertEq(count, 2);
 
-const i2 = new Instance(m, { inc });
+const i2 = new Instance(m, { "":{inc} });
 assertEq(count, 3);
 
 function fail() { assertEq(true, false); }
 
 count = 0;
-const m2 = new Module(textToBinary('(module (import "fail" "") (import $imp "inc" "") (func) (start $imp))'));
+const m2 = new Module(textToBinary('(module (import "" "fail") (import $imp "" "inc") (func) (start $imp))'));
 assertEq(count, 0);
-new Instance(m2, { inc, fail });
+new Instance(m2, {"":{ inc, fail }});
 assertEq(count, 1);