static guint32 methods_size;
static guint32 signatures_size;
-/*
- * This TLS variable contains the last type load error encountered by the loader.
- */
-MonoNativeTlsKey loader_error_thread_id;
-
/*
* This TLS variable holds how many times the current thread has acquired the loader
* lock.
mono_os_mutex_init_recursive (&global_loader_data_mutex);
loader_lock_inited = TRUE;
- mono_native_tls_alloc (&loader_error_thread_id, NULL);
mono_native_tls_alloc (&loader_lock_nest_id, NULL);
mono_counters_init ();
{
dllmap_cleanup ();
- mono_native_tls_free (loader_error_thread_id);
mono_native_tls_free (loader_lock_nest_id);
mono_coop_mutex_destroy (&loader_mutex);
loader_lock_inited = FALSE;
}
-void
-mono_loader_assert_no_error (void)
-{
- MonoLoaderError *error = NULL;
-
- if (error) {
- g_print ("Unhandled loader error: %x, %s %s %s\n", error->exception_type, error->msg, error->assembly_name, error->class_name);
- g_assert_not_reached ();
- }
-}
-
-/**
- * mono_loader_clear_error:
- *
- * Disposes any loader error messages on this thread
- */
-void
-mono_loader_clear_error (void)
-{
- MonoLoaderError *ex = (MonoLoaderError*)mono_native_tls_get_value (loader_error_thread_id);
-
- if (ex) {
- g_free (ex->class_name);
- g_free (ex->assembly_name);
- g_free (ex->msg);
- g_free (ex);
-
- mono_native_tls_set_value (loader_error_thread_id, NULL);
- }
-}
-
/*
* find_cached_memberref_sig:
*
fname = mono_metadata_string_heap (image, cols [MONO_MEMBERREF_NAME]);
if (!mono_verifier_verify_memberref_field_signature (image, cols [MONO_MEMBERREF_SIGNATURE], NULL)) {
- mono_error_set_bad_image (error, image, "Bad field '%s' signature 0x%08x", class_index, token);
+ mono_error_set_bad_image (error, image, "Bad field '%u' signature 0x%08x", class_index, token);
return NULL;
}
klass = mono_class_get_and_inflate_typespec_checked (image, MONO_TOKEN_TYPE_SPEC | nindex, context, error);
break;
default:
- mono_error_set_bad_image (error, image, "Bad field field '%s' signature 0x%08x", class_index, token);
+ mono_error_set_bad_image (error, image, "Bad field field '%u' signature 0x%08x", class_index, token);
}
if (!klass)
field = mono_class_get_field_from_name_full (klass, fname, sig_type);
if (!field) {
- mono_loader_assert_no_error ();
mono_error_set_field_load (error, klass, fname, "Could not find field '%s'", fname);
}
if (mono_metadata_token_table (token) == MONO_TABLE_MEMBERREF) {
field = field_from_memberref (image, token, retklass, context, error);
- mono_loader_assert_no_error ();
} else {
type = mono_metadata_typedef_from_field (image, mono_metadata_token_index (token));
if (!type) {
*retklass = k;
field = mono_class_get_field (k, token);
if (!field) {
- mono_loader_assert_no_error ();
mono_error_set_bad_image (error, image, "Could not resolve field token 0x%08x", token);
}
}
- if (field && field->parent && !field->parent->generic_class && !field->parent->generic_container) {
+ if (field && field->parent && !mono_class_is_ginst (field->parent) && !field->parent->generic_container) {
mono_image_lock (image);
mono_conc_hashtable_insert (image->field_cache, GUINT_TO_POINTER (token), field);
mono_image_unlock (image);
}
- mono_loader_assert_no_error ();
return field;
}
/* Search directly in the metadata to avoid calling setup_methods () */
mono_error_init (error);
- /* FIXME: !from_class->generic_class condition causes test failures. */
- if (klass->type_token && !image_is_dynamic (klass->image) && !klass->methods && !klass->rank && klass == from_class && !from_class->generic_class) {
+ /* FIXME: !mono_class_is_ginst (from_class) condition causes test failures. */
+ if (klass->type_token && !image_is_dynamic (klass->image) && !klass->methods && !klass->rank && klass == from_class && !mono_class_is_ginst (from_class)) {
for (i = 0; i < klass->method.count; ++i) {
guint32 cols [MONO_METHOD_SIZE];
MonoMethod *method;
return mono_method_signature_checked (method, error);
}
- if (method->klass->generic_class)
+ if (mono_class_is_ginst (method->klass))
return mono_method_signature_checked (method, error);
if (image_is_dynamic (image)) {
type = &klass->byval_arg;
if (type->type != MONO_TYPE_ARRAY && type->type != MONO_TYPE_SZARRAY) {
- MonoClass *in_class = klass->generic_class ? klass->generic_class->container_class : klass;
+ MonoClass *in_class = mono_class_is_ginst (klass) ? mono_class_get_generic_class (klass)->container_class : klass;
method = find_method (in_class, NULL, mname, sig, klass, error);
break;
}
g_free (msig);
msig = g_string_free (s, FALSE);
- mono_loader_assert_no_error ();
mono_error_set_method_load (error, klass, mname, "Could not find method %s", msig);
g_free (msig);
}
- mono_loader_assert_no_error ();
return method;
fail:
- mono_loader_assert_no_error ();
g_assert (!mono_error_ok (error));
return NULL;
}
klass = method->klass;
- if (klass->generic_class) {
+ if (mono_class_is_ginst (klass)) {
g_assert (method->is_inflated);
method = ((MonoMethodInflated *) method)->declaring;
}
- new_context.class_inst = klass->generic_class ? klass->generic_class->context.class_inst : NULL;
+ new_context.class_inst = mono_class_is_ginst (klass) ? mono_class_get_generic_class (klass)->context.class_inst : NULL;
new_context.method_inst = inst;
method = mono_class_inflate_generic_method_full_checked (method, klass, &new_context, error);
- mono_loader_assert_no_error ();
return method;
}
*/
}
if (dll_map->func && strcmp (dll_map->func, func) == 0) {
+ *rdll = dll_map->target;
*rfunc = dll_map->target_func;
break;
}
* @dll: The name of the external library, as it would be found in the DllImport declaration. If prefixed with 'i:' the matching of the library name is done without case sensitivity
* @func: if not null, the mapping will only applied to the named function (the value of EntryPoint)
* @tdll: The name of the library to map the specified @dll if it matches.
- * @tfunc: if func is not NULL, the name of the function that replaces the invocation
+ * @tfunc: The name of the function that replaces the invocation. If NULL, it is replaced with a copy of @func.
*
* LOCKING: Acquires the loader lock.
*
entry->dll = dll? g_strdup (dll): NULL;
entry->target = tdll? g_strdup (tdll): NULL;
entry->func = func? g_strdup (func): NULL;
- entry->target_func = tfunc? g_strdup (tfunc): NULL;
+ entry->target_func = tfunc? g_strdup (tfunc): (func? g_strdup (func): NULL);
global_loader_data_lock ();
entry->next = global_dll_map;
entry->dll = dll? mono_image_strdup (assembly, dll): NULL;
entry->target = tdll? mono_image_strdup (assembly, tdll): NULL;
entry->func = func? mono_image_strdup (assembly, func): NULL;
- entry->target_func = tfunc? mono_image_strdup (assembly, tfunc): NULL;
+ entry->target_func = tfunc? mono_image_strdup (assembly, tfunc): (func? mono_image_strdup (assembly, func): NULL);
mono_image_lock (assembly);
entry->next = assembly->dll_map;
return res;
}
+void
+mono_loader_register_module (const char *name, MonoDl *module)
+{
+ if (!global_module_map)
+ global_module_map = g_hash_table_new (g_str_hash, g_str_equal);
+ g_hash_table_insert (global_module_map, g_strdup (name), module);
+}
+
static MonoDl *internal_module;
static gboolean
result = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context, error);
mono_error_assert_ok (error);
- mono_loader_assert_no_error ();
// This checks the memberref type as well
if (result && handle_class != mono_defaults.methodhandle_class) {
*/
if (*sig & 0x10) {
generic_container = mono_metadata_load_generic_params (image, token, container);
- mono_loader_assert_no_error (); /* FIXME don't swallow this error. */
}
if (generic_container) {
result->is_generic = TRUE;
if (generic_container)
mono_method_set_generic_container (result, generic_container);
- mono_loader_assert_no_error ();
return result;
}
g_assert (method != NULL);
g_assert (method->wrapper_type != MONO_WRAPPER_NONE);
- if (method->is_inflated)
- method = ((MonoMethodInflated *) method)->declaring;
data = (void **)((MonoMethodWrapper *)method)->method_data;
g_assert (data != NULL);
g_assert (id <= GPOINTER_TO_UINT (*data));
AsyncStackWalkUserData ud = { func, user_data };
mono_sigctx_to_monoctx (initial_sig_context, &ctx);
- mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (async_stack_walk_adapter, NULL, MONO_UNWIND_SIGNAL_SAFE, &ud);
+ mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (async_stack_walk_adapter, &ctx, MONO_UNWIND_SIGNAL_SAFE, &ud);
}
static gboolean
sig = mono_metadata_blob_heap (img, sig_offset = mono_metadata_decode_row_col (&img->tables [MONO_TABLE_METHOD], idx - 1, MONO_METHOD_SIGNATURE));
- g_assert (!m->klass->generic_class);
+ g_assert (!mono_class_is_ginst (m->klass));
container = mono_method_get_generic_container (m);
if (!container)
container = m->klass->generic_container;