Skip to content

Commit 4b6fb30

Browse files
committed
Create new type WebAssembly.LinkError
1 parent 6a8a129 commit 4b6fb30

7 files changed

Lines changed: 36 additions & 1 deletion

File tree

lib/Parser/ParserCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum ErrorTypeEnum
2727
kjstURIError,
2828
kjstWebAssemblyCompileError,
2929
kjstWebAssemblyRuntimeError,
30+
kjstWebAssemblyLinkError,
3031
kjstCustomError,
3132
#ifdef ENABLE_PROJECTION
3233
kjstWinRTError,

lib/Runtime/Base/JnDirectFields.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ ENTRY(Memory)
283283
ENTRY(Table)
284284
ENTRY(CompileError)
285285
ENTRY(RuntimeError)
286+
ENTRY(LinkError)
286287
ENTRY(validate)
287288
ENTRY(instantiate)
288289
ENTRY(grow)

lib/Runtime/Library/JavascriptBuiltInFunctionList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ BUILTIN(JavascriptError, NewTypeErrorInstance, NewTypeErrorInstance, FunctionInf
131131
BUILTIN(JavascriptError, NewURIErrorInstance, NewURIErrorInstance, FunctionInfo::None)
132132
BUILTIN(JavascriptError, NewWebAssemblyCompileErrorInstance, NewWebAssemblyCompileErrorInstance, FunctionInfo::None)
133133
BUILTIN(JavascriptError, NewWebAssemblyRuntimeErrorInstance, NewWebAssemblyRuntimeErrorInstance, FunctionInfo::None)
134+
BUILTIN(JavascriptError, NewWebAssemblyLinkErrorInstance, NewWebAssemblyLinkErrorInstance, FunctionInfo::None)
134135
#ifdef ENABLE_PROJECTION
135136
BUILTIN(JavascriptError, NewWinRTErrorInstance, NewWinRTErrorInstance, FunctionInfo::None)
136137
#endif

lib/Runtime/Library/JavascriptError.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ namespace Js
146146
NEW_ERROR(URIError);
147147
NEW_ERROR(WebAssemblyCompileError);
148148
NEW_ERROR(WebAssemblyRuntimeError);
149+
NEW_ERROR(WebAssemblyLinkError);
149150

150151
#undef NEW_ERROR
151152

@@ -301,6 +302,7 @@ namespace Js
301302
THROW_ERROR_IMPL(ThrowURIError, CreateURIError, GetURIErrorType, kjstURIError)
302303
THROW_ERROR_IMPL(ThrowWebAssemblyCompileError, CreateWebAssemblyCompileError, GetWebAssemblyCompileErrorType, kjstWebAssemblyCompileError)
303304
THROW_ERROR_IMPL(ThrowWebAssemblyRuntimeError, CreateWebAssemblyRuntimeError, GetWebAssemblyRuntimeErrorType, kjstWebAssemblyRuntimeError)
305+
THROW_ERROR_IMPL(ThrowWebAssemblyLinkError, CreateWebAssemblyLinkError, GetWebAssemblyLinkErrorType, kjstWebAssemblyLinkError)
304306
#undef THROW_ERROR_IMPL
305307

306308
void __declspec(noreturn) JavascriptError::ThrowUnreachable(ScriptContext* scriptContext) { ThrowWebAssemblyRuntimeError(scriptContext, WASMERR_Unreachable); }
@@ -324,6 +326,8 @@ namespace Js
324326
return CreateWebAssemblyCompileError(scriptContext);
325327
case kjstWebAssemblyRuntimeError:
326328
return CreateWebAssemblyRuntimeError(scriptContext);
329+
case kjstWebAssemblyLinkError:
330+
return CreateWebAssemblyLinkError(scriptContext);
327331
default:
328332
AssertMsg(FALSE, "Invalid error type");
329333
__assume(false);
@@ -784,6 +788,8 @@ namespace Js
784788
jsNewError = targetJavascriptLibrary->CreateWebAssemblyCompileError();
785789
case kjstWebAssemblyRuntimeError:
786790
jsNewError = targetJavascriptLibrary->CreateWebAssemblyRuntimeError();
791+
case kjstWebAssemblyLinkError:
792+
jsNewError = targetJavascriptLibrary->CreateWebAssemblyLinkError();
787793

788794
case kjstCustomError:
789795
default:

lib/Runtime/Library/JavascriptError.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ namespace Js
6262
static FunctionInfo NewURIErrorInstance;
6363
static FunctionInfo NewWebAssemblyCompileErrorInstance;
6464
static FunctionInfo NewWebAssemblyRuntimeErrorInstance;
65+
static FunctionInfo NewWebAssemblyLinkErrorInstance;
6566
#ifdef ENABLE_PROJECTION
6667
static FunctionInfo NewWinRTErrorInstance;
6768
#endif
@@ -77,6 +78,7 @@ namespace Js
7778
static Var NewURIErrorInstance(RecyclableObject* function, CallInfo callInfo, ...);
7879
static Var NewWebAssemblyCompileErrorInstance(RecyclableObject* function, CallInfo callInfo, ...);
7980
static Var NewWebAssemblyRuntimeErrorInstance(RecyclableObject* function, CallInfo callInfo, ...);
81+
static Var NewWebAssemblyLinkErrorInstance(RecyclableObject* function, CallInfo callInfo, ...);
8082
#ifdef ENABLE_PROJECTION
8183
static Var NewWinRTErrorInstance(RecyclableObject* function, CallInfo callInfo, ...);
8284
#endif
@@ -105,6 +107,7 @@ namespace Js
105107
THROW_ERROR_DECL(ThrowURIError)
106108
THROW_ERROR_DECL(ThrowWebAssemblyCompileError)
107109
THROW_ERROR_DECL(ThrowWebAssemblyRuntimeError)
110+
THROW_ERROR_DECL(ThrowWebAssemblyLinkError)
108111

109112
#undef THROW_ERROR_DECL
110113
static void __declspec(noreturn) ThrowDispatchError(ScriptContext* scriptContext, HRESULT hCode, PCWSTR message);

lib/Runtime/Library/JavascriptLibrary.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ namespace Js
311311
{
312312
INIT_ERROR_PROTO(webAssemblyCompileErrorPrototype, InitializeWebAssemblyCompileErrorPrototype);
313313
INIT_ERROR_PROTO(webAssemblyRuntimeErrorPrototype, InitializeWebAssemblyRuntimeErrorPrototype);
314+
INIT_ERROR_PROTO(webAssemblyLinkErrorPrototype, InitializeWebAssemblyLinkErrorPrototype);
314315
}
315316
#endif
316317

@@ -471,6 +472,7 @@ namespace Js
471472
{
472473
INIT_SIMPLE_TYPE(webAssemblyCompileErrorType, TypeIds_Error, webAssemblyCompileErrorPrototype);
473474
INIT_SIMPLE_TYPE(webAssemblyRuntimeErrorType, TypeIds_Error, webAssemblyRuntimeErrorPrototype);
475+
INIT_SIMPLE_TYPE(webAssemblyLinkErrorType, TypeIds_Error, webAssemblyLinkErrorPrototype);
474476
}
475477
#endif
476478

@@ -826,6 +828,9 @@ namespace Js
826828

827829
case kjstWebAssemblyRuntimeError:
828830
return GetWebAssemblyRuntimeErrorType();
831+
832+
case kjstWebAssemblyLinkError:
833+
return GetWebAssemblyLinkErrorType();
829834
}
830835

