Преглед изворни кода

Put the WebAssembly errors in it own section to keep them all close together

Michael Ferris пре 9 година
родитељ
комит
c974ee3a85

+ 22 - 21
lib/Parser/rterrors.h

@@ -273,7 +273,6 @@ RT_ERROR_MSG(JSERR_DeletePropertyWithSuper, 5146, "Unable to delete property '%s
 RT_ERROR_MSG(JSERR_DetachedTypedArray, 5147, "%s: The ArrayBuffer is detached.", "The ArrayBuffer is detached.", kjstTypeError, 0)
 RT_ERROR_MSG(JSERR_AsmJsCompileError, 5148, "%s: Compiling asm.js failed.", "Compiling asm.js failed.", kjstError, 0)
 RT_ERROR_MSG(JSERR_ImmutablePrototypeSlot, 5149, "%s: Can't set the prototype of this object.", "Can't set the prototype of this object.", kjstTypeError, 0)
-RT_ERROR_MSG(JSERR_WasmCompileError, 5150, "Compiling wasm failed: %s", "Compiling wasm failed.", kjstError, 0)
 
 /* Error messages for misbehaved Async Operations for use in Promise.js */
 RT_ERROR_MSG(ASYNCERR_NoErrorInErrorState, 5200, "", "Status is 'error', but getResults did not return an error", kjstError, 0)
@@ -363,23 +362,25 @@ RT_ERROR_MSG(JSERR_InvalidTypedArrayIndex, 5663, "", "Access index is out of ran
 RT_ERROR_MSG(JSERR_InvalidOperationOnTypedArray, 5664, "", "The operation is not supported on this typed array type", kjstRangeError, 0)
 RT_ERROR_MSG(JSERR_CannotSuspendBuffer, 5665, "", "Current agent cannot be suspended", kjstRangeError, 0)
 RT_ERROR_MSG(JSERR_CantDeleteNonConfigProp, 5666, "Cannot delete non-configurable property '%s'", "Cannot delete non-configurable property", kjstTypeError, 0)
-
-RT_ERROR_MSG(WASMERR_Unreachable, 5667, "", "Unreachable Code", kjstWebAssemblyRuntimeError, 0)
-RT_ERROR_MSG(WASMERR_NeedBufferSource, 5668, "%s is not a BufferSource", "BufferSource expected", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_NeedModule, 5669, "%s is not a WebAssembly.Module", "WebAssembly.Module expected", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_DataSegOutOfRange, 5670, "", "Data segment is out of range", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_MutableGlobal, 5671, "", "Cannot export mutable global", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_InvalidImport, 5672, "", "Import is invalid", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_InvalidGlobalRef, 5673, "", "Global initialization does not support forward reference", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_NeedMemoryObject, 5674, "%s is not a WebAssembly.Memory", "WebAssembly.Memory object expected", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_InvalidTypeConversion, 5675, "Invalid WebAssembly type conversion %s to %s", "Invalid WebAssembly type conversion", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_DivideByZero, 5676,    "",  "Division by zero", kjstWebAssemblyRuntimeError, 0)
-RT_ERROR_MSG(WASMERR_ExpectedAnyFunc, 5677, "%s is not AnyFunc", "AnyFunc expected", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_NeedTableObject, 5678, "%s is not a WebAssembly.Table", "WebAssembly.Table object expected", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_NeedWebAssemblyFunc, 5679, "%s is not a WebAssembly exported function", "WebAssembly exported function expected", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_SignatureMismatch, 5680, "%s called with invalid signature", "Function called with invalid signature", kjstWebAssemblyRuntimeError, 0)
-RT_ERROR_MSG(WASMERR_ElementSegOutOfRange, 5681, "", "Element segment is out of range", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_TableIndexOutOfRange, 5682, "", "Table index is out of range", kjstWebAssemblyRuntimeError, 0)
-RT_ERROR_MSG(WASMERR_ArrayIndexOutOfRange, 5683, "", "Memory index is out of range", kjstWebAssemblyRuntimeError, 0)
-RT_ERROR_MSG(JSERR_CantRedefineProp, 5684, "Cannot redefine property '%s'", "Cannot redefine property", kjstTypeError, 0)
-RT_ERROR_MSG(WASMERR_InvalidInstantiateArgument, 5685, "", "Invalid arguments to instantiate", kjstTypeError, 0)
+RT_ERROR_MSG(JSERR_CantRedefineProp, 5667, "Cannot redefine property '%s'", "Cannot redefine property", kjstTypeError, 0)
+
+// WebAssembly Errors
+RT_ERROR_MSG(WASMERR_WasmCompileError, 7000, "%s", "Compilation failed.", kjstWebAssemblyCompileError, 0)
+RT_ERROR_MSG(WASMERR_Unreachable, 7001, "", "Unreachable Code", kjstWebAssemblyRuntimeError, 0)
+RT_ERROR_MSG(WASMERR_NeedBufferSource, 7002, "%s is not a BufferSource", "BufferSource expected", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_NeedModule, 7003, "%s is not a WebAssembly.Module", "WebAssembly.Module expected", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_DataSegOutOfRange, 7004, "", "Data segment is out of range", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_MutableGlobal, 7005, "", "Cannot export mutable global", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_InvalidImport, 7006, "", "Import is invalid", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_InvalidGlobalRef, 7007, "", "Global initialization does not support forward reference", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_NeedMemoryObject, 7008, "%s is not a WebAssembly.Memory", "WebAssembly.Memory object expected", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_InvalidTypeConversion, 7009, "Invalid WebAssembly type conversion %s to %s", "Invalid WebAssembly type conversion", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_DivideByZero, 7010, "", "Division by zero", kjstWebAssemblyRuntimeError, 0)
+RT_ERROR_MSG(WASMERR_ExpectedAnyFunc, 7011, "%s is not AnyFunc", "AnyFunc expected", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_NeedTableObject, 7012, "%s is not a WebAssembly.Table", "WebAssembly.Table object expected", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_NeedWebAssemblyFunc, 7013, "%s is not a WebAssembly exported function", "WebAssembly exported function expected", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_SignatureMismatch, 7014, "%s called with invalid signature", "Function called with invalid signature", kjstWebAssemblyRuntimeError, 0)
+RT_ERROR_MSG(WASMERR_ElementSegOutOfRange, 7015, "", "Element segment is out of range", kjstTypeError, 0)
+RT_ERROR_MSG(WASMERR_TableIndexOutOfRange, 7016, "", "Table index is out of range", kjstWebAssemblyRuntimeError, 0)
+RT_ERROR_MSG(WASMERR_ArrayIndexOutOfRange, 7017, "", "Memory index is out of range", kjstWebAssemblyRuntimeError, 0)
+RT_ERROR_MSG(WASMERR_InvalidInstantiateArgument, 7018, "", "Invalid arguments to instantiate", kjstTypeError, 0)

+ 1 - 1
lib/Parser/screrror.cpp

@@ -286,7 +286,7 @@ HRESULT  CompileScriptException::ProcessError(IScanner * pScan, HRESULT hr, Pars
         // Remove E_FAIL once we have this feature.
         // error during code gen - no line number info available
         // E_ABORT may result if compilation does stack probe while thread is in disabled state.
-        Assert(hr == JSERR_WasmCompileError || hr == JSERR_AsmJsCompileError || hr == ERRnoMemory || hr == VBSERR_OutOfStack || hr == E_OUTOFMEMORY || hr == E_FAIL || hr == E_ABORT);
+        Assert(hr == WASMERR_WasmCompileError || hr == JSERR_AsmJsCompileError || hr == ERRnoMemory || hr == VBSERR_OutOfStack || hr == E_OUTOFMEMORY || hr == E_FAIL || hr == E_ABORT);
     }
     return SCRIPT_E_RECORDED;
 }

+ 1 - 1
lib/Runtime/Library/WasmLibrary.cpp

@@ -141,7 +141,7 @@ Js::JavascriptMethod Js::WasmLibrary::WasmDeferredParseEntryPoint(Js::AsmJsScrip
         char16* msg = newEx.ReleaseErrorMessage();
         JavascriptLibrary *library = scriptContext->GetLibrary();
         JavascriptError *pError = library->CreateWebAssemblyCompileError();
-        JavascriptError::SetErrorMessage(pError, JSERR_WasmCompileError, msg, scriptContext);
+        JavascriptError::SetErrorMessage(pError, WASMERR_WasmCompileError, msg, scriptContext);
 
         func->GetDynamicType()->SetEntryPoint(WasmLazyTrapCallback);
         entypointInfo->jsMethod = WasmLazyTrapCallback;

+ 1 - 1
lib/Runtime/Library/WebAssemblyModule.cpp

@@ -217,7 +217,7 @@ WebAssemblyModule::CreateModule(
         }
         JavascriptLibrary *library = scriptContext->GetLibrary();
         JavascriptError *pError = library->CreateWebAssemblyCompileError();
-        JavascriptError::SetErrorMessage(pError, JSERR_WasmCompileError, newEx.ReleaseErrorMessage(), scriptContext);
+        JavascriptError::SetErrorMessage(pError, WASMERR_WasmCompileError, newEx.ReleaseErrorMessage(), scriptContext);
         JavascriptExceptionOperators::Throw(pError, scriptContext);
     }
 

+ 3 - 3
test/wasm/baselines/api.baseline

@@ -21,7 +21,7 @@ Test 4: Expected Error: TypeError: BufferSource expected
 Test 5: Expected Error: TypeError: BufferSource expected
 Test 6: Expected Error: TypeError: BufferSource expected
 Test 7: Expected Error: TypeError: BufferSource expected
-Test 8: Expected Error: WebAssemblyCompileError: Compiling wasm failed: Invalid LEB128 format
+Test 8: Expected Error: WebAssemblyCompileError: Invalid LEB128 format
 Test 9: Expected Error: TypeError: BufferSource expected
 Testing module
 exports
@@ -38,7 +38,7 @@ Test 4: Expected Error: TypeError: BufferSource expected
 Test 5: Expected Error: TypeError: BufferSource expected
 Test 6: Expected Error: TypeError: BufferSource expected
 Test 7: Expected Error: TypeError: BufferSource expected
-Test 8: Expected Error: WebAssemblyCompileError: Compiling wasm failed: Invalid LEB128 format
+Test 8: Expected Error: WebAssemblyCompileError: Invalid LEB128 format
 Test 9: Expected Error: TypeError: BufferSource expected
 Test 10: Expected Error: TypeError: Object expected
 Test 11: Expected Error: TypeError: Object expected
@@ -86,7 +86,7 @@ Test 6: Expected Error: TypeError: BufferSource expected
 Test 7: Expected Error: TypeError: BufferSource expected
 Test 8: Expected Error: TypeError: BufferSource expected
 Test 9: Expected Error: TypeError: BufferSource expected
-Test 10: Expected Error: WebAssemblyCompileError: Compiling wasm failed: Invalid LEB128 format
+Test 10: Expected Error: WebAssemblyCompileError: Invalid LEB128 format
 Test 11: Expected Error: TypeError: BufferSource expected
 Testing module
 exports

+ 1 - 1
test/wasm/baselines/global.baseline

@@ -60,4 +60,4 @@ impInit: 78.145
 Invalid cases
 Should be invalid type conversion: Invalid WebAssembly type conversion
 Should be invalid type conversion: Invalid WebAssembly type conversion
-Should be invalid init expr: Compiling wasm failed: Global can only be initialized with a const or an imported global
+Should be invalid init expr: Global can only be initialized with a const or an imported global