Skip to content

Commit

Permalink
Only set ins->klass for non-primitive types and use the right destina…
Browse files Browse the repository at this point in the history
…tion register type
  • Loading branch information
tannergooding committed Jun 27, 2024
1 parent 4331445 commit bae04c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 36 deletions.
8 changes: 0 additions & 8 deletions src/mono/mono/mini/interp/interp-intrins.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ interp_intrins_widen_ascii_to_utf16 (guint8 *pAsciiBuffer, mono_unichar2 *pUtf16
return currentOffset;
}

gint64
interp_intrins_bitcast (gdouble value)
{
gint64 result;
memcpy(&result, &value, sizeof (double));
return result;
}

gint64
interp_intrins_double_to_int64_bits (gdouble value)
{
Expand Down
20 changes: 4 additions & 16 deletions src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -2140,25 +2140,13 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas
}
} else if (in_corlib && !strcmp (klass_name_space, "System") && (!strcmp (klass_name, "BitConverter"))) {
if (!strcmp (tm, "DoubleToInt64Bits") || !strcmp (tm, "DoubleToUInt64Bits")) {
CHECK_STACK (td, 1);
interp_add_conv (td, td->sp - 1, NULL, STACK_TYPE_I8, MINT_BITCAST_I8_R8);
td->ip += 3;
return TRUE;
*op = MINT_BITCAST_I8_R8;
} else if (!strcmp (tm, "Int32BitsToSingle") || !strcmp (tm, "UInt32BitsToSingle")) {
CHECK_STACK (td, 1);
interp_add_conv (td, td->sp - 1, NULL, STACK_TYPE_R4, MINT_BITCAST_R4_I4);
td->ip += 3;
return TRUE;
*op = MINT_BITCAST_R4_I4;
} else if (!strcmp (tm, "Int64BitsToDouble") || !strcmp (tm, "UInt64BitsToDouble")) {
CHECK_STACK (td, 1);
interp_add_conv (td, td->sp - 1, NULL, STACK_TYPE_R8, MINT_BITCAST_R8_I8);
td->ip += 3;
return TRUE;
*op = MINT_BITCAST_R8_I8;
} else if (!strcmp (tm, "SingleToInt32Bits") || !strcmp (tm, "SingleToUInt32Bits")) {
CHECK_STACK (td, 1);
interp_add_conv (td, td->sp - 1, NULL, STACK_TYPE_I4, MINT_BITCAST_I4_R4);
td->ip += 3;
return TRUE;
*op = MINT_BITCAST_I4_R4;
}
} else if (in_corlib && !strcmp (klass_name_space, "System.Runtime.CompilerServices") && !strcmp (klass_name, "Unsafe")) {
if (!strcmp (tm, "AddByteOffset"))
Expand Down
16 changes: 4 additions & 12 deletions src/mono/mono/mini/intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,53 +581,43 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu
// for anything that can't be special cased as potentially zero-cost move.

guint32 opcode = OP_LDADDR;
MonoStackType tfrom_stack = STACK_PTR;
MonoStackType tto_stack = STACK_OBJ;

if (tfrom_type == MONO_TYPE_I4) {
if (tto_type == MONO_TYPE_R4) {
opcode = OP_MOVE_I4_TO_F;
tfrom_stack = STACK_I4;
tto_stack = STACK_R4;
} else if (tto_type == MONO_TYPE_I4) {
opcode = OP_MOVE;
tfrom_stack = STACK_I4;
tto_stack = STACK_I4;
}
} else if (tfrom_type == MONO_TYPE_I8) {
if (tto_type == MONO_TYPE_R8) {
opcode = OP_MOVE_I8_TO_F;
tfrom_stack = STACK_I8;
tto_stack = STACK_R8;
} else if (tto_type == MONO_TYPE_I8) {
opcode = OP_MOVE;
tfrom_stack = STACK_I8;
tto_stack = STACK_I8;
}
} else if (tfrom_type == MONO_TYPE_R4) {
if (tto_type == MONO_TYPE_I4) {
opcode = OP_MOVE_F_TO_I4;
tfrom_stack = STACK_R4;
tto_stack = STACK_I4;
} else if (tto_type == MONO_TYPE_R4) {
opcode = OP_RMOVE;
tfrom_stack = STACK_R4;
tto_stack = STACK_R4;
}
} else if (tfrom_type == MONO_TYPE_R8) {
if (tto_type == MONO_TYPE_I8) {
opcode = OP_MOVE_F_TO_I8;
tfrom_stack = STACK_R8;
tto_stack = STACK_I8;
} else if (tto_type == MONO_TYPE_R8) {
opcode = OP_FMOVE;
tfrom_stack = STACK_R8;
tto_stack = STACK_R8;
}
} else if (mini_class_is_simd (cfg, tfrom_klass)) {
if (mini_class_is_simd (cfg, tto_klass)) {
opcode = OP_XMOVE;
tfrom_stack = STACK_VTYPE;
tto_stack = STACK_VTYPE;
}
}
Expand All @@ -643,10 +633,12 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu
return mini_emit_memory_load (cfg, tto, arg0, 0, MONO_INST_UNALIGNED);
}

int dreg = mono_alloc_dreg (cfg, tfrom_stack);
int dreg = mono_alloc_dreg (cfg, tto_stack);
EMIT_NEW_UNALU (cfg, ins, opcode, dreg, args [0]->dreg);
ins->type = tto_stack;
ins->klass = tto_klass;
if (opcode == OP_XMOVE) {
ins->klass = tto_klass;
}
return ins;
} else if (!strcmp (cmethod->name, "IsAddressLessThan")) {
g_assert (ctx);
Expand Down

0 comments on commit bae04c3

Please sign in to comment.