Browse files

Add AOT support for castclass_with_cache wrappers.

  • Loading branch information...
1 parent 0dfe460 commit e2282824129f51a3b6d2ee22ec1160d0de208348 @vargaz vargaz committed Jan 27, 2011
Showing with 41 additions and 3 deletions.
  1. +17 −1 mono/mini/aot-compiler.c
  2. +10 −0 mono/mini/aot-runtime.c
  3. +8 −2 mono/mini/method-to-ir.c
  4. +4 −0 mono/mini/mini.c
  5. +1 −0 mono/mini/mini.h
  6. +1 −0 mono/mini/patch-info.h
View
18 mono/mini/aot-compiler.c
@@ -2084,6 +2084,13 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8
g_assert_not_reached ();
}
break;
+ case MONO_WRAPPER_CASTCLASS:
+ if (!strcmp (method->name, "__castclass_with_cache")) {
+ encode_value (MONO_AOT_WRAPPER_CASTCLASS_WITH_CACHE, p, &p);
+ } else {
+ g_assert_not_reached ();
+ }
+ break;
default:
g_assert_not_reached ();
}
@@ -2658,6 +2665,9 @@ add_wrappers (MonoAotCompile *acfg)
if (klass)
add_method (acfg, mono_marshal_get_virtual_stelemref (mono_array_class_get (klass, 1)));
}
+
+ /* castclass_with_check wrapper */
+ add_method (acfg, mono_marshal_get_castclass_with_cache ());
}
/*
@@ -3555,6 +3565,7 @@ encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info, guint8 *buf, guint
break;
case MONO_PATCH_INFO_MSCORLIB_GOT_ADDR:
case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
+ case MONO_PATCH_INFO_CASTCLASS_CACHE:
break;
case MONO_PATCH_INFO_METHOD_REL:
encode_value ((gint)patch_info->data.offset, p, &p);
@@ -4717,6 +4728,11 @@ can_encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info)
return TRUE;
else
return FALSE;
+ case MONO_WRAPPER_CASTCLASS:
+ if (!strcmp (method->name, "__castclass_with_cache"))
+ return TRUE;
+ else
+ return FALSE;
default:
//printf ("Skip (wrapper call): %d -> %s\n", patch_info->type, mono_method_full_name (patch_info->data.method, TRUE));
return FALSE;
@@ -5258,7 +5274,7 @@ emit_llvm_file (MonoAotCompile *acfg)
* then removing tailcallelim + the global opts, and adding a second gvn.
*/
opts = g_strdup ("-instcombine -simplifycfg");
- opts = g_strdup ("-simplifycfg -domtree -domfrontier -scalarrepl -instcombine -simplifycfg -basiccg -prune-eh -inline -functionattrs -domtree -domfrontier -scalarrepl -simplify-libcalls -instcombine -simplifycfg -instcombine -simplifycfg -reassociate -domtree -loops -loopsimplify -domfrontier -loopsimplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loopsimplify -lcssa -iv-users -indvars -loop-deletion -loopsimplify -lcssa -loop-unroll -instcombine -memdep -gvn -memdep -memcpyopt -sccp -instcombine -domtree -memdep -dse -adce -gvn -simplifycfg -preverify -domtree -verify");
+ opts = g_strdup ("-simplifycfg -domtree -domfrontier -scalarrepl -instcombine -simplifycfg -basiccg -prune-eh -inline -functionattrs -domtree -domfrontier -scalarrepl -simplify-libcalls -instcombine -simplifycfg -instcombine -simplifycfg -reassociate -domtree -loops -loopsimplify -domfrontier -loopsimplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loopsimplify -lcssa -iv-users -indvars -loop-deletion -loopsimplify -lcssa -loop-unroll -instcombine -memdep -gvn -memdep -memcpyopt -sccp -instcombine -domtree -memdep -dse -adce -simplifycfg -preverify -domtree -verify");
#if 1
command = g_strdup_printf ("%sopt -f %s -o temp.opt.bc temp.bc", acfg->aot_opts.llvm_path, opts);
printf ("Executing opt: %s\n", command);
View
10 mono/mini/aot-runtime.c
@@ -654,6 +654,15 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
return FALSE;
break;
}
+ case MONO_WRAPPER_CASTCLASS: {
+ int subtype = decode_value (p, &p);
+
+ if (subtype == MONO_AOT_WRAPPER_CASTCLASS_WITH_CACHE)
+ ref->method = mono_marshal_get_castclass_with_cache ();
+ else
+ g_assert_not_reached ();
+ break;
+ }
default:
g_assert_not_reached ();
}
@@ -2348,6 +2357,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
case MONO_PATCH_INFO_MONITOR_ENTER:
case MONO_PATCH_INFO_MONITOR_EXIT:
case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
+ case MONO_PATCH_INFO_CASTCLASS_CACHE:
break;
case MONO_PATCH_INFO_RGCTX_FETCH: {
gboolean res;
View
10 mono/mini/method-to-ir.c
@@ -8136,7 +8136,10 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
/* inline cache*/
/*FIXME AOT support*/
- EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
+ if (cfg->compile_aot)
+ EMIT_NEW_AOTCONST (cfg, args [2], MONO_PATCH_INFO_CASTCLASS_CACHE, NULL);
+ else
+ EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
/*The wrapper doesn't inline well so the bloat of inlining doesn't pay off.*/
*sp++ = mono_emit_method_call (cfg, mono_castclass, args, NULL);
@@ -8258,7 +8261,10 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
/* inline cache*/
/*FIXME AOT support*/
- EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
+ if (cfg->compile_aot)
+ EMIT_NEW_AOTCONST (cfg, args [2], MONO_PATCH_INFO_CASTCLASS_CACHE, NULL);
+ else
+ EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
/*The wrapper doesn't inline well so the bloat of inlining doesn't pay off.*/
*sp++ = mono_emit_method_call (cfg, mono_castclass, args, NULL);
View
4 mono/mini/mini.c
@@ -3230,6 +3230,10 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
target = mono_gc_get_card_table (&card_table_shift_bits, &card_table_mask);
break;
}
+ case MONO_PATCH_INFO_CASTCLASS_CACHE: {
+ target = mono_domain_alloc0 (domain, sizeof (gpointer));
+ break;
+ }
default:
g_assert_not_reached ();
}
View
1 mono/mini/mini.h
@@ -2427,6 +2427,7 @@ enum {
MONO_AOT_WRAPPER_ELEMENT_ADDR,
MONO_AOT_WRAPPER_PTR_TO_STRUCTURE,
MONO_AOT_WRAPPER_STRUCTURE_TO_PTR,
+ MONO_AOT_WRAPPER_CASTCLASS_WITH_CACHE,
MONO_AOT_WRAPPER_LAST
};
View
1 mono/mini/patch-info.h
@@ -41,4 +41,5 @@ PATCH_INFO(MSCORLIB_GOT_ADDR, "mscorlib_got_addr")
PATCH_INFO(SEQ_POINT_INFO, "seq_point_info")
PATCH_INFO(LLVM_IMT_TRAMPOLINE, "llvm_imt_trampoline")
PATCH_INFO(GC_CARD_TABLE_ADDR, "gc_card_table_addr")
+PATCH_INFO(CASTCLASS_CACHE, "castclass_cache")
PATCH_INFO(NONE, "none")

0 comments on commit e228282

Please sign in to comment.