* test-9.il: New test, test instaniating a class
[mono.git] / mono / metadata / icall.c
index 6daa33829bae0fda23028ccc4b81bae004e77419..594b1bbddb366cc5ae0f0e5cfb525a24d7681a79 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <mono/metadata/object.h>
 #include <mono/metadata/threads.h>
+#include <mono/metadata/monitor.h>
 #include <mono/metadata/reflection.h>
 #include <mono/metadata/assembly.h>
 #include <mono/metadata/tabledefs.h>
 #include <mono/metadata/unicode.h>
 #include <mono/metadata/appdomain.h>
 #include <mono/metadata/marshal.h>
-#include <mono/metadata/gc.h>
+#include <mono/metadata/gc-internal.h>
 #include <mono/metadata/rand.h>
 #include <mono/metadata/sysmath.h>
 #include <mono/metadata/string-icalls.h>
 #include <mono/metadata/debug-mono-symfile.h>
 #include <mono/metadata/process.h>
+#include <mono/metadata/environment.h>
 #include <mono/io-layer/io-layer.h>
 #include <mono/utils/strtod.h>
 
 #endif
 #include "decimal.h"
 
+static MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_GetCallingAssembly (void);
+
+
 static MonoString *
 mono_double_ToStringImpl (double value)
 {
        /* FIXME: Handle formats, etc. */
        MonoString *s;
        gchar *retVal;
+
+       MONO_ARCH_SAVE_REGS;
+
        retVal = g_strdup_printf ("%.15g", value);
        s = mono_string_new (mono_domain_get (), retVal);
        g_free (retVal);
@@ -64,12 +72,27 @@ mono_double_ToStringImpl (double value)
 static double
 mono_double_ParseImpl (char *ptr)
 {
-       return bsd_strtod (ptr, NULL);
+       gchar *endptr = NULL;
+       gdouble result;
+
+       MONO_ARCH_SAVE_REGS;
+
+       if (*ptr)
+               result = bsd_strtod (ptr, &endptr);
+
+       if (!*ptr || (endptr && *endptr))
+               mono_raise_exception (mono_exception_from_name (mono_defaults.corlib,
+                                                               "System",
+                                                               "FormatException"));
+       
+       return result;
 }
 
 static MonoString *
 mono_float_ToStringImpl (float value)
 {
+       MONO_ARCH_SAVE_REGS;
+
        return mono_double_ToStringImpl (value);
 }
 
@@ -81,6 +104,8 @@ ves_icall_System_Array_GetValueImpl (MonoObject *this, guint32 pos)
        gint32 esize;
        gpointer *ea;
 
+       MONO_ARCH_SAVE_REGS;
+
        ao = (MonoArray *)this;
        ac = (MonoClass *)ao->obj.vtable->klass;
 
@@ -100,6 +125,8 @@ ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs)
        MonoArray *ao, *io;
        gint32 i, pos, *ind;
 
+       MONO_ARCH_SAVE_REGS;
+
        MONO_CHECK_ARG_NULL (idxs);
 
        io = (MonoArray *)idxs;
@@ -145,6 +172,8 @@ ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32
        gint64 i64;
        gdouble r64;
 
+       MONO_ARCH_SAVE_REGS;
+
        if (value)
                vc = value->vtable->klass;
        else
@@ -403,6 +432,8 @@ ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value,
        MonoClass *ac, *ic;
        gint32 i, pos, *ind;
 
+       MONO_ARCH_SAVE_REGS;
+
        MONO_CHECK_ARG_NULL (idxs);
 
        ic = idxs->obj.vtable->klass;
@@ -442,6 +473,8 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *
        MonoArray *array;
        gint32 *sizes, i;
 
+       MONO_ARCH_SAVE_REGS;
+
        MONO_CHECK_ARG_NULL (type);
        MONO_CHECK_ARG_NULL (lengths);
 
@@ -472,6 +505,8 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *
 static gint32 
 ves_icall_System_Array_GetRank (MonoObject *this)
 {
+       MONO_ARCH_SAVE_REGS;
+
        return this->vtable->klass->rank;
 }
 
