Bug 1303079 - Baldr: add WebAssembly.(Compile|Runtime)Error (r=bbouvier)
authorLuke Wagner <luke@mozilla.com>
Fri, 23 Sep 2016 09:13:16 -0500
changeset 315210 06baf9c96c5b2f45df49941ef00f190c79445295
parent 315209 4119fba22f7fc6a60e504933d2e9a89d00aab0cd
child 315211 dfc1afe56b75b0eb563e1fe8ed74af7d51b8ebe0
push id32563
push userihsiao@mozilla.com
push dateMon, 26 Sep 2016 11:18:33 +0000
treeherderautoland@eb840c87b5fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1303079
milestone52.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 1303079 - Baldr: add WebAssembly.(Compile|Runtime)Error (r=bbouvier) MozReview-Commit-ID: 7DweEFy2IUW
js/src/asmjs/WasmBinaryToAST.cpp
js/src/asmjs/WasmJS.cpp
js/src/asmjs/WasmTypes.cpp
js/src/builtin/TestingFunctions.cpp
js/src/jit-test/lib/wasm.js
js/src/jit-test/tests/wasm/basic.js
js/src/jit-test/tests/wasm/binary.js
js/src/jit-test/tests/wasm/control-flow.js
js/src/jit-test/tests/wasm/conversion.js
js/src/jit-test/tests/wasm/float.js
js/src/jit-test/tests/wasm/globals.js
js/src/jit-test/tests/wasm/import-export.js
js/src/jit-test/tests/wasm/integer.js
js/src/jit-test/tests/wasm/jsapi.js
js/src/jit-test/tests/wasm/memory.js
js/src/jit-test/tests/wasm/regress/misc-control-flow.js
js/src/jit-test/tests/wasm/start.js
js/src/jit-test/tests/wasm/tables.js
js/src/jit-test/tests/wasm/to-text-experimental.js
js/src/js.msg
js/src/jsapi.h
js/src/jsexn.cpp
js/src/jsexn.h
js/src/jsprototypes.h
js/src/vm/ErrorObject.h
--- a/js/src/asmjs/WasmBinaryToAST.cpp
+++ b/js/src/asmjs/WasmBinaryToAST.cpp
@@ -2134,17 +2134,17 @@ wasm::BinaryToAst(JSContext* cx, const u
         !AstDecodeExportSection(c) ||
         !AstDecodeStartSection(c) ||
         !AstDecodeElemSection(c) ||
         !AstDecodeCodeSection(c) ||
         !AstDecodeDataSection(c) ||
         !DecodeUnknownSections(c.d))
     {
         if (error) {
-            JS_ReportErrorNumber(c.cx, GetErrorMessage, nullptr, JSMSG_WASM_DECODE_FAIL,
+            JS_ReportErrorNumber(c.cx, GetErrorMessage, nullptr, JSMSG_WASM_COMPILE_ERROR,
                                  error.get());
             return false;
         }
         ReportOutOfMemory(c.cx);
         return false;
     }
 
     *module = result;
--- a/js/src/asmjs/WasmJS.cpp
+++ b/js/src/asmjs/WasmJS.cpp
@@ -145,18 +145,17 @@ wasm::CreateI64Object(JSContext* cx, int
 
     return result;
 }
 
 bool
 wasm::ReadI64Object(JSContext* cx, HandleValue v, int64_t* i64)
 {
     if (!v.isObject()) {
-        JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_FAIL,
-                             "i64 JS value must be an object");
+        JS_ReportError(cx, "i64 JS value must be an object");
         return false;
     }
 
     RootedObject obj(cx, &v.toObject());
 
     int32_t* i32 = (int32_t*)i64;
 
     RootedValue val(cx);
@@ -172,26 +171,26 @@ wasm::ReadI64Object(JSContext* cx, Handl
 
     return true;
 }
 
 // ============================================================================
 // (Temporary) Wasm class and static methods
 
 static bool
-Throw(JSContext* cx, const char* str)
+ThrowBadImportArg(JSContext* cx)
 {
-    JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_FAIL, str);
+    JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_ARG);
     return false;
 }
 
 static bool
-Throw(JSContext* cx, unsigned errorNumber, const char* str)
+ThrowBadImportField(JSContext* cx, const char* str)
 {
-    JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, errorNumber, str);
+    JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_FIELD, str);
     return false;
 }
 
 static bool
 GetProperty(JSContext* cx, HandleObject obj, const char* chars, MutableHandleValue v)
 {
     JSAtom* atom = AtomizeUTF8Chars(cx, chars, strlen(chars));
     if (!atom)
@@ -207,53 +206,53 @@ GetImports(JSContext* cx,
            HandleObject importObj,
            MutableHandle<FunctionVector> funcImports,
            MutableHandleWasmTableObject tableImport,
            MutableHandleWasmMemoryObject memoryImport,
            ValVector* globalImports)
 {
     const ImportVector& imports = module.imports();
     if (!imports.empty() && !importObj)
-        return Throw(cx, "no import object given");
+        return ThrowBadImportArg(cx);
 
     const Metadata& metadata = module.metadata();
 
     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 (!v.isObject())
-            return Throw(cx, JSMSG_WASM_BAD_IMPORT_FIELD, "an Object");
+            return ThrowBadImportField(cx, "an Object");
 
         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");
+                return ThrowBadImportField(cx, "a Function");
 
             if (!funcImports.append(&v.toObject().as<JSFunction>()))
                 return false;
 
             break;
           case DefinitionKind::Table:
             if (!v.isObject() || !v.toObject().is<WasmTableObject>())
-                return Throw(cx, JSMSG_WASM_BAD_IMPORT_FIELD, "a Table");
+                return ThrowBadImportField(cx, "a Table");
 
             MOZ_ASSERT(!tableImport);
             tableImport.set(&v.toObject().as<WasmTableObject>());
             break;
           case DefinitionKind::Memory:
             if (!v.isObject() || !v.toObject().is<WasmMemoryObject>())
-                return Throw(cx, JSMSG_WASM_BAD_IMPORT_FIELD, "a Memory");
+                return ThrowBadImportField(cx, "a Memory");
 
             MOZ_ASSERT(!memoryImport);
             memoryImport.set(&v.toObject().as<WasmMemoryObject>());
             break;
 
           case DefinitionKind::Global:
             Val val;
             const GlobalDesc& global = globals[globalIndex++];
@@ -357,17 +356,17 @@ wasm::Eval(JSContext* cx, Handle<TypedAr
     CompileArgs compileArgs;
     if (!compileArgs.initFromContext(cx, Move(scriptedCaller)))
         return false;
 
     UniqueChars error;
     SharedModule module = Compile(*bytecode, compileArgs, &error);
     if (!module) {
         if (error) {
-            JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_DECODE_FAIL,
+            JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_COMPILE_ERROR,
                                  error.get());
             return false;
         }
         ReportOutOfMemory(cx);
         return false;
     }
 
     Rooted<FunctionVector> funcs(cx, FunctionVector(cx));
@@ -593,17 +592,17 @@ WasmModuleObject::construct(JSContext* c
     CompileArgs compileArgs;
     if (!GetCompileArgs(cx, callArgs, "WebAssembly.Module", &bytecode, &compileArgs))
         return false;
 
     UniqueChars error;
     SharedModule module = Compile(*bytecode, compileArgs, &error);
     if (!module) {
         if (error) {
-            JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_DECODE_FAIL,
+            JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_COMPILE_ERROR,
                                  error.get());
             return false;
         }
         ReportOutOfMemory(cx);
         return false;
     }
 
     RootedObject proto(cx, &cx->global()->getPrototype(JSProto_WasmModule).toObject());
@@ -738,20 +737,18 @@ WasmInstanceObject::construct(JSContext*
         JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_MOD_ARG);
         return false;
     }
 
     const Module& module = args[0].toObject().as<WasmModuleObject>().module();
 
     RootedObject importObj(cx);
     if (!args.get(1).isUndefined()) {
-        if (!args[1].isObject()) {
-            JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_ARG);
-            return false;
-        }
+        if (!args[1].isObject())
+            return ThrowBadImportArg(cx);
         importObj = &args[1].toObject();
     }
 
     Rooted<FunctionVector> funcs(cx, FunctionVector(cx));
     RootedWasmTableObject table(cx);
     RootedWasmMemoryObject memory(cx);
     ValVector globals;
     if (!GetImports(cx, module, importObj, &funcs, &table, &memory, &globals))
@@ -1451,17 +1448,17 @@ Reject(JSContext* cx, const CompileArgs&
     RootedObject stack(cx, promise->allocationSite());
     RootedString filename(cx, JS_NewStringCopyZ(cx, args.scriptedCaller.filename.get()));
     if (!filename)
         return false;
 
     unsigned line = args.scriptedCaller.line;
     unsigned column = args.scriptedCaller.column;
 
-    // Ideally we'd report a JSMSG_WASM_DECODE_FAIL here, but there's no easy
+    // Ideally we'd report a JSMSG_WASM_COMPILE_ERROR here, but there's no easy
     // way to create an ErrorObject for an arbitrary error code with multiple
     // replacements.
     UniqueChars str(JS_smprintf("wasm validation error: %s", error.get()));
     if (!str)
         return false;
 
     RootedString message(cx, NewLatin1StringZ(cx, Move(str)));
     if (!message)
@@ -1578,17 +1575,17 @@ WebAssembly_validate(JSContext* cx, unsi
     // correct.
     if (!validated && !error) {
         ReportOutOfMemory(cx);
         return false;
     }
 
     if (error) {
         JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, GetErrorMessage, nullptr,
-                                     JSMSG_WASM_DECODE_FAIL, error.get());
+                                     JSMSG_WASM_COMPILE_ERROR, error.get());
     }
 
     callArgs.rval().setBoolean(validated);
     return true;
 }
 
 static const JSFunctionSpec WebAssembly_static_methods[] =
 {
@@ -1630,16 +1627,33 @@ InitConstructor(JSContext* cx, HandleObj
     if (!LinkConstructorAndPrototype(cx, ctor, proto))
         return false;
 
     RootedId id(cx, AtomToId(className));
     RootedValue ctorValue(cx, ObjectValue(*ctor));
     return DefineProperty(cx, wasm, id, ctorValue, nullptr, nullptr, 0);
 }
 
+static bool
+InitErrorClass(JSContext* cx, HandleObject wasm, const char* name, JSExnType exn)
+{
+    Handle<GlobalObject*> global = cx->global();
+    RootedObject proto(cx, GlobalObject::getOrCreateCustomErrorPrototype(cx, global, exn));
+    if (!proto)
+        return false;
+
+    RootedAtom className(cx, Atomize(cx, name, strlen(name)));
+    if (!className)
+        return false;
+
+    RootedId id(cx, AtomToId(className));
+    RootedValue ctorValue(cx, global->getConstructor(GetExceptionProtoKey(exn)));
+    return DefineProperty(cx, wasm, id, ctorValue, nullptr, nullptr, 0);
+}
+
 JSObject*
 js::InitWebAssemblyClass(JSContext* cx, HandleObject obj)
 {
     MOZ_RELEASE_ASSERT(HasCompilerSupport(cx));
     MOZ_ASSERT(cx->options().wasm());
 
     Handle<GlobalObject*> global = obj.as<GlobalObject>();
     MOZ_ASSERT(!global->isStandardClassResolved(JSProto_WebAssembly));
@@ -1663,16 +1677,20 @@ js::InitWebAssemblyClass(JSContext* cx, 
     if (!InitConstructor<WasmModuleObject>(cx, wasm, "Module", &moduleProto))
         return nullptr;
     if (!InitConstructor<WasmInstanceObject>(cx, wasm, "Instance", &instanceProto))
         return nullptr;
     if (!InitConstructor<WasmMemoryObject>(cx, wasm, "Memory", &memoryProto))
         return nullptr;
     if (!InitConstructor<WasmTableObject>(cx, wasm, "Table", &tableProto))
         return nullptr;
+    if (!InitErrorClass(cx, wasm, "CompileError", JSEXN_WASMCOMPILEERROR))
+        return nullptr;
+    if (!InitErrorClass(cx, wasm, "RuntimeError", JSEXN_WASMRUNTIMEERROR))
+        return nullptr;
 
     // Perform the final fallible write of the WebAssembly object to a global
     // object property at the end. Only after that succeeds write all the
     // constructor and prototypes to the JSProto slots. This ensures that
     // initialization is atomic since a failed initialization can be retried.
 
     if (!JS_DefineProperty(cx, global, js_WebAssembly_str, wasm, JSPROP_RESOLVING))
         return nullptr;
--- a/js/src/asmjs/WasmTypes.cpp
+++ b/js/src/asmjs/WasmTypes.cpp
@@ -72,17 +72,17 @@ extern MOZ_EXPORT int64_t
 __aeabi_uidivmod(int, int);
 
 }
 #endif
 
 static void
 WasmReportOverRecursed()
 {
-    ReportOverRecursed(JSRuntime::innermostWasmActivation()->cx(), JSMSG_WASM_OVERRECURSED);
+    ReportOverRecursed(JSRuntime::innermostWasmActivation()->cx());
 }
 
 static bool
 WasmHandleExecutionInterrupt()
 {
     WasmActivation* activation = JSRuntime::innermostWasmActivation();
     bool success = CheckForInterrupt(activation->cx());
 
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -596,28 +596,25 @@ WasmBinaryToText(JSContext* cx, unsigned
             return false;
         bool match;
         if (!JS_StringEqualsAscii(cx, opt, "experimental", &match))
             return false;
         experimental = match;
     }
 
     StringBuffer buffer(cx);
-    if (experimental) {
-        if (!wasm::BinaryToExperimentalText(cx, bytes, length, buffer, wasm::ExperimentalTextFormatting())) {
-            if (!cx->isExceptionPending())
-                JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_FAIL, "print error");
-            return false;
-        }
-    } else {
-        if (!wasm::BinaryToText(cx, bytes, length, buffer)) {
-            if (!cx->isExceptionPending())
-                JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_FAIL, "print error");
-            return false;
-        }
+    bool ok;
+    if (experimental)
+        ok = wasm::BinaryToExperimentalText(cx, bytes, length, buffer, wasm::ExperimentalTextFormatting());
+    else
+        ok = wasm::BinaryToText(cx, bytes, length, buffer);
+    if (!ok) {
+        if (!cx->isExceptionPending())
+            JS_ReportError(cx, "wasm binary to text print error");
+        return false;
     }
 
     JSString* result = buffer.finishString();
     if (!result)
         return false;
 
     args.rval().setString(result);
     return true;
--- a/js/src/jit-test/lib/wasm.js
+++ b/js/src/jit-test/lib/wasm.js
@@ -18,20 +18,20 @@ function wasmEvalText(str, imports) {
 
     return new WebAssembly.Instance(m, imports);
 }
 
 function wasmValidateText(str) {
     assertEq(WebAssembly.validate(wasmTextToBinary(str)), true);
 }
 
-function wasmFailValidateText(str, errorType, pattern) {
+function wasmFailValidateText(str, pattern) {
     let binary = wasmTextToBinary(str);
     assertEq(WebAssembly.validate(binary), false);
-    assertErrorMessage(() => new WebAssembly.Module(binary), errorType, pattern);
+    assertErrorMessage(() => new WebAssembly.Module(binary), WebAssembly.CompileError, pattern);
 }
 
 function mismatchError(actual, expect) {
     var str = `type mismatch: expression has type ${actual} but expected ${expect}`;
     return RegExp(str);
 }
 
 function jsify(wasmVal) {
--- a/js/src/jit-test/tests/wasm/basic.js
+++ b/js/src/jit-test/tests/wasm/basic.js
@@ -24,18 +24,18 @@ assertEq(desc.enumerable, true);
 assertEq(desc.configurable, true);
 assertEq(desc.value(), undefined);
 
 wasmValidateText('(module (func) (func) (export "a" 0))');
 wasmValidateText('(module (func) (func) (export "a" 1))');
 wasmValidateText('(module (func $a) (func $b) (export "a" $a) (export "b" $b))');
 wasmValidateText('(module (func $a) (func $b) (export "a" $a) (export "b" $b))');
 
-wasmFailValidateText('(module (func) (export "a" 1))', TypeError, /exported function index out of bounds/);
-wasmFailValidateText('(module (func) (func) (export "a" 2))', TypeError, /exported function index out of bounds/);
+wasmFailValidateText('(module (func) (export "a" 1))', /exported function index out of bounds/);
+wasmFailValidateText('(module (func) (func) (export "a" 2))', /exported function index out of bounds/);
 
 var o = wasmEvalText('(module (func) (export "a" 0) (export "b" 0))').exports;
 assertEq(Object.getOwnPropertyNames(o).sort().toString(), "a,b");
 assertEq(o.a.name, "wasm-function[0]");
 assertEq(o.b.name, "wasm-function[0]");
 assertEq(o.a === o.b, true);
 
 var o = wasmEvalText('(module (func) (func) (export "a" 0) (export "b" 1))').exports;
@@ -46,24 +46,24 @@ assertEq(o.a === o.b, false);
 
 var o = wasmEvalText('(module (func (result i32) (i32.const 1)) (func (result i32) (i32.const 2)) (export "a" 0) (export "b" 1))').exports;
 assertEq(o.a(), 1);
 assertEq(o.b(), 2);
 var o = wasmEvalText('(module (func (result i32) (i32.const 1)) (func (result i32) (i32.const 2)) (export "a" 1) (export "b" 0))').exports;
 assertEq(o.a(), 2);
 assertEq(o.b(), 1);
 
-assertErrorMessage(() => wasmEvalText('(module (func) (export "a" 0) (export "a" 0))'), TypeError, /duplicate export/);
-assertErrorMessage(() => wasmEvalText('(module (func) (func) (export "a" 0) (export "a" 1))'), TypeError, /duplicate export/);
+wasmFailValidateText('(module (func) (export "a" 0) (export "a" 0))', /duplicate export/);
+wasmFailValidateText('(module (func) (func) (export "a" 0) (export "a" 1))', /duplicate export/);
 
 // ----------------------------------------------------------------------------
 // signatures
 
-wasmFailValidateText('(module (func (result i32)))', TypeError, mismatchError("void", "i32"));
-wasmFailValidateText('(module (func (result i32) (nop)))', TypeError, mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32)))', mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32) (nop)))', mismatchError("void", "i32"));
 
 wasmValidateText('(module (func (nop)))');
 wasmValidateText('(module (func (result i32) (i32.const 42)))');
 wasmValidateText('(module (func (param i32)))');
 wasmValidateText('(module (func (param i32) (result i32) (i32.const 42)))');
 wasmValidateText('(module (func (result i32) (param i32) (i32.const 42)))');
 wasmValidateText('(module (func (param f32)))');
 wasmValidateText('(module (func (param f64)))');
@@ -83,20 +83,21 @@ assertEqI64(wasmEvalText('(module (func 
 assertEqI64(wasmEvalText('(module (func (param i64) (result i64) (get_local 0)) (export "" 0))').exports[""]({ low: 0x7fffffff, high: 0x12340000}),
             {low: 0x7fffffff, high: 0x12340000});
 assertEqI64(wasmEvalText('(module (func (param i64) (result i64) (i64.add (get_local 0) (i64.const 1))) (export "" 0))').exports[""]({ low: 0xffffffff, high: 0x12340000}), {low: 0x0, high: 0x12340001});
 setJitCompilerOption('wasm.test-mode', 0);
 
 // ----------------------------------------------------------------------------
 // imports
 
-assertErrorMessage(() => wasmEvalText('(module (import "a" "b"))', 1), Error, /second argument, if present, must be an object/);
-assertErrorMessage(() => wasmEvalText('(module (import "a" "b"))', null), Error, /second argument, if present, must be an object/);
+const noImportObj = "second argument must be an object";
 
-const noImportObj = /no import object given/;
+assertErrorMessage(() => wasmEvalText('(module (import "a" "b"))', 1), TypeError, noImportObj);
+assertErrorMessage(() => wasmEvalText('(module (import "a" "b"))', null), TypeError, noImportObj);
+
 const notObject = /import object field is not an Object/;
 const notFunction = /import object field is not a Function/;
 
 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);
@@ -121,17 +122,17 @@ wasmEvalText('(module (import "a" "" (re
 wasmEvalText('(module (import "a" "" (result f64)))', {a:{"":()=>{}}});
 wasmEvalText('(module (import $foo "a" "" (result f64)))', {a:{"":()=>{}}});
 
 // ----------------------------------------------------------------------------
 // memory
 
 wasmValidateText('(module (memory 0))');
 wasmValidateText('(module (memory 1))');
-wasmFailValidateText('(module (memory 65536))', TypeError, /initial memory size too big/);
+wasmFailValidateText('(module (memory 65536))', /initial memory size too big/);
 
 // May OOM, but must not crash:
 try {
     wasmEvalText('(module (memory 65535))');
 } catch (e) {
     assertEq(String(e).indexOf("out of memory") != -1 ||
              String(e).indexOf("memory size too big") != -1, true);
 }
@@ -161,97 +162,97 @@ var buf = wasmEvalText('(module (memory 
 assertEq(new Uint8Array(buf)[0], 'a'.charCodeAt(0));
 assertEq(new Uint8Array(buf)[1], 0);
 assertEq(new Uint8Array(buf)[2], 'b'.charCodeAt(0));
 
 var buf = wasmEvalText('(module (memory 1) (data 65535 "c") (export "memory" memory))').exports.memory.buffer;
 assertEq(new Uint8Array(buf)[0], 0);
 assertEq(new Uint8Array(buf)[65535], 'c'.charCodeAt(0));
 
-wasmFailValidateText('(module (memory 1) (data 65536 "a") (export "memory" memory))', TypeError, /data segment does not fit/);
-wasmFailValidateText('(module (memory 1) (data 65535 "ab") (export "memory" memory))', TypeError, /data segment does not fit/);
+wasmFailValidateText('(module (memory 1) (data 65536 "a") (export "memory" memory))', /data segment does not fit/);
+wasmFailValidateText('(module (memory 1) (data 65535 "ab") (export "memory" memory))', /data segment does not fit/);
 
 // ----------------------------------------------------------------------------
 // locals
 
 assertEq(wasmEvalText('(module (func (param i32) (result i32) (get_local 0)) (export "" 0))').exports[""](), 0);
 assertEq(wasmEvalText('(module (func (param i32) (result i32) (get_local 0)) (export "" 0))').exports[""](42), 42);
 assertEq(wasmEvalText('(module (func (param i32) (param i32) (result i32) (get_local 0)) (export "" 0))').exports[""](42, 43), 42);
 assertEq(wasmEvalText('(module (func (param i32) (param i32) (result i32) (get_local 1)) (export "" 0))').exports[""](42, 43), 43);
 
-wasmFailValidateText('(module (func (get_local 0)))', TypeError, /get_local index out of range/);
+wasmFailValidateText('(module (func (get_local 0)))', /get_local index out of range/);
 wasmValidateText('(module (func (local i32)))');
 wasmValidateText('(module (func (local i32) (local f32)))');
 assertEq(wasmEvalText('(module (func (result i32) (local i32) (get_local 0)) (export "" 0))').exports[""](), 0);
-wasmFailValidateText('(module (func (result f32) (local i32) (get_local 0)))', TypeError, mismatchError("i32", "f32"));
-wasmFailValidateText('(module (func (result i32) (local f32) (get_local 0)))', TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (result f32) (local i32) (get_local 0)))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (result i32) (local f32) (get_local 0)))', mismatchError("f32", "i32"));
 assertEq(wasmEvalText('(module (func (result i32) (param i32) (local f32) (get_local 0)) (export "" 0))').exports[""](), 0);
 assertEq(wasmEvalText('(module (func (result f32) (param i32) (local f32) (get_local 1)) (export "" 0))').exports[""](), 0);
-wasmFailValidateText('(module (func (result f32) (param i32) (local f32) (get_local 0)))', TypeError, mismatchError("i32", "f32"));
-wasmFailValidateText('(module (func (result i32) (param i32) (local f32) (get_local 1)))', TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (result f32) (param i32) (local f32) (get_local 0)))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (result i32) (param i32) (local f32) (get_local 1)))', mismatchError("f32", "i32"));
 
