Skip to content
Closed
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
13 changes: 12 additions & 1 deletion src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1629,8 +1629,19 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas
if (tm [0] == 'g') {
if (strcmp (tm, "get_Chars") == 0)
*op = MINT_GETCHR;
else if (strcmp (tm, "get_Length") == 0)
else if (strcmp(tm, "get_Length") == 0) {
// try to fold "ldstr".get_Length into a constant
if (td->last_ins && td->last_ins->opcode == MINT_LDSTR && interp_ip_in_cbb(td, td->ip - td->il_code)) {
MonoString* str = (MonoString*)td->data_items[td->last_ins->data[0]];
g_assert(str && str->length >= 0);
interp_clear_ins(td->last_ins);
interp_get_ldc_i4_from_const(td, NULL, str->length);
SET_SIMPLE_TYPE(td->sp - 1, STACK_TYPE_I4);
td->ip += 5;
return TRUE;
}
*op = MINT_STRLEN;
}
}
} else if (type_index >= 0) {
return interp_handle_magic_type_intrinsics (td, target_method, csignature, type_index);
Expand Down