@@ -1491,6 +1491,7 @@ export class Compiler extends DiagnosticEmitter {
14911491 /** Ensures that the specified string exists in static memory and returns a pointer to it. */
14921492 ensureStaticString ( stringValue : string ) : ExpressionRef {
14931493 var program = this . program ;
1494+ var module = this . module ;
14941495 var rtHeaderSize = program . runtimeHeaderSize ;
14951496 var stringInstance = assert ( program . stringInstance ) ;
14961497 var stringSegment : MemorySegment ;
@@ -1509,12 +1510,14 @@ export class Compiler extends DiagnosticEmitter {
15091510 }
15101511 var ref = i64_add ( stringSegment . offset , i64_new ( rtHeaderSize ) ) ;
15111512 this . currentType = stringInstance . type ;
1513+ var ptr : ExpressionRef ;
15121514 if ( this . options . isWasm64 ) {
1513- return this . module . i64 ( i64_low ( ref ) , i64_high ( ref ) ) ;
1515+ ptr = module . i64 ( i64_low ( ref ) , i64_high ( ref ) ) ;
15141516 } else {
15151517 assert ( i64_is_u32 ( ref ) ) ;
1516- return this . module . i32 ( i64_low ( ref ) ) ;
1518+ ptr = module . i32 ( i64_low ( ref ) ) ;
15171519 }
1520+ return module . relocMem ( ptr ) ;
15181521 }
15191522
15201523 ensureStaticArrayBuffer ( elementType : Type , values : ExpressionRef [ ] ) : MemorySegment {
@@ -7606,9 +7609,14 @@ export class Compiler extends DiagnosticEmitter {
76067609 let arraySegment = this . ensureStaticArrayHeader ( elementType , bufferSegment ) ;
76077610 let arrayAddress = i64_add ( arraySegment . offset , i64_new ( runtimeHeaderSize ) ) ;
76087611 this . currentType = arrayType ;
7609- return program . options . isWasm64
7610- ? this . module . i64 ( i64_low ( arrayAddress ) , i64_high ( arrayAddress ) )
7611- : this . module . i32 ( i64_low ( arrayAddress ) ) ;
7612+ let ptr : ExpressionRef ;
7613+ if ( program . options . isWasm64 ) {
7614+ ptr = module . i64 ( i64_low ( arrayAddress ) , i64_high ( arrayAddress ) ) ;
7615+ } else {
7616+ assert ( i64_is_u32 ( arrayAddress ) ) ;
7617+ ptr = module . i32 ( i64_low ( arrayAddress ) ) ;
7618+ }
7619+ return module . relocMem ( ptr ) ;
76127620
76137621 // otherwise allocate a new array header and make it wrap a copy of the static buffer
76147622 } else {
0 commit comments