@@ -201,9 +201,30 @@ var LibraryDylink = {
201
201
#endif
202
202
;
203
203
} ,
204
+ $setGOTEntry__deps: [ '$addFunction' , '$getFunctionAddress' ] ,
205
+ $setGOTEntry : ( symName , value ) => {
206
+ const entry = GOT [ symName ] ;
207
+ #if DYLINK_DEBUG == 2
208
+ dbg ( `setGOTEntry: before: ${ symName } : ${ entry . value } ` ) ;
209
+ #endif
210
+ if ( typeof value == 'function' ) {
211
+ entry . value = { { { to64 ( 'addFunction(value, value.sig)' ) } } } ;
212
+ } else if ( typeof value == 'number' ) {
213
+ entry . value = { { { to64 ( 'value' ) } } } ;
214
+ #if MEMORY64
215
+ } else if ( typeof value == 'bigint' ) {
216
+ entry . value = value ;
217
+ #endif
218
+ } else {
219
+ throw new Error ( `bad export type for '${ symName } ': ${ typeof value } ` ) ;
220
+ }
221
+ #if DYLINK_DEBUG == 2
222
+ dbg ( `setGOTEntry: after: ${ symName } ${ typeof value } : ${ entry . value } (${ value } )` ) ;
223
+ #endif
224
+ } ,
204
225
205
226
$updateGOT__internal: true ,
206
- $updateGOT__deps : [ '$GOT' , '$isInternalSym' , '$addFunction' , '$getFunctionAddress '] ,
227
+ $updateGOT__deps : [ '$GOT' , '$isInternalSym' , '$setGOTEntry ' ] ,
207
228
$updateGOT : ( exports , replace ) = > {
208
229
#if DYLINK_DEBUG
209
230
dbg ( "updateGOT: adding " + Object . keys ( exports ) . length + " symbols" ) ;
@@ -223,22 +244,7 @@ var LibraryDylink = {
223
244
224
245
GOT [ symName ] ||= new WebAssembly . Global ( { 'value' : '{{{ POINTER_WASM_TYPE }}}' , 'mutable' : true } ) ;
225
246
if ( replace || GOT [ symName ] . value == 0 ) {
226
- #if DYLINK_DEBUG == 2
227
- dbg ( `updateGOT: before: ${ symName } : ${ GOT [ symName ] . value } ` ) ;
228
- #endif
229
- if ( typeof value == 'function' ) {
230
- GOT [ symName ] . value = { { { to64 ( 'addFunction(value)' ) } } } ;
231
- #if DYLINK_DEBUG == 2
232
- dbg ( `updateGOT: FUNC: ${ symName } : ${ GOT [ symName ] . value } ` ) ;
233
- #endif
234
- } else if ( typeof value == { { { POINTER_JS_TYPE } } } ) {
235
- GOT [ symName ] . value = value ;
236
- } else {
237
- err ( `unhandled export type for '${ symName } ': ${ typeof value } ` ) ;
238
- }
239
- #if DYLINK_DEBUG == 2
240
- dbg ( `updateGOT: after: ${ symName } : ${ GOT [ symName ] . value } (${ value } )` ) ;
241
- #endif
247
+ setGOTEntry ( symName , value ) ;
242
248
}
243
249
#if DYLINK_DEBUG
244
250
else if ( GOT [ symName ] . value != value ) {
@@ -303,21 +309,7 @@ var LibraryDylink = {
303
309
#if DYLINK_DEBUG == 2
304
310
dbg ( `assigning dynamic symbol from main module: ${ symName } -> ${ prettyPrint ( value ) } ` ) ;
305
311
#endif
306
- if ( typeof value == 'function' ) {
307
- /** @suppress {checkTypes} */
308
- entry . value = { { { to64 ( 'addFunction(value, value.sig)' ) } } } ;
309
- #if DYLINK_DEBUG == 2
310
- dbg ( `assigning table entry for : ${ symName } -> ${ entry . value } ` ) ;
311
- #endif
312
- } else if ( typeof value == 'number' ) {
313
- entry . value = { { { to64 ( 'value' ) } } } ;
314
- #if MEMORY64
315
- } else if ( typeof value == 'bigint' ) {
316
- entry . value = value ;
317
- #endif
318
- } else {
319
- throw new Error ( `bad export type for '${ symName } ': ${ typeof value } ` ) ;
320
- }
312
+ setGOTEntry ( symName , value ) ;
321
313
}
322
314
}
323
315
#if DYLINK_DEBUG
0 commit comments