Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[interp] break up MINT_LDSTR_TOKEN into two opcodes #88738

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 13 additions & 9 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5573,19 +5573,23 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK;
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [2]];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSTR_TOKEN) {
MINT_IN_CASE(MINT_LDSTR_DYNAMIC) {
MonoString *s = NULL;
guint32 strtoken = (guint32)(gsize)frame->imethod->data_items [ip [2]];

MonoMethod *method = frame->imethod->method;
if (method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD) {
s = (MonoString*)mono_method_get_wrapper_data (method, strtoken);
} else if (method->wrapper_type != MONO_WRAPPER_NONE) {
// FIXME push/pop LMF
s = mono_string_new_wrapper_internal ((const char*)mono_method_get_wrapper_data (method, strtoken));
} else {
g_assert_not_reached ();
}
g_assert (method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD);
s = (MonoString*)mono_method_get_wrapper_data (method, strtoken);
LOCAL_VAR (ip [1], gpointer) = s;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDSTR_CSTR) {
MonoString *s = NULL;
const char* cstr = (const char*)frame->imethod->data_items [ip [2]];

// FIXME push/pop LMF
s = mono_string_new_wrapper_internal (cstr);
LOCAL_VAR (ip [1], gpointer) = s;
ip += 3;
MINT_IN_BREAK;
Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/mini/interp/mintops.def
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ OPDEF(MINT_BLT_UN_I8_IMM_SP, "blt.un.i8.imm.sp", 4, 0, 1, MintOpShortAndShortBra
OPDEF(MINT_SWITCH, "switch", 0, 0, 1, MintOpSwitch)

OPDEF(MINT_LDSTR, "ldstr", 3, 1, 0, MintOpShortInt)
OPDEF(MINT_LDSTR_TOKEN, "ldstr.token", 3, 1, 0, MintOpShortInt)
OPDEF(MINT_LDSTR_DYNAMIC, "ldstr.dynamic", 3, 1, 0, MintOpShortInt)
OPDEF(MINT_LDSTR_CSTR, "ldstr.cstr", 3, 1, 0, MintOpShortInt)

OPDEF(MINT_JMP, "jmp", 2, 0, 0, MintOpMethodToken)

Expand Down
19 changes: 16 additions & 3 deletions src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -6106,11 +6106,24 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
interp_add_ins (td, MINT_LDSTR);
interp_ins_set_dreg (td->last_ins, td->sp [-1].local);
td->last_ins->data [0] = get_data_item_index (td, s);
} else {
/* defer allocation to execution-time */
interp_add_ins (td, MINT_LDSTR_TOKEN);
} else if (method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD) {
/* token is an index into the MonoDynamicMethod:method.method_data
* which comes from ReflectionMethodBuilder:refs. See
* reflection_methodbuilder_to_mono_method.
*
* the actual data item is a managed MonoString from the managed DynamicMethod
*/
interp_add_ins (td, MINT_LDSTR_DYNAMIC);
interp_ins_set_dreg (td->last_ins, td->sp [-1].local);
td->last_ins->data [0] = get_data_item_index (td, GUINT_TO_POINTER (token));
} else {
/* the token is an index into MonoWrapperMethod:method_data that
* stores a global or malloc'ed C string. defer MonoString
* allocation to execution-time */
interp_add_ins (td, MINT_LDSTR_CSTR);
interp_ins_set_dreg (td->last_ins, td->sp [-1].local);
const char *cstr = (const char*)mono_method_get_wrapper_data (method, token);
td->last_ins->data [0] = get_data_item_index (td, (void*)cstr);
}
td->ip += 5;
break;
Expand Down