Skip to content

Commit ecdfcb1

Browse files
committed
Remove more domain usage from the JIT code.
1 parent 8c1ea09 commit ecdfcb1

File tree

8 files changed

+37
-38
lines changed

8 files changed

+37
-38
lines changed

src/mono/mono/metadata/appdomain.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -507,16 +507,6 @@ mono_domain_try_type_resolve_name (MonoAssembly *assembly, MonoStringHandle name
507507
HANDLE_FUNCTION_RETURN_REF (MonoReflectionAssembly, MONO_HANDLE_CAST (MonoReflectionAssembly, ret));
508508
}
509509

510-
/**
511-
* mono_domain_owns_vtable_slot:
512-
* \returns Whether \p vtable_slot is inside a vtable which belongs to \p domain.
513-
*/
514-
gboolean
515-
mono_domain_owns_vtable_slot (MonoDomain *domain, gpointer vtable_slot)
516-
{
517-
return mono_mem_manager_mp_contains_addr (mono_mem_manager_get_ambient (), vtable_slot);
518-
}
519-
520510
MonoAssembly*
521511
mono_try_assembly_resolve (MonoAssemblyLoadContext *alc, const char *fname_raw, MonoAssembly *requesting, MonoError *error)
522512
{

src/mono/mono/metadata/appdomain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ mono_domain_has_type_resolve (MonoDomain *domain);
121121
MONO_API MONO_RT_EXTERNAL_ONLY MonoReflectionAssembly *
122122
mono_domain_try_type_resolve (MonoDomain *domain, char *name, MonoObject *tb);
123123

124-
MONO_API mono_bool
124+
MONO_API MONO_RT_EXTERNAL_ONLY mono_bool
125125
mono_domain_owns_vtable_slot (MonoDomain *domain, void* vtable_slot);
126126

127127
MONO_API MONO_RT_EXTERNAL_ONLY void

src/mono/mono/metadata/external-only.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,3 +686,13 @@ mono_jit_info_table_find (MonoDomain *domain, gpointer addr)
686686
{
687687
return mono_jit_info_table_find_internal (addr, TRUE, FALSE);
688688
}
689+
690+
/**
691+
* mono_domain_owns_vtable_slot:
692+
* \returns Whether \p vtable_slot is inside a vtable which belongs to \p domain.
693+
*/
694+
gboolean
695+
mono_domain_owns_vtable_slot (MonoDomain *domain, gpointer vtable_slot)
696+
{
697+
return mono_mem_manager_mp_contains_addr (mono_mem_manager_get_ambient (), vtable_slot);
698+
}

src/mono/mono/mini/interp/interp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7276,7 +7276,7 @@ interp_metadata_update_init (MonoError *error)
72767276

72777277
#ifdef ENABLE_METADATA_UPDATE
72787278
static void
7279-
metadata_update_backup_frames (MonoDomain *domain, MonoThreadInfo *info, InterpFrame *frame)
7279+
metadata_update_backup_frames (MonoThreadInfo *info, InterpFrame *frame)
72807280
{
72817281
while (frame) {
72827282
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "threadinfo=%p, copy imethod for method=%s", info, mono_method_full_name (frame->imethod->method, 1));
@@ -7286,7 +7286,7 @@ metadata_update_backup_frames (MonoDomain *domain, MonoThreadInfo *info, InterpF
72867286
}
72877287

72887288
static void
7289-
metadata_update_prepare_to_invalidate (MonoDomain *domain)
7289+
metadata_update_prepare_to_invalidate (void)
72907290
{
72917291
/* (1) make a copy of imethod for every interpframe that is on the stack,
72927292
* so we do not invalidate currently running methods */
@@ -7302,7 +7302,7 @@ metadata_update_prepare_to_invalidate (MonoDomain *domain)
73027302
*/
73037303
if (context && context->safepoint_frame) {
73047304
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "threadinfo=%p, has safepoint frame %p", info, context->safepoint_frame);
7305-
metadata_update_backup_frames (domain, info, context->safepoint_frame);
7305+
metadata_update_backup_frames (info, context->safepoint_frame);
73067306
}
73077307

73087308
MonoLMF *lmf = info->jit_data->lmf;
@@ -7311,7 +7311,7 @@ metadata_update_prepare_to_invalidate (MonoDomain *domain)
73117311
MonoLMFExt *ext = (MonoLMFExt *) lmf;
73127312
if (ext->kind == MONO_LMFEXT_INTERP_EXIT || ext->kind == MONO_LMFEXT_INTERP_EXIT_WITH_CTX) {
73137313
InterpFrame *frame = ext->interp_exit_data;
7314-
metadata_update_backup_frames (domain, info, frame);
7314+
metadata_update_backup_frames (info, frame);
73157315
}
73167316
}
73177317
lmf = (MonoLMF *)(((gsize) lmf->previous_lmf) & ~3);
@@ -7330,7 +7330,7 @@ interp_invalidate_transformed (void)
73307330
#ifdef ENABLE_METADATA_UPDATE
73317331
need_stw_restart = TRUE;
73327332
mono_stop_world (MONO_THREAD_INFO_FLAGS_NO_GC);
7333-
metadata_update_prepare_to_invalidate (mono_get_root_domain ());
7333+
metadata_update_prepare_to_invalidate ();
73347334
#endif
73357335

73367336
// FIXME: Enumerate all memory managers

src/mono/mono/mini/interp/transform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9171,7 +9171,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
91719171
save_seq_points (td, jinfo);
91729172
#ifdef ENABLE_EXPERIMENT_TIERED
91739173
/* debugging aid, it makes `mono_pmip` work. */
9174-
mono_jit_info_table_add (mono_get_root_domain (), jinfo);
9174+
mono_jit_info_table_add (jinfo);
91759175
#endif
91769176

91779177
exit:

src/mono/mono/mini/mini-arm.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,7 +3772,7 @@ emit_thunk (guint8 *code, gconstpointer target)
37723772
}
37733773

