@@ -397,13 +397,41 @@ my class MASTCompilerInstance {
397
397
}
398
398
elsif $ desired == $ MVM_reg_void {
399
399
$ reg := MAST::VOID;
400
- $ got := $ MVM_reg_void ;
401
400
}
402
401
elsif $ desired == $ MVM_reg_obj {
403
- return QAST ::MASTOperations. box(self , $ ! hll , $ got , $ reg );
402
+ # See if we already have full-width native.
403
+ if $ got == $ MVM_reg_int64 || $ got == $ MVM_reg_num64 ||
404
+ $ got == $ MVM_reg_str || $ got == $ MVM_reg_void {
405
+ return QAST ::MASTOperations. box(self , $ ! hll , $ got , $ reg );
406
+ }
407
+ elsif $ got == $ MVM_reg_num32 {
408
+ my $ grow := self . coercion($ res , $ MVM_reg_num64 );
409
+ my $ box := QAST ::MASTOperations. box(self , $ ! hll , $ MVM_reg_num64 ,
410
+ $ grow . result_reg);
411
+ $ il := $ grow . instructions;
412
+ push_ilist($ il , $ box );
413
+ $ * REGALLOC . release_register($ grow . result_reg, $ MVM_reg_num64 );
414
+ $ reg := $ box . result_reg;
415
+ }
416
+ else {
417
+ nqp ::die(" Unknown boxing case; got: " ~ $ got );
418
+ }
404
419
}
405
420
elsif $ got == $ MVM_reg_obj {
406
- return QAST ::MASTOperations. unbox(self , $ ! hll , $ desired , $ reg );
421
+ # See if we want a full-width native.
422
+ if $ desired == $ MVM_reg_int64 || $ desired == $ MVM_reg_num64 || $ desired == $ MVM_reg_str {
423
+ return QAST ::MASTOperations. unbox(self , $ ! hll , $ desired , $ reg );
424
+ }
425
+ elsif $ desired == $ MVM_reg_num32 {
426
+ my $ unbox := QAST ::MASTOperations. unbox(self , $ ! hll , $ MVM_reg_num64 , $ reg );
427
+ my $ shrink := self . coercion($ unbox , $ desired );
428
+ $ il := $ unbox . instructions;
429
+ push_ilist($ il , $ shrink );
430
+ $ reg := $ shrink . result_reg;
431
+ }
432
+ else {
433
+ nqp ::die(" Unknown unboxing case; desired: " ~ $ desired );
434
+ }
407
435
}
408
436
else {
409
437
my $ res_reg := $ * REGALLOC . fresh_register($ desired );
0 commit comments