831836
return nullptr;
@@ -1525,6 +1530,10 @@ namespace Js
15251530
DeferredTypeHandler<InitializeWebAssemblyRuntimeErrorConstructor>::GetDefaultInstance(),
15261531
nativeErrorPrototype);
15271532

1533+
webAssemblyLinkErrorConstructor = CreateBuiltinConstructor(&JavascriptError::EntryInfo::NewWebAssemblyLinkErrorInstance,
1534+
DeferredTypeHandler<InitializeWebAssemblyLinkErrorConstructor>::GetDefaultInstance(),
1535+
nativeErrorPrototype);
1536+
15281537
webAssemblyInstanceConstructor = CreateBuiltinConstructor(&WebAssemblyInstance::EntryInfo::NewInstance,
15291538
DeferredTypeHandler<InitializeWebAssemblyInstanceConstructor>::GetDefaultInstance(), webAssemblyInstancePrototype);
15301539

@@ -2101,6 +2110,7 @@ namespace Js
21012110
INIT_ERROR(URIError);
21022111
INIT_ERROR(WebAssemblyCompileError);
21032112
INIT_ERROR(WebAssemblyRuntimeError);
2113+
INIT_ERROR(WebAssemblyLinkError);
21042114

21052115
#undef INIT_ERROR
21062116

@@ -2842,6 +2852,7 @@ namespace Js
28422852

28432853
library->AddFunction(webAssemblyObject, PropertyIds::CompileError, library->webAssemblyCompileErrorConstructor);
28442854
library->AddFunction(webAssemblyObject, PropertyIds::RuntimeError, library->webAssemblyRuntimeErrorConstructor);
2855+
library->AddFunction(webAssemblyObject, PropertyIds::LinkError, library->webAssemblyLinkErrorConstructor);
28452856
library->AddFunction(webAssemblyObject, PropertyIds::Memory, library->webAssemblyMemoryConstructor);
28462857
library->AddFunction(webAssemblyObject, PropertyIds::Table, library->webAssemblyTableConstructor);
28472858
}
@@ -6215,6 +6226,9 @@ namespace Js
62156226
case kjstWebAssemblyRuntimeError:
62166227
baseErrorType = webAssemblyRuntimeErrorType;
62176228
break;
6229+
case kjstWebAssemblyLinkError:
6230+
baseErrorType = webAssemblyLinkErrorType;
6231+
break;
62186232
}
62196233

