[mono][llvm] Access mono_thread_interruption_request_flag directly from llvm generate...
authorZoltan Varga <vargaz@gmail.com>
Tue, 17 Aug 2021 00:18:51 +0000 (20:18 -0400)
committerGitHub <noreply@github.com>
Tue, 17 Aug 2021 00:18:51 +0000 (19:18 -0500)
src/mono/mono/metadata/threads-types.h
src/mono/mono/mini/mini-llvm.c

index 163e3ab..e4bd2d4 100644 (file)
@@ -292,7 +292,7 @@ MonoException* mono_thread_force_interruption_checkpoint_noraise (void);
  * mono_thread_interruption_checkpoint () is always needed if the flag is not
  * zero.
  */
-extern gint32 mono_thread_interruption_request_flag;
+MONO_API_DATA gint32 mono_thread_interruption_request_flag;
 
 uint32_t mono_alloc_special_static_data (uint32_t static_type, uint32_t size, uint32_t align, uintptr_t *bitmap, int numbits);
 
index c8a3a90..ada72e4 100644 (file)
@@ -108,6 +108,7 @@ typedef struct {
        LLVMContextRef context;
        LLVMValueRef sentinel_exception;
        LLVMValueRef gc_safe_point_flag_var;
+       LLVMValueRef interrupt_flag_var;
        void *di_builder, *cu;
        GHashTable *objc_selector_to_var;
        GPtrArray *cfgs;
@@ -1909,15 +1910,6 @@ get_aotconst_module (MonoLLVMModule *module, LLVMBuilderRef builder, MonoJumpInf
        guint32 got_offset;
        LLVMValueRef load;
 
-       if (module->static_link && type == MONO_PATCH_INFO_GC_SAFE_POINT_FLAG) {
-               const char *symbol = "mono_polling_required";
-               if (!module->gc_safe_point_flag_var) {
-                       module->gc_safe_point_flag_var = LLVMAddGlobal (module->lmodule, llvm_type, symbol);
-                       LLVMSetLinkage (module->gc_safe_point_flag_var, LLVMExternalLinkage);
-               }
-               return module->gc_safe_point_flag_var;
-       }
-
        MonoJumpInfo tmp_ji;
        tmp_ji.type = type;
        tmp_ji.data.target = data;
@@ -1933,6 +1925,23 @@ get_aotconst_module (MonoLLVMModule *module, LLVMBuilderRef builder, MonoJumpInf
        if (out_got_offset)
                *out_got_offset = got_offset;
 
+       if (module->static_link && type == MONO_PATCH_INFO_GC_SAFE_POINT_FLAG) {
+               if (!module->gc_safe_point_flag_var) {
+                       const char *symbol = "mono_polling_required";
+                       module->gc_safe_point_flag_var = LLVMAddGlobal (module->lmodule, llvm_type, symbol);
+                       LLVMSetLinkage (module->gc_safe_point_flag_var, LLVMExternalLinkage);
+               }
+               return module->gc_safe_point_flag_var;
+       }
+       if (module->static_link && type == MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG) {
+               if (!module->interrupt_flag_var) {
+                       const char *symbol = "mono_thread_interruption_request_flag";
+                       module->interrupt_flag_var = LLVMAddGlobal (module->lmodule, llvm_type, symbol);
+                       LLVMSetLinkage (module->interrupt_flag_var, LLVMExternalLinkage);
+               }
+               return module->interrupt_flag_var;
+       }
+
        LLVMValueRef const_var = g_hash_table_lookup (module->aotconst_vars, GINT_TO_POINTER (got_offset));
        if (!const_var) {
                LLVMTypeRef type = llvm_type;