37743774
static void
3775-
handle_thunk (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guchar *target)
3775+
handle_thunk (MonoCompile *cfg, guchar *code, const guchar *target)
37763776
{
37773777
MonoJitInfo *ji = NULL;
37783778
MonoThunkJitInfo *info;
@@ -3781,9 +3781,6 @@ handle_thunk (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guchar *
37813781
guint8 *orig_target;
37823782
guint8 *target_thunk;
37833783

3784-
if (!domain)
3785-
domain = mono_domain_get ();
3786-
37873784
if (cfg) {
37883785
/*
37893786
* This can be called multiple times during JITting,
@@ -3855,7 +3852,7 @@ handle_thunk (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guchar *
38553852
}
38563853

38573854
static void
3858-
arm_patch_general (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guchar *target)
3855+
arm_patch_general (MonoCompile *cfg, guchar *code, const guchar *target)
38593856
{
38603857
guint32 *code32 = (guint32*)code;
38613858
guint32 ins = *code32;
@@ -3901,7 +3898,7 @@ arm_patch_general (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guc
39013898
}
39023899
}
39033900

3904-
handle_thunk (cfg, domain, code, target);
3901+
handle_thunk (cfg, code, target);
39053902
return;
39063903
}
39073904

@@ -4004,7 +4001,7 @@ arm_patch_general (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guc
40044001
void
40054002
arm_patch (guchar *code, const guchar *target)
40064003
{
4007-
arm_patch_general (NULL, NULL, code, target);
4004+
arm_patch_general (NULL, code, target);
40084005
}
40094006

40104007
/*
@@ -6078,7 +6075,6 @@ void
60786075
mono_arch_patch_code_new (MonoCompile *cfg, guint8 *code, MonoJumpInfo *ji, gpointer target)
60796076
{
60806077
unsigned char *ip = ji->ip.i + code;
6081-
MonoDomain *domain = mono_get_root_domain ();
60826078

60836079
switch (ji->type) {
60846080
case MONO_PATCH_INFO_SWITCH: {
@@ -6125,7 +6121,7 @@ mono_arch_patch_code_new (MonoCompile *cfg, guint8 *code, MonoJumpInfo *ji, gpoi
61256121
/* everything is dealt with at epilog output time */
61266122
break;
61276123
default:
6128-
arm_patch_general (cfg, domain, ip, (const guchar*)target);
6124+
arm_patch_general (cfg, ip, (const guchar*)target);
61296125
break;
61306126
}
61316127
}

src/mono/mono/mini/mini-ppc.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,7 @@ emit_thunk (guint8 *code, gconstpointer target)
26922692
}
26932693