@@ -479,6 +514,9 @@ static gint32
 ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension)
 {
        gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
+
+       MONO_ARCH_SAVE_REGS;
+
        if ((dimension < 0) || (dimension >= rank))
                mono_raise_exception (mono_get_exception_index_out_of_range ());
        
@@ -492,6 +530,9 @@ static gint32
 ves_icall_System_Array_GetLowerBound (MonoArray *this, gint32 dimension)
 {
        gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
+
+       MONO_ARCH_SAVE_REGS;
+
        if ((dimension < 0) || (dimension >= rank))
                mono_raise_exception (mono_get_exception_index_out_of_range ());
        
@@ -508,6 +549,8 @@ ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* d
        void * dest_addr = mono_array_addr_with_size (dest, element_size, dest_idx);
        void * source_addr = mono_array_addr_with_size (source, element_size, source_idx);
 
+       MONO_ARCH_SAVE_REGS;
+
        g_assert (dest_idx + length <= mono_array_length (dest));
        g_assert (source_idx + length <= mono_array_length (source));
        memmove (dest_addr, source_addr, element_size * length);
@@ -520,6 +563,8 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoAr
        guint32 size = mono_array_element_size (klass);
        int i;
 
+       MONO_ARCH_SAVE_REGS;
+
        if (array->bounds == NULL)
                size *= array->max_length;
        else
@@ -564,12 +609,16 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoAr
 static gint
 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData (void)
 {
+       MONO_ARCH_SAVE_REGS;
+
        return offsetof (MonoString, chars);
 }
 
 static MonoObject *
 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObject *obj)
 {
+       MONO_ARCH_SAVE_REGS;
+
        if ((obj == NULL) || (! (obj->vtable->klass->valuetype)))
                return obj;
        else
@@ -581,18 +630,23 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (Mo
 {
        MonoClass *klass;
 
+       MONO_ARCH_SAVE_REGS;
+
        MONO_CHECK_ARG_NULL (handle);
 
        klass = mono_class_from_mono_type (handle);
        MONO_CHECK_ARG (handle, klass);
 
        /* This will call the type constructor */
-       mono_class_vtable (mono_domain_get (), klass);
+       if (! (klass->flags & TYPE_ATTRIBUTE_INTERFACE))
+               mono_class_vtable (mono_domain_get (), klass);
 }
 
 static MonoObject *
 ves_icall_System_Object_MemberwiseClone (MonoObject *this)
 {
+       MONO_ARCH_SAVE_REGS;
+
        return mono_object_clone (this);
 }
 
@@ -614,6 +668,9 @@ static gint32
 ves_icall_System_Object_GetHashCode (MonoObject *this)
 {
        register guint32 key;
+
+       MONO_ARCH_SAVE_REGS;
+
        key = (GPOINTER_TO_UINT (this) >> MONO_OBJECT_ALIGNMENT_SHIFT) * 2654435761u;
 
        return key & 0x7fffffff;
@@ -630,6 +687,8 @@ ves_icall_System_ValueType_GetHashCode (MonoObject *this)
        const char *p;
        guint h = 0;
 
+       MONO_ARCH_SAVE_REGS;
+
        MONO_CHECK_ARG_NULL (this);
 
        size = this->vtable->klass->instance_size - sizeof (MonoObject);
@@ -650,6 +709,8 @@ ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that)
        gint32 size;
        const char *p, *s;
 
+       MONO_ARCH_SAVE_REGS;
+
        MONO_CHECK_ARG_NULL (that);
 
        if (this->vtable != that->vtable)
@@ -666,12 +727,16 @@ ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that)
 static MonoReflectionType *
 ves_icall_System_Object_GetType (MonoObject *obj)
 {
+       MONO_ARCH_SAVE_REGS;
+
        return mono_type_get_object (mono_object_domain (obj), &obj->vtable->klass->byval_arg);
 }
 
 static void
 mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
 {
+       MONO_ARCH_SAVE_REGS;
+
        mtype->type = &obj->vtable->klass->byval_arg;
        g_assert (mtype->type->type);
 }
@@ -679,6 +744,8 @@ mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
 static gint32
 ves_icall_AssemblyBuilder_getToken (MonoReflectionAssemblyBuilder *assb, MonoObject *obj)
 {
+       MONO_ARCH_SAVE_REGS;
+
        return mono_image_create_token (assb->dynamic_assembly, obj);
 }
 
@@ -689,6 +756,8 @@ ves_icall_AssemblyBuilder_getDataChunk (MonoReflectionAssemblyBuilder *assb, Mon
        MonoDynamicAssembly *ass = assb->dynamic_assembly;
        char *p = mono_array_addr (buf, char, 0);
 
+       MONO_ARCH_SAVE_REGS;
+
        mono_image_create_pefile (assb);
 
        if (offset >= ass->pefile.index)
@@ -701,34 +770,63 @@ ves_icall_AssemblyBuilder_getDataChunk (MonoReflectionAssemblyBuilder *assb, Mon
        return count;
 }
 
-static gboolean
-get_get_type_caller (MonoMethod *m, gint32 no, gint32 ilo, gpointer data) {
-       MonoImage **dest = data;
+static void
+ves_icall_AssemblyBuilder_build_metadata (MonoReflectionAssemblyBuilder *assb)
+{
+       MONO_ARCH_SAVE_REGS;
 
-       /* skip icalls and Type::GetType () */
-       if (!m || m->wrapper_type || (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
-                       (strcmp (m->name, "GetType") == 0 && m->klass == mono_defaults.monotype_class->parent))
-               return FALSE;
-       *dest = m->klass->image;
-       return TRUE;
+       mono_image_build_metadata (assb);
 }
 
 static MonoReflectionType*
-ves_icall_type_from_name (MonoString *name)
+ves_icall_type_from_name (MonoString *name,
+                         MonoBoolean throwOnError,
+                         MonoBoolean ignoreCase)
 {
-       MonoImage *image = NULL;
-       MonoType *type;
        gchar *str;
+       MonoType *type = NULL;
+       MonoAssembly *assembly;
+       MonoTypeNameParse info;
+
+       MONO_ARCH_SAVE_REGS;
 
-       mono_stack_walk (get_get_type_caller, &image);
        str = mono_string_to_utf8 (name);
-       /*g_print ("requested type %s\n", str);*/
-       type = mono_reflection_type_from_name (str, image);
+       if (!mono_reflection_parse_type (str, &info)) {
+               g_free (str);
+               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 ());
+
+               return NULL;
+       }
+
+       if (info.assembly.name) {
+               assembly = mono_assembly_load (&info.assembly, NULL, NULL);
+       } else {
+               MonoReflectionAssembly *refass;
+
+               refass = ves_icall_System_Reflection_Assembly_GetCallingAssembly  ();
+               assembly = refass->assembly;
+       }
+
+       if (assembly)
+               type = mono_reflection_get_type (assembly->image, &info, ignoreCase);
+       
+       if (!info.assembly.name && !type) /* try mscorlib */
+               type = mono_reflection_get_type (NULL, &info, ignoreCase);
+
        g_free (str);
-       if (!type)
+       g_list_free (info.modifiers);
+       g_list_free (info.nested);
+       if (!type) {
+               if (throwOnError)
+                       mono_raise_exception (mono_get_exception_type_load ());
+
                return NULL;
-       /*g_print ("got it\n");*/
-       return mono_type_get_object (mono_object_domain (name), type);
+       }
+
+       return mono_type_get_object (mono_domain_get (), type);
 }
 
 static MonoReflectionType*
@@ -737,6 +835,8 @@ ves_icall_type_from_handle (MonoType *handle)
        MonoDomain *domain = mono_domain_get (); 
        MonoClass *klass = mono_class_from_mono_type (handle);
 
+       MONO_ARCH_SAVE_REGS;
+
        mono_class_init (klass);
        return mono_type_get_object (domain, handle);
 }
@@ -744,6 +844,8 @@ ves_icall_type_from_handle (MonoType *handle)
 static guint32
 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");
@@ -776,6 +878,9 @@ static guint32
 ves_icall_type_GetTypeCode (MonoReflectionType *type)
 {
        int t = type->type->type;
+
+       MONO_ARCH_SAVE_REGS;
+
 handle_enum:
        switch (t) {
        case MONO_TYPE_VOID:
@@ -846,6 +951,8 @@ ves_icall_type_is_subtype_of (MonoReflectionType *type, MonoReflectionType *c, M
        MonoClass *klass;
        MonoClass *klassc;
 
+       MONO_ARCH_SAVE_REGS;
+
        g_assert (type != NULL);
        
        domain = ((MonoObject *)type)->vtable->domain;
@@ -885,6 +992,8 @@ ves_icall_get_attributes (MonoReflectionType *type)
 {
        MonoClass *klass = mono_class_from_mono_type (type->type);
 
+       MONO_ARCH_SAVE_REGS;
+
        return klass->flags;
 }
 
@@ -893,6 +1002,8 @@ ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info)
 {
        MonoDomain *domain = mono_domain_get ();
 
+       MONO_ARCH_SAVE_REGS;
+
        info->parent = mono_type_get_object (domain, &method->klass->byval_arg);
        info->ret = mono_type_get_object (domain, method->signature->ret);
        info->attrs = method->flags;
@@ -908,6 +1019,8 @@ ves_icall_get_parameter_info (MonoMethod *method)
        MonoReflectionParameter** args;
        int i;
 
+       MONO_ARCH_SAVE_REGS;
+
        args = mono_param_get_objects (domain, method);
        if (!System_Reflection_ParameterInfo)
                System_Reflection_ParameterInfo = mono_class_from_name (
@@ -924,6 +1037,8 @@ ves_icall_get_field_info (MonoReflectionField *field, MonoFieldInfo *info)
 {
        MonoDomain *domain = mono_object_domain (field); 
 
+       MONO_ARCH_SAVE_REGS;
+
        info->parent = mono_type_get_object (domain, &field->klass->byval_arg);
        info->type = mono_type_get_object (domain, field->field->type);
        info->name = mono_string_new (domain, field->field->name);
@@ -942,6 +1057,8 @@ ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *ob
        gboolean is_static = FALSE;
        gboolean is_ref = FALSE;
 
+       MONO_ARCH_SAVE_REGS;
+
        mono_class_init (field->klass);
 
        switch (cf->type->type) {
@@ -1008,6 +1125,8 @@ ves_icall_FieldInfo_SetValueInternal (MonoReflectionField *field, MonoObject *ob
        MonoClassField *cf = field->field;
        gchar *v;
 
+       MONO_ARCH_SAVE_REGS;
+
        v = (gchar *) value;
        if (!cf->type->byref) {
                switch (cf->type->type) {
@@ -1055,6 +1174,8 @@ ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo
 {
        MonoDomain *domain = mono_object_domain (property); 
 
+       MONO_ARCH_SAVE_REGS;
+
        info->parent = mono_type_get_object (domain, &property->klass->byval_arg);
        info->name = mono_string_new (domain, property->property->name);
        info->attrs = property->property->attrs;
@@ -1071,6 +1192,8 @@ ves_icall_get_event_info (MonoReflectionEvent *event, MonoEventInfo *info)
 {
        MonoDomain *domain = mono_object_domain (event); 
 
+       MONO_ARCH_SAVE_REGS;
+
        info->parent = mono_type_get_object (domain, &event->klass->byval_arg);
        info->name = mono_string_new (domain, event->event->name);
        info->attrs = event->event->attrs;
@@ -1088,6 +1211,8 @@ ves_icall_Type_GetInterfaces (MonoReflectionType* type)
        MonoClass *class = mono_class_from_mono_type (type->type);
        MonoClass *parent;
 
+       MONO_ARCH_SAVE_REGS;
+
        ninterf = 0;
        for (parent = class; parent; parent = parent->parent) {
                ninterf += parent->interface_count;
@@ -1103,10 +1228,41 @@ ves_icall_Type_GetInterfaces (MonoReflectionType* type)
        return intf;
 }
 
+static void
+ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType *iface, MonoArray **targets, MonoArray **methods)
+{
+       MonoClass *class = mono_class_from_mono_type (type->type);
+       MonoClass *iclass = mono_class_from_mono_type (iface->type);
+       MonoReflectionMethod *member;
+       int i, len, ioffset;
+       MonoDomain *domain;
+
+       MONO_ARCH_SAVE_REGS;
+
+       /* type doesn't implement iface: the exception is thrown in managed code */
+       if ((iclass->interface_id > class->max_interface_id) || !class->interface_offsets [iclass->interface_id])
+                       return;
+
+       len = iclass->method.count;
+       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);
+               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);
+       }
+}
+
 static MonoReflectionType*
 ves_icall_MonoType_GetElementType (MonoReflectionType *type)
 {
        MonoClass *class = mono_class_from_mono_type (type->type);
+
+       MONO_ARCH_SAVE_REGS;
+
        if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
                return mono_type_get_object (mono_object_domain (type), class->enum_basetype);
        else if (class->element_class)
@@ -1119,18 +1275,25 @@ static MonoReflectionType*
 ves_icall_get_type_parent (MonoReflectionType *type)
 {
        MonoClass *class = mono_class_from_mono_type (type->type);
+
+       MONO_ARCH_SAVE_REGS;
+
        return class->parent ? mono_type_get_object (mono_object_domain (type), &class->parent->byval_arg): NULL;
 }
 
 static MonoBoolean
 ves_icall_type_ispointer (MonoReflectionType *type)
 {
+       MONO_ARCH_SAVE_REGS;
+
        return type->type->type == MONO_TYPE_PTR;
 }
 
 static MonoBoolean
 ves_icall_type_isbyref (MonoReflectionType *type)
 {
+       MONO_ARCH_SAVE_REGS;
+
        return type->type->byref;
 }
 
@@ -1138,6 +1301,9 @@ static MonoReflectionModule*
 ves_icall_MonoType_get_Module (MonoReflectionType *type)
 {
        MonoClass *class = mono_class_from_mono_type (type->type);
+
+       MONO_ARCH_SAVE_REGS;
+
        return mono_module_get_object (mono_object_domain (type), class->image);
 }
 
@@ -1147,6 +1313,8 @@ ves_icall_get_type_info (MonoType *type, MonoTypeInfo *info)
        MonoDomain *domain = mono_domain_get (); 
        MonoClass *class = mono_class_from_mono_type (type);
 
+       MONO_ARCH_SAVE_REGS;
+
        info->nested_in = class->nested_in ? mono_type_get_object (domain, &class->nested_in->byval_arg): NULL;
        info->name = mono_string_new (domain, class->name);
        info->name_space = mono_string_new (domain, class->name_space);
@@ -1159,13 +1327,34 @@ ves_icall_get_type_info (MonoType *type, MonoTypeInfo *info)
        else
                info->etype = NULL;
 
-       info->isprimitive = (type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8);
+       info->isprimitive = (!type->byref && (type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8));
 }
 
 static MonoObject *
 ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params) 
 {
-       return mono_runtime_invoke_array (method->method, this, params, NULL);
+       /* 
+        * Invoke from reflection is supposed to always be a virtual call (the API
+        * is stupid), mono_runtime_invoke_*() calls the provided method, allowing
+        * greater flexibility.
+        */
+       MonoMethod *m = method->method;
+       int pcount;
+
+       MONO_ARCH_SAVE_REGS;
+
+       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);
+       } else if (!(m->flags & METHOD_ATTRIBUTE_STATIC) && strcmp (m->name, ".ctor"))
+               mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
+
+       pcount = params? mono_array_length (params): 0;
+       if (pcount != m->signature->param_count)
+               mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetParameterCountException"));
+
+       return mono_runtime_invoke_array (m, this, params, NULL);
 }
 
 static MonoObject *
@@ -1178,6 +1367,8 @@ ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoA
        MonoObject *result;
        int i, j, outarg_count = 0;
 
+       MONO_ARCH_SAVE_REGS;
+
        if (m->klass == mono_defaults.object_class) {
 
                if (!strcmp (m->name, "FieldGetter")) {
@@ -1228,7 +1419,9 @@ ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoA
                                        } else 
                                                *((gpointer *)this + k->fields [i].offset) = val;
                                
-                                       g_assert (result);
+                                       out_args = mono_array_new (domain, mono_defaults.object_class, 0);
+                                       *outArgs = out_args;
+
                                        g_free (str);
                                        return NULL;
                                }
@@ -1275,6 +1468,8 @@ ves_icall_System_Enum_ToObject (MonoReflectionType *type, MonoObject *obj)
        gint32 s1, s2;
        MonoObject *res;
        
+       MONO_ARCH_SAVE_REGS;
+
        MONO_CHECK_ARG_NULL (type);
        MONO_CHECK_ARG_NULL (obj);
 
@@ -1310,6 +1505,8 @@ ves_icall_System_Enum_get_value (MonoObject *this)
        gpointer src;
        int size;
 
+       MONO_ARCH_SAVE_REGS;
+
        if (!this)
                return NULL;
 
@@ -1334,6 +1531,8 @@ ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
        guint i, j, nvalues, crow;
        MonoClassField *field;
        
+       MONO_ARCH_SAVE_REGS;
+
        info->utype = mono_type_get_object (domain, enumc->enum_basetype);
        nvalues = enumc->field.count - 1;
        info->names = mono_array_new (domain, mono_defaults.string_class, nvalues);
@@ -1375,35 +1574,6 @@ ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
        }
 }
 
-static MonoProperty*
-search_property (MonoClass *klass, char* name, MonoArray *args) {
-       int i;
-       MonoProperty *p;
-
-       /* FIXME: handle args */
-       for (i = 0; i < klass->property.count; ++i) {
-               p = &klass->properties [i];
-               if (strcmp (p->name, name) == 0)
-                       return p;
-       }
-       return NULL;
-}
-
-static MonoReflectionProperty*
-ves_icall_get_property (MonoReflectionType *type, MonoString *name, MonoArray *args)
-{
-       MonoDomain *domain = mono_object_domain (type); 
-       MonoProperty *p;
-       MonoClass *class = mono_class_from_mono_type (type->type);
-       char *n = mono_string_to_utf8 (name);
-
-       p = search_property (class, n, args);
-       g_free (n);
-       if (p)
-               return mono_property_get_object (domain, class, p);
-       return NULL;
-}
-
 enum {
        BFLAGS_IgnoreCase = 1,
        BFLAGS_DeclaredOnly = 2,
@@ -1433,6 +1603,8 @@ ves_icall_Type_GetField (MonoReflectionType *type, MonoString *name, guint32 bfl
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
 
+       MONO_ARCH_SAVE_REGS;
+
        if (!name)
                return NULL;
 
@@ -1488,6 +1660,8 @@ ves_icall_Type_GetFields (MonoReflectionType *type, guint32 bflags)
        int i, len, match;
        MonoClassField *field;
 
+       MONO_ARCH_SAVE_REGS;
+
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
 
@@ -1535,7 +1709,6 @@ ves_icall_Type_GetMethods (MonoReflectionType *type, guint32 bflags)
 {
        MonoDomain *domain; 
        GSList *l = NULL, *tmp;
-       static MonoClass *System_Reflection_MethodInfo;
        MonoClass *startklass, *klass;
        MonoArray *res;
        MonoMethod *method;
@@ -1543,8 +1716,11 @@ ves_icall_Type_GetMethods (MonoReflectionType *type, guint32 bflags)
        int i, len, match;
        GHashTable *method_slots = g_hash_table_new (NULL, NULL);
                
+       MONO_ARCH_SAVE_REGS;
+
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
+       len = 0;
 
 handle_parent:
        for (i = 0; i < klass->method.count; ++i) {
@@ -1579,14 +1755,11 @@ handle_parent:
                member = (MonoObject*)mono_method_get_object (domain, method, startklass);
                
                l = g_slist_prepend (l, member);
+               len++;
        }
        if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
                goto handle_parent;
-       len = g_slist_length (l);
-       if (!System_Reflection_MethodInfo)
-               System_Reflection_MethodInfo = mono_class_from_name (
-                       mono_defaults.corlib, "System.Reflection", "MethodInfo");
-       res = mono_array_new (domain, System_Reflection_MethodInfo, len);
+       res = mono_array_new (domain, mono_defaults.method_info_class, len);
        i = 0;
        tmp = l;
        for (; tmp; tmp = tmp->next, ++i)
@@ -1608,10 +1781,11 @@ ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
        MonoObject *member;
        int i, len, match;
 
+       MONO_ARCH_SAVE_REGS;
+
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
 
-handle_parent: 
        for (i = 0; i < klass->method.count; ++i) {
                match = 0;
                method = klass->methods [i];
@@ -1641,8 +1815,6 @@ handle_parent:
                        
                l = g_slist_prepend (l, member);
        }
-       if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
-               goto handle_parent;
        len = g_slist_length (l);
        if (!System_Reflection_ConstructorInfo)
                System_Reflection_ConstructorInfo = mono_class_from_name (
@@ -1666,7 +1838,11 @@ ves_icall_Type_GetProperties (MonoReflectionType *type, guint32 bflags)
        MonoArray *res;
        MonoMethod *method;
        MonoProperty *prop;
-       int i, len, match;
+       int i, match;
+       int len = 0;
+       GHashTable *method_slots = g_hash_table_new (NULL, NULL);
+
+       MONO_ARCH_SAVE_REGS;
 
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
@@ -1699,11 +1875,16 @@ handle_parent:
                if (!match)
                        continue;
                match = 0;
+
+               if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
+                       continue;
+               g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), prop);
+
                l = g_slist_prepend (l, mono_property_get_object (domain, klass, prop));
+               len++;
        }
        if ((!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)))
                goto handle_parent;
-       len = g_slist_length (l);
        if (!System_Reflection_PropertyInfo)
                System_Reflection_PropertyInfo = mono_class_from_name (
                        mono_defaults.corlib, "System.Reflection", "PropertyInfo");
@@ -1713,9 +1894,55 @@ 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);
        return res;
 }
 
+static MonoReflectionEvent *
+ves_icall_MonoType_GetEvent (MonoReflectionType *type, MonoString *name, guint32 bflags)
+{
+       MonoDomain *domain;
+       MonoClass *klass;
+       gint i;
+       MonoEvent *event;
+       MonoMethod *method;
+       gchar *event_name;
+
+       MONO_ARCH_SAVE_REGS;
+
+       event_name = mono_string_to_utf8 (name);
+       klass = 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];
+               if (strcmp (event->name, event_name))
+                       continue;
+
+               method = event->add;
+               if (!method)
+                       method = event->remove;
+
+               if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
+                       if (!(bflags & BFLAGS_Public))
+                               continue;
+               } else {
+                       if (!(bflags & BFLAGS_NonPublic))
+                               continue;
+               }
+
+               g_free (event_name);
+               return mono_event_get_object (domain, klass, event);
+       }
+
+       if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
+               goto handle_parent;
+
+       g_free (event_name);
+       return NULL;
+}
+
 static MonoArray*
 ves_icall_Type_GetEvents (MonoReflectionType *type, guint32 bflags)
 {
@@ -1728,6 +1955,8 @@ ves_icall_Type_GetEvents (MonoReflectionType *type, guint32 bflags)
        MonoEvent *event;
        int i, len, match;
 
+       MONO_ARCH_SAVE_REGS;
+
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
 
@@ -1788,6 +2017,8 @@ ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags)
        int i, len, match;
        MonoClass *nested;
 
