Skip to content

Commit

Permalink
[mono][interp] Add stobj version for no reference case
Browse files Browse the repository at this point in the history
The noref opcode is twice as fast and it doesn't mark any cards for the GC to scan.
  • Loading branch information
BrzVlad committed Dec 2, 2022
1 parent c1a24d2 commit fa46f3c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -6088,6 +6088,11 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STOBJ_VT_NOREF) {
memcpy (LOCAL_VAR (ip [1], gpointer), locals + ip [2], ip [3]);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U8_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0)
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/mini/interp/mintops.def
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ OPDEF(MINT_CPOBJ, "cpobj", 4, 0, 2, MintOpClassToken)
OPDEF(MINT_CPOBJ_VT, "cpobj.vt", 4, 0, 2, MintOpClassToken)
OPDEF(MINT_LDOBJ_VT, "ldobj.vt", 4, 1, 1, MintOpShortInt)
OPDEF(MINT_STOBJ_VT, "stobj.vt", 4, 0, 2, MintOpClassToken)
OPDEF(MINT_STOBJ_VT_NOREF, "stobj.vt.noref", 4, 0, 2, MintOpShortInt)
OPDEF(MINT_CPBLK, "cpblk", 4, 0, 3, MintOpNoArgs)
OPDEF(MINT_INITBLK, "initblk", 4, 0, 3, MintOpNoArgs)
OPDEF(MINT_LOCALLOC, "localloc", 3, 1, 1, MintOpNoArgs)
Expand Down
9 changes: 7 additions & 2 deletions src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1861,8 +1861,13 @@ interp_emit_stobj (TransformData *td, MonoClass *klass, gboolean reverse_order)
int mt = mint_type (m_class_get_byval_arg (klass));

if (mt == MINT_TYPE_VT) {
interp_add_ins (td, MINT_STOBJ_VT);
td->last_ins->data [0] = get_data_item_index (td, klass);
if (m_class_has_references (klass)) {
interp_add_ins (td, MINT_STOBJ_VT);
td->last_ins->data [0] = get_data_item_index (td, klass);
} else {
interp_add_ins (td, MINT_STOBJ_VT_NOREF);
td->last_ins->data [0] = GINT32_TO_UINT16 (mono_class_value_size (klass, NULL));
}
} else {
int opcode = interp_get_stind_for_mt (mt);
interp_add_ins (td, opcode);
Expand Down

0 comments on commit fa46f3c

Please sign in to comment.