26942694
static void
2695-
handle_thunk (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guchar *target)
2695+
handle_thunk (MonoCompile *cfg, guchar *code, const guchar *target)
26962696
{
26972697
MonoJitInfo *ji = NULL;
26982698
MonoThunkJitInfo *info;
@@ -2701,9 +2701,6 @@ handle_thunk (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guchar *
27012701
guint8 *orig_target;
27022702
guint8 *target_thunk;
27032703

2704-
if (!domain)
2705-
domain = mono_domain_get ();
2706-
27072704
if (cfg) {
27082705
/*
27092706
* This can be called multiple times during JITting,
@@ -2792,7 +2789,7 @@ patch_ins (guint8 *code, guint32 ins)
27922789
}
27932790

27942791
static void
2795-
ppc_patch_full (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guchar *target, gboolean is_fd)
2792+
ppc_patch_full (MonoCompile *cfg, guchar *code, const guchar *target, gboolean is_fd)
27962793
{
27972794
guint32 ins = *(guint32*)code;
27982795
guint32 prim = ins >> 26;
@@ -2832,7 +2829,7 @@ ppc_patch_full (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guchar
28322829
}
28332830
}
28342831

2835-
handle_thunk (cfg, domain, code, target);
2832+
handle_thunk (cfg, code, target);
28362833
return;
28372834

28382835
g_assert_not_reached ();
@@ -2940,7 +2937,7 @@ ppc_patch_full (MonoCompile *cfg, MonoDomain *domain, guchar *code, const guchar
29402937
void
29412938
ppc_patch (guchar *code, const guchar *target)
29422939
{
2943-
ppc_patch_full (NULL, NULL, code, target, FALSE);
2940+
ppc_patch_full (NULL, code, target, FALSE);
29442941
}
29452942

29462943
void
@@ -4618,7 +4615,6 @@ mono_arch_patch_code_new (MonoCompile *cfg, guint8 *code, MonoJumpInfo *ji, gpoi
46184615
{
46194616
unsigned char *ip = ji->ip.i + code;
46204617
gboolean is_fd = FALSE;
4621-
MonoDomain *domain = mono_get_root_domain ();
46224618

46234619
switch (ji->type) {
46244620
case MONO_PATCH_INFO_IP:
@@ -4673,7 +4669,7 @@ mono_arch_patch_code_new (MonoCompile *cfg, guint8 *code, MonoJumpInfo *ji, gpoi
46734669
/* fall through */
46744670
#endif
46754671
default:
4676-
ppc_patch_full (cfg, domain, ip, (const guchar*)target, is_fd);
4672+
ppc_patch_full (cfg, ip, (const guchar*)target, is_fd);
46774673
break;
46784674
}
46794675
}

src/mono/mono/mini/mini-trampolines.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr)
153153
}
154154
#endif
155155

156+
// FIXME: Is this still needed ?
157+
static gboolean
158+
owns_vtable_slot (gpointer vtable_slot)
159+
{
160+
return mono_mem_manager_mp_contains_addr (mono_mem_manager_get_ambient (), vtable_slot);
161+
}
162+
156163
gpointer
157164
mono_create_ftnptr_arg_trampoline (gpointer arg, gpointer addr)
158165
{
@@ -507,7 +514,7 @@ common_call_trampoline (host_mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTa
507514
/*
508515
* We found AOT compiled code for the method, skip the rest.
509516
*/
510-
if (mono_domain_owns_vtable_slot (mono_get_root_domain (), vtable_slot))
517+
if (owns_vtable_slot (vtable_slot))
511518
*vtable_slot = addr;
512519

513520
return mono_create_ftnptr (addr);
@@ -690,7 +697,7 @@ common_call_trampoline (host_mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTa
690697
vtable_slot = orig_vtable_slot;
691698

692699
if (vtable_slot) {
693-
if (vtable_slot_to_patch && (mono_aot_is_got_entry (code, (guint8*)vtable_slot_to_patch) || mono_domain_owns_vtable_slot (mono_get_root_domain (), vtable_slot_to_patch))) {
700+
if (vtable_slot_to_patch && (mono_aot_is_got_entry (code, (guint8*)vtable_slot_to_patch) || owns_vtable_slot (vtable_slot_to_patch))) {
694701
g_assert (*vtable_slot_to_patch);
695702
*vtable_slot_to_patch = mono_get_addr_from_ftnptr (addr);
696703
}
@@ -823,7 +830,7 @@ mono_vcall_trampoline (host_mgreg_t *regs, guint8 *code, int slot, guint8 *tramp
823830
addr = mono_aot_get_method_from_vt_slot (vt, slot, error);
824831
goto_if_nok (error, leave);
825832
if (addr && !m_class_is_valuetype (vt->klass)) {
826-
if (mono_domain_owns_vtable_slot (mono_get_root_domain (), vtable_slot))
833+
if (owns_vtable_slot (vtable_slot))
827834
*vtable_slot = addr;
828835

829836
res = mono_create_ftnptr (addr);

0 commit comments

Comments
 (0)