@@ -95,12 +95,12 @@ addToLibrary({
95
95
}
96
96
} ,
97
97
#if ASYNCIFY == 1 && MEMORY64
98
- saveOrRestoreRewindArguments ( funcName , passedArguments ) {
99
- if ( passedArguments . length === 0 ) {
100
- return Asyncify . rewindArguments [ funcName ] || [ ]
101
- }
98
+ saveRewindArguments ( funcName , passedArguments ) {
102
99
return Asyncify . rewindArguments [ funcName ] = Array . from ( passedArguments )
103
100
} ,
101
+ restoreRewindArguments ( funcName ) {
102
+ return Asyncify . rewindArguments [ funcName ] || [ ]
103
+ } ,
104
104
#endif
105
105
instrumentWasmExports ( exports ) {
106
106
#if ASYNCIFY_DEBUG
@@ -130,14 +130,9 @@ addToLibrary({
130
130
try {
131
131
#endif
132
132
#if ASYNCIFY == 1 && MEMORY64
133
- // When re-winding, the arguments to a function are ignored. For i32 arguments we
134
- // can just call the function with no args at all since and the engine will produce zeros
135
- // for all arguments. However, for i64 arguments we get `undefined cannot be converted to
136
- // BigInt`.
137
- return original ( ...Asyncify . saveOrRestoreRewindArguments ( x , args ) ) ;
138
- #else
139
- return original ( ...args ) ;
133
+ Asyncify . saveRewindArguments ( x , args ) ;
140
134
#endif
135
+ return original ( ...args ) ;
141
136
#if ASYNCIFY == 1
142
137
} finally {
143
138
if ( ! ABORT ) {
@@ -265,12 +260,16 @@ addToLibrary({
265
260
{ { { makeSetValue ( 'ptr' , C_STRUCTS . asyncify_data_s . rewind_id , 'rewindId' , 'i32' ) } } } ;
266
261
} ,
267
262
263
+ getDataRewindFuncName ( ptr ) {
264
+ var id = { { { makeGetValue ( 'ptr' , C_STRUCTS . asyncify_data_s . rewind_id , 'i32' ) } } } ;
265
+ var name = Asyncify . callStackIdToName [ id ] ;
266
+ return name ;
267
+ } ,
268
+
268
269
#if RELOCATABLE
269
270
getDataRewindFunc__deps : [ '$resolveGlobalSymbol ' ] ,
270
271
#endif
271
- getDataRewindFunc ( ptr ) {
272
- var id = { { { makeGetValue ( 'ptr' , C_STRUCTS . asyncify_data_s . rewind_id , 'i32' ) } } } ;
273
- var name = Asyncify . callStackIdToName [ id ] ;
272
+ getDataRewindFunc ( name ) {
274
273
var func = wasmExports [ name ] ;
275
274
#if RELOCATABLE
276
275
// Exported functions in side modules are not listed in `wasmExports`,
@@ -283,14 +282,23 @@ addToLibrary({
283
282
} ,
284
283
285
284
doRewind ( ptr ) {
286
- var start = Asyncify . getDataRewindFunc ( ptr ) ;
285
+ var name = Asyncify . getDataRewindFuncName ( ptr ) ;
286
+ var func = Asyncify . getDataRewindFunc ( name ) ;
287
287
#if ASYNCIFY_DEBUG
288
- dbg ( 'ASYNCIFY: start :' , start ) ;
288
+ dbg ( 'ASYNCIFY: doRewind :' , name ) ;
289
289
#endif
290
290
// Once we have rewound and the stack we no longer need to artificially
291
291
// keep the runtime alive.
292
292
{ { { runtimeKeepalivePop( ) ; } } }
293
- return start ( ) ;
293
+ #if MEMORY64
294
+ // When re-winding, the arguments to a function are ignored. For i32 arguments we
295
+ // can just call the function with no args at all since and the engine will produce zeros
296
+ // for all arguments. However, for i64 arguments we get `undefined cannot be converted to
297
+ // BigInt`.
298
+ return func ( ...Asyncify . restoreRewindArguments ( name ) ) ;
299
+ #else
300
+ return func ( ) ;
301
+ #endif
294
302
} ,
295
303
296
304
// This receives a function to call to start the async operation, and
@@ -441,7 +449,7 @@ addToLibrary({
441
449
} ,
442
450
makeAsyncFunction ( original ) {
443
451
#if ASYNCIFY_DEBUG
444
- dbg ( 'asyncify: returnPromiseOnSuspend for' , original ) ;
452
+ dbg ( 'asyncify: makeAsyncFunction for' , original ) ;
445
453
#endif
446
454
return WebAssembly . promising ( original ) ;
447
455
} ,
0 commit comments