@@ -449,10 +449,9 @@ export function generateWasmBody (
449
449
if ( pruneOpcodes ) {
450
450
// We emit an unreachable opcode so that if execution somehow reaches a pruned opcode, we will abort
451
451
// This should be impossible anyway but it's also useful to have pruning visible in the wasm
452
- // FIXME: Ideally we would stop generating opcodes after the first unreachable, but that causes v8 to hang
453
452
if ( ! hasEmittedUnreachable )
454
453
builder . appendU8 ( WasmOpcode . unreachable ) ;
455
- // Each unreachable opcode could generate a bunch of native code in a bad wasm jit so generate nops after it
454
+ // Don't generate multiple unreachable opcodes in a row
456
455
hasEmittedUnreachable = true ;
457
456
}
458
457
break ;
@@ -467,7 +466,7 @@ export function generateWasmBody (
467
466
}
468
467
case MintOpcode . MINT_LOCALLOC : {
469
468
// dest
470
- append_ldloca ( builder , getArgU16 ( ip , 1 ) ) ;
469
+ append_ldloca ( builder , getArgU16 ( ip , 1 ) , 0 ) ;
471
470
// len
472
471
append_ldloc ( builder , getArgU16 ( ip , 2 ) , WasmOpcode . i32_load ) ;
473
472
// frame
@@ -648,10 +647,12 @@ export function generateWasmBody (
648
647
// locals[ip[1]] = &locals[ip[2]]
649
648
const offset = getArgU16 ( ip , 2 ) ,
650
649
flag = isAddressTaken ( builder , offset ) ,
651
- destOffset = getArgU16 ( ip , 1 ) ;
650
+ destOffset = getArgU16 ( ip , 1 ) ,
651
+ // Size value stored for us by emit_compacted_instruction so we can do invalidation
652
+ size = getArgU16 ( ip , 3 ) ;
652
653
if ( ! flag )
653
654
mono_log_error ( `${ traceName } : Expected local ${ offset } to have address taken flag` ) ;
654
- append_ldloca ( builder , offset ) ;
655
+ append_ldloca ( builder , offset , size ) ;
655
656
append_stloc_tail ( builder , destOffset , WasmOpcode . i32_store ) ;
656
657
// Record this ldloca as a known constant so that later uses of it turn into a lea,
657
658
// and the wasm runtime can constant fold them with other constants. It's not uncommon
@@ -875,9 +876,8 @@ export function generateWasmBody (
875
876
}
876
877
877
878
case MintOpcode . MINT_LD_DELEGATE_METHOD_PTR : {
878
- // FIXME: ldloca invalidation size
879
- append_ldloca ( builder , getArgU16 ( ip , 1 ) , 8 ) ;
880
- append_ldloca ( builder , getArgU16 ( ip , 2 ) , 8 ) ;
879
+ append_ldloca ( builder , getArgU16 ( ip , 1 ) , 4 ) ;
880
+ append_ldloca ( builder , getArgU16 ( ip , 2 ) , 4 ) ;
881
881
builder . callImport ( "ld_del_ptr" ) ;
882
882
break ;
883
883
}
@@ -1383,7 +1383,9 @@ export function generateWasmBody (
1383
1383
( builder . callHandlerReturnAddresses . length <= maxCallHandlerReturnAddresses )
1384
1384
) {
1385
1385
// mono_log_info(`endfinally @0x${(<any>ip).toString(16)}. return addresses:`, builder.callHandlerReturnAddresses.map(ra => (<any>ra).toString(16)));
1386
- // FIXME: Clean this codegen up
1386
+ // FIXME: Replace this with a chain of selects to more efficiently map from RA -> index, then
1387
+ // a single jump table at the end to jump to the right place. This will generate much smaller
1388
+ // code and be able to handle a larger number of return addresses.
1387
1389
// Load ret_ip
1388
1390
const clauseIndex = getArgU16 ( ip , 1 ) ,
1389
1391
clauseDataOffset = get_imethod_clause_data_offset ( frame , clauseIndex ) ;
@@ -1972,10 +1974,7 @@ function append_stloc_tail (builder: WasmBuilder, offset: number, opcodeOrPrefix
1972
1974
1973
1975
// Pass bytesInvalidated=0 if you are reading from the local and the address will never be
1974
1976
// used for writes
1975
- function append_ldloca ( builder : WasmBuilder , localOffset : number , bytesInvalidated ?: number ) {
1976
- if ( typeof ( bytesInvalidated ) !== "number" )
1977
- bytesInvalidated = 512 ;
1978
- // FIXME: We need to know how big this variable is so we can invalidate the whole space it occupies
1977
+ function append_ldloca ( builder : WasmBuilder , localOffset : number , bytesInvalidated : number ) {
1979
1978
if ( bytesInvalidated > 0 )
1980
1979
invalidate_local_range ( localOffset , bytesInvalidated ) ;
1981
1980
builder . lea ( "pLocals" , localOffset ) ;
@@ -2476,7 +2475,8 @@ function emit_sfieldop (
2476
2475
builder . ptr_const ( pStaticData ) ;
2477
2476
// src
2478
2477
append_ldloca ( builder , localOffset , 0 ) ;
2479
- // FIXME: Use mono_gc_wbarrier_set_field_internal
2478
+ // We don't need to use gc_wbarrier_set_field_internal here because there's no object
2479
+ // reference, interp does a raw write
2480
2480
builder . callImport ( "copy_ptr" ) ;
2481
2481
return true ;
2482
2482
case MintOpcode . MINT_LDSFLD_VT : {
@@ -2903,7 +2903,6 @@ function emit_branch (
2903
2903
) ;
2904
2904
2905
2905
cwraps . mono_jiterp_boost_back_branch_target ( destination ) ;
2906
- // FIXME: Should there be a safepoint here?
2907
2906
append_bailout ( builder , destination , BailoutReason . BackwardBranch ) ;
2908
2907
modifyCounter ( JiterpCounter . BackBranchesNotEmitted , 1 ) ;
2909
2908
return true ;
@@ -4036,7 +4035,6 @@ function emit_atomics (
4036
4035
if ( ! builder . options . enableAtomics )
4037
4036
return false ;
4038
4037
4039
- // FIXME: memory barrier might be worthwhile to implement
4040
4038
// FIXME: We could probably unify most of the xchg/cmpxchg implementation into one implementation
4041
4039
4042
4040
const xchg = xchgTable [ opcode ] ;
0 commit comments