Skip to content

Commit 14aa392

Browse files
committed
[MERGE #2180 @Cellule] WASM - combine errors
Merge pull request #2180 from Cellule:users/micfer/wasm/errors Put the WebAssembly errors in it own section to keep them all close together
2 parents cae8b48 + c974ee3 commit 14aa392

File tree

6 files changed

+29
-28
lines changed

6 files changed

+29
-28
lines changed

lib/Parser/rterrors.h

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ RT_ERROR_MSG(JSERR_DeletePropertyWithSuper, 5146, "Unable to delete property '%s
273273
RT_ERROR_MSG(JSERR_DetachedTypedArray, 5147, "%s: The ArrayBuffer is detached.", "The ArrayBuffer is detached.", kjstTypeError, 0)
274274
RT_ERROR_MSG(JSERR_AsmJsCompileError, 5148, "%s: Compiling asm.js failed.", "Compiling asm.js failed.", kjstError, 0)
275275
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)
276-
RT_ERROR_MSG(JSERR_WasmCompileError, 5150, "Compiling wasm failed: %s", "Compiling wasm failed.", kjstError, 0)
277276

278277
/* Error messages for misbehaved Async Operations for use in Promise.js */
279278
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
363362
RT_ERROR_MSG(JSERR_InvalidOperationOnTypedArray, 5664, "", "The operation is not supported on this typed array type", kjstRangeError, 0)
364363
RT_ERROR_MSG(JSERR_CannotSuspendBuffer, 5665, "", "Current agent cannot be suspended", kjstRangeError, 0)
365364
RT_ERROR_MSG(JSERR_CantDeleteNonConfigProp, 5666, "Cannot delete non-configurable property '%s'", "Cannot delete non-configurable property", kjstTypeError, 0)
366-
367-
RT_ERROR_MSG(WASMERR_Unreachable, 5667, "", "Unreachable Code", kjstWebAssemblyRuntimeError, 0)
368-
RT_ERROR_MSG(WASMERR_NeedBufferSource, 5668, "%s is not a BufferSource", "BufferSource expected", kjstTypeError, 0)
369-
RT_ERROR_MSG(WASMERR_NeedModule, 5669, "%s is not a WebAssembly.Module", "WebAssembly.Module expected", kjstTypeError, 0)
370-
RT_ERROR_MSG(WASMERR_DataSegOutOfRange, 5670, "", "Data segment is out of range", kjstTypeError, 0)
371-
RT_ERROR_MSG(WASMERR_MutableGlobal, 5671, "", "Cannot export mutable global", kjstTypeError, 0)
372-
RT_ERROR_MSG(WASMERR_InvalidImport, 5672, "", "Import is invalid", kjstTypeError, 0)
373-
RT_ERROR_MSG(WASMERR_InvalidGlobalRef, 5673, "", "Global initialization does not support forward reference", kjstTypeError, 0)
374-
RT_ERROR_MSG(WASMERR_NeedMemoryObject, 5674, "%s is not a WebAssembly.Memory", "WebAssembly.Memory object expected", kjstTypeError, 0)
375-
RT_ERROR_MSG(WASMERR_InvalidTypeConversion, 5675, "Invalid WebAssembly type conversion %s to %s", "Invalid WebAssembly type conversion", kjstTypeError, 0)
376-
RT_ERROR_MSG(WASMERR_DivideByZero, 5676, "", "Division by zero", kjstWebAssemblyRuntimeError, 0)
377-
RT_ERROR_MSG(WASMERR_ExpectedAnyFunc, 5677, "%s is not AnyFunc", "AnyFunc expected", kjstTypeError, 0)
378-
RT_ERROR_MSG(WASMERR_NeedTableObject, 5678, "%s is not a WebAssembly.Table", "WebAssembly.Table object expected", kjstTypeError, 0)
379-
RT_ERROR_MSG(WASMERR_NeedWebAssemblyFunc, 5679, "%s is not a WebAssembly exported function", "WebAssembly exported function expected", kjstTypeError, 0)
380-
RT_ERROR_MSG(WASMERR_SignatureMismatch, 5680, "%s called with invalid signature", "Function called with invalid signature", kjstWebAssemblyRuntimeError, 0)
381-
RT_ERROR_MSG(WASMERR_ElementSegOutOfRange, 5681, "", "Element segment is out of range", kjstTypeError, 0)
382-
RT_ERROR_MSG(WASMERR_TableIndexOutOfRange, 5682, "", "Table index is out of range", kjstWebAssemblyRuntimeError, 0)
383-
RT_ERROR_MSG(WASMERR_ArrayIndexOutOfRange, 5683, "", "Memory index is out of range", kjstWebAssemblyRuntimeError, 0)
384-
RT_ERROR_MSG(JSERR_CantRedefineProp, 5684, "Cannot redefine property '%s'", "Cannot redefine property", kjstTypeError, 0)
385-
RT_ERROR_MSG(WASMERR_InvalidInstantiateArgument, 5685, "", "Invalid arguments to instantiate", kjstTypeError, 0)
365+
RT_ERROR_MSG(JSERR_CantRedefineProp, 5667, "Cannot redefine property '%s'", "Cannot redefine property", kjstTypeError, 0)
366+
367+
// WebAssembly Errors
368+
RT_ERROR_MSG(WASMERR_WasmCompileError, 7000, "%s", "Compilation failed.", kjstWebAssemblyCompileError, 0)
369+
RT_ERROR_MSG(WASMERR_Unreachable, 7001, "", "Unreachable Code", kjstWebAssemblyRuntimeError, 0)
370+
RT_ERROR_MSG(WASMERR_NeedBufferSource, 7002, "%s is not a BufferSource", "BufferSource expected", kjstTypeError, 0)
371+
RT_ERROR_MSG(WASMERR_NeedModule, 7003, "%s is not a WebAssembly.Module", "WebAssembly.Module expected", kjstTypeError, 0)
372+
RT_ERROR_MSG(WASMERR_DataSegOutOfRange, 7004, "", "Data segment is out of range", kjstTypeError, 0)
373+
RT_ERROR_MSG(WASMERR_MutableGlobal, 7005, "", "Cannot export mutable global", kjstTypeError, 0)
374+
RT_ERROR_MSG(WASMERR_InvalidImport, 7006, "", "Import is invalid", kjstTypeError, 0)
375+
RT_ERROR_MSG(WASMERR_InvalidGlobalRef, 7007, "", "Global initialization does not support forward reference", kjstTypeError, 0)
376+
RT_ERROR_MSG(WASMERR_NeedMemoryObject, 7008, "%s is not a WebAssembly.Memory", "WebAssembly.Memory object expected", kjstTypeError, 0)
377+
RT_ERROR_MSG(WASMERR_InvalidTypeConversion, 7009, "Invalid WebAssembly type conversion %s to %s", "Invalid WebAssembly type conversion", kjstTypeError, 0)
378+
RT_ERROR_MSG(WASMERR_DivideByZero, 7010, "", "Division by zero", kjstWebAssemblyRuntimeError, 0)
379+
RT_ERROR_MSG(WASMERR_ExpectedAnyFunc, 7011, "%s is not AnyFunc", "AnyFunc expected", kjstTypeError, 0)
380+
RT_ERROR_MSG(WASMERR_NeedTableObject, 7012, "%s is not a WebAssembly.Table", "WebAssembly.Table object expected", kjstTypeError, 0)
381+
RT_ERROR_MSG(WASMERR_NeedWebAssemblyFunc, 7013, "%s is not a WebAssembly exported function", "WebAssembly exported function expected", kjstTypeError, 0)
382+
RT_ERROR_MSG(WASMERR_SignatureMismatch, 7014, "%s called with invalid signature", "Function called with invalid signature", kjstWebAssemblyRuntimeError, 0)
383+
RT_ERROR_MSG(WASMERR_ElementSegOutOfRange, 7015, "", "Element segment is out of range", kjstTypeError, 0)
384+
RT_ERROR_MSG(WASMERR_TableIndexOutOfRange, 7016, "", "Table index is out of range", kjstWebAssemblyRuntimeError, 0)
385+
RT_ERROR_MSG(WASMERR_ArrayIndexOutOfRange, 7017, "", "Memory index is out of range", kjstWebAssemblyRuntimeError, 0)
386+
RT_ERROR_MSG(WASMERR_InvalidInstantiateArgument, 7018, "", "Invalid arguments to instantiate", kjstTypeError, 0)

lib/Parser/screrror.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ HRESULT CompileScriptException::ProcessError(IScanner * pScan, HRESULT hr, Pars
286286
// Remove E_FAIL once we have this feature.
287287
// error during code gen - no line number info available
288288
// E_ABORT may result if compilation does stack probe while thread is in disabled state.
289-
Assert(hr == JSERR_WasmCompileError || hr == JSERR_AsmJsCompileError || hr == ERRnoMemory || hr == VBSERR_OutOfStack || hr == E_OUTOFMEMORY || hr == E_FAIL || hr == E_ABORT);
289+
Assert(hr == WASMERR_WasmCompileError || hr == JSERR_AsmJsCompileError || hr == ERRnoMemory || hr == VBSERR_OutOfStack || hr == E_OUTOFMEMORY || hr == E_FAIL || hr == E_ABORT);
290290
}
291291
return SCRIPT_E_RECORDED;
292292
}

