Fix mcs build to use Thread.Abort.
[mono.git] / mono / mini / aot-runtime.c
index 1bd466e298688657350bad9ad181b1ac80fb076b..3091cab90549320f868f5dc2f5c385c909fc21b8 100644 (file)
 #include <mono/metadata/assembly.h>
 #include <mono/metadata/metadata-internals.h>
 #include <mono/metadata/marshal.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
 #include <mono/metadata/threads-types.h>
 #include <mono/metadata/mono-endian.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
 #include <mono/utils/mono-mmap.h>
 #include <mono/utils/mono-compiler.h>
 #include <mono/utils/mono-counters.h>
@@ -60,6 +60,7 @@
 #include "seq-points.h"
 #include "version.h"
 #include "debugger-agent.h"
+#include "aot-compiler.h"
 
 #ifndef DISABLE_AOT
 
@@ -895,15 +896,7 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
                        break;
                }
                case MONO_WRAPPER_WRITE_BARRIER: {
-                       int nursery_bits = decode_value (p, &p);
-
                        ref->method = mono_gc_get_write_barrier ();
-                       if (ref->method) {
-                               /* Sanity check */
-                               info = mono_marshal_get_wrapper_info (ref->method);
-                               g_assert (info);
-                               g_assert (info->d.wbarrier.nursery_bits == nursery_bits);
-                       }
                        break;
                }
                case MONO_WRAPPER_STELEMREF: {
@@ -1777,7 +1770,7 @@ static void
 init_amodule_got (MonoAotModule *amodule)
 {
        MonoJumpInfo *ji;
-       MonoMemPool *mp = mono_mempool_new ();
+       MonoMemPool *mp;
        MonoJumpInfo *patches;
        guint32 got_offsets [128];
        int i, npatches;
@@ -1788,6 +1781,7 @@ init_amodule_got (MonoAotModule *amodule)
 
        amodule->got_initializing = TRUE;
 
+       mp = mono_mempool_new ();
        npatches = amodule->info.nshared_got_entries;
        for (i = 0; i < npatches; ++i)
                got_offsets [i] = i;
@@ -1800,6 +1794,8 @@ init_amodule_got (MonoAotModule *amodule)
                        amodule->shared_got [i] = NULL;
                } else if (ji->type == MONO_PATCH_INFO_GC_NURSERY_START && !mono_gc_is_moving ()) {
                        amodule->shared_got [i] = NULL;
+               } else if (ji->type == MONO_PATCH_INFO_GC_NURSERY_BITS && !mono_gc_is_moving ()) {
+                       amodule->shared_got [i] = NULL;
                } else if (ji->type == MONO_PATCH_INFO_IMAGE) {
                        amodule->shared_got [i] = amodule->assembly->image;
                } else if (ji->type == MONO_PATCH_INFO_MSCORLIB_GOT_ADDR) {
@@ -1826,6 +1822,8 @@ init_amodule_got (MonoAotModule *amodule)
                for (i = 0; i < npatches; ++i)
                        amodule->llvm_got [i] = amodule->shared_got [i];
        }
+
+       mono_mempool_destroy (mp);
 }
 
 static void
@@ -2149,18 +2147,6 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
                mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: loaded AOT Module for %s.\n", assembly->image->name);
 }
 
-/*
- * mono_aot_register_globals:
- *
- *   This is called by the ctor function in AOT images compiled with the
- * 'no-dlsym' option.
- */
-void
-mono_aot_register_globals (gpointer *globals)
-{
-       g_assert_not_reached ();
-}
-
 /*
  * mono_aot_register_module:
  *
@@ -3425,6 +3411,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
        case MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG:
        case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
        case MONO_PATCH_INFO_GC_NURSERY_START:
+       case MONO_PATCH_INFO_GC_NURSERY_BITS:
        case MONO_PATCH_INFO_JIT_TLS_ID:
                break;
        case MONO_PATCH_INFO_CASTCLASS_CACHE:
@@ -3612,8 +3599,6 @@ load_patch_info (MonoAotModule *amodule, MonoMemPool *mp, int n_patches,
 
        p = buf;
 
-       patches = mono_mempool_alloc0 (mp, sizeof (MonoJumpInfo) * n_patches);
-
        *got_slots = g_malloc (sizeof (guint32) * n_patches);
        for (pindex = 0; pindex < n_patches; ++pindex) {
                (*got_slots)[pindex] = decode_value (p, &p);
@@ -3855,7 +3840,7 @@ find_aot_method_in_amodule (MonoAotModule *amodule, MonoMethod *method, guint32
                        MonoMethod *w1 = mono_marshal_method_from_wrapper (method);
                        MonoMethod *w2 = mono_marshal_method_from_wrapper (m);
 
-                       if (w1->is_inflated && ((MonoMethodInflated *)w1)->declaring == w2) {
+                       if ((w1 == w2) || (w1->is_inflated && ((MonoMethodInflated *)w1)->declaring == w2)) {
                                index = value;
                                break;
                        }
@@ -3984,8 +3969,10 @@ init_llvm_method (MonoAotModule *amodule, guint32 method_index, MonoMethod *meth
                }
 
                patches = load_patch_info (amodule, mp, n_patches, llvm, &got_slots, p, &p);
-               if (patches == NULL)
+               if (patches == NULL) {
+                       mono_mempool_destroy (mp);
                        goto cleanup;
+               }
 
                for (pindex = 0; pindex < n_patches; ++pindex) {
                        MonoJumpInfo *ji = &patches [pindex];