未验证 提交 c580f49f 编写于 作者: Z Zoltan Varga 提交者: GitHub

[mono][jit] Optimize calls to Type:get_IsValueType () on gshared constrained types. (#61514)

These are used for example in Span<T>:.ctor ().
上级 8574ce9a
......@@ -1894,6 +1894,33 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
MONO_ADD_INS (cfg->cbb, ins);
}
return ins;
} else if (cmethod->klass == mono_defaults.systemtype_class && !strcmp (cmethod->name, "get_IsValueType") &&
args [0]->klass == mono_defaults.runtimetype_class) {
MonoClass *k1 = get_class_from_ldtoken_ins (args [0]);
if (k1) {
MonoType *t1 = m_class_get_byval_arg (k1);
MonoType *constraint1 = NULL;
/* Common case in gshared BCL code: t1 is a gshared type like T_INT */
if (mono_class_is_gparam (k1)) {
MonoGenericParam *gparam = t1->data.generic_param;
constraint1 = gparam->gshared_constraint;
if (constraint1) {
if (constraint1->type == MONO_TYPE_OBJECT) {
if (cfg->verbose_level > 2)
printf ("-> false\n");
EMIT_NEW_ICONST (cfg, ins, 0);
return ins;
} else if (MONO_TYPE_IS_PRIMITIVE (constraint1)) {
if (cfg->verbose_level > 2)
printf ("-> true\n");
EMIT_NEW_ICONST (cfg, ins, 1);
return ins;
}
}
}
}
return NULL;
} else if (((!strcmp (cmethod_klass_image->assembly->aname.name, "MonoMac") ||
!strcmp (cmethod_klass_image->assembly->aname.name, "monotouch")) &&
!strcmp (cmethod_klass_name_space, "XamCore.ObjCRuntime") &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册