[jit] Add jit icalls used by the inline rgctx fetch code.
authorZoltan Varga <vargaz@gmail.com>
Tue, 16 Jun 2015 02:50:32 +0000 (22:50 -0400)
committerZoltan Varga <vargaz@gmail.com>
Tue, 16 Jun 2015 02:50:32 +0000 (22:50 -0400)
mono/mini/jit-icalls.c
mono/mini/jit-icalls.h
mono/mini/method-to-ir.c
mono/mini/mini-runtime.c

index 1e94b262df7a9a40b61b8501e7aed244a1bc40b2..9b05034f316c7468b614a8474e3ef432c6d31c3c 100644 (file)
@@ -1285,3 +1285,15 @@ mono_generic_class_init (MonoVTable *vtable)
 {
        mono_runtime_class_init (vtable);
 }
+
+gpointer
+mono_fill_class_rgctx (MonoVTable *vtable, int index)
+{
+       return mono_class_fill_runtime_generic_context (vtable, index);
+}
+
+gpointer
+mono_fill_method_rgctx (MonoMethodRuntimeGenericContext *mrgctx, int index)
+{
+       return mono_method_fill_runtime_generic_context (mrgctx, index);
+}
index 9ec1a4f60e709b203d5d1d8665f93483161afc86..d31e06e63c5f99dd4511a227031563398f31594f 100644 (file)
@@ -189,5 +189,9 @@ mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *kl
 
 void mono_gsharedvt_value_copy (gpointer dest, gpointer src, MonoClass *klass);
 
+gpointer mono_fill_class_rgctx (MonoVTable *vtable, int index);
+
+gpointer mono_fill_method_rgctx (MonoMethodRuntimeGenericContext *mrgctx, int index);
+
 #endif /* __MONO_JIT_ICALLS_H__ */
 
index 1f46ee3ba7f26468a4eed3505f595da30dd2f425..ff72fe750f2f9bbce18c2034a0aa954fee8cd5b8 100644 (file)
@@ -3448,11 +3448,13 @@ static inline MonoInst*
 emit_rgctx_fetch (MonoCompile *cfg, MonoInst *rgctx, MonoJumpInfoRgctxEntry *entry)
 {
        /* Inline version, not currently used */
+       // FIXME: This can be called from mono_decompose_vtype_opts (), which can't create new bblocks
 #if 0
        int i, slot, depth, index, rgctx_reg, val_reg, res_reg;
        gboolean mrgctx;
        MonoBasicBlock *is_null_bb, *end_bb;
        MonoInst *res, *ins, *call;
+       MonoInst *args[16];
 
        slot = mini_get_rgctx_entry_slot (entry);
 
@@ -3509,21 +3511,25 @@ emit_rgctx_fetch (MonoCompile *cfg, MonoInst *rgctx, MonoJumpInfoRgctxEntry *ent
 
        /* Fastpath */
        res_reg = alloc_preg (cfg);
-       MONO_INST_NEW (cfg, res, OP_MOVE);
-       res->dreg = res_reg;
-       res->sreg1 = val_reg;
-       MONO_ADD_INS (cfg->cbb, res);
+       MONO_INST_NEW (cfg, ins, OP_MOVE);
+       ins->dreg = res_reg;
+       ins->sreg1 = val_reg;
+       MONO_ADD_INS (cfg->cbb, ins);
+       res = ins;
        MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb);
 
        /* Slowpath */
        MONO_START_BB (cfg, is_null_bb);
-       // FIXME: This should use a jit icall
-       call = mono_emit_abs_call (cfg, MONO_PATCH_INFO_RGCTX_FETCH, entry, helper_sig_rgctx_lazy_fetch_trampoline, &rgctx);
+       args [0] = rgctx;
+       EMIT_NEW_ICONST (cfg, args [1], index);
+       if (mrgctx)
+               call = mono_emit_jit_icall (cfg, mono_fill_method_rgctx, args);
+       else
+               call = mono_emit_jit_icall (cfg, mono_fill_class_rgctx, args);
        MONO_INST_NEW (cfg, ins, OP_MOVE);
        ins->dreg = res_reg;
        ins->sreg1 = call->dreg;
        MONO_ADD_INS (cfg->cbb, ins);
-
        MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb);
 
        MONO_START_BB (cfg, end_bb);
index 12f5901920d83d1d33961bd4c2065cb33ec5f7e7..264a99cdc6934ca8c05d5d60694acc8829dddc0f 100644 (file)
@@ -3355,6 +3355,8 @@ register_icalls (void)
        register_icall (mono_object_castclass_with_cache, "mono_object_castclass_with_cache", "object object ptr ptr", FALSE);
        register_icall (mono_object_isinst_with_cache, "mono_object_isinst_with_cache", "object object ptr ptr", FALSE);
        register_icall (mono_generic_class_init, "mono_generic_class_init", "void ptr", FALSE);
+       register_icall (mono_fill_class_rgctx, "mono_class_fill_rgctx", "ptr ptr int", FALSE);
+       register_icall (mono_fill_method_rgctx, "mono_method_fill_rgctx", "ptr ptr int", FALSE);
 
        register_icall (mono_debugger_agent_user_break, "mono_debugger_agent_user_break", "void", FALSE);
        register_dyn_icall (mono_create_specific_trampoline (NULL, MONO_TRAMPOLINE_GENERIC_CLASS_INIT, mono_get_root_domain (), NULL),