+       MONO_ARCH_SAVE_REGS;
+
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
 
@@ -1817,12 +2048,14 @@ ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags)
 }
 
 static MonoReflectionType*
-ves_icall_System_Reflection_Assembly_GetType (MonoReflectionAssembly *assembly, MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase)
+ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly *assembly, MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase)
 {
        gchar *str;
        MonoType *type;
        MonoTypeNameParse info;
 
+       MONO_ARCH_SAVE_REGS;
+
        str = mono_string_to_utf8 (name);
        /*g_print ("requested type %s in %s\n", str, assembly->assembly->aname.name);*/
        if (!mono_reflection_parse_type (str, &info)) {
@@ -1858,6 +2091,8 @@ ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly *asse
        char *name = g_strconcat (
                "file://", assembly->assembly->image->name, NULL);
        
+       MONO_ARCH_SAVE_REGS;
+
        res = mono_string_new (domain, name);
        g_free (name);
        return res;
@@ -1868,30 +2103,39 @@ ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssembly *assem
 {
        MonoDomain *domain = mono_object_domain (assembly); 
        MonoString *res;
-       char *name = g_strconcat (
-               assembly->assembly->basedir, G_DIR_SEPARATOR_S,
+       char *name = g_build_filename (
+               assembly->assembly->basedir,
                assembly->assembly->image->module_name, NULL);
 
+       MONO_ARCH_SAVE_REGS;
+
        res = mono_string_new (domain, name);
        g_free (name);
        return res;
 }
 
 static MonoReflectionMethod*
-ves_icall_System_Reflection_Assembly_get_EntryPoint (MonoReflectionAssembly *assembly) {
+ves_icall_System_Reflection_Assembly_get_EntryPoint (MonoReflectionAssembly *assembly) 
+{
        guint32 token = mono_image_get_entry_point (assembly->assembly->image);
+
+       MONO_ARCH_SAVE_REGS;
+
        if (!token)
                return NULL;
        return mono_method_get_object (mono_object_domain (assembly), mono_get_method (assembly->assembly->image, token, NULL), NULL);
 }
 
 static MonoArray*
-ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAssembly *assembly) {
+ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAssembly *assembly) 
+{
        MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
        MonoArray *result = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, table->rows);
        int i;
        const char *val;
 
+       MONO_ARCH_SAVE_REGS;
+
        for (i = 0; i < table->rows; ++i) {
                val = mono_metadata_string_heap (assembly->assembly->image, mono_metadata_decode_row_col (table, i, MONO_MANIFEST_NAME));
                mono_array_set (result, gpointer, i, mono_string_new (mono_object_domain (assembly), val));
@@ -1899,6 +2143,48 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAss
        return result;
 }
 
+static MonoArray*
+ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAssembly *assembly) 
+{
+       static MonoClass *System_Reflection_AssemblyName;
+       MonoArray *result;
+       MonoAssembly **ptr;
+       MonoDomain *domain = mono_object_domain (assembly);
+       int i, count = 0;
+
+       MONO_ARCH_SAVE_REGS;
+
+       if (!System_Reflection_AssemblyName)
+               System_Reflection_AssemblyName = mono_class_from_name (
+                       mono_defaults.corlib, "System.Reflection", "AssemblyName");
+
+       for (ptr = assembly->assembly->image->references; ptr && *ptr; ptr++)
+               count++;
+
+       result = mono_array_new (mono_object_domain (assembly), System_Reflection_AssemblyName, count);
+
+       for (i = 0; i < count; i++) {
+               MonoAssembly *assem = assembly->assembly->image->references [i];
+               MonoReflectionAssemblyName *aname;
+               char *codebase;
+
+               aname = (MonoReflectionAssemblyName *) mono_object_new (
+                       domain, System_Reflection_AssemblyName);
+
+               if (strcmp (assem->aname.name, "corlib") == 0)
+                       aname->name = mono_string_new (domain, "mscorlib");
+               else
+                       aname->name = mono_string_new (domain, assem->aname.name);
+               aname->major = assem->aname.major;
+
+               codebase = g_strconcat ("file://", assembly->assembly->image->references [i]->image->name, NULL);
+               aname->codebase = mono_string_new (domain, codebase);
+               g_free (codebase);
+               mono_array_set (result, gpointer, i, aname);
+       }
+       return result;
+}
+
 /* move this in some file in mono/util/ */
 static char *
 g_concat_dir_and_file (const char *dir, const char *file)
@@ -1917,7 +2203,8 @@ g_concat_dir_and_file (const char *dir, const char *file)
 }
 
 static MonoObject*
-ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflectionAssembly *assembly, MonoString *name) {
+ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflectionAssembly *assembly, MonoString *name) 
+{
        char *n = mono_string_to_utf8 (name);
        MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
        guint32 i;
@@ -1925,6 +2212,8 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflection
        const char *val;
        MonoObject *result;
 
+       MONO_ARCH_SAVE_REGS;
+
        for (i = 0; i < table->rows; ++i) {
                mono_metadata_decode_row (table, i, cols, MONO_MANIFEST_SIZE);
                val = mono_metadata_string_heap (assembly->assembly->image, cols [MONO_MANIFEST_NAME]);
@@ -1965,13 +2254,16 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflection
 }
 
 static MonoObject*
-ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssembly *assembly, MonoString *name) {
+ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssembly *assembly, MonoString *name) 
+{
        MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
-       MonoArray *result;
+       MonoArray *result = NULL;
        int i;
        const char *val;
        char *n;
 
+       MONO_ARCH_SAVE_REGS;
+
        /* check hash if needed */
        if (name) {
                n = mono_string_to_utf8 (name);
@@ -2001,8 +2293,12 @@ ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssembly *a
 }
 
 static MonoReflectionMethod*
-ves_icall_GetCurrentMethod (void) {
+ves_icall_GetCurrentMethod (void) 
+{
        MonoMethod *m = mono_method_get_last_managed ();
+
+       MONO_ARCH_SAVE_REGS;
+
        return mono_method_get_object (mono_domain_get (), m, NULL);
 }
 
@@ -2010,14 +2306,22 @@ static MonoReflectionAssembly*
 ves_icall_System_Reflection_Assembly_GetExecutingAssembly (void)
 {
        MonoMethod *m = mono_method_get_last_managed ();
+
+       MONO_ARCH_SAVE_REGS;
+
        return mono_assembly_get_object (mono_domain_get (), m->klass->image->assembly);
 }
 
 
 static gboolean
-get_caller (MonoMethod *m, gint32 no, gint32 ilo, gpointer data)
+get_caller (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
 {
        MonoMethod **dest = data;
+
+       /* skip unmanaged frames */
+       if (!managed)
+               return FALSE;
+
        if (m == *dest) {
                *dest = NULL;
                return FALSE;
@@ -2033,7 +2337,12 @@ static MonoReflectionAssembly*
 ves_icall_System_Reflection_Assembly_GetEntryAssembly (void)
 {
        MonoDomain* domain = mono_domain_get ();
-       g_assert (domain->entry_assembly);
+
+       MONO_ARCH_SAVE_REGS;
+
+       if (!domain->entry_assembly)
+               domain = mono_root_domain;
+
        return mono_assembly_get_object (domain, domain->entry_assembly);
 }
 
@@ -2043,6 +2352,9 @@ ves_icall_System_Reflection_Assembly_GetCallingAssembly (void)
 {
        MonoMethod *m = mono_method_get_last_managed ();
        MonoMethod *dest = m;
+
+       MONO_ARCH_SAVE_REGS;
+
        mono_stack_walk (get_caller, &dest);
        if (!dest)
                dest = m;
@@ -2056,6 +2368,8 @@ ves_icall_System_MonoType_getFullName (MonoReflectionType *object)
        MonoString *res;
        gchar *name;
 
+       MONO_ARCH_SAVE_REGS;
+
        name = mono_type_get_name (object->type);
        res = mono_string_new (domain, name);
        g_free (name);
@@ -2068,11 +2382,17 @@ ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly,
 {
        MonoAssemblyName *name = &assembly->assembly->aname;
 
+       MONO_ARCH_SAVE_REGS;
+
        if (strcmp (name->name, "corlib") == 0)
                aname->name = mono_string_new (mono_object_domain (assembly), "mscorlib");
        else
                aname->name = mono_string_new (mono_object_domain (assembly), name->name);
+
        aname->major = name->major;
+       aname->minor = name->minor;
+       aname->build = name->build;
+       aname->revision = name->revision;
 }
 
 static MonoArray*
@@ -2085,6 +2405,8 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
        int i, count;
        guint32 attrs, visibility;
 
+       MONO_ARCH_SAVE_REGS;
+
        /* we start the count from 1 because we skip the special type <Module> */
        if (exportedOnly) {
                count = 0;
@@ -2120,6 +2442,8 @@ ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, Mon
        char *str = mono_string_to_utf8 (smodifiers);
        char *p;
 
+       MONO_ARCH_SAVE_REGS;
+
        klass = mono_class_from_mono_type (tb->type.type);
        p = str;
        /* logic taken from mono_reflection_parse_type(): keep in sync */
@@ -2178,6 +2502,8 @@ ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, Mon
        MonoObject *delegate;
        gpointer func;
 
+       MONO_ARCH_SAVE_REGS;
+
        mono_assert (delegate_class->parent == mono_defaults.multicastdelegate_class);
 
        delegate = mono_object_new (mono_object_domain (type), delegate_class);
@@ -2210,6 +2536,8 @@ ves_icall_System_DateTime_GetNow (void)
        struct timeval tv;
        gint64 res;
 
+       MONO_ARCH_SAVE_REGS;
+
        if (gettimeofday (&tv, NULL) == 0) {
                res = (((gint64)tv.tv_sec + EPOCH_ADJUST)* 1000000 + tv.tv_usec)*10;
                return res;
@@ -2244,6 +2572,12 @@ ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data
 
        long int gmtoff;
        int is_daylight = 0, day;
+       char tzone[10];
+
+       MONO_ARCH_SAVE_REGS;
+
+       if ((year < 1900) || (year > 2100))
+               mono_raise_exception (mono_get_exception_not_implemented ());
 
        memset (&start, 0, sizeof (start));
 
@@ -2260,7 +2594,7 @@ ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data
 #endif
        
        gmtoff = gmt_offset (start);
-       
+
        MONO_CHECK_ARG_NULL (data);
        MONO_CHECK_ARG_NULL (names);
 
@@ -2275,7 +2609,6 @@ ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data
 
                /* Daylight saving starts or ends here. */
                if (gmt_offset (tt) != gmtoff) {
-                       char tzone[10];
                        struct tm tt1;
                        time_t t1;
 
@@ -2314,6 +2647,17 @@ ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data
 
                gmtoff = gmt_offset (tt);
        }
+
+       if (!is_daylight) {
+               strftime (tzone, 10, "%Z", &tt);
+               mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tzone));
+               mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tzone));
+               mono_array_set ((*data), gint64, 0, 0);
+               mono_array_set ((*data), gint64, 1, 0);
+               mono_array_set ((*data), gint64, 2, (gint64) gmtoff * 10000000L);
+               mono_array_set ((*data), gint64, 3, 0);
+       }
+
        return 1;
 #else
        MonoDomain *domain = mono_domain_get ();
@@ -2350,19 +2694,25 @@ ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data
 }
 
 static gpointer
-ves_icall_System_Object_obj_address (MonoObject *this) {
+ves_icall_System_Object_obj_address (MonoObject *this) 
+{
+       MONO_ARCH_SAVE_REGS;
+
        return this;
 }
 
 /* System.Buffer */
 
 static gint32 
-ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array) {
+ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array) 
+{
        MonoClass *klass;
        MonoTypeEnum etype;
        int length, esize;
        int i;
 
+       MONO_ARCH_SAVE_REGS;
+
        klass = array->obj.vtable->klass;
        etype = klass->element_class->byval_arg.type;
        if (etype < MONO_TYPE_BOOLEAN || etype > MONO_TYPE_R8)
@@ -2381,19 +2731,28 @@ ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array) {
 }
 
 static gint8 
-ves_icall_System_Buffer_GetByteInternal (MonoArray *array, gint32 idx) {
+ves_icall_System_Buffer_GetByteInternal (MonoArray *array, gint32 idx) 
+{
+       MONO_ARCH_SAVE_REGS;
+
        return mono_array_get (array, gint8, idx);
 }
 
 static void 
-ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 value) {
+ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 value) 
+{
+       MONO_ARCH_SAVE_REGS;
+
        mono_array_set (array, gint8, idx, value);
 }
 
 static void 
-ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count) {
+ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count) 
+{
        char *src_buf, *dest_buf;
 
+       MONO_ARCH_SAVE_REGS;
+
        src_buf = (gint8 *)src->vector + src_offset;
        dest_buf = (gint8 *)dest->vector + dest_offset;
 
@@ -2409,6 +2768,8 @@ ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this)
        MonoType *type;
        MonoClass *klass;
 
+       MONO_ARCH_SAVE_REGS;
+
        res = mono_object_new (domain, mono_defaults.transparent_proxy_class);
        
        ((MonoTransparentProxy *)res)->rp = rp;
@@ -2446,11 +2807,13 @@ ves_icall_System_Environment_get_MachineName (void)
        int len;
        MonoString *result;
 
+       MONO_ARCH_SAVE_REGS;
+
        len = 256;
        buf = g_new (gchar, len);
 
        result = NULL;
-       if (gethostname (buf, len) != 0)
+       if (gethostname (buf, len) == 0)
                result = mono_string_new (mono_domain_get (), buf);
        
        g_free (buf);
@@ -2461,6 +2824,8 @@ ves_icall_System_Environment_get_MachineName (void)
 static int
 ves_icall_System_Environment_get_Platform (void)
 {
+       MONO_ARCH_SAVE_REGS;
+
 #if defined (PLATFORM_WIN32)
        /* Win32NT */
        return 2;
@@ -2473,6 +2838,8 @@ ves_icall_System_Environment_get_Platform (void)
 static MonoString *
 ves_icall_System_Environment_get_NewLine (void)
 {
+       MONO_ARCH_SAVE_REGS;
+
 #if defined (PLATFORM_WIN32)
        return mono_string_new (mono_domain_get (), "\r\n");
 #else
@@ -2486,6 +2853,8 @@ ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
        const gchar *value;
        gchar *utf8_name;
 
+       MONO_ARCH_SAVE_REGS;
+
        if (name == NULL)
                return NULL;
 
@@ -2513,6 +2882,8 @@ ves_icall_System_Environment_GetEnvironmentVariableNames (void)
        gchar **e, **parts;
        int n;
 
+       MONO_ARCH_SAVE_REGS;
+
        n = 0;
        for (e = environ; *e != 0; ++ e)
                ++ n;
@@ -2549,6 +2920,8 @@ ves_icall_System_Environment_get_TickCount (void)
        struct timezone tz;
        gint32 res;
 
+       MONO_ARCH_SAVE_REGS;
+
        res = (gint32) gettimeofday (&tv, &tz);
 
        if (res != -1)
@@ -2561,13 +2934,19 @@ ves_icall_System_Environment_get_TickCount (void)
 static void
 ves_icall_System_Environment_Exit (int result)
 {
+       MONO_ARCH_SAVE_REGS;
+
        /* we may need to do some cleanup here... */
        exit (result);
 }
 
 static MonoString*
-ves_icall_System_Text_Encoding_InternalCodePage (void) {
+ves_icall_System_Text_Encoding_InternalCodePage (void) 
+{
        const char *cset;
+
+       MONO_ARCH_SAVE_REGS;
+
        g_get_charset (&cset);
        /* g_print ("charset: %s\n", cset); */
        /* handle some common aliases */
@@ -2585,12 +2964,16 @@ ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this,
                                         MonoReflectionMethod *method,
                                         MonoArray *out_args)
 {
+       MONO_ARCH_SAVE_REGS;
+
        mono_message_init (mono_object_domain (this), this, method, out_args);
 }
 
 static MonoBoolean
 ves_icall_IsTransparentProxy (MonoObject *proxy)
 {
+       MONO_ARCH_SAVE_REGS;
+
        if (!proxy)
                return 0;
 
@@ -2600,6 +2983,36 @@ ves_icall_IsTransparentProxy (MonoObject *proxy)
        return 0;
 }
 
+static void
+ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionType *type, MonoBoolean enable)
+{
+       MonoClass *klass;
+       MonoVTable* vtable;
+
+       MONO_ARCH_SAVE_REGS;
+
+       klass = mono_class_from_mono_type (type->type);
+       vtable = mono_class_vtable (mono_domain_get (), klass);
+
+       if (enable) vtable->remote = 1;
+       else vtable->remote = 0;
+}
+
+static MonoObject *
+ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance (MonoReflectionType *type)
+{
+       MonoClass *klass;
+       MonoDomain *domain;
+       
+       MONO_ARCH_SAVE_REGS;
+
+       domain = mono_object_domain (type);
+       klass = mono_class_from_mono_type (type->type);
+
+       // Bypass remoting object creation check
+       return mono_object_new_alloc_specific (mono_class_vtable (domain, klass));
+}
+
 static MonoObject *
 ves_icall_System_Runtime_Serialization_FormatterServices_GetUninitializedObject_Internal (MonoReflectionType *type)
 {
@@ -2607,6 +3020,8 @@ ves_icall_System_Runtime_Serialization_FormatterServices_GetUninitializedObject_
        MonoObject *obj;
        MonoDomain *domain;
        
+       MONO_ARCH_SAVE_REGS;
+
        domain = mono_object_domain (type);
        klass = mono_class_from_mono_type (type->type);
 
@@ -2623,15 +3038,155 @@ ves_icall_System_Runtime_Serialization_FormatterServices_GetUninitializedObject_
 static MonoString *
 ves_icall_System_IO_get_temp_path (void)
 {
+       MONO_ARCH_SAVE_REGS;
+
        return mono_string_new (mono_domain_get (), g_get_tmp_dir ());
 }
 
 static gpointer
 ves_icall_RuntimeMethod_GetFunctionPointer (MonoMethod *method)
 {
+       MONO_ARCH_SAVE_REGS;
+
        return mono_compile_method (method);
 }
 
+char const * mono_cfg_dir = "";
+
+void    
+mono_install_get_config_dir (void)
+{
+#ifdef PLATFORM_WIN32
+  int i;
+#endif
+
+  mono_cfg_dir = getenv ("MONO_CFG_DIR");
+
+  if (!mono_cfg_dir) {
+#ifndef PLATFORM_WIN32
+    mono_cfg_dir = MONO_CFG_DIR;
+#else
+    mono_cfg_dir = g_strdup (MONO_CFG_DIR);
+    for (i = strlen (mono_cfg_dir) - 1; i >= 0; i--) {
+        if (mono_cfg_dir [i] == '/')
+            mono_cfg_dir [i] = '\\';
+    }
+#endif
+  }
+}
+
+
+static MonoString *
+ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
+{
+       static MonoString *mcpath;
+       gchar *path;
+
+       MONO_ARCH_SAVE_REGS;
+
+       if (mcpath != NULL)
+               return mcpath;
+
+       path = g_build_path (G_DIR_SEPARATOR_S, mono_cfg_dir, "mono", "machine.config", NULL);
+
+#if defined (PLATFORM_WIN32)
+       /* Avoid mixing '/' and '\\' */
+       {
+               gint i;
+               for (i = strlen (path) - 1; i >= 0; i--)
+                       if (path [i] == '/')
+                               path [i] = '\\';
+       }
+#endif
+       mcpath = mono_string_new (mono_domain_get (), path);
+       g_free (path);
+
+       return mcpath;
+}
+
+static void
+ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString (MonoString *message)
+{
+#if defined (PLATFORM_WIN32)
+       static void (*output_debug) (gchar *);
+       static gboolean tried_loading = FALSE;
+       gchar *str;
+
+       MONO_ARCH_SAVE_REGS;
+
+       if (!tried_loading && output_debug == NULL) {
+               GModule *k32;
+
+               tried_loading = TRUE;
+               k32 = g_module_open ("kernel32", G_MODULE_BIND_LAZY);
+               if (!k32) {
+                       gchar *error = g_strdup (g_module_error ());
+                       g_warning ("Failed to load kernel32.dll: %s\n", error);
+                       g_free (error);
+                       return;
+               }
+
+               g_module_symbol (k32, "OutputDebugStringW", (gpointer *) &output_debug);
+               if (!output_debug) {
+                       gchar *error = g_strdup (g_module_error ());
+                       g_warning ("Failed to load OutputDebugStringW: %s\n", error);
+                       g_free (error);
+                       return;
+               }
+       }
+
+       if (output_debug == NULL)
+               return;
+       
+       str = mono_string_to_utf8 (message);
+       output_debug (str);
+       g_free (str);
+#else
+       g_warning ("WriteWindowsDebugString called and PLATFORM_WIN32 not defined!\n");
+#endif
+}
+
+/* Only used for value types */
+static MonoObject *
+ves_icall_System_Activator_CreateInstanceInternal (MonoReflectionType *type)
+{
+       MonoClass *klass;
+       MonoDomain *domain;
+       
+       MONO_ARCH_SAVE_REGS;
+
+       domain = mono_object_domain (type);
+       klass = mono_class_from_mono_type (type->type);
+
+       return mono_object_new (domain, klass);
+}
+
+static MonoReflectionMethod *
+ves_icall_MonoMethod_get_base_definition (MonoReflectionMethod *m)
+{
+       MonoClass *klass;
+       MonoMethod *method = m->method;
+       MonoMethod *result = NULL;
+
+       MONO_ARCH_SAVE_REGS;
+
+       if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
+            method->klass->flags & TYPE_ATTRIBUTE_INTERFACE ||
+            method->flags & METHOD_ATTRIBUTE_NEW_SLOT)
+               return m;
+
+       if (method->klass == NULL || (klass = method->klass->parent) == NULL)
+               return m;
+
+       if (klass->vtable_size > method->slot)
+               result = klass->vtable [method->slot];
+
+       if (result == NULL)
+               return m;
+
+       return mono_method_get_object (mono_domain_get (), result, NULL);
+}
+
 /* icall map */
 
 static gconstpointer icall_map [] = {
@@ -2698,7 +3253,7 @@ static gconstpointer icall_map [] = {
        "System.String::InternalStrcpy(string,int,string,int,int)", ves_icall_System_String_InternalStrcpy_StrN,
        "System.String::InternalIntern", ves_icall_System_String_InternalIntern,
        "System.String::InternalIsInterned", ves_icall_System_String_InternalIsInterned,
-       "System.String::InternalCompare(string,int,string,int,int,bool)", ves_icall_System_String_InternalCompareStr_N,
+       "System.String::InternalCompare(string,int,string,int,int,int)", ves_icall_System_String_InternalCompareStr_N,
        "System.String::GetHashCode", ves_icall_System_String_GetHashCode,
        "System.String::get_Chars", ves_icall_System_String_get_Chars,
 
@@ -2713,8 +3268,13 @@ static gconstpointer icall_map [] = {
        "System.AppDomain::getFriendlyName", ves_icall_System_AppDomain_getFriendlyName,
        "System.AppDomain::GetAssemblies", ves_icall_System_AppDomain_GetAssemblies,
        "System.AppDomain::LoadAssembly", ves_icall_System_AppDomain_LoadAssembly,
-       "System.AppDomain::Unload", ves_icall_System_AppDomain_Unload,
+       "System.AppDomain::InternalUnload", ves_icall_System_AppDomain_InternalUnload,
        "System.AppDomain::ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly,
+       "System.AppDomain::InternalSetDomain", ves_icall_System_AppDomain_InternalSetDomain,
+       "System.AppDomain::InternalSetDomainByID", ves_icall_System_AppDomain_InternalSetDomainByID,
+       "System.AppDomain::InternalSetContext", ves_icall_System_AppDomain_InternalSetContext,
+       "System.AppDomain::InternalGetContext", ves_icall_System_AppDomain_InternalGetContext,
+       "System.AppDomain::InternalGetDefaultContext", ves_icall_System_AppDomain_InternalGetDefaultContext,
 
        /*
         * System.AppDomainSetup
@@ -2754,6 +3314,7 @@ static gconstpointer icall_map [] = {
         * ModuleBuilder
         */
        "System.Reflection.Emit.ModuleBuilder::create_modified_type", ves_icall_ModuleBuilder_create_modified_type,
+       "System.Reflection.Emit.ModuleBuilder::basic_init", mono_image_module_basic_init,
        
        /*
         * AssemblyBuilder
@@ -2762,6 +3323,7 @@ static gconstpointer icall_map [] = {
        "System.Reflection.Emit.AssemblyBuilder::getUSIndex", mono_image_insert_string,
        "System.Reflection.Emit.AssemblyBuilder::getToken", ves_icall_AssemblyBuilder_getToken,
        "System.Reflection.Emit.AssemblyBuilder::basic_init", mono_image_basic_init,
+       "System.Reflection.Emit.AssemblyBuilder::build_metadata", ves_icall_AssemblyBuilder_build_metadata,
 
        /*
         * Reflection stuff.
@@ -2782,6 +3344,7 @@ static gconstpointer icall_map [] = {
        "System.Reflection.Emit.SignatureHelper::get_signature_field", mono_reflection_sighelper_get_signature_field,
 
        "System.RuntimeMethodHandle::GetFunctionPointer", ves_icall_RuntimeMethod_GetFunctionPointer,
+       "System.Reflection.MonoMethod::get_base_definition", ves_icall_MonoMethod_get_base_definition,
        
        /* System.Enum */
 
@@ -2805,11 +3368,11 @@ static gconstpointer icall_map [] = {
         */
        "System.Type::internal_from_name", ves_icall_type_from_name,
        "System.Type::internal_from_handle", ves_icall_type_from_handle,
-       "System.Type::get_property", ves_icall_get_property,
        "System.MonoType::get_attributes", ves_icall_get_attributes,
        "System.Type::type_is_subtype_of", ves_icall_type_is_subtype_of,
        "System.Type::Equals", ves_icall_type_Equals,
        "System.Type::GetTypeCode", ves_icall_type_GetTypeCode,
+       "System.Type::GetInterfaceMapData", ves_icall_Type_GetInterfaceMapData,
 
        /*
         * System.Runtime.CompilerServices.RuntimeHelpers
@@ -2829,10 +3392,10 @@ static gconstpointer icall_map [] = {
        "System.Threading.Thread::Start_internal", ves_icall_System_Threading_Thread_Start_internal,
        "System.Threading.Thread::Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal,
        "System.Threading.Thread::CurrentThread_internal", mono_thread_current,
-       "System.Threading.Thread::CurrentThreadDomain_internal", ves_icall_System_Threading_Thread_CurrentThreadDomain_internal,
        "System.Threading.Thread::Join_internal", ves_icall_System_Threading_Thread_Join_internal,
        "System.Threading.Thread::SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup,
        "System.Threading.Thread::SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store,
+       "System.Threading.Thread::GetDomainID", ves_icall_System_Threading_Thread_GetDomainID,
        "System.Threading.Monitor::Monitor_exit", ves_icall_System_Threading_Monitor_Monitor_exit,
        "System.Threading.Monitor::Monitor_test_owner", ves_icall_System_Threading_Monitor_Monitor_test_owner,
        "System.Threading.Monitor::Monitor_test_synchronised", ves_icall_System_Threading_Monitor_Monitor_test_synchronised,
@@ -2893,7 +3456,7 @@ static gconstpointer icall_map [] = {
 
 
        "System.Reflection.Assembly::LoadFrom", ves_icall_System_Reflection_Assembly_LoadFrom,
-       "System.Reflection.Assembly::GetType", ves_icall_System_Reflection_Assembly_GetType,
+       "System.Reflection.Assembly::InternalGetType", ves_icall_System_Reflection_Assembly_InternalGetType,
        "System.Reflection.Assembly::GetTypes", ves_icall_System_Reflection_Assembly_GetTypes,
        "System.Reflection.Assembly::FillName", ves_icall_System_Reflection_Assembly_FillName,
        "System.Reflection.Assembly::get_code_base", ves_icall_System_Reflection_Assembly_get_code_base,
@@ -2905,6 +3468,7 @@ static gconstpointer icall_map [] = {
        "System.Reflection.Assembly::GetManifestResourceNames", ves_icall_System_Reflection_Assembly_GetManifestResourceNames,
        "System.Reflection.Assembly::GetManifestResourceInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInternal,
        "System.Reflection.Assembly::GetFilesInternal", ves_icall_System_Reflection_Assembly_GetFilesInternal,
+       "System.Reflection.Assembly::GetReferencedAssemblies", ves_icall_System_Reflection_Assembly_GetReferencedAssemblies,
 
        /*
         * System.MonoType.
@@ -2923,6 +3487,7 @@ static gconstpointer icall_map [] = {
        "System.MonoType::GetConstructors", ves_icall_Type_GetConstructors,
        "System.MonoType::GetProperties", ves_icall_Type_GetProperties,
        "System.MonoType::GetEvents", ves_icall_Type_GetEvents,
+       "System.MonoType::InternalGetEvent", ves_icall_MonoType_GetEvent,
        "System.MonoType::GetInterfaces", ves_icall_Type_GetInterfaces,
        "System.MonoType::GetNestedTypes", ves_icall_Type_GetNestedTypes,
 
@@ -2949,8 +3514,9 @@ static gconstpointer icall_map [] = {
        "System.Net.Sockets.Socket::GetSocketOption_obj_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal,
        "System.Net.Sockets.Socket::GetSocketOption_arr_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal,
        "System.Net.Sockets.Socket::SetSocketOption_internal", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal,
-       "System.Net.Dns::GetHostByName_internal", ves_icall_System_Net_Dns_GetHostByName_internal,
-       "System.Net.Dns::GetHostByAddr_internal", ves_icall_System_Net_Dns_GetHostByAddr_internal,
+       "System.Net.Dns::GetHostByName_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByName_internal,
+       "System.Net.Dns::GetHostByAddr_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByAddr_internal,
+       "System.Net.Dns::GetHostName_internal(string&)", ves_icall_System_Net_Dns_GetHostName_internal,
 
        /*
         * System.Char
@@ -2997,8 +3563,8 @@ static gconstpointer icall_map [] = {
         * System.Security.Cryptography calls
         */
 
-        "System.Security.Cryptography.RNGCryptoServiceProvider::GetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_GetBytes,
-        "System.Security.Cryptography.RNGCryptoServiceProvider::GetNonZeroBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_GetNonZeroBytes,
+        "System.Security.Cryptography.RNGCryptoServiceProvider::InternalGetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_InternalGetBytes,
+        "System.Security.Cryptography.RNGCryptoServiceProvider::InternalGetNonZeroBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_InternalGetNonZeroBytes,
        
        /*
         * System.Buffer
@@ -3011,29 +3577,29 @@ static gconstpointer icall_map [] = {
        /*
         * System.IO.MonoIO
         */
-       "System.IO.MonoIO::GetLastError", ves_icall_System_IO_MonoIO_GetLastError,
-       "System.IO.MonoIO::CreateDirectory", ves_icall_System_IO_MonoIO_CreateDirectory,
-       "System.IO.MonoIO::RemoveDirectory", ves_icall_System_IO_MonoIO_RemoveDirectory,
-       "System.IO.MonoIO::FindFirstFile", ves_icall_System_IO_MonoIO_FindFirstFile,
-       "System.IO.MonoIO::FindNextFile", ves_icall_System_IO_MonoIO_FindNextFile,
-       "System.IO.MonoIO::FindClose", ves_icall_System_IO_MonoIO_FindClose,
-       "System.IO.MonoIO::GetCurrentDirectory", ves_icall_System_IO_MonoIO_GetCurrentDirectory,
-       "System.IO.MonoIO::SetCurrentDirectory", ves_icall_System_IO_MonoIO_SetCurrentDirectory,
-       "System.IO.MonoIO::MoveFile", ves_icall_System_IO_MonoIO_MoveFile,
-       "System.IO.MonoIO::CopyFile", ves_icall_System_IO_MonoIO_CopyFile,
-       "System.IO.MonoIO::DeleteFile", ves_icall_System_IO_MonoIO_DeleteFile,
-       "System.IO.MonoIO::GetFileAttributes", ves_icall_System_IO_MonoIO_GetFileAttributes,
-       "System.IO.MonoIO::SetFileAttributes", ves_icall_System_IO_MonoIO_SetFileAttributes,
-       "System.IO.MonoIO::GetFileStat", ves_icall_System_IO_MonoIO_GetFileStat,
-       "System.IO.MonoIO::Open", ves_icall_System_IO_MonoIO_Open,
-       "System.IO.MonoIO::Close", ves_icall_System_IO_MonoIO_Close,
-       "System.IO.MonoIO::Read", ves_icall_System_IO_MonoIO_Read,
-       "System.IO.MonoIO::Write", ves_icall_System_IO_MonoIO_Write,
-       "System.IO.MonoIO::Seek", ves_icall_System_IO_MonoIO_Seek,
-       "System.IO.MonoIO::GetLength", ves_icall_System_IO_MonoIO_GetLength,
-       "System.IO.MonoIO::SetLength", ves_icall_System_IO_MonoIO_SetLength,
-       "System.IO.MonoIO::SetFileTime", ves_icall_System_IO_MonoIO_SetFileTime,
-       "System.IO.MonoIO::Flush", ves_icall_System_IO_MonoIO_Flush,
+       "System.IO.MonoIO::CreateDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CreateDirectory,
+       "System.IO.MonoIO::RemoveDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_RemoveDirectory,
+       "System.IO.MonoIO::FindFirstFile(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindFirstFile,
+       "System.IO.MonoIO::FindNextFile(intptr,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindNextFile,
+       "System.IO.MonoIO::FindClose(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindClose,
+       "System.IO.MonoIO::GetCurrentDirectory(System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetCurrentDirectory,
+       "System.IO.MonoIO::SetCurrentDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetCurrentDirectory,
+       "System.IO.MonoIO::MoveFile(string,string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_MoveFile,
+       "System.IO.MonoIO::CopyFile(string,string,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CopyFile,
+       "System.IO.MonoIO::DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile,
+       "System.IO.MonoIO::GetFileAttributes(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileAttributes,
+       "System.IO.MonoIO::SetFileAttributes(string,System.IO.FileAttributes,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileAttributes,
+       "System.IO.MonoIO::GetFileType(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileType,
+       "System.IO.MonoIO::GetFileStat(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileStat,
+       "System.IO.MonoIO::Open(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Open,
+       "System.IO.MonoIO::Close(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Close,
+       "System.IO.MonoIO::Read(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Read,
+       "System.IO.MonoIO::Write(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Write,
+       "System.IO.MonoIO::Seek(intptr,long,System.IO.SeekOrigin,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Seek,
+       "System.IO.MonoIO::GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength,
+       "System.IO.MonoIO::SetLength(intptr,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetLength,
+       "System.IO.MonoIO::SetFileTime(intptr,long,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileTime,
+       "System.IO.MonoIO::Flush(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Flush,
        "System.IO.MonoIO::get_ConsoleOutput", ves_icall_System_IO_MonoIO_get_ConsoleOutput,
        "System.IO.MonoIO::get_ConsoleInput", ves_icall_System_IO_MonoIO_get_ConsoleInput,
        "System.IO.MonoIO::get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError,
@@ -3047,21 +3613,24 @@ static gconstpointer icall_map [] = {
        /*
         * System.Math
         */
+       "System.Math::Floor", ves_icall_System_Math_Floor,
+       "System.Math::Round", ves_icall_System_Math_Round,
+       "System.Math::Round2", ves_icall_System_Math_Round2,
        "System.Math::Sin", ves_icall_System_Math_Sin,
-    "System.Math::Cos", ves_icall_System_Math_Cos,
-    "System.Math::Tan", ves_icall_System_Math_Tan,
-    "System.Math::Sinh", ves_icall_System_Math_Sinh,
-    "System.Math::Cosh", ves_icall_System_Math_Cosh,
-    "System.Math::Tanh", ves_icall_System_Math_Tanh,
-    "System.Math::Acos", ves_icall_System_Math_Acos,
-    "System.Math::Asin", ves_icall_System_Math_Asin,
-    "System.Math::Atan", ves_icall_System_Math_Atan,
-    "System.Math::Atan2", ves_icall_System_Math_Atan2,
-    "System.Math::Exp", ves_icall_System_Math_Exp,
-    "System.Math::Log", ves_icall_System_Math_Log,
-    "System.Math::Log10", ves_icall_System_Math_Log10,
-    "System.Math::PowImpl", ves_icall_System_Math_Pow,
-    "System.Math::Sqrt", ves_icall_System_Math_Sqrt,
+        "System.Math::Cos", ves_icall_System_Math_Cos,
+        "System.Math::Tan", ves_icall_System_Math_Tan,
+        "System.Math::Sinh", ves_icall_System_Math_Sinh,
+        "System.Math::Cosh", ves_icall_System_Math_Cosh,
+        "System.Math::Tanh", ves_icall_System_Math_Tanh,
+        "System.Math::Acos", ves_icall_System_Math_Acos,
+        "System.Math::Asin", ves_icall_System_Math_Asin,
+        "System.Math::Atan", ves_icall_System_Math_Atan,
+        "System.Math::Atan2", ves_icall_System_Math_Atan2,
+        "System.Math::Exp", ves_icall_System_Math_Exp,
+        "System.Math::Log", ves_icall_System_Math_Log,
+        "System.Math::Log10", ves_icall_System_Math_Log10,
+        "System.Math::Pow", ves_icall_System_Math_Pow,
+        "System.Math::Sqrt", ves_icall_System_Math_Sqrt,
 
        /*
         * System.Environment
@@ -3074,6 +3643,8 @@ static gconstpointer icall_map [] = {
        "System.Environment::get_TickCount", ves_icall_System_Environment_get_TickCount,
        "System.Environment::Exit", ves_icall_System_Environment_Exit,
        "System.Environment::get_Platform", ves_icall_System_Environment_get_Platform,
+       "System.Environment::get_ExitCode", mono_environment_exitcode_get,
+       "System.Environment::set_ExitCode", mono_environment_exitcode_set,
 
        /*
         * System.Runtime.Remoting
@@ -3083,6 +3654,14 @@ static gconstpointer icall_map [] = {
        "System.Runtime.Remoting.RemotingServices::IsTransparentProxy",
        ves_icall_IsTransparentProxy,
 
+       /*
+        * System.Runtime.Remoting.Activation
+        */     
+       "System.Runtime.Remoting.Activation.ActivationServices::AllocateUninitializedClassInstance",
+       ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance,
+       "System.Runtime.Remoting.Activation.ActivationServices::EnableProxyActivation",
+       ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation,
+
        /*
         * System.Runtime.Remoting.Messaging
         */     
@@ -3092,7 +3671,7 @@ static gconstpointer icall_map [] = {
        /*
         * System.Runtime.Remoting.Proxies
         */     
-       "System.Runtime.Remoting.Proxies.RealProxy::GetTransparentProxy", 
+       "System.Runtime.Remoting.Proxies.RealProxy::InternalGetTransparentProxy", 
        ves_icall_Remoting_RealProxy_GetTransparentProxy,
 
        /*
@@ -3112,7 +3691,8 @@ static gconstpointer icall_map [] = {
        /*
         * System.Diagnostics.Process
         */
-       "System.Diagnostics.Process::GetCurrentProcess_internal()", ves_icall_System_Diagnostics_Process_GetCurrentProcess_internal,
+       "System.Diagnostics.Process::GetProcess_internal(int)", ves_icall_System_Diagnostics_Process_GetProcess_internal,
+       "System.Diagnostics.Process::GetProcesses_internal()", ves_icall_System_Diagnostics_Process_GetProcesses_internal,
        "System.Diagnostics.Process::GetPid_internal()", ves_icall_System_Diagnostics_Process_GetPid_internal,
        "System.Diagnostics.Process::Process_free_internal(intptr)", ves_icall_System_Diagnostics_Process_Process_free_internal,
        "System.Diagnostics.Process::GetModules_internal()", ves_icall_System_Diagnostics_Process_GetModules_internal,
@@ -3121,6 +3701,9 @@ static gconstpointer icall_map [] = {
        "System.Diagnostics.Process::ExitTime_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitTime_internal,
        "System.Diagnostics.Process::StartTime_internal(intptr)", ves_icall_System_Diagnostics_Process_StartTime_internal,
        "System.Diagnostics.Process::ExitCode_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitCode_internal,
+       "System.Diagnostics.Process::ProcessName_internal(intptr)", ves_icall_System_Diagnostics_Process_ProcessName_internal,
+       "System.Diagnostics.Process::GetWorkingSet_internal(intptr,int&,int&)", ves_icall_System_Diagnostics_Process_GetWorkingSet_internal,
+       "System.Diagnostics.Process::SetWorkingSet_internal(intptr,int,int,bool)", ves_icall_System_Diagnostics_Process_SetWorkingSet_internal,
        "System.Diagnostics.FileVersionInfo::GetVersionInfo_internal(string)", ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal,
 
        /* 
@@ -3145,9 +3728,32 @@ static gconstpointer icall_map [] = {
        "System.Reflection.Assembly::MonoDebugger_GetMethod",
        ves_icall_MonoDebugger_GetMethod,
 
+       "System.Reflection.Assembly::MonoDebugger_GetMethodToken",
+       ves_icall_MonoDebugger_GetMethodToken,
+
        "System.Reflection.Assembly::MonoDebugger_GetLocalTypeFromSignature",
        ves_icall_MonoDebugger_GetLocalTypeFromSignature,
 
+       "System.Reflection.Assembly::MonoDebugger_GetType",
+       ves_icall_MonoDebugger_GetType,
+
+       /*
+        * System.Configuration
+        */
+       "System.Configuration.DefaultConfig::get_machine_config_path",
+       ves_icall_System_Configuration_DefaultConfig_get_machine_config_path,
+
+       /*
+        * System.Diagnostics.DefaultTraceListener
+        */
+       "System.Diagnostics.DefaultTraceListener::WriteWindowsDebugString",
+       ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString,
+       /*
+        * System.Activator
+        */
+       "System.Activator::CreateInstanceInternal",
+       ves_icall_System_Activator_CreateInstanceInternal,
+
        /*
         * add other internal calls here
         */