[coop] InternalGetHashCode (mono/mono#16583)
authorJay Krell <jaykrell@microsoft.com>
Sat, 31 Aug 2019 07:38:12 +0000 (00:38 -0700)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Sat, 31 Aug 2019 07:38:12 +0000 (09:38 +0200)
Commit migrated from https://github.com/mono/mono/commit/cba94f28bed566e7a976842d016a7b2d4ef3f91a

src/mono/mono/metadata/icall-def-netcore.h
src/mono/mono/metadata/icall-def.h
src/mono/mono/metadata/monitor.c
src/mono/mono/metadata/object-internals.h

index 5a953db..b7e951f 100644 (file)
@@ -323,7 +323,7 @@ ICALL_TYPE(RUNH, "System.Runtime.CompilerServices.RuntimeHelpers", RUNH_1)
 HANDLES(RUNH_1, "GetObjectValue", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue, MonoObject, 1, (MonoObject))
 HANDLES(RUNH_2, "GetUninitializedObjectInternal", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetUninitializedObjectInternal, MonoObject, 1, (MonoType_ptr))
 HANDLES(RUNH_3, "InitializeArray", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray, void, 2, (MonoArray, MonoClassField_ptr))
-ICALL(RUNH_7, "InternalGetHashCode", mono_object_hash_internal)
+HANDLES(RUNH_7, "InternalGetHashCode", mono_object_hash_icall, int, 1, (MonoObject))
 HANDLES(RUNH_3a, "PrepareMethod", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_PrepareMethod, void, 3, (MonoMethod_ptr, gpointer, int))
 HANDLES(RUNH_4, "RunClassConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor, void, 1, (MonoType_ptr))
 HANDLES(RUNH_5, "RunModuleConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunModuleConstructor, void, 1, (MonoImage_ptr))
index c50da32..ebb5b76 100644 (file)
@@ -581,7 +581,7 @@ NOHANDLES(ICALL(NUMBER_FORMATTER_1, "GetFormatterTables", ves_icall_System_Numbe
 
 ICALL_TYPE(OBJ, "System.Object", OBJ_1)
 HANDLES(OBJ_1, "GetType", ves_icall_System_Object_GetType, MonoReflectionType, 1, (MonoObject))
-ICALL(OBJ_2, "InternalGetHashCode", mono_object_hash_internal)
+HANDLES(OBJ_2, "InternalGetHashCode", mono_object_hash_icall, int, 1, (MonoObject))
 HANDLES(OBJ_3, "MemberwiseClone", ves_icall_System_Object_MemberwiseClone, MonoObject, 1, (MonoObject))
 
 ICALL_TYPE(ASSEM, "System.Reflection.Assembly", ASSEM_2)
index 296b48b..146ecd7 100644 (file)
@@ -34,6 +34,7 @@
 #include <mono/utils/w32api.h>
 #include <mono/utils/mono-os-wait.h>
 #include "external-only.h"
+#include "icall-decl.h"
 
 /*
  * Pull the list of opcodes
@@ -561,6 +562,7 @@ int
 mono_object_hash_internal (MonoObject* obj)
 {
 #ifdef HAVE_MOVING_COLLECTOR
+
        LockWord lw;
        unsigned int hash;
        if (!obj)
@@ -619,13 +621,22 @@ mono_object_hash_internal (MonoObject* obj)
        mono_memory_write_barrier ();
        obj->synchronisation = lw.sync;
        return hash;
+
 #else
+
 /*
  * Wang's address-based hash function:
  *   http://www.concentric.net/~Ttwang/tech/addrhash.htm
  */
        return (GPOINTER_TO_UINT (obj) >> MONO_OBJECT_ALIGNMENT_SHIFT) * 2654435761u;
 #endif
+
+}
+
+int
+mono_object_hash_icall (MonoObjectHandle obj, MonoError* error)
+{
+       return mono_object_hash_internal (MONO_HANDLE_RAW (obj));
 }
 
 /*
@@ -637,6 +648,7 @@ mono_object_hash_internal (MonoObject* obj)
 int
 mono_object_hash (MonoObject* obj)
 {
+       // FIXME slow?
        MONO_EXTERNAL_ONLY (int, mono_object_hash_internal (obj));
 }
 
@@ -1062,6 +1074,7 @@ mono_monitor_enter_internal (MonoObject *obj)
 gboolean
 mono_monitor_enter (MonoObject *obj)
 {
+       // FIXME slow?
        MONO_EXTERNAL_ONLY (gboolean, mono_monitor_enter_internal (obj));
 }
 
index 554f711..eb5bda7 100644 (file)
@@ -2283,7 +2283,6 @@ mono_string_equal_internal (MonoString *s1, MonoString *s2);
 unsigned
 mono_string_hash_internal (MonoString *s);
 
-ICALL_EXPORT
 int
 mono_object_hash_internal (MonoObject* obj);