Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono][interp] Avoid calls to m_class_get_mem_manager () in get_virtu… #60229

Merged
merged 1 commit into from
Oct 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,11 +694,12 @@ static InterpMethod* // Inlining causes additional stack use in caller.
get_virtual_method_fast (InterpMethod *imethod, MonoVTable *vtable, int offset)
{
gpointer *table;
MonoMemoryManager *memory_manager = m_class_get_mem_manager (vtable->klass);
MonoMemoryManager *memory_manager = NULL;

table = get_method_table (vtable, offset);

if (!table) {
if (G_UNLIKELY (!table)) {
memory_manager = m_class_get_mem_manager (vtable->klass);
/* Lazily allocate method table */
mono_mem_manager_lock (memory_manager);
table = get_method_table (vtable, offset);
Expand All @@ -707,8 +708,10 @@ get_virtual_method_fast (InterpMethod *imethod, MonoVTable *vtable, int offset)
mono_mem_manager_unlock (memory_manager);
}

if (!table [offset]) {
if (G_UNLIKELY (!table [offset])) {
InterpMethod *target_imethod = get_virtual_method (imethod, vtable);
if (!memory_manager)
memory_manager = m_class_get_mem_manager (vtable->klass);
/* Lazily initialize the method table slot */
mono_mem_manager_lock (memory_manager);
if (!table [offset]) {
Expand All @@ -727,8 +730,10 @@ get_virtual_method_fast (InterpMethod *imethod, MonoVTable *vtable, int offset)
/* Virtual generic or interface call. Multiple methods in slot */
InterpMethod *target_imethod = get_target_imethod ((GSList*)table [offset], imethod);

if (!target_imethod) {
if (G_UNLIKELY (!target_imethod)) {
target_imethod = get_virtual_method (imethod, vtable);
if (!memory_manager)
memory_manager = m_class_get_mem_manager (vtable->klass);
mono_mem_manager_lock (memory_manager);
if (!get_target_imethod ((GSList*)table [offset], imethod))
table [offset] = append_imethod (memory_manager, (GSList*)table [offset], imethod, target_imethod);
Expand Down