-wasmFailValidateText('(module (func (set_local 0 (i32.const 0))))', TypeError, /set_local index out of range/);
+wasmFailValidateText('(module (func (set_local 0 (i32.const 0))))', /set_local index out of range/);
 wasmValidateText('(module (func (local i32) (set_local 0 (i32.const 0))))');
-wasmFailValidateText('(module (func (local f32) (set_local 0 (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
-wasmFailValidateText('(module (func (local f32) (set_local 0 (nop))))', TypeError, /popping value from empty stack/);
-wasmFailValidateText('(module (func (local i32) (local f32) (set_local 0 (get_local 1))))', TypeError, mismatchError("f32", "i32"));
-wasmFailValidateText('(module (func (local i32) (local f32) (set_local 1 (get_local 0))))', TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (local f32) (set_local 0 (i32.const 0))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (local f32) (set_local 0 (nop))))', /popping value from empty stack/);
+wasmFailValidateText('(module (func (local i32) (local f32) (set_local 0 (get_local 1))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (local i32) (local f32) (set_local 1 (get_local 0))))', mismatchError("i32", "f32"));
 wasmValidateText('(module (func (local i32) (local f32) (set_local 0 (get_local 0))))');
 wasmValidateText('(module (func (local i32) (local f32) (set_local 1 (get_local 1))))');
 assertEq(wasmEvalText('(module (func (result i32) (local i32) (tee_local 0 (i32.const 42))) (export "" 0))').exports[""](), 42);
 assertEq(wasmEvalText('(module (func (result i32) (local i32) (tee_local 0 (get_local 0))) (export "" 0))').exports[""](), 0);
 
 assertEq(wasmEvalText('(module (func (param $a i32) (result i32) (get_local $a)) (export "" 0))').exports[""](), 0);
 assertEq(wasmEvalText('(module (func (param $a i32) (local $b i32) (result i32) (block i32 (set_local $b (get_local $a)) (get_local $b))) (export "" 0))').exports[""](42), 42);
 
 wasmValidateText('(module (func (local i32) (local $a f32) (set_local 0 (i32.const 1)) (set_local $a (f32.const nan))))');
 
 // ----------------------------------------------------------------------------
 // blocks
 
 assertEq(wasmEvalText('(module (func (block )) (export "" 0))').exports[""](), undefined);
 
-wasmFailValidateText('(module (func (result i32) (block )))', TypeError, mismatchError("void", "i32"));
-wasmFailValidateText('(module (func (result i32) (block (block ))))', TypeError, mismatchError("void", "i32"));
-wasmFailValidateText('(module (func (local i32) (set_local 0 (block ))))', TypeError, /popping value from empty stack/);
+wasmFailValidateText('(module (func (result i32) (block )))', mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32) (block (block ))))', mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (local i32) (set_local 0 (block ))))', /popping value from empty stack/);
 
 assertEq(wasmEvalText('(module (func (block (block ))) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (result i32) (block i32 (i32.const 42))) (export "" 0))').exports[""](), 42);
 assertEq(wasmEvalText('(module (func (result i32) (block i32 (block i32 (i32.const 42)))) (export "" 0))').exports[""](), 42);
-wasmFailValidateText('(module (func (result f32) (block i32 (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (result f32) (block i32 (i32.const 0))))', mismatchError("i32", "f32"));
 
 assertEq(wasmEvalText('(module (func (result i32) (block i32 (drop (i32.const 13)) (block i32 (i32.const 42)))) (export "" 0))').exports[""](), 42);
-wasmFailValidateText('(module (func (result f32) (param f32) (block i32 (drop (get_local 0)) (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (result f32) (param f32) (block i32 (drop (get_local 0)) (i32.const 0))))', mismatchError("i32", "f32"));
 
 assertEq(wasmEvalText('(module (func (result i32) (local i32) (set_local 0 (i32.const 42)) (get_local 0)) (export "" 0))').exports[""](), 42);
 
 // ----------------------------------------------------------------------------
 // calls
 
-wasmFailValidateText('(module (func (nop)) (func (call 0 (i32.const 0))))', TypeError, /unused values not explicitly dropped by end of block/);
+wasmFailValidateText('(module (func (nop)) (func (call 0 (i32.const 0))))', /unused values not explicitly dropped by end of block/);
 
-wasmFailValidateText('(module (func (param i32) (nop)) (func (call 0)))', TypeError, /peeking at value from outside block/);
-wasmFailValidateText('(module (func (param f32) (nop)) (func (call 0 (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
-wasmFailValidateText('(module (func (nop)) (func (call 3)))', TypeError, /callee index out of range/);
+wasmFailValidateText('(module (func (param i32) (nop)) (func (call 0)))', /peeking at value from outside block/);
+wasmFailValidateText('(module (func (param f32) (nop)) (func (call 0 (i32.const 0))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (nop)) (func (call 3)))', /callee index out of range/);
 
 wasmValidateText('(module (func (nop)) (func (call 0)))');
 wasmValidateText('(module (func (param i32) (nop)) (func (call 0 (i32.const 0))))');
 
 assertEq(wasmEvalText('(module (func (result i32) (i32.const 42)) (func (result i32) (call 0)) (export "" 1))').exports[""](), 42);
 assertThrowsInstanceOf(() => wasmEvalText('(module (func (call 0)) (export "" 0))').exports[""](), InternalError);
 assertThrowsInstanceOf(() => wasmEvalText('(module (func (call 1)) (func (call 0)) (export "" 0))').exports[""](), InternalError);
 
 wasmValidateText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (f32.const nan))))');
-wasmFailValidateText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (i32.const 0))))', mismatchError("i32", "f32"));
 
-wasmFailValidateText('(module (import "a" "") (func (call_import 0 (i32.const 0))))', TypeError, /unused values not explicitly dropped by end of block/);
-wasmFailValidateText('(module (import "a" "" (param i32)) (func (call_import 0)))', TypeError, /peeking at value from outside block/);
-wasmFailValidateText('(module (import "a" "" (param f32)) (func (call_import 0 (i32.const 0))))', TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (import "a" "") (func (call_import 0 (i32.const 0))))', /unused values not explicitly dropped by end of block/);
+wasmFailValidateText('(module (import "a" "" (param i32)) (func (call_import 0)))', /peeking at value from outside block/);
+wasmFailValidateText('(module (import "a" "" (param f32)) (func (call_import 0 (i32.const 0))))', mismatchError("i32", "f32"));
 
-assertErrorMessage(() => wasmEvalText('(module (import "a" "") (func (call_import 1)))'), TypeError, /no import object given/);
+assertErrorMessage(() => wasmEvalText('(module (import "a" "") (func (call_import 1)))'), TypeError, noImportObj);
 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 "" 1))', {"":{a:()=>{ return v; }}}).exports[""](), Math.fround(v));
     wasmEvalText('(module (import "" "a" (param f32)) (func (param f32) (call_import 0 (get_local 0))) (export "" 1))', {"":{a:x=>{ assertEq(Math.fround(v), x); }}}).exports[""](v);
 }
 checkF32CallImport(13.37);
