Skip to content

Commit

Permalink
[mono][llvm] Access mono_thread_interruption_request_flag directly fr…
Browse files Browse the repository at this point in the history
…om llvm generated code, similarly to mono_polling_required. (#57263)
  • Loading branch information
vargaz authored Aug 17, 2021
1 parent 2144431 commit 44b1cd6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/threads-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
27 changes: 18 additions & 9 deletions src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 44b1cd6

Please sign in to comment.