2005-10-30 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mono / metadata / icall.c
index 61e9925a39c535b4942bfff809f4aaed54e76247..07db51e1b4b64d669a1d13175ccbf11e77132608 100644 (file)
@@ -78,11 +78,16 @@ mono_double_ParseImpl (char *ptr)
 
        MONO_ARCH_SAVE_REGS;
 
+#ifdef __arm__
+       if (*ptr)
+               result = strtod (ptr, &endptr);
+#else
        if (*ptr)
                result = bsd_strtod (ptr, &endptr);
+#endif
 
        if (!*ptr || (endptr && *endptr))
-               mono_raise_exception (mono_exception_from_name (mono_defaults.corlib,
+               mono_raise_exception (mono_exception_from_name (mono_get_corlib (),
                                                                "System",
                                                                "FormatException"));
        
@@ -140,7 +145,7 @@ ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs)
        if (io->bounds != NULL || io->max_length !=  ac->rank)
                mono_raise_exception (mono_get_exception_argument (NULL, NULL));
 
-       ind = (guint32 *)io->vector;
+       ind = (gint32 *)io->vector;
 
        if (ao->bounds == NULL) {
                if (*ind < 0 || *ind >= ao->max_length)
@@ -440,7 +445,7 @@ ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value,
        if (idxs->bounds != NULL || idxs->max_length != ac->rank)
                mono_raise_exception (mono_get_exception_argument (NULL, NULL));
 
-       ind = (guint32 *)idxs->vector;
+       ind = (gint32 *)idxs->vector;
 
        if (this->bounds == NULL) {
                if (*ind < 0 || *ind >= this->max_length)
@@ -468,7 +473,7 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *
 {
        MonoClass *aklass;
        MonoArray *array;
-       gint32 *sizes, i;
+       guint32 *sizes, i;
        gboolean bounded = FALSE;
 
        MONO_ARCH_SAVE_REGS;
@@ -494,9 +499,9 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *
 
        sizes = alloca (aklass->rank * sizeof(guint32) * 2);
        for (i = 0; i < aklass->rank; ++i) {
-               sizes [i] = mono_array_get (lengths, gint32, i);
+               sizes [i] = mono_array_get (lengths, guint32, i);
                if (bounds)
-                       sizes [i + aklass->rank] = mono_array_get (bounds, gint32, i);
+                       sizes [i + aklass->rank] = mono_array_get (bounds, guint32, i);
                else
                        sizes [i + aklass->rank] = 0;
        }
@@ -606,6 +611,7 @@ ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* d
                return TRUE;
        }
 
+       /* Check if we're copying a char[] <==> (u)short[] */
        if (src_class != dest_class) {
                if (dest_class->valuetype || dest_class->enumtype || src_class->valuetype || src_class->enumtype)
                        return FALSE;
@@ -628,6 +634,26 @@ ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* d
        return TRUE;
 }
 
+static void
+ves_icall_System_Array_InternalArray_GetGenericValueImpl (MonoObject *this, guint32 pos,
+                                                         gpointer value)
+{
+       MonoClass *ac;
+       MonoArray *ao;
+       gint32 esize;
+       gpointer *ea;
+
+       MONO_ARCH_SAVE_REGS;
+
+       ao = (MonoArray *)this;
+       ac = (MonoClass *)ao->obj.vtable->klass;
+
+       esize = mono_array_element_size (ac);
+       ea = (gpointer*)((char*)ao->vector + (pos * esize));
+
+       memcpy (value, ea, esize);
+}
+
 static void
 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoArray *array, MonoClassField *field_handle)
 {
@@ -743,18 +769,19 @@ ves_icall_System_Object_GetHashCode (MonoObject *this)
 static gint32
 ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this, MonoArray **fields)
 {
-       int i;
        MonoClass *klass;
        MonoObject **values = NULL;
        MonoObject *o;
        int count = 0;
        gint32 result = 0;
+       MonoClassField* field;
+       gpointer iter;
 
        MONO_ARCH_SAVE_REGS;
 
-       klass = this->vtable->klass;
+       klass = mono_object_class (this);
 
-       if (klass->field.count == 0)
+       if (mono_class_num_fields (klass) == 0)
                return ves_icall_System_Object_GetHashCode (this);
 
        /*
@@ -762,8 +789,8 @@ ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this, MonoArray **fi
         * types, and return the remaining fields in an array to the managed side.
         * This way, we can avoid costly reflection operations in managed code.
         */
-       for (i = 0; i < klass->field.count; ++i) {
-               MonoClassField *field = &klass->fields [i];
+       iter = NULL;
+       while ((field = mono_class_get_fields (klass, &iter))) {
                if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
                        continue;
                if (mono_field_is_deleted (field))
@@ -777,12 +804,12 @@ ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this, MonoArray **fi
                        MonoString *s;
                        s = *(MonoString**)((guint8*)this + field->offset);
                        if (s != NULL)
-                               result ^= ves_icall_System_String_GetHashCode (s);
+                               result ^= mono_string_hash (s);
                        break;
                }
                default:
                        if (!values)
-                               values = alloca (klass->field.count * sizeof (MonoObject*));
+                               values = g_newa (MonoObject*, mono_class_num_fields (klass));
                        o = mono_field_get_value_object (mono_object_domain (this), field, this);
                        values [count++] = o;
                }
@@ -800,10 +827,11 @@ ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this, MonoArray **fi
 static MonoBoolean
 ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that, MonoArray **fields)
 {
-       int i;
        MonoClass *klass;
        MonoObject **values = NULL;
        MonoObject *o;
+       MonoClassField* field;
+       gpointer iter;
        int count = 0;
 
        MONO_ARCH_SAVE_REGS;
@@ -813,7 +841,7 @@ ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that, MonoArray
        if (this->vtable != that->vtable)
                return FALSE;
 
-       klass = this->vtable->klass;
+       klass = mono_object_class (this);
 
        /*
         * Do the comparison for fields of primitive type and return a result if
@@ -822,8 +850,8 @@ ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that, MonoArray
         * managed code.
         */
        *fields = NULL;
-       for (i = 0; i < klass->field.count; ++i) {
-               MonoClassField *field = &klass->fields [i];
+       iter = NULL;
+       while ((field = mono_class_get_fields (klass, &iter))) {
                if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
                        continue;
                if (mono_field_is_deleted (field))
@@ -854,7 +882,7 @@ ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that, MonoArray
                }
                default:
                        if (!values)
-                               values = alloca (klass->field.count * 2 * sizeof (MonoObject*));
+                               values = g_newa (MonoObject*, mono_class_num_fields (klass) * 2);
                        o = mono_field_get_value_object (mono_object_domain (this), field, this);
                        values [count++] = o;
                        o = mono_field_get_value_object (mono_object_domain (this), field, that);
@@ -999,7 +1027,7 @@ ves_icall_type_from_name (MonoString *name,
        g_free (str);
        if (type == NULL){
                if (throwOnError)
-                       mono_raise_exception (mono_get_exception_type_load (name));
+                       mono_raise_exception (mono_get_exception_type_load (name, NULL));
        }
        
        return type;
@@ -1018,15 +1046,15 @@ ves_icall_type_from_handle (MonoType *handle)
        return mono_type_get_object (domain, handle);
 }
 
-static guint32
+static MonoBoolean
 ves_icall_type_Equals (MonoReflectionType *type, MonoReflectionType *c)
 {
        MONO_ARCH_SAVE_REGS;
 
        if (type->type && c->type)
                return mono_metadata_type_equal (type->type, c->type);
-       g_print ("type equals\n");
-       return 0;
+       else
+               return FALSE;
 }
 
 /* System.TypeCode */
@@ -1052,7 +1080,7 @@ typedef enum {
 } TypeCode;
 
 static guint32
-ves_icall_type_GetTypeCode (MonoReflectionType *type)
+ves_icall_type_GetTypeCodeInternal (MonoReflectionType *type)
 {
        int t = type->type->type;
 
@@ -1295,6 +1323,7 @@ ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *ob
        MonoClassField *cf = field->field;
        MonoClass *klass;
        MonoVTable *vtable;
+       MonoType *t;
        MonoDomain *domain = mono_object_domain (field); 
        gchar *v;
        gboolean is_static = FALSE;
@@ -1302,9 +1331,14 @@ ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *ob
 
        MONO_ARCH_SAVE_REGS;
 
+       if (field->klass->image->assembly->ref_only)
+               mono_raise_exception (mono_get_exception_invalid_operation (
+                                       "It is illegal to get the value on a field on a type loaded using the ReflectionOnly methods."));
+       
        mono_class_init (field->klass);
 
-       switch (cf->type->type) {
+       t = mono_type_get_underlying_type (cf->type);
+       switch (t->type) {
        case MONO_TYPE_STRING:
        case MONO_TYPE_OBJECT:
        case MONO_TYPE_CLASS:
@@ -1327,11 +1361,11 @@ ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *ob
        case MONO_TYPE_I8:
        case MONO_TYPE_R8:
        case MONO_TYPE_VALUETYPE:
-               is_ref = cf->type->byref;
+               is_ref = t->byref;
                break;
        default:
                g_error ("type 0x%x not handled in "
-                        "ves_icall_Monofield_GetValue", cf->type->type);
+                        "ves_icall_Monofield_GetValue", t->type);
                return NULL;
        }
 
@@ -1373,6 +1407,10 @@ ves_icall_FieldInfo_SetValueInternal (MonoReflectionField *field, MonoObject *ob
 
        MONO_ARCH_SAVE_REGS;
 
+       if (field->klass->image->assembly->ref_only)
+               mono_raise_exception (mono_get_exception_invalid_operation (
+                                       "It is illegal to set the value on a field on a type loaded using the ReflectionOnly methods."));
+
        v = (gchar *) value;
        if (!cf->type->byref) {
                switch (cf->type->type) {
@@ -1401,6 +1439,13 @@ ves_icall_FieldInfo_SetValueInternal (MonoReflectionField *field, MonoObject *ob
                case MONO_TYPE_SZARRAY:
                        /* Do nothing */
                        break;
+               case MONO_TYPE_GENERICINST: {
+                       MonoGenericClass *gclass = cf->type->data.generic_class;
+                       g_assert (!gclass->inst->is_open);
+                       if (gclass->container_class->valuetype && (v != NULL))
+                               v += sizeof (MonoObject);
+                       break;
+               }
                default:
                        g_error ("type 0x%x not handled in "
                                 "ves_icall_FieldInfo_SetValueInternal", cf->type->type);
@@ -1565,7 +1610,9 @@ ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType
        MonoClass *class = mono_class_from_mono_type (type->type);
        MonoClass *iclass = mono_class_from_mono_type (iface->type);
        MonoReflectionMethod *member;
-       int i, len, ioffset;
+       MonoMethod* method;
+       gpointer iter;
+       int i = 0, len, ioffset;
        MonoDomain *domain;
 
        MONO_ARCH_SAVE_REGS;
@@ -1574,16 +1621,20 @@ ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType
        if ((iclass->interface_id > class->max_interface_id) || !class->interface_offsets [iclass->interface_id])
                        return;
 
-       len = iclass->method.count;
+       len = mono_class_num_methods (iclass);
        ioffset = class->interface_offsets [iclass->interface_id];
        domain = mono_object_domain (type);
        *targets = mono_array_new (domain, mono_defaults.method_info_class, len);
        *methods = mono_array_new (domain, mono_defaults.method_info_class, len);
-       for (i = 0; i < len; ++i) {
-               member = mono_method_get_object (domain, iclass->methods [i], iclass);
+       iter = NULL;
+       iter = NULL;
+       while ((method = mono_class_get_methods (iclass, &iter))) {
+               member = mono_method_get_object (domain, method, iclass);
                mono_array_set (*methods, gpointer, i, member);
                member = mono_method_get_object (domain, class->vtable [i + ioffset], class);
                mono_array_set (*targets, gpointer, i, member);
+               
+               i ++;
        }
 }
 
@@ -1800,7 +1851,7 @@ ves_icall_Type_GetGenericTypeDefinition_impl (MonoReflectionType *type)
 }
 
 static MonoReflectionType*
-ves_icall_Type_BindGenericParameters (MonoReflectionType *type, MonoArray *type_array)
+ves_icall_Type_MakeGenericType (MonoReflectionType *type, MonoArray *type_array)
 {
        MonoType *geninst, **types;
        int i, count;
@@ -1816,6 +1867,8 @@ ves_icall_Type_BindGenericParameters (MonoReflectionType *type, MonoArray *type_
        }
 
        geninst = mono_reflection_bind_generic_parameters (type, count, types);
+       if (!geninst)
+               return NULL;
 
        return mono_type_get_object (mono_object_domain (type), geninst);
 }
@@ -1830,6 +1883,16 @@ ves_icall_Type_get_IsGenericInstance (MonoReflectionType *type)
        return klass->generic_class != NULL;
 }
 
+static gboolean
+ves_icall_Type_get_IsGenericType (MonoReflectionType *type)
+{
+       MonoClass *klass;
+       MONO_ARCH_SAVE_REGS;
+
+       klass = mono_class_from_mono_type (type->type);
+       return klass->generic_class != NULL || klass->generic_container != NULL;
+}
+
 static gint32
 ves_icall_Type_GetGenericParameterPosition (MonoReflectionType *type)
 {
@@ -1872,18 +1935,6 @@ ves_icall_Type_GetGenericParameterConstraints (MonoReflectionType *type)
        return res;
 }
 
-static MonoBoolean
-ves_icall_MonoType_get_HasGenericArguments (MonoReflectionType *type)
-{
-       MonoClass *klass;
-       MONO_ARCH_SAVE_REGS;
-
-       klass = mono_class_from_mono_type (type->type);
-       if (klass->generic_container || klass->generic_class)
-               return TRUE;
-       return FALSE;
-}
-
 static MonoBoolean
 ves_icall_MonoType_get_IsGenericParameter (MonoReflectionType *type)
 {
@@ -1914,13 +1965,15 @@ ves_icall_EnumBuilder_setup_enum_type (MonoReflectionType *enumtype,
 static MonoReflectionType*
 ves_icall_MonoGenericClass_GetParentType (MonoReflectionGenericClass *type)
 {
-       MonoGenericClass *gclass;
+       MonoDynamicGenericClass *gclass;
        MonoClass *klass;
 
        MONO_ARCH_SAVE_REGS;
 
-       gclass = type->type.type->data.generic_class;
-       if (!gclass || !gclass->parent || (gclass->parent->type != MONO_TYPE_GENERICINST))
+       g_assert (type->type.type->data.generic_class->is_dynamic);
+       gclass = (MonoDynamicGenericClass *) type->type.type->data.generic_class;
+
+       if (!gclass->parent || (gclass->parent->type != MONO_TYPE_GENERICINST))
                return NULL;
 
        klass = mono_class_from_mono_type (gclass->parent);
@@ -1934,7 +1987,7 @@ static MonoArray*
 ves_icall_MonoGenericClass_GetInterfaces (MonoReflectionGenericClass *type)
 {
        static MonoClass *System_Reflection_MonoGenericClass;
-       MonoGenericClass *gclass;
+       MonoDynamicGenericClass *gclass;
        MonoDomain *domain;
        MonoClass *klass;
        MonoArray *res;
@@ -1950,11 +2003,12 @@ ves_icall_MonoGenericClass_GetInterfaces (MonoReflectionGenericClass *type)
 
        domain = mono_object_domain (type);
 
-       gclass = type->type.type->data.generic_class;
-       if (!gclass || !gclass->ifaces)
+       g_assert (type->type.type->data.generic_class->is_dynamic);
+       gclass = (MonoDynamicGenericClass *) type->type.type->data.generic_class;
+       if (!gclass->ifaces)
                return mono_array_new (domain, System_Reflection_MonoGenericClass, 0);
 
-       klass = gclass->container_class;
+       klass = gclass->generic_class.generic_class.container_class;
 
        res = mono_array_new (domain, System_Reflection_MonoGenericClass, gclass->count_ifaces);
 
@@ -1967,6 +2021,116 @@ ves_icall_MonoGenericClass_GetInterfaces (MonoReflectionGenericClass *type)
        return res;
 }
 
+
+static MonoReflectionMethod*
+ves_icall_MonoGenericClass_GetCorrespondingInflatedMethod (MonoReflectionGenericClass *type, 
+                                                           MonoReflectionMethod* generic)
+{
+       MonoGenericClass *gclass;
+       MonoDynamicGenericClass *dgclass;
+       MonoDomain *domain;
+       int i;
+
+       MONO_ARCH_SAVE_REGS;
+
+       gclass = type->type.type->data.generic_class;
+       g_assert (gclass->is_dynamic);
+
+       dgclass = (MonoDynamicGenericClass *) gclass;
+
+       domain = mono_object_domain (type);
+
+       for (i = 0; i < dgclass->count_methods; i++)
+               if (generic->method->token == dgclass->methods [i]->token)
+                        return mono_method_get_object (domain, dgclass->methods [i], NULL);
+
+       return NULL;
+}
+
+static MonoReflectionMethod*
+ves_icall_MonoGenericClass_GetCorrespondingInflatedConstructor (MonoReflectionGenericClass *type, 
+                                                                MonoReflectionMethod* generic)
+{
+       MonoGenericClass *gclass;
+       MonoDynamicGenericClass *dgclass;
+       MonoDomain *domain;
+       int i;
+
+       MONO_ARCH_SAVE_REGS;
+
+       gclass = type->type.type->data.generic_class;
+       g_assert (gclass->is_dynamic);
+
+       dgclass = (MonoDynamicGenericClass *) gclass;
+
+       domain = mono_object_domain (type);
+
+       for (i = 0; i < dgclass->count_ctors; i++)
+               if (generic->method->token == dgclass->ctors [i]->token)
+                        return mono_method_get_object (domain, dgclass->ctors [i], NULL);
+
+       return NULL;
+}
+
+
+static MonoReflectionField*
+ves_icall_MonoGenericClass_GetCorrespondingInflatedField (MonoReflectionGenericClass *type, 
+                                                          MonoString* generic_name)
+{
+       MonoGenericClass *gclass;
+       MonoDynamicGenericClass *dgclass;
+       MonoDomain *domain;
+        MonoClass *refclass;
+       char *utf8_name = mono_string_to_utf8 (generic_name);
+       int i;
+
+       MONO_ARCH_SAVE_REGS;
+
+       gclass = type->type.type->data.generic_class;
+       g_assert (gclass->is_dynamic);
+
+       dgclass = (MonoDynamicGenericClass *) gclass;
+
+       refclass = mono_class_from_mono_type (type->type.type);
+
+       domain = mono_object_domain (type);
+
+       for (i = 0; i < dgclass->count_fields; i++)
+                if (strcmp (utf8_name, dgclass->fields [i].name) == 0) {
+                       g_free (utf8_name);
+                        return mono_field_get_object (domain, refclass, &dgclass->fields [i]);
+               }
+       
+       g_free (utf8_name);
+
+       return NULL;
+}
+
+
+static MonoReflectionMethod*
+ves_icall_MonoType_GetCorrespondingInflatedMethod (MonoReflectionType *type, 
+                                                   MonoReflectionMethod* generic)
+{
+       MonoDomain *domain; 
+       MonoClass *klass;
+       MonoMethod *method;
+       gpointer iter;
+               
+       MONO_ARCH_SAVE_REGS;
+
+       domain = ((MonoObject *)type)->vtable->domain;
+
+       klass = mono_class_from_mono_type (type->type);
+
+       iter = NULL;
+       while ((method = mono_class_get_methods (klass, &iter))) {
+                if (method->token == generic->method->token)
+                        return mono_method_get_object (domain, method, klass);
+        }
+
+        return NULL;
+}
+
 static MonoArray*
 ves_icall_MonoGenericClass_GetMethods (MonoReflectionGenericClass *type,
                                       MonoReflectionType *reflected_type)
@@ -2200,9 +2364,9 @@ ves_icall_MonoMethod_GetDllImportAttribute (MonoMethod *method)
        if (attr->charset == 1)
                attr->charset = 2;
        attr->exact_spelling = (flags & 0x1) != 0;
-       attr->set_last_error = (flags & 0x4) != 0;
-       attr->best_fit_mapping = (flags & 0x10) != 0;
-       attr->throw_on_unmappable = (flags & 0x1000) != 0;
+       attr->set_last_error = (flags & 0x40) != 0;
+       attr->best_fit_mapping = (flags & 0x30) == 0x10;
+       attr->throw_on_unmappable = (flags & 0x3000) == 0x1000;
        attr->preserve_sig = FALSE;
 
        return attr;
@@ -2328,15 +2492,17 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr
 
        MONO_ARCH_SAVE_REGS;
 
-       if (this) {
-               if (!mono_object_isinst (this, m->klass))
+       if (!(m->flags & METHOD_ATTRIBUTE_STATIC)) {
+               if (this) {
+                       if (!mono_object_isinst (this, m->klass))
+                               mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
+                       m = mono_object_get_virtual_method (this, m);
+                       /* must pass the pointer to the value for valuetype methods */
+                       if (m->klass->valuetype)
+                               obj = mono_object_unbox (this);
+               } else if (strcmp (m->name, ".ctor") && !m->wrapper_type)
                        mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
-               m = mono_object_get_virtual_method (this, m);
-               /* must pass the pointer to the value for valuetype methods */
-               if (m->klass->valuetype)
-                       obj = mono_object_unbox (this);
-       } else if (!(m->flags & METHOD_ATTRIBUTE_STATIC) && strcmp (m->name, ".ctor") && !m->wrapper_type)
-               mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
+       }
 
        pcount = params? mono_array_length (params): 0;
        if (pcount != mono_method_signature (m)->param_count)
@@ -2345,6 +2511,9 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr
        if ((m->klass->flags & TYPE_ATTRIBUTE_ABSTRACT) && !strcmp (m->name, ".ctor"))
                mono_raise_exception (mono_exception_from_name_msg (mono_defaults.corlib, "System", "MethodAccessException", "Cannot invoke constructor of an abstract class."));
 
+       if (m->klass->image->assembly->ref_only)
+               mono_raise_exception (mono_get_exception_invalid_operation ("It is illegal to invoke a method on a type loaded using the ReflectionOnly api."));
+       
        if (m->klass->rank && !strcmp (m->name, ".ctor")) {
                int i;
                guint32 *lengths;
@@ -2400,26 +2569,22 @@ ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoA
                        str = mono_string_to_utf8 (name);
                
                        do {
-                               for (i = 0; i < k->field.count; i++) {
-                                       if (!strcmp (k->fields [i].name, str)) {
-                                               MonoClass *field_klass =  mono_class_from_mono_type (k->fields [i].type);
-                                               if (field_klass->valuetype)
-                                                       result = mono_value_box (domain, field_klass,
-                                                                                (char *)this + k->fields [i].offset);
-                                               else 
-                                                       result = *((gpointer *)((char *)this + k->fields [i].offset));
-                                       
-                                               g_assert (result);
-                                               out_args = mono_array_new (domain, mono_defaults.object_class, 1);
-                                               *outArgs = out_args;
-                                               mono_array_set (out_args, gpointer, 0, result);
-                                               g_free (str);
-                                               return NULL;
-                                       }
+                               MonoClassField* field = mono_class_get_field_from_name (k, str);
+                               if (field) {
+                                       MonoClass *field_klass =  mono_class_from_mono_type (field->type);
+                                       if (field_klass->valuetype)
+                                               result = mono_value_box (domain, field_klass, (char *)this + field->offset);
+                                       else 
+                                               result = *((gpointer *)((char *)this + field->offset));
+                               
+                                       out_args = mono_array_new (domain, mono_defaults.object_class, 1);
+                                       *outArgs = out_args;
+                                       mono_array_set (out_args, gpointer, 0, result);
+                                       g_free (str);
+                                       return NULL;
                                }
                                k = k->parent;
-                       } 
-                       while (k != NULL);
+                       } while (k);
 
                        g_free (str);
                        g_assert_not_reached ();
@@ -2442,28 +2607,27 @@ ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoA
                        str = mono_string_to_utf8 (name);
                
                        do {
-                               for (i = 0; i < k->field.count; i++) {
-                                       if (!strcmp (k->fields [i].name, str)) {
-                                               MonoClass *field_klass =  mono_class_from_mono_type (k->fields [i].type);
-                                               MonoObject *val = mono_array_get (params, gpointer, 2);
-       
-                                               if (field_klass->valuetype) {
-                                                       size = mono_type_size (k->fields [i].type, &align);
-                                                       memcpy ((char *)this + k->fields [i].offset, 
-                                                               ((char *)val) + sizeof (MonoObject), size);
-                                               } else 
-                                                       *(MonoObject**)((char *)this + k->fields [i].offset) = val;
-                                       
-                                               out_args = mono_array_new (domain, mono_defaults.object_class, 0);
-                                               *outArgs = out_args;
-       
-                                               g_free (str);
-                                               return NULL;
-                                       }
+                               MonoClassField* field = mono_class_get_field_from_name (k, str);
+                               if (field) {
+                                       MonoClass *field_klass =  mono_class_from_mono_type (field->type);
+                                       MonoObject *val = mono_array_get (params, gpointer, 2);
+
+                                       if (field_klass->valuetype) {
+                                               size = mono_type_size (field->type, &align);
+                                               memcpy ((char *)this + field->offset, 
+                                                       ((char *)val) + sizeof (MonoObject), size);
+                                       } else 
+                                               *(MonoObject**)((char *)this + field->offset) = val;
+                               
+                                       out_args = mono_array_new (domain, mono_defaults.object_class, 0);
+                                       *outArgs = out_args;
+
+                                       g_free (str);
+                                       return NULL;
                                }
+                               
                                k = k->parent;
-                       } 
-                       while (k != NULL);
+                       } while (k);
 
                        g_free (str);
                        g_assert_not_reached ();
@@ -2568,22 +2732,23 @@ ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
 {
        MonoDomain *domain = mono_object_domain (type); 
        MonoClass *enumc = mono_class_from_mono_type (type->type);
-       guint i, j, nvalues, crow;
+       guint j = 0, nvalues, crow;
+       gpointer iter;
        MonoClassField *field;
 
        MONO_ARCH_SAVE_REGS;
 
        info->utype = mono_type_get_object (domain, enumc->enum_basetype);
-       nvalues = enumc->field.count ? enumc->field.count - 1 : 0;
+       nvalues = mono_class_num_fields (enumc) ? mono_class_num_fields (enumc) - 1 : 0;
        info->names = mono_array_new (domain, mono_defaults.string_class, nvalues);
        info->values = mono_array_new (domain, enumc, nvalues);
        
        crow = -1;
-       for (i = 0, j = 0; i < enumc->field.count; ++i) {
+       iter = NULL;
+       while ((field = mono_class_get_fields (enumc, &iter))) {
                const char *p;
                int len;
-
-               field = &enumc->fields [i];
+               
                if (strcmp ("value__", field->name) == 0)
                        continue;
                if (mono_field_is_deleted (field))
@@ -2591,7 +2756,7 @@ ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
                mono_array_set (info->names, gpointer, j, mono_string_new (domain, field->name));
 
                if (!field->data) {
-                       crow = mono_metadata_get_constant_index (enumc->image, MONO_TOKEN_FIELD_DEF | (i+enumc->field.first+1), crow + 1);
+                       crow = mono_metadata_get_constant_index (enumc->image, mono_class_get_field_token (field), crow + 1);
                        field->def_type = mono_metadata_decode_row_col (&enumc->image->tables [MONO_TABLE_CONSTANT], crow-1, MONO_CONSTANT_TYPE);
                        crow = mono_metadata_decode_row_col (&enumc->image->tables [MONO_TABLE_CONSTANT], crow-1, MONO_CONSTANT_VALUE);
                        field->data = (gpointer)mono_metadata_blob_heap (enumc->image, crow);
@@ -2648,8 +2813,9 @@ ves_icall_Type_GetField (MonoReflectionType *type, MonoString *name, guint32 bfl
 {
        MonoDomain *domain; 
        MonoClass *startklass, *klass;
-       int i, match;
+       int match;
        MonoClassField *field;
+       gpointer iter;
        char *utf8_name;
        int (*compare_func) (const char *s1, const char *s2) = NULL;
        domain = ((MonoObject *)type)->vtable->domain;
@@ -2659,13 +2825,15 @@ ves_icall_Type_GetField (MonoReflectionType *type, MonoString *name, guint32 bfl
 
        if (!name)
                mono_raise_exception (mono_get_exception_argument_null ("name"));
+       if (type->type->byref)
+               return NULL;
 
        compare_func = (bflags & BFLAGS_IgnoreCase) ? g_strcasecmp : strcmp;
 
-handle_parent: 
-       for (i = 0; i < klass->field.count; ++i) {
+handle_parent:
+       iter = NULL;
+       while ((field = mono_class_get_fields (klass, &iter))) {
                match = 0;
-               field = &klass->fields [i];
                if (mono_field_is_deleted (field))
                        continue;
                if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
@@ -2698,7 +2866,7 @@ handle_parent:
                }
                g_free (utf8_name);
                
-               return mono_field_get_object (domain, startklass, field);
+               return mono_field_get_object (domain, klass, field);
        }
        if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
                goto handle_parent;
@@ -2715,18 +2883,21 @@ ves_icall_Type_GetFields_internal (MonoReflectionType *type, guint32 bflags, Mon
        MonoArray *res;
        MonoObject *member;
        int i, len, match;
+       gpointer iter;
        MonoClassField *field;
 
        MONO_ARCH_SAVE_REGS;
 
        domain = ((MonoObject *)type)->vtable->domain;
+       if (type->type->byref)
+               return mono_array_new (domain, mono_defaults.method_info_class, 0);
        klass = startklass = mono_class_from_mono_type (type->type);
        refklass = mono_class_from_mono_type (reftype->type);
 
 handle_parent: 
-       for (i = 0; i < klass->field.count; ++i) {
+       iter = NULL;
+       while ((field = mono_class_get_fields (klass, &iter))) {
                match = 0;
-               field = &klass->fields [i];
                if (mono_field_is_deleted (field))
                        continue;
                if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
@@ -2773,15 +2944,19 @@ ves_icall_Type_GetMethodsByName (MonoReflectionType *type, MonoString *name, gui
        MonoClass *startklass, *klass, *refklass;
        MonoArray *res;
        MonoMethod *method;
+       gpointer iter;
        MonoObject *member;
        int i, len, match;
-       GHashTable *method_slots = g_hash_table_new (mono_aligned_addr_hash, NULL);
+       guint32 method_slots_default [8];
+       guint32 *method_slots;
        gchar *mname = NULL;
        int (*compare_func) (const char *s1, const char *s2) = NULL;
                
        MONO_ARCH_SAVE_REGS;
 
        domain = ((MonoObject *)type)->vtable->domain;
+       if (type->type->byref)
+               return mono_array_new (domain, mono_defaults.method_info_class, 0);
        klass = startklass = mono_class_from_mono_type (type->type);
        refklass = mono_class_from_mono_type (reftype->type);
        len = 0;
@@ -2790,11 +2965,18 @@ ves_icall_Type_GetMethodsByName (MonoReflectionType *type, MonoString *name, gui
                compare_func = (ignore_case) ? g_strcasecmp : strcmp;
        }
 
+       if (klass->vtable_size >= sizeof (method_slots_default) * 8) {
+               method_slots = g_new0 (guint32, klass->vtable_size / 32 + 1);
+       } else {
+               method_slots = method_slots_default;
+               memset (method_slots, 0, sizeof (method_slots_default));
+       }
 handle_parent:
-       for (i = 0; i < klass->method.count; ++i) {
+       mono_class_setup_vtable (klass);
+       iter = NULL;
+       while ((method = mono_class_get_methods (klass, &iter))) {
                match = 0;
-               method = klass->methods [i];
-               if (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0)
+               if (method->name [0] == '.' && (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0))
                        continue;
                if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
                        if (bflags & BFLAGS_Public)
@@ -2825,9 +3007,9 @@ handle_parent:
                
                match = 0;
                if (method->slot != -1) {
-                       if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
+                       if (method_slots [method->slot >> 5] & (1 << (method->slot & 0x1f)))
                                continue;
-                       g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), method);
+                       method_slots [method->slot >> 5] |= 1 << (method->slot & 0x1f);
                }
                
                member = (MonoObject*)mono_method_get_object (domain, method, refklass);
@@ -2847,7 +3029,8 @@ handle_parent:
        for (; tmp; tmp = tmp->next, ++i)
                mono_array_set (res, gpointer, i, tmp->data);
        g_slist_free (l);
-       g_hash_table_destroy (method_slots);
+       if (method_slots != method_slots_default)
+               g_free (method_slots);
        return res;
 }
 
@@ -2862,16 +3045,19 @@ ves_icall_Type_GetConstructors_internal (MonoReflectionType *type, guint32 bflag
        MonoMethod *method;
        MonoObject *member;
        int i, len, match;
-
+       gpointer iter = NULL;
+       
        MONO_ARCH_SAVE_REGS;
 
        domain = ((MonoObject *)type)->vtable->domain;
+       if (type->type->byref)
+               return mono_array_new (domain, mono_defaults.method_info_class, 0);
        klass = startklass = mono_class_from_mono_type (type->type);
        refklass = mono_class_from_mono_type (reftype->type);
 
-       for (i = 0; i < klass->method.count; ++i) {
+       iter = NULL;
+       while ((method = mono_class_get_methods (klass, &iter))) {
                match = 0;
-               method = klass->methods [i];
                if (strcmp (method->name, ".ctor") && strcmp (method->name, ".cctor"))
                        continue;
                if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
@@ -2925,22 +3111,37 @@ ves_icall_Type_GetPropertiesByName (MonoReflectionType *type, MonoString *name,
        int i, match;
        int len = 0;
        guint32 flags;
-       GHashTable *method_slots = g_hash_table_new (mono_aligned_addr_hash, NULL);
+       guint32 method_slots_default [8];
+       guint32 *method_slots;
        gchar *propname = NULL;
        int (*compare_func) (const char *s1, const char *s2) = NULL;
+       gpointer iter;
 
        MONO_ARCH_SAVE_REGS;
 
+       if (!System_Reflection_PropertyInfo)
+               System_Reflection_PropertyInfo = mono_class_from_name (
+                       mono_defaults.corlib, "System.Reflection", "PropertyInfo");
+
        domain = ((MonoObject *)type)->vtable->domain;
+       if (type->type->byref)
+               return mono_array_new (domain, System_Reflection_PropertyInfo, 0);
        klass = startklass = mono_class_from_mono_type (type->type);
        if (name != NULL) {
                propname = mono_string_to_utf8 (name);
                compare_func = (ignore_case) ? g_strcasecmp : strcmp;
        }
 
+       if (klass->vtable_size >= sizeof (method_slots_default) * 8) {
+               method_slots = g_new0 (guint32, klass->vtable_size / 32 + 1);
+       } else {
+               method_slots = method_slots_default;
+               memset (method_slots, 0, sizeof (method_slots_default));
+       }
 handle_parent:
-       for (i = 0; i < klass->property.count; ++i) {
-               prop = &klass->properties [i];
+       mono_class_setup_vtable (klass);
+       iter = NULL;
+       while ((prop = mono_class_get_properties (klass, &iter))) {
                match = 0;
                method = prop->get;
                if (!method)
@@ -2979,14 +3180,14 @@ handle_parent:
                }
                
                if (prop->get && prop->get->slot != -1) {
-                       if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (prop->get->slot)))
+                       if (method_slots [prop->get->slot >> 5] & (1 << (prop->get->slot & 0x1f)))
                                continue;
-                       g_hash_table_insert (method_slots, GUINT_TO_POINTER (prop->get->slot), prop);
+                       method_slots [prop->get->slot >> 5] |= 1 << (prop->get->slot & 0x1f);
                }
                if (prop->set && prop->set->slot != -1) {
-                       if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (prop->set->slot)))
+                       if (method_slots [prop->set->slot >> 5] & (1 << (prop->set->slot & 0x1f)))
                                continue;
-                       g_hash_table_insert (method_slots, GUINT_TO_POINTER (prop->set->slot), prop);
+                       method_slots [prop->set->slot >> 5] |= 1 << (prop->set->slot & 0x1f);
                }
 
                l = g_slist_prepend (l, mono_property_get_object (domain, startklass, prop));
@@ -2996,9 +3197,6 @@ handle_parent:
                goto handle_parent;
 
        g_free (propname);
-       if (!System_Reflection_PropertyInfo)
-               System_Reflection_PropertyInfo = mono_class_from_name (
-                       mono_defaults.corlib, "System.Reflection", "PropertyInfo");
        res = mono_array_new (domain, System_Reflection_PropertyInfo, len);
        i = 0;
 
@@ -3007,7 +3205,8 @@ handle_parent:
        for (; tmp; tmp = tmp->next, ++i)
                mono_array_set (res, gpointer, i, tmp->data);
        g_slist_free (l);
-       g_hash_table_destroy (method_slots);
+       if (method_slots != method_slots_default)
+               g_free (method_slots);
        return res;
 }
 
@@ -3016,7 +3215,7 @@ ves_icall_MonoType_GetEvent (MonoReflectionType *type, MonoString *name, guint32
 {
        MonoDomain *domain;
        MonoClass *klass, *startklass;
-       gint i;
+       gpointer iter;
        MonoEvent *event;
        MonoMethod *method;
        gchar *event_name;
@@ -3024,12 +3223,14 @@ ves_icall_MonoType_GetEvent (MonoReflectionType *type, MonoString *name, guint32
        MONO_ARCH_SAVE_REGS;
 
        event_name = mono_string_to_utf8 (name);
+       if (type->type->byref)
+               return NULL;
        klass = startklass = mono_class_from_mono_type (type->type);
        domain = mono_object_domain (type);
 
 handle_parent: 
-       for (i = 0; i < klass->event.count; i++) {
-               event = &klass->events [i];
+       iter = NULL;
+       while ((event = mono_class_get_events (klass, &iter))) {
                if (strcmp (event->name, event_name))
                        continue;
 
@@ -3073,15 +3274,22 @@ ves_icall_Type_GetEvents_internal (MonoReflectionType *type, guint32 bflags, Mon
        MonoMethod *method;
        MonoEvent *event;
        int i, len, match;
+       gpointer iter;
 
        MONO_ARCH_SAVE_REGS;
 
-       domain = ((MonoObject *)type)->vtable->domain;
+       if (!System_Reflection_EventInfo)
+               System_Reflection_EventInfo = mono_class_from_name (
+                       mono_defaults.corlib, "System.Reflection", "EventInfo");
+
+       domain = mono_object_domain (type);
+       if (type->type->byref)
+               return mono_array_new (domain, System_Reflection_EventInfo, 0);
        klass = startklass = mono_class_from_mono_type (type->type);
 
 handle_parent: 
-       for (i = 0; i < klass->event.count; ++i) {
-               event = &klass->events [i];
+       iter = NULL;
+       while ((event = mono_class_get_events (klass, &iter))) {
                match = 0;
                method = event->add;
                if (!method)
@@ -3124,9 +3332,6 @@ handle_parent:
        if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
                goto handle_parent;
        len = g_slist_length (l);
-       if (!System_Reflection_EventInfo)
-               System_Reflection_EventInfo = mono_class_from_name (
-                       mono_defaults.corlib, "System.Reflection", "EventInfo");
        res = mono_array_new (domain, System_Reflection_EventInfo, len);
        i = 0;
 
@@ -3150,6 +3355,8 @@ ves_icall_Type_GetNestedType (MonoReflectionType *type, MonoString *name, guint3
        MONO_ARCH_SAVE_REGS;
 
        domain = ((MonoObject *)type)->vtable->domain;
+       if (type->type->byref)
+               return NULL;
        klass = startklass = mono_class_from_mono_type (type->type);
        str = mono_string_to_utf8 (name);
 
@@ -3192,6 +3399,8 @@ ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags)
        MONO_ARCH_SAVE_REGS;
 
        domain = ((MonoObject *)type)->vtable->domain;
+       if (type->type->byref)
+               return mono_array_new (domain, mono_defaults.monotype_class, 0);
        klass = startklass = mono_class_from_mono_type (type->type);
 
        for (tmpn = klass->nested_classes; tmpn; tmpn = tmpn->next) {
@@ -3236,7 +3445,7 @@ ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly *as
                g_list_free (info.modifiers);
                g_list_free (info.nested);
                if (throwOnError) /* uhm: this is a parse error, though... */
-                       mono_raise_exception (mono_get_exception_type_load (name));
+                       mono_raise_exception (mono_get_exception_type_load (name, NULL));
                /*g_print ("failed parse\n");*/
                return NULL;
        }
@@ -3279,13 +3488,25 @@ ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly *as
        g_list_free (info.nested);
        if (!type) {
                if (throwOnError)
-                       mono_raise_exception (mono_get_exception_type_load (name));
+                       mono_raise_exception (mono_get_exception_type_load (name, NULL));
                /* g_print ("failed find\n"); */
                return NULL;
        }
+
+       if (type->type == MONO_TYPE_CLASS) {
+               MonoClass *klass = mono_type_get_class (type);
+               /* need to report exceptions ? */
+               if (throwOnError && klass->exception_type) {
+                       /* report SecurityException (or others) that occured when loading the assembly */
+                       MonoException *exc = mono_class_get_exception_for_failure (klass);
+                       mono_raise_exception (exc);
+               } else if (klass->exception_type == MONO_EXCEPTION_SECURITY_INHERITANCEDEMAND) {
+                       return NULL;
+               }
+       }
+
        /* g_print ("got it\n"); */
        return mono_type_get_object (mono_object_domain (assembly), type);
-
 }
 
 static MonoString *
@@ -3349,6 +3570,14 @@ ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssembly *assem
        return res;
 }
 
+static MonoBoolean
+ves_icall_System_Reflection_Assembly_get_ReflectionOnly (MonoReflectionAssembly *assembly)
+{
+       MONO_ARCH_SAVE_REGS;
+
+       return assembly->assembly->ref_only;
+}
+
 static MonoString *
 ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion (MonoReflectionAssembly *assembly)
 {
@@ -3394,6 +3623,36 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAss
        return result;
 }
 
+static MonoObject*
+create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build, guint32 revision)
+{
+       static MonoClass *System_Version = NULL;
+       static MonoMethod *create_version = NULL;
+       MonoObject *result;
+       gpointer args [4];
+       
+       if (!System_Version) {
+               System_Version = mono_class_from_name (mono_defaults.corlib, "System", "Version");
+               g_assert (System_Version);
+       }
+
+       if (!create_version) {
+               MonoMethodDesc *desc = mono_method_desc_new (":.ctor(int,int,int,int)", FALSE);
+               create_version = mono_method_desc_search_in_class (desc, System_Version);
+               g_assert (create_version);
+               mono_method_desc_free (desc);
+       }
+
+       args [0] = &major;
+       args [1] = &minor;
+       args [2] = &build;
+       args [3] = &revision;
+       result = mono_object_new (domain, System_Version);
+       mono_runtime_invoke (create_version, result, args, NULL);
+
+       return result;
+}
+
 static MonoArray*
 ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAssembly *assembly) 
 {
@@ -3402,6 +3661,7 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
        MonoDomain *domain = mono_object_domain (assembly);
        int i, count = 0;
        static MonoMethod *create_culture = NULL;
+       MonoImage *image = assembly->assembly->image;
        MonoTableInfo *t;
 
        MONO_ARCH_SAVE_REGS;
@@ -3424,57 +3684,49 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
        }
 
        for (i = 0; i < count; i++) {
-               MonoAssembly *assem;
                MonoReflectionAssemblyName *aname;
-               char *codebase, *absolute;
+               guint32 cols [MONO_ASSEMBLYREF_SIZE];
 
-               /* FIXME: There is no need to load the assemblies themselves */
-               mono_assembly_load_reference (assembly->assembly->image, i);
-
-               assem = assembly->assembly->image->references [i];
-               if (assem == (gpointer)-1) {
-                       char *msg = g_strdup_printf ("Assembly %d referenced from assembly %s not found ", i, assembly->assembly->image->name);
-                       MonoException *ex = mono_get_exception_file_not_found2 (msg, NULL);
-                       g_free (msg);
-                       mono_raise_exception (ex);
-               }
+               mono_metadata_decode_row (t, i, cols, MONO_ASSEMBLYREF_SIZE);
 
                aname = (MonoReflectionAssemblyName *) mono_object_new (
                        domain, System_Reflection_AssemblyName);
 
-               aname->name = mono_string_new (domain, assem->aname.name);
+               aname->name = mono_string_new (domain, mono_metadata_string_heap (image, cols [MONO_ASSEMBLYREF_NAME]));
 
-               aname->major = assem->aname.major;
-               aname->minor = assem->aname.minor;
-               aname->build = assem->aname.build;
-               aname->revision = assem->aname.revision;
-               aname->revision = assem->aname.revision;
-               aname->hashalg = assem->aname.hash_alg;
-               aname->flags = assem->aname.flags;
+               aname->major = cols [MONO_ASSEMBLYREF_MAJOR_VERSION];
+               aname->minor = cols [MONO_ASSEMBLYREF_MINOR_VERSION];
+               aname->build = cols [MONO_ASSEMBLYREF_BUILD_NUMBER];
+               aname->revision = cols [MONO_ASSEMBLYREF_REV_NUMBER];
+               aname->flags = cols [MONO_ASSEMBLYREF_FLAGS];
+               aname->versioncompat = 1; /* SameMachine (default) */
+               aname->hashalg = ASSEMBLY_HASH_SHA1; /* SHA1 (default) */
+               aname->version = create_version (domain, aname->major, aname->minor, aname->build, aname->revision);
 
                if (create_culture) {
                        gpointer args [1];
-                       args [0] = mono_string_new (domain, assem->aname.culture);
+                       args [0] = mono_string_new (domain, mono_metadata_string_heap (image, cols [MONO_ASSEMBLYREF_CULTURE]));
                        aname->cultureInfo = mono_runtime_invoke (create_culture, NULL, args, NULL);
                }
-
-               if (assem->aname.public_key) {
-                       guint32 pkey_len;
-                       const char *pkey_ptr = assem->aname.public_key;
-                       pkey_len = mono_metadata_decode_blob_size (pkey_ptr, &pkey_ptr);
-
-                       aname->publicKey = mono_array_new (domain, mono_defaults.byte_class, pkey_len);
-                       memcpy (mono_array_addr (aname->publicKey, guint8, 0), pkey_ptr, pkey_len);
+               
+               if (cols [MONO_ASSEMBLYREF_PUBLIC_KEY]) {
+                       const gchar *pkey_ptr = mono_metadata_blob_heap (image, cols [MONO_ASSEMBLYREF_PUBLIC_KEY]);
+                       guint32 pkey_len = mono_metadata_decode_blob_size (pkey_ptr, &pkey_ptr);
+
+                       if ((cols [MONO_ASSEMBLYREF_FLAGS] & ASSEMBLYREF_FULL_PUBLIC_KEY_FLAG)) {
+                               /* public key token isn't copied - the class library will 
+                               automatically generate it from the public key if required */
+                               aname->publicKey = mono_array_new (domain, mono_defaults.byte_class, pkey_len);
+                               memcpy (mono_array_addr (aname->publicKey, guint8, 0), pkey_ptr, pkey_len);
+                       } else {
+                               aname->keyToken = mono_array_new (domain, mono_defaults.byte_class, pkey_len);
+                               memcpy (mono_array_addr (aname->keyToken, guint8, 0), pkey_ptr, pkey_len);
+                       }
                }
+               
+               /* note: this function doesn't return the codebase on purpose (i.e. it can
+                        be used under partial trust as path information isn't present). */
 
-               /* public key token isn't copied - the class library will 
-                  automatically generate it from the public key if required */
-
-               absolute = g_build_filename (assem->basedir, assem->image->module_name, NULL);
-               codebase = g_filename_to_uri (absolute, NULL, NULL);
-               aname->codebase = mono_string_new (domain, codebase);
-               g_free (codebase);
-               g_free (absolute);
                mono_array_set (result, gpointer, i, aname);
        }
        return result;
@@ -3569,7 +3821,7 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflection
 
        *ref_module = mono_module_get_object (mono_domain_get (), module);
 
-       return (void*)mono_image_get_resource (module, cols [MONO_MANIFEST_OFFSET], size);
+       return (void*)mono_image_get_resource (module, cols [MONO_MANIFEST_OFFSET], (guint32*)size);
 }
 
 static gboolean
@@ -3710,9 +3962,11 @@ ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly
                real_module_count = module_count;
 
                modules = g_new0 (MonoImage*, module_count);
-               for (i = 0; i < mono_array_length (assemblyb->modules); ++i) {
-                       modules [i] = 
-                               mono_array_get (assemblyb->modules, MonoReflectionModuleBuilder*, i)->module.image;
+               if (assemblyb->modules) {
+                       for (i = 0; i < mono_array_length (assemblyb->modules); ++i) {
+                               modules [i] = 
+                                       mono_array_get (assemblyb->modules, MonoReflectionModuleBuilder*, i)->module.image;
+                       }
                }
        }
        else {
@@ -3830,18 +4084,26 @@ ves_icall_System_Reflection_Assembly_GetCallingAssembly (void)
 }
 
 static MonoString *
-ves_icall_System_MonoType_getFullName (MonoReflectionType *object, gboolean full_name)
+ves_icall_System_MonoType_getFullName (MonoReflectionType *object, gboolean full_name,
+                                      gboolean assembly_qualified)
 {
        MonoDomain *domain = mono_object_domain (object); 
+       MonoTypeNameFormat format;
        MonoString *res;
        gchar *name;
 
        MONO_ARCH_SAVE_REGS;
-
        if (full_name)
-               name = mono_type_get_full_name (object->type);
+               format = assembly_qualified ?
+                       MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED :
+                       MONO_TYPE_NAME_FORMAT_FULL_NAME;
        else
-               name = mono_type_get_name (object->type);
+               format = MONO_TYPE_NAME_FORMAT_REFLECTION;
+       name = mono_type_get_name_full (object->type, format);
+       if (!name)
+               return NULL;
+
        res = mono_string_new (domain, name);
        g_free (name);
 
@@ -3849,7 +4111,7 @@ ves_icall_System_MonoType_getFullName (MonoReflectionType *object, gboolean full
 }
 
 static void
-fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute)
+fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute, gboolean by_default_version)
 {
        static MonoMethod *create_culture = NULL;
        gpointer args [1];
@@ -3865,7 +4127,9 @@ fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *a
        aname->build = name->build;
        aname->revision = name->revision;
        aname->hashalg = name->hash_alg;
-
+       if (by_default_version)
+               aname->version = create_version (domain, name->major, name->minor, name->build, name->revision);
+       
        codebase = g_filename_to_uri (absolute, NULL, NULL);
        if (codebase) {
                aname->codebase = mono_string_new (domain, codebase);
@@ -3879,12 +4143,13 @@ fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *a
                mono_method_desc_free (desc);
        }
 
-       args [0] = mono_string_new (domain, name->culture);
-       aname->cultureInfo = 
-               mono_runtime_invoke (create_culture, NULL, args, NULL);
+       if (name->culture) {
+               args [0] = mono_string_new (domain, name->culture);
+               aname->cultureInfo = mono_runtime_invoke (create_culture, NULL, args, NULL);
+       }
 
        if (name->public_key) {
-               pkey_ptr = name->public_key;
+               pkey_ptr = (char*)name->public_key;
                pkey_len = mono_metadata_decode_blob_size (pkey_ptr, &pkey_ptr);
 
                aname->publicKey = mono_array_new (domain, mono_defaults.byte_class, pkey_len);
@@ -3917,7 +4182,7 @@ ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly,
        absolute = g_build_filename (assembly->assembly->basedir, assembly->assembly->image->module_name, NULL);
 
        fill_reflection_assembly_name (mono_object_domain (assembly), aname, 
-                                                                  &assembly->assembly->aname, absolute);
+                                                                  &assembly->assembly->aname, absolute, TRUE);
 
        g_free (absolute);
 }
@@ -3952,7 +4217,7 @@ ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoString *fname,
                mono_raise_exception (mono_get_exception_argument ("assemblyFile", "The file does not contain a manifest"));
        }
 
-       fill_reflection_assembly_name (mono_domain_get (), aname, &name, filename);
+       fill_reflection_assembly_name (mono_domain_get (), aname, &name, filename, TRUE);
 
        g_free (filename);
        mono_image_close (image);
@@ -4129,10 +4394,70 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
                                }
                        }
                }
-       }               
+       }
+
+       if (mono_is_security_manager_active ()) {
+               /* the ReflectionTypeLoadException must have all the types (Types property), 
+                * NULL replacing types which throws an exception. The LoaderException must
+                * contains all exceptions for NULL items.
+                */
+
+               guint32 len = mono_array_length (res);
+               GList *list = NULL;
+
+               for (i = 0; i < len; i++) {
+                       MonoReflectionType *t = mono_array_get (res, gpointer, i);
+                       MonoClass *klass = mono_type_get_class (t->type);
+                       if ((klass != NULL) && klass->exception_type) {
+                               /* keep the class in the list */
+                               list = g_list_append (list, klass);
+                               /* and replace Type with NULL */
+                               mono_array_set (res, gpointer, i, NULL);
+                       }
+               }
+
+               if (list) {
+                       GList *tmp = NULL;
+                       MonoException *exc = NULL;
+                       int length = g_list_length (list);
+
+                       MonoArray *exl = mono_array_new (domain, mono_defaults.exception_class, length);
+                       for (i = 0, tmp = list; i < length; i++, tmp = tmp->next) {
+                               MonoException *exc = mono_class_get_exception_for_failure (tmp->data);
+                               mono_array_set (exl, gpointer, i, exc);
+                       }
+                       g_list_free (list);
+                       list = NULL;
+
+                       exc = mono_get_exception_reflection_type_load (res, exl);
+                       mono_raise_exception (exc);
+               }
+       }
+               
        return res;
 }
 
+static gboolean
+ves_icall_System_Reflection_AssemblyName_ParseName (MonoReflectionAssemblyName *name, MonoString *assname)
+{
+       MonoAssemblyName aname;
+       MonoDomain *domain = mono_object_domain (name);
+       char *val;
+       gboolean is_version_defined;
+
+       val = mono_string_to_utf8 (assname);
+       if (!mono_assembly_name_parse_full (val, &aname, TRUE, &is_version_defined))
+               return FALSE;
+       
+       fill_reflection_assembly_name (domain, name, &aname, "", is_version_defined);
+
+       mono_assembly_name_free (&aname);
+       g_free ((guint8*) aname.public_key);
+       g_free (val);
+
+       return TRUE;
+}
+
 static MonoReflectionType*
 ves_icall_System_Reflection_Module_GetGlobalType (MonoReflectionModule *module)
 {
@@ -4516,7 +4841,9 @@ ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, Mon
 static void
 ves_icall_System_Delegate_FreeTrampoline (MonoDelegate *this)
 {
-       mono_delegate_free_ftnptr (this);
+       /*
+       Delegates have a finalizer only when needed, now.
+       mono_delegate_free_ftnptr (this);*/
 }
 
 /*
@@ -4861,7 +5188,7 @@ ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 val
 static MonoBoolean
 ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count) 
 {
-       char *src_buf, *dest_buf;
+       guint8 *src_buf, *dest_buf;
 
        MONO_ARCH_SAVE_REGS;
 
@@ -4869,8 +5196,8 @@ ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, Mo
        if ((src_offset > mono_array_get_byte_length (src) - count) || (dest_offset > mono_array_get_byte_length (dest) - count))
                return FALSE;
 
-       src_buf = (gint8 *)src->vector + src_offset;
-       dest_buf = (gint8 *)dest->vector + dest_offset;
+       src_buf = (guint8 *)src->vector + src_offset;
+       dest_buf = (guint8 *)dest->vector + dest_offset;
 
        if (src != dest)
                memcpy (dest_buf, src_buf, count);
@@ -5054,6 +5381,8 @@ ves_icall_System_Environment_Exit (int result)
 {
        MONO_ARCH_SAVE_REGS;
 
+       mono_runtime_set_shutting_down ();
+
        /* Suspend all managed threads since the runtime is going away */
        mono_thread_suspend_all_other_threads ();
 
@@ -5095,12 +5424,13 @@ static MonoArray *
 ves_icall_System_Environment_GetLogicalDrives (void)
 {
         gunichar2 buf [128], *ptr, *dname;
-       gchar *u8;
+       gunichar2 *u16;
        gint initial_size = 127, size = 128;
        gint ndrives;
        MonoArray *result;
        MonoString *drivestr;
        MonoDomain *domain = mono_domain_get ();
+       gint len;
 
        MONO_ARCH_SAVE_REGS;
 
@@ -5130,9 +5460,10 @@ ves_icall_System_Environment_GetLogicalDrives (void)
        result = mono_array_new (domain, mono_defaults.string_class, ndrives);
        ndrives = 0;
        do {
-               u8 = g_utf16_to_utf8 (dname, -1, NULL, NULL, NULL);
-               drivestr = mono_string_new (domain, u8);
-               g_free (u8);
+               len = 0;
+               u16 = dname;
+               while (*u16) { u16++; len ++; }
+               drivestr = mono_string_new_utf16 (domain, dname, len);
                mono_array_set (result, gpointer, ndrives++, drivestr);
                while (*dname++);
        } while (*dname);
@@ -5323,7 +5654,7 @@ ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
 
        MONO_ARCH_SAVE_REGS;
 
-       path = g_build_path (G_DIR_SEPARATOR_S, mono_get_config_dir (), "mono", mono_get_framework_version (), "machine.config", NULL);
+       path = g_build_path (G_DIR_SEPARATOR_S, mono_get_config_dir (), "mono", mono_get_runtime_info ()->framework_version, "machine.config", NULL);
 
 #if defined (PLATFORM_WIN32)
        /* Avoid mixing '/' and '\\' */
@@ -5369,7 +5700,7 @@ static void
 ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString (MonoString *message)
 {
 #if defined (PLATFORM_WIN32)
-       static void (*output_debug) (gchar *);
+       static void (*output_debug) (gunichar2 *);
        static gboolean tried_loading = FALSE;
 
        MONO_ARCH_SAVE_REGS;
@@ -5439,15 +5770,20 @@ ves_icall_MonoMethod_get_base_definition (MonoReflectionMethod *m)
        if (klass->generic_class)
                klass = klass->generic_class->container_class;
 
+       mono_class_setup_vtable (klass);
+       mono_class_setup_vtable (method->klass);
        while (result == NULL && klass != NULL && (klass->vtable_size > method->slot))
        {
+               mono_class_setup_vtable (klass);
+
                result = klass->vtable [method->slot];
                if (result == NULL) {
+                       MonoMethod* m;
+                       gpointer iter = NULL;
                        /* It is an abstract method */
-                       int i;
-                       for (i=0; i<klass->method.count; i++) {
-                               if (klass->methods [i]->slot == method->slot) {
-                                       result = klass->methods [i];
+                       while ((m = mono_class_get_methods (klass, &iter))) {
+                               if (m->slot == method->slot) {
+                                       result = m;
                                        break;
                                }
                        }
@@ -5610,12 +5946,12 @@ static void
 ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionType *type)
 {
        MonoClass *klass = mono_class_from_mono_type (type->type);
-       int i;
+       MonoMethod* m;
+       gpointer iter = NULL;
        MONO_ARCH_SAVE_REGS;
 
-       mono_class_init (klass);
-       for (i = 0; i < klass->method.count; ++i)
-               prelink_method (klass->methods [i]);
+       while ((m = mono_class_get_methods (klass, &iter)))
+               prelink_method (m);
 }
 
 /* These parameters are "readonly" in corlib/System/Char.cs */
@@ -5637,21 +5973,10 @@ ves_icall_System_Char_GetDataTablePointers (guint8 const **category_data,
        *to_upper_data_high = ToUpperDataHigh;
 }
 
-static MonoString *
-ves_icall_MonoDebugger_check_runtime_version (MonoString *fname)
+static gint32
+ves_icall_MonoDebugger_GetMethodToken (MonoReflectionMethod *method)
 {
-       gchar *filename, *error = NULL;
-
-       MONO_ARCH_SAVE_REGS;
-
-       filename = mono_string_to_utf8 (fname);
-       error = mono_debugger_check_runtime_version (filename);
-       g_free (filename);
-
-       if (error)
-               return mono_string_new (mono_domain_get (), error);
-       else
-               return NULL;
+       return method->method->token;
 }
 
 static MonoBoolean
@@ -5669,6 +5994,138 @@ custom_attrs_defined_internal (MonoObject *obj, MonoReflectionType *attr_type)
        return found;
 }
 
+static MonoArray*
+custom_attrs_get_by_type (MonoObject *obj, MonoReflectionType *attr_type)
+{
+       return mono_reflection_get_custom_attrs_by_type (obj, attr_type ? mono_class_from_mono_type (attr_type->type) : NULL);
+}
+
+static MonoBoolean
+GCHandle_CheckCurrentDomain (guint32 gchandle)
+{
+       return mono_gchandle_is_in_domain (gchandle, mono_domain_get ());
+}
+
+static MonoString*
+ves_icall_Mono_Runtime_GetDisplayName (void)
+{
+       char *display_name_str = g_strdup_printf ("Mono %s", VERSION);
+       MonoString *display_name = mono_string_new (mono_domain_get (), display_name_str);
+       g_free (display_name_str);
+       return display_name;
+}
+
+static guchar dbase64 [] = {
+       128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+       128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+       128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 62, 128, 128, 128, 63,
+       52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 0, 128, 128,
+       128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+       15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 128, 128, 128, 128, 128,
+       128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+       41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
+       };
+
+static MonoArray *
+base64_to_byte_array (gunichar2 *start, gint ilength, MonoBoolean allowWhitespaceOnly)
+{
+       gint ignored;
+       gint i;
+       gunichar2 c;
+       gunichar2 last, prev_last;
+       gint olength;
+       MonoArray *result;
+       guchar *res_ptr;
+       gint a [4], b [4];
+       MonoException *exc;
+
+       ignored = 0;
+       last = prev_last = 0;
+       for (i = 0; i < ilength; i++) {
+               c = start [i];
+               if (c >= sizeof (dbase64)) {
+                       exc = mono_exception_from_name_msg (mono_get_corlib (),
+                               "System", "FormatException",
+                               "Invalid character found.");
+                       mono_raise_exception (exc);
+               } else if (isspace (c)) {
+                       ignored++;
+               } else {
+                       prev_last = last;
+                       last = c;
+               }
+       }
+
+       olength = ilength - ignored;
+
+       if (allowWhitespaceOnly && olength == 0) {
+               return mono_array_new (mono_domain_get (), mono_defaults.byte_class, 0);
+       }
+
+       if ((olength & 3) != 0 || olength <= 0) {
+               exc = mono_exception_from_name_msg (mono_get_corlib (), "System",
+                                       "FormatException", "Invalid length.");
+               mono_raise_exception (exc);
+       }
+
+       olength = (olength * 3) / 4;
+       if (last == '=')
+               olength--;
+
+       if (prev_last == '=')
+               olength--;
+
+       result = mono_array_new (mono_domain_get (), mono_defaults.byte_class, olength);
+       res_ptr = mono_array_addr (result, guchar, 0);
+       for (i = 0; i < ilength; ) {
+               int k;
+
+               for (k = 0; k < 4 && i < ilength;) {
+                       c = start [i++];
+                       if (isspace (c))
+                               continue;
+
+                       a [k] = (guchar) c;
+                       if (((b [k] = dbase64 [c]) & 0x80) != 0) {
+                               exc = mono_exception_from_name_msg (mono_get_corlib (),
+                                       "System", "FormatException",
+                                       "Invalid character found.");
+                               mono_raise_exception (exc);
+                       }
+                       k++;
+               }
+
+               *res_ptr++ = (b [0] << 2) | (b [1] >> 4);
+               if (a [2] != '=')
+                       *res_ptr++ = (b [1] << 4) | (b [2] >> 2);
+               if (a [3] != '=')
+                       *res_ptr++ = (b [2] << 6) | b [3];
+
+               while (i < ilength && isspace (start [i]))
+                       i++;
+       }
+
+       return result;
+}
+
+static MonoArray *
+InternalFromBase64String (MonoString *str, MonoBoolean allowWhitespaceOnly)
+{
+       MONO_ARCH_SAVE_REGS;
+
+       return base64_to_byte_array (mono_string_chars (str), 
+               mono_string_length (str), allowWhitespaceOnly);
+}
+
+static MonoArray *
+InternalFromBase64CharArray (MonoArray *input, gint offset, gint length)
+{
+       MONO_ARCH_SAVE_REGS;
+
+       return base64_to_byte_array (mono_array_addr (input, gunichar2, offset),
+               length, FALSE);
+}
+
 /* icall map */
 typedef struct {
        const char *method;
@@ -5681,6 +6138,10 @@ typedef struct {
        const int size;
 } IcallMap;
 
+static const IcallEntry runtime_icalls [] = {
+       {"GetDisplayName", ves_icall_Mono_Runtime_GetDisplayName}
+};
+
 static const IcallEntry activator_icalls [] = {
        {"CreateInstanceInternal", ves_icall_System_Activator_CreateInstanceInternal}
 };
@@ -5738,9 +6199,7 @@ static const IcallEntry buffer_icalls [] = {
 };
 
 static const IcallEntry char_icalls [] = {
-       {"GetDataTablePointers", ves_icall_System_Char_GetDataTablePointers},
-       {"InternalToLower(char,System.Globalization.CultureInfo)", ves_icall_System_Char_InternalToLower_Comp},
-       {"InternalToUpper(char,System.Globalization.CultureInfo)", ves_icall_System_Char_InternalToUpper_Comp}
+       {"GetDataTablePointers", ves_icall_System_Char_GetDataTablePointers}
 };
 
 static const IcallEntry defaultconf_icalls [] = {
@@ -5752,7 +6211,12 @@ static const IcallEntry consoledriver_icalls [] = {
        {"Isatty", ves_icall_System_ConsoleDriver_Isatty },
        {"SetBreak", ves_icall_System_ConsoleDriver_SetBreak },
        {"SetEcho", ves_icall_System_ConsoleDriver_SetEcho },
-       {"TtySetup", ves_icall_System_ConsoleDriver_TtySetup },
+       {"TtySetup", ves_icall_System_ConsoleDriver_TtySetup }
+};
+
+static const IcallEntry convert_icalls [] = {
+       {"InternalFromBase64CharArray", InternalFromBase64CharArray },
+       {"InternalFromBase64String", InternalFromBase64String }
 };
 
 static const IcallEntry timezone_icalls [] = {
@@ -5856,6 +6320,11 @@ static const IcallEntry cultureinfo_icalls [] = {
        {"internal_is_lcid_neutral", ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral}
 };
 
+static const IcallEntry regioninfo_icalls [] = {
+       {"construct_internal_region_from_lcid", ves_icall_System_Globalization_RegionInfo_construct_internal_region_from_lcid},
+       {"construct_internal_region_from_name", ves_icall_System_Globalization_RegionInfo_construct_internal_region_from_name}
+};
+
 static const IcallEntry compareinfo_icalls [] = {
        {"assign_sortkey(object,string,System.Globalization.CompareOptions)", ves_icall_System_Globalization_CompareInfo_assign_sortkey},
        {"construct_compareinfo(string)", ves_icall_System_Globalization_CompareInfo_construct_compareinfo},
@@ -5890,23 +6359,18 @@ static const IcallEntry path_icalls [] = {
 };
 
 static const IcallEntry monoio_icalls [] = {
-       {"BeginRead", ves_icall_System_IO_MonoIO_BeginRead },
-       {"BeginWrite", ves_icall_System_IO_MonoIO_BeginWrite },
        {"Close(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Close},
        {"CopyFile(string,string,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CopyFile},
        {"CreateDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CreateDirectory},
        {"CreatePipe(intptr&,intptr&)", ves_icall_System_IO_MonoIO_CreatePipe},
        {"DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile},
-       {"FindClose(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindClose},
-       {"FindFirstFile(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindFirstFile},
-       {"FindNextFile(intptr,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindNextFile},
        {"Flush(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Flush},
        {"GetCurrentDirectory(System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetCurrentDirectory},
        {"GetFileAttributes(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileAttributes},
        {"GetFileStat(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileStat},
+       {"GetFileSystemEntries", ves_icall_System_IO_MonoIO_GetFileSystemEntries},
        {"GetFileType(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileType},
        {"GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength},
-       {"GetSupportsAsync", ves_icall_System_IO_MonoIO_GetSupportsAsync},
        {"GetTempPath(string&)", ves_icall_System_IO_MonoIO_GetTempPath},
        {"Lock(intptr,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Lock},
        {"MoveFile(string,string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_MoveFile},
@@ -5952,7 +6416,8 @@ static const IcallEntry math_icalls [] = {
 };
 
 static const IcallEntry customattrs_icalls [] = {
-       {"GetCustomAttributesInternal", mono_reflection_get_custom_attrs},
+       {"GetCustomAttributesDataInternal", mono_reflection_get_custom_attrs_data},
+       {"GetCustomAttributesInternal", custom_attrs_get_by_type},
        {"IsDefinedInternal", custom_attrs_defined_internal}
 };
 
@@ -5973,6 +6438,8 @@ static const IcallEntry monotype_icalls [] = {
        {"GetArrayRank", ves_icall_MonoType_GetArrayRank},
        {"GetConstructors", ves_icall_Type_GetConstructors_internal},
        {"GetConstructors_internal", ves_icall_Type_GetConstructors_internal},
+       {"GetCorrespondingInflatedConstructor", ves_icall_MonoType_GetCorrespondingInflatedMethod},
+       {"GetCorrespondingInflatedMethod", ves_icall_MonoType_GetCorrespondingInflatedMethod},
        {"GetElementType", ves_icall_MonoType_GetElementType},
        {"GetEvents_internal", ves_icall_Type_GetEvents_internal},
        {"GetField", ves_icall_Type_GetField},
@@ -5992,7 +6459,6 @@ static const IcallEntry monotype_icalls [] = {
        {"get_BaseType", ves_icall_get_type_parent},
        {"get_DeclaringMethod", ves_icall_MonoType_get_DeclaringMethod},
        {"get_DeclaringType", ves_icall_MonoType_get_DeclaringType},
-       {"get_HasGenericArguments", ves_icall_MonoType_get_HasGenericArguments},
        {"get_IsGenericParameter", ves_icall_MonoType_get_IsGenericParameter},
        {"get_Module", ves_icall_MonoType_get_Module},
        {"get_Name", ves_icall_MonoType_get_Name},
@@ -6023,22 +6489,23 @@ static const IcallEntry assembly_icalls [] = {
        /*
         * Private icalls for the Mono Debugger
         */
-       {"MonoDebugger_CheckRuntimeVersion", ves_icall_MonoDebugger_check_runtime_version},
-       {"MonoDebugger_GetLocalTypeFromSignature", ves_icall_MonoDebugger_GetLocalTypeFromSignature},
-       {"MonoDebugger_GetMethod", ves_icall_MonoDebugger_GetMethod},
        {"MonoDebugger_GetMethodToken", ves_icall_MonoDebugger_GetMethodToken},
-       {"MonoDebugger_GetType", ves_icall_MonoDebugger_GetType},
 
        /* normal icalls again */
        {"get_EntryPoint", ves_icall_System_Reflection_Assembly_get_EntryPoint},
        {"get_ManifestModule", ves_icall_System_Reflection_Assembly_get_ManifestModule},
        {"get_MetadataToken", mono_reflection_get_token},
+       {"get_ReflectionOnly", ves_icall_System_Reflection_Assembly_get_ReflectionOnly},
        {"get_code_base", ves_icall_System_Reflection_Assembly_get_code_base},
        {"get_global_assembly_cache", ves_icall_System_Reflection_Assembly_get_global_assembly_cache},
        {"get_location", ves_icall_System_Reflection_Assembly_get_location},
        {"load_with_partial_name", ves_icall_System_Reflection_Assembly_load_with_partial_name}
 };
 
+static const IcallEntry assembly_name_icalls [] = {
+       {"ParseName", ves_icall_System_Reflection_AssemblyName_ParseName}
+};
+
 static const IcallEntry methodbase_icalls [] = {
        {"GetCurrentMethod", ves_icall_GetCurrentMethod},
        {"GetMethodBodyInternal", ves_icall_System_Reflection_MethodBase_GetMethodBodyInternal},
@@ -6079,6 +6546,9 @@ static const IcallEntry monofield_icalls [] = {
 
 static const IcallEntry monogenericclass_icalls [] = {
        {"GetConstructors_internal", ves_icall_MonoGenericClass_GetConstructors},
+       {"GetCorrespondingInflatedConstructor", ves_icall_MonoGenericClass_GetCorrespondingInflatedConstructor},
+       {"GetCorrespondingInflatedField", ves_icall_MonoGenericClass_GetCorrespondingInflatedField},
+       {"GetCorrespondingInflatedMethod", ves_icall_MonoGenericClass_GetCorrespondingInflatedMethod},
        {"GetEvents_internal", ves_icall_MonoGenericClass_GetEvents},
        {"GetFields_internal", ves_icall_MonoGenericClass_GetFields},
        {"GetInterfaces_internal", ves_icall_MonoGenericClass_GetInterfaces},
@@ -6097,11 +6567,11 @@ static const IcallEntry generictypeparambuilder_icalls [] = {
 };
 
 static const IcallEntry monomethod_icalls [] = {
-       {"BindGenericParameters", mono_reflection_bind_generic_method_parameters},
        {"GetDllImportAttribute", ves_icall_MonoMethod_GetDllImportAttribute},
        {"GetGenericArguments", ves_icall_MonoMethod_GetGenericArguments},
        {"GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition},
        {"InternalInvoke", ves_icall_InternalInvoke},
+       {"MakeGenericMethod", mono_reflection_bind_generic_method_parameters},
        {"get_HasGenericParameters", ves_icall_MonoMethod_get_HasGenericParameters},
        {"get_IsGenericMethodDefinition", ves_icall_MonoMethod_get_IsGenericMethodDefinition},
        {"get_Mono_IsInflatedMethod", ves_icall_MonoMethod_get_Mono_IsInflatedMethod},
@@ -6129,8 +6599,6 @@ static const IcallEntry dns_icalls [] = {
 
 static const IcallEntry socket_icalls [] = {
        {"Accept_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Accept_internal},
-       {"AsyncReceiveInternal", ves_icall_System_Net_Sockets_Socket_AsyncReceive},
-       {"AsyncSendInternal", ves_icall_System_Net_Sockets_Socket_AsyncSend},
        {"Available_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Available_internal},
        {"Bind_internal(intptr,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_Bind_internal},
        {"Blocking_internal(intptr,bool,int&)", ves_icall_System_Net_Sockets_Socket_Blocking_internal},
@@ -6138,14 +6606,13 @@ static const IcallEntry socket_icalls [] = {
        {"Connect_internal(intptr,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_Connect_internal},
        {"GetSocketOption_arr_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,byte[]&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal},
        {"GetSocketOption_obj_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal},
-       {"GetSupportsAsync", ves_icall_System_IO_MonoIO_GetSupportsAsync},
        {"Listen_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_Listen_internal},
        {"LocalEndPoint_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal},
        {"Poll_internal", ves_icall_System_Net_Sockets_Socket_Poll_internal},
        {"Receive_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&)", ves_icall_System_Net_Sockets_Socket_Receive_internal},
        {"RecvFrom_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&)", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal},
        {"RemoteEndPoint_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal},
-       {"Select_internal(System.Net.Sockets.Socket[]&,System.Net.Sockets.Socket[]&,System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal},
+       {"Select_internal(System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal},
        {"SendTo_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_SendTo_internal},
        {"Send_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&)", ves_icall_System_Net_Sockets_Socket_Send_internal},
        {"SetSocketOption_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object,byte[],int,int&)", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal},
@@ -6179,7 +6646,7 @@ static const IcallEntry dynamicmethod_icalls [] = {
 };
 
 static const IcallEntry methodbuilder_icalls [] = {
-       {"BindGenericParameters", mono_reflection_bind_generic_method_parameters}
+       {"MakeGenericMethod", mono_reflection_bind_generic_method_parameters}
 };
 
 static const IcallEntry modulebuilder_icalls [] = {
@@ -6221,6 +6688,7 @@ static const IcallEntry runtimehelpers_icalls [] = {
 };
 
 static const IcallEntry gchandle_icalls [] = {
+       {"CheckCurrentDomain", GCHandle_CheckCurrentDomain},
        {"FreeHandle", ves_icall_System_GCHandle_FreeHandle},
        {"GetAddrOfPinnedObject", ves_icall_System_GCHandle_GetAddrOfPinnedObject},
        {"GetTarget", ves_icall_System_GCHandle_GetTarget},
@@ -6291,7 +6759,8 @@ static const IcallEntry remotingservices_icalls [] = {
 static const IcallEntry rng_icalls [] = {
        {"RngClose", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngClose},
        {"RngGetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngGetBytes},
-       {"RngInitialize", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngInitialize}
+       {"RngInitialize", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngInitialize},
+       {"RngOpen", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngOpen}
 };
 
 static const IcallEntry methodhandle_icalls [] = {
@@ -6307,7 +6776,6 @@ static const IcallEntry string_icalls [] = {
        {".ctor(sbyte*)", ves_icall_System_String_ctor_sbytep},
        {".ctor(sbyte*,int,int)", ves_icall_System_String_ctor_sbytep_int_int},
        {".ctor(sbyte*,int,int,System.Text.Encoding)", ves_icall_System_String_ctor_encoding},
-       {"GetHashCode", ves_icall_System_String_GetHashCode},
        {"InternalAllocateStr", ves_icall_System_String_InternalAllocateStr},
        {"InternalCharCopy", ves_icall_System_String_InternalCharCopy},
        {"InternalCopyTo", ves_icall_System_String_InternalCopyTo},
@@ -6326,8 +6794,6 @@ static const IcallEntry string_icalls [] = {
        {"InternalStrcpy(string,int,char[],int,int)", ves_icall_System_String_InternalStrcpy_CharsN},
        {"InternalStrcpy(string,int,string)", ves_icall_System_String_InternalStrcpy_Str},
        {"InternalStrcpy(string,int,string,int,int)", ves_icall_System_String_InternalStrcpy_StrN},
-       {"InternalToLower(System.Globalization.CultureInfo)", ves_icall_System_String_InternalToLower_Comp},
-       {"InternalToUpper(System.Globalization.CultureInfo)", ves_icall_System_String_InternalToUpper_Comp},
        {"InternalTrim", ves_icall_System_String_InternalTrim},
        {"get_Chars", ves_icall_System_String_get_Chars}
 };
@@ -6347,16 +6813,25 @@ static const IcallEntry monitor_icalls [] = {
 };
 
 static const IcallEntry interlocked_icalls [] = {
+    {"Add(int&,int)", ves_icall_System_Threading_Interlocked_Add_Int},
+       {"Add(long&,long)", ves_icall_System_Threading_Interlocked_Add_Long},
+    {"CompareExchange(double&,double,double)", ves_icall_System_Threading_Interlocked_CompareExchange_Double},
        {"CompareExchange(int&,int,int)", ves_icall_System_Threading_Interlocked_CompareExchange_Int},
+       {"CompareExchange(intptr&,intptr,intptr)", ves_icall_System_Threading_Interlocked_CompareExchange_Object},
+       {"CompareExchange(long&,long,long)", ves_icall_System_Threading_Interlocked_CompareExchange_Long},
        {"CompareExchange(object&,object,object)", ves_icall_System_Threading_Interlocked_CompareExchange_Object},
        {"CompareExchange(single&,single,single)", ves_icall_System_Threading_Interlocked_CompareExchange_Single},
        {"Decrement(int&)", ves_icall_System_Threading_Interlocked_Decrement_Int},
        {"Decrement(long&)", ves_icall_System_Threading_Interlocked_Decrement_Long},
+       {"Exchange(double&,double)", ves_icall_System_Threading_Interlocked_Exchange_Double},
        {"Exchange(int&,int)", ves_icall_System_Threading_Interlocked_Exchange_Int},
+       {"Exchange(intptr&,intptr)", ves_icall_System_Threading_Interlocked_Exchange_Object},
+       {"Exchange(long&,long)", ves_icall_System_Threading_Interlocked_Exchange_Long},
        {"Exchange(object&,object)", ves_icall_System_Threading_Interlocked_Exchange_Object},
        {"Exchange(single&,single)", ves_icall_System_Threading_Interlocked_Exchange_Single},
        {"Increment(int&)", ves_icall_System_Threading_Interlocked_Increment_Int},
-       {"Increment(long&)", ves_icall_System_Threading_Interlocked_Increment_Long}
+       {"Increment(long&)", ves_icall_System_Threading_Interlocked_Increment_Long},
+       {"Read(long&)", ves_icall_System_Threading_Interlocked_Read_Long}
 };
 
 static const IcallEntry mutex_icalls [] = {
@@ -6373,6 +6848,7 @@ static const IcallEntry nativeevents_icalls [] = {
 
 static const IcallEntry thread_icalls [] = {
        {"Abort_internal(object)", ves_icall_System_Threading_Thread_Abort},
+       {"ClrState", ves_icall_System_Threading_Thread_ClrState},
        {"CurrentThread_internal", mono_thread_current},
        {"GetCachedCurrentCulture", ves_icall_System_Threading_Thread_GetCachedCurrentCulture},
        {"GetCachedCurrentUICulture", ves_icall_System_Threading_Thread_GetCachedCurrentUICulture},
@@ -6380,7 +6856,9 @@ static const IcallEntry thread_icalls [] = {
        {"GetName_internal", ves_icall_System_Threading_Thread_GetName_internal},
        {"GetSerializedCurrentCulture", ves_icall_System_Threading_Thread_GetSerializedCurrentCulture},
        {"GetSerializedCurrentUICulture", ves_icall_System_Threading_Thread_GetSerializedCurrentUICulture},
+       {"GetState", ves_icall_System_Threading_Thread_GetState},
        {"Join_internal", ves_icall_System_Threading_Thread_Join_internal},
+       {"MemoryBarrier", ves_icall_System_Threading_Thread_MemoryBarrier},
        {"ResetAbort_internal()", ves_icall_System_Threading_Thread_ResetAbort},
        {"Resume_internal()", ves_icall_System_Threading_Thread_Resume},
        {"SetCachedCurrentCulture", ves_icall_System_Threading_Thread_SetCachedCurrentCulture},
@@ -6388,10 +6866,8 @@ static const IcallEntry thread_icalls [] = {
        {"SetName_internal", ves_icall_System_Threading_Thread_SetName_internal},
        {"SetSerializedCurrentCulture", ves_icall_System_Threading_Thread_SetSerializedCurrentCulture},
        {"SetSerializedCurrentUICulture", ves_icall_System_Threading_Thread_SetSerializedCurrentUICulture},
+       {"SetState", ves_icall_System_Threading_Thread_SetState},
        {"Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal},
-       {"SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup},
-       {"SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store},
-       {"Start_internal", ves_icall_System_Threading_Thread_Start_internal},
        {"Suspend_internal", ves_icall_System_Threading_Thread_Suspend},
        {"Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal},
        {"Thread_internal", ves_icall_System_Threading_Thread_Thread_internal},
@@ -6425,7 +6901,6 @@ static const IcallEntry thread_icalls [] = {
 };
 
 static const IcallEntry threadpool_icalls [] = {
-       {"BindHandleInternal", ves_icall_System_Threading_ThreadPool_BindHandle},
        {"GetAvailableThreads", ves_icall_System_Threading_ThreadPool_GetAvailableThreads},
        {"GetMaxThreads", ves_icall_System_Threading_ThreadPool_GetMaxThreads},
        {"GetMinThreads", ves_icall_System_Threading_ThreadPool_GetMinThreads},
@@ -6439,7 +6914,6 @@ static const IcallEntry waithandle_icalls [] = {
 };
 
 static const IcallEntry type_icalls [] = {
-       {"BindGenericParameters", ves_icall_Type_BindGenericParameters},
        {"Equals", ves_icall_type_Equals},
        {"GetGenericParameterAttributes", ves_icall_Type_GetGenericParameterAttributes},
        {"GetGenericParameterConstraints_impl", ves_icall_Type_GetGenericParameterConstraints},
@@ -6447,11 +6921,14 @@ static const IcallEntry type_icalls [] = {
        {"GetGenericTypeDefinition_impl", ves_icall_Type_GetGenericTypeDefinition_impl},
        {"GetInterfaceMapData", ves_icall_Type_GetInterfaceMapData},
        {"GetPacking", ves_icall_Type_GetPacking},
-       {"GetTypeCode", ves_icall_type_GetTypeCode},
+       {"GetTypeCode", ves_icall_type_GetTypeCodeInternal},
+       {"GetTypeCodeInternal", ves_icall_type_GetTypeCodeInternal},
        {"IsArrayImpl", ves_icall_Type_IsArrayImpl},
        {"IsInstanceOfType", ves_icall_type_IsInstanceOfType},
+       {"MakeGenericType", ves_icall_Type_MakeGenericType},
        {"MakePointerType", ves_icall_Type_MakePointerType},
        {"get_IsGenericInstance", ves_icall_Type_get_IsGenericInstance},
+       {"get_IsGenericType", ves_icall_Type_get_IsGenericType},
        {"get_IsGenericTypeDefinition", ves_icall_Type_get_IsGenericTypeDefinition},
        {"internal_from_handle", ves_icall_type_from_handle},
        {"internal_from_name", ves_icall_type_from_name},
@@ -6508,12 +6985,17 @@ static const IcallEntry evidence_icalls [] = {
 };
 
 static const IcallEntry securitymanager_icalls [] = {
+       {"GetLinkDemandSecurity", ves_icall_System_Security_SecurityManager_GetLinkDemandSecurity},
        {"get_CheckExecutionRights", ves_icall_System_Security_SecurityManager_get_CheckExecutionRights},
        {"get_SecurityEnabled", ves_icall_System_Security_SecurityManager_get_SecurityEnabled},
        {"set_CheckExecutionRights", ves_icall_System_Security_SecurityManager_set_CheckExecutionRights},
        {"set_SecurityEnabled", ves_icall_System_Security_SecurityManager_set_SecurityEnabled}
 };
 
+static const IcallEntry generic_array_icalls [] = {
+       {"GetGenericValueImpl", ves_icall_System_Array_InternalArray_GetGenericValueImpl}
+};
+
 /* proto
 static const IcallEntry array_icalls [] = {
 };
@@ -6522,15 +7004,18 @@ static const IcallEntry array_icalls [] = {
 
 /* keep the entries all sorted */
 static const IcallMap icall_entries [] = {
+       {"Mono.Runtime", runtime_icalls, G_N_ELEMENTS (runtime_icalls)},
        {"Mono.Security.Cryptography.KeyPairPersistence", keypair_icalls, G_N_ELEMENTS (keypair_icalls)},
        {"System.Activator", activator_icalls, G_N_ELEMENTS (activator_icalls)},
        {"System.AppDomain", appdomain_icalls, G_N_ELEMENTS (appdomain_icalls)},
        {"System.ArgIterator", argiterator_icalls, G_N_ELEMENTS (argiterator_icalls)},
        {"System.Array", array_icalls, G_N_ELEMENTS (array_icalls)},
+       {"System.Array/InternalArray`1", generic_array_icalls, G_N_ELEMENTS (generic_array_icalls)},
        {"System.Buffer", buffer_icalls, G_N_ELEMENTS (buffer_icalls)},
        {"System.Char", char_icalls, G_N_ELEMENTS (char_icalls)},
        {"System.Configuration.DefaultConfig", defaultconf_icalls, G_N_ELEMENTS (defaultconf_icalls)},
        {"System.ConsoleDriver", consoledriver_icalls, G_N_ELEMENTS (consoledriver_icalls)},
+       {"System.Convert", convert_icalls, G_N_ELEMENTS (convert_icalls)},
        {"System.CurrentTimeZone", timezone_icalls, G_N_ELEMENTS (timezone_icalls)},
        {"System.DateTime", datetime_icalls, G_N_ELEMENTS (datetime_icalls)},
 #ifndef DISABLE_DECIMAL
@@ -6546,6 +7031,7 @@ static const IcallMap icall_entries [] = {
        {"System.GC", gc_icalls, G_N_ELEMENTS (gc_icalls)},
        {"System.Globalization.CompareInfo", compareinfo_icalls, G_N_ELEMENTS (compareinfo_icalls)},
        {"System.Globalization.CultureInfo", cultureinfo_icalls, G_N_ELEMENTS (cultureinfo_icalls)},
+       {"System.Globalization.RegionInfo", regioninfo_icalls, G_N_ELEMENTS (regioninfo_icalls)},
        {"System.IO.FAMWatcher", famwatcher_icalls, G_N_ELEMENTS (famwatcher_icalls)},
        {"System.IO.FileSystemWatcher", filewatcher_icalls, G_N_ELEMENTS (filewatcher_icalls)},
        {"System.IO.MonoIO", monoio_icalls, G_N_ELEMENTS (monoio_icalls)},
@@ -6559,6 +7045,7 @@ static const IcallMap icall_entries [] = {
        {"System.Net.Sockets.SocketException", socketex_icalls, G_N_ELEMENTS (socketex_icalls)},
        {"System.Object", object_icalls, G_N_ELEMENTS (object_icalls)},
        {"System.Reflection.Assembly", assembly_icalls, G_N_ELEMENTS (assembly_icalls)},
+       {"System.Reflection.AssemblyName", assembly_name_icalls, G_N_ELEMENTS (assembly_name_icalls)},
        {"System.Reflection.Emit.AssemblyBuilder", assemblybuilder_icalls, G_N_ELEMENTS (assemblybuilder_icalls)},
        {"System.Reflection.Emit.CustomAttributeBuilder", customattrbuilder_icalls, G_N_ELEMENTS (customattrbuilder_icalls)},
        {"System.Reflection.Emit.DynamicMethod", dynamicmethod_icalls, G_N_ELEMENTS (dynamicmethod_icalls)},
@@ -6726,9 +7213,24 @@ mono_lookup_internal_call (MonoMethod *method)
 
        g_assert (method != NULL);
 
-       typelen = concat_class_name (mname, sizeof (mname), method->klass);
-       if (!typelen)
-               return NULL;
+       if (method->klass->nested_in) {
+               int pos = concat_class_name (mname, sizeof (mname)-2, method->klass->nested_in);
+               if (!pos)
+                       return NULL;
+
+               mname [pos++] = '/';
+               mname [pos] = 0;
+
+               typelen = concat_class_name (mname+pos, sizeof (mname)-pos-1, method->klass);
+               if (!typelen)
+                       return NULL;
+
+               typelen += pos;
+       } else {
+               typelen = concat_class_name (mname, sizeof (mname), method->klass);
+               if (!typelen)
+                       return NULL;
+       }
 
        imap = find_class_icalls (mname);