@@ -357,17 +358,17 @@ if (typeof evaluate === 'function')
          )
          (get_local 1)
         )
     (export "" 1))`, imp).exports[""](), { low: 1337, high: 0x12345678 });
 
     setJitCompilerOption('wasm.test-mode', 0);
 }
 
-wasmFailValidateText(`(module (type $t (func)) (func (call_indirect $t (i32.const 0))))`, TypeError, /can't call_indirect without a table/);
+wasmFailValidateText(`(module (type $t (func)) (func (call_indirect $t (i32.const 0))))`, /can't call_indirect without a table/);
 
 var {v2i, i2i, i2v} = wasmEvalText(`(module
     (type (func (result i32)))
     (type (func (param i32) (result i32)))
     (type (func (param i32)))
     (func (type 0) (i32.const 13))
     (func (type 0) (i32.const 42))
     (func (type 1) (i32.add (get_local 0) (i32.const 1)))
@@ -440,24 +441,24 @@ for (bad of [6, 7, 100, Math.pow(2,31)-1
 
 wasmValidateText('(module (func $foo (nop)) (func (call $foo)))');
 wasmValidateText('(module (func (call $foo)) (func $foo (nop)))');
 wasmValidateText('(module (import $bar "" "a") (func (call_import $bar)) (func $foo (nop)))');
 
 // ----------------------------------------------------------------------------
 // select
 
-wasmFailValidateText('(module (func (select (i32.const 0) (i32.const 0) (f32.const 0))))', TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (select (i32.const 0) (i32.const 0) (f32.const 0))))', mismatchError("f32", "i32"));
 
-wasmFailValidateText('(module (func (select (i32.const 0) (f32.const 0) (i32.const 0))) (export "" 0))', TypeError, /select operand types must match/);
-wasmFailValidateText('(module (func (select (block ) (i32.const 0) (i32.const 0))) (export "" 0))', TypeError, /popping value from empty stack/);
+wasmFailValidateText('(module (func (select (i32.const 0) (f32.const 0) (i32.const 0))) (export "" 0))', /select operand types must match/);
+wasmFailValidateText('(module (func (select (block ) (i32.const 0) (i32.const 0))) (export "" 0))', /popping value from empty stack/);
 assertEq(wasmEvalText('(module (func (select (return) (i32.const 0) (i32.const 0))) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (i32.add (i32.const 0) (select (return) (i32.const 0) (i32.const 0)))) (export "" 0))').exports[""](), undefined);
-wasmFailValidateText('(module (func (select (if i32 (i32.const 1) (i32.const 0) (f32.const 0)) (i32.const 0) (i32.const 0))) (export "" 0))', TypeError, mismatchError("f32", "i32"));
-wasmFailValidateText('(module (func) (func (select (call 0) (call 0) (i32.const 0))) (export "" 0))', TypeError, /popping value from empty stack/);
+wasmFailValidateText('(module (func (select (if i32 (i32.const 1) (i32.const 0) (f32.const 0)) (i32.const 0) (i32.const 0))) (export "" 0))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func) (func (select (call 0) (call 0) (i32.const 0))) (export "" 0))', /popping value from empty stack/);
 
 (function testSideEffects() {
 
 var numT = 0;
 var numF = 0;
 
 var imports = {"": {
     ifTrue: () => 1 + numT++,
--- a/js/src/jit-test/tests/wasm/binary.js
+++ b/js/src/jit-test/tests/wasm/binary.js
@@ -1,11 +1,13 @@
 // |jit-test| test-also-wasm-baseline
 load(libdir + "wasm.js");
 
+const CompileError = WebAssembly.CompileError;
+
 // MagicNumber = 0x6d736100;
 const magic0 = 0x00;  // '\0'
 const magic1 = 0x61;  // 'a'
 const magic2 = 0x73;  // 's'
 const magic3 = 0x6d;  // 'm'
 
 // EncodingVersion (temporary; to be set to 1 at some point before release)
 const ver0 = (Wasm.experimentalVersion >>>  0) & 0xff;
@@ -103,57 +105,57 @@ function varS32(s32) {
     } while (s32 != 0 && s32 != -1);
     return bytes;
 }
 
 const U32MAX_LEB = [255, 255, 255, 255, 15];
 
 const wasmEval = (code, imports) => new WebAssembly.Instance(new WebAssembly.Module(code), imports).exports;
 
-assertErrorMessage(() => wasmEval(toU8([])), TypeError, magicError);
-assertErrorMessage(() => wasmEval(toU8([42])), TypeError, magicError);
-assertErrorMessage(() => wasmEval(toU8([magic0, magic1, magic2])), TypeError, magicError);
-assertErrorMessage(() => wasmEval(toU8([1,2,3,4])), TypeError, magicError);
-assertErrorMessage(() => wasmEval(toU8([magic0, magic1, magic2, magic3])), TypeError, versionError(0x6d736100));
-assertErrorMessage(() => wasmEval(toU8([magic0, magic1, magic2, magic3, 1])), TypeError, versionError(0x6d736100));
-assertErrorMessage(() => wasmEval(toU8([magic0, magic1, magic2, magic3, ver0])), TypeError, versionError(0x6d736100));
-assertErrorMessage(() => wasmEval(toU8([magic0, magic1, magic2, magic3, ver0, ver1, ver2])), TypeError, versionError(0x6d736100));
+assertErrorMessage(() => wasmEval(toU8([])), CompileError, magicError);
+assertErrorMessage(() => wasmEval(toU8([42])), CompileError, magicError);
+assertErrorMessage(() => wasmEval(toU8([magic0, magic1, magic2])), CompileError, magicError);
+assertErrorMessage(() => wasmEval(toU8([1,2,3,4])), CompileError, magicError);
+assertErrorMessage(() => wasmEval(toU8([magic0, magic1, magic2, magic3])), CompileError, versionError(0x6d736100));
+assertErrorMessage(() => wasmEval(toU8([magic0, magic1, magic2, magic3, 1])), CompileError, versionError(0x6d736100));
+assertErrorMessage(() => wasmEval(toU8([magic0, magic1, magic2, magic3, ver0])), CompileError, versionError(0x6d736100));
+assertErrorMessage(() => wasmEval(toU8([magic0, magic1, magic2, magic3, ver0, ver1, ver2])), CompileError, versionError(0x6d736100));
 
 function moduleHeaderThen(...rest) {
     return [magic0, magic1, magic2, magic3, ver0, ver1, ver2, ver3, ...rest];
 }
 
 var o = wasmEval(toU8(moduleHeaderThen()));
 assertEq(Object.getOwnPropertyNames(o).length, 0);
 
 // unfinished known sections
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(typeId))), TypeError, sectionError("type"));
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(importId))), TypeError, sectionError("import"));
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(functionId))), TypeError, sectionError("function"));
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(tableId))), TypeError, sectionError("table"));
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(memoryId))), TypeError, sectionError("memory"));
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(globalId))), TypeError, sectionError("global"));
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(exportId))), TypeError, sectionError("export"));
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(startId))), TypeError, sectionError("start"));
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(elemId))), TypeError, sectionError("elem"));
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(codeId))), TypeError, sectionError("code"));
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(dataId))), TypeError, sectionError("data"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(typeId))), CompileError, sectionError("type"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(importId))), CompileError, sectionError("import"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(functionId))), CompileError, sectionError("function"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(tableId))), CompileError, sectionError("table"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(memoryId))), CompileError, sectionError("memory"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(globalId))), CompileError, sectionError("global"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(exportId))), CompileError, sectionError("export"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(startId))), CompileError, sectionError("start"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(elemId))), CompileError, sectionError("elem"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(codeId))), CompileError, sectionError("code"));
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(dataId))), CompileError, sectionError("data"));
 
 // unknown sections are unconditionally rejected
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(42))), TypeError, unknownSection);
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(42, 0))), TypeError, unknownSection);
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(42, 1, 0))), TypeError, unknownSection);
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(42))), CompileError, unknownSection);
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(42, 0))), CompileError, unknownSection);
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(42, 1, 0))), CompileError, unknownSection);
 
 // user sections have special rules
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0))), TypeError, sectionError("user-defined"));  // no length
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0, 0))), TypeError, sectionError("user-defined"));  // no id
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0, 0, 0))), TypeError, sectionError("user-defined"));  // payload too small to have id length
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0, 1, 1))), TypeError, sectionError("user-defined"));  // id not present
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0, 1, 1, 65))), TypeError, sectionError("user-defined"));  // id length doesn't fit in section
-assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0, 1, 0, 0))), TypeError, sectionError("user-defined"));  // second, unfinished user-defined section
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0))), CompileError, sectionError("user-defined"));  // no length
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0, 0))), CompileError, sectionError("user-defined"));  // no id
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0, 0, 0))), CompileError, sectionError("user-defined"));  // payload too small to have id length
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0, 1, 1))), CompileError, sectionError("user-defined"));  // id not present
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0, 1, 1, 65))), CompileError, sectionError("user-defined"));  // id length doesn't fit in section
+assertErrorMessage(() => wasmEval(toU8(moduleHeaderThen(0, 1, 0, 0))), CompileError, sectionError("user-defined"));  // second, unfinished user-defined section
 wasmEval(toU8(moduleHeaderThen(0, 1, 0)));  // empty id
 wasmEval(toU8(moduleHeaderThen(0, 1, 0,  0, 1, 0)));  // 2x empty id
 wasmEval(toU8(moduleHeaderThen(0, 2, 1, 65)));  // id = "A"
 
 function string(name) {
     var nameBytes = name.split('').map(c => {
         var code = c.charCodeAt(0);
         assertEq(code < 128, true); // TODO
@@ -293,92 +295,92 @@ function nameSection(elems) {
 function userDefinedSection(name, ...body) {
     return { name: userDefinedId, body: [...string(name), ...body] };
 }
 
 const v2vSig = {args:[], ret:VoidCode};
 const i2vSig = {args:[I32Code], ret:VoidCode};
 const v2vBody = funcBody({locals:[], body:[]});
 
-assertErrorMessage(() => wasmEval(moduleWithSections([ {name: typeId, body: U32MAX_LEB } ])), TypeError, /too many signatures/);
-assertErrorMessage(() => wasmEval(moduleWithSections([ {name: typeId, body: [1, 0], } ])), TypeError, /expected function form/);
-assertErrorMessage(() => wasmEval(moduleWithSections([ {name: typeId, body: [1, FunctionConstructorCode, ...U32MAX_LEB], } ])), TypeError, /too many arguments in signature/);
+assertErrorMessage(() => wasmEval(moduleWithSections([ {name: typeId, body: U32MAX_LEB } ])), CompileError, /too many signatures/);
+assertErrorMessage(() => wasmEval(moduleWithSections([ {name: typeId, body: [1, 0], } ])), CompileError, /expected function form/);
+assertErrorMessage(() => wasmEval(moduleWithSections([ {name: typeId, body: [1, FunctionConstructorCode, ...U32MAX_LEB], } ])), CompileError, /too many arguments in signature/);
 
-assertThrowsInstanceOf(() => wasmEval(moduleWithSections([{name: typeId, body: [1]}])), TypeError);
-assertThrowsInstanceOf(() => wasmEval(moduleWithSections([{name: typeId, body: [1, 1, 0]}])), TypeError);
+assertThrowsInstanceOf(() => wasmEval(moduleWithSections([{name: typeId, body: [1]}])), CompileError);
+assertThrowsInstanceOf(() => wasmEval(moduleWithSections([{name: typeId, body: [1, 1, 0]}])), CompileError);
 
 wasmEval(moduleWithSections([sigSection([])]));
 wasmEval(moduleWithSections([sigSection([v2vSig])]));
 wasmEval(moduleWithSections([sigSection([i2vSig])]));
 wasmEval(moduleWithSections([sigSection([v2vSig, i2vSig])]));
 
-assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([{args:[], ret:100}])])), TypeError, /bad type/);
-assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([{args:[100], ret:VoidCode}])])), TypeError, /bad type/);
+assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([{args:[], ret:100}])])), CompileError, /bad type/);
+assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([{args:[100], ret:VoidCode}])])), CompileError, /bad type/);
 
-assertThrowsInstanceOf(() => wasmEval(moduleWithSections([sigSection([]), declSection([0])])), TypeError, /signature index out of range/);
-assertThrowsInstanceOf(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([1])])), TypeError, /signature index out of range/);
-assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0])])), TypeError, /expected function bodies/);
+assertThrowsInstanceOf(() => wasmEval(moduleWithSections([sigSection([]), declSection([0])])), CompileError, /signature index out of range/);
+assertThrowsInstanceOf(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([1])])), CompileError, /signature index out of range/);
+assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0])])), CompileError, /expected function bodies/);
 wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([v2vBody])]));
 
-assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([v2vBody.concat(v2vBody)])])), TypeError, /byte size mismatch in code section/);
+assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([v2vBody.concat(v2vBody)])])), CompileError, /byte size mismatch in code section/);
 
-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/);
+assertThrowsInstanceOf(() => wasmEval(moduleWithSections([sigSection([v2vSig]), {name: importId, body:[]}])), CompileError);
+assertErrorMessage(() => wasmEval(moduleWithSections([importSection([{sigIndex:0, module:"a", func:"b"}])])), CompileError, /signature index out of range/);
+assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), importSection([{sigIndex:1, module:"a", func:"b"}])])), CompileError, /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:""}]),
     declSection([0]),
     bodySection([v2vBody])
 ]), {a:{"":()=>{}}});
 
-assertErrorMessage(() => wasmEval(moduleWithSections([ {name: dataId, body: [], } ])), TypeError, /data section requires a memory section/);
+assertErrorMessage(() => wasmEval(moduleWithSections([ {name: dataId, body: [], } ])), CompileError, /data section requires a memory section/);
 
 wasmEval(moduleWithSections([tableSection(0)]));
 wasmEval(moduleWithSections([elemSection([])]));
 wasmEval(moduleWithSections([tableSection(0), elemSection([])]));
 wasmEval(moduleWithSections([tableSection(1), elemSection([{offset:1, elems:[]}])]));
-assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(1), elemSection([{offset:0, elems:[0]}])])), TypeError, /table element out of range/);
-assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(0), elemSection([{offset:0, elems:[0]}])])), TypeError, /element segment does not fit/);
-assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(1), elemSection([{offset:1, elems:[0]}])])), TypeError, /element segment does not fit/);
-assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(1), elemSection([{offset:0, elems:[0,0]}])])), TypeError, /element segment does not fit/);
-assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(0), elemSection([{offset:1, elems:[]}])])), TypeError, /element segment does not fit/);
-assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(0), elemSection([{offset:-1, elems:[]}])])), TypeError, /element segment does not fit/);
+assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(1), elemSection([{offset:0, elems:[0]}])])), CompileError, /table element out of range/);
+assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(0), elemSection([{offset:0, elems:[0]}])])), CompileError, /element segment does not fit/);
+assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(1), elemSection([{offset:1, elems:[0]}])])), CompileError, /element segment does not fit/);
+assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(1), elemSection([{offset:0, elems:[0,0]}])])), CompileError, /element segment does not fit/);
+assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(0), elemSection([{offset:1, elems:[]}])])), CompileError, /element segment does not fit/);
+assertErrorMessage(() => wasmEval(moduleWithSections([tableSection(0), elemSection([{offset:-1, elems:[]}])])), CompileError, /element segment does not fit/);
 wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), tableSection(1), elemSection([{offset:0, elems:[0]}]), bodySection([v2vBody])]));
 wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), tableSection(2), elemSection([{offset:0, elems:[0,0]}]), bodySection([v2vBody])]));
-assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), tableSection(2), elemSection([{offset:0, elems:[0,1]}]), bodySection([v2vBody])])), TypeError, /table element out of range/);
+assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), tableSection(2), elemSection([{offset:0, elems:[0,1]}]), bodySection([v2vBody])])), CompileError, /table element out of range/);
 wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0,0,0]), tableSection(4), elemSection([{offset:0, elems:[0,1,0,2]}]), bodySection([v2vBody, v2vBody, v2vBody])]));
 wasmEval(moduleWithSections([sigSection([v2vSig,i2vSig]), declSection([0,0,1]), tableSection(3), elemSection([{offset:0,elems:[0,1,2]}]), bodySection([v2vBody, v2vBody, v2vBody])]));
 
 function invalidTableSection0() {
     var body = [];
     body.push(...varU32(0));           // number of tables
     return { name: tableId, body };
 }
 
-assertErrorMessage(() => wasmEval(moduleWithSections([invalidTableSection0()])), TypeError, /number of tables must be exactly one/);
+assertErrorMessage(() => wasmEval(moduleWithSections([invalidTableSection0()])), CompileError, /number of tables must be exactly one/);
 
 wasmEval(moduleWithSections([memorySection(0)]));
 
 function invalidMemorySection0() {
     var body = [];
     body.push(...varU32(0));           // number of memories
     return { name: memoryId, body };
 }
 
-assertErrorMessage(() => wasmEval(moduleWithSections([invalidMemorySection0()])), TypeError, /number of memories must be exactly one/);
+assertErrorMessage(() => wasmEval(moduleWithSections([invalidMemorySection0()])), CompileError, /number of memories must be exactly one/);
 
 // Test early 'end'
 const bodyMismatch = /function body length mismatch/;
-assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:[End]})])])), TypeError, bodyMismatch);
-assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:[Unreachable,End]})])])), TypeError, bodyMismatch);
-assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:[End,Unreachable]})])])), TypeError, bodyMismatch);
+assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:[End]})])])), CompileError, bodyMismatch);
+assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:[Unreachable,End]})])])), CompileError, bodyMismatch);
+assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:[End,Unreachable]})])])), CompileError, bodyMismatch);
 
 // Deep nesting shouldn't crash or even throw.
 var manyBlocks = [];
 for (var i = 0; i < 20000; i++)
     manyBlocks.push(Block, VoidCode, End);
 wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:manyBlocks})])]));
 
 // Ignore errors in name section.
@@ -396,17 +398,17 @@ var bodySec = bodySection([v2vBody]);
 wasmEval(moduleWithSections([userDefSec, sigSec, declSec, bodySec]));
 wasmEval(moduleWithSections([sigSec, userDefSec, declSec, bodySec]));
 wasmEval(moduleWithSections([sigSec, declSec, userDefSec, bodySec]));
 wasmEval(moduleWithSections([sigSec, declSec, bodySec, userDefSec]));
 wasmEval(moduleWithSections([userDefSec, userDefSec, sigSec, declSec, bodySec]));
 wasmEval(moduleWithSections([userDefSec, userDefSec, sigSec, userDefSec, declSec, userDefSec, bodySec]));
 
 // Diagnose nonstandard block signature types.
-assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:[Block, F64Code + 1, End]})])])), TypeError, /unknown block signature type/);
+assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:[Block, F64Code + 1, End]})])])), CompileError, /unknown block signature type/);
 
 // Checking stack trace.
 function runStackTraceTest(namesContent, expectedName) {
     var sections = [
         sigSection([v2vSig]),
         importSection([{sigIndex:0, module:"env", func:"callback"}]),
         declSection([0]),
         exportSection([{funcIndex:1, name: "run"}]),
--- a/js/src/jit-test/tests/wasm/control-flow.js
+++ b/js/src/jit-test/tests/wasm/control-flow.js
@@ -1,30 +1,32 @@
 // |jit-test| test-also-wasm-baseline
 load(libdir + "wasm.js");
 
+const RuntimeError = WebAssembly.RuntimeError;
+
 // ----------------------------------------------------------------------------
 // if
 
 // Condition is an int32
-assertErrorMessage(() => wasmEvalText('(module (func (local f32) (if (get_local 0) (i32.const 1))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (local f32) (if (get_local 0) (i32.const 1) (i32.const 0))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (local f64) (if (get_local 0) (i32.const 1) (i32.const 0))))'), TypeError, mismatchError("f64", "i32"));
+wasmFailValidateText('(module (func (local f32) (if (get_local 0) (i32.const 1))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (local f32) (if (get_local 0) (i32.const 1) (i32.const 0))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (local f64) (if (get_local 0) (i32.const 1) (i32.const 0))))', mismatchError("f64", "i32"));
 wasmEvalText('(module (func (local i32) (if (get_local 0) (nop))) (export "" 0))');
 wasmEvalText('(module (func (local i32) (if (get_local 0) (nop) (nop))) (export "" 0))');
 
 // Expression values types are consistent
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (local f32) (if f32 (i32.const 42) (get_local 0) (i32.const 0))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (local f64) (if i32 (i32.const 42) (i32.const 0) (get_local 0))))'), TypeError, mismatchError("f64", "i32"));
+wasmFailValidateText('(module (func (result i32) (local f32) (if f32 (i32.const 42) (get_local 0) (i32.const 0))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (result i32) (local f64) (if i32 (i32.const 42) (i32.const 0) (get_local 0))))', mismatchError("f64", "i32"));
 assertEq(wasmEvalText('(module (func (result i32) (if i32 (i32.const 42) (i32.const 1) (i32.const 2))) (export "" 0))').exports[""](), 1);
 assertEq(wasmEvalText('(module (func (result i32) (if i32 (i32.const 0) (i32.const 1) (i32.const 2))) (export "" 0))').exports[""](), 2);
 
 // Even if we don't yield, sub expressions types still have to match.
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (if i32 (i32.const 42) (i32.const 1) (get_local 0))) (export "" 0))'), TypeError, mismatchError('f32', 'i32'));
-assertErrorMessage(() => wasmEvalText('(module (func (if i32 (i32.const 42) (i32.const 1) (i32.const 0))) (export "" 0))'), TypeError, /unused values not explicitly dropped by end of block/);
+wasmFailValidateText('(module (func (param f32) (if i32 (i32.const 42) (i32.const 1) (get_local 0))) (export "" 0))', mismatchError('f32', 'i32'));
+wasmFailValidateText('(module (func (if i32 (i32.const 42) (i32.const 1) (i32.const 0))) (export "" 0))', /unused values not explicitly dropped by end of block/);
 assertEq(wasmEvalText('(module (func (drop (if i32 (i32.const 42) (i32.const 1) (i32.const 0)))) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (param f32) (if (i32.const 42) (drop (i32.const 1)) (drop (get_local 0)))) (export "" 0))').exports[""](13.37), undefined);
 
 // Sub-expression values are returned
 assertEq(wasmEvalText(`(module
     (func
         (result i32)
         (if i32
@@ -150,65 +152,65 @@ assertEq(wasmEvalText(`(module
             (call_import 0)
         )
     )
     (export "" 1)
 )`, imports).exports[""](), 42);
 assertEq(counter, 0);
 
 // "if" doesn't return an expression value
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (if i32 (i32.const 42) (i32.const 0))))'), TypeError, /if without else with a result value/);
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (if i32 (i32.const 42) (drop (i32.const 0)))))'), TypeError, mismatchError("void", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (if i32 (i32.const 1) (i32.const 0) (if i32 (i32.const 1) (i32.const 1)))))'), TypeError, /if without else with a result value/);
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (if i32 (i32.const 1) (drop (i32.const 0)) (if (i32.const 1) (drop (i32.const 1))))))'), TypeError, mismatchError("void", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (if i32 (i32.const 1) (i32.const 0) (if i32 (i32.const 1) (i32.const 1)))))'), TypeError, /if without else with a result value/);
-assertErrorMessage(() => wasmEvalText('(module (func (if i32 (i32.const 1) (i32.const 0) (if (i32.const 1) (drop (i32.const 1))))))'), TypeError, mismatchError("void", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (if (i32.const 1) (drop (i32.const 0)) (if i32 (i32.const 1) (i32.const 1)))))'), TypeError, /if without else with a result value/);
+wasmFailValidateText('(module (func (result i32) (if i32 (i32.const 42) (i32.const 0))))', /if without else with a result value/);
+wasmFailValidateText('(module (func (result i32) (if i32 (i32.const 42) (drop (i32.const 0)))))', mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32) (if i32 (i32.const 1) (i32.const 0) (if i32 (i32.const 1) (i32.const 1)))))', /if without else with a result value/);
+wasmFailValidateText('(module (func (result i32) (if i32 (i32.const 1) (drop (i32.const 0)) (if (i32.const 1) (drop (i32.const 1))))))', mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (if i32 (i32.const 1) (i32.const 0) (if i32 (i32.const 1) (i32.const 1)))))', /if without else with a result value/);
+wasmFailValidateText('(module (func (if i32 (i32.const 1) (i32.const 0) (if (i32.const 1) (drop (i32.const 1))))))', mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (if (i32.const 1) (drop (i32.const 0)) (if i32 (i32.const 1) (i32.const 1)))))', /if without else with a result value/);
 wasmEvalText('(module (func (if (i32.const 1) (drop (i32.const 0)) (if (i32.const 1) (drop (i32.const 1))))))');
 
 // ----------------------------------------------------------------------------
 // return
 
 assertEq(wasmEvalText('(module (func (return)) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (result i32) (return (i32.const 1))) (export "" 0))').exports[""](), 1);
 assertEq(wasmEvalText('(module (func (if (return) (i32.const 0))) (export "" 0))').exports[""](), undefined);
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (return)) (export "" 0))'), TypeError, /popping value from empty stack/);
+wasmFailValidateText('(module (func (result i32) (return)) (export "" 0))', /popping value from empty stack/);
 assertEq(wasmEvalText('(module (func (return (i32.const 1))) (export "" 0))').exports[""](), undefined);
-assertErrorMessage(() => wasmEvalText('(module (func (result f32) (return (i32.const 1))) (export "" 0))'), TypeError, mismatchError("i32", "f32"));
-assertThrowsInstanceOf(() => wasmEvalText('(module (func (result i32) (return)) (export "" 0))'), TypeError);
+wasmFailValidateText('(module (func (result f32) (return (i32.const 1))) (export "" 0))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (result i32) (return)) (export "" 0))', /popping value from empty stack/);
 
 // ----------------------------------------------------------------------------
 // br / br_if
 
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (block (br 0))) (export "" 0))'), TypeError, mismatchError("void", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (br 0)) (export "" 0))'), TypeError, /popping value from empty stack/);
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (block (br_if 0 (i32.const 0)))) (export "" 0))'), TypeError, mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32) (block (br 0))) (export "" 0))', mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32) (br 0)) (export "" 0))', /popping value from empty stack/);
+wasmFailValidateText('(module (func (result i32) (block (br_if 0 (i32.const 0)))) (export "" 0))', mismatchError("void", "i32"));
 
 const DEPTH_OUT_OF_BOUNDS = /branch depth exceeds current nesting level/;
 
-assertErrorMessage(() => wasmEvalText('(module (func (br 1)))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (block (br 2))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (loop (br 2))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (if (i32.const 0) (br 2))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (if (i32.const 0) (br 1) (br 2))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (if (i32.const 0) (br 2) (br 1))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (br 1)))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (block (br 2))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (loop (br 2))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (if (i32.const 0) (br 2))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (if (i32.const 0) (br 1) (br 2))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (if (i32.const 0) (br 2) (br 1))))', DEPTH_OUT_OF_BOUNDS);
 
-assertErrorMessage(() => wasmEvalText('(module (func (br_if 1 (i32.const 0))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (block (br_if 2 (i32.const 0)))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (loop (br_if 2 (i32.const 0)))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (br_if 1 (i32.const 0))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (block (br_if 2 (i32.const 0)))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (loop (br_if 2 (i32.const 0)))))', DEPTH_OUT_OF_BOUNDS);
 
-assertErrorMessage(() => wasmEvalText(`(module (func (result i32)
+wasmFailValidateText(`(module (func (result i32)
   (block
     (if
       (br 0)
       (i32.const 0)
       (i32.const 2)
     )
   )
-) (export "" 0))`), TypeError, mismatchError("void", "i32"));
+) (export "" 0))`, mismatchError("void", "i32"));
 
 assertEq(wasmEvalText(`(module (func (block $out (br_if $out (br 0)))) (export "" 0))`).exports[""](), undefined);
 
 assertEq(wasmEvalText('(module (func (br 0)) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (block (br 0))) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (block $l (br $l))) (export "" 0))').exports[""](), undefined);
 
 assertEq(wasmEvalText('(module (func (block (block (br 1)))) (export "" 0))').exports[""](), undefined);
@@ -302,51 +304,51 @@ var isNonZero = wasmEvalText(`(module (f
 ) (export "" 0))`).exports[""];
 
 assertEq(isNonZero(0), 0);
 assertEq(isNonZero(1), 1);
 assertEq(isNonZero(-1), 1);
 
 // branches with values
 // br/br_if and block
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (br 0)))'), TypeError, /popping value from empty stack/);
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (br 0 (f32.const 42))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (block (br 0))))'), TypeError, mismatchError("void", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (block f32 (br 0 (f32.const 42)))))'), TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (result i32) (br 0)))', /popping value from empty stack/);
+wasmFailValidateText('(module (func (result i32) (br 0 (f32.const 42))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (result i32) (block (br 0))))', mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32) (block f32 (br 0 (f32.const 42)))))', mismatchError("f32", "i32"));
 
-assertErrorMessage(() => wasmEvalText(`(module (func (result i32) (param i32) (block (if i32 (get_local 0) (br 0 (i32.const 42))))) (export "" 0))`), TypeError, /if without else with a result value/);
-assertErrorMessage(() => wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (drop (i32.const 42))) (br 0 (f32.const 42)))) (export "" 0))`), TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText(`(module (func (result i32) (param i32) (block (if i32 (get_local 0) (br 0 (i32.const 42))))) (export "" 0))`, /if without else with a result value/);
+wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (drop (i32.const 42))) (br 0 (f32.const 42)))) (export "" 0))`, mismatchError("f32", "i32"));
 
 assertEq(wasmEvalText('(module (func (result i32) (br 0 (i32.const 42)) (i32.const 13)) (export "" 0))').exports[""](), 42);
 assertEq(wasmEvalText('(module (func (result i32) (block i32 (br 0 (i32.const 42)) (i32.const 13))) (export "" 0))').exports[""](), 42);
 
-assertErrorMessage(() => wasmEvalText('(module (func) (func (block i32 (br 0 (call 0)) (i32.const 13))) (export "" 0))'), TypeError, /popping value from empty stack/);
-assertErrorMessage(() => wasmEvalText('(module (func) (func (block i32 (br_if 0 (call 0) (i32.const 1)) (i32.const 13))) (export "" 0))'), TypeError, /popping value from empty stack/);
+wasmFailValidateText('(module (func) (func (block i32 (br 0 (call 0)) (i32.const 13))) (export "" 0))', /popping value from empty stack/);
+wasmFailValidateText('(module (func) (func (block i32 (br_if 0 (call 0) (i32.const 1)) (i32.const 13))) (export "" 0))', /popping value from empty stack/);
 
 var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (drop (i32.const 42))) (i32.const 43))) (export "" 0))`).exports[""];
 assertEq(f(0), 43);
 assertEq(f(1), 43);
 
-assertErrorMessage(() => wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if i32 (get_local 0) (br 0 (i32.const 42))) (i32.const 43))) (export "" 0))`), TypeError, /if without else with a result value/);
+wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if i32 (get_local 0) (br 0 (i32.const 42))) (i32.const 43))) (export "" 0))`, /if without else with a result value/);
 
 var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (br 1 (i32.const 42))) (i32.const 43))) (export "" 0))`).exports[""];
 assertEq(f(0), 43);
 assertEq(f(1), 42);
 
-assertErrorMessage(() => wasmEvalText(`(module (func (result i32) (param i32) (block (br_if 0 (i32.const 42) (get_local 0)) (i32.const 43))) (export "" 0))`), TypeError, /unused values not explicitly dropped by end of block/);
+wasmFailValidateText(`(module (func (result i32) (param i32) (block (br_if 0 (i32.const 42) (get_local 0)) (i32.const 43))) (export "" 0))`, /unused values not explicitly dropped by end of block/);
 
 var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (drop (br_if 0 (i32.const 42) (get_local 0))) (i32.const 43))) (export "" 0))`).exports[""];
 assertEq(f(0), 43);
 assertEq(f(1), 42);
 
 var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (drop (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
 assertEq(f(0), 43);
 assertEq(f(1), 43);
 
-assertErrorMessage(() => wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if i32 (get_local 0) (br 0 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`), TypeError, /if without else with a result value/);
+wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if i32 (get_local 0) (br 0 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`, /if without else with a result value/);
 
 var f = wasmEvalText(`(module (func (result i32) (param i32) (if (get_local 0) (br 1 (i32.const 42))) (br 0 (i32.const 43))) (export "" 0))`).exports[""];
 assertEq(f(0), 43);
 assertEq(f(1), 42);
 
 var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (get_local 0) (br 1 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
 assertEq(f(0), 43);
 assertEq(f(1), 42);
@@ -358,23 +360,23 @@ assertEq(f(1), 42);
 var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (br_if 0 (i32.const 42) (get_local 0)) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
 assertEq(f(0), 43);
 assertEq(f(1), 42);
 
 var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if (get_local 0) (drop (i32.const 99))) (i32.const -1)))) (export "" 0))`).exports[""];
 assertEq(f(0), 0);
 assertEq(f(1), 0);
 
-assertErrorMessage(() => wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if i32 (get_local 0) (br 0 (i32.const 99))) (i32.const -1)))) (export "" 0))`), TypeError, /if without else with a result value/);
+wasmFailValidateText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if i32 (get_local 0) (br 0 (i32.const 99))) (i32.const -1)))) (export "" 0))`, /if without else with a result value/);
 
 var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if (get_local 0) (br 1 (i32.const 99))) (i32.const -1)))) (export "" 0))`).exports[""];
 assertEq(f(0), 0);
 assertEq(f(1), 100);
 
