Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 9 additions & 14 deletions src/mono/mono/metadata/class-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -952,25 +952,20 @@ mono_class_get_##shortname##_class (void) \

// GENERATE_TRY_GET_CLASS_WITH_CACHE attempts mono_class_load_from_name approximately
// only once. i.e. if it fails, it will return null and not retry.
// In a race it might try a few times, but not indefinitely.
//
// FIXME This maybe has excessive volatile/barriers.
//
#define GENERATE_TRY_GET_CLASS_WITH_CACHE(shortname,name_space,name) \
MonoClass* \
mono_class_try_get_##shortname##_class (void) \
{ \
static volatile MonoClass *tmp_class; \
static volatile gboolean inited; \
MonoClass *klass = (MonoClass *)tmp_class; \
mono_memory_barrier (); \
if (!inited) { \
klass = mono_class_try_load_from_name (mono_class_generate_get_corlib_impl (), name_space, name); \
tmp_class = klass; \
mono_memory_barrier (); \
inited = TRUE; \
static MonoClass *cached_class; \
static gboolean cached_class_inited; \
gboolean tmp_inited; \
mono_atomic_load_acquire(tmp_inited, gboolean, &cached_class_inited); \
if (G_LIKELY(tmp_inited)) { \
return (MonoClass*)cached_class; \
} \
return klass; \
cached_class = mono_class_try_load_from_name (mono_class_generate_get_corlib_impl (), name_space, name); \
mono_atomic_store_release(&cached_class_inited, TRUE); \
return (MonoClass*)cached_class; \
}

GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL (safehandle)
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -3391,6 +3391,8 @@ static void
init_io_stream_slots (void)
{
MonoClass* klass = mono_class_try_get_stream_class ();
g_assert(klass);

mono_class_setup_vtable (klass);
MonoMethod **klass_methods = m_class_get_methods (klass);
if (!klass_methods) {
Expand Down
Loading