(mono_runtime_delegate_invoke): impl.
[mono.git] / mono / metadata / icall.c
index c862d05ccf8d28a3b9f55e12a30ffede6eaac191..4fbb9c192522eb167538a6a3f2e2b8f61e8bae17 100644 (file)
@@ -37,6 +37,7 @@
 #include <mono/metadata/debug-symfile.h>
 #include <mono/metadata/string-icalls.h>
 #include <mono/io-layer/io-layer.h>
+#include <mono/utils/strtod.h>
 
 #if defined (PLATFORM_WIN32)
 #include <windows.h>
@@ -52,6 +53,15 @@ mono_double_ToStringImpl (double value)
        return mono_string_new (mono_domain_get (), retVal);
 }
 
+/*
+ * We expect a pointer to a char, not a string
+ */
+static double
+mono_double_ParseImpl (char *ptr)
+{
+       return bsd_strtod (ptr, NULL);
+}
+
 static MonoString *
 mono_float_ToStringImpl (float value)
 {
@@ -555,10 +565,27 @@ ves_icall_System_Object_MemberwiseClone (MonoObject *this)
        return mono_object_clone (this);
 }
 
+#if HAVE_BOEHM_GC
+#define MONO_OBJECT_ALIGNMENT_SHIFT    3
+#else
+#define MONO_OBJECT_ALIGNMENT_SHIFT    2
+#endif
+
+/*
+ * Return hashcode based on object address. This function will need to be
+ * smarter in the presence of a moving garbage collector, which will cache
+ * the address hash before relocating the object.
+ *
+ * Wang's address-based hash function:
+ *   http://www.concentric.net/~Ttwang/tech/addrhash.htm
+ */
 static gint32
 ves_icall_System_Object_GetHashCode (MonoObject *this)
 {
-       return *((gint32 *)this - 1);
+       register guint32 key;
+       key = (GPOINTER_TO_UINT (this) >> MONO_OBJECT_ALIGNMENT_SHIFT) * 2654435761u;
+
+       return key & 0x7fffffff;
 }
 
 /*
@@ -924,7 +951,7 @@ ves_icall_get_type_info (MonoType *type, MonoTypeInfo *info)
 static MonoObject *
 ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params) 
 {
-       return mono_runtime_invoke_array (method->method, this, params);
+       return mono_runtime_invoke_array (method->method, this, params, NULL);
 }
 
 static MonoObject *
@@ -1019,7 +1046,7 @@ ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoA
        if (!strcmp (method->method->name, ".ctor"))
                g_assert_not_reached ();
 
-       result = mono_runtime_invoke_array (method->method, this, params);
+       result = mono_runtime_invoke_array (method->method, this, params, NULL);
 
        *outArgs = out_args;
 
@@ -1679,9 +1706,10 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
        int i, count;
        guint32 attrs, visibility;
 
+       /* we start the count from 1 because we skip the special type <Module> */
        if (exportedOnly) {
                count = 0;
-               for (i = 0; i < tdef->rows; ++i) {
+               for (i = 1; i < tdef->rows; ++i) {
                        attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
                        visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
                        if (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)
@@ -1692,7 +1720,7 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
        }
        res = mono_array_new (domain, mono_defaults.monotype_class, count);
        count = 0;
-       for (i = 0; i < tdef->rows; ++i) {
+       for (i = 1; i < tdef->rows; ++i) {
                attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
                visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
                if (!exportedOnly || (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)) {
@@ -2098,13 +2126,11 @@ ves_icall_System_Environment_GetEnvironmentVariableNames (void)
        return names;
 }
 
-int ves_icall_System_Environment_get_TickCount (void);
-
 /*
  * Returns the number of milliseconds elapsed since the system started.
  */
 static gint32
-ves_icall_System_Environment_get_TickCount ()
+ves_icall_System_Environment_get_TickCount (void)
 {
 #if defined (PLATFORM_WIN32)
        return GetTickCount();
@@ -2245,6 +2271,7 @@ static gconstpointer icall_map [] = {
         * System.Double
         */
        "System.Double::ToStringImpl", mono_double_ToStringImpl,
+       "System.Double::ParseImpl",    mono_double_ParseImpl,
 
        /*
         * System.Single