From: Zoltan Varga Date: Fri, 29 May 2015 23:07:03 +0000 (-0400) Subject: [jit] Refactor the calls to class init trampolines into a common function. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=39de60515f972807c5c6b7678c748d261ce31783;p=mono.git [jit] Refactor the calls to class init trampolines into a common function. --- diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index 61cd9f74496..5115fdcfd7c 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -3682,6 +3682,18 @@ emit_generic_class_init (MonoCompile *cfg, MonoClass *klass, MonoBasicBlock **ou #endif } + +static void +emit_class_init (MonoCompile *cfg, MonoClass *klass, MonoBasicBlock **out_bblock) +{ + /* This could be used as a fallback if needed */ + //emit_generic_class_init (cfg, klass, out_bblock); + + *out_bblock = cfg->cbb; + + mono_emit_abs_call (cfg, MONO_PATCH_INFO_CLASS_INIT, klass, helper_sig_class_init_trampoline, NULL); +} + static void emit_seq_point (MonoCompile *cfg, MonoMethod *method, guint8* ip, gboolean intr_loc, gboolean nonempty_stack) { @@ -10387,7 +10399,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b * As a workaround, we call class cctors before allocating objects. */ if (mini_field_access_needs_cctor_run (cfg, method, cmethod->klass, vtable) && !(g_slist_find (class_inits, cmethod->klass))) { - mono_emit_abs_call (cfg, MONO_PATCH_INFO_CLASS_INIT, cmethod->klass, helper_sig_class_init_trampoline, NULL); + emit_class_init (cfg, cmethod->klass, &bblock); if (cfg->verbose_level > 2) printf ("class %s.%s needs init call for ctor\n", cmethod->klass->name_space, cmethod->klass->name); class_inits = g_slist_prepend (class_inits, cmethod->klass); @@ -11097,7 +11109,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b if (!addr) { if (mini_field_access_needs_cctor_run (cfg, method, klass, vtable)) { if (!(g_slist_find (class_inits, klass))) { - mono_emit_abs_call (cfg, MONO_PATCH_INFO_CLASS_INIT, klass, helper_sig_class_init_trampoline, NULL); + emit_class_init (cfg, klass, &bblock); if (cfg->verbose_level > 2) printf ("class %s.%s needs init call for %s\n", klass->name_space, klass->name, mono_field_get_name (field)); class_inits = g_slist_prepend (class_inits, klass);