-assertErrorMessage(() => wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block (br_if 0 (i32.const 99) (get_local 0)) (i32.const -1)))) (export "" 0))`), TypeError, /unused values not explicitly dropped by end of block/);
+wasmFailValidateText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block (br_if 0 (i32.const 99) (get_local 0)) (i32.const -1)))) (export "" 0))`, /unused values not explicitly dropped by end of block/);
 
 var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (drop (br_if 0 (i32.const 99) (get_local 0))) (i32.const -1)))) (export "" 0))`).exports[""];
 assertEq(f(0), 0);
 assertEq(f(1), 100);
 
 assertEq(wasmEvalText(`(module (func (result i32) (block i32 (br 0 (return (i32.const 42))) (i32.const 0))) (export "" 0))`).exports[""](), 42);
 assertEq(wasmEvalText(`(module (func (result i32) (block i32 (return (br 0 (i32.const 42))))) (export "" 0))`).exports[""](), 42);
 assertEq(wasmEvalText(`(module (func (result i32) (block i32 (return (br 0 (i32.const 42))) (i32.const 0))) (export "" 0))`).exports[""](), 42);
@@ -411,25 +413,25 @@ assertEq(called, -1);
 assertEq(f(1), 42);
 assertEq(called, 0);
 
 // br/br_if and loop
 assertEq(wasmEvalText(`(module (func (param i32) (result i32) (loop $out $in i32 (br $out (get_local 0)))) (export "" 0))`).exports[""](1), 1);
 assertEq(wasmEvalText(`(module (func (param i32) (result i32) (loop $in (br 1 (get_local 0)))) (export "" 0))`).exports[""](1), 1);
 assertEq(wasmEvalText(`(module (func (param i32) (result i32) (block $out i32 (loop $in i32 (br $out (get_local 0))))) (export "" 0))`).exports[""](1), 1);
 
-assertErrorMessage(() => wasmEvalText(`(module (func (param i32) (result i32)
+wasmFailValidateText(`(module (func (param i32) (result i32)
   (loop $out $in
    (if (get_local 0) (br $in (i32.const 1)))
    (if (get_local 0) (br $in (f32.const 2)))
    (if (get_local 0) (br $in (f64.const 3)))
    (if (get_local 0) (br $in))
    (i32.const 7)
   )
-) (export "" 0))`), TypeError, /unused values not explicitly dropped by end of block/);
+) (export "" 0))`, /unused values not explicitly dropped by end of block/);
 
 assertEq(wasmEvalText(`(module
  (func
   (result i32)
   (local i32)
   (block $out i32
   (loop $in
    (set_local 0 (i32.add (get_local 0) (i32.const 1)))
@@ -452,20 +454,20 @@ assertEq(wasmEvalText(`(module
    )
   )
  )
 (export "" 0))`).exports[""](), 7);
 
 // ----------------------------------------------------------------------------
 // loop
 
-assertErrorMessage(() => wasmEvalText('(module (func (loop (br 2))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (loop (br 2))))', DEPTH_OUT_OF_BOUNDS);
 
 assertEq(wasmEvalText('(module (func (loop )) (export "" 0))').exports[""](), undefined);
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (drop (loop (i32.const 2))) (i32.const 1)) (export "" 0))'), TypeError, /unused values not explicitly dropped by end of block/);
+wasmFailValidateText('(module (func (result i32) (drop (loop (i32.const 2))) (i32.const 1)) (export "" 0))', /unused values not explicitly dropped by end of block/);
 assertEq(wasmEvalText('(module (func (result i32) (loop (drop (i32.const 2))) (i32.const 1)) (export "" 0))').exports[""](), 1);
 
 assertEq(wasmEvalText('(module (func (loop (br 1))) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (loop $a (br 1))) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (loop $a (br_if $a (i32.const 0)))) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (loop $a $b (br $a))) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (block $a (loop $b (br $a)))) (export "" 0))').exports[""](), undefined);
 assertEq(wasmEvalText('(module (func (result i32) (loop i32 (i32.const 1))) (export "" 0))').exports[""](), 1);
@@ -621,25 +623,25 @@ assertEq(wasmEvalText(`(module (func (re
     )
   )
   (return (get_local 0))
 ) (export "" 0))`).exports[""](), 6);
 
 // ----------------------------------------------------------------------------
 // br_table
 
-assertErrorMessage(() => wasmEvalText('(module (func (br_table 1 (i32.const 0))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (br_table 1 0 (i32.const 0))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (br_table 0 1 (i32.const 0))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (block (br_table 2 0 (i32.const 0)))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (block (br_table 0 2 (i32.const 0)))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (block (br_table 0 (f32.const 0)))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (loop (br_table 2 0 (i32.const 0)))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (loop (br_table 0 2 (i32.const 0)))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
-assertErrorMessage(() => wasmEvalText('(module (func (loop (br_table 0 (f32.const 0)))))'), TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (br_table 1 (i32.const 0))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (br_table 1 0 (i32.const 0))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (br_table 0 1 (i32.const 0))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (block (br_table 2 0 (i32.const 0)))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (block (br_table 0 2 (i32.const 0)))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (block (br_table 0 (f32.const 0)))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (loop (br_table 2 0 (i32.const 0)))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (loop (br_table 0 2 (i32.const 0)))))', DEPTH_OUT_OF_BOUNDS);
+wasmFailValidateText('(module (func (loop (br_table 0 (f32.const 0)))))', mismatchError("f32", "i32"));
 
 assertEq(wasmEvalText(`(module (func (result i32) (param i32)
   (block $default
    (br_table $default (get_local 0))
    (return (i32.const 0))
   )
   (return (i32.const 1))
 ) (export "" 0))`).exports[""](), 1);
@@ -681,30 +683,30 @@ var f = wasmEvalText(`(module (func (res
 assertEq(f(-2), -1);
 assertEq(f(-1), -1);
 assertEq(f(0), 0);
 assertEq(f(1), 0);
 assertEq(f(2), 2);
 assertEq(f(3), -1);
 
 // br_table with values
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (block (br_table 0 (i32.const 0)))))'), TypeError, mismatchError("void", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (result i32) (block i32 (br_table 0 (f32.const 0) (i32.const 0)))))'), TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (result i32) (block (br_table 0 (i32.const 0)))))', mismatchError("void", "i32"));
+wasmFailValidateText('(module (func (result i32) (block i32 (br_table 0 (f32.const 0) (i32.const 0)))))', mismatchError("f32", "i32"));
 
-assertErrorMessage(() => wasmEvalText(`(module
+wasmFailValidateText(`(module
  (func
   (result i32)
   (block $outer f32
    (block $inner f32
     (br_table $outer $inner (f32.const 13.37) (i32.const 1))
    )
    (br $outer (i32.const 42))
   )
  )
-(export "" 0))`), TypeError, mismatchError("i32", "f32"));
+(export "" 0))`, mismatchError("i32", "f32"));
 
 assertEq(wasmEvalText(`(module (func (result i32) (block $default i32 (br_table $default (i32.const 42) (i32.const 1)))) (export "" 0))`).exports[""](), 42);
 
 var f = wasmEvalText(`(module (func (param i32) (result i32)
   (i32.add
    (block $1 i32
     (drop (block $0 i32
      (drop (block $default i32
@@ -723,13 +725,13 @@ assertEq(f(1), 2);
 assertEq(f(2), 9);
 assertEq(f(3), 11);
 assertEq(f(4), 13);
 
 // ----------------------------------------------------------------------------
 // unreachable
 
 const UNREACHABLE = /unreachable/;
-assertErrorMessage(wasmEvalText(`(module (func (unreachable)) (export "" 0))`).exports[""], Error, UNREACHABLE);
-assertErrorMessage(wasmEvalText(`(module (func (if (unreachable) (i32.const 0))) (export "" 0))`).exports[""], Error, UNREACHABLE);
-assertErrorMessage(wasmEvalText(`(module (func (block (br_if 0 (unreachable)))) (export "" 0))`).exports[""], Error, UNREACHABLE);
-assertErrorMessage(wasmEvalText(`(module (func (block (br_table 0 (unreachable)))) (export "" 0))`).exports[""], Error, UNREACHABLE);
-assertErrorMessage(wasmEvalText(`(module (func (result i32) (i32.add (i32.const 0) (unreachable))) (export "" 0))`).exports[""], Error, UNREACHABLE);
+assertErrorMessage(wasmEvalText(`(module (func (unreachable)) (export "" 0))`).exports[""], RuntimeError, UNREACHABLE);
+assertErrorMessage(wasmEvalText(`(module (func (if (unreachable) (i32.const 0))) (export "" 0))`).exports[""], RuntimeError, UNREACHABLE);
+assertErrorMessage(wasmEvalText(`(module (func (block (br_if 0 (unreachable)))) (export "" 0))`).exports[""], RuntimeError, UNREACHABLE);
+assertErrorMessage(wasmEvalText(`(module (func (block (br_table 0 (unreachable)))) (export "" 0))`).exports[""], RuntimeError, UNREACHABLE);
+assertErrorMessage(wasmEvalText(`(module (func (result i32) (i32.add (i32.const 0) (unreachable))) (export "" 0))`).exports[""], RuntimeError, UNREACHABLE);
--- a/js/src/jit-test/tests/wasm/conversion.js
+++ b/js/src/jit-test/tests/wasm/conversion.js
@@ -22,27 +22,25 @@ function testConversion(resultType, opco
   } else {
     assertEq(wasmEvalText('(module (func (param ' + paramType + ') (result ' + resultType + ') (' + resultType + '.' + opcode + '/' + paramType + ' (get_local 0))) (export "" 0))').exports[""](op), expect);
   }
 
   let formerTestMode = getJitCompilerOptions()['wasm.test-mode'];
   setJitCompilerOption('wasm.test-mode', 1);
   for (var bad of ['i32', 'f32', 'f64', 'i64']) {
       if (bad != resultType) {
-          assertErrorMessage(
-              () => wasmEvalText(`(module (func (param ${paramType}) (result ${bad}) (${resultType}.${opcode}/${paramType} (get_local 0))))`),
-              TypeError,
+          wasmFailValidateText(
+              `(module (func (param ${paramType}) (result ${bad}) (${resultType}.${opcode}/${paramType} (get_local 0))))`,
               mismatchError(resultType, bad)
           );
       }
 
       if (bad != paramType) {
-          assertErrorMessage(
-              () => wasmEvalText(`(module (func (param ${bad}) (result ${resultType}) (${resultType}.${opcode}/${paramType} (get_local 0))))`),
-              TypeError,
+          wasmFailValidateText(
+              `(module (func (param ${bad}) (result ${resultType}) (${resultType}.${opcode}/${paramType} (get_local 0))))`,
               mismatchError(bad, paramType)
           );
       }
   }
   setJitCompilerOption('wasm.test-mode', formerTestMode);
 }
 
 function testTrap(resultType, opcode, paramType, op, expect) {
--- a/js/src/jit-test/tests/wasm/float.js
+++ b/js/src/jit-test/tests/wasm/float.js
@@ -67,39 +67,39 @@ testBinary('f64', 'copysign', 40, -2, -4
 
 testComparison('f64', 'eq', 40, 40, 1);
 testComparison('f64', 'ne', 40, 40, 0);
 testComparison('f64', 'lt', 40, 40, 0);
 testComparison('f64', 'le', 40, 40, 1);
 testComparison('f64', 'gt', 40, 40, 0);
 testComparison('f64', 'ge', 40, 40, 1);
 
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (result f32) (f32.sqrt (get_local 0))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (result i32) (f32.sqrt (get_local 0))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (result i32) (f32.sqrt (get_local 0))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (result f64) (f64.sqrt (get_local 0))))'), TypeError, mismatchError("i32", "f64"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f64) (result i32) (f64.sqrt (get_local 0))))'), TypeError, mismatchError("f64", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (result i32) (f64.sqrt (get_local 0))))'), TypeError, mismatchError("i32", "f64"));
-assertErrorMessage(() => wasmEvalText('(module (func (f32.sqrt (nop))))'), TypeError, /popping value from empty stack/);
+wasmFailValidateText('(module (func (param i32) (result f32) (f32.sqrt (get_local 0))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param f32) (result i32) (f32.sqrt (get_local 0))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (param i32) (result i32) (f32.sqrt (get_local 0))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param i32) (result f64) (f64.sqrt (get_local 0))))', mismatchError("i32", "f64"));
+wasmFailValidateText('(module (func (param f64) (result i32) (f64.sqrt (get_local 0))))', mismatchError("f64", "i32"));
+wasmFailValidateText('(module (func (param i32) (result i32) (f64.sqrt (get_local 0))))', mismatchError("i32", "f64"));
+wasmFailValidateText('(module (func (f32.sqrt (nop))))', /popping value from empty stack/);
 
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param f32) (result f32) (f32.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (param i32) (result f32) (f32.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (param f32) (result i32) (f32.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param i32) (result i32) (f32.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param f64) (result f64) (f64.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f64"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f64) (param i32) (result f64) (f64.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f64"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f64) (param f64) (result i32) (f64.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("f64", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param i32) (result i32) (f64.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f64"));
+wasmFailValidateText('(module (func (param i32) (param f32) (result f32) (f32.add (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param f32) (param i32) (result f32) (f32.add (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param f32) (param f32) (result i32) (f32.add (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (param i32) (param i32) (result i32) (f32.add (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param i32) (param f64) (result f64) (f64.add (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
+wasmFailValidateText('(module (func (param f64) (param i32) (result f64) (f64.add (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
+wasmFailValidateText('(module (func (param f64) (param f64) (result i32) (f64.add (get_local 0) (get_local 1))))', mismatchError("f64", "i32"));
+wasmFailValidateText('(module (func (param i32) (param i32) (result i32) (f64.add (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
 
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param f32) (result f32) (f32.eq (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (param i32) (result f32) (f32.eq (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (param f32) (result f32) (f32.eq (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param f64) (result f64) (f64.eq (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f64"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f64) (param i32) (result f64) (f64.eq (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f64"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f64) (param f64) (result f64) (f64.eq (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f64"));
+wasmFailValidateText('(module (func (param i32) (param f32) (result f32) (f32.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param f32) (param i32) (result f32) (f32.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param f32) (param f32) (result f32) (f32.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param i32) (param f64) (result f64) (f64.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
+wasmFailValidateText('(module (func (param f64) (param i32) (result f64) (f64.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
+wasmFailValidateText('(module (func (param f64) (param f64) (result f64) (f64.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f64"));
 
 // Non-canonical NaNs.
 assertEq(wasmEvalText('(module (func (result i32) (i32.reinterpret/f32 (f32.mul (f32.const 0.0) (f32.const -nan:0x222222)))) (export "" 0))').exports[""](), -0x1dddde);
 assertEq(wasmEvalText('(module (func (result i32) (i32.reinterpret/f32 (f32.min (f32.const 0.0) (f32.const -nan:0x222222)))) (export "" 0))').exports[""](), -0x1dddde);
 assertEq(wasmEvalText('(module (func (result i32) (i32.reinterpret/f32 (f32.max (f32.const 0.0) (f32.const -nan:0x222222)))) (export "" 0))').exports[""](), -0x1dddde);
 assertEq(wasmEvalText('(module (func (result i32) (local i64) (set_local 0 (i64.reinterpret/f64 (f64.mul (f64.const 0.0) (f64.const -nan:0x4444444444444)))) (i32.xor (i32.wrap/i64 (get_local 0)) (i32.wrap/i64 (i64.shr_u (get_local 0) (i64.const 32))))) (export "" 0))').exports[""](), -0x44480000);
 assertEq(wasmEvalText('(module (func (result i32) (local i64) (set_local 0 (i64.reinterpret/f64 (f64.min (f64.const 0.0) (f64.const -nan:0x4444444444444)))) (i32.xor (i32.wrap/i64 (get_local 0)) (i32.wrap/i64 (i64.shr_u (get_local 0) (i64.const 32))))) (export "" 0))').exports[""](), -0x44480000);
 assertEq(wasmEvalText('(module (func (result i32) (local i64) (set_local 0 (i64.reinterpret/f64 (f64.max (f64.const 0.0) (f64.const -nan:0x4444444444444)))) (i32.xor (i32.wrap/i64 (get_local 0)) (i32.wrap/i64 (i64.shr_u (get_local 0) (i64.const 32))))) (export "" 0))').exports[""](), -0x44480000);
--- a/js/src/jit-test/tests/wasm/globals.js
+++ b/js/src/jit-test/tests/wasm/globals.js
@@ -4,22 +4,22 @@ load(libdir + "wasm.js");
 const { Instance, Module } = WebAssembly;
 
 // Locally-defined globals
 assertErrorMessage(() => wasmEvalText(`(module (global))`), SyntaxError, /parsing/);
 assertErrorMessage(() => wasmEvalText(`(module (global i32))`), SyntaxError, /parsing/);
 assertErrorMessage(() => wasmEvalText(`(module (global i32 immutable))`), SyntaxError, /parsing/);
 
 // Initializer expressions.
-assertErrorMessage(() => wasmEvalText(`(module (global i32 (f32.const 13.37)))`), TypeError, /type mismatch/);
-assertErrorMessage(() => wasmEvalText(`(module (global f64 (f32.const 13.37)))`), TypeError, /type mismatch/);
-assertErrorMessage(() => wasmEvalText(`(module (global i32 (i32.add (i32.const 13) (i32.const 37))))`), TypeError, /failed to read end/);
+wasmFailValidateText(`(module (global i32 (f32.const 13.37)))`, /type mismatch/);
+wasmFailValidateText(`(module (global f64 (f32.const 13.37)))`, /type mismatch/);
+wasmFailValidateText(`(module (global i32 (i32.add (i32.const 13) (i32.const 37))))`, /failed to read end/);
 
-assertErrorMessage(() => wasmEvalText(`(module (global i32 (get_global 0)))`), TypeError, /out of range/);
-assertErrorMessage(() => wasmEvalText(`(module (global i32 (get_global 1)) (global i32 immutable (i32.const 1)))`), TypeError, /out of range/);
+wasmFailValidateText(`(module (global i32 (get_global 0)))`, /out of range/);
+wasmFailValidateText(`(module (global i32 (get_global 1)) (global i32 immutable (i32.const 1)))`, /out of range/);
 
 // Test a well-defined global section.
 function testInner(type, initialValue, nextValue, coercion, assertFunc = assertEq)
 {
     var module = wasmEvalText(`(module
         (global ${type} (${type}.const ${initialValue}))
         (global ${type} immutable (${type}.const ${initialValue}))
 
@@ -41,18 +41,18 @@ function testInner(type, initialValue, n
     assertFunc(module.get_cst(), coercion(initialValue));
 }
 
 testInner('i32', 13, 37, x => x|0);
 testInner('f32', 13.37, 0.1989, Math.fround);
 testInner('f64', 13.37, 0.1989, x => +x);
 
 // Semantic errors.
-assertErrorMessage(() => wasmEvalText(`(module (global i32 (i32.const 1337)) (func (set_global 1 (i32.const 0))))`), TypeError, /out of range/);
-assertErrorMessage(() => wasmEvalText(`(module (global i32 immutable (i32.const 1337)) (func (set_global 0 (i32.const 0))))`), TypeError, /can't write an immutable global/);
+wasmFailValidateText(`(module (global i32 (i32.const 1337)) (func (set_global 1 (i32.const 0))))`, /out of range/);
+wasmFailValidateText(`(module (global i32 immutable (i32.const 1337)) (func (set_global 0 (i32.const 0))))`, /can't write an immutable global/);
 
 // Big module with many variables: test that setting one doesn't overwrite the
 // other ones.
 function get_set(i, type) { return `
     (func $get_${i} (result ${type}) (get_global ${i}))
     (func $set_${i} (param ${type}) (set_global ${i} (get_local 0)))
 `
 }
@@ -88,35 +88,35 @@ for (let i = 0; i < 5; i++) {
             continue;
         assertEq(module[`get${j}`](), values[j]);
     }
     assertEq(module[`set${i}`](values[i]), undefined);
     assertEq(module[`get${i}`](), values[i]);
 }
 
 // Initializer expressions can also be used in elem section initializers.
-assertErrorMessage(() => wasmEvalText(`(module (import "globals" "a" (global f32 immutable)) (table (resizable 4)) (elem (get_global 0) $f) (func $f))`), TypeError, /type mismatch/);
+wasmFailValidateText(`(module (import "globals" "a" (global f32 immutable)) (table (resizable 4)) (elem (get_global 0) $f) (func $f))`, /type mismatch/);
 
 module = wasmEvalText(`(module
     (import "globals" "a" (global i32 immutable))
     (table (resizable 4))
     (elem (get_global 0) $f)
     (func $f)
     (export "f" $f)
     (export "tbl" table)
 )`, {
     globals: {
         a: 1
     }
 }).exports;
 assertEq(module.f, module.tbl.get(1));
 
 // Import/export rules.
-assertErrorMessage(() => wasmEvalText(`(module (import "globals" "x" (global i32)))`), TypeError, /can't import.* mutable globals in the MVP/);
-assertErrorMessage(() => wasmEvalText(`(module (global i32 (i32.const 42)) (export "" global 0))`), TypeError, /can't .*export mutable globals in the MVP/);
+wasmFailValidateText(`(module (import "globals" "x" (global i32)))`, /can't import.* mutable globals in the MVP/);
+wasmFailValidateText(`(module (global i32 (i32.const 42)) (export "" global 0))`, /can't .*export mutable globals in the MVP/);
 
 // Import/export semantics.
 module = wasmEvalText(`(module
  (import $g "globals" "x" (global i32 immutable))
  (func $get (result i32) (get_global $g))
  (export "getter" $get)
  (export "value" global 0)
 )`, { globals: {x: 42} }).exports;
@@ -131,21 +131,21 @@ module = wasmEvalText(`(module
  (export "imported" global 0)
  (export "defined" global 1)
 )`, { globals: {x: 42} }).exports;
 
 assertEq(module.imported, 42);
 assertEq(module.defined, 1337);
 
 // Initializer expressions can reference an imported immutable global.
-assertErrorMessage(() => wasmEvalText(`(module (global f32 immutable (f32.const 13.37)) (global i32 (get_global 0)))`), TypeError, /must reference a global immutable import/);
-assertErrorMessage(() => wasmEvalText(`(module (global f32 (f32.const 13.37)) (global i32 (get_global 0)))`), TypeError, /must reference a global immutable import/);
-assertErrorMessage(() => wasmEvalText(`(module (global i32 (i32.const 0)) (global i32 (get_global 0)))`), TypeError, /must reference a global immutable import/);
+wasmFailValidateText(`(module (global f32 immutable (f32.const 13.37)) (global i32 (get_global 0)))`, /must reference a global immutable import/);
+wasmFailValidateText(`(module (global f32 (f32.const 13.37)) (global i32 (get_global 0)))`, /must reference a global immutable import/);
+wasmFailValidateText(`(module (global i32 (i32.const 0)) (global i32 (get_global 0)))`, /must reference a global immutable import/);
 
-assertErrorMessage(() => wasmEvalText(`(module (import "globals" "a" (global f32 immutable)) (global i32 (get_global 0)))`), TypeError, /type mismatch/);
+wasmFailValidateText(`(module (import "globals" "a" (global f32 immutable)) (global i32 (get_global 0)))`, /type mismatch/);
 
 function testInitExpr(type, initialValue, nextValue, coercion, assertFunc = assertEq) {
     var module = wasmEvalText(`(module
         (import "globals" "a" (global ${type} immutable))
 
         (global ${type} (get_global 0))
         (global ${type} immutable (get_global 0))
 
@@ -178,18 +178,18 @@ function testInitExpr(type, initialValue
 }
 
 testInitExpr('i32', 13, 37, x => x|0);
 testInitExpr('f32', 13.37, 0.1989, Math.fround);
 testInitExpr('f64', 13.37, 0.1989, x => +x);
 
 // Int64.
 {
-    assertErrorMessage(() => wasmEvalText(`(module (import "globals" "x" (global i64 immutable)))`), TypeError, /can't import.* an Int64 global/);
-    assertErrorMessage(() => wasmEvalText(`(module (global i64 immutable (i64.const 42)) (export "" global 0))`), TypeError, /can't .*export an Int64 global/);
+    wasmFailValidateText(`(module (import "globals" "x" (global i64 immutable)))`, /can't import.* an Int64 global/);
+    wasmFailValidateText(`(module (global i64 immutable (i64.const 42)) (export "" global 0))`, /can't .*export an Int64 global/);
 
     setJitCompilerOption('wasm.test-mode', 1);
     testInner('i64', '0x531642753864975F', '0x123456789abcdef0', createI64, assertEqI64);
     testInitExpr('i64', '0x531642753864975F', '0x123456789abcdef0', createI64, assertEqI64);
 
     module = wasmEvalText(`(module
      (import "globals" "x" (global i64 immutable))
      (global i64 immutable (i64.const 0xFAFADADABABA))
--- a/js/src/jit-test/tests/wasm/import-export.js
+++ b/js/src/jit-test/tests/wasm/import-export.js
@@ -19,49 +19,49 @@ const mem4PageMax4 = new Memory({initial
 const tab1Elem = new Table({initial:1, element:"anyfunc"});
 const tab2Elem = new Table({initial:2, element:"anyfunc"});
 const tab3Elem = new Table({initial:3, element:"anyfunc"});
 const tab4Elem = new Table({initial:4, element:"anyfunc"});
 
 assertErrorMessage(() => new Memory({initial:2, maximum:1}), RangeError, /bad Memory maximum size/);
 
 const m1 = new Module(wasmTextToBinary('(module (import "foo" "bar") (import "baz" "quux"))'));
-assertErrorMessage(() => new Instance(m1), TypeError, /no import object given/);
+assertErrorMessage(() => new Instance(m1), TypeError, /second argument must be an object/);
 assertErrorMessage(() => new Instance(m1, {foo:null}), TypeError, /import object field is not an Object/);
 assertErrorMessage(() => new Instance(m1, {foo:{bar:{}}}), TypeError, /import object field is not a Function/);
 assertErrorMessage(() => new Instance(m1, {foo:{bar:()=>{}}, baz:null}), TypeError, /import object field is not an Object/);
 assertErrorMessage(() => new Instance(m1, {foo:{bar:()=>{}}, baz:{}}), TypeError, /import object field is not a Function/);
 assertEq(new Instance(m1, {foo:{bar:()=>{}}, baz:{quux:()=>{}}}) instanceof Instance, true);
 
 const m2 = new Module(wasmTextToBinary('(module (import "x" "y" (memory 2 3)))'));
-assertErrorMessage(() => new Instance(m2), TypeError, /no import object given/);
+assertErrorMessage(() => new Instance(m2), TypeError, /second argument must be an object/);
 assertErrorMessage(() => new Instance(m2, {x:null}), TypeError, /import object field is not an Object/);
 assertErrorMessage(() => new Instance(m2, {x:{y:{}}}), TypeError, /import object field is not a Memory/);
 assertErrorMessage(() => new Instance(m2, {x:{y:mem1Page}}), TypeError, /imported Memory with incompatible size/);
 assertErrorMessage(() => new Instance(m2, {x:{y:mem1PageMax1}}), TypeError, /imported Memory with incompatible size/);
 assertErrorMessage(() => new Instance(m2, {x:{y:mem4Page}}), TypeError, /imported Memory with incompatible size/);
 assertErrorMessage(() => new Instance(m2, {x:{y:mem4PageMax4}}), TypeError, /imported Memory with incompatible size/);
 assertErrorMessage(() => new Instance(m2, {x:{y:mem2Page}}), TypeError, /imported Memory with incompatible maximum size/);
 assertEq(new Instance(m2, {x:{y:mem2PageMax2}}) instanceof Instance, true);
 assertErrorMessage(() => new Instance(m2, {x:{y:mem3Page}}), TypeError, /imported Memory with incompatible maximum size/);
 assertEq(new Instance(m2, {x:{y:mem3PageMax3}}) instanceof Instance, true);
 assertEq(new Instance(m2, {x:{y:mem2PageMax3}}) instanceof Instance, true);
 assertErrorMessage(() => new Instance(m2, {x:{y:mem2PageMax4}}), TypeError, /imported Memory with incompatible maximum size/);
 
 const m3 = new Module(wasmTextToBinary('(module (import "foo" "bar" (memory 1 1)) (import "baz" "quux"))'));
-assertErrorMessage(() => new Instance(m3), TypeError, /no import object given/);
+assertErrorMessage(() => new Instance(m3), TypeError, /second argument must be an object/);
 assertErrorMessage(() => new Instance(m3, {foo:null}), TypeError, /import object field is not an Object/);
 assertErrorMessage(() => new Instance(m3, {foo:{bar:{}}}), TypeError, /import object field is not a Memory/);
 assertErrorMessage(() => new Instance(m3, {foo:{bar:mem1Page}, baz:null}), TypeError, /import object field is not an Object/);
 assertErrorMessage(() => new Instance(m3, {foo:{bar:mem1Page}, baz:{quux:mem1Page}}), TypeError, /import object field is not a Function/);
 assertErrorMessage(() => new Instance(m3, {foo:{bar:mem1Page}, baz:{quux:()=>{}}}), TypeError, /imported Memory with incompatible maximum size/);
 assertEq(new Instance(m3, {foo:{bar:mem1PageMax1}, baz:{quux:()=>{}}}) instanceof Instance, true);
 
 const m4 = new Module(wasmTextToBinary('(module (import "baz" "quux") (import "foo" "bar" (memory 1 1)))'));
-assertErrorMessage(() => new Instance(m4), TypeError, /no import object given/);
+assertErrorMessage(() => new Instance(m4), TypeError, /second argument must be an object/);
 assertErrorMessage(() => new Instance(m4, {baz:null}), TypeError, /import object field is not an Object/);
 assertErrorMessage(() => new Instance(m4, {baz:{quux:{}}}), TypeError, /import object field is not a Function/);
 assertErrorMessage(() => new Instance(m4, {baz:{quux:()=>{}}, foo:null}), TypeError, /import object field is not an Object/);
 assertErrorMessage(() => new Instance(m4, {baz:{quux:()=>{}}, foo:{bar:()=>{}}}), TypeError, /import object field is not a Memory/);
 assertErrorMessage(() => new Instance(m4, {baz:{quux:()=>{}}, foo:{bar:mem1Page}}), TypeError, /imported Memory with incompatible maximum size/);
 assertEq(new Instance(m3, {baz:{quux:()=>{}}, foo:{bar:mem1PageMax1}}) instanceof Instance, true);
 
 const m5 = new Module(wasmTextToBinary('(module (import "a" "b" (memory 2)))'));
@@ -77,20 +77,20 @@ assertEq(new Instance(m6, {a:{b:tab3Elem
 assertEq(new Instance(m6, {a:{b:tab4Elem}}) instanceof Instance, true);
 
 const m7 = new Module(wasmTextToBinary('(module (import "a" "b" (table 2 3)))'));
 assertErrorMessage(() => new Instance(m7, {a:{b:tab1Elem}}), TypeError, /imported Table with incompatible size/);
 assertErrorMessage(() => new Instance(m7, {a:{b:tab2Elem}}), TypeError, /imported Table with incompatible maximum size/);
 assertErrorMessage(() => new Instance(m7, {a:{b:tab3Elem}}), TypeError, /imported Table with incompatible maximum size/);
 assertErrorMessage(() => new Instance(m7, {a:{b:tab4Elem}}), TypeError, /imported Table with incompatible size/);
 
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (memory 2 1))')), TypeError, /maximum length 1 is less than initial length 2/);
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (import "a" "b" (memory 2 1)))')), TypeError, /maximum length 1 is less than initial length 2/);
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (table (resizable 2 1)))')), TypeError, /maximum length 1 is less than initial length 2/);
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (import "a" "b" (table 2 1)))')), TypeError, /maximum length 1 is less than initial length 2/);
+wasmFailValidateText('(module (memory 2 1))', /maximum length 1 is less than initial length 2/);
+wasmFailValidateText('(module (import "a" "b" (memory 2 1)))', /maximum length 1 is less than initial length 2/);
+wasmFailValidateText('(module (table (resizable 2 1)))', /maximum length 1 is less than initial length 2/);
+wasmFailValidateText('(module (import "a" "b" (table 2 1)))', /maximum length 1 is less than initial length 2/);
 
 // Import wasm-wasm type mismatch
 
 var e = wasmEvalText('(module (func $i2v (param i32)) (export "i2v" $i2v) (func $f2v (param f32)) (export "f2v" $f2v))').exports;
 var i2vm = new Module(wasmTextToBinary('(module (import "a" "b" (param i32)))'));
 var f2vm = new Module(wasmTextToBinary('(module (import "a" "b" (param f32)))'));
 assertEq(new Instance(i2vm, {a:{b:e.i2v}}) instanceof Instance, true);
 assertErrorMessage(() => new Instance(i2vm, {a:{b:e.f2v}}), TypeError, /imported function signature mismatch/);
@@ -318,27 +318,27 @@ assertEq(e1.tbl.get(1) === e2.tbl.get(1)
 var code1 = wasmTextToBinary('(module (func $exp (param i64) (result i64) (i64.add (get_local 0) (i64.const 10))) (export "exp" $exp))');
 var e1 = new Instance(new Module(code1)).exports;
 var code2 = wasmTextToBinary('(module (import $i "a" "b" (param i64) (result i64)) (func $f (result i32) (i32.wrap/i64 (call_import $i (i64.const 42)))) (export "f" $f))');
 var e2 = new Instance(new Module(code2), {a:{b:e1.exp}}).exports;
 assertEq(e2.f(), 52);
 
 // Non-existent export errors
 
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (export "a" 0))')), TypeError, /exported function index out of bounds/);
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (export "a" global 0))')), TypeError, /exported global index out of bounds/);
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (export "a" memory))')), TypeError, /exported memory index out of bounds/);
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (export "a" table))')), TypeError, /exported table index out of bounds/);
+wasmFailValidateText('(module (export "a" 0))', /exported function index out of bounds/);
+wasmFailValidateText('(module (export "a" global 0))', /exported global index out of bounds/);
+wasmFailValidateText('(module (export "a" memory))', /exported memory index out of bounds/);
+wasmFailValidateText('(module (export "a" table))', /exported table index out of bounds/);
 
 // Default memory/table rules
 
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (import "a" "b" (memory 1 1)) (memory 1 1))')), TypeError, /already have default memory/);
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (import "a" "b" (memory 1 1)) (import "x" "y" (memory 2 2)))')), TypeError, /already have default memory/);
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (import "a" "b" (table 1 1)) (table 1 1))')), TypeError, /already have default table/);
-assertErrorMessage(() => new Module(wasmTextToBinary('(module (import "a" "b" (table 1 1)) (import "x" "y" (table 2 2)))')), TypeError, /already have default table/);
+wasmFailValidateText('(module (import "a" "b" (memory 1 1)) (memory 1 1))', /already have default memory/);
+wasmFailValidateText('(module (import "a" "b" (memory 1 1)) (import "x" "y" (memory 2 2)))', /already have default memory/);
+wasmFailValidateText('(module (import "a" "b" (table 1 1)) (table 1 1))', /already have default table/);
+wasmFailValidateText('(module (import "a" "b" (table 1 1)) (import "x" "y" (table 2 2)))', /already have default table/);
 
 // Data segments on imports
 
 var m = new Module(wasmTextToBinary(`
     (module
         (import "a" "b" (memory 1 1))
         (data 0 "\\0a\\0b")
         (data 100 "\\0c\\0d")
--- a/js/src/jit-test/tests/wasm/integer.js
+++ b/js/src/jit-test/tests/wasm/integer.js
@@ -285,20 +285,20 @@ assertEq(testTrunc(13.37), 1);
     assertEq(testTrunc(0), 0);
     assertEq(testTrunc(13.37), 1);
 
     assertEqI64(wasmEvalText(`(module (func (result i64) (local i64) (set_local 0 (i64.rem_s (i64.const 1) (i64.const 0xf))) (i64.rem_s (get_local 0) (get_local 0))) (export "" 0))`).exports[""](), 0);
 
     setJitCompilerOption('wasm.test-mode', 0);
 }
 
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (result i32) (i32.clz (get_local 0))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (result f32) (i32.clz (get_local 0))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (result f32) (i32.clz (get_local 0))))'), TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (param f32) (result i32) (i32.clz (get_local 0))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (param i32) (result f32) (i32.clz (get_local 0))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param f32) (result f32) (i32.clz (get_local 0))))', mismatchError("f32", "i32"));
 
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (param i32) (result i32) (i32.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param f32) (result i32) (i32.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param i32) (result f32) (i32.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (param f32) (result f32) (i32.add (get_local 0) (get_local 1))))'), TypeError, mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (param f32) (param i32) (result i32) (i32.add (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (param i32) (param f32) (result i32) (i32.add (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (param i32) (param i32) (result f32) (i32.add (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param f32) (param f32) (result f32) (i32.add (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
 
-assertErrorMessage(() => wasmEvalText('(module (func (param f32) (param i32) (result i32) (i32.eq (get_local 0) (get_local 1))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param f32) (result i32) (i32.eq (get_local 0) (get_local 1))))'), TypeError, mismatchError("f32", "i32"));
-assertErrorMessage(() => wasmEvalText('(module (func (param i32) (param i32) (result f32) (i32.eq (get_local 0) (get_local 1))))'), TypeError, mismatchError("i32", "f32"));
+wasmFailValidateText('(module (func (param f32) (param i32) (result i32) (i32.eq (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (param i32) (param f32) (result i32) (i32.eq (get_local 0) (get_local 1))))', mismatchError("f32", "i32"));
+wasmFailValidateText('(module (func (param i32) (param i32) (result f32) (i32.eq (get_local 0) (get_local 1))))', mismatchError("i32", "f32"));
--- a/js/src/jit-test/tests/wasm/jsapi.js
+++ b/js/src/jit-test/tests/wasm/jsapi.js
@@ -10,16 +10,52 @@ assertEq(typeof wasmDesc.value, "object"
 assertEq(wasmDesc.writable, true);
 assertEq(wasmDesc.enumerable, false);
 assertEq(wasmDesc.configurable, true);
 
 // 'WebAssembly' object
 assertEq(WebAssembly, wasmDesc.value);
 assertEq(String(WebAssembly), "[object WebAssembly]");
 
+// 'WebAssembly.(Compile|Runtime)Error' data property
+const compileErrorDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'CompileError');
+const runtimeErrorDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'RuntimeError');
+assertEq(typeof compileErrorDesc.value, "function");
+assertEq(typeof runtimeErrorDesc.value, "function");
+assertEq(compileErrorDesc.writable, true);
+assertEq(runtimeErrorDesc.writable, true);
+assertEq(compileErrorDesc.enumerable, false);
+assertEq(runtimeErrorDesc.enumerable, false);
+assertEq(compileErrorDesc.configurable, true);
+assertEq(runtimeErrorDesc.configurable, true);
+
+// 'WebAssembly.(Compile|Runtime)Error' constructor function
+const CompileError = WebAssembly.CompileError;
+const RuntimeError = WebAssembly.RuntimeError;
+assertEq(CompileError, compileErrorDesc.value);
+assertEq(RuntimeError, runtimeErrorDesc.value);
+assertEq(CompileError.length, 1);
+assertEq(RuntimeError.length, 1);
+assertEq(CompileError.name, "CompileError");
+assertEq(RuntimeError.name, "RuntimeError");
+
+// 'WebAssembly.(Compile|Runtime)Error' instance objects
+const compileError = new CompileError;
+const runtimeError = new RuntimeError;
+assertEq(compileError instanceof CompileError, true);
+assertEq(runtimeError instanceof RuntimeError, true);
+assertEq(compileError instanceof Error, true);
+assertEq(runtimeError instanceof Error, true);
+assertEq(compileError instanceof TypeError, false);
+assertEq(runtimeError instanceof TypeError, false);
+assertEq(compileError.message, "");
+assertEq(runtimeError.message, "");
+assertEq(new CompileError("hi").message, "hi");
+assertEq(new RuntimeError("hi").message, "hi");
+
 // 'WebAssembly.Module' data property
 const moduleDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Module');
 assertEq(typeof moduleDesc.value, "function");
 assertEq(moduleDesc.writable, true);
 assertEq(moduleDesc.enumerable, false);
 assertEq(moduleDesc.configurable, true);
 
 // 'WebAssembly.Module' constructor function
@@ -27,18 +63,18 @@ const Module = WebAssembly.Module;
 assertEq(Module, moduleDesc.value);
 assertEq(Module.length, 1);
 assertEq(Module.name, "Module");
 assertErrorMessage(() => Module(), TypeError, /constructor without new is forbidden/);
 assertErrorMessage(() => new Module(), TypeError, /requires more than 0 arguments/);
 assertErrorMessage(() => new Module(undefined), TypeError, "first argument must be an ArrayBuffer or typed array object");
 assertErrorMessage(() => new Module(1), TypeError, "first argument must be an ArrayBuffer or typed array object");
 assertErrorMessage(() => new Module({}), TypeError, "first argument must be an ArrayBuffer or typed array object");
-assertErrorMessage(() => new Module(new Uint8Array()), /* TODO: WebAssembly.CompileError */ TypeError, /failed to match magic number/);
-assertErrorMessage(() => new Module(new ArrayBuffer()), /* TODO: WebAssembly.CompileError */ TypeError, /failed to match magic number/);
+assertErrorMessage(() => new Module(new Uint8Array()), CompileError, /failed to match magic number/);
+assertErrorMessage(() => new Module(new ArrayBuffer()), CompileError, /failed to match magic number/);
 assertEq(new Module(emptyModule) instanceof Module, true);
 assertEq(new Module(emptyModule.buffer) instanceof Module, true);
 
 // 'WebAssembly.Module.prototype' data property
 const moduleProtoDesc = Object.getOwnPropertyDescriptor(Module, 'prototype');
 assertEq(typeof moduleProtoDesc.value, "object");
 assertEq(moduleProtoDesc.writable, false);
 assertEq(moduleProtoDesc.enumerable, false);
@@ -66,17 +102,17 @@ assertEq(instanceDesc.configurable, true
 // 'WebAssembly.Instance' constructor function
 const Instance = WebAssembly.Instance;
 assertEq(Instance, instanceDesc.value);
 assertEq(Instance.length, 1);
 assertEq(Instance.name, "Instance");
 assertErrorMessage(() => Instance(), TypeError, /constructor without new is forbidden/);
 assertErrorMessage(() => new Instance(1), TypeError, "first argument must be a WebAssembly.Module");
 assertErrorMessage(() => new Instance({}), TypeError, "first argument must be a WebAssembly.Module");
-assertErrorMessage(() => new Instance(m1, null), TypeError, "second argument, if present, must be an object");
+assertErrorMessage(() => new Instance(m1, null), TypeError, "second argument must be an object");
 assertEq(new Instance(m1) instanceof Instance, true);
 assertEq(new Instance(m1, {}) instanceof Instance, true);
 
 // 'WebAssembly.Instance.prototype' data property
 const instanceProtoDesc = Object.getOwnPropertyDescriptor(Instance, 'prototype');
 assertEq(typeof instanceProtoDesc.value, "object");
 assertEq(instanceProtoDesc.writable, false);
 assertEq(instanceProtoDesc.enumerable, false);
--- a/js/src/jit-test/tests/wasm/memory.js
+++ b/js/src/jit-test/tests/wasm/memory.js
@@ -97,21 +97,21 @@ function testStore(type, ext, base, offs
 
 function testStoreOOB(type, ext, base, offset, align, value) {
     if (type === 'i64')
         value = createI64(value);
     assertErrorMessage(() => storeModule(type, ext, offset, align).store(base, value), Error, /invalid or out-of-range index/);
 }
 
 function badLoadModule(type, ext) {
-    return wasmEvalText( `(module (func (param i32) (${type}.load${ext} (get_local 0))) (export "" 0))`);
+    wasmFailValidateText( `(module (func (param i32) (${type}.load${ext} (get_local 0))) (export "" 0))`, /can't touch memory/);
 }
 
 function badStoreModule(type, ext) {
-    return wasmEvalText( `(module (func (param i32) (${type}.store${ext} (get_local 0) (${type}.const 0))) (export "" 0))`);
+    wasmFailValidateText(`(module (func (param i32) (${type}.store${ext} (get_local 0) (${type}.const 0))) (export "" 0))`, /can't touch memory/);
 }
 
 // Can't touch memory.
 for (let [type, ext] of [
     ['i32', ''],
     ['i32', '8_s'],
     ['i32', '8_u'],
     ['i32', '16_s'],
@@ -122,32 +122,32 @@ for (let [type, ext] of [
     ['i64', '16_s'],
     ['i64', '16_u'],
     ['i64', '32_s'],
     ['i64', '32_u'],
     ['f32', ''],
     ['f64', ''],
 ])
 {
-    assertErrorMessage(() => badLoadModule(type, ext), TypeError, /can't touch memory/);
+    badLoadModule(type, ext);
 }
 
 for (let [type, ext] of [
     ['i32', ''],
     ['i32', '8'],
     ['i32', '16'],
     ['i64', ''],
     ['i64', '8'],
     ['i64', '16'],
     ['i64', '32'],
     ['f32', ''],
     ['f64', ''],
 ])
 {
-    assertErrorMessage(() => badStoreModule(type, ext), TypeError, /can't touch memory/);
+    badStoreModule(type, ext);
 }
 
 assertEq(getJitCompilerOptions()['wasm.fold-offsets'], 1);
 
 for (var foldOffsets = 0; foldOffsets <= 1; foldOffsets++) {
     setJitCompilerOption('wasm.fold-offsets', foldOffsets);
 
     testLoad('i32', '', 0, 0, 0, 0x03020100);
@@ -180,17 +180,17 @@ for (var foldOffsets = 0; foldOffsets <=
     testStore('f64', '', 0, 0, 0, 0.89012345);
     testStore('f64', '', 1, 0, 1, 0.89012345);
     testStore('f64', '', 0, 8, 0, 0.89012345);
     testStore('f64', '', 1, 7, 8, 0.89012345);
 
     testStore('i32', '8', 0, 0, 0, 0x23);
     testStore('i32', '16', 0, 0, 0, 0x2345);
 
-    assertErrorMessage(() => wasmEvalText('(module (memory 2 1))'), TypeError, /maximum length 1 is less than initial length 2/);
+    wasmFailValidateText('(module (memory 2 1))', /maximum length 1 is less than initial length 2/);
 
     // Test bounds checks and edge cases.
     const align = 0;
 
     for (let offset of [0, 1, 2, 3, 4, 8, 16, 41, 0xfff8]) {
         // Accesses of 1 byte.
         let lastValidIndex = 0x10000 - 1 - offset;
 
@@ -259,27 +259,27 @@ for (var foldOffsets = 0; foldOffsets <=
         testLoadOOB('i32', '', index, offset, 1);
         testLoadOOB('i32', '', index, offset, 4);
         testLoadOOB('f32', '', index, offset, 1);
         testLoadOOB('f32', '', index, offset, 4);
         testLoadOOB('f64', '', index, offset, 1);
         testLoadOOB('f64', '', index, offset, 8);
     }
 
-    assertErrorMessage(() => wasmEvalText('(module (memory 1) (func (f64.store offset=0 (i32.const 0) (i32.const 0))))'), TypeError, mismatchError("i32", "f64"));
-    assertErrorMessage(() => wasmEvalText('(module (memory 1) (func (f64.store offset=0 (i32.const 0) (f32.const 0))))'), TypeError, mismatchError("f32", "f64"));
+    wasmFailValidateText('(module (memory 1) (func (f64.store offset=0 (i32.const 0) (i32.const 0))))', mismatchError("i32", "f64"));
+    wasmFailValidateText('(module (memory 1) (func (f64.store offset=0 (i32.const 0) (f32.const 0))))', mismatchError("f32", "f64"));
 
-    assertErrorMessage(() => wasmEvalText('(module (memory 1) (func (f32.store offset=0 (i32.const 0) (i32.const 0))))'), TypeError, mismatchError("i32", "f32"));
-    assertErrorMessage(() => wasmEvalText('(module (memory 1) (func (f32.store offset=0 (i32.const 0) (f64.const 0))))'), TypeError, mismatchError("f64", "f32"));
+    wasmFailValidateText('(module (memory 1) (func (f32.store offset=0 (i32.const 0) (i32.const 0))))', mismatchError("i32", "f32"));
+    wasmFailValidateText('(module (memory 1) (func (f32.store offset=0 (i32.const 0) (f64.const 0))))', mismatchError("f64", "f32"));
 
-    assertErrorMessage(() => wasmEvalText('(module (memory 1) (func (i32.store offset=0 (i32.const 0) (f32.const 0))))'), TypeError, mismatchError("f32", "i32"));
-    assertErrorMessage(() => wasmEvalText('(module (memory 1) (func (i32.store offset=0 (i32.const 0) (f64.const 0))))'), TypeError, mismatchError("f64", "i32"));
+    wasmFailValidateText('(module (memory 1) (func (i32.store offset=0 (i32.const 0) (f32.const 0))))', mismatchError("f32", "i32"));
+    wasmFailValidateText('(module (memory 1) (func (i32.store offset=0 (i32.const 0) (f64.const 0))))', mismatchError("f64", "i32"));
 
     wasmEvalText('(module (memory 0 65535))')
-    assertErrorMessage(() => wasmEvalText('(module (memory 0 65536))'), TypeError, /maximum memory size too big/);
+    wasmFailValidateText('(module (memory 0 65536))', /maximum memory size too big/);
 
     // Test high charge of registers
     function testRegisters() {
         assertEq(wasmEvalText(
             `(module
               (memory 1)
               (data 0 "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")
               (data 16 "\\f0\\f1\\f2\\f3\\f4\\f5\\f6\\f7\\f8\\f9\\fa\\fb\\fc\\fd\\fe\\ff")
--- a/js/src/jit-test/tests/wasm/regress/misc-control-flow.js
+++ b/js/src/jit-test/tests/wasm/regress/misc-control-flow.js
@@ -1,28 +1,28 @@
 // |jit-test| test-also-wasm-baseline
 load(libdir + "wasm.js");
 
-assertErrorMessage(() => wasmEvalText(`(module
+wasmFailValidateText(`(module
    (func (result i32) (param i32)
      (loop (if (i32.const 0) (br 0)) (get_local 0)))
    (export "" 0)
-)`), TypeError, /unused values not explicitly dropped by end of block/);
+)`, /unused values not explicitly dropped by end of block/);
 
-assertErrorMessage(() => wasmEvalText(`(module
+wasmFailValidateText(`(module
    (func (param i32)
      (loop (if (i32.const 0) (br 0)) (get_local 0)))
    (export "" 0)
-)`), TypeError, /unused values not explicitly dropped by end of block/);
+)`, /unused values not explicitly dropped by end of block/);
 
-assertErrorMessage(() => wasmEvalText(`(module
+wasmFailValidateText(`(module
    (func (result i32) (param i32)
      (loop (if (i32.const 0) (br 0)) (drop (get_local 0))))
    (export "" 0)
-)`), TypeError, mismatchError("void", "i32"));
+)`, mismatchError("void", "i32"));
 
 assertEq(wasmEvalText(`(module
    (func (result i32) (param i32)
      (loop (if (i32.const 0) (br 0))) (get_local 0))
    (export "" 0)
 )`).exports[""](42), 42);
 
 wasmEvalText(`(module (func $func$0
@@ -153,35 +153,34 @@ wasmEvalText(`(module (func
      )
     )
     (br $in)
    )
   )
  )
 ))`);
 
-assertErrorMessage(() => wasmEvalText(`
-(module
+wasmFailValidateText(
+`(module
   (func $func$0
    (select
     (if f32
      (i32.const 0)
      (f32.const 0)
      (i32.const 0)
     )
     (if f32
      (i32.const 0)
      (f32.const 0)
      (i32.const 0)
     )
     (i32.const 0)
    )
   )
-)
-`), TypeError, mismatchError("i32", "f32"));
+)`, mismatchError("i32", "f32"));
 
 wasmEvalText(`
 (module
  (func (result i32)
   (i32.add
    (block $outer i32
     (drop (block $middle i32
      (block $inner i32
--- a/js/src/jit-test/tests/wasm/start.js
+++ b/js/src/jit-test/tests/wasm/start.js
@@ -1,20 +1,19 @@
 // |jit-test| test-also-wasm-baseline
 load(libdir + "wasm.js");
 
 assertErrorMessage(() => wasmEvalText('(module (func) (start 0) (start 0))'), SyntaxError, /wasm text error/);
-assertErrorMessage(() => wasmEvalText('(module (func) (start 1))'), TypeError, /unknown start function/);
 assertErrorMessage(() => wasmEvalText('(module (func) (start $unknown))'), SyntaxError, /label.*not found/);
 
-assertErrorMessage(() => wasmEvalText('(module (func (param i32)) (start 0))'), TypeError, /must be nullary/);
-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/);
+wasmFailValidateText('(module (func) (start 1))', /unknown start function/);
+wasmFailValidateText('(module (func (param i32)) (start 0))', /must be nullary/);
+wasmFailValidateText('(module (func (param i32) (param f32)) (start 0))', /must be nullary/);
+wasmFailValidateText('(module (func (param i32) (param f32) (param f64)) (start 0))', /must be nullary/);
+wasmFailValidateText('(module (func (result f32)) (start 0))', /must not return anything/);
 
 // Basic use case.
 var count = 0;
 function inc() { count++; }
 var exports = wasmEvalText(`(module (import $imp "" "inc") (func $f (call_import $imp)) (start $f))`, { "":{inc} }).exports;
 assertEq(count, 1);
 assertEq(Object.keys(exports).length, 0);
 
@@ -28,17 +27,17 @@ assertEq(count, 2);
 // New API.
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 
 count = 0;
 const m = new Module(wasmTextToBinary('(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/);
+assertErrorMessage(() => new Instance(m), TypeError, /second argument must be an object/);
 assertEq(count, 0);
 
 const i1 = new Instance(m, { "":{inc} });
 assertEq(count, 1);
 i1.exports[""]();
 assertEq(count, 2);
 
 const i2 = new Instance(m, { "":{inc} });
--- a/js/src/jit-test/tests/wasm/tables.js
+++ b/js/src/jit-test/tests/wasm/tables.js
@@ -3,23 +3,23 @@ load(libdir + 'wasm.js');
 
 const Module = WebAssembly.Module;
 const Instance = WebAssembly.Instance;
 const Table = WebAssembly.Table;
 const Memory = WebAssembly.Memory;
 
 var callee = i => `(func $f${i} (result i32) (i32.const ${i}))`;
 
-assertErrorMessage(() => new Module(wasmTextToBinary(`(module (elem (i32.const 0) $f0) ${callee(0)})`)), TypeError, /table index out of range/);
-assertErrorMessage(() => new Module(wasmTextToBinary(`(module (table (resizable 10)) (elem (i32.const 0) 0))`)), TypeError, /table element out of range/);
-assertErrorMessage(() => new Module(wasmTextToBinary(`(module (table (resizable 10)) (func) (elem (i32.const 0) 0 1))`)), TypeError, /table element out of range/);
-assertErrorMessage(() => new Module(wasmTextToBinary(`(module (table (resizable 10)) (func) (elem (f32.const 0) 0) ${callee(0)})`)), TypeError, /type mismatch/);
+wasmFailValidateText(`(module (elem (i32.const 0) $f0) ${callee(0)})`, /table index out of range/);
+wasmFailValidateText(`(module (table (resizable 10)) (elem (i32.const 0) 0))`, /table element out of range/);
+wasmFailValidateText(`(module (table (resizable 10)) (func) (elem (i32.const 0) 0 1))`, /table element out of range/);
+wasmFailValidateText(`(module (table (resizable 10)) (func) (elem (f32.const 0) 0) ${callee(0)})`, /type mismatch/);
 
-assertErrorMessage(() => new Module(wasmTextToBinary(`(module (table (resizable 10)) (elem (i32.const 10) $f0) ${callee(0)})`)), TypeError, /element segment does not fit/);
-assertErrorMessage(() => new Module(wasmTextToBinary(`(module (table (resizable 10)) (elem (i32.const 8) $f0 $f0 $f0) ${callee(0)})`)), TypeError, /element segment does not fit/);
+wasmFailValidateText(`(module (table (resizable 10)) (elem (i32.const 10) $f0) ${callee(0)})`, /element segment does not fit/);
+wasmFailValidateText(`(module (table (resizable 10)) (elem (i32.const 8) $f0 $f0 $f0) ${callee(0)})`, /element segment does not fit/);
 
 assertErrorMessage(() => wasmEvalText(`(module (table (resizable 10)) (import "globals" "a" (global i32 immutable)) (elem (get_global 0) $f0) ${callee(0)})`, {globals:{a:10}}), RangeError, /elem segment does not fit/);
 assertErrorMessage(() => wasmEvalText(`(module (table (resizable 10)) (import "globals" "a" (global i32 immutable)) (elem (get_global 0) $f0 $f0 $f0) ${callee(0)})`, {globals:{a:8}}), RangeError, /elem segment does not fit/);
 
 assertEq(new Module(wasmTextToBinary(`(module (table (resizable 10)) (elem (i32.const 1) $f0 $f0) (elem (i32.const 0) $f0) ${callee(0)})`)) instanceof Module, true);
 assertEq(new Module(wasmTextToBinary(`(module (table (resizable 10)) (elem (i32.const 1) $f0 $f0) (elem (i32.const 2) $f0) ${callee(0)})`)) instanceof Module, true);
 wasmEvalText(`(module (table (resizable 10)) (import "globals" "a" (global i32 immutable)) (elem (i32.const 1) $f0 $f0) (elem (get_global 0) $f0) ${callee(0)})`, {globals:{a:0}});
 wasmEvalText(`(module (table (resizable 10)) (import "globals" "a" (global i32 immutable)) (elem (get_global 0) $f0 $f0) (elem (i32.const 2) $f0) ${callee(0)})`, {globals:{a:1}});
--- a/js/src/jit-test/tests/wasm/to-text-experimental.js
+++ b/js/src/jit-test/tests/wasm/to-text-experimental.js
@@ -35,18 +35,18 @@ runTest(`
 "type $type0 of function (i32) : (f64); " +
 "export $func0 as \"test\"; " +
 "function $func0($var0: i32) : (f64) {" +
 " var $var1: f32; { $var1 = 0.0f; { loop { br_if ($var0) $label0; br $label1; } $label0: };" +
 " if (1) { f64.min(-1.0, 0.0) } else { 0.5 + f64[0] }; $label1: };" +
 " i32:16[8] = 128; return 0.0; "+
 "} memory 1, 10 {} ");
 
-assertErrorMessage(() => wasmBinaryToText(wasmTextToBinary(`
-(module
+wasmFailValidateText(
+`(module
   (func (param i32) (result f64)
      (local $l f32)
      (block
         (set_local $l (f32.const 0.0))
         (loop $cont
            (br_if $cont (get_local 0))
            (br 2)
         )
@@ -56,17 +56,17 @@ assertErrorMessage(() => wasmBinaryToTex
         ))
      )
      (i32.store16 (i32.const 8) (i32.const 128))
 
      (return (f64.const 0))
   )
   (export "test" 0)
   (memory 1 10)
-)`), "experimental"), TypeError, /popping value from empty stack/);
+)`, /popping value from empty stack/);
 
 // function calls
 runTest(`
 (module
   (type $type1 (func (param i32) (result i32)))
   (import $import1 "mod" "test" (param f32) (result f32))
   (table $func1 $func2)
   (func $func1 (param i32) (param f32) (nop))
--- a/js/src/js.msg
+++ b/js/src/js.msg
@@ -340,42 +340,40 @@ MSG_DEF(JSMSG_BAD_NEWTARGET,           0
 MSG_DEF(JSMSG_ESCAPED_KEYWORD,         0, JSEXN_SYNTAXERR, "keywords must be written literally, without embedded escapes")
 
 // asm.js
 MSG_DEF(JSMSG_USE_ASM_TYPE_FAIL,       1, JSEXN_TYPEERR, "asm.js type error: {0}")
 MSG_DEF(JSMSG_USE_ASM_LINK_FAIL,       1, JSEXN_TYPEERR, "asm.js link error: {0}")
 MSG_DEF(JSMSG_USE_ASM_TYPE_OK,         1, JSEXN_WARN,    "Successfully compiled asm.js code ({0})")
 
 // wasm
-MSG_DEF(JSMSG_WASM_FAIL,               1, JSEXN_TYPEERR,     "wasm error: {0}")
-MSG_DEF(JSMSG_WASM_DECODE_FAIL,        1, JSEXN_TYPEERR,     "wasm validation error: {0}")
-MSG_DEF(JSMSG_WASM_TEXT_FAIL,          1, JSEXN_SYNTAXERR,   "wasm text error: {0}")
-MSG_DEF(JSMSG_WASM_IND_CALL_TO_NULL,   0, JSEXN_ERR,         "indirect call to null")
-MSG_DEF(JSMSG_WASM_IND_CALL_BAD_SIG,   0, JSEXN_ERR,         "indirect call signature mismatch")
-MSG_DEF(JSMSG_WASM_BAD_GROW,           1, JSEXN_ERR,         "failed to grow {0}")
+MSG_DEF(JSMSG_WASM_COMPILE_ERROR,      1, JSEXN_WASMCOMPILEERROR, "{0}")
+MSG_DEF(JSMSG_WASM_IND_CALL_TO_NULL,   0, JSEXN_WASMRUNTIMEERROR, "indirect call to null")
+MSG_DEF(JSMSG_WASM_IND_CALL_BAD_SIG,   0, JSEXN_WASMRUNTIMEERROR, "indirect call signature mismatch")
+MSG_DEF(JSMSG_WASM_BAD_GROW,           1, JSEXN_WASMRUNTIMEERROR, "failed to grow {0}")
+MSG_DEF(JSMSG_WASM_UNREACHABLE,        0, JSEXN_WASMRUNTIMEERROR, "unreachable executed")
+MSG_DEF(JSMSG_WASM_INTEGER_OVERFLOW,   0, JSEXN_WASMRUNTIMEERROR, "integer overflow")
+MSG_DEF(JSMSG_WASM_INVALID_CONVERSION, 0, JSEXN_WASMRUNTIMEERROR, "invalid conversion to integer")
+MSG_DEF(JSMSG_WASM_INT_DIVIDE_BY_ZERO, 0, JSEXN_WASMRUNTIMEERROR, "integer divide by zero")
+MSG_DEF(JSMSG_WASM_UNALIGNED_ACCESS,   0, JSEXN_WASMRUNTIMEERROR, "unaligned memory access")
+MSG_DEF(JSMSG_WASM_BAD_UINT32,         2, JSEXN_RANGEERR,    "bad {0} {1}")
+MSG_DEF(JSMSG_WASM_BAD_FIT,            2, JSEXN_RANGEERR,    "{0} segment does not fit in {1}")
 MSG_DEF(JSMSG_WASM_BAD_BUF_ARG,        0, JSEXN_TYPEERR,     "first argument must be an ArrayBuffer or typed array object")
 MSG_DEF(JSMSG_WASM_BAD_MOD_ARG,        0, JSEXN_TYPEERR,     "first argument must be a WebAssembly.Module")
 MSG_DEF(JSMSG_WASM_BAD_DESC_ARG,       1, JSEXN_TYPEERR,     "first argument must be a {0} descriptor")
 MSG_DEF(JSMSG_WASM_BAD_IMP_SIZE,       1, JSEXN_TYPEERR,     "imported {0} with incompatible size")
-MSG_DEF(JSMSG_WASM_BAD_UINT32,         2, JSEXN_RANGEERR,    "bad {0} {1}")
 MSG_DEF(JSMSG_WASM_BAD_IMP_MAX,        1, JSEXN_TYPEERR,     "imported {0} with incompatible maximum size")
 MSG_DEF(JSMSG_WASM_BAD_ELEMENT,        0, JSEXN_TYPEERR,     "\"element\" property of table descriptor must be \"anyfunc\"")
-MSG_DEF(JSMSG_WASM_BAD_IMPORT_ARG,     0, JSEXN_TYPEERR,     "second argument, if present, must be an object")
+MSG_DEF(JSMSG_WASM_BAD_IMPORT_ARG,     0, JSEXN_TYPEERR,     "second argument must be an object")
 MSG_DEF(JSMSG_WASM_BAD_IMPORT_FIELD,   1, JSEXN_TYPEERR,     "import object field is not {0}")
 MSG_DEF(JSMSG_WASM_BAD_IMPORT_SIG,     0, JSEXN_TYPEERR,     "imported function signature mismatch")
 MSG_DEF(JSMSG_WASM_BAD_TABLE_VALUE,    0, JSEXN_TYPEERR,     "can only assign WebAssembly exported functions to Table")
 MSG_DEF(JSMSG_WASM_BAD_I64,            0, JSEXN_TYPEERR,     "cannot pass i64 to or from JS")
-MSG_DEF(JSMSG_WASM_BAD_FIT,            2, JSEXN_RANGEERR,    "{0} segment does not fit in {1}")
-MSG_DEF(JSMSG_WASM_UNREACHABLE,        0, JSEXN_ERR,         "unreachable executed")
-MSG_DEF(JSMSG_WASM_INTEGER_OVERFLOW,   0, JSEXN_ERR,         "integer overflow")
-MSG_DEF(JSMSG_WASM_INVALID_CONVERSION, 0, JSEXN_ERR,         "invalid conversion to integer")
-MSG_DEF(JSMSG_WASM_INT_DIVIDE_BY_ZERO, 0, JSEXN_ERR,         "integer divide by zero")
-MSG_DEF(JSMSG_WASM_UNALIGNED_ACCESS,   0, JSEXN_ERR,         "unaligned memory access")
-MSG_DEF(JSMSG_WASM_OVERRECURSED,       0, JSEXN_INTERNALERR, "call stack exhausted")
-MSG_DEF(JSMSG_WASM_NO_TRANSFER,        0, JSEXN_INTERNALERR, "cannot transfer WebAssembly/asm.js ArrayBuffer")
+MSG_DEF(JSMSG_WASM_NO_TRANSFER,        0, JSEXN_TYPEERR,     "cannot transfer WebAssembly/asm.js ArrayBuffer")
+MSG_DEF(JSMSG_WASM_TEXT_FAIL,          1, JSEXN_SYNTAXERR,   "wasm text error: {0}")
 
 // Proxy
 MSG_DEF(JSMSG_BAD_TRAP_RETURN_VALUE,   2, JSEXN_TYPEERR,"trap {1} for {0} returned a primitive value")
 MSG_DEF(JSMSG_BAD_GETPROTOTYPEOF_TRAP_RETURN,0,JSEXN_TYPEERR,"proxy getPrototypeOf handler returned a non-object, non-null value")
 MSG_DEF(JSMSG_INCONSISTENT_GETPROTOTYPEOF_TRAP,0,JSEXN_TYPEERR,"proxy getPrototypeOf handler didn't return the target object's prototype")
 MSG_DEF(JSMSG_PROXY_SETPROTOTYPEOF_RETURNED_FALSE, 0, JSEXN_TYPEERR, "proxy setPrototypeOf handler returned false")
 MSG_DEF(JSMSG_PROXY_ISEXTENSIBLE_RETURNED_FALSE,0,JSEXN_TYPEERR,"proxy isExtensible handler must return the same extensibility as target")
 MSG_DEF(JSMSG_INCONSISTENT_SETPROTOTYPEOF_TRAP,0,JSEXN_TYPEERR,"proxy setPrototypeOf handler returned true, even though the target's prototype is immutable because the target is non-extensible")
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -643,16 +643,18 @@ typedef enum JSExnType {
         JSEXN_INTERNALERR,
         JSEXN_EVALERR,
         JSEXN_RANGEERR,
         JSEXN_REFERENCEERR,
         JSEXN_SYNTAXERR,
         JSEXN_TYPEERR,
         JSEXN_URIERR,
         JSEXN_DEBUGGEEWOULDRUN,
+        JSEXN_WASMCOMPILEERROR,
+        JSEXN_WASMRUNTIMEERROR,
     JSEXN_WARN,
     JSEXN_LIMIT
 } JSExnType;
 
 typedef struct JSErrorFormatString {
      /** The error message name in ASCII. */
     const char* name;
 
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -111,17 +111,17 @@ ErrorObject::subErrorClassSpec_ = {
     nullptr,
     exception_methods,
     exception_properties,
     nullptr,
     JSProto_Error
 };
 
 const ClassSpec
-ErrorObject::debuggeeWouldRunClassSpec_ = {
+ErrorObject::nonGlobalErrorClassSpec_ = {
     ErrorObject::createConstructor,
     ErrorObject::createProto,
     nullptr,
     nullptr,
     exception_methods,
     exception_properties,
     nullptr,
     JSProto_Error | ClassSpec::DontDefineConstructor
@@ -133,19 +133,20 @@ ErrorObject::classes[JSEXN_LIMIT] = {
     IMPLEMENT_ERROR_CLASS(InternalError,  &ErrorObject::subErrorClassSpec_),
     IMPLEMENT_ERROR_CLASS(EvalError,      &ErrorObject::subErrorClassSpec_),
     IMPLEMENT_ERROR_CLASS(RangeError,     &ErrorObject::subErrorClassSpec_),
     IMPLEMENT_ERROR_CLASS(ReferenceError, &ErrorObject::subErrorClassSpec_),
     IMPLEMENT_ERROR_CLASS(SyntaxError,    &ErrorObject::subErrorClassSpec_),
     IMPLEMENT_ERROR_CLASS(TypeError,      &ErrorObject::subErrorClassSpec_),
     IMPLEMENT_ERROR_CLASS(URIError,       &ErrorObject::subErrorClassSpec_),
 
-    // DebuggeeWouldRun is a subclass of Error but is accessible via the
-    // Debugger constructor, not the global.
-    IMPLEMENT_ERROR_CLASS(DebuggeeWouldRun, &ErrorObject::debuggeeWouldRunClassSpec_)
+    // These Error subclasses are not accessible via the global object:
+    IMPLEMENT_ERROR_CLASS(DebuggeeWouldRun, &ErrorObject::nonGlobalErrorClassSpec_),
+    IMPLEMENT_ERROR_CLASS(CompileError,   &ErrorObject::nonGlobalErrorClassSpec_),
+    IMPLEMENT_ERROR_CLASS(RuntimeError,   &ErrorObject::nonGlobalErrorClassSpec_)
 };
 
 JSErrorReport*
 js::CopyErrorReport(JSContext* cx, JSErrorReport* report)
 {
     /*
      * We use a single malloc block to make a deep copy of JSErrorReport with
      * the following layout:
--- a/js/src/jsexn.h
+++ b/js/src/jsexn.h
@@ -59,17 +59,19 @@ static_assert(JSEXN_ERR == 0 &&
               JSProto_Error + JSEXN_INTERNALERR == JSProto_InternalError &&
               JSProto_Error + JSEXN_EVALERR == JSProto_EvalError &&
               JSProto_Error + JSEXN_RANGEERR == JSProto_RangeError &&
               JSProto_Error + JSEXN_REFERENCEERR == JSProto_ReferenceError &&
               JSProto_Error + JSEXN_SYNTAXERR == JSProto_SyntaxError &&
               JSProto_Error + JSEXN_TYPEERR == JSProto_TypeError &&
               JSProto_Error + JSEXN_URIERR == JSProto_URIError &&
               JSProto_Error + JSEXN_DEBUGGEEWOULDRUN == JSProto_DebuggeeWouldRun &&
-              JSEXN_DEBUGGEEWOULDRUN + 1 == JSEXN_WARN &&
+              JSProto_Error + JSEXN_WASMCOMPILEERROR == JSProto_CompileError &&
+              JSProto_Error + JSEXN_WASMRUNTIMEERROR == JSProto_RuntimeError &&
+              JSEXN_WASMRUNTIMEERROR + 1 == JSEXN_WARN &&
               JSEXN_WARN + 1 == JSEXN_LIMIT,
               "GetExceptionProtoKey and ExnTypeFromProtoKey require that "
               "each corresponding JSExnType and JSProtoKey value be separated "
               "by the same constant value");
 
 static inline JSProtoKey
 GetExceptionProtoKey(JSExnType exn)
 {
--- a/js/src/jsprototypes.h
+++ b/js/src/jsprototypes.h
@@ -83,46 +83,48 @@
     real(InternalError,         12,     InitViaClassSpec,       ERROR_CLASP(JSEXN_INTERNALERR)) \
     real(EvalError,             13,     InitViaClassSpec,       ERROR_CLASP(JSEXN_EVALERR)) \
     real(RangeError,            14,     InitViaClassSpec,       ERROR_CLASP(JSEXN_RANGEERR)) \
     real(ReferenceError,        15,     InitViaClassSpec,       ERROR_CLASP(JSEXN_REFERENCEERR)) \
     real(SyntaxError,           16,     InitViaClassSpec,       ERROR_CLASP(JSEXN_SYNTAXERR)) \
     real(TypeError,             17,     InitViaClassSpec,       ERROR_CLASP(JSEXN_TYPEERR)) \
     real(URIError,              18,     InitViaClassSpec,       ERROR_CLASP(JSEXN_URIERR)) \
     real(DebuggeeWouldRun,      19,     InitViaClassSpec,       ERROR_CLASP(JSEXN_DEBUGGEEWOULDRUN)) \
-    real(Iterator,              20,     InitLegacyIteratorClass,OCLASP(PropertyIterator)) \
-    real(StopIteration,         21,     InitStopIterationClass, OCLASP(StopIteration)) \
-    real(ArrayBuffer,           22,     InitArrayBufferClass,   &js::ArrayBufferObject::protoClass) \
-    real(Int8Array,             23,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Int8)) \
-    real(Uint8Array,            24,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint8)) \
-    real(Int16Array,            25,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Int16)) \
-    real(Uint16Array,           26,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint16)) \
-    real(Int32Array,            27,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Int32)) \
-    real(Uint32Array,           28,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint32)) \
-    real(Float32Array,          29,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Float32)) \
-    real(Float64Array,          30,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Float64)) \
-    real(Uint8ClampedArray,     31,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint8Clamped)) \
-    real(Proxy,                 32,     InitProxyClass,         js::ProxyClassPtr) \
-    real(WeakMap,               33,     InitWeakMapClass,       OCLASP(WeakMap)) \
-    real(Map,                   34,     InitMapClass,           OCLASP(Map)) \
-    real(Set,                   35,     InitSetClass,           OCLASP(Set)) \
-    real(DataView,              36,     InitDataViewClass,      OCLASP(DataView)) \
-    real(Symbol,                37,     InitSymbolClass,        OCLASP(Symbol)) \
-IF_SAB(real,imaginary)(SharedArrayBuffer,       38,     InitSharedArrayBufferClass, &js::SharedArrayBufferObject::protoClass) \
-IF_INTL(real,imaginary) (Intl,                  39,     InitIntlClass,          CLASP(Intl)) \
-IF_BDATA(real,imaginary)(TypedObject,           40,     InitTypedObjectModuleObject,   OCLASP(TypedObjectModule)) \
-    real(Reflect,               41,     InitReflect,            nullptr) \
-IF_SIMD(real,imaginary)(SIMD,                   42,     InitSimdClass, OCLASP(Simd)) \
-    real(WeakSet,               43,     InitWeakSetClass,       OCLASP(WeakSet)) \
-    real(TypedArray,            44,     InitViaClassSpec,       &js::TypedArrayObject::sharedTypedArrayPrototypeClass) \
-IF_SAB(real,imaginary)(Atomics, 45,     InitAtomicsClass, OCLASP(Atomics)) \
-    real(SavedFrame,            46,     InitViaClassSpec,       &js::SavedFrame::class_) \
-    real(Wasm,                  47,     InitWasmClass,          CLASP(Wasm)) \
-    real(WebAssembly,           48,     InitWebAssemblyClass,   CLASP(WebAssembly)) \
-    imaginary(WasmModule,       49,     dummy,                  dummy) \
-    imaginary(WasmInstance,     50,     dummy,                  dummy) \
-    imaginary(WasmMemory,       51,     dummy,                  dummy) \
-    imaginary(WasmTable,        52,     dummy,                  dummy) \
-IF_PROMISE(real,imaginary)(Promise,             53,     InitViaClassSpec, OCLASP(Promise)) \
+    real(CompileError,          20,     InitViaClassSpec,       ERROR_CLASP(JSEXN_WASMCOMPILEERROR)) \
+    real(RuntimeError,          21,     InitViaClassSpec,       ERROR_CLASP(JSEXN_WASMRUNTIMEERROR)) \
+    real(Iterator,              22,     InitLegacyIteratorClass,OCLASP(PropertyIterator)) \
+    real(StopIteration,         23,     InitStopIterationClass, OCLASP(StopIteration)) \
+    real(ArrayBuffer,           24,     InitArrayBufferClass,   &js::ArrayBufferObject::protoClass) \
+    real(Int8Array,             25,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Int8)) \
+    real(Uint8Array,            26,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint8)) \
+    real(Int16Array,            27,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Int16)) \
+    real(Uint16Array,           28,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint16)) \
+    real(Int32Array,            29,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Int32)) \
+    real(Uint32Array,           30,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint32)) \
+    real(Float32Array,          31,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Float32)) \
+    real(Float64Array,          32,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Float64)) \
+    real(Uint8ClampedArray,     33,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint8Clamped)) \
+    real(Proxy,                 34,     InitProxyClass,         js::ProxyClassPtr) \
+    real(WeakMap,               35,     InitWeakMapClass,       OCLASP(WeakMap)) \
+    real(Map,                   36,     InitMapClass,           OCLASP(Map)) \
+    real(Set,                   37,     InitSetClass,           OCLASP(Set)) \
+    real(DataView,              38,     InitDataViewClass,      OCLASP(DataView)) \
+    real(Symbol,                39,     InitSymbolClass,        OCLASP(Symbol)) \
+IF_SAB(real,imaginary)(SharedArrayBuffer,       40,     InitSharedArrayBufferClass, &js::SharedArrayBufferObject::protoClass) \
+IF_INTL(real,imaginary) (Intl,                  41,     InitIntlClass,          CLASP(Intl)) \
+IF_BDATA(real,imaginary)(TypedObject,           42,     InitTypedObjectModuleObject,   OCLASP(TypedObjectModule)) \
+    real(Reflect,               43,     InitReflect,            nullptr) \
+IF_SIMD(real,imaginary)(SIMD,                   44,     InitSimdClass, OCLASP(Simd)) \
+    real(WeakSet,               45,     InitWeakSetClass,       OCLASP(WeakSet)) \
+    real(TypedArray,            46,     InitViaClassSpec,       &js::TypedArrayObject::sharedTypedArrayPrototypeClass) \
+IF_SAB(real,imaginary)(Atomics, 47,     InitAtomicsClass, OCLASP(Atomics)) \
+    real(SavedFrame,            48,     InitViaClassSpec,       &js::SavedFrame::class_) \
+    real(Wasm,                  49,     InitWasmClass,          CLASP(Wasm)) \
+    real(WebAssembly,           50,     InitWebAssemblyClass,   CLASP(WebAssembly)) \
+    imaginary(WasmModule,       51,     dummy,                  dummy) \
+    imaginary(WasmInstance,     52,     dummy,                  dummy) \
+    imaginary(WasmMemory,       53,     dummy,                  dummy) \
+    imaginary(WasmTable,        54,     dummy,                  dummy) \
+IF_PROMISE(real,imaginary)(Promise,             55,     InitViaClassSpec, OCLASP(Promise)) \
 
 #define JS_FOR_EACH_PROTOTYPE(macro) JS_FOR_PROTOTYPES(macro,macro)
 
 #endif /* jsprototypes_h */
--- a/js/src/vm/ErrorObject.h
+++ b/js/src/vm/ErrorObject.h
@@ -38,17 +38,17 @@ class ErrorObject : public NativeObject
          ScopedJSFreePtr<JSErrorReport>* errorReport, HandleString fileName, HandleObject stack,
          uint32_t lineNumber, uint32_t columnNumber, HandleString message);
 
     static bool checkAndUnwrapThis(JSContext* cx, CallArgs& args, const char* fnName,
                                    MutableHandle<ErrorObject*> error);
 
     static const ClassSpec errorClassSpec_;
     static const ClassSpec subErrorClassSpec_;
-    static const ClassSpec debuggeeWouldRunClassSpec_;
+    static const ClassSpec nonGlobalErrorClassSpec_;
 
   protected:
     static const uint32_t EXNTYPE_SLOT          = 0;
     static const uint32_t STACK_SLOT            = EXNTYPE_SLOT + 1;
     static const uint32_t ERROR_REPORT_SLOT     = STACK_SLOT + 1;
     static const uint32_t FILENAME_SLOT         = ERROR_REPORT_SLOT + 1;
     static const uint32_t LINENUMBER_SLOT       = FILENAME_SLOT + 1;
     static const uint32_t COLUMNNUMBER_SLOT     = LINENUMBER_SLOT + 1;