Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix Ascii normalization not optimizing properly anymore
  • Loading branch information
kg committed Mar 25, 2023
commit 949d1b1ee74b7d50c41764dc270bc1af66552f64
4 changes: 4 additions & 0 deletions src/mono/mono/mini/interp/jiterpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,10 @@ jiterp_should_abort_trace (InterpInst *ins, gboolean *inside_branch_block)
return mono_opt_jiterpreter_backward_branches_enabled ? TRACE_CONTINUE : TRACE_ABORT;
}

// NOTE: This is technically incorrect - we are not conditionally executing code. However
// the instructions *following* this may not be executed since we might skip over them.
*inside_branch_block = TRUE;

return TRACE_CONTINUE;

case MINT_ICALL_V_P:
Expand Down
23 changes: 18 additions & 5 deletions src/mono/wasm/runtime/jiterpreter-trace-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export function generate_wasm_body (

if (ip >= endOfBody) {
record_abort(traceIp, ip, traceName, "end-of-body");
if (instrumentedTraceId)
console.log(`instrumented trace ${traceName} exited at end of body @${(<any>ip).toString(16)}`);
break;
}

Expand All @@ -177,6 +179,8 @@ export function generate_wasm_body (
if (builder.size >= spaceLeft) {
// console.log(`trace too big, estimated size is ${builder.size + builder.bytesGeneratedSoFar}`);
record_abort(traceIp, ip, traceName, "trace-too-big");
if (instrumentedTraceId)
console.log(`instrumented trace ${traceName} exited because of size limit at @${(<any>ip).toString(16)} (spaceLeft=${spaceLeft}b)`);
break;
}

Expand Down Expand Up @@ -332,13 +336,18 @@ export function generate_wasm_body (
isConditionallyExecuted = true;
break;

// Non-conditional branch doesn't set isConditionallyExecuted
case MintOpcode.MINT_LEAVE_S:
case MintOpcode.MINT_BR_S:
case MintOpcode.MINT_CALL_HANDLER:
case MintOpcode.MINT_CALL_HANDLER_S:
if (!emit_branch(builder, ip, frame, opcode))
ip = abort;
else
// Technically incorrect, but the instructions following this one may not be executed
// since we might have skipped over them.
// FIXME: Identify when we should actually set the conditionally executed flag, perhaps
// by doing a simple static flow analysis based on the displacements. Update heuristic too!
isConditionallyExecuted = true;
break;

case MintOpcode.MINT_CKNULL: {
Expand Down Expand Up @@ -2435,8 +2444,10 @@ function emit_branch (
counters.backBranchesEmitted++;
return true;
} else {
if (traceBackBranches > 0)
console.log(`back branch target 0x${destination.toString(16)} not found`);
if ((traceBackBranches > 0) || (builder.cfg.trace > 0))
console.log(`back branch target 0x${destination.toString(16)} not found in list ` +
builder.backBranchOffsets.map(bbo => "0x" + (<any>bbo).toString(16)).join(", ")
);
cwraps.mono_jiterp_boost_back_branch_target(destination);
// FIXME: Should there be a safepoint here?
append_bailout(builder, destination, BailoutReason.BackwardBranch);
Expand Down Expand Up @@ -2523,8 +2534,10 @@ function emit_branch (
builder.cfg.branch(destination, true, true);
counters.backBranchesEmitted++;
} else {
if (traceBackBranches > 0)
console.log(`back branch target 0x${destination.toString(16)} not found`);
if ((traceBackBranches > 0) || (builder.cfg.trace > 0))
console.log(`back branch target 0x${destination.toString(16)} not found in list ` +
builder.backBranchOffsets.map(bbo => "0x" + (<any>bbo).toString(16)).join(", ")
);
// We didn't find a loop to branch to, so bail out
cwraps.mono_jiterp_boost_back_branch_target(destination);
append_bailout(builder, destination, BailoutReason.BackwardBranch);
Expand Down