Skip to content

Commit b5d8bc9

Browse files
committed
[ASYNCIFY] Add an assertion to getDataRewindFunc. NFC
1 parent 0552c30 commit b5d8bc9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib/libasync.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ addToLibrary({
195195
sleepCallbacks: [], // functions to call every time we sleep
196196

197197
getCallStackId(funcName) {
198+
#if ASSERTIONS
199+
assert(funcName, funcName);
200+
#endif
198201
var id = Asyncify.callStackNameToId[funcName];
199202
if (id === undefined) {
200203
id = Asyncify.callStackId++;
@@ -263,6 +266,9 @@ addToLibrary({
263266
var bottomOfCallStack = Asyncify.exportCallStack[0];
264267
#if ASYNCIFY_DEBUG >= 2
265268
dbg(`ASYNCIFY: setDataRewindFunc(${ptr}), bottomOfCallStack is`, bottomOfCallStack, new Error().stack);
269+
#endif
270+
#if ASSERTIONS
271+
assert(bottomOfCallStack, 'exportCallStack is empty');
266272
#endif
267273
var rewindId = Asyncify.getCallStackId(bottomOfCallStack);
268274
{{{ makeSetValue('ptr', C_STRUCTS.asyncify_data_s.rewind_id, 'rewindId', 'i32') }}};
@@ -271,6 +277,9 @@ addToLibrary({
271277
getDataRewindFuncName(ptr) {
272278
var id = {{{ makeGetValue('ptr', C_STRUCTS.asyncify_data_s.rewind_id, 'i32') }}};
273279
var name = Asyncify.callStackIdToName[id];
280+
#if ASSERTIONS
281+
assert(name, `id ${id} not found in callStackIdToName`);
282+
#endif
274283
return name;
275284
},
276285

@@ -279,6 +288,9 @@ addToLibrary({
279288
#endif
280289
getDataRewindFunc(name) {
281290
var func = wasmExports[name];
291+
#if ASSERTIONS
292+
assert(func, `export not found: ${name}`);
293+
#endif
282294
#if RELOCATABLE
283295
// Exported functions in side modules are not listed in `wasmExports`,
284296
// So we should use `resolveGlobalSymbol` helper function, which is defined in `library_dylink.js`.

0 commit comments

Comments
 (0)