Skip to content

Commit 5b1ffb8

Browse files
lewingCopilot
andauthored
[mono][interp] Group all the System.Runtime.Intrinsics logic together (#114270)
Remove nonexistent namespace check and avoid comparing the same 25 characters over and over for every System.Runtime.Intrinsics method. --------- Co-authored-by: Copilot <[email protected]>
1 parent 027916b commit 5b1ffb8

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

src/mono/mono/mini/interp/transform.c

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,43 +2594,49 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas
25942594
*op = MINT_CEQ_I4;
25952595
}
25962596
}
2597-
}
2598-
else if (in_corlib &&
2597+
} else if (in_corlib &&
25992598
!strcmp ("System.Runtime.CompilerServices", klass_name_space) &&
26002599
!strcmp ("RuntimeFeature", klass_name)) {
26012600
// NOTE: on the interpreter, use the C# code in System.Private.CoreLib for IsDynamicCodeSupported
26022601
// and always return false for IsDynamicCodeCompiled
26032602
if (!strcmp (tm, "get_IsDynamicCodeCompiled"))
26042603
*op = MINT_LDC_I4_0;
2604+
} else if (in_corlib && (!strncmp ("System.Runtime.Intrinsics", klass_name_space, 25))) {
2605+
if (klass_name_space[25] == '\0' &&
2606+
!strncmp ("Vector", klass_name, 6) &&
2607+
!strcmp (tm, "get_IsHardwareAccelerated")) {
2608+
*op = MINT_LDC_I4_0;
2609+
} else if (klass_name_space[25] == '.') {
2610+
if (!strncmp ("Arm", klass_name_space + 26, 3) ||
2611+
!strncmp ("X86", klass_name_space + 26, 3)) {
2612+
if (!strcmp (tm, "get_IsSupported"))
2613+
*op = MINT_LDC_I4_0;
2614+
else
2615+
interp_generate_void_throw (td, MONO_JIT_ICALL_mono_throw_platform_not_supported);
2616+
} else if (!strncmp ("Wasm", klass_name_space + 26, 4)) {
2617+
if (!strcmp (tm, "get_IsSupported")) {
2618+
*op = MINT_LDC_I4_0;
2619+
}
26052620
#if defined(TARGET_WASM)
2606-
} else if (in_corlib &&
2607-
!strncmp ("System.Runtime.Intrinsics.Wasm", klass_name_space, 30) &&
2608-
!strcmp (klass_name, "WasmBase")) {
2609-
if (!strcmp (tm, "get_IsSupported")) {
2610-
*op = MINT_LDC_I4_1;
2611-
} else if (!strcmp (tm, "LeadingZeroCount")) {
2612-
if (csignature->params [0]->type == MONO_TYPE_U4 || csignature->params [0]->type == MONO_TYPE_I4)
2613-
*op = MINT_CLZ_I4;
2614-
else if (csignature->params [0]->type == MONO_TYPE_U8 || csignature->params [0]->type == MONO_TYPE_I8)
2615-
*op = MINT_CLZ_I8;
2616-
} else if (!strcmp (tm, "TrailingZeroCount")) {
2617-
if (csignature->params [0]->type == MONO_TYPE_U4 || csignature->params [0]->type == MONO_TYPE_I4)
2618-
*op = MINT_CTZ_I4;
2619-
else if (csignature->params [0]->type == MONO_TYPE_U8 || csignature->params [0]->type == MONO_TYPE_I8)
2620-
*op = MINT_CTZ_I8;
2621-
}
2621+
if (!strcmp (klass_name, "WasmBase")) {
2622+
if (!strcmp (tm, "get_IsSupported")) {
2623+
// override the value set above
2624+
*op = MINT_LDC_I4_1;
2625+
} else if (!strcmp (tm, "LeadingZeroCount")) {
2626+
if (csignature->params [0]->type == MONO_TYPE_U4 || csignature->params [0]->type == MONO_TYPE_I4)
2627+
*op = MINT_CLZ_I4;
2628+
else if (csignature->params [0]->type == MONO_TYPE_U8 || csignature->params [0]->type == MONO_TYPE_I8)
2629+
*op = MINT_CLZ_I8;
2630+
} else if (!strcmp (tm, "TrailingZeroCount")) {
2631+
if (csignature->params [0]->type == MONO_TYPE_U4 || csignature->params [0]->type == MONO_TYPE_I4)
2632+
*op = MINT_CTZ_I4;
2633+
else if (csignature->params [0]->type == MONO_TYPE_U8 || csignature->params [0]->type == MONO_TYPE_I8)
2634+
*op = MINT_CTZ_I8;
2635+
}
2636+
}
26222637
#endif
2623-
} else if (in_corlib &&
2624-
(!strncmp ("System.Runtime.Intrinsics.Arm", klass_name_space, 29) ||
2625-
!strncmp ("System.Runtime.Intrinsics.PackedSimd", klass_name_space, 36) ||
2626-
!strncmp ("System.Runtime.Intrinsics.X86", klass_name_space, 29) ||
2627-
!strncmp ("System.Runtime.Intrinsics.Wasm", klass_name_space, 30)) &&
2628-
!strcmp (tm, "get_IsSupported")) {
2629-
*op = MINT_LDC_I4_0;
2630-
} else if (in_corlib &&
2631-
(!strncmp ("System.Runtime.Intrinsics.Arm", klass_name_space, 29) ||
2632-
!strncmp ("System.Runtime.Intrinsics.X86", klass_name_space, 29))) {
2633-
interp_generate_void_throw (td, MONO_JIT_ICALL_mono_throw_platform_not_supported);
2638+
}
2639+
}
26342640
} else if (in_corlib && !strncmp ("System.Numerics", klass_name_space, 15)) {
26352641
if (!strcmp ("Vector", klass_name) &&
26362642
!strcmp (tm, "get_IsHardwareAccelerated")) {
@@ -2683,11 +2689,6 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas
26832689
*op = MINT_LOG2_I8;
26842690
}
26852691
}
2686-
} else if (in_corlib &&
2687-
(!strncmp ("System.Runtime.Intrinsics", klass_name_space, 25) &&
2688-
!strncmp ("Vector", klass_name, 6) &&
2689-
!strcmp (tm, "get_IsHardwareAccelerated"))) {
2690-
*op = MINT_LDC_I4_0;
26912692
} else if ((target_method->klass == mono_defaults.double_class) || (target_method->klass == mono_defaults.single_class)) {
26922693
MonoGenericContext *method_context = mono_method_get_context (target_method);
26932694
bool isDouble = target_method->klass == mono_defaults.double_class;

0 commit comments

Comments
 (0)