#include <mono/metadata/tokentype.h>
#include <mono/metadata/loader.h>
#include <mono/metadata/object.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/domain-internals.h>
#include "mono/metadata/metadata-internals.h"
#include "mono/metadata/profiler-private.h"
#include "mono/metadata/security-manager.h"
#include "mono/metadata/mono-debug-debugger.h"
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/verify-internals.h>
#include <mono/utils/strenc.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-memory-model.h>
#include <mono/utils/checked-build.h>
+#include <mono/utils/mono-threads.h>
#include "cominterop.h"
static void
mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, MonoError *error);
-#define ldstr_lock() mono_mutex_lock (&ldstr_section)
-#define ldstr_unlock() mono_mutex_unlock (&ldstr_section)
+#define ldstr_lock() mono_os_mutex_lock (&ldstr_section)
+#define ldstr_unlock() mono_os_mutex_unlock (&ldstr_section)
static mono_mutex_t ldstr_section;
void
-mono_runtime_object_init (MonoObject *this)
+mono_runtime_object_init (MonoObject *this_obj)
{
MONO_REQ_GC_UNSAFE_MODE;
MonoMethod *method = NULL;
- MonoClass *klass = this->vtable->klass;
+ MonoClass *klass = this_obj->vtable->klass;
method = mono_class_get_method_from_name (klass, ".ctor", 0);
if (!method)
g_error ("Could not lookup zero argument constructor for class %s", mono_type_get_full_name (klass));
if (method->klass->valuetype)
- this = mono_object_unbox (this);
- mono_runtime_invoke (method, this, NULL, NULL);
+ this_obj = (MonoObject *)mono_object_unbox (this_obj);
+ mono_runtime_invoke (method, this_obj, NULL, NULL);
}
/* The pseudo algorithm for type initialization from the spec
typedef struct
{
- guint32 initializing_tid;
+ MonoNativeThreadId initializing_tid;
guint32 waiting_count;
gboolean done;
- mono_mutex_t initialization_section;
+ MonoCoopMutex initialization_section;
} TypeInitializationLock;
/* for locking access to type_initialization_hash and blocked_thread_hash */
-static mono_mutex_t type_initialization_section;
+static MonoCoopMutex type_initialization_section;
static inline void
mono_type_initialization_lock (void)
{
/* The critical sections protected by this lock in mono_runtime_class_init_full () can block */
- MONO_PREPARE_BLOCKING;
- mono_mutex_lock (&type_initialization_section);
- MONO_FINISH_BLOCKING;
+ mono_coop_mutex_lock (&type_initialization_section);
}
static inline void
mono_type_initialization_unlock (void)
{
- mono_mutex_unlock (&type_initialization_section);
+ mono_coop_mutex_unlock (&type_initialization_section);
}
static void
{
MONO_REQ_GC_NEUTRAL_MODE;
- MONO_TRY_BLOCKING;
- mono_mutex_lock (&lock->initialization_section);
- MONO_FINISH_TRY_BLOCKING;
+ mono_coop_mutex_lock (&lock->initialization_section);
}
static void
mono_type_init_unlock (TypeInitializationLock *lock)
{
- mono_mutex_unlock (&lock->initialization_section);
+ mono_coop_mutex_unlock (&lock->initialization_section);
}
/* from vtable to lock */
void
mono_type_initialization_init (void)
{
- mono_mutex_init_recursive (&type_initialization_section);
+ mono_coop_mutex_init_recursive (&type_initialization_section);
type_initialization_hash = g_hash_table_new (NULL, NULL);
blocked_thread_hash = g_hash_table_new (NULL, NULL);
- mono_mutex_init_recursive (&ldstr_section);
+ mono_os_mutex_init_recursive (&ldstr_section);
}
void
/* This is causing race conditions with
* mono_release_type_locks
*/
- mono_mutex_destroy (&type_initialization_section);
+ mono_coop_mutex_destroy (&type_initialization_section);
g_hash_table_destroy (type_initialization_hash);
type_initialization_hash = NULL;
#endif
- mono_mutex_destroy (&ldstr_section);
+ mono_os_mutex_destroy (&ldstr_section);
g_hash_table_destroy (blocked_thread_hash);
blocked_thread_hash = NULL;
ex = NULL;
mono_domain_lock (domain);
if (domain->type_init_exception_hash)
- ex = mono_g_hash_table_lookup (domain->type_init_exception_hash, klass);
+ ex = (MonoException *)mono_g_hash_table_lookup (domain->type_init_exception_hash, klass);
mono_domain_unlock (domain);
if (!ex) {
gchar *full_name;
MonoDomain *domain = vtable->domain;
TypeInitializationLock *lock;
- guint32 tid;
+ MonoNativeThreadId tid;
int do_initialization = 0;
MonoDomain *last_domain = NULL;
return NULL;
}
- tid = GetCurrentThreadId ();
+ tid = mono_native_thread_id_get ();
mono_type_initialization_lock ();
/* double check... */
mono_raise_exception (get_type_init_exception_for_vtable (vtable));
return get_type_init_exception_for_vtable (vtable);
}
- lock = g_hash_table_lookup (type_initialization_hash, vtable);
+ lock = (TypeInitializationLock *)g_hash_table_lookup (type_initialization_hash, vtable);
if (lock == NULL) {
/* This thread will get to do the initialization */
if (mono_domain_get () != domain) {
return mono_get_exception_appdomain_unloaded ();
}
}
- lock = g_malloc (sizeof(TypeInitializationLock));
- mono_mutex_init_recursive (&lock->initialization_section);
+ lock = (TypeInitializationLock *)g_malloc (sizeof (TypeInitializationLock));
+ mono_coop_mutex_init_recursive (&lock->initialization_section);
lock->initializing_tid = tid;
lock->waiting_count = 1;
lock->done = FALSE;
gpointer blocked;
TypeInitializationLock *pending_lock;
- if (lock->initializing_tid == tid || lock->done) {
+ if (mono_native_thread_id_equals (lock->initializing_tid, tid) || lock->done) {
mono_type_initialization_unlock ();
return NULL;
}
/* see if the thread doing the initialization is already blocked on this thread */
- blocked = GUINT_TO_POINTER (lock->initializing_tid);
+ blocked = GUINT_TO_POINTER (MONO_NATIVE_THREAD_ID_TO_UINT (lock->initializing_tid));
while ((pending_lock = (TypeInitializationLock*) g_hash_table_lookup (blocked_thread_hash, blocked))) {
- if (pending_lock->initializing_tid == tid) {
+ if (mono_native_thread_id_equals (pending_lock->initializing_tid, tid)) {
if (!pending_lock->done) {
mono_type_initialization_unlock ();
return NULL;
break;
}
}
- blocked = GUINT_TO_POINTER (pending_lock->initializing_tid);
+ blocked = GUINT_TO_POINTER (MONO_NATIVE_THREAD_ID_TO_UINT (pending_lock->initializing_tid));
}
++lock->waiting_count;
/* record the fact that we are waiting on the initializing thread */
}
mono_type_initialization_lock ();
- if (lock->initializing_tid != tid)
+ if (!mono_native_thread_id_equals (lock->initializing_tid, tid))
g_hash_table_remove (blocked_thread_hash, GUINT_TO_POINTER (tid));
--lock->waiting_count;
if (lock->waiting_count == 0) {
- mono_mutex_destroy (&lock->initialization_section);
+ mono_coop_mutex_destroy (&lock->initialization_section);
g_hash_table_remove (type_initialization_hash, vtable);
g_free (lock);
}
MonoVTable *vtable = (MonoVTable*)key;
TypeInitializationLock *lock = (TypeInitializationLock*) value;
- if (lock->initializing_tid == GPOINTER_TO_UINT (user) && !lock->done) {
+ if (mono_native_thread_id_equals (lock->initializing_tid, MONO_UINT_TO_NATIVE_THREAD_ID (GPOINTER_TO_UINT (user))) && !lock->done) {
lock->done = TRUE;
/*
* Have to set this since it cannot be set by the normal code in
mono_type_init_unlock (lock);
--lock->waiting_count;
if (lock->waiting_count == 0) {
- mono_mutex_destroy (&lock->initialization_section);
+ mono_coop_mutex_destroy (&lock->initialization_section);
g_free (lock);
return TRUE;
}
MONO_REQ_GC_UNSAFE_MODE;
mono_type_initialization_lock ();
- g_hash_table_foreach_remove (type_initialization_hash, release_type_locks, (gpointer)(gsize)(thread->tid));
+ g_hash_table_foreach_remove (type_initialization_hash, release_type_locks, GUINT_TO_POINTER (thread->tid));
mono_type_initialization_unlock ();
}
#define BITMAP_EL_SIZE (sizeof (gsize) * 8)
static gsize*
-compute_class_bitmap (MonoClass *class, gsize *bitmap, int size, int offset, int *max_set, gboolean static_fields)
+compute_class_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int *max_set, gboolean static_fields)
{
MONO_REQ_GC_NEUTRAL_MODE;
int max_size;
if (static_fields)
- max_size = mono_class_data_size (class) / sizeof (gpointer);
+ max_size = mono_class_data_size (klass) / sizeof (gpointer);
else
- max_size = class->instance_size / sizeof (gpointer);
+ max_size = klass->instance_size / sizeof (gpointer);
if (max_size > size) {
g_assert (offset <= 0);
- bitmap = g_malloc0 ((max_size + BITMAP_EL_SIZE - 1) / BITMAP_EL_SIZE * sizeof (gsize));
+ bitmap = (gsize *)g_malloc0 ((max_size + BITMAP_EL_SIZE - 1) / BITMAP_EL_SIZE * sizeof (gsize));
size = max_size;
}
#ifdef HAVE_SGEN_GC
/*An Ephemeron cannot be marked by sgen*/
- if (!static_fields && class->image == mono_defaults.corlib && !strcmp ("Ephemeron", class->name)) {
+ if (!static_fields && klass->image == mono_defaults.corlib && !strcmp ("Ephemeron", klass->name)) {
*max_set = 0;
memset (bitmap, 0, size / 8);
return bitmap;
}
#endif
- for (p = class; p != NULL; p = p->parent) {
+ for (p = klass; p != NULL; p = p->parent) {
gpointer iter = NULL;
while ((field = mono_class_get_fields (p, &iter))) {
MonoType *type;
#ifdef HAVE_SGEN_GC
break;
#else
- if (class->image != mono_defaults.corlib)
+ if (klass->image != mono_defaults.corlib)
break;
#endif
case MONO_TYPE_STRING:
* Mono internal function to compute a bitmap of reference fields in a class.
*/
gsize*
-mono_class_compute_bitmap (MonoClass *class, gsize *bitmap, int size, int offset, int *max_set, gboolean static_fields)
+mono_class_compute_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int *max_set, gboolean static_fields)
{
MONO_REQ_GC_NEUTRAL_MODE;
- return compute_class_bitmap (class, bitmap, size, offset, max_set, static_fields);
+ return compute_class_bitmap (klass, bitmap, size, offset, max_set, static_fields);
}
#if 0
* and ignores static fields
*/
static gsize*
-compute_class_non_ref_bitmap (MonoClass *class, gsize *bitmap, int size, int offset)
+compute_class_non_ref_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset)
{
MonoClassField *field;
MonoClass *p;
}
void
-mono_class_compute_gc_descriptor (MonoClass *class)
+mono_class_compute_gc_descriptor (MonoClass *klass)
{
MONO_REQ_GC_NEUTRAL_MODE;
mono_loader_unlock ();
}
- if (!class->inited)
- mono_class_init (class);
+ if (!klass->inited)
+ mono_class_init (klass);
- if (class->gc_descr_inited)
+ if (klass->gc_descr_inited)
return;
- class->gc_descr_inited = TRUE;
- class->gc_descr = MONO_GC_DESCRIPTOR_NULL;
+ klass->gc_descr_inited = TRUE;
+ klass->gc_descr = MONO_GC_DESCRIPTOR_NULL;
bitmap = default_bitmap;
- if (class == mono_defaults.string_class) {
- class->gc_descr = mono_gc_make_descr_for_string (bitmap, 2);
- } else if (class->rank) {
- mono_class_compute_gc_descriptor (class->element_class);
- if (MONO_TYPE_IS_REFERENCE (&class->element_class->byval_arg)) {
+ if (klass == mono_defaults.string_class) {
+ klass->gc_descr = mono_gc_make_descr_for_string (bitmap, 2);
+ } else if (klass->rank) {
+ mono_class_compute_gc_descriptor (klass->element_class);
+ if (MONO_TYPE_IS_REFERENCE (&klass->element_class->byval_arg)) {
gsize abm = 1;
- class->gc_descr = mono_gc_make_descr_for_array (class->byval_arg.type == MONO_TYPE_SZARRAY, &abm, 1, sizeof (gpointer));
+ klass->gc_descr = mono_gc_make_descr_for_array (klass->byval_arg.type == MONO_TYPE_SZARRAY, &abm, 1, sizeof (gpointer));
/*printf ("new array descriptor: 0x%x for %s.%s\n", class->gc_descr,
class->name_space, class->name);*/
} else {
/* remove the object header */
- bitmap = compute_class_bitmap (class->element_class, default_bitmap, sizeof (default_bitmap) * 8, - (int)(sizeof (MonoObject) / sizeof (gpointer)), &max_set, FALSE);
- class->gc_descr = mono_gc_make_descr_for_array (class->byval_arg.type == MONO_TYPE_SZARRAY, bitmap, mono_array_element_size (class) / sizeof (gpointer), mono_array_element_size (class));
+ bitmap = compute_class_bitmap (klass->element_class, default_bitmap, sizeof (default_bitmap) * 8, - (int)(sizeof (MonoObject) / sizeof (gpointer)), &max_set, FALSE);
+ klass->gc_descr = mono_gc_make_descr_for_array (klass->byval_arg.type == MONO_TYPE_SZARRAY, bitmap, mono_array_element_size (klass) / sizeof (gpointer), mono_array_element_size (klass));
/*printf ("new vt array descriptor: 0x%x for %s.%s\n", class->gc_descr,
class->name_space, class->name);*/
if (bitmap != default_bitmap)
/*static int count = 0;
if (count++ > 58)
return;*/
- bitmap = compute_class_bitmap (class, default_bitmap, sizeof (default_bitmap) * 8, 0, &max_set, FALSE);
- class->gc_descr = mono_gc_make_descr_for_object (bitmap, max_set + 1, class->instance_size);
+ bitmap = compute_class_bitmap (klass, default_bitmap, sizeof (default_bitmap) * 8, 0, &max_set, FALSE);
+ klass->gc_descr = mono_gc_make_descr_for_object (bitmap, max_set + 1, klass->instance_size);
/*
if (class->gc_descr == MONO_GC_DESCRIPTOR_NULL)
g_print ("disabling typed alloc (%d) for %s.%s\n", max_set, class->name_space, class->name);
sig = mono_method_signature (method);
hashes_count = sig->param_count + 4;
- hashes_start = malloc (hashes_count * sizeof (guint32));
+ hashes_start = (guint32 *)malloc (hashes_count * sizeof (guint32));
hashes = hashes_start;
if (! MONO_CLASS_IS_INTERFACE (method->klass)) {
return;
}
- entry = g_malloc0 (sizeof (MonoImtBuilderEntry));
+ entry = (MonoImtBuilderEntry *)g_malloc0 (sizeof (MonoImtBuilderEntry));
entry->key = method;
entry->value.vtable_slot = vtable_slot;
entry->next = imt_builder [imt_slot];
MONO_REQ_GC_NEUTRAL_MODE;
int number_of_entries = entries->children + 1;
- MonoImtBuilderEntry **sorted_array = malloc (sizeof (MonoImtBuilderEntry*) * number_of_entries);
+ MonoImtBuilderEntry **sorted_array = (MonoImtBuilderEntry **)malloc (sizeof (MonoImtBuilderEntry*) * number_of_entries);
GPtrArray *result = g_ptr_array_new ();
MonoImtBuilderEntry *current_entry;
int i;
int i;
GSList *list_item;
guint32 imt_collisions_bitmap = 0;
- MonoImtBuilderEntry **imt_builder = calloc (MONO_IMT_SIZE, sizeof (MonoImtBuilderEntry*));
+ MonoImtBuilderEntry **imt_builder = (MonoImtBuilderEntry **)calloc (MONO_IMT_SIZE, sizeof (MonoImtBuilderEntry*));
int method_count = 0;
gboolean record_method_count_for_max_collisions = FALSE;
gboolean has_generic_virtual = FALSE, has_variant_iface = FALSE;
int interface_offset = klass->vtable_size;
for (list_item = extra_interfaces; list_item != NULL; list_item=list_item->next) {
- MonoClass* iface = list_item->data;
+ MonoClass* iface = (MonoClass *)list_item->data;
int method_slot_in_interface;
for (method_slot_in_interface = 0; method_slot_in_interface < iface->method.count; method_slot_in_interface++) {
MonoMethod *method = mono_class_get_method_by_index (iface, method_slot_in_interface);
if (domain->thunk_free_lists)
return;
- domain->thunk_free_lists = mono_domain_alloc0 (domain, sizeof (gpointer) * NUM_FREE_LISTS);
+ domain->thunk_free_lists = (MonoThunkFreeList **)mono_domain_alloc0 (domain, sizeof (gpointer) * NUM_FREE_LISTS);
}
static int
}
generic_virtual_thunks_size += size;
- p = mono_domain_code_reserve (domain, size);
+ p = (guint32 *)mono_domain_code_reserve (domain, size);
*p = size;
mono_domain_lock (domain);
{
MONO_REQ_GC_NEUTRAL_MODE;
- guint32 *p = code;
+ guint32 *p = (guint32 *)code;
MonoThunkFreeList *l = (MonoThunkFreeList*)(p - 1);
gboolean found = FALSE;
if (!domain->generic_virtual_cases)
domain->generic_virtual_cases = g_hash_table_new (mono_aligned_addr_hash, NULL);
- list = g_hash_table_lookup (domain->generic_virtual_cases, vtable_slot);
+ list = (GenericVirtualCase *)g_hash_table_lookup (domain->generic_virtual_cases, vtable_slot);
entries = NULL;
for (; list; list = list->next) {
domain->generic_virtual_cases = g_hash_table_new (mono_aligned_addr_hash, NULL);
/* Check whether the case was already added */
- list = g_hash_table_lookup (domain->generic_virtual_cases, vtable_slot);
+ list = (GenericVirtualCase *)g_hash_table_lookup (domain->generic_virtual_cases, vtable_slot);
gvc = list;
while (gvc) {
if (gvc->method == method)
/* If not found, make a new one */
if (!gvc) {
- gvc = mono_domain_alloc (domain, sizeof (GenericVirtualCase));
+ gvc = (GenericVirtualCase *)mono_domain_alloc (domain, sizeof (GenericVirtualCase));
gvc->method = method;
gvc->code = code;
gvc->count = 0;
- gvc->next = g_hash_table_lookup (domain->generic_virtual_cases, vtable_slot);
+ gvc->next = (GenericVirtualCase *)g_hash_table_lookup (domain->generic_virtual_cases, vtable_slot);
g_hash_table_insert (domain->generic_virtual_cases, vtable_slot, gvc);
}
if (++gvc->count == THUNK_THRESHOLD) {
- gpointer *old_thunk = *vtable_slot;
+ gpointer *old_thunk = (void **)*vtable_slot;
gpointer vtable_trampoline = NULL;
gpointer imt_trampoline = NULL;
mono_domain_unlock (domain);
}
-static MonoVTable *mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean raise_on_error);
+static MonoVTable *mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, gboolean raise_on_error);
/**
* mono_class_vtable:
* On failure, NULL is returned, and class->exception_type is set.
*/
MonoVTable *
-mono_class_vtable (MonoDomain *domain, MonoClass *class)
+mono_class_vtable (MonoDomain *domain, MonoClass *klass)
{
- return mono_class_vtable_full (domain, class, FALSE);
+ return mono_class_vtable_full (domain, klass, FALSE);
}
/**
* they contain the domain specific static class data.
*/
MonoVTable *
-mono_class_vtable_full (MonoDomain *domain, MonoClass *class, gboolean raise_on_error)
+mono_class_vtable_full (MonoDomain *domain, MonoClass *klass, gboolean raise_on_error)
{
MONO_REQ_GC_UNSAFE_MODE;
MonoClassRuntimeInfo *runtime_info;
- g_assert (class);
+ g_assert (klass);
- if (class->exception_type) {
+ if (klass->exception_type) {
if (raise_on_error)
- mono_raise_exception (mono_class_get_exception_for_failure (class));
+ mono_raise_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
/* this check can be inlined in jitted code, too */
- runtime_info = class->runtime_info;
+ runtime_info = klass->runtime_info;
if (runtime_info && runtime_info->max_domain >= domain->domain_id && runtime_info->domain_vtables [domain->domain_id])
return runtime_info->domain_vtables [domain->domain_id];
- return mono_class_create_runtime_vtable (domain, class, raise_on_error);
+ return mono_class_create_runtime_vtable (domain, klass, raise_on_error);
}
/**
* it was already created.
*/
MonoVTable *
-mono_class_try_get_vtable (MonoDomain *domain, MonoClass *class)
+mono_class_try_get_vtable (MonoDomain *domain, MonoClass *klass)
{
MONO_REQ_GC_NEUTRAL_MODE;
MonoClassRuntimeInfo *runtime_info;
- g_assert (class);
+ g_assert (klass);
- runtime_info = class->runtime_info;
+ runtime_info = klass->runtime_info;
if (runtime_info && runtime_info->max_domain >= domain->domain_id && runtime_info->domain_vtables [domain->domain_id])
return runtime_info->domain_vtables [domain->domain_id];
return NULL;
}
static MonoVTable *
-mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean raise_on_error)
+mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, gboolean raise_on_error)
{
MONO_REQ_GC_UNSAFE_MODE;
mono_loader_lock (); /*FIXME mono_class_init acquires it*/
mono_domain_lock (domain);
- runtime_info = class->runtime_info;
+ runtime_info = klass->runtime_info;
if (runtime_info && runtime_info->max_domain >= domain->domain_id && runtime_info->domain_vtables [domain->domain_id]) {
mono_domain_unlock (domain);
mono_loader_unlock ();
return runtime_info->domain_vtables [domain->domain_id];
}
- if (!class->inited || class->exception_type) {
- if (!mono_class_init (class) || class->exception_type) {
+ if (!klass->inited || klass->exception_type) {
+ if (!mono_class_init (klass) || klass->exception_type) {
mono_domain_unlock (domain);
mono_loader_unlock ();
if (raise_on_error)
- mono_raise_exception (mono_class_get_exception_for_failure (class));
+ mono_raise_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
}
/* Array types require that their element type be valid*/
- if (class->byval_arg.type == MONO_TYPE_ARRAY || class->byval_arg.type == MONO_TYPE_SZARRAY) {
- MonoClass *element_class = class->element_class;
+ if (klass->byval_arg.type == MONO_TYPE_ARRAY || klass->byval_arg.type == MONO_TYPE_SZARRAY) {
+ MonoClass *element_class = klass->element_class;
if (!element_class->inited)
mono_class_init (element_class);
if (element_class->exception_type != MONO_EXCEPTION_NONE) {
/*Can happen if element_class only got bad after mono_class_setup_vtable*/
- if (class->exception_type == MONO_EXCEPTION_NONE)
- mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
+ if (klass->exception_type == MONO_EXCEPTION_NONE)
+ mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
mono_domain_unlock (domain);
mono_loader_unlock ();
if (raise_on_error)
- mono_raise_exception (mono_class_get_exception_for_failure (class));
+ mono_raise_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
}
/*
- * For some classes, mono_class_init () already computed class->vtable_size, and
+ * For some classes, mono_class_init () already computed klass->vtable_size, and
* that is all that is needed because of the vtable trampolines.
*/
- if (!class->vtable_size)
- mono_class_setup_vtable (class);
+ if (!klass->vtable_size)
+ mono_class_setup_vtable (klass);
- if (class->generic_class && !class->vtable)
- mono_class_check_vtable_constraints (class, NULL);
+ if (klass->generic_class && !klass->vtable)
+ mono_class_check_vtable_constraints (klass, NULL);
/* Initialize klass->has_finalize */
- mono_class_has_finalizer (class);
+ mono_class_has_finalizer (klass);
- if (class->exception_type) {
+ if (klass->exception_type) {
mono_domain_unlock (domain);
mono_loader_unlock ();
if (raise_on_error)
- mono_raise_exception (mono_class_get_exception_for_failure (class));
+ mono_raise_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
- vtable_slots = class->vtable_size;
+ vtable_slots = klass->vtable_size;
/* we add an additional vtable slot to store the pointer to static field data only when needed */
- class_size = mono_class_data_size (class);
+ class_size = mono_class_data_size (klass);
if (class_size)
vtable_slots++;
- if (class->interface_offsets_count) {
+ if (klass->interface_offsets_count) {
imt_table_bytes = sizeof (gpointer) * (MONO_IMT_SIZE);
mono_stats.imt_number_of_tables++;
mono_stats.imt_tables_size += imt_table_bytes;
vt = (MonoVTable*) ((char*)interface_offsets + imt_table_bytes);
g_assert (!((gsize)vt & 7));
- vt->klass = class;
- vt->rank = class->rank;
+ vt->klass = klass;
+ vt->rank = klass->rank;
vt->domain = domain;
- mono_class_compute_gc_descriptor (class);
+ mono_class_compute_gc_descriptor (klass);
/*
* We can't use typed allocation in the non-root domains, since the
* collector needs the GC descriptor stored in the vtable even after
vt->gc_descr = MONO_GC_DESCRIPTOR_NULL;
else
#endif
- vt->gc_descr = class->gc_descr;
+ vt->gc_descr = klass->gc_descr;
- gc_bits = mono_gc_get_vtable_bits (class);
+ gc_bits = mono_gc_get_vtable_bits (klass);
g_assert (!(gc_bits & ~((1 << MONO_VTABLE_AVAILABLE_GC_BITS) - 1)));
vt->gc_bits = gc_bits;
if (class_size) {
/* we store the static field pointer at the end of the vtable: vt->vtable [class->vtable_size] */
- if (class->has_static_refs) {
+ if (klass->has_static_refs) {
MonoGCDescriptor statics_gc_descr;
int max_set = 0;
gsize default_bitmap [4] = {0};
gsize *bitmap;
- bitmap = compute_class_bitmap (class, default_bitmap, sizeof (default_bitmap) * 8, 0, &max_set, TRUE);
- /*g_print ("bitmap 0x%x for %s.%s (size: %d)\n", bitmap [0], class->name_space, class->name, class_size);*/
+ bitmap = compute_class_bitmap (klass, default_bitmap, sizeof (default_bitmap) * 8, 0, &max_set, TRUE);
+ /*g_print ("bitmap 0x%x for %s.%s (size: %d)\n", bitmap [0], klass->name_space, klass->name, class_size);*/
statics_gc_descr = mono_gc_make_descr_from_bitmap (bitmap, max_set + 1);
- vt->vtable [class->vtable_size] = mono_gc_alloc_fixed (class_size, statics_gc_descr, MONO_ROOT_SOURCE_STATIC, "managed static variables");
- mono_domain_add_class_static_data (domain, class, vt->vtable [class->vtable_size], NULL);
+ vt->vtable [klass->vtable_size] = mono_gc_alloc_fixed (class_size, statics_gc_descr, MONO_ROOT_SOURCE_STATIC, "managed static variables");
+ mono_domain_add_class_static_data (domain, klass, vt->vtable [klass->vtable_size], NULL);
if (bitmap != default_bitmap)
g_free (bitmap);
} else {
- vt->vtable [class->vtable_size] = mono_domain_alloc0 (domain, class_size);
+ vt->vtable [klass->vtable_size] = mono_domain_alloc0 (domain, class_size);
}
vt->has_static_fields = TRUE;
mono_stats.class_static_data_size += class_size;
}
iter = NULL;
- while ((field = mono_class_get_fields (class, &iter))) {
+ while ((field = mono_class_get_fields (klass, &iter))) {
if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
continue;
if (mono_field_is_deleted (field))
continue;
if (!(field->type->attrs & FIELD_ATTRIBUTE_LITERAL)) {
- gint32 special_static = class->no_special_static_fields ? SPECIAL_STATIC_NONE : field_is_special_static (class, field);
+ gint32 special_static = klass->no_special_static_fields ? SPECIAL_STATIC_NONE : field_is_special_static (klass, field);
if (special_static != SPECIAL_STATIC_NONE) {
guint32 size, offset;
gint32 align;
}
}
- vt->max_interface_id = class->max_interface_id;
- vt->interface_bitmap = class->interface_bitmap;
+ vt->max_interface_id = klass->max_interface_id;
+ vt->interface_bitmap = klass->interface_bitmap;
//printf ("Initializing VT for class %s (interface_offsets_count = %d)\n",
- // class->name, class->interface_offsets_count);
+ // class->name, klass->interface_offsets_count);
/* Initialize vtable */
if (callbacks.get_vtable_trampoline) {
// This also covers the AOT case
- for (i = 0; i < class->vtable_size; ++i) {
+ for (i = 0; i < klass->vtable_size; ++i) {
vt->vtable [i] = callbacks.get_vtable_trampoline (i);
}
} else {
- mono_class_setup_vtable (class);
+ mono_class_setup_vtable (klass);
- for (i = 0; i < class->vtable_size; ++i) {
+ for (i = 0; i < klass->vtable_size; ++i) {
MonoMethod *cm;
- if ((cm = class->vtable [i]))
+ if ((cm = klass->vtable [i]))
vt->vtable [i] = arch_create_jit_trampoline (cm);
}
}
* re-acquire them and check if another thread has created the vtable in the meantime.
*/
/* Special case System.MonoType to avoid infinite recursion */
- if (class != mono_defaults.monotype_class) {
+ if (klass != mono_defaults.monotype_class) {
/*FIXME check for OOM*/
- vt->type = mono_type_get_object (domain, &class->byval_arg);
- if (mono_object_get_class (vt->type) != mono_defaults.monotype_class)
+ vt->type = mono_type_get_object (domain, &klass->byval_arg);
+ if (mono_object_get_class ((MonoObject *)vt->type) != mono_defaults.monotype_class)
/* This is unregistered in
unregister_vtable_reflection_type() in
domain.c. */
MONO_GC_REGISTER_ROOT_IF_MOVING(vt->type, MONO_ROOT_SOURCE_REFLECTION, "vtable reflection type");
}
- mono_vtable_set_is_remote (vt, mono_class_is_contextbound (class));
+ mono_vtable_set_is_remote (vt, mono_class_is_contextbound (klass));
/* class_vtable_array keeps an array of created vtables
*/
g_ptr_array_add (domain->class_vtable_array, vt);
- /* class->runtime_info is protected by the loader lock, both when
+ /* klass->runtime_info is protected by the loader lock, both when
* it it enlarged and when it is stored info.
*/
/*
- * Store the vtable in class->runtime_info.
- * class->runtime_info is accessed without locking, so this do this last after the vtable has been constructed.
+ * Store the vtable in klass->runtime_info.
+ * klass->runtime_info is accessed without locking, so this do this last after the vtable has been constructed.
*/
mono_memory_barrier ();
- old_info = class->runtime_info;
+ old_info = klass->runtime_info;
if (old_info && old_info->max_domain >= domain->domain_id) {
/* someone already created a large enough runtime info */
old_info->domain_vtables [domain->domain_id] = vt;
/* this is a bounded memory retention issue: may want to
* handle it differently when we'll have a rcu-like system.
*/
- runtime_info = mono_image_alloc0 (class->image, MONO_SIZEOF_CLASS_RUNTIME_INFO + new_size * sizeof (gpointer));
+ runtime_info = (MonoClassRuntimeInfo *)mono_image_alloc0 (klass->image, MONO_SIZEOF_CLASS_RUNTIME_INFO + new_size * sizeof (gpointer));
runtime_info->max_domain = new_size - 1;
/* copy the stuff from the older info */
if (old_info) {
runtime_info->domain_vtables [domain->domain_id] = vt;
/* keep this last*/
mono_memory_barrier ();
- class->runtime_info = runtime_info;
+ klass->runtime_info = runtime_info;
}
- if (class == mono_defaults.monotype_class) {
+ if (klass == mono_defaults.monotype_class) {
/*FIXME check for OOM*/
- vt->type = mono_type_get_object (domain, &class->byval_arg);
- if (mono_object_get_class (vt->type) != mono_defaults.monotype_class)
+ vt->type = mono_type_get_object (domain, &klass->byval_arg);
+ if (mono_object_get_class ((MonoObject *)vt->type) != mono_defaults.monotype_class)
/* This is unregistered in
unregister_vtable_reflection_type() in
domain.c. */
/* make sure the parent is initialized */
/*FIXME shouldn't this fail the current type?*/
- if (class->parent)
- mono_class_vtable_full (domain, class->parent, raise_on_error);
+ if (klass->parent)
+ mono_class_vtable_full (domain, klass->parent, raise_on_error);
return vt;
}
int i, j, vtsize, max_interface_id, extra_interface_vtsize = 0;
MonoClass *k;
GSList *extra_interfaces = NULL;
- MonoClass *class = remote_class->proxy_class;
+ MonoClass *klass = remote_class->proxy_class;
gpointer *interface_offsets;
uint8_t *bitmap;
int bsize;
int bcsize;
#endif
- vt = mono_class_vtable (domain, class);
+ vt = mono_class_vtable (domain, klass);
g_assert (vt); /*FIXME property handle failure*/
max_interface_id = vt->max_interface_id;
int method_count;
/*FIXME test for interfaces with variant generic arguments*/
- if (MONO_CLASS_IMPLEMENTS_INTERFACE (class, iclass->interface_id))
+ if (MONO_CLASS_IMPLEMENTS_INTERFACE (klass, iclass->interface_id))
continue; /* interface implemented by the class */
if (g_slist_find (extra_interfaces, iclass))
continue;
g_assert (mono_error_ok (&error)); /*FIXME do proper error handling*/
if (ifaces) {
for (i = 0; i < ifaces->len; ++i) {
- MonoClass *ic = g_ptr_array_index (ifaces, i);
+ MonoClass *ic = (MonoClass *)g_ptr_array_index (ifaces, i);
/*FIXME test for interfaces with variant generic arguments*/
- if (MONO_CLASS_IMPLEMENTS_INTERFACE (class, ic->interface_id))
+ if (MONO_CLASS_IMPLEMENTS_INTERFACE (klass, ic->interface_id))
continue; /* interface implemented by the class */
if (g_slist_find (extra_interfaces, ic))
continue;
mono_stats.imt_number_of_tables++;
mono_stats.imt_tables_size += imt_table_bytes;
- vtsize = imt_table_bytes + MONO_SIZEOF_VTABLE + class->vtable_size * sizeof (gpointer);
+ vtsize = imt_table_bytes + MONO_SIZEOF_VTABLE + klass->vtable_size * sizeof (gpointer);
mono_stats.class_vtable_size += vtsize + extra_interface_vtsize;
pvt = (MonoVTable*) ((char*)interface_offsets + imt_table_bytes);
g_assert (!((gsize)pvt & 7));
- memcpy (pvt, vt, MONO_SIZEOF_VTABLE + class->vtable_size * sizeof (gpointer));
+ memcpy (pvt, vt, MONO_SIZEOF_VTABLE + klass->vtable_size * sizeof (gpointer));
pvt->klass = mono_defaults.transparent_proxy_class;
/* we need to keep the GC descriptor for a transparent proxy or we confuse the precise GC */
pvt->gc_descr = mono_defaults.transparent_proxy_class->gc_descr;
/* initialize vtable */
- mono_class_setup_vtable (class);
- for (i = 0; i < class->vtable_size; ++i) {
+ mono_class_setup_vtable (klass);
+ for (i = 0; i < klass->vtable_size; ++i) {
MonoMethod *cm;
- if ((cm = class->vtable [i]))
+ if ((cm = klass->vtable [i]))
pvt->vtable [i] = arch_create_remoting_trampoline (domain, cm, target_type);
else
pvt->vtable [i] = NULL;
}
- if (class->flags & TYPE_ATTRIBUTE_ABSTRACT) {
+ if (klass->flags & TYPE_ATTRIBUTE_ABSTRACT) {
/* create trampolines for abstract methods */
- for (k = class; k; k = k->parent) {
+ for (k = klass; k; k = k->parent) {
MonoMethod* m;
gpointer iter = NULL;
while ((m = mono_class_get_methods (k, &iter)))
pvt->max_interface_id = max_interface_id;
bsize = sizeof (guint8) * (max_interface_id/8 + 1 );
#ifdef COMPRESSED_INTERFACE_BITMAP
- bitmap = g_malloc0 (bsize);
+ bitmap = (uint8_t *)g_malloc0 (bsize);
#else
- bitmap = mono_domain_alloc0 (domain, bsize);
+ bitmap = (uint8_t *)mono_domain_alloc0 (domain, bsize);
#endif
- for (i = 0; i < class->interface_offsets_count; ++i) {
- int interface_id = class->interfaces_packed [i]->interface_id;
+ for (i = 0; i < klass->interface_offsets_count; ++i) {
+ int interface_id = klass->interfaces_packed [i]->interface_id;
bitmap [interface_id >> 3] |= (1 << (interface_id & 7));
}
if (extra_interfaces) {
- int slot = class->vtable_size;
+ int slot = klass->vtable_size;
MonoClass* interf;
gpointer iter;
MonoMethod* cm;
/* Create trampolines for the methods of the interfaces */
for (list_item = extra_interfaces; list_item != NULL; list_item=list_item->next) {
- interf = list_item->data;
+ interf = (MonoClass *)list_item->data;
bitmap [interf->interface_id >> 3] |= (1 << (interf->interface_id & 7));
}
/* Now that the vtable is full, we can actually fill up the IMT */
- build_imt (class, pvt, domain, interface_offsets, extra_interfaces);
+ build_imt (klass, pvt, domain, interface_offsets, extra_interfaces);
if (extra_interfaces) {
g_slist_free (extra_interfaces);
}
if (remote_class == NULL) {
if (extra_class->flags & TYPE_ATTRIBUTE_INTERFACE) {
- key = g_malloc (sizeof(gpointer) * 3);
+ key = (void **)g_malloc (sizeof(gpointer) * 3);
key [0] = GINT_TO_POINTER (2);
key [1] = mono_defaults.marshalbyrefobject_class;
key [2] = extra_class;
} else {
- key = g_malloc (sizeof(gpointer) * 2);
+ key = (void **)g_malloc (sizeof(gpointer) * 2);
key [0] = GINT_TO_POINTER (1);
key [1] = extra_class;
}
} else {
if (extra_class != NULL && (extra_class->flags & TYPE_ATTRIBUTE_INTERFACE)) {
- key = g_malloc (sizeof(gpointer) * (remote_class->interface_count + 3));
+ key = (void **)g_malloc (sizeof(gpointer) * (remote_class->interface_count + 3));
key [0] = GINT_TO_POINTER (remote_class->interface_count + 2);
key [1] = remote_class->proxy_class;
key [j] = extra_class;
} else {
// Replace the old class. The interface list is the same
- key = g_malloc (sizeof(gpointer) * (remote_class->interface_count + 2));
+ key = (void **)g_malloc (sizeof(gpointer) * (remote_class->interface_count + 2));
key [0] = GINT_TO_POINTER (remote_class->interface_count + 1);
key [1] = extra_class != NULL ? extra_class : remote_class->proxy_class;
for (i = 0; i < remote_class->interface_count; i++)
MONO_REQ_GC_NEUTRAL_MODE
int key_size = (GPOINTER_TO_UINT (key [0]) + 1) * sizeof (gpointer);
- gpointer *mp_key = mono_domain_alloc (domain, key_size);
+ gpointer *mp_key = (gpointer *)mono_domain_alloc (domain, key_size);
memcpy (mp_key, key, key_size);
key = create_remote_class_key (NULL, proxy_class);
mono_domain_lock (domain);
- rc = g_hash_table_lookup (domain->proxy_vtable_hash, key);
+ rc = (MonoRemoteClass *)g_hash_table_lookup (domain->proxy_vtable_hash, key);
if (rc) {
g_free (key);
key = mp_key;
if (proxy_class->flags & TYPE_ATTRIBUTE_INTERFACE) {
- rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*));
+ rc = (MonoRemoteClass *)mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*));
rc->interface_count = 1;
rc->interfaces [0] = proxy_class;
rc->proxy_class = mono_defaults.marshalbyrefobject_class;
} else {
- rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS);
+ rc = (MonoRemoteClass *)mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS);
rc->interface_count = 0;
rc->proxy_class = proxy_class;
}
gpointer* key, *mp_key;
key = create_remote_class_key (remote_class, extra_class);
- rc = g_hash_table_lookup (domain->proxy_vtable_hash, key);
+ rc = (MonoRemoteClass *)g_hash_table_lookup (domain->proxy_vtable_hash, key);
if (rc != NULL) {
g_free (key);
return rc;
if (extra_class->flags & TYPE_ATTRIBUTE_INTERFACE) {
int i,j;
- rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * (remote_class->interface_count + 1));
+ rc = (MonoRemoteClass *)mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * (remote_class->interface_count + 1));
rc->proxy_class = remote_class->proxy_class;
rc->interface_count = remote_class->interface_count + 1;
rc->interfaces [j] = extra_class;
} else {
// Replace the old class. The interface array is the same
- rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * remote_class->interface_count);
+ rc = (MonoRemoteClass *)mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * remote_class->interface_count);
rc->proxy_class = extra_class;
rc->interface_count = remote_class->interface_count;
if (rc->interface_count > 0)
if (redo_vtable) {
tproxy->remote_class = clone_remote_class (domain, remote_class, klass);
- proxy_object->vtable = mono_remote_class_vtable (domain, tproxy->remote_class, tproxy->rp);
+ proxy_object->vtable = (MonoVTable *)mono_remote_class_vtable (domain, tproxy->remote_class, tproxy->rp);
}
mono_domain_unlock (domain);
gpointer res;
- MONO_PREPARE_RESET_BLOCKING
+ MONO_PREPARE_RESET_BLOCKING;
method = mono_marshal_get_thunk_invoke_wrapper (method);
res = mono_compile_method (method);
- MONO_FINISH_RESET_BLOCKING
+ MONO_FINISH_RESET_BLOCKING;
return res;
}
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_ARRAY:
- mono_gc_wbarrier_generic_store (dest, deref_pointer? *(gpointer*)value: value);
+ mono_gc_wbarrier_generic_store (dest, deref_pointer ? *(MonoObject **)value : (MonoObject *)value);
return;
case MONO_TYPE_FNPTR:
case MONO_TYPE_PTR: {
t = mono_class_enum_basetype (type->data.klass)->type;
goto handle_enum;
} else {
- MonoClass *class = mono_class_from_mono_type (type);
- int size = mono_class_value_size (class, NULL);
+ MonoClass *klass = mono_class_from_mono_type (type);
+ int size = mono_class_value_size (klass, NULL);
if (value == NULL)
mono_gc_bzero_atomic (dest, size);
else
- mono_gc_wbarrier_value_copy (dest, value, 1, class);
+ mono_gc_wbarrier_value_copy (dest, value, 1, klass);
}
return;
case MONO_TYPE_GENERICINST:
mono_domain_lock (vt->domain);
addr = g_hash_table_lookup (vt->domain->special_static_fields, field);
mono_domain_unlock (vt->domain);
- src = mono_get_special_static_data (GPOINTER_TO_UINT (addr));
+ src = (guint8 *)mono_get_special_static_data (GPOINTER_TO_UINT (addr));
} else {
src = (guint8*)mono_vtable_get_static_field_data (vt) + field->offset;
}
{
MONO_REQ_GC_UNSAFE_MODE;
- MonoDomain *current_domain = mono_domain_get ();
- MonoDomain *root_domain = mono_get_root_domain ();
MonoClassField *field;
- MonoObject *current_appdomain_delegate;
- MonoObject *root_appdomain_delegate;
+ MonoDomain *current_domain, *root_domain;
+ MonoObject *current_appdomain_delegate = NULL, *root_appdomain_delegate = NULL;
- field=mono_class_get_field_from_name(mono_defaults.appdomain_class,
- "UnhandledException");
+ if (mono_class_has_parent (exc->vtable->klass, mono_defaults.threadabortexception_class))
+ return;
+
+ field = mono_class_get_field_from_name (mono_defaults.appdomain_class, "UnhandledException");
g_assert (field);
- if (exc->vtable->klass != mono_defaults.threadabortexception_class) {
- gboolean abort_process = (main_thread && (mono_thread_internal_current () == main_thread->internal_thread)) ||
- (mono_runtime_unhandled_exception_policy_get () == MONO_UNHANDLED_POLICY_CURRENT);
- root_appdomain_delegate = *(MonoObject **)(((char *)root_domain->domain) + field->offset);
- if (current_domain != root_domain) {
- current_appdomain_delegate = *(MonoObject **)(((char *)current_domain->domain) + field->offset);
- } else {
- current_appdomain_delegate = NULL;
- }
+ current_domain = mono_domain_get ();
+ root_domain = mono_get_root_domain ();
- /* set exitcode only if we will abort the process */
- if ((current_appdomain_delegate == NULL) && (root_appdomain_delegate == NULL)) {
- if (abort_process)
- mono_environment_exitcode_set (1);
- mono_print_unhandled_exception (exc);
- } else {
- if (root_appdomain_delegate) {
- call_unhandled_exception_delegate (root_domain, root_appdomain_delegate, exc);
- }
- if (current_appdomain_delegate) {
- call_unhandled_exception_delegate (current_domain, current_appdomain_delegate, exc);
- }
+ root_appdomain_delegate = mono_field_get_value_object (root_domain, field, (MonoObject*) root_domain->domain);
+ if (current_domain != root_domain)
+ current_appdomain_delegate = mono_field_get_value_object (current_domain, field, (MonoObject*) current_domain->domain);
+
+ /* set exitcode only if we will abort the process */
+ if (!current_appdomain_delegate && !root_appdomain_delegate) {
+ if ((main_thread && mono_thread_internal_current () == main_thread->internal_thread)
+ || mono_runtime_unhandled_exception_policy_get () == MONO_UNHANDLED_POLICY_CURRENT)
+ {
+ mono_environment_exitcode_set (1);
}
+
+ mono_print_unhandled_exception (exc);
+ } else {
+ if (root_appdomain_delegate)
+ call_unhandled_exception_delegate (root_domain, root_appdomain_delegate, exc);
+ if (current_appdomain_delegate)
+ call_unhandled_exception_delegate (current_domain, current_appdomain_delegate, exc);
}
}
gboolean has_byref_nullables = FALSE;
if (NULL != params) {
- pa = alloca (sizeof (gpointer) * mono_array_length (params));
+ pa = (void **)alloca (sizeof (gpointer) * mono_array_length (params));
for (i = 0; i < mono_array_length (params); i++) {
MonoType *t = sig->params [i];
}
#endif
if (method->klass->valuetype)
- o = mono_object_unbox (obj);
+ o = (MonoObject *)mono_object_unbox ((MonoObject *)obj);
else
o = obj;
} else if (method->klass->valuetype) {
}
mono_runtime_invoke (method, o, pa, exc);
- return obj;
+ return (MonoObject *)obj;
} else {
if (mono_class_is_nullable (method->klass)) {
MonoObject *nullable;
/* Convert the unboxed vtype into a Nullable structure */
nullable = mono_object_new (mono_domain_get (), method->klass);
- mono_nullable_init (mono_object_unbox (nullable), mono_value_box (mono_domain_get (), method->klass->cast_class, obj), method->klass);
+ mono_nullable_init ((guint8 *)mono_object_unbox (nullable), mono_value_box (mono_domain_get (), method->klass->cast_class, obj), method->klass);
obj = mono_object_unbox (nullable);
}
return NULL;
#ifdef HAVE_SGEN_GC
- return mono_gc_alloc_pinned_obj (vtable, mono_class_instance_size (klass));
+ return (MonoObject *)mono_gc_alloc_pinned_obj (vtable, mono_class_instance_size (klass));
#else
return mono_object_new_specific (vtable);
#endif
{
MONO_REQ_GC_UNSAFE_MODE;
- MonoObject *o = mono_gc_alloc_obj (vtable, vtable->klass->instance_size);
+ MonoObject *o = (MonoObject *)mono_gc_alloc_obj (vtable, vtable->klass->instance_size);
if (G_UNLIKELY (vtable->klass->has_finalize))
mono_object_register_finalizer (o);
{
MONO_REQ_GC_UNSAFE_MODE;
- return mono_gc_alloc_obj (vtable, vtable->klass->instance_size);
+ return (MonoObject *)mono_gc_alloc_obj (vtable, vtable->klass->instance_size);
}
/**
MONO_REQ_GC_UNSAFE_MODE;
MonoError error;
- MonoClass *class;
+ MonoClass *klass;
- class = mono_class_get_checked (image, token, &error);
+ klass = mono_class_get_checked (image, token, &error);
g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
- return mono_object_new (domain, class);
+ return mono_object_new (domain, klass);
}
if (obj->vtable->klass->rank)
return (MonoObject*)mono_array_clone ((MonoArray*)obj);
- o = mono_gc_alloc_obj (obj->vtable, size);
+ o = (MonoObject *)mono_gc_alloc_obj (obj->vtable, size);
/* If the object doesn't contain references this will do a simple memmove. */
mono_gc_wbarrier_object_copy (o, obj);
return o;
}
- sizes = alloca (klass->rank * sizeof(intptr_t) * 2);
+ sizes = (uintptr_t *)alloca (klass->rank * sizeof(intptr_t) * 2);
size = mono_array_element_size (klass);
for (i = 0; i < klass->rank; ++i) {
sizes [i] = array->bounds [i].length;
#endif
gboolean
-mono_array_calc_byte_len (MonoClass *class, uintptr_t len, uintptr_t *res)
+mono_array_calc_byte_len (MonoClass *klass, uintptr_t len, uintptr_t *res)
{
MONO_REQ_GC_NEUTRAL_MODE;
uintptr_t byte_len;
- byte_len = mono_array_element_size (class);
+ byte_len = mono_array_element_size (klass);
if (CHECK_MUL_OVERFLOW_UN (byte_len, len))
return FALSE;
byte_len *= len;
- if (CHECK_ADD_OVERFLOW_UN (byte_len, sizeof (MonoArray)))
+ if (CHECK_ADD_OVERFLOW_UN (byte_len, MONO_SIZEOF_MONO_ARRAY))
return FALSE;
- byte_len += sizeof (MonoArray);
+ byte_len += MONO_SIZEOF_MONO_ARRAY;
*res = byte_len;
*/
vtable = mono_class_vtable_full (domain, array_class, TRUE);
if (bounds_size)
- o = mono_gc_alloc_array (vtable, byte_len, len, bounds_size);
+ o = (MonoObject *)mono_gc_alloc_array (vtable, byte_len, len, bounds_size);
else
- o = mono_gc_alloc_vector (vtable, byte_len, len);
+ o = (MonoObject *)mono_gc_alloc_vector (vtable, byte_len, len);
array = (MonoArray*)o;
bounds = array->bounds;
mono_gc_out_of_memory (MONO_ARRAY_MAX_SIZE);
return NULL;
}
- o = mono_gc_alloc_vector (vtable, byte_len, n);
+ o = (MonoObject *)mono_gc_alloc_vector (vtable, byte_len, n);
ao = (MonoArray*)o;
return ao;
vtable = mono_class_vtable (domain, mono_defaults.string_class);
g_assert (vtable);
- s = mono_gc_alloc_string (vtable, size, len);
+ s = (MonoString *)mono_gc_alloc_string (vtable, size, len);
return s;
}
* Returns: A newly created object which contains @value.
*/
MonoObject *
-mono_value_box (MonoDomain *domain, MonoClass *class, gpointer value)
+mono_value_box (MonoDomain *domain, MonoClass *klass, gpointer value)
{
MONO_REQ_GC_UNSAFE_MODE;
int size;
MonoVTable *vtable;
- g_assert (class->valuetype);
- if (mono_class_is_nullable (class))
- return mono_nullable_box (value, class);
+ g_assert (klass->valuetype);
+ if (mono_class_is_nullable (klass))
+ return mono_nullable_box ((guint8 *)value, klass);
- vtable = mono_class_vtable (domain, class);
+ vtable = mono_class_vtable (domain, klass);
if (!vtable)
return NULL;
- size = mono_class_instance_size (class);
+ size = mono_class_instance_size (klass);
res = mono_object_new_alloc_specific (vtable);
size = size - sizeof (MonoObject);
#ifdef HAVE_SGEN_GC
- g_assert (size == mono_class_value_size (class, NULL));
- mono_gc_wbarrier_value_copy ((char *)res + sizeof (MonoObject), value, 1, class);
+ g_assert (size == mono_class_value_size (klass, NULL));
+ mono_gc_wbarrier_value_copy ((char *)res + sizeof (MonoObject), value, 1, klass);
#else
#if NO_UNALIGNED_ACCESS
mono_gc_memmove_atomic ((char *)res + sizeof (MonoObject), value, size);
}
#endif
#endif
- if (class->has_finalize)
+ if (klass->has_finalize)
mono_object_register_finalizer (res);
return res;
}
return sizeof (MonoString) + 2 * mono_string_length ((MonoString*) o) + 2;
} else if (o->vtable->rank) {
MonoArray *array = (MonoArray*)o;
- size_t size = sizeof (MonoArray) + mono_array_element_size (klass) * mono_array_length (array);
+ size_t size = MONO_SIZEOF_MONO_ARRAY + mono_array_element_size (klass) * mono_array_length (array);
if (array->bounds) {
size += 3;
size &= ~3;
{
MONO_REQ_GC_UNSAFE_MODE;
- LDStrInfo *info = user_data;
+ LDStrInfo *info = (LDStrInfo *)user_data;
if (info->res || domain == info->orig_domain)
return;
- info->res = mono_g_hash_table_lookup (domain->ldstr_table, info->ins);
+ info->res = (MonoString *)mono_g_hash_table_lookup (domain->ldstr_table, info->ins);
}
#ifdef HAVE_SGEN_GC
int size;
MonoString *news;
size = sizeof (MonoString) + 2 * (mono_string_length (str) + 1);
- news = mono_gc_alloc_pinned_obj (((MonoObject*)str)->vtable, size);
+ news = (MonoString *)mono_gc_alloc_pinned_obj (((MonoObject*)str)->vtable, size);
if (news) {
memcpy (mono_string_chars (news), mono_string_chars (str), mono_string_length (str) * 2);
news->length = mono_string_length (str);
domain = ((MonoObject *)str)->vtable->domain;
ldstr_table = domain->ldstr_table;
ldstr_lock ();
- res = mono_g_hash_table_lookup (ldstr_table, str);
+ res = (MonoString *)mono_g_hash_table_lookup (ldstr_table, str);
if (res) {
ldstr_unlock ();
return res;
s = mono_string_get_pinned (str);
if (s) {
ldstr_lock ();
- res = mono_g_hash_table_lookup (ldstr_table, str);
+ res = (MonoString *)mono_g_hash_table_lookup (ldstr_table, str);
if (res) {
ldstr_unlock ();
return res;
MONO_REQ_GC_UNSAFE_MODE;
if (image->dynamic) {
- MonoString *str = mono_lookup_dynamic_token (image, MONO_TOKEN_STRING | idx, NULL);
+ MonoString *str = (MonoString *)mono_lookup_dynamic_token (image, MONO_TOKEN_STRING | idx, NULL);
return str;
} else {
if (!mono_verifier_verify_string_signature (image, idx, NULL))
}
#endif
ldstr_lock ();
- interned = mono_g_hash_table_lookup (domain->ldstr_table, o);
+ interned = (MonoString *)mono_g_hash_table_lookup (domain->ldstr_table, o);
ldstr_unlock ();
if (interned)
return interned; /* o will get garbage collected */
o = mono_string_get_pinned (o);
if (o) {
ldstr_lock ();
- interned = mono_g_hash_table_lookup (domain->ldstr_table, o);
+ interned = (MonoString *)mono_g_hash_table_lookup (domain->ldstr_table, o);
if (!interned) {
mono_g_hash_table_insert (domain->ldstr_table, o, o);
interned = o;
/* g_utf16_to_utf8 may not be able to complete the convertion (e.g. NULL values were found, #335488) */
if (s->length > written) {
/* allocate the total length and copy the part of the string that has been converted */
- char *as2 = g_malloc0 (s->length);
+ char *as2 = (char *)g_malloc0 (s->length);
memcpy (as2, as, written);
g_free (as);
as = as2;
/* g_utf16_to_utf8 may not be able to complete the convertion (e.g. NULL values were found, #335488) */
if (s->length > written) {
/* allocate the total length and copy the part of the string that has been converted */
- char *as2 = g_malloc0 (s->length);
+ char *as2 = (char *)g_malloc0 (s->length);
memcpy (as2, as, written);
g_free (as);
as = as2;
if (s == NULL)
return NULL;
- as = g_malloc ((s->length * 2) + 2);
+ as = (char *)g_malloc ((s->length * 2) + 2);
as [(s->length * 2)] = '\0';
as [(s->length * 2) + 1] = '\0';
len = strlen (r) + 1;
if (mp)
- mp_s = mono_mempool_alloc (mp, len);
+ mp_s = (char *)mono_mempool_alloc (mp, len);
else
- mp_s = mono_image_alloc (image, len);
+ mp_s = (char *)mono_image_alloc (image, len);
memcpy (mp_s, r, len);
MonoMethod *wrapper;
if (!method)
return NULL;
- wrapper = mono_marshal_get_runtime_invoke (method, FALSE);
+ wrapper = mono_marshal_get_runtime_invoke (method, FALSE, FALSE);
domain->capture_context_runtime_invoke = mono_compile_method (wrapper);
domain->capture_context_method = mono_compile_method (method);
}
- runtime_invoke = domain->capture_context_runtime_invoke;
+ runtime_invoke = (RuntimeInvokeFunction)domain->capture_context_runtime_invoke;
return runtime_invoke (NULL, NULL, NULL, domain->capture_context_method);
}
/* note: result may be null if the flow is suppressed */
}
- res->data = data;
+ res->data = (void **)data;
MONO_OBJECT_SETREF (res, object_data, object_data);
MONO_OBJECT_SETREF (res, async_state, state);
if (handle != NULL)
for (i = 0, j = 0; i < sig->param_count; i++) {
if (sig->params [i]->byref) {
if (out_args) {
- MonoObject* arg = mono_array_get (out_args, gpointer, j);
+ MonoObject* arg = (MonoObject *)mono_array_get (out_args, gpointer, j);
mono_array_setref (this_obj->args, i, arg);
j++;
}
for (i = 0, j = 0; i < sig->param_count; i++) {
if (sig->params [i]->byref) {
MonoObject* arg;
- arg = mono_array_get (msg->args, gpointer, i);
+ arg = (MonoObject *)mono_array_get (msg->args, gpointer, i);
mono_array_setref (*out_args, j, arg);
j++;
}
g_assert (addr);
- ji = mono_jit_info_table_find (domain, mono_get_addr_from_ftnptr (addr));
+ ji = mono_jit_info_table_find (domain, (char *)mono_get_addr_from_ftnptr (addr));
/* Shared code */
if (!ji && domain != mono_get_root_domain ())
- ji = mono_jit_info_table_find (mono_get_root_domain (), mono_get_addr_from_ftnptr (addr));
+ ji = mono_jit_info_table_find (mono_get_root_domain (), (char *)mono_get_addr_from_ftnptr (addr));
if (ji) {
method = mono_jit_info_get_method (ji);
g_assert (!method->klass->generic_container);
for (i = 0; i < count; i++) {
gpointer vpos;
- MonoClass *class;
+ MonoClass *klass;
MonoObject *arg;
if (sig->params [i]->byref)
else
vpos = params [i];
- class = mono_class_from_mono_type (sig->params [i]);
+ klass = mono_class_from_mono_type (sig->params [i]);
- if (class->valuetype)
- arg = mono_value_box (domain, class, vpos);
+ if (klass->valuetype)
+ arg = mono_value_box (domain, klass, vpos);
else
arg = *((MonoObject **)vpos);
if (j >= out_len)
mono_raise_exception (mono_get_exception_execution_engine ("The proxy call returned an incorrect number of output arguments"));
- arg = mono_array_get (out_args, gpointer, j);
+ arg = (char *)mono_array_get (out_args, gpointer, j);
type = pt->type;
g_assert (type != MONO_TYPE_VOID);
mono_gc_wbarrier_generic_store (*((MonoObject ***)params [i]), (MonoObject *)arg);
} else {
if (arg) {
- MonoClass *class = ((MonoObject*)arg)->vtable->klass;
- size = mono_class_value_size (class, NULL);
- if (class->has_references)
- mono_gc_wbarrier_value_copy (*((gpointer *)params [i]), arg + sizeof (MonoObject), 1, class);
+ MonoClass *klass = ((MonoObject*)arg)->vtable->klass;
+ size = mono_class_value_size (klass, NULL);
+ if (klass->has_references)
+ mono_gc_wbarrier_value_copy (*((gpointer *)params [i]), arg + sizeof (MonoObject), 1, klass);
else
mono_gc_memmove_atomic (*((gpointer *)params [i]), arg + sizeof (MonoObject), size);
} else {
return ((char*)(array)->vector) + size * idx;
}
+
+MonoArray *
+mono_glist_to_array (GList *list, MonoClass *eclass)
+{
+ MonoDomain *domain = mono_domain_get ();
+ MonoArray *res;
+ int len, i;
+
+ if (!list)
+ return NULL;
+
+ len = g_list_length (list);
+ res = mono_array_new (domain, eclass, len);
+
+ for (i = 0; list; list = list->next, i++)
+ mono_array_set (res, gpointer, i, list->data);
+
+ return res;
+}
+