File tree Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -46,8 +46,7 @@ addToLibrary({
4646
4747 function convertReturnValue ( ret ) {
4848 if ( returnType === 'string' ) {
49- { { { from64 ( 'ret' ) } } }
50- return UTF8ToString ( ret ) ;
49+ return UTF8ToString ( { { { from64Expr ( 'ret' ) } } } ) ;
5150 }
5251#if MEMORY64
5352 if ( returnType === 'pointer' ) return Number ( ret ) ;
Original file line number Diff line number Diff line change @@ -814,8 +814,7 @@ var LibraryDylink = {
814814 for ( var name in moduleExports ) {
815815 if ( name . startsWith ( '__em_js__' ) ) {
816816 var start = moduleExports [ name ]
817- { { { from64 ( 'start' ) } } }
818- var jsString = UTF8ToString ( start ) ;
817+ var jsString = UTF8ToString ( { { { from64Expr ( 'start' ) } } } ) ;
819818 // EM_JS strings are stored in the data section in the form
820819 // SIG<::>BODY.
821820 var parts = jsString . split ( '<::>' ) ;
Original file line number Diff line number Diff line change @@ -949,20 +949,20 @@ function receiveI64ParamAsI53Unchecked(name) {
949949 return `var ${ name } = convertI32PairToI53(${ name } _low, ${ name } _high);` ;
950950}
951951
952- // Any function called from wasm64 may have bigint args, this function takes
953- // a list of variable names to convert to number .
952+ // Convert a pointer value under wasm64 from BigInt (used at local level API
953+ // level) to Number (used in JS library code). No-op under wasm32 .
954954function from64 ( x ) {
955- if ( ! MEMORY64 ) {
956- return '' ;
957- }
958- if ( Array . isArray ( x ) ) {
959- let ret = '' ;
960- for ( e of x ) ret += from64 ( e ) ;
961- return ret ;
962- }
955+ if ( ! MEMORY64 ) return '' ;
963956 return `${ x } = Number(${ x } );` ;
964957}
965958
959+ // Like from64 above but generate an expression instead of an assignment
960+ // statement.
961+ function from64Expr ( x , assign = true ) {
962+ if ( ! MEMORY64 ) return x ;
963+ return `Number(${ x } )` ;
964+ }
965+
966966function to64 ( x ) {
967967 if ( ! MEMORY64 ) return x ;
968968 return `BigInt(${ x } )` ;
@@ -1118,6 +1118,7 @@ addToCompileTimeContext({
11181118 expectToReceiveOnModule,
11191119 formattedMinNodeVersion,
11201120 from64,
1121+ from64Expr,
11211122 getEntryFunction,
11221123 getHeapForType,
11231124 getHeapOffset,
You can’t perform that action at this time.
0 commit comments