#include "marshal.h"
#include "debug-helpers.h"
#include <mono/utils/mono-error-internals.h>
-
+#include <mono/utils/bsearch.h>
+
/* Auxiliary structure used for caching inflated signatures */
typedef struct {
MonoMethodSignature *sig;
n = MAX (n, meta->tables [MONO_TABLE_METHOD].rows);
n = MAX (n, meta->tables [MONO_TABLE_MODULEREF].rows);
n = MAX (n, meta->tables [MONO_TABLE_TYPESPEC].rows);
- n = MAX (n, meta->tables [MONO_TABLE_MEMBERREF].rows);
/* 3 bits to encode */
field_size = rtsize (n, 16 - 3);
const char *
mono_metadata_string_heap (MonoImage *meta, guint32 index)
{
+ g_assert (index < meta->heap_strings.size);
g_return_val_if_fail (index < meta->heap_strings.size, "");
return meta->heap_strings.data + index;
}
const char *
mono_metadata_user_string (MonoImage *meta, guint32 index)
{
+ g_assert (index < meta->heap_us.size);
g_return_val_if_fail (index < meta->heap_us.size, "");
return meta->heap_us.data + index;
}
const char *
mono_metadata_blob_heap (MonoImage *meta, guint32 index)
{
+ g_assert (index < meta->heap_blob.size);
g_return_val_if_fail (index < meta->heap_blob.size, "");/*FIXME shouldn't we return NULL and check for index == 0?*/
return meta->heap_blob.data + index;
}
static void
collect_method_images (MonoMethodInflated *method, CollectData *data)
{
+ MonoMethod *m = method->declaring;
+
add_image (method->declaring->klass->image, data);
if (method->context.class_inst)
collect_ginst_images (method->context.class_inst, data);
if (method->context.method_inst)
collect_ginst_images (method->context.method_inst, data);
/*
- if (((MonoMethod*)method)->signature)
- collect_signature_images (mono_method_signature ((MonoMethod*)method), data);
- */
+ * Dynamic assemblies have no references, so the images they depend on can be unloaded before them.
+ */
+ if (m->klass->image->dynamic)
+ collect_signature_images (mono_method_signature (m), data);
}
static void
}
}
-GSList*
+void
mono_metadata_clean_for_image (MonoImage *image)
{
CleanForImageUserData ginst_data, gclass_data;
- GSList *l, *set_list, *free_list = NULL;
+ GSList *l, *set_list;
//check_image_sets (image);
g_slist_free (set_list);
mono_loader_unlock ();
-
- return free_list;
}
static void
if (meta->uncompressed_metadata)
loc.idx = search_ptr_table (meta, MONO_TABLE_FIELD_POINTER, loc.idx);
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, typedef_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, typedef_locator))
return 0;
/* loc_result is 0..1, needs to be mapped to table index (that is +1) */
if (meta->uncompressed_metadata)
loc.idx = search_ptr_table (meta, MONO_TABLE_METHOD_POINTER, loc.idx);
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, typedef_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, typedef_locator))
return 0;
/* loc_result is 0..1, needs to be mapped to table index (that is +1) */
loc.col_idx = MONO_INTERFACEIMPL_CLASS;
loc.t = tdef;
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
return TRUE;
start = loc.result;
*
* Returns: the 1-based index into the TypeDef table of the type
* where the type described by @index is nested.
- * Retruns 0 if @index describes a non-nested type.
+ * Returns 0 if @index describes a non-nested type.
*/
guint32
mono_metadata_nested_in_typedef (MonoImage *meta, guint32 index)
loc.col_idx = MONO_NESTED_CLASS_NESTED;
loc.t = tdef;
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
return 0;
/* loc_result is 0..1, needs to be mapped to table index (that is +1) */
loc.col_idx = MONO_CLASS_LAYOUT_PARENT;
loc.t = tdef;
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
return 0;
mono_metadata_decode_row (tdef, loc.result, cols, MONO_CLASS_LAYOUT_SIZE);
/* FIXME: Index translation */
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
return 0;
/* Find the first entry by searching backwards */
loc.col_idx = MONO_DECL_SECURITY_PARENT;
loc.t = tdef;
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, declsec_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, declsec_locator))
return -1;
/* Find the first entry by searching backwards */
return 4;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
-#if defined(__APPLE__) && SIZEOF_VOID_P==4
- /* xcode 4.3 llvm-gcc bug */
- *align = 4;
-#else
*align = abi__alignof__(gint64);
-#endif
return 8;
case MONO_TYPE_R8:
*align = abi__alignof__(double);
return TRUE;
if (mono_generic_param_num (p1) != mono_generic_param_num (p2))
return FALSE;
+ if (p1->serial != p2->serial)
+ return FALSE;
/*
* We have to compare the image as well because if we didn't,
if (signature_only &&
(c1->byval_arg.type == MONO_TYPE_SZARRAY) && (c2->byval_arg.type == MONO_TYPE_SZARRAY))
return mono_metadata_class_equal (c1->byval_arg.data.klass, c2->byval_arg.data.klass, signature_only);
+ if (signature_only &&
+ (c1->byval_arg.type == MONO_TYPE_ARRAY) && (c2->byval_arg.type == MONO_TYPE_ARRAY))
+ return do_mono_metadata_type_equal (&c1->byval_arg, &c2->byval_arg, signature_only);
return FALSE;
}
loc.col_idx = MONO_FIELD_LAYOUT_FIELD;
loc.t = tdef;
- if (tdef->base && bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator)) {
+ if (tdef->base && mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator)) {
*offset = mono_metadata_decode_row_col (tdef, loc.result, MONO_FIELD_LAYOUT_OFFSET);
} else {
*offset = (guint32)-1;
loc.col_idx = MONO_FIELD_RVA_FIELD;
loc.t = tdef;
- if (tdef->base && bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator)) {
+ if (tdef->base && mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator)) {
/*
* LAMESPEC: There is no signature, no nothing, just the raw data.
*/
if ((hint > 0) && (hint < tdef->rows) && (mono_metadata_decode_row_col (tdef, hint - 1, MONO_CONSTANT_PARENT) == index))
return hint;
- if (tdef->base && bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator)) {
+ if (tdef->base && mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator)) {
return loc.result + 1;
}
return 0;
loc.col_idx = MONO_EVENT_MAP_PARENT;
loc.idx = index + 1;
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
return 0;
start = mono_metadata_decode_row_col (tdef, loc.result, MONO_EVENT_MAP_EVENTLIST);
loc.col_idx = MONO_METHOD_SEMA_ASSOCIATION;
loc.idx = ((index + 1) << MONO_HAS_SEMANTICS_BITS) | MONO_HAS_SEMANTICS_EVENT; /* Method association coded index */
- if (!bsearch (&loc, msemt->base, msemt->rows, msemt->row_size, table_locator))
+ if (!mono_binary_search (&loc, msemt->base, msemt->rows, msemt->row_size, table_locator))
return 0;
start = loc.result;
loc.col_idx = MONO_PROPERTY_MAP_PARENT;
loc.idx = index + 1;
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
return 0;
start = mono_metadata_decode_row_col (tdef, loc.result, MONO_PROPERTY_MAP_PROPERTY_LIST);
loc.col_idx = MONO_METHOD_SEMA_ASSOCIATION;
loc.idx = ((index + 1) << MONO_HAS_SEMANTICS_BITS) | MONO_HAS_SEMANTICS_PROPERTY; /* Method association coded index */
- if (!bsearch (&loc, msemt->base, msemt->rows, msemt->row_size, table_locator))
+ if (!mono_binary_search (&loc, msemt->base, msemt->rows, msemt->row_size, table_locator))
return 0;
start = loc.result;
loc.col_idx = MONO_IMPLMAP_MEMBER;
loc.idx = ((method_idx + 1) << MONO_MEMBERFORWD_BITS) | MONO_MEMBERFORWD_METHODDEF;
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
return 0;
return loc.result + 1;
/* FIXME: Index translation */
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
return NULL;
return mono_metadata_blob_heap (meta, mono_metadata_decode_row_col (tdef, loc.result, MONO_FIELD_MARSHAL_NATIVE_TYPE));
loc.col_idx = MONO_METHODIMPL_CLASS;
loc.idx = mono_metadata_token_index (type_token);
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
return TRUE;
start = loc.result;
loc.col_idx = MONO_GENERICPARAM_OWNER;
loc.t = tdef;
- if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
+ if (!mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator))
return 0;
/* Find the first entry by searching backwards */
return sig->hasthis;
}
+/**
+ * mono_signature_param_is_out
+ * @sig: the method signature inspected
+ * @param_num: the 0-based index of the inspected parameter
+ *
+ * Returns: #TRUE if the parameter is an out parameter, #FALSE
+ * otherwise.
+ */
+mono_bool
+mono_signature_param_is_out (MonoMethodSignature *sig, int param_num)
+{
+ g_assert (param_num >= 0 && param_num < sig->param_count);
+ return (sig->params [param_num]->attrs & PARAM_ATTRIBUTE_OUT) != 0;
+}
+
/**
* mono_signature_explicit_this:
* @sig: the method signature inspected