Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / aot-runtime.c
index 4e86a5a3f32dc0f21460bfb23046f2a12f34f55b..7330d1cd30a976205ad29f6ae985472c6a8b28ad 100644 (file)
@@ -3957,9 +3957,10 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
                return code;
 
        if (mono_last_aot_method != -1) {
-               if (mono_jit_stats.methods_aot >= mono_last_aot_method)
-                               return NULL;
-               else if (mono_jit_stats.methods_aot == mono_last_aot_method - 1) {
+               gint32 methods_aot = InterlockedRead (&mono_jit_stats.methods_aot);
+               if (methods_aot >= mono_last_aot_method)
+                       return NULL;
+               else if (methods_aot == mono_last_aot_method - 1) {
                        if (!method) {
                                method = mono_get_method_checked (image, token, NULL, NULL, error);
                                if (!method)