MonoGenericContext context;
} MonoInflatedMethodSignature;
+/**
+ * mono_image_alloc_lock:
+ *
+ * Same as mono_image_alloc, but do the locking as well.
+ * LOCKING: Acquires the loader lock.
+ */
+static gpointer
+mono_image_alloc_lock (MonoImage *image, guint size)
+{
+ gpointer res;
+
+ mono_loader_lock ();
+ res = mono_image_alloc (image, size);
+ mono_loader_unlock ();
+
+ return res;
+}
+
+/**
+ * mono_image_alloc0_lock:
+ *
+ * Same as mono_image_alloc, but do the locking as well.
+ * LOCKING: Acquires the loader lock.
+ */
+static gpointer
+mono_image_alloc0_lock (MonoImage *image, guint size)
+{
+ gpointer res;
+
+ mono_loader_lock ();
+ res = mono_image_alloc0 (image, size);
+ mono_loader_unlock ();
+
+ return res;
+}
+
/**
* mono_meta_table_name:
* @table: table index
*
+ * Returns the name of the given ECMA metadata logical format table
+ * as described in ECMA 335, Partition II, Section 22.
+ *
* Returns: the name for the @table index
*/
const char *
* Returns: a #MonoArrayType structure describing the array type
* and dimensions. Memory is allocated from the image mempool.
*
- * LOCKING: Assumes the loader lock is held.
+ * LOCKING: Acquires the loader lock
*/
MonoArrayType *
mono_metadata_parse_array_full (MonoImage *m, MonoGenericContainer *container,
const char *ptr, const char **rptr)
{
int i;
- MonoArrayType *array = mono_image_alloc0 (m, sizeof (MonoArrayType));
+ MonoArrayType *array;
MonoType *etype;
+ array = mono_image_alloc0_lock (m, sizeof (MonoArrayType));
etype = mono_metadata_parse_type_full (m, container, MONO_PARSE_TYPE, 0, ptr, &ptr);
if (!etype)
return NULL;
int count = 0;
gboolean found;
- mono_loader_lock ();
/*
* According to the spec, custom modifiers should come before the byref
* flag, but the IL produced by ilasm from the following signature:
}
if (count) {
- type = mono_image_alloc0 (m, sizeof (MonoType) + ((gint32)count - MONO_ZERO_LEN_ARRAY) * sizeof (MonoCustomMod));
+ type = mono_image_alloc0_lock (m, sizeof (MonoType) + ((gint32)count - MONO_ZERO_LEN_ARRAY) * sizeof (MonoCustomMod));
type->num_mods = count;
if (count > 64)
g_warning ("got more than 64 modifiers in type");
type->pinned = pinned ? 1 : 0;
if (!do_mono_metadata_parse_type (type, m, container, ptr, &ptr)) {
- mono_loader_unlock ();
return NULL;
}
of a MonoClass which currently holds the loader lock. 'type' is local.
*/
if (ret->data.klass == type->data.klass) {
- mono_loader_unlock ();
return ret;
}
}
/* No need to use locking since nobody is modifying the hash table */
if ((cached = g_hash_table_lookup (type_cache, type))) {
- mono_loader_unlock ();
return cached;
}
}
/* printf ("%x %x %c %s\n", type->attrs, type->num_mods, type->pinned ? 'p' : ' ', mono_type_full_name (type)); */
if (type == &stype) {
- type = mono_image_alloc (m, sizeof (MonoType));
+ type = mono_image_alloc_lock (m, sizeof (MonoType));
memcpy (type, &stype, sizeof (MonoType));
}
- mono_loader_unlock ();
return type;
}
/*
- * LOCKING: Assumes the loader lock is held.
+ * LOCKING: Acquires the loader lock.
*/
MonoType*
mono_metadata_parse_type (MonoImage *m, MonoParseTypeMode mode, short opt_attrs,
{
MonoMethodSignature *sig;
- mono_loader_lock ();
- sig = mono_image_alloc0 (m, sizeof (MonoMethodSignature) + ((gint32)nparams - MONO_ZERO_LEN_ARRAY) * sizeof (MonoType*));
+ sig = mono_image_alloc0_lock (m, sizeof (MonoMethodSignature) + ((gint32)nparams - MONO_ZERO_LEN_ARRAY) * sizeof (MonoType*));
sig->param_count = nparams;
sig->sentinelpos = -1;
- mono_loader_unlock ();
return sig;
}
* @generic_container: Our MonoClass's or MonoMethodNormal's MonoGenericContainer;
* see mono_metadata_parse_type_full() for details.
* Internal routine to parse a generic type parameter.
- * LOCKING: Assumes the loader lock is held.
+ * LOCKING: Acquires the loader lock
*/
static MonoGenericParam *
mono_metadata_parse_generic_param (MonoImage *m, MonoGenericContainer *generic_container,
generic_container = select_container (generic_container, type);
if (!generic_container) {
/* Create dummy MonoGenericParam */
- MonoGenericParam *param = mono_image_alloc0 (m, sizeof (MonoGenericParam));
- param->name = mono_image_alloc0 (m, 8);
+ MonoGenericParam *param;
+
+ param = mono_image_alloc0_lock (m, sizeof (MonoGenericParam));
+ param->name = mono_image_alloc0_lock (m, 8);
sprintf ((char*)param->name, "%d", index);
param->num = index;
param->image = m;
int i;
mh->num_clauses = is_fat ? sect_data_len / 24: sect_data_len / 12;
/* we could just store a pointer if we don't need to byteswap */
- mh->clauses = mono_image_alloc0 (m, sizeof (MonoExceptionClause) * mh->num_clauses);
+ mh->clauses = mono_image_alloc0_lock (m, sizeof (MonoExceptionClause) * mh->num_clauses);
for (i = 0; i < mh->num_clauses; ++i) {
MonoExceptionClause *ec = &mh->clauses [i];
guint32 tof_value;
* info about local variables and optional exception tables.
* This is a Mono runtime internal function.
*
- * LOCKING: Assumes the loader lock is held.
+ * LOCKING: Acquires the loader lock.
*
* Returns: a MonoMethodHeader allocated from the image mempool.
*/
g_return_val_if_fail (ptr != NULL, NULL);
- mono_loader_lock ();
switch (format) {
case METHOD_HEADER_TINY_FORMAT:
- mh = mono_image_alloc0 (m, sizeof (MonoMethodHeader));
+ mh = mono_image_alloc0_lock (m, sizeof (MonoMethodHeader));
ptr++;
mh->max_stack = 8;
local_var_sig_tok = 0;
mh->code_size = flags >> 2;
mh->code = (unsigned char*)ptr;
- mono_loader_unlock ();
return mh;
case METHOD_HEADER_TINY_FORMAT1:
- mh = mono_image_alloc0 (m, sizeof (MonoMethodHeader));
+ mh = mono_image_alloc0_lock (m, sizeof (MonoMethodHeader));
ptr++;
mh->max_stack = 8;
local_var_sig_tok = 0;
*/
mh->code_size = flags >> 2;
mh->code = (unsigned char*)ptr;
- mono_loader_unlock ();
return mh;
case METHOD_HEADER_FAT_FORMAT:
fat_flags = read16 (ptr);
ptr = (char*)code + code_size;
break;
default:
- mono_loader_unlock ();
return NULL;
}
g_warning ("wrong signature for locals blob");
locals_ptr++;
len = mono_metadata_decode_value (locals_ptr, &locals_ptr);
- mh = mono_image_alloc0 (m, sizeof (MonoMethodHeader) + (len - MONO_ZERO_LEN_ARRAY) * sizeof (MonoType*));
+ mh = mono_image_alloc0_lock (m, sizeof (MonoMethodHeader) + (len - MONO_ZERO_LEN_ARRAY) * sizeof (MonoType*));
mh->num_locals = len;
for (i = 0; i < len; ++i) {
mh->locals [i] = mono_metadata_parse_type_full (
m, container, MONO_PARSE_LOCAL, 0, locals_ptr, &locals_ptr);
if (!mh->locals [i]) {
- mono_loader_unlock ();
return NULL;
}
}
} else {
- mh = mono_image_alloc0 (m, sizeof (MonoMethodHeader));
+ mh = mono_image_alloc0_lock (m, sizeof (MonoMethodHeader));
}
mh->code = code;
mh->code_size = code_size;
mh->init_locals = init_locals;
if (fat_flags & METHOD_HEADER_MORE_SECTS)
parse_section_data (m, mh, (const unsigned char*)ptr);
- mono_loader_unlock ();
return mh;
}
++pos;
}
- mono_loader_lock ();
- result = mono_image_alloc0 (meta, sizeof (MonoClass*) * (pos - start));
- mono_loader_unlock ();
+ result = mono_image_alloc0_lock (meta, sizeof (MonoClass*) * (pos - start));
pos = start;
while (pos < tdef->rows) {
*
* Returns: NULL if @token is not a generic type or method definition or the new generic container.
*
- * LOCKING: Assumes the loader lock is held.
+ * LOCKING: Acquires the loader lock
*
*/
MonoGenericContainer *
mono_metadata_decode_row (tdef, i - 1, cols, MONO_GENERICPARAM_SIZE);
params = NULL;
n = 0;
- container = mono_image_alloc0 (image, sizeof (MonoGenericContainer));
+ container = mono_image_alloc0_lock (image, sizeof (MonoGenericContainer));
do {
n++;
params = g_realloc (params, sizeof (MonoGenericParam) * n);
} while (cols [MONO_GENERICPARAM_OWNER] == owner);
container->type_argc = n;
- container->type_params = mono_image_alloc0 (image, sizeof (MonoGenericParam) * n);
+ container->type_params = mono_image_alloc0_lock (image, sizeof (MonoGenericParam) * n);
memcpy (container->type_params, params, sizeof (MonoGenericParam) * n);
g_free (params);
container->parent = parent_container;