@@ -548,15 +548,16 @@ fn instruction(js: &mut JsBuilder, instr: &Instruction, log_error: &mut bool) ->
548
548
| Instruction :: CallExport ( _)
549
549
| Instruction :: CallAdapter ( _)
550
550
| Instruction :: CallTableElement ( _)
551
- | Instruction :: DeferCallCore ( _ ) => {
551
+ | Instruction :: DeferFree { .. } => {
552
552
let invoc = Invocation :: from ( instr, js. cx . module ) ?;
553
553
let ( mut params, results) = invoc. params_results ( js. cx ) ;
554
-
555
554
let mut args = Vec :: new ( ) ;
556
555
let tmp = js. tmp ( ) ;
557
556
if invoc. defer ( ) {
558
- // substract alignment
559
- params -= 1 ;
557
+ if let Instruction :: DeferFree { .. } = instr {
558
+ // substract alignment
559
+ params -= 1 ;
560
+ }
560
561
// If the call is deferred, the arguments to the function still need to be
561
562
// accessible in the `finally` block, so we declare variables to hold the args
562
563
// outside of the try-finally block and then set those to the args.
@@ -566,19 +567,19 @@ fn instruction(js: &mut JsBuilder, instr: &Instruction, log_error: &mut bool) ->
566
567
writeln ! ( js. prelude, "{name} = {arg};" ) . unwrap ( ) ;
567
568
args. push ( name) ;
568
569
}
569
- // add alignment
570
- args. push ( String :: from ( "4" ) ) ;
570
+ if let Instruction :: DeferFree { align, .. } = instr {
571
+ // add alignment
572
+ args. push ( align. to_string ( ) ) ;
573
+ }
571
574
} else {
572
575
// Otherwise, pop off the number of parameters for the function we're calling.
573
576
for _ in 0 ..params {
574
577
args. push ( js. pop ( ) ) ;
575
578
}
576
579
args. reverse ( ) ;
577
580
}
578
-
579
581
// Call the function through an export of the underlying module.
580
582
let call = invoc. invoke ( js. cx , & args, & mut js. prelude , log_error) ?;
581
-
582
583
// And then figure out how to actually handle where the call
583
584
// happens. This is pretty conditional depending on the number of
584
585
// return values of the function.
@@ -1194,8 +1195,8 @@ impl Invocation {
1194
1195
defer : false ,
1195
1196
} ,
1196
1197
1197
- DeferCallCore ( f ) => Invocation :: Core {
1198
- id : * f ,
1198
+ DeferFree { free , .. } => Invocation :: Core {
1199
+ id : * free ,
1199
1200
defer : true ,
1200
1201
} ,
1201
1202
0 commit comments