@@ -449,10 +449,9 @@ export function generateWasmBody (
449449 if ( pruneOpcodes ) {
450450 // We emit an unreachable opcode so that if execution somehow reaches a pruned opcode, we will abort
451451 // 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
453452 if ( ! hasEmittedUnreachable )
454453 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
456455 hasEmittedUnreachable = true ;
457456 }
458457 break ;
@@ -467,7 +466,7 @@ export function generateWasmBody (
467466 }
468467 case MintOpcode . MINT_LOCALLOC : {
469468 // dest
470- append_ldloca ( builder , getArgU16 ( ip , 1 ) ) ;
469+ append_ldloca ( builder , getArgU16 ( ip , 1 ) , 0 ) ;
471470 // len
472471 append_ldloc ( builder , getArgU16 ( ip , 2 ) , WasmOpcode . i32_load ) ;
473472 // frame
@@ -648,10 +647,12 @@ export function generateWasmBody (
648647 // locals[ip[1]] = &locals[ip[2]]
649648 const offset = getArgU16 ( ip , 2 ) ,
650649 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 ) ;
652653 if ( ! flag )
653654 mono_log_error ( `${ traceName } : Expected local ${ offset } to have address taken flag` ) ;
654- append_ldloca ( builder , offset ) ;
655+ append_ldloca ( builder , offset , size ) ;
655656 append_stloc_tail ( builder , destOffset , WasmOpcode . i32_store ) ;
656657 // Record this ldloca as a known constant so that later uses of it turn into a lea,
657658 // and the wasm runtime can constant fold them with other constants. It's not uncommon
@@ -875,9 +876,8 @@ export function generateWasmBody (
875876 }
876877
877878 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 ) ;
881881 builder . callImport ( "ld_del_ptr" ) ;
882882 break ;
883883 }
@@ -1383,7 +1383,9 @@ export function generateWasmBody (
13831383 ( builder . callHandlerReturnAddresses . length <= maxCallHandlerReturnAddresses )
13841384 ) {
13851385 // 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.
13871389 // Load ret_ip
13881390 const clauseIndex = getArgU16 ( ip , 1 ) ,
13891391 clauseDataOffset = get_imethod_clause_data_offset ( frame , clauseIndex ) ;
@@ -1972,10 +1974,7 @@ function append_stloc_tail (builder: WasmBuilder, offset: number, opcodeOrPrefix
19721974
19731975// Pass bytesInvalidated=0 if you are reading from the local and the address will never be
19741976// 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 ) {
19791978 if ( bytesInvalidated > 0 )
19801979 invalidate_local_range ( localOffset , bytesInvalidated ) ;
19811980 builder . lea ( "pLocals" , localOffset ) ;
@@ -2476,7 +2475,8 @@ function emit_sfieldop (
24762475 builder . ptr_const ( pStaticData ) ;
24772476 // src
24782477 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
24802480 builder . callImport ( "copy_ptr" ) ;
24812481 return true ;
24822482 case MintOpcode . MINT_LDSFLD_VT : {
@@ -2903,7 +2903,6 @@ function emit_branch (
29032903 ) ;
29042904
29052905 cwraps . mono_jiterp_boost_back_branch_target ( destination ) ;
2906- // FIXME: Should there be a safepoint here?
29072906 append_bailout ( builder , destination , BailoutReason . BackwardBranch ) ;
29082907 modifyCounter ( JiterpCounter . BackBranchesNotEmitted , 1 ) ;
29092908 return true ;
@@ -4036,7 +4035,6 @@ function emit_atomics (
40364035 if ( ! builder . options . enableAtomics )
40374036 return false ;
40384037
4039- // FIXME: memory barrier might be worthwhile to implement
40404038 // FIXME: We could probably unify most of the xchg/cmpxchg implementation into one implementation
40414039
40424040 const xchg = xchgTable [ opcode ] ;
0 commit comments