lib/Runtime/Library/WasmLibrary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Js::JavascriptMethod Js::WasmLibrary::WasmDeferredParseEntryPoint(Js::AsmJsScrip
141141
char16* msg = newEx.ReleaseErrorMessage();
142142
JavascriptLibrary *library = scriptContext->GetLibrary();
143143
JavascriptError *pError = library->CreateWebAssemblyCompileError();
144-
JavascriptError::SetErrorMessage(pError, JSERR_WasmCompileError, msg, scriptContext);
144+
JavascriptError::SetErrorMessage(pError, WASMERR_WasmCompileError, msg, scriptContext);
145145

146146
func->GetDynamicType()->SetEntryPoint(WasmLazyTrapCallback);
147147
entypointInfo->jsMethod = WasmLazyTrapCallback;

lib/Runtime/Library/WebAssemblyModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ WebAssemblyModule::CreateModule(
217217
}
218218
JavascriptLibrary *library = scriptContext->GetLibrary();
219219
JavascriptError *pError = library->CreateWebAssemblyCompileError();
220-
JavascriptError::SetErrorMessage(pError, JSERR_WasmCompileError, newEx.ReleaseErrorMessage(), scriptContext);
220+
JavascriptError::SetErrorMessage(pError, WASMERR_WasmCompileError, newEx.ReleaseErrorMessage(), scriptContext);
221221
JavascriptExceptionOperators::Throw(pError, scriptContext);
222222
}
223223

