Skip to content

Commit

Permalink
[interp] handle box + brtrue/brfalse pattern for byreflike types
Browse files Browse the repository at this point in the history
In cases where we don't do cprop and deadce (for example if
~mono_interp_opt~ is 0 because we're debugging) don't emit a box_vt
opcode before a branch.  Instead just emit a constant true

Fixes dotnet#102988
  • Loading branch information
lambdageek committed Jun 4, 2024
1 parent 40ff2ec commit 74e4871
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -4827,6 +4827,25 @@ interp_handle_box_patterns (TransformData *td, MonoClass *box_class, const unsig
td->ip = next_ip + 5;
return TRUE;
}
if (m_class_is_byreflike (box_class)) {
if (*next_ip == CEE_BRTRUE || *next_ip == CEE_BRTRUE_S || *next_ip == CEE_BRFALSE || *next_ip == CEE_BRFALSE_S) {
// replace
// box ByRefLike
// brtrue/brfalse
//
// by
//
// ldc.i4.s 1
// brtrue/brfalse
td->sp--;
interp_add_ins (td, MINT_LDC_I4_S);
td->last_ins->data[0] = (guint16) 1;
push_simple_type (td, STACK_TYPE_I4);
interp_ins_set_dreg (td->last_ins, td->sp [-1].var);
td->ip += 5;
return TRUE;
}
}
return FALSE;
}

Expand Down

0 comments on commit 74e4871

Please sign in to comment.