Skip to content

Commit

Permalink
[runtime] Change MonoImage::field_cache lock from the loader lock to …
Browse files Browse the repository at this point in the history
…the image lock.
  • Loading branch information
kumpera committed Jan 9, 2014
1 parent b3f05d8 commit b8bb36e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions mono/metadata/loader.c
Expand Up @@ -532,13 +532,13 @@ mono_field_from_token (MonoImage *image, guint32 token, MonoClass **retklass,
return result;
}

mono_loader_lock ();
mono_image_lock (image);
if ((field = g_hash_table_lookup (image->field_cache, GUINT_TO_POINTER (token)))) {
*retklass = field->parent;
mono_loader_unlock ();
mono_image_unlock (image);
return field;
}
mono_loader_unlock ();
mono_image_unlock (image);

if (mono_metadata_token_table (token) == MONO_TABLE_MEMBERREF)
field = field_from_memberref (image, token, retklass, context);
Expand All @@ -555,10 +555,10 @@ mono_field_from_token (MonoImage *image, guint32 token, MonoClass **retklass,
field = mono_class_get_field (k, token);
}

mono_loader_lock ();
mono_image_lock (image);
if (field && field->parent && !field->parent->generic_class && !field->parent->generic_container)
g_hash_table_insert (image->field_cache, GUINT_TO_POINTER (token), field);
mono_loader_unlock ();
mono_image_unlock (image);
return field;
}

Expand Down
2 changes: 1 addition & 1 deletion mono/metadata/metadata-internals.h
Expand Up @@ -224,7 +224,7 @@ struct _MonoImage {
/*
* Indexed by fielddef and memberref tokens
*/
GHashTable *field_cache;
GHashTable *field_cache; /*protected by the image lock*/

/* indexed by typespec tokens. */
GHashTable *typespec_cache;
Expand Down

0 comments on commit b8bb36e

Please sign in to comment.