Skip to content

Commit a8cf3ba

Browse files
committed
Add more explicit validation
1 parent 70cb4bd commit a8cf3ba

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

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

+20-4
Original file line numberDiff line numberDiff line change
@@ -482,18 +482,34 @@ emit_sri_vector128 (TransformData *td, MonoMethod *cmethod, MonoMethodSignature
482482
MonoClass *ret_class = mono_class_from_mono_type_internal (csignature->ret);
483483
int ret_size = mono_class_value_size (ret_class, NULL);
484484

485+
if (!strcmp (m_class_get_name (ret_class), "Vector2")) {
486+
g_assert (ret_size == 8);
487+
} else if (!strcmp (m_class_get_name (ret_class), "Vector3")) {
488+
g_assert (ret_size == 12);
489+
} else {
490+
g_assert (ret_size == 16);
491+
}
492+
485493
MonoClass *arg_class = mono_class_from_mono_type_internal (csignature->params [0]);
486494
int arg_size = mono_class_value_size (arg_class, NULL);
487495

496+
if (!strcmp (m_class_get_name (arg_class), "Vector2")) {
497+
g_assert (arg_size == 8);
498+
} else if (!strcmp (m_class_get_name (arg_class), "Vector3")) {
499+
g_assert (arg_size == 12);
500+
} else {
501+
g_assert (arg_size == 16);
502+
}
503+
488504
vector_klass = ret_class;
489505
vector_size = ret_size;
490506

491507
if (id == SN_AsVector2) {
492-
g_assert(ret_size == 8);
493-
g_assert((arg_size == 12) || (arg_size == 16));
508+
g_assert (ret_size == 8);
509+
g_assert ((arg_size == 12) || (arg_size == 16));
494510
} else if (id == SN_AsVector3) {
495-
g_assert(ret_size == 12);
496-
g_assert((arg_size == 8) || (arg_size == 16));
511+
g_assert (ret_size == 12);
512+
g_assert ((arg_size == 8) || (arg_size == 16));
497513
}
498514

499515
if (arg_size == ret_size) {

0 commit comments

Comments
 (0)