62206234
JavascriptError *pError = RecyclerNew(recycler, JavascriptError, baseErrorType, TRUE);
@@ -6239,6 +6253,7 @@ namespace Js
62396253
CREATE_ERROR(URIError, uriErrorType, kjstURIError);
62406254
CREATE_ERROR(WebAssemblyCompileError, webAssemblyCompileErrorType, kjstWebAssemblyCompileError);
62416255
CREATE_ERROR(WebAssemblyRuntimeError, webAssemblyRuntimeErrorType, kjstWebAssemblyRuntimeError);
6256+
CREATE_ERROR(WebAssemblyLinkError, webAssemblyLinkErrorType, kjstWebAssemblyLinkError);
62426257

62436258
#undef CREATE_ERROR
62446259

lib/Runtime/Library/JavascriptLibrary.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ namespace Js
261261
DynamicType * uriErrorType;
262262
DynamicType * webAssemblyCompileErrorType;
263263
DynamicType * webAssemblyRuntimeErrorType;
264+
DynamicType * webAssemblyLinkErrorType;
264265
StaticType * numberTypeStatic;
265266
StaticType * int64NumberTypeStatic;
266267
StaticType * uint64NumberTypeStatic;
@@ -426,6 +427,8 @@ namespace Js
426427
RuntimeFunction* webAssemblyCompileErrorConstructor;
427428
DynamicObject* webAssemblyRuntimeErrorPrototype;
428429
RuntimeFunction* webAssemblyRuntimeErrorConstructor;
430+
DynamicObject* webAssemblyLinkErrorPrototype;
431+
RuntimeFunction* webAssemblyLinkErrorConstructor;
429432

430433
DynamicObject* webAssemblyMemoryPrototype;
431434
RuntimeFunction* webAssemblyMemoryConstructor;
@@ -673,6 +676,8 @@ namespace Js
673676
DynamicObject* GetWebAssemblyCompileErrorConstructor() const { return webAssemblyCompileErrorConstructor; }
674677
DynamicObject* GetWebAssemblyRuntimeErrorPrototype() const { return webAssemblyRuntimeErrorPrototype; }
675678
DynamicObject* GetWebAssemblyRuntimeErrorConstructor() const { return webAssemblyRuntimeErrorConstructor; }
679+
DynamicObject* GetWebAssemblyLinkErrorPrototype() const { return webAssemblyLinkErrorPrototype; }
680+
DynamicObject* GetWebAssemblyLinkErrorConstructor() const { return webAssemblyLinkErrorConstructor; }
676681

677682
#if ENABLE_TTD
678683
Js::PropertyId ExtractPrimitveSymbolId_TTD(Var value);
@@ -749,8 +754,9 @@ namespace Js
749754
DynamicType * GetSyntaxErrorType() const { return syntaxErrorType; }
750755
DynamicType * GetTypeErrorType() const { return typeErrorType; }
751756
DynamicType * GetURIErrorType() const { return uriErrorType; }
752-
DynamicType * GetWebAssemblyRuntimeErrorType() const { return webAssemblyRuntimeErrorType; }
753757
DynamicType * GetWebAssemblyCompileErrorType() const { return webAssemblyCompileErrorType; }
758+
DynamicType * GetWebAssemblyRuntimeErrorType() const { return webAssemblyRuntimeErrorType; }
759+
DynamicType * GetWebAssemblyLinkErrorType() const { return webAssemblyLinkErrorType; }
754760
StaticType * GetNumberTypeStatic() const { return numberTypeStatic; }
755761
StaticType * GetInt64TypeStatic() const { return int64NumberTypeStatic; }
756762
StaticType * GetUInt64TypeStatic() const { return uint64NumberTypeStatic; }
@@ -961,6 +967,7 @@ namespace Js
961967
JavascriptError* CreateOutOfMemoryError();
962968
JavascriptError* CreateWebAssemblyCompileError();
963969
JavascriptError* CreateWebAssemblyRuntimeError();
970+
JavascriptError* CreateWebAssemblyLinkError();
964971
JavascriptSymbol* CreateSymbol(JavascriptString* description);
965972
JavascriptSymbol* CreateSymbol(const char16* description, int descriptionLength);
966973
JavascriptSymbol* CreateSymbol(const PropertyRecord* propertyRecord);
@@ -1225,6 +1232,7 @@ namespace Js
12251232
STANDARD_INIT(AsyncFunction);
12261233
STANDARD_INIT(WebAssemblyCompileError);
12271234
STANDARD_INIT(WebAssemblyRuntimeError);
1235+
STANDARD_INIT(WebAssemblyLinkError);
12281236
STANDARD_INIT(WebAssemblyMemory);
12291237
STANDARD_INIT(WebAssemblyModule);
12301238
STANDARD_INIT(WebAssemblyInstance);

0 commit comments

Comments
 (0)