Implement AOT support for the new Monitor.Enter () wrapper.
authorZoltan Varga <vargaz@gmail.com>
Wed, 25 May 2011 02:15:11 +0000 (04:15 +0200)
committerZoltan Varga <vargaz@gmail.com>
Wed, 25 May 2011 02:15:11 +0000 (04:15 +0200)
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/method-to-ir.c
mono/mini/mini.h

index b5516fb8034973468e22a76047c504a9cda3e76a..fa86cf174a287510ddfbc2c2d1e2e7f8f80b0b37 100644 (file)
@@ -2048,9 +2048,11 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8
                }
                case MONO_WRAPPER_UNKNOWN:
                        if (strcmp (method->name, "FastMonitorEnter") == 0) {
-                               encode_value (MONO_AOT_WRAPPER_MONO_ENTER, p, &p);
+                               encode_value (MONO_AOT_WRAPPER_MONITOR_ENTER, p, &p);
                        } else if (strcmp (method->name, "FastMonitorExit") == 0) {
-                               encode_value (MONO_AOT_WRAPPER_MONO_EXIT, p, &p);
+                               encode_value (MONO_AOT_WRAPPER_MONITOR_EXIT, p, &p);
+                       } else if (strcmp (method->name, "FastMonitorEnterV4") == 0) {
+                               encode_value (MONO_AOT_WRAPPER_MONITOR_ENTER_V4, p, &p);
                        } else if (strcmp (method->name, "PtrToStructure") == 0) {
                                encode_value (MONO_AOT_WRAPPER_PTR_TO_STRUCTURE, p, &p);
                                encode_klass_ref (acfg, method->klass, p, &p);
@@ -2673,6 +2675,21 @@ add_wrappers (MonoAotCompile *acfg)
                add_method (acfg, mono_marshal_get_castclass_with_cache ());
                /* isinst_with_check wrapper */
                add_method (acfg, mono_marshal_get_isinst_with_cache ());
+
+#if defined(MONO_ARCH_ENABLE_MONITOR_IL_FASTPATH)
+               {
+                       MonoMethodDesc *desc;
+                       MonoMethod *m;
+
+                       desc = mono_method_desc_new ("Monitor:Enter(object,bool&)", FALSE);
+                       m = mono_method_desc_search_in_class (desc, mono_defaults.monitor_class);
+                       mono_method_desc_free (desc);
+                       if (m) {
+                               m = mono_monitor_get_fast_path (m);
+                               add_method (acfg, m);
+                       }
+               }
+#endif
        }
 
        /* 
index cf13cd5a1697394f1d52d19b0e18676eba691b8a..fc58efdfa63c81a758a24872e67e49e87a03acd6 100644 (file)
@@ -605,10 +605,12 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
                                        ref->method = mono_marshal_get_struct_to_ptr (klass);
                                }
                        } else {
-                               if (subtype == MONO_AOT_WRAPPER_MONO_ENTER)
+                               if (subtype == MONO_AOT_WRAPPER_MONITOR_ENTER)
                                        desc = mono_method_desc_new ("Monitor:Enter", FALSE);
-                               else if (subtype == MONO_AOT_WRAPPER_MONO_EXIT)
+                               else if (subtype == MONO_AOT_WRAPPER_MONITOR_EXIT)
                                        desc = mono_method_desc_new ("Monitor:Exit", FALSE);
+                               else if (subtype == MONO_AOT_WRAPPER_MONITOR_ENTER_V4)
+                                       desc = mono_method_desc_new ("Monitor:Enter(object,bool&)", FALSE);
                                else
                                        g_assert_not_reached ();
                                orig_method = mono_method_desc_search_in_class (desc, mono_defaults.monitor_class);
index dcfbb246eb4d2fd637e0ae883a513ebf3cab038c..0c87551301da8c59c4fb0a9cb470916013f2c0db 100644 (file)
@@ -4454,7 +4454,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                        MonoMethod *fast_method = NULL;
 
                        /*FIXME fix LLVM and AOT support*/
-                       if (COMPILE_LLVM (cfg) || cfg->compile_aot)
+                       if (COMPILE_LLVM (cfg))
                                return NULL;
 
                        /* Avoid infinite recursion */
@@ -4465,7 +4465,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                        if (!fast_method)
                                return NULL;
 
-                       return (MonoInst*)mono_emit_method_call (cfg, fast_method, args, NULL);                 
+                       return (MonoInst*)mono_emit_method_call (cfg, fast_method, args, NULL);
                }
 #endif
 
index 79dd2508644f8caa19081750c793a9cdfdf3112c..aea2e754b6ff2f2f9647a4423a6cf4705278140d 100644 (file)
@@ -2427,13 +2427,14 @@ gboolean SIG_HANDLER_SIGNATURE (mono_chain_signal) MONO_INTERNAL;
 
 /* for MONO_WRAPPER_UNKNOWN/MANAGED_TO_MANAGED subtypes */
 enum {
-       MONO_AOT_WRAPPER_MONO_ENTER,
-       MONO_AOT_WRAPPER_MONO_EXIT,
+       MONO_AOT_WRAPPER_MONITOR_ENTER,
+       MONO_AOT_WRAPPER_MONITOR_EXIT,
        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_ISINST_WITH_CACHE,
+       MONO_AOT_WRAPPER_MONITOR_ENTER_V4,
        MONO_AOT_WRAPPER_LAST
 };