test/wasm/baselines/api.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Test 4: Expected Error: TypeError: BufferSource expected
2121
Test 5: Expected Error: TypeError: BufferSource expected
2222
Test 6: Expected Error: TypeError: BufferSource expected
2323
Test 7: Expected Error: TypeError: BufferSource expected
24-
Test 8: Expected Error: WebAssemblyCompileError: Compiling wasm failed: Invalid LEB128 format
24+
Test 8: Expected Error: WebAssemblyCompileError: Invalid LEB128 format
2525
Test 9: Expected Error: TypeError: BufferSource expected
2626
Testing module
2727
exports
@@ -38,7 +38,7 @@ Test 4: Expected Error: TypeError: BufferSource expected
3838
Test 5: Expected Error: TypeError: BufferSource expected
3939
Test 6: Expected Error: TypeError: BufferSource expected
4040
Test 7: Expected Error: TypeError: BufferSource expected
41-
Test 8: Expected Error: WebAssemblyCompileError: Compiling wasm failed: Invalid LEB128 format
41+
Test 8: Expected Error: WebAssemblyCompileError: Invalid LEB128 format
4242
Test 9: Expected Error: TypeError: BufferSource expected
4343
Test 10: Expected Error: TypeError: Object expected
4444
Test 11: Expected Error: TypeError: Object expected
@@ -86,7 +86,7 @@ Test 6: Expected Error: TypeError: BufferSource expected
8686
Test 7: Expected Error: TypeError: BufferSource expected
8787
Test 8: Expected Error: TypeError: BufferSource expected
8888
Test 9: Expected Error: TypeError: BufferSource expected
89-
Test 10: Expected Error: WebAssemblyCompileError: Compiling wasm failed: Invalid LEB128 format
89+
Test 10: Expected Error: WebAssemblyCompileError: Invalid LEB128 format
9090
Test 11: Expected Error: TypeError: BufferSource expected
9191
Testing module
9292
exports

test/wasm/baselines/global.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ impInit: 78.145
6060
Invalid cases
6161
Should be invalid type conversion: Invalid WebAssembly type conversion
6262
Should be invalid type conversion: Invalid WebAssembly type conversion
63-
Should be invalid init expr: Compiling wasm failed: Global can only be initialized with a const or an imported global
63+
Should be invalid init expr: Global can only be initialized with a const or an imported global

0 commit comments

Comments
 (0)