未验证 提交 51d8e981 编写于 作者: V Vlad Brezae 提交者: GitHub

[interp] Small interp tweaks (#48412)

* [interp] Fix overflow in PROFILE_INTERP log

* [interp] Replace LDFLDA of offset 0 field with MOV

Commonly used when accessing first field of valuetypes, eg span operations. Will help with cprop and remove redundant instruction.

* [interp] Remove redundant opcode
上级 e6cc4ae3
......@@ -4841,11 +4841,6 @@ call:
ip += 4;;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_BYREFERENCE_GET_VALUE) {
LOCAL_VAR (ip [1], gpointer) = *LOCAL_VAR (ip [2], gpointer*);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_UNSAFE_ADD_BYTE_OFFSET) {
LOCAL_VAR (ip [1], gpointer) = LOCAL_VAR (ip [2], guint8*) + LOCAL_VAR (ip [3], mono_u);
ip += 4;
......@@ -7169,7 +7164,13 @@ interp_add_imethod (gpointer method)
static int
imethod_opcount_comparer (gconstpointer m1, gconstpointer m2)
{
return (*(InterpMethod**)m2)->opcounts - (*(InterpMethod**)m1)->opcounts;
long diff = (*(InterpMethod**)m2)->opcounts > (*(InterpMethod**)m1)->opcounts;
if (diff > 0)
return 1;
else if (diff < 0)
return -1;
else
return 0;
}
static void
......
......@@ -716,7 +716,6 @@ OPDEF(MINT_INTRINS_ENUM_HASFLAG, "intrins_enum_hasflag", 5, 1, 2, MintOpClassTok
OPDEF(MINT_INTRINS_GET_HASHCODE, "intrins_get_hashcode", 3, 1, 1, MintOpNoArgs)
OPDEF(MINT_INTRINS_GET_TYPE, "intrins_get_type", 3, 1, 1, MintOpNoArgs)
OPDEF(MINT_INTRINS_SPAN_CTOR, "intrins_span_ctor", 4, 1, 2, MintOpNoArgs)
OPDEF(MINT_INTRINS_BYREFERENCE_GET_VALUE, "intrins_byreference_get_value", 3, 1, 1, MintOpNoArgs)
OPDEF(MINT_INTRINS_UNSAFE_ADD_BYTE_OFFSET, "intrins_unsafe_add_byte_offset", 4, 1, 2, MintOpNoArgs)
OPDEF(MINT_INTRINS_UNSAFE_BYTE_OFFSET, "intrins_unsafe_byte_offset", 4, 1, 2, MintOpNoArgs)
OPDEF(MINT_INTRINS_RUNTIMEHELPERS_OBJECT_HAS_COMPONENT_SIZE, "intrins_runtimehelpers_object_has_component_size", 3, 1, 1, MintOpNoArgs)
......
......@@ -2026,7 +2026,7 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas
*op = MINT_INTRINS_CLEAR_WITH_REFERENCES;
} else if (in_corlib && !strcmp (klass_name_space, "System") && !strcmp (klass_name, "ByReference`1")) {
g_assert (!strcmp (tm, "get_Value"));
*op = MINT_INTRINS_BYREFERENCE_GET_VALUE;
*op = MINT_LDIND_I;
} else if (in_corlib && !strcmp (klass_name_space, "System") && !strcmp (klass_name, "Marvin")) {
if (!strcmp (tm, "Block"))
*op = MINT_INTRINS_MARVIN_BLOCK;
......@@ -5621,14 +5621,20 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
goto_if_nok (error, exit);
} else {
td->sp--;
int foffset = m_class_is_valuetype (klass) ? field->offset - MONO_ABI_SIZEOF (MonoObject) : field->offset;
if (td->sp->type == STACK_TYPE_O) {
interp_add_ins (td, MINT_LDFLDA);
td->last_ins->data [0] = foffset;
} else {
int sp_type = td->sp->type;
g_assert (sp_type == STACK_TYPE_MP || sp_type == STACK_TYPE_I);
interp_add_ins (td, MINT_LDFLDA_UNSAFE);
if (foffset) {
interp_add_ins (td, MINT_LDFLDA_UNSAFE);
td->last_ins->data [0] = foffset;
} else {
interp_add_ins (td, MINT_MOV_P);
}
}
td->last_ins->data [0] = m_class_is_valuetype (klass) ? field->offset - MONO_ABI_SIZEOF (MonoObject) : field->offset;
interp_ins_set_sreg (td->last_ins, td->sp [0].local);
push_simple_type (td, STACK_TYPE_MP);
interp_ins_set_dreg (td->last_ins, td->sp [-1].local);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册