Compare commits

...
35 Commits
Author SHA1 Message Date
Vlad Brezae 4a50a2eb04 Fix jit regression 2019-11-18 18:13:13 +02:00
Vlad Brezae e0217d6371 Bump coreclr to include layout / gcdescr changes 2019-11-18 15:07:03 +02:00
Vlad Brezae 75eaefcff7 No critical regions on coregc
Should add them later
2019-11-18 14:49:37 +02:00
Vlad Brezae a7db40a813 Pin internal thread object
It is used in start_wrapper_internal which doesn't register its stack end. Not sure yet where sgen pins this from.
2019-11-18 14:46:35 +02:00
Vlad Brezae 05f0f319f5 Add scanning of roots 2019-11-18 14:46:35 +02:00
Vlad Brezae 48a6994de5 Add gc descriptors for objects
We store them before the imt tables, which currently always wastes imt space and is not optimized for gc access since it is far away from vtable pointer. CoreGC doesn't yet know how to scan value arrays, but it is enough for simple tests.
2019-11-18 14:46:31 +02:00
Vlad Brezae d3292aa3cf Implement api for triggering manual collections 2019-11-17 16:07:23 +02:00
Vlad Brezae 345c823407 Enable running of empty application 2019-11-17 15:55:28 +02:00
Vlad Brezae 31dd8c2ee3 Add some missing api 2019-11-15 14:51:22 +01:00
Vlad Brezae 2b0cc9644a Another fix for object allocation size
We might need to have the minimal object size represented also in the vtable base size for normal objects in the future.
2019-11-15 14:30:36 +01:00
Vlad Brezae 08253d307f Add support for gchandles 2019-11-15 00:09:27 +01:00
Vlad Brezae 6b354998f9 Switch runtime to ptr sizes gchandles
In order to align to CoreGC handles. Breaks embedding api and products.
2019-11-14 23:28:23 +01:00
Vlad Brezae a60df8f914 I'm stupid 2019-11-14 21:35:44 +01:00
Vlad Brezae 2ace29070d Add missing vtable storing 2019-11-14 20:06:00 +01:00
Vlad Brezae d31389ecd7 Finish write barriers 2019-11-14 20:02:28 +01:00
Vlad Brezae 9e912609b6 Header is not included in object sizes
Except for free object apparently ?
2019-11-14 19:17:15 +01:00
Vlad Brezae ed278e541c Add allocation 2019-11-14 18:33:38 +01:00
Vlad Brezae 97281d6f84 Make sure we have handle stack allocated
This allocation should be done outside of sgen
2019-11-14 18:33:07 +01:00
Vlad Brezae 2736860b21 Add root registering mechanism 2019-11-14 17:41:37 +01:00
Vlad Brezae 06ae29dfe0 Add encoding for root descriptors
Same as sgen. We don't need SgenArrayList since all root scanning should happen with the world stopped, so no complex descriptors can be allocated.
2019-11-14 12:21:22 +01:00
Vlad Brezae 9ebe96f923 Remove fields that are not used and don't look like they will 2019-11-14 10:26:31 +01:00
Vlad Brezae 466440920b Add support for mono object size computation, and various flags
This information is accessed through the vtable->gc_descr field. The vtable will need a new, larger real gcdescr to be used by the gc to find object references.
2019-11-13 16:53:29 +01:00
Imran Hameed 72efb8ad49 Draft STW implementation for CoreCLR GC. 2019-11-12 09:05:01 -08:00
Bernhard Urban-Forster e0229d06aa [coregc] implement mono_gc_wbarrier_object_copy_internal 2019-11-12 17:43:04 +01:00
Bernhard Urban 37f8d4e654 [configure] require CXX linker when coregc is enabled 2019-11-09 04:27:07 -08:00
Vlad Brezae e98e13652f Revert "[coregc] implement GCToEEInterface::GetFreeObjectMethodTable"
This reverts commit 893c7c7caa.
2019-11-09 14:03:40 +02:00
Vlad Brezae e887042951 Add missing api which is used on linux 2019-11-09 14:03:24 +02:00
Vlad Brezae 7914e0cc6b Add some needed configure checks for coregc on ubuntu 2019-11-09 13:22:17 +02:00
Bernhard Urban-Forster 893c7c7caa [coregc] implement GCToEEInterface::GetFreeObjectMethodTable 2019-11-09 12:05:39 +01:00
Vlad Brezae f1ce89d63f Add initial glue
Mono will invoke gc functionality through the standard mono_gc api. The glue should implement this API and invoke GC functionality through pGCHeap and pGCHandleManager. The GC will ask for runtime information through the registered GCToEEInterface.
2019-11-08 19:05:34 +02:00
Vlad Brezae 8a915e5f3a bump coreclr 2019-11-08 17:42:13 +02:00
Vlad Brezae 9e27c03294 Make coregc-mono c++ so we can interact with coregc interface
Removed HAVE_CORE_GC from coregc-mono.cpp since I'm too stupid to pass this flag to the c++ compiler.
2019-11-07 17:48:48 +02:00
Bernhard Urban-Forster 34504f021d bump coreclr 2019-11-06 21:58:51 +01:00
Bernhard Urban-Forster 8195519607 initial build support for coreclr gc 2019-11-06 21:58:51 +01:00
Bernhard Urban-Forster 7625234438 add mono/coreclr submodule with mono-coregc branch 2019-11-06 09:09:58 +01:00
65 changed files with 2341 additions and 281 deletions

No files matched your search

+4
View File
@@ -68,3 +68,7 @@
[submodule "external/illinker-test-assets"]
path = external/illinker-test-assets
url = git://github.com/mono/illinker-test-assets.git
[submodule "coreclr"]
path = external/coreclr
url = git://github.com/mono/coreclr.git
branch = mono-coregc
+39 -1
View File
@@ -2179,6 +2179,25 @@ if test x$host_win32 = xno; then
AC_SEARCH_LIBS(clock_gettime, rt)
AC_CHECK_FUNCS(clock_nanosleep)
AC_MSG_CHECKING(for _SC_AVPHYS_PAGES)
AC_TRY_COMPILE([#include <unistd.h>], [
const int foo = _SC_AVPHYS_PAGES;
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE__SC_AVPHYS_PAGES, 1, [_SC_AVPHYS_PAGES])
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(for _SC_PHYS_PAGES)
AC_TRY_COMPILE([#include <unistd.h>], [
const int foo = _SC_PHYS_PAGES;
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE__SC_PHYS_PAGES, 1, [_SC_PHYS_PAGES])
], [
AC_MSG_RESULT(no)
])
dnl dynamic loader support
AC_CHECK_FUNC(dlopen, DL_LIB="",
AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", dl_support=no)
@@ -2775,6 +2794,7 @@ if test x$host_win32 = xno; then
AC_CHECK_FUNCS(pthread_attr_setstacksize)
AC_CHECK_FUNCS(pthread_attr_getstack pthread_attr_getstacksize)
AC_CHECK_FUNCS(pthread_get_stacksize_np pthread_get_stackaddr_np)
AC_CHECK_FUNCS(pthread_condattr_setclock)
dnl check that pthread_mutexattr_setprotocol is declared
AC_CHECK_DECLS([pthread_mutexattr_setprotocol], [], [], [[#include <pthread.h>]])
AC_CHECK_FUNCS(mincore mlock munlock)
@@ -4940,6 +4960,23 @@ fi
AC_SUBST(SGEN_DEFINES)
AM_CONDITIONAL(SUPPORT_SGEN, test x$buildsgen = xyes)
dnl
dnl CoreCLR GC checks (coregc)
dnl
COREGC_DEFINES=
AC_ARG_WITH(coregc, [ --with-coregc=yes,no CoreCLR GC, default=yes],[buildcoregc=$with_coregc],[buildcoregc=yes])
if test x$buildcoregc = xyes; then
AC_DEFINE(HAVE_MOVING_COLLECTOR, 1, [Moving collector])
COREGC_DEFINES="-DHAVE_CORE_GC --std=gnu++11"
if test "x$gc_msg" = "x"; then
gc_msg="coregc"
else
gc_msg="coregc and $gc_msg"
fi
fi
AC_SUBST(COREGC_DEFINES)
AM_CONDITIONAL(SUPPORT_COREGC, test x$buildcoregc = xyes)
jit_status="Building and using the JIT"
libsuffix=".so"
@@ -6629,7 +6666,7 @@ AC_SUBST(MONO_NATIVE_PLATFORM_TYPE_UNIFIED)
# mono/mini/Makefile.am.in we have CCLD=$MONO_CXXLD and CXXLD=$MONO_CXXLD which bypasses
# automake's autodetection and lets us use the linker that we want.
#
if test "x$enable_llvm_runtime" = "xyes"; then
if test "x$enable_llvm_runtime" = "xyes" || test "x$buildcoregc" = "xyes"; then
AC_SUBST(MONO_CXXLD, [$CXX])
else
AC_SUBST(MONO_CXXLD, [$CC])
@@ -6720,6 +6757,7 @@ mono/arch/arm64/Makefile
mono/arch/mips/Makefile
mono/arch/riscv/Makefile
mono/sgen/Makefile
mono/coregc/Makefile
mono/native/platform-type.c
mono/native/platform-type-compat.c
mono/native/platform-type-unified.c
Vendored Submodule
+1
Submodule external/coreclr added at b1f16cf71f.
@@ -42,11 +42,11 @@ namespace System.Runtime.InteropServices
public struct GCHandle
{
// fields
private int handle;
private IntPtr handle;
private GCHandle(IntPtr h)
{
handle = (int)h;
handle = h;
}
// Constructors
@@ -59,7 +59,7 @@ namespace System.Runtime.InteropServices
// MS does not crash/throw on (most) invalid GCHandleType values (except -1)
if ((type < GCHandleType.Weak) || (type > GCHandleType.Pinned))
type = GCHandleType.Normal;
handle = GetTargetHandle (value, 0, type);
handle = GetTargetHandle (value, IntPtr.Zero, type);
}
// Properties
@@ -68,7 +68,7 @@ namespace System.Runtime.InteropServices
{
get
{
return (handle != 0);
return (handle != IntPtr.Zero);
}
}
@@ -111,10 +111,10 @@ namespace System.Runtime.InteropServices
{
// Copy the handle instance member to a local variable. This is required to prevent
// race conditions releasing the handle.
int local_handle = handle;
IntPtr local_handle = handle;
// Free the handle if it hasn't already been freed.
if (local_handle != 0 && Interlocked.CompareExchange (ref handle, 0, local_handle) == local_handle) {
if (local_handle != IntPtr.Zero && Interlocked.CompareExchange (ref handle, IntPtr.Zero, local_handle) == local_handle) {
FreeHandle (local_handle);
}
else {
@@ -131,25 +131,25 @@ namespace System.Runtime.InteropServices
{
if (value == IntPtr.Zero)
throw new InvalidOperationException ("GCHandle value cannot be zero");
if (!CheckCurrentDomain ((int)value))
if (!CheckCurrentDomain (value))
throw new ArgumentException ("GCHandle value belongs to a different domain");
return new GCHandle (value);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static bool CheckCurrentDomain (int handle);
private extern static bool CheckCurrentDomain (IntPtr handle);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static object GetTarget(int handle);
private extern static object GetTarget(IntPtr handle);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static int GetTargetHandle(object obj, int handle, GCHandleType type);
private extern static IntPtr GetTargetHandle(object obj, IntPtr handle, GCHandleType type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static void FreeHandle(int handle);
private extern static void FreeHandle(IntPtr handle);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static IntPtr GetAddrOfPinnedObject(int handle);
private extern static IntPtr GetAddrOfPinnedObject(IntPtr handle);
public static bool operator ==(GCHandle a, GCHandle b)
{
+8 -4
View File
@@ -4,6 +4,10 @@ if SUPPORT_SGEN
sgen_dirs = sgen
endif
if SUPPORT_COREGC
coregc_dirs = coregc
endif
if BTLS
btls_dirs = btls
endif
@@ -21,10 +25,10 @@ SUBDIRS = eglib arch utils sgen metadata mini profiler
else
if CROSS_COMPILING
SUBDIRS = $(btls_dirs) eglib arch utils cil $(sgen_dirs) metadata mini dis profiler $(native_dirs)
SUBDIRS = $(btls_dirs) eglib arch utils cil $(sgen_dirs) $(coregc_dirs) metadata mini dis profiler $(native_dirs)
else
if INSTALL_MONOTOUCH
SUBDIRS = $(btls_dirs) eglib arch utils $(sgen_dirs) metadata mini profiler $(native_dirs)
SUBDIRS = $(btls_dirs) eglib arch utils $(sgen_dirs) $(coregc_dirs) metadata mini profiler $(native_dirs)
monotouch-do-build:
@list='$(SUBDIRS)'; for subdir in $$list; do \
@@ -48,9 +52,9 @@ monotouch-do-clean:
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target); \
done;
else
SUBDIRS = $(btls_dirs) eglib arch utils cil $(sgen_dirs) metadata mini dis tests unit-tests benchmark profiler $(native_dirs)
SUBDIRS = $(btls_dirs) eglib arch utils cil $(sgen_dirs) $(coregc_dirs) metadata mini dis tests unit-tests benchmark profiler $(native_dirs)
endif
endif
endif
DIST_SUBDIRS = btls native eglib arch utils cil $(sgen_dirs) metadata mini dis tests unit-tests benchmark profiler
DIST_SUBDIRS = btls native eglib arch utils cil $(sgen_dirs) $(coregc_dirs) metadata mini dis tests unit-tests benchmark profiler
+8
View File
@@ -0,0 +1,8 @@
/Makefile
/Makefile.in
/.libs
/.deps
/*.lo
/*.la
/*.o
/*.a
+76
View File
@@ -0,0 +1,76 @@
include $(top_srcdir)/mk/common.mk
# FIXME
TMPFLAGS=-D_AMD64_ -DBIT64 -D_ASSERTE= -DFEATURE_REDHAWK -DPLATFORM_UNIX
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/mono \
-I$(top_srcdir)/external/coreclr/src/gc \
-I$(top_srcdir)/external/coreclr/src/gc/env \
-I$(top_srcdir)/external/coreclr/src/gc/unix \
$(TMPFLAGS) \
$(LIBGC_CPPFLAGS) $(GLIB_CFLAGS) $(SHARED_CFLAGS)
if SUPPORT_COREGC
shared_libraries = libmonocoregc.la
endif
noinst_LTLIBRARIES = $(shared_libraries)
monocoregc_sources = \
../../external/coreclr/src/gc/gceventstatus.cpp \
../../external/coreclr/src/gc/gceventstatus.h \
../../external/coreclr/src/gc/gcconfig.cpp \
../../external/coreclr/src/gc/gcconfig.h \
../../external/coreclr/src/gc/gccommon.cpp \
../../external/coreclr/src/gc/gcsvr.cpp \
../../external/coreclr/src/gc/gcwks.cpp \
../../external/coreclr/src/gc/handletable.cpp \
../../external/coreclr/src/gc/handletable.h \
../../external/coreclr/src/gc/handletablepriv.h \
../../external/coreclr/src/gc/handletablecore.cpp \
../../external/coreclr/src/gc/handletablescan.cpp \
../../external/coreclr/src/gc/objecthandle.cpp \
../../external/coreclr/src/gc/objecthandle.h \
../../external/coreclr/src/gc/softwarewritewatch.cpp \
../../external/coreclr/src/gc/softwarewritewatch.h \
../../external/coreclr/src/gc/gchandletable.cpp \
../../external/coreclr/src/gc/gchandletableimpl.h \
../../external/coreclr/src/gc/gceesvr.cpp \
../../external/coreclr/src/gc/gceewks.cpp \
../../external/coreclr/src/gc/gcload.cpp \
../../external/coreclr/src/gc/handletablecache.cpp \
../../external/coreclr/src/gc/unix/gcenv.unix.cpp \
../../external/coreclr/src/gc/unix/events.cpp \
../../external/coreclr/src/gc/unix/cgroup.cpp \
../../external/coreclr/src/gc/unix/cgroup.h \
../../external/coreclr/src/gc/gcscan.cpp \
../../external/coreclr/src/gc/gcscan.h
# ../../external/coreclr/src/gc/WarningControl.h \
# ../../external/coreclr/src/gc/env \
# ../../external/coreclr/src/gc/gc.cpp \
# ../../external/coreclr/src/gc/gc.h \
# ../../external/coreclr/src/gc/gcdesc.h \
# ../../external/coreclr/src/gc/gcee.cpp \
# ../../external/coreclr/src/gc/gcenv.ee.standalone.inl \
# ../../external/coreclr/src/gc/gcenv.inl \
# ../../external/coreclr/src/gc/gcevent_serializers.h \
# ../../external/coreclr/src/gc/gcevents.h \
# ../../external/coreclr/src/gc/gcimpl.h \
# ../../external/coreclr/src/gc/gcinterface.dac.h \
# ../../external/coreclr/src/gc/gcinterface.dacvars.def \
# ../../external/coreclr/src/gc/gcinterface.ee.h \
# ../../external/coreclr/src/gc/gcinterface.h \
# ../../external/coreclr/src/gc/gcpriv.h \
# ../../external/coreclr/src/gc/gcrecord.h \
# ../../external/coreclr/src/gc/handletable.inl \
# ../../external/coreclr/src/gc/unix/CMakeLists.txt
# ../../external/coreclr/src/gc/unix/config.gc.h.in \
# ../../external/coreclr/src/gc/unix/configure.cmake \
# ../../external/coreclr/src/gc/unix/globals.h
libmonocoregc_la_SOURCES = $(monocoregc_sources)
libmonocoregc_la_CFLAGS = $(COREGC_DEFINES)
libmonocoregc_la_CXXFLAGS = $(COREGC_DEFINES)
CFLAGS := $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @CXX_ADD_CFLAGS@
+14 -1
View File
@@ -83,6 +83,10 @@ if SUPPORT_BOEHM
boehm_libraries = libmonoruntime.la
endif
if SUPPORT_COREGC
coregc_libraries = libmonoruntimecoregc.la
endif
if DISABLE_ICALL_TABLES
icall_table_libraries = libmono-icall-table.la
endif
@@ -139,7 +143,7 @@ Z_LIBS=
endif
endif
noinst_LTLIBRARIES = libmonoruntime-config.la libmonoruntime-support.la $(boehm_libraries) $(sgen_libraries)
noinst_LTLIBRARIES = libmonoruntime-config.la libmonoruntime-support.la $(boehm_libraries) $(sgen_libraries) $(coregc_libraries)
lib_LTLIBRARIES = $(icall_table_libraries) $(ilgen_libraries)
@@ -447,6 +451,10 @@ sgen_sources = \
sgen-mono.h \
sgen-client-mono.h
coregc_sources = \
coregc-mono.cpp \
coregc-mono.h
endif # !ENABLE_MSVC_ONLY
# Per-library to workaround CoreFX/native until/unless https://github.com/dotnet/corefx/pull/31342.
@@ -465,6 +473,11 @@ libmonoruntimesgen_la_SOURCES = $(common_sources) $(icall_tables_sources) $(ilge
libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES) @CXX_ADD_CFLAGS@
libmonoruntimesgen_la_LIBADD = libmonoruntime-config.la libmonoruntime-support.la
libmonoruntimecoregc_la_SOURCES = $(common_sources) $(icall_tables_sources) $(ilgen_sources) $(gc_dependent_sources) $(coregc_sources)
# Add CXX_ADD_CFLAGS per-library until/unless https://github.com/dotnet/corefx/pull/31342.
libmonoruntimecoregc_la_CFLAGS = $(COREGC_DEFINES) @CXX_ADD_CFLAGS@
libmonoruntimecoregc_la_LIBADD = libmonoruntime-config.la libmonoruntime-support.la
endif # !ENABLE_MSVC_ONLY
libmonoruntimeincludedir = $(includedir)/mono-$(API_VER)/mono/metadata
+4 -4
View File
@@ -760,7 +760,7 @@ mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetupHa
MonoStringHandle root_app_base = MONO_HANDLE_NEW_GET (MonoString, root_setup, application_base);
if (!MONO_HANDLE_IS_NULL (root_app_base)) {
/* N.B. new string is in the new domain */
uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, root_app_base), TRUE);
gpointer gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, root_app_base), TRUE);
MonoStringHandle s = mono_string_new_utf16_handle (data, mono_string_chars_internal (MONO_HANDLE_RAW (root_app_base)), mono_string_handle_length (root_app_base), error);
mono_gchandle_free_internal (gchandle);
if (!is_ok (error)) {
@@ -2679,7 +2679,7 @@ ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomainHandle ad,
mono_error_set_out_of_memory (error, "Could not allocate %ud bytes to copy raw assembly data", raw_assembly_len);
return refass;
}
uint32_t gchandle;
gpointer gchandle;
mono_byte *raw_data = (mono_byte*) MONO_ARRAY_HANDLE_PIN (raw_assembly, gchar, 0, &gchandle);
memcpy (assembly_data, raw_data, raw_assembly_len);
mono_gchandle_free_internal (gchandle); /* unpin */
@@ -2689,7 +2689,7 @@ ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomainHandle ad,
mono_byte *raw_symbol_data = NULL;
guint32 symbol_len = 0;
uint32_t symbol_gchandle = 0;
gpointer symbol_gchandle = 0;
if (!MONO_HANDLE_IS_NULL (raw_symbol_store)) {
symbol_len = mono_array_handle_length (raw_symbol_store);
raw_symbol_data = (mono_byte*) MONO_ARRAY_HANDLE_PIN (raw_symbol_store, mono_byte, 0, &symbol_gchandle);
@@ -2999,7 +2999,7 @@ ves_icall_System_AppDomain_InternalGetProcessGuid (MonoStringHandle newguid, Mon
mono_domain_unlock (mono_root_domain);
return mono_string_new_utf16_handle (mono_domain_get (), process_guid, sizeof(process_guid)/2, error);
}
uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, newguid), TRUE);
gpointer gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, newguid), TRUE);
memcpy (process_guid, mono_string_chars_internal (MONO_HANDLE_RAW (newguid)), sizeof(process_guid));
mono_gchandle_free_internal (gchandle);
process_guid_set = TRUE;
+1 -1
View File
@@ -1597,7 +1597,7 @@ mono_gc_is_null (void)
* \returns TRUE if the object wrapped by the \p gchandle belongs to the specific \p domain.
*/
gboolean
mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain)
mono_gchandle_is_in_domain (gpointer gchandle, MonoDomain *domain)
{
guint slot = MONO_GC_HANDLE_SLOT (gchandle);
guint type = MONO_GC_HANDLE_TYPE (gchandle);
+14 -13
View File
@@ -259,35 +259,35 @@ typedef struct {
guint32 value;
} Uint32Property;
guint32
typedef struct {
MonoPropertyBagItem head;
gpointer value;
} PointerProperty;
gpointer
mono_class_get_ref_info_handle (MonoClass *klass)
{
Uint32Property *prop = (Uint32Property*)mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
PointerProperty *prop = (PointerProperty*)mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
return prop ? prop->value : 0;
}
guint32
mono_class_set_ref_info_handle (MonoClass *klass, guint32 value)
gpointer
mono_class_set_ref_info_handle (MonoClass *klass, gpointer value)
{
if (!value) {
Uint32Property *prop = (Uint32Property*)mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
PointerProperty *prop = (PointerProperty*)mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
if (prop)
prop->value = 0;
return 0;
}
Uint32Property *prop = (Uint32Property*)mono_class_alloc (klass, sizeof (Uint32Property));
PointerProperty *prop = (PointerProperty*)mono_class_alloc (klass, sizeof (PointerProperty));
prop->head.tag = PROP_REF_INFO_HANDLE;
prop->value = value;
prop = (Uint32Property*)mono_property_bag_add (m_class_get_infrequent_data (klass), prop);
prop = (PointerProperty*)mono_property_bag_add (m_class_get_infrequent_data (klass), prop);
return prop->value;
}
typedef struct {
MonoPropertyBagItem head;
gpointer value;
} PointerProperty;
static void
set_pointer_property (MonoClass *klass, InfrequentDataKind property, gpointer value)
{
@@ -532,12 +532,13 @@ mono_class_contextbound_bit_offset (int* byte_offset_out, guint8* mask_out) {
* LOCKING: Acquires the loader lock.
*/
gboolean
mono_class_publish_gc_descriptor (MonoClass *klass, MonoGCDescriptor gc_descr)
mono_class_publish_gc_descriptor (MonoClass *klass, MonoGCDescriptor gc_descr, GPtrArray *gc_descr_full)
{
gboolean ret;
mono_loader_lock ();
ret = klass->gc_descr_inited;
klass->gc_descr = gc_descr;
klass->gc_descr_full = gc_descr_full;
mono_memory_barrier ();
klass->gc_descr_inited = TRUE;
mono_loader_unlock ();
+1 -1
View File
@@ -1014,7 +1014,7 @@ mono_class_create_bounded_array (MonoClass *eclass, guint32 rank, gboolean bound
mono_class_set_type_load_failure (klass, "Could not create array type '%s[]'", full_name);
g_free (full_name);
} else if (eclass->enumtype && !mono_class_enum_basetype_internal (eclass)) {
guint32 ref_info_handle = mono_class_get_ref_info_handle (eclass);
gpointer ref_info_handle = mono_class_get_ref_info_handle (eclass);
if (!ref_info_handle || eclass->wastypebuilder) {
g_warning ("Only incomplete TypeBuilder objects are allowed to be an enum without base_type");
g_assert (ref_info_handle && !eclass->wastypebuilder);
+4
View File
@@ -10,6 +10,8 @@
#include <mono/metadata/metadata.h>
#include <mono/metadata/class-internals.h>
G_BEGIN_DECLS
gboolean
mono_class_init_internal (MonoClass *klass);
@@ -88,4 +90,6 @@ mono_class_setup_runtime_info (MonoClass *klass, MonoDomain *domain, MonoVTable
MonoClass *
mono_class_create_array_fill_type (void);
G_END_DECLS
#endif
+4 -4
View File
@@ -1380,11 +1380,11 @@ mono_class_get_marshal_info (MonoClass *klass);
void
mono_class_set_marshal_info (MonoClass *klass, MonoMarshalType *marshal_info);
guint32
gpointer
mono_class_get_ref_info_handle (MonoClass *klass);
guint32
mono_class_set_ref_info_handle (MonoClass *klass, guint32 value);
gpointer
mono_class_set_ref_info_handle (MonoClass *klass, gpointer value);
MonoErrorBoxed*
mono_class_get_exception_data (MonoClass *klass);
@@ -1484,7 +1484,7 @@ void
mono_class_set_nonblittable (MonoClass *klass);
gboolean
mono_class_publish_gc_descriptor (MonoClass *klass, MonoGCDescriptor gc_descr);
mono_class_publish_gc_descriptor (MonoClass *klass, MonoGCDescriptor gc_descr, GPtrArray *gc_descr_full);
void
mono_class_compute_gc_descriptor (MonoClass *klass);
+1
View File
@@ -120,6 +120,7 @@ struct _MonoClass {
MonoType _byval_arg;
MonoGCDescriptor gc_descr;
GPtrArray *gc_descr_full;
MonoClassRuntimeInfo *runtime_info;
+8 -8
View File
@@ -158,7 +158,7 @@ static GENERATE_GET_CLASS_WITH_CACHE (com_default_interface_attribute, "System.R
*/
typedef struct {
guint32 ref_count;
guint32 gc_handle;
gpointer gc_handle;
GHashTable* vtable_hash;
#ifdef HOST_WIN32
MonoIUnknown *free_marshaler; // actually IMarshal
@@ -1798,7 +1798,7 @@ mono_System_ComObject_ReleaseInterfaces (MonoComObjectHandle obj)
return;
mono_cominterop_lock ();
guint32 const gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (rcw_hash, MONO_HANDLE_GETVAL (obj, iunknown)));
gpointer gchandle = g_hash_table_lookup (rcw_hash, MONO_HANDLE_GETVAL (obj, iunknown));
if (gchandle) {
mono_gchandle_free_internal (gchandle);
g_hash_table_remove (rcw_hash, MONO_HANDLE_GETVAL (obj, iunknown));
@@ -1823,7 +1823,7 @@ cominterop_rcw_finalizer (gpointer key, gpointer value, gpointer user_data)
{
gchandle_t gchandle = 0;
gchandle = GPOINTER_TO_UINT (value);
gchandle = value;
if (gchandle) {
MonoComInteropProxy* proxy = (MonoComInteropProxy*)mono_gchandle_get_target_internal (gchandle);
@@ -1882,12 +1882,12 @@ void
ves_icall_Mono_Interop_ComInteropProxy_AddProxy (gpointer pUnk, MonoComInteropProxyHandle proxy, MonoError *error)
{
#ifndef DISABLE_COM
guint32 const gchandle = mono_gchandle_new_weakref_from_handle (MONO_HANDLE_CAST (MonoObject, proxy));
gpointer gchandle = mono_gchandle_new_weakref_from_handle (MONO_HANDLE_CAST (MonoObject, proxy));
mono_cominterop_lock ();
if (!rcw_hash)
rcw_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
g_hash_table_insert (rcw_hash, pUnk, GUINT_TO_POINTER (gchandle));
g_hash_table_insert (rcw_hash, pUnk, gchandle);
mono_cominterop_unlock ();
#else
g_assert_not_reached ();
@@ -1902,7 +1902,7 @@ ves_icall_Mono_Interop_ComInteropProxy_FindProxy (gpointer pUnk, MonoError *erro
mono_cominterop_lock ();
if (rcw_hash)
gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (rcw_hash, pUnk));
gchandle = g_hash_table_lookup (rcw_hash, pUnk);
mono_cominterop_unlock ();
if (!gchandle)
return MONO_HANDLE_NEW (MonoComInteropProxy, NULL);
@@ -2558,7 +2558,7 @@ cominterop_ccw_addref_impl (MonoCCWInterface* ccwe)
g_assert (ccw->gc_handle);
gint32 const ref_count = mono_atomic_inc_i32 ((gint32*)&ccw->ref_count);
if (ref_count == 1) {
guint32 oldhandle = ccw->gc_handle;
gpointer oldhandle = ccw->gc_handle;
g_assert (oldhandle);
/* since we now have a ref count, alloc a strong handle*/
ccw->gc_handle = mono_gchandle_from_handle (mono_gchandle_get_target_handle (oldhandle), FALSE);
@@ -2590,7 +2590,7 @@ cominterop_ccw_release_impl (MonoCCWInterface* ccwe)
gint32 const ref_count = mono_atomic_dec_i32 ((gint32*)&ccw->ref_count);
if (ref_count == 0) {
/* allow gc of object */
guint32 oldhandle = ccw->gc_handle;
gpointer oldhandle = ccw->gc_handle;
g_assert (oldhandle);
ccw->gc_handle = mono_gchandle_new_weakref_from_handle (mono_gchandle_get_target_handle (oldhandle));
mono_gchandle_free_internal (oldhandle);
+1 -1
View File
@@ -484,7 +484,7 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoStringHandle keypad, MonoStringHand
if (ret == -1)
return FALSE;
uint32_t h;
gpointer h;
set_control_chars (MONO_ARRAY_HANDLE_PIN (control_chars_arr, gchar, 0, &h), mono_attr.c_cc);
mono_gchandle_free_internal (h);
/* If initialized from another appdomain... */
File diff suppressed because it is too large. Load diff
+99
View File
@@ -0,0 +1,99 @@
/**
* \file
* Copyright 2019 Microsoft
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#ifndef __MONO_COREGC_MONO_H__
#define __MONO_COREGC_MONO_H__
#include <external/coreclr/src/gc/env/gcenv.base.h>
#include <external/coreclr/src/gc/gcinterface.h>
/* FIXME: what's the correct struct? */
#define COREGC_CLIENT_OBJECT_HEADER_SIZE (sizeof (MonoObject))
class GCToEEInterface
{
public:
static void SuspendEE(SUSPEND_REASON reason);
static void RestartEE(bool bFinishedGC); //resume threads.
//
// The GC roots enumeration callback
//
static void GcScanRoots(promote_func* fn, int condemned, int max_gen, ScanContext* sc);
//
// Callbacks issues during GC that the execution engine can do its own bookeeping
//
// start of GC call back - single threaded
static void GcStartWork(int condemned, int max_gen);
//EE can perform post stack scanning action, while the
// user threads are still suspended
static void AfterGcScanRoots(int condemned, int max_gen, ScanContext* sc);
// Called before BGC starts sweeping, the heap is walkable
static void GcBeforeBGCSweepWork();
// post-gc callback.
static void GcDone(int condemned);
// Promote refcounted handle callback
static bool RefCountedHandleCallbacks(Object * pObject);
// Sync block cache management
static void SyncBlockCacheWeakPtrScan(HANDLESCANPROC scanProc, uintptr_t lp1, uintptr_t lp2);
static void SyncBlockCacheDemote(int max_gen);
static void SyncBlockCachePromotionsGranted(int max_gen);
static uint32_t GetActiveSyncBlockCount();
// Thread functions
static bool IsPreemptiveGCDisabled();
static bool EnablePreemptiveGC();
static void DisablePreemptiveGC();
static Thread* GetThread();
static gc_alloc_context * GetAllocContext();
static void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param);
static uint8_t* GetLoaderAllocatorObjectForGC(Object* pObject);
// Diagnostics methods.
static void DiagGCStart(int gen, bool isInduced);
static void DiagUpdateGenerationBounds();
static void DiagGCEnd(size_t index, int gen, int reason, bool fConcurrent);
static void DiagWalkFReachableObjects(void* gcContext);
static void DiagWalkSurvivors(void* gcContext, bool fCompacting);
static void DiagWalkLOHSurvivors(void* gcContext);
static void DiagWalkBGCSurvivors(void* gcContext);
static void StompWriteBarrier(WriteBarrierParameters* args);
static void EnableFinalization(bool foundFinalizers);
static void HandleFatalError(unsigned int exitCode);
static bool EagerFinalized(Object* obj);
static MethodTable* GetFreeObjectMethodTable();
static bool GetBooleanConfigValue(const char* key, bool* value);
static bool GetIntConfigValue(const char* key, int64_t* value);
static bool GetStringConfigValue(const char* key, const char** value);
static void FreeStringConfigValue(const char* key);
static bool IsGCThread();
static bool WasCurrentThreadCreatedByGC();
static bool CreateThread(void (*threadStart)(void*), void* arg, bool is_suspendable, const char* name);
static void WalkAsyncPinnedForPromotion(Object* object, ScanContext* sc, promote_func* callback);
static void WalkAsyncPinned(Object* object, void* context, void(*callback)(Object*, Object*, void*));
static IGCToCLREventSink* EventSink();
static uint32_t GetTotalNumSizedRefHandles();
static bool AnalyzeSurvivorsRequested(int condemnedGeneration);
static void AnalyzeSurvivorsFinished(int condemnedGeneration);
static void VerifySyncTableEntry();
static void UpdateGCEventStatus(int publicLevel, int publicKeywords, int privateLevel, int privateKeywords);
};
#endif
+1 -1
View File
@@ -708,7 +708,7 @@ mono_custom_attrs_from_builders_handle (MonoImage *alloc_img, MonoImage *image,
continue;
MONO_HANDLE_GET (cattr_data, cattr, data);
unsigned char *saved = (unsigned char *)mono_image_alloc (image, mono_array_handle_length (cattr_data));
guint32 gchandle = 0;
gpointer gchandle = 0;
memcpy (saved, MONO_ARRAY_HANDLE_PIN (cattr_data, char, 0, &gchandle), mono_array_handle_length (cattr_data));
mono_gchandle_free_internal (gchandle);
ainfo->attrs [index].ctor = ctor_method;
+1 -1
View File
@@ -286,7 +286,7 @@ struct _MonoJitInfo {
typedef struct {
gpointer *static_data; /* Used to free the static data without going through the MonoAppContext object itself. */
uint32_t gc_handle;
gpointer gc_handle;
} ContextStaticData;
struct _MonoAppContext {
+1 -1
View File
@@ -1161,7 +1161,7 @@ mono_exception_handle_get_native_backtrace (MonoExceptionHandle exc)
domain = mono_domain_get ();
len = mono_array_handle_length (arr);
text = g_string_new_len (NULL, len * 20);
uint32_t gchandle;
gpointer gchandle;
gpointer *addr = MONO_ARRAY_HANDLE_PIN (arr, gpointer, 0, &gchandle);
MONO_ENTER_GC_SAFE;
messages = backtrace_symbols (addr, len);
+6 -6
View File
@@ -39,10 +39,10 @@
*
* \returns a handle that can be used to access the object from unmanaged code.
*/
uint32_t
gpointer
mono_gchandle_new (MonoObject *obj, mono_bool pinned)
{
MONO_EXTERNAL_ONLY_GC_UNSAFE (uint32_t, mono_gchandle_new_internal (obj, pinned));
MONO_EXTERNAL_ONLY_GC_UNSAFE (gpointer, mono_gchandle_new_internal (obj, pinned));
}
/**
@@ -66,10 +66,10 @@ mono_gchandle_new (MonoObject *obj, mono_bool pinned)
* \returns a handle that can be used to access the object from
* unmanaged code.
*/
uint32_t
gpointer
mono_gchandle_new_weakref (MonoObject *obj, mono_bool track_resurrection)
{
MONO_EXTERNAL_ONLY_GC_UNSAFE (uint32_t, mono_gchandle_new_weakref_internal (obj, track_resurrection));
MONO_EXTERNAL_ONLY_GC_UNSAFE (gpointer, mono_gchandle_new_weakref_internal (obj, track_resurrection));
}
/**
@@ -83,7 +83,7 @@ mono_gchandle_new_weakref (MonoObject *obj, mono_bool track_resurrection)
* NULL for a collected object if using a weakref handle.
*/
MonoObject*
mono_gchandle_get_target (uint32_t gchandle)
mono_gchandle_get_target (gpointer gchandle)
{
MONO_EXTERNAL_ONLY_GC_UNSAFE (MonoObject*, mono_gchandle_get_target_internal (gchandle));
}
@@ -97,7 +97,7 @@ mono_gchandle_get_target (uint32_t gchandle)
* object wrapped.
*/
void
mono_gchandle_free (uint32_t gchandle)
mono_gchandle_free (gpointer gchandle)
{
/* Xamarin.Mac and Xamarin.iOS can call this from a worker thread
* that's not attached to the runtime. This is okay for SGen because
+8 -4
View File
@@ -19,6 +19,8 @@
#include <mono/sgen/gc-internal-agnostic.h>
#include <mono/metadata/icalls.h>
G_BEGIN_DECLS
#define mono_domain_finalizers_lock(domain) mono_os_mutex_lock (&(domain)->finalizable_objects_hash_lock);
#define mono_domain_finalizers_unlock(domain) mono_os_mutex_unlock (&(domain)->finalizable_objects_hash_lock);
@@ -84,7 +86,7 @@ extern void mono_gc_set_stack_end (void *stack_end);
gboolean mono_object_is_alive (MonoObject* obj);
gboolean mono_gc_is_finalizer_thread (MonoThread *thread);
void mono_gchandle_set_target (guint32 gchandle, MonoObject *obj);
void mono_gchandle_set_target (gpointer gchandle, MonoObject *obj);
/*Ephemeron functionality. Sgen only*/
gboolean mono_gc_ephemeron_array_add (MonoObject *obj);
@@ -119,7 +121,7 @@ mono_gc_alloc_fixed_no_descriptor (size_t size, MonoGCRootSource source, void *k
void mono_gc_free_fixed (void* addr);
/* make sure the gchandle was allocated for an object in domain */
gboolean mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain);
gboolean mono_gchandle_is_in_domain (gpointer gchandle, MonoDomain *domain);
void mono_gchandle_free_domain (MonoDomain *domain);
typedef void (*FinalizerThreadCallback) (gpointer user_data);
@@ -157,7 +159,7 @@ mono_gc_alloc_handle_string (MonoVTable *vtable, gsize size, gint32 len);
MonoObject*
mono_gc_alloc_mature (MonoVTable *vtable, size_t size);
MonoGCDescriptor mono_gc_make_descr_for_string (gsize *bitmap, int numbits);
MonoGCDescriptor mono_gc_make_descr_for_string (gsize *bitmap, int numbits, GPtrArray **gc_descr_full);
MonoObjectHandle
mono_gc_alloc_handle_mature (MonoVTable *vtable, gsize size);
@@ -352,7 +354,7 @@ typedef struct _RefQueueEntry RefQueueEntry;
struct _RefQueueEntry {
void *dis_link;
guint32 gchandle;
gpointer gchandle;
MonoDomain *domain;
void *user_data;
RefQueueEntry *next;
@@ -407,4 +409,6 @@ extern gboolean mono_do_not_finalize;
/* List of names of classes not to finalize. */
extern gchar **mono_do_not_finalize_class_names;
G_END_DECLS
#endif /* __MONO_METADATA_GC_INTERNAL_H__ */
+8 -10
View File
@@ -692,7 +692,7 @@ ves_icall_System_GCHandle_InternalSet (gpointer handle, MonoObjectHandle obj, Mo
#else
MonoObjectHandle
ves_icall_System_GCHandle_GetTarget (guint32 handle, MonoError *error)
ves_icall_System_GCHandle_GetTarget (gpointer handle, MonoError *error)
{
return mono_gchandle_get_target_handle (handle);
}
@@ -700,8 +700,8 @@ ves_icall_System_GCHandle_GetTarget (guint32 handle, MonoError *error)
/*
* if type == -1, change the target of the handle, otherwise allocate a new handle.
*/
guint32
ves_icall_System_GCHandle_GetTargetHandle (MonoObjectHandle obj, guint32 handle, gint32 type, MonoError *error)
gpointer
ves_icall_System_GCHandle_GetTargetHandle (MonoObjectHandle obj, gpointer handle, gint32 type, MonoError *error)
{
if (type == -1) {
mono_gchandle_set_target_handle (handle, obj);
@@ -724,20 +724,18 @@ ves_icall_System_GCHandle_GetTargetHandle (MonoObjectHandle obj, guint32 handle,
}
void
ves_icall_System_GCHandle_FreeHandle (guint32 handle)
ves_icall_System_GCHandle_FreeHandle (gpointer handle)
{
mono_gchandle_free_internal (handle);
}
gpointer
ves_icall_System_GCHandle_GetAddrOfPinnedObject (guint32 handle)
ves_icall_System_GCHandle_GetAddrOfPinnedObject (gpointer handle)
{
// Handles seem to only be in the way here, and the object is pinned.
MonoObject *obj;
if (MONO_GC_HANDLE_TYPE (handle) != HANDLE_PINNED)
return (gpointer)-2;
obj = mono_gchandle_get_target_internal (handle);
if (obj) {
MonoClass *klass = mono_object_class (obj);
@@ -762,7 +760,7 @@ ves_icall_System_GCHandle_GetAddrOfPinnedObject (guint32 handle)
}
MonoBoolean
ves_icall_System_GCHandle_CheckCurrentDomain (guint32 gchandle)
ves_icall_System_GCHandle_CheckCurrentDomain (gpointer gchandle)
{
return mono_gchandle_is_in_domain (gchandle, mono_domain_get ());
}
@@ -1191,7 +1189,7 @@ reference_queue_proccess (MonoReferenceQueue *queue)
RefQueueEntry *entry;
while ((entry = *iter)) {
if (queue->should_be_deleted || !mono_gchandle_get_target_internal (entry->gchandle)) {
mono_gchandle_free_internal ((guint32)entry->gchandle);
mono_gchandle_free_internal (entry->gchandle);
ref_list_remove_element (iter, entry);
queue->callback (entry->user_data);
g_free (entry);
@@ -1246,7 +1244,7 @@ reference_queue_clear_for_domain (MonoDomain *domain)
RefQueueEntry *entry;
while ((entry = *iter)) {
if (entry->domain == domain) {
mono_gchandle_free_internal ((guint32)entry->gchandle);
mono_gchandle_free_internal (entry->gchandle);
ref_list_remove_element (iter, entry);
queue->callback (entry->user_data);
g_free (entry);
+10 -10
View File
@@ -396,7 +396,7 @@ mono_array_new_full_handle (MonoDomain *domain, MonoClass *array_class, uintptr_
return MONO_HANDLE_NEW (MonoArray, mono_array_new_full_checked (domain, array_class, lengths, lower_bounds, error));
}
uint32_t
gpointer
mono_gchandle_from_handle (MonoObjectHandle handle, mono_bool pinned)
{
// FIXME This used to check for out of scope handles.
@@ -409,13 +409,13 @@ mono_gchandle_from_handle (MonoObjectHandle handle, mono_bool pinned)
}
MonoObjectHandle
mono_gchandle_get_target_handle (uint32_t gchandle)
mono_gchandle_get_target_handle (gpointer gchandle)
{
return MONO_HANDLE_NEW (MonoObject, mono_gchandle_get_target_internal (gchandle));
}
gpointer
mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t idx, uint32_t *gchandle)
mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t idx, gpointer *gchandle)
{
g_assert (gchandle != NULL);
*gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST(MonoObject,handle), TRUE);
@@ -424,7 +424,7 @@ mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t idx
}
gunichar2*
mono_string_handle_pin_chars (MonoStringHandle handle, uint32_t *gchandle)
mono_string_handle_pin_chars (MonoStringHandle handle, gpointer *gchandle)
{
g_assert (gchandle != NULL);
*gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, handle), TRUE);
@@ -433,7 +433,7 @@ mono_string_handle_pin_chars (MonoStringHandle handle, uint32_t *gchandle)
}
gpointer
mono_object_handle_pin_unbox (MonoObjectHandle obj, uint32_t *gchandle)
mono_object_handle_pin_unbox (MonoObjectHandle obj, gpointer *gchandle)
{
g_assert (!MONO_HANDLE_IS_NULL (obj));
MonoClass *klass = mono_handle_class (obj);
@@ -457,7 +457,7 @@ mono_handle_stack_is_empty (HandleStack *stack)
//FIXME inline
gboolean
mono_gchandle_target_equal (uint32_t gchandle, MonoObjectHandle equal)
mono_gchandle_target_equal (gpointer gchandle, MonoObjectHandle equal)
{
// This function serves to reduce coop handle creation.
MONO_HANDLE_SUPPRESS_SCOPE (1);
@@ -466,7 +466,7 @@ mono_gchandle_target_equal (uint32_t gchandle, MonoObjectHandle equal)
//FIXME inline
void
mono_gchandle_target_is_null_or_equal (uint32_t gchandle, MonoObjectHandle equal, gboolean *is_null,
mono_gchandle_target_is_null_or_equal (gpointer gchandle, MonoObjectHandle equal, gboolean *is_null,
gboolean *is_equal)
{
// This function serves to reduce coop handle creation.
@@ -478,13 +478,13 @@ mono_gchandle_target_is_null_or_equal (uint32_t gchandle, MonoObjectHandle equal
//FIXME inline
void
mono_gchandle_set_target_handle (guint32 gchandle, MonoObjectHandle obj)
mono_gchandle_set_target_handle (gpointer gchandle, MonoObjectHandle obj)
{
mono_gchandle_set_target (gchandle, MONO_HANDLE_RAW (obj));
}
//FIXME inline
guint32
gpointer
mono_gchandle_new_weakref_from_handle (MonoObjectHandle handle)
{
return mono_gchandle_new_weakref_internal (MONO_HANDLE_SUPPRESS (MONO_HANDLE_RAW (handle)), FALSE);
@@ -498,7 +498,7 @@ mono_handle_hash (MonoObjectHandle object)
}
//FIXME inline
guint32
gpointer
mono_gchandle_new_weakref_from_handle_track_resurrection (MonoObjectHandle handle)
{
return mono_gchandle_new_weakref_internal (MONO_HANDLE_SUPPRESS (MONO_HANDLE_RAW (handle)), TRUE);
+14 -10
View File
@@ -25,6 +25,8 @@
#include <mono/utils/checked-build.h>
#include <mono/metadata/class-internals.h>
G_BEGIN_DECLS
/*
Handle stack.
@@ -612,21 +614,21 @@ mono_handle_array_getref (MonoObjectHandleOut dest, MonoArrayHandle array, uintp
/* Local handles to global GC handles and back */
uint32_t
gpointer
mono_gchandle_from_handle (MonoObjectHandle handle, mono_bool pinned);
MonoObjectHandle
mono_gchandle_get_target_handle (uint32_t gchandle);
mono_gchandle_get_target_handle (gpointer gchandle);
gboolean
mono_gchandle_target_equal (uint32_t gchandle, MonoObjectHandle equal);
mono_gchandle_target_equal (gpointer gchandle, MonoObjectHandle equal);
void
mono_gchandle_target_is_null_or_equal (uint32_t gchandle, MonoObjectHandle equal, gboolean *is_null,
mono_gchandle_target_is_null_or_equal (gpointer gchandle, MonoObjectHandle equal, gboolean *is_null,
gboolean *is_equal);
void
mono_gchandle_set_target_handle (guint32 gchandle, MonoObjectHandle obj);
mono_gchandle_set_target_handle (gpointer gchandle, MonoObjectHandle obj);
void
mono_array_handle_memcpy_refs (MonoArrayHandle dest, uintptr_t dest_idx, MonoArrayHandle src, uintptr_t src_idx, uintptr_t len);
@@ -636,7 +638,7 @@ mono_array_handle_memcpy_refs (MonoArrayHandle dest, uintptr_t dest_idx, MonoArr
* size. Call mono_gchandle_free to unpin.
*/
gpointer
mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t index, uint32_t *gchandle);
mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t index, gpointer *gchandle);
#define MONO_ARRAY_HANDLE_PIN(handle,type,index,gchandle_out) ((type*)mono_array_handle_pin_with_size (MONO_HANDLE_CAST(MonoArray,(handle)), sizeof (type), (index), (gchandle_out)))
@@ -644,10 +646,10 @@ void
mono_value_copy_array_handle (MonoArrayHandle dest, int dest_idx, gconstpointer src, int count);
gunichar2 *
mono_string_handle_pin_chars (MonoStringHandle s, uint32_t *gchandle_out);
mono_string_handle_pin_chars (MonoStringHandle s, gpointer *gchandle_out);
gpointer
mono_object_handle_pin_unbox (MonoObjectHandle boxed_valuetype_obj, uint32_t *gchandle_out);
mono_object_handle_pin_unbox (MonoObjectHandle boxed_valuetype_obj, gpointer *gchandle_out);
static inline gpointer
mono_handle_unbox_unsafe (MonoObjectHandle handle)
@@ -665,13 +667,15 @@ mono_context_get_handle (void);
void
mono_context_set_handle (MonoAppContextHandle new_context);
guint32
gpointer
mono_gchandle_new_weakref_from_handle (MonoObjectHandle handle);
int
mono_handle_hash (MonoObjectHandle object);
guint32
gpointer
mono_gchandle_new_weakref_from_handle_track_resurrection (MonoObjectHandle handle);
G_END_DECLS
#endif /* __MONO_HANDLE_H__ */
+3 -3
View File
@@ -77,7 +77,7 @@ ICALL_EXPORT MonoAssemblyName* ves_icall_System_Reflection_AssemblyName_GetNativ
ICALL_EXPORT MonoBoolean ves_icall_RuntimeTypeHandle_is_subclass_of (MonoType*, MonoType*);
ICALL_EXPORT MonoBoolean ves_icall_System_Environment_GetIs64BitOperatingSystem (void);
ICALL_EXPORT MonoBoolean ves_icall_System_Environment_get_HasShutdownStarted (void);
ICALL_EXPORT MonoBoolean ves_icall_System_GCHandle_CheckCurrentDomain (guint32 gchandle);
ICALL_EXPORT MonoBoolean ves_icall_System_GCHandle_CheckCurrentDomain (gpointer gchandle);
ICALL_EXPORT MonoBoolean ves_icall_System_IO_DriveInfo_GetDiskFreeSpace (const gunichar2*, gint32, guint64*, guint64*, guint64*, gint32*);
ICALL_EXPORT MonoBoolean ves_icall_System_Reflection_AssemblyName_ParseAssemblyName (const char*, MonoAssemblyName*, MonoBoolean*, MonoBoolean* is_token_defined_arg);
ICALL_EXPORT MonoBoolean ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack (void);
@@ -156,7 +156,7 @@ ICALL_EXPORT gint64 ves_icall_System_Diagnostics_Process_GetProcessData (int, gi
ICALL_EXPORT gint64 ves_icall_System_Diagnostics_Stopwatch_GetTimestamp (void);
ICALL_EXPORT gint64 ves_icall_System_GC_GetTotalMemory (MonoBoolean forceCollection);
ICALL_EXPORT gint64 ves_icall_System_Threading_Timer_GetTimeMonotonic (void);
ICALL_EXPORT gpointer ves_icall_System_GCHandle_GetAddrOfPinnedObject (guint32 handle);
ICALL_EXPORT gpointer ves_icall_System_GCHandle_GetAddrOfPinnedObject (gpointer handle);
ICALL_EXPORT int ves_icall_Interop_Sys_DoubleToString (double, char*, char*, int);
ICALL_EXPORT int ves_icall_System_Environment_get_Platform (void);
ICALL_EXPORT int ves_icall_System_GC_GetCollectionCount (int);
@@ -170,7 +170,7 @@ ICALL_EXPORT void ves_icall_System_Array_GetGenericValue_icall (MonoArray**, gui
ICALL_EXPORT void ves_icall_System_Array_SetGenericValue_icall (MonoArray**, guint32, gpointer);
ICALL_EXPORT void ves_icall_System_Buffer_MemcpyInternal (gpointer dest, gconstpointer src, gint32 count);
ICALL_EXPORT void ves_icall_System_Environment_Exit (int);
ICALL_EXPORT void ves_icall_System_GCHandle_FreeHandle (guint32 handle);
ICALL_EXPORT void ves_icall_System_GCHandle_FreeHandle (gpointer handle);
ICALL_EXPORT void ves_icall_System_GC_InternalCollect (int generation);
ICALL_EXPORT void ves_icall_System_GC_RecordPressure (gint64);
ICALL_EXPORT void ves_icall_System_GC_WaitForPendingFinalizers (void);
+2 -2
View File
@@ -742,8 +742,8 @@ ICALL_TYPE(GCH, "System.Runtime.InteropServices.GCHandle", GCH_1)
NOHANDLES(ICALL(GCH_1, "CheckCurrentDomain", ves_icall_System_GCHandle_CheckCurrentDomain))
NOHANDLES(ICALL(GCH_2, "FreeHandle", ves_icall_System_GCHandle_FreeHandle))
NOHANDLES(ICALL(GCH_3, "GetAddrOfPinnedObject", ves_icall_System_GCHandle_GetAddrOfPinnedObject))
HANDLES(GCH_4, "GetTarget", ves_icall_System_GCHandle_GetTarget, MonoObject, 1, (guint32))
HANDLES(GCH_5, "GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle, guint32, 3, (MonoObject, guint32, gint32))
HANDLES(GCH_4, "GetTarget", ves_icall_System_GCHandle_GetTarget, MonoObject, 1, (gpointer))
HANDLES(GCH_5, "GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle, gpointer, 3, (MonoObject, gpointer, gint32))
#if !defined(DISABLE_COM) || defined (HOST_WIN32)
ICALL_TYPE(MARSHAL, "System.Runtime.InteropServices.Marshal", MARSHAL_1)
+5 -5
View File
@@ -2410,7 +2410,7 @@ ves_icall_RuntimeFieldInfo_SetValueInternal (MonoReflectionFieldHandle field, Mo
return_if_nok (error);
gboolean isref = FALSE;
uint32_t value_gchandle = 0;
gpointer value_gchandle = 0;
gchar *v = NULL;
if (!type->byref) {
switch (type->type) {
@@ -2457,7 +2457,7 @@ ves_icall_RuntimeFieldInfo_SetValueInternal (MonoReflectionFieldHandle field, Mo
MonoObjectHandle nullable = mono_object_new_handle (mono_domain_get (), nklass, error);
return_if_nok (error);
uint32_t nullable_gchandle = 0;
gpointer nullable_gchandle = 0;
guint8 *nval = (guint8*)mono_object_handle_pin_unbox (nullable, &nullable_gchandle);
mono_nullable_init_from_handle (nval, value, nklass);
@@ -2557,7 +2557,7 @@ ves_icall_System_RuntimeFieldHandle_SetValueDirect (MonoReflectionFieldHandle fi
} else if (MONO_TYPE_IS_REFERENCE (f->type)) {
mono_copy_value (f->type, (guint8*)obj->value + f->offset - sizeof (MonoObject), MONO_HANDLE_RAW (value_h), FALSE);
} else {
guint gchandle = 0;
gpointer gchandle = 0;
g_assert (MONO_HANDLE_RAW (value_h));
mono_copy_value (f->type, (guint8*)obj->value + f->offset - sizeof (MonoObject), mono_object_handle_pin_unbox (value_h, &gchandle), FALSE);
mono_gchandle_free_internal (gchandle);
@@ -3293,7 +3293,7 @@ ves_icall_RuntimeTypeHandle_GetGenericTypeDefinition_impl (MonoReflectionTypeHan
if (mono_class_is_ginst (klass)) {
MonoClass *generic_class = mono_class_get_generic_class (klass)->container_class;
guint32 ref_info_handle = mono_class_get_ref_info_handle (generic_class);
gpointer ref_info_handle = mono_class_get_ref_info_handle (generic_class);
if (m_class_was_typebuilder (generic_class) && ref_info_handle) {
MonoObjectHandle tb = mono_gchandle_get_target_handle (ref_info_handle);
@@ -7091,7 +7091,7 @@ ves_icall_System_Reflection_RuntimeModule_ResolveSignature (MonoImage *image, gu
// FIXME MONO_ENTER_NO_SAFEPOINTS instead of pin/gchandle.
uint32_t h;
gpointer h;
gpointer array_base = MONO_ARRAY_HANDLE_PIN (res, guint8, 0, &h);
memcpy (array_base, ptr, len);
mono_gchandle_free_internal (h);
+5 -3
View File
@@ -6012,7 +6012,7 @@ emit_marshal_variant_ilgen (EmitMarshalContext *m, int argnum, MonoType *t,
}
static void
emit_managed_wrapper_ilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle)
emit_managed_wrapper_ilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, gpointer target_handle)
{
MonoMethodSignature *sig, *csig;
int i, *tmp_locals, orig_domain, attach_cookie;
@@ -6106,14 +6106,16 @@ emit_managed_wrapper_ilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_s
if (sig->hasthis) {
if (target_handle) {
mono_mb_emit_icon (mb, (gint32)target_handle);
mono_mb_emit_icon8 (mb, (gint64)target_handle);
mono_mb_emit_byte (mb, CEE_CONV_I);
mono_mb_emit_icall (mb, mono_gchandle_get_target_internal);
} else {
/* fixme: */
g_assert_not_reached ();
}
} else if (closed) {
mono_mb_emit_icon (mb, (gint32)target_handle);
mono_mb_emit_icon8 (mb, (gint64)target_handle);
mono_mb_emit_byte (mb, CEE_CONV_I);
mono_mb_emit_icall (mb, mono_gchandle_get_target_internal);
}
+1 -1
View File
@@ -98,7 +98,7 @@ mono_string_to_utf8str_impl (MonoStringHandle s, MonoError *error)
// FIXME pass g_utf16_to_utf8 an allocator to avoid double alloc/copy.
uint32_t gchandle = 0;
gpointer gchandle = 0;
tmp = g_utf16_to_utf8 (mono_string_handle_pin_chars (s, &gchandle), mono_string_handle_length (s), NULL, &len, &gerror);
mono_gchandle_free_internal (gchandle);
if (gerror) {
+19 -19
View File
@@ -242,7 +242,7 @@ mono_marshal_init (void)
register_icall (mono_delegate_begin_invoke, mono_icall_sig_object_object_ptr, FALSE);
register_icall (mono_delegate_end_invoke, mono_icall_sig_object_object_ptr, FALSE);
register_icall (mono_gc_wbarrier_generic_nostore_internal, mono_icall_sig_void_ptr, FALSE);
register_icall (mono_gchandle_get_target_internal, mono_icall_sig_object_int32, TRUE);
register_icall (mono_gchandle_get_target_internal, mono_icall_sig_object_ptr, TRUE);
register_icall (mono_marshal_isinst_with_cache, mono_icall_sig_object_object_ptr_ptr, FALSE);
register_icall (mono_threads_enter_gc_safe_region_unbalanced, mono_icall_sig_ptr_ptr, TRUE);
register_icall (mono_threads_exit_gc_safe_region_unbalanced, mono_icall_sig_void_ptr_ptr, TRUE);
@@ -290,7 +290,7 @@ mono_delegate_to_ftnptr_impl (MonoDelegateHandle delegate, MonoError *error)
gpointer result = NULL;
MonoMethod *method, *wrapper;
MonoClass *klass;
uint32_t target_handle = 0;
gpointer target_handle = 0;
if (MONO_HANDLE_IS_NULL (delegate))
goto leave;
@@ -364,7 +364,7 @@ delegate_hash_table_new (void) {
static void
delegate_hash_table_remove (MonoDelegate *d)
{
guint32 gchandle = 0;
gpointer gchandle = NULL;
if (!d->target)
return;
@@ -372,7 +372,7 @@ delegate_hash_table_remove (MonoDelegate *d)
mono_marshal_lock ();
if (delegate_hash_table == NULL)
delegate_hash_table = delegate_hash_table_new ();
gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (delegate_hash_table, d->delegate_trampoline));
gchandle = g_hash_table_lookup (delegate_hash_table, d->delegate_trampoline);
g_hash_table_remove (delegate_hash_table, d->delegate_trampoline);
mono_marshal_unlock ();
if (gchandle)
@@ -390,21 +390,21 @@ delegate_hash_table_add (MonoDelegateHandle d)
if (has_target) {
// If the delegate has an instance method there is 1 to 1 mapping between
// the delegate object and the delegate_trampoline
guint32 gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (delegate_hash_table, delegate_trampoline));
gpointer gchandle = g_hash_table_lookup (delegate_hash_table, delegate_trampoline);
if (gchandle) {
// Somehow, some other thread beat us to it ?
g_assert (mono_gchandle_target_equal (gchandle, MONO_HANDLE_CAST (MonoObject, d)));
} else {
gchandle = mono_gchandle_new_weakref_from_handle (MONO_HANDLE_CAST (MonoObject, d));
g_hash_table_insert (delegate_hash_table, delegate_trampoline, GUINT_TO_POINTER (gchandle));
g_hash_table_insert (delegate_hash_table, delegate_trampoline, gchandle);
}
} else {
if (g_hash_table_lookup (delegate_hash_table, delegate_trampoline) == NULL) {
guint32 gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, d), FALSE);
gpointer gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, d), FALSE);
// This delegate will always be associated with its delegate_trampoline in the table.
// We don't free this delegate object because it is too expensive to keep track of these
// pairs and avoid races with the delegate finalization.
g_hash_table_insert (delegate_hash_table, delegate_trampoline, GUINT_TO_POINTER (gchandle));
g_hash_table_insert (delegate_hash_table, delegate_trampoline, gchandle);
}
}
mono_marshal_unlock ();
@@ -459,7 +459,7 @@ parse_unmanaged_function_pointer_attr (MonoClass *klass, MonoMethodPInvoke *piin
MonoDelegateHandle
mono_ftnptr_to_delegate_impl (MonoClass *klass, gpointer ftn, MonoError *error)
{
guint32 gchandle;
gpointer gchandle;
MonoDelegateHandle d = MONO_HANDLE_NEW (MonoDelegate, NULL);
if (ftn == NULL)
@@ -468,7 +468,7 @@ mono_ftnptr_to_delegate_impl (MonoClass *klass, gpointer ftn, MonoError *error)
mono_marshal_lock ();
if (delegate_hash_table == NULL)
delegate_hash_table = delegate_hash_table_new ();
gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (delegate_hash_table, ftn));
gchandle = g_hash_table_lookup (delegate_hash_table, ftn);
mono_marshal_unlock ();
if (gchandle)
MONO_HANDLE_ASSIGN (d, MONO_HANDLE_CAST (MonoDelegate, mono_gchandle_get_target_handle (gchandle)));
@@ -539,7 +539,7 @@ mono_delegate_free_ftnptr (MonoDelegate *delegate)
}
if (ptr) {
uint32_t gchandle;
gpointer gchandle;
void **method_data;
MonoMethod *method;
@@ -552,7 +552,7 @@ mono_delegate_free_ftnptr (MonoDelegate *delegate)
method_data = (void **)((MonoMethodWrapper*)method)->method_data;
/*the target gchandle is the first entry after size and the wrapper itself.*/
gchandle = GPOINTER_TO_UINT (method_data [2]);
gchandle = method_data [2];
if (gchandle)
mono_gchandle_free_internal (gchandle);
@@ -3809,14 +3809,14 @@ mono_marshal_get_native_func_wrapper_aot (MonoClass *klass)
* THIS_LOC is the memory location where the target of the delegate is stored.
*/
void
mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle)
mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, gpointer target_handle)
{
get_marshal_cb ()->emit_managed_wrapper (mb, invoke_sig, mspecs, m, method, target_handle);
}
#ifndef ENABLE_ILGEN
static void
emit_managed_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle)
emit_managed_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, gpointer target_handle)
{
MonoMethodSignature *sig, *csig;
int i;
@@ -3859,7 +3859,7 @@ emit_managed_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke
* If \p target_handle is \c 0, the wrapper info will be a \c WrapperInfo structure.
*/
MonoMethod *
mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, uint32_t target_handle, MonoError *error)
mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, gpointer target_handle, MonoError *error)
{
MonoMethodSignature *sig, *csig, *invoke_sig;
MonoMethodBuilder *mb;
@@ -3899,7 +3899,7 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass,
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_NATIVE_TO_MANAGED);
/*the target gchandle must be the first entry after size and the wrapper itself.*/
mono_mb_add_data (mb, GUINT_TO_POINTER (target_handle));
mono_mb_add_data (mb, target_handle);
/* we copy the signature, so that we can modify it */
if (target_handle)
@@ -5109,7 +5109,7 @@ mono_marshal_clear_last_error (void)
static gsize
copy_managed_common (MonoArrayHandle managed, gconstpointer native, gint32 start_index,
gint32 length, gpointer *managed_addr, guint32 *gchandle, MonoError *error)
gint32 length, gpointer *managed_addr, gpointer *gchandle, MonoError *error)
{
MONO_CHECK_ARG_NULL_HANDLE (managed, 0);
MONO_CHECK_ARG_NULL (native, 0);
@@ -5147,7 +5147,7 @@ void
ves_icall_System_Runtime_InteropServices_Marshal_copy_to_unmanaged (MonoArrayHandle src, gint32 start_index,
gpointer dest, gint32 length, gconstpointer managed_source_addr, MonoError *error)
{
guint32 gchandle = 0;
gpointer gchandle = 0;
gsize const bytes = copy_managed_common (src, dest, start_index, length, (gpointer*)&managed_source_addr, &gchandle, error);
if (bytes)
memmove (dest, managed_source_addr, bytes); // no references should be involved
@@ -5158,7 +5158,7 @@ void
ves_icall_System_Runtime_InteropServices_Marshal_copy_from_unmanaged (gconstpointer src, gint32 start_index,
MonoArrayHandle dest, gint32 length, gpointer managed_dest_addr, MonoError *error)
{
guint32 gchandle = 0;
gpointer gchandle = 0;
gsize const bytes = copy_managed_common (dest, src, start_index, length, &managed_dest_addr, &gchandle, error);
if (bytes)
memmove (managed_dest_addr, src, bytes); // no references should be involved
+3 -3
View File
@@ -324,7 +324,7 @@ typedef struct {
void (*emit_stelemref) (MonoMethodBuilder *mb);
void (*emit_array_address) (MonoMethodBuilder *mb, int rank, int elem_size);
void (*emit_native_wrapper) (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func, gboolean aot, gboolean check_exceptions, gboolean func_param, gboolean skip_gc_trans);
void (*emit_managed_wrapper) (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle);
void (*emit_managed_wrapper) (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, gpointer target_handle);
void (*emit_runtime_invoke_body) (MonoMethodBuilder *mb, const char **param_names, MonoImage *image, MonoMethod *method, MonoMethodSignature *sig, MonoMethodSignature *callsig, gboolean virtual_, gboolean need_direct_wrapper);
void (*emit_runtime_invoke_dynamic) (MonoMethodBuilder *mb);
void (*emit_delegate_begin_invoke) (MonoMethodBuilder *mb, MonoMethodSignature *sig);
@@ -442,7 +442,7 @@ MonoMethodSignature*
mono_marshal_get_string_ctor_signature (MonoMethod *method);
MonoMethod *
mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, uint32_t this_loc, MonoError *exernal_error);
mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, gpointer this_loc, MonoError *exernal_error);
gpointer
mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type);
@@ -662,7 +662,7 @@ void
mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func, gboolean aot, gboolean check_exceptions, gboolean func_param, gboolean skip_gc_trans);
void
mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle);
mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, gpointer target_handle);
GHashTable*
mono_marshal_get_cache (GHashTable **var, GHashFunc hash_func, GCompareFunc equal_func);
+9 -9
View File
@@ -333,7 +333,7 @@ mono_locks_dump (gboolean include_untaken)
to_recycle++;
} else {
if (!monitor_is_on_freelist ((MonoThreadsSync *)mon->data)) {
MonoObject *holder = (MonoObject *)mono_gchandle_get_target_internal ((guint32)(gsize)mon->data);
MonoObject *holder = (MonoObject *)mono_gchandle_get_target_internal (mon->data);
if (mon_status_get_owner (mon->status)) {
g_print ("Lock %p in object %p held by thread %d, nest level: %d\n",
mon, holder, mon_status_get_owner (mon->status), mon->nest);
@@ -395,7 +395,7 @@ mon_new (gsize id)
new_ = NULL;
for (marray = monitor_allocated; marray; marray = marray->next) {
for (i = 0; i < marray->num_monitors; ++i) {
if (mono_gchandle_get_target_internal ((guint32)(gsize)marray->monitors [i].data) == NULL) {
if (mono_gchandle_get_target_internal (marray->monitors [i].data) == NULL) {
new_ = &marray->monitors [i];
if (new_->wait_list) {
/* Orphaned events left by aborted threads */
@@ -405,7 +405,7 @@ mon_new (gsize id)
new_->wait_list = g_slist_remove (new_->wait_list, new_->wait_list->data);
}
}
mono_gchandle_free_internal ((guint32)(gsize)new_->data);
mono_gchandle_free_internal (new_->data);
new_->data = monitor_freelist;
monitor_freelist = new_;
}
@@ -462,7 +462,7 @@ alloc_mon (MonoObject *obj, gint32 id)
mono_monitor_allocator_lock ();
mon = mon_new (id);
mon->data = (void *)(size_t)mono_gchandle_new_weakref_internal (obj, TRUE);
mon->data = mono_gchandle_new_weakref_internal (obj, TRUE);
mono_monitor_allocator_unlock ();
return mon;
@@ -472,7 +472,7 @@ static void
discard_mon (MonoThreadsSync *mon)
{
mono_monitor_allocator_lock ();
mono_gchandle_free_internal ((guint32)(gsize)mon->data);
mono_gchandle_free_internal (mon->data);
mon_finalize (mon);
mono_monitor_allocator_unlock ();
}
@@ -1145,7 +1145,7 @@ mono_monitor_exit (MonoObject *obj)
MONO_EXTERNAL_ONLY_VOID (mono_monitor_exit_internal (obj));
}
guint32
gpointer
mono_monitor_get_object_monitor_gchandle (MonoObject *object)
{
LockWord lw;
@@ -1154,9 +1154,9 @@ mono_monitor_get_object_monitor_gchandle (MonoObject *object)
if (lock_word_is_inflated (lw)) {
MonoThreadsSync *mon = lock_word_get_inflated_lock (lw);
return (guint32)(gsize)mon->data;
return mon->data;
}
return 0;
return NULL;
}
/*
@@ -1514,4 +1514,4 @@ ves_icall_System_Threading_Monitor_Monitor_LockContentionCount (void)
return 0;
#endif
}
#endif
#endif
+1 -1
View File
@@ -122,7 +122,7 @@ ICALL_EXTERN_C
guint32
mono_monitor_enter_v4_fast (MonoObject *obj, MonoBoolean *lock_taken);
guint32
gpointer
mono_monitor_get_object_monitor_gchandle (MonoObject *object);
void
+11 -7
View File
@@ -26,6 +26,8 @@
#include "mono/utils/mono-coop-mutex.h"
#include <mono/metadata/icalls.h>
G_BEGIN_DECLS
/* Use this as MONO_CHECK_ARG (arg,expr,) in functions returning void */
#define MONO_CHECK_ARG(arg, expr, retval) do { \
if (G_UNLIKELY (!(expr))) \
@@ -167,10 +169,10 @@ typedef struct {
struct _MonoArray {
MonoObject obj;
/* bounds is NULL for szarrays */
MonoArrayBounds *bounds;
/* total number of elements of the array */
mono_array_size_t max_length;
/* bounds is NULL for szarrays */
MonoArrayBounds *bounds;
/* we use mono_64bitaligned_t to ensure proper alignment on platforms that need it */
mono_64bitaligned_t vector [MONO_ZERO_LEN_ARRAY];
};
@@ -586,7 +588,7 @@ struct _MonoInternalThread {
MonoThreadName name;
guint32 state; /* must be accessed while longlived->synch_cs is locked */
MonoException *abort_exc;
int abort_state_handle;
gpointer abort_state_handle;
guint64 tid; /* This is accessed as a gsize in the code (so it can hold a 64bit pointer on systems that need it), but needs to reserve 64 bits of space on all machines as it corresponds to a field in managed code */
gsize debugger_thread; // FIXME switch to bool as soon as CI testing with corlib version bump works
gpointer *static_data;
@@ -2347,17 +2349,17 @@ mono_runtime_get_aotid_arr (void);
* mono_gchandle_get_target () can be used to get the object referenced by both kinds
* of handle: for a weakref handle, if an object has been collected, it will return NULL.
*/
uint32_t
gpointer
mono_gchandle_new_internal (MonoObject *obj, mono_bool pinned);
uint32_t
gpointer
mono_gchandle_new_weakref_internal (MonoObject *obj, mono_bool track_resurrection);
ICALL_EXTERN_C
MonoObject*
mono_gchandle_get_target_internal (uint32_t gchandle);
mono_gchandle_get_target_internal (gpointer gchandle);
void mono_gchandle_free_internal (uint32_t gchandle);
void mono_gchandle_free_internal (gpointer gchandle);
/* Reference queue support
*
@@ -2405,4 +2407,6 @@ mono_gc_wbarrier_value_copy_internal (void* dest, const void* src, int count, Mo
void
mono_gc_wbarrier_object_copy_internal (MonoObject* obj, MonoObject *src);
G_END_DECLS
#endif /* __MONO_OBJECT_INTERNALS_H__ */
+26 -17
View File
@@ -137,7 +137,7 @@ mono_runtime_object_init_handle (MonoObjectHandle this_obj, MonoError *error)
g_assertf (method, "Could not lookup zero argument constructor for class %s", mono_type_get_full_name (klass));
if (m_class_is_valuetype (method->klass)) {
guint gchandle = 0;
gpointer gchandle = 0;
gpointer raw = mono_object_handle_pin_unbox (this_obj, &gchandle);
mono_runtime_invoke_checked (method, raw, NULL, error);
mono_gchandle_free_internal (gchandle);
@@ -1145,6 +1145,7 @@ mono_class_compute_gc_descriptor (MonoClass *klass)
gsize *bitmap;
gsize default_bitmap [4] = {0};
MonoGCDescriptor gc_descr;
GPtrArray *gc_descr_full = NULL;
if (!m_class_is_inited (klass))
mono_class_init_internal (klass);
@@ -1154,19 +1155,19 @@ mono_class_compute_gc_descriptor (MonoClass *klass)
bitmap = default_bitmap;
if (klass == mono_defaults.string_class) {
gc_descr = mono_gc_make_descr_for_string (bitmap, 2);
gc_descr = mono_gc_make_descr_for_string (bitmap, 2, &gc_descr_full);
} else if (m_class_get_rank (klass)) {
MonoClass *klass_element_class = m_class_get_element_class (klass);
mono_class_compute_gc_descriptor (klass_element_class);
if (MONO_TYPE_IS_REFERENCE (m_class_get_byval_arg (klass_element_class))) {
gsize abm = 1;
gc_descr = mono_gc_make_descr_for_array (m_class_get_byval_arg (klass)->type == MONO_TYPE_SZARRAY, &abm, 1, sizeof (gpointer));
gc_descr = mono_gc_make_descr_for_array (m_class_get_byval_arg (klass)->type == MONO_TYPE_SZARRAY, &abm, 1, sizeof (gpointer), &gc_descr_full);
/*printf ("new array descriptor: 0x%x for %s.%s\n", class->gc_descr,
class->name_space, class->name);*/
} else {
/* remove the object header */
bitmap = mono_class_compute_bitmap (klass_element_class, default_bitmap, sizeof (default_bitmap) * 8, - (int)(MONO_OBJECT_HEADER_BITS), &max_set, FALSE);
gc_descr = mono_gc_make_descr_for_array (m_class_get_byval_arg (klass)->type == MONO_TYPE_SZARRAY, bitmap, mono_array_element_size (klass) / sizeof (gpointer), mono_array_element_size (klass));
gc_descr = mono_gc_make_descr_for_array (m_class_get_byval_arg (klass)->type == MONO_TYPE_SZARRAY, bitmap, mono_array_element_size (klass) / sizeof (gpointer), mono_array_element_size (klass), &gc_descr_full);
/*printf ("new vt array descriptor: 0x%x for %s.%s\n", class->gc_descr,
class->name_space, class->name);*/
}
@@ -1218,14 +1219,14 @@ mono_class_compute_gc_descriptor (MonoClass *klass)
mono_loader_unlock ();
}
gc_descr = mono_gc_make_descr_for_object (bitmap, max_set + 1, m_class_get_instance_size (klass));
gc_descr = mono_gc_make_descr_for_object (klass, bitmap, max_set + 1, m_class_get_instance_size (klass), &gc_descr_full);
}
if (bitmap != default_bitmap)
g_free (bitmap);
/* Publish the data */
mono_class_publish_gc_descriptor (klass, gc_descr);
mono_class_publish_gc_descriptor (klass, gc_descr, gc_descr_full);
}
/**
@@ -2005,6 +2006,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro
char *t;
int i, vtable_slots;
size_t imt_table_bytes;
size_t gc_descr_full_bytes;
int gc_bits;
guint32 vtable_size, class_size;
gpointer iter;
@@ -2079,27 +2081,35 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro
if (class_size)
vtable_slots++;
if (m_class_get_interface_offsets_count (klass)) {
mono_class_compute_gc_descriptor (klass);
if (m_class_get_interface_offsets_count (klass) || klass->gc_descr_full) {
imt_table_bytes = sizeof (gpointer) * (MONO_IMT_SIZE);
/* Interface table for the interpreter */
if (use_interpreter)
imt_table_bytes *= 2;
imt_table_bytes *= 2;
if (klass->gc_descr_full)
gc_descr_full_bytes = klass->gc_descr_full->len * sizeof (gpointer);
else
gc_descr_full_bytes = 0;
UnlockedIncrement (&mono_stats.imt_number_of_tables);
UnlockedAdd (&mono_stats.imt_tables_size, imt_table_bytes);
} else {
imt_table_bytes = 0;
gc_descr_full_bytes = 0;
}
vtable_size = imt_table_bytes + MONO_SIZEOF_VTABLE + vtable_slots * sizeof (gpointer);
vtable_size = gc_descr_full_bytes + imt_table_bytes + MONO_SIZEOF_VTABLE + vtable_slots * sizeof (gpointer);
UnlockedIncrement (&mono_stats.used_class_count);
UnlockedAdd (&mono_stats.class_vtable_size, vtable_size);
interface_offsets = alloc_vtable (domain, vtable_size, imt_table_bytes);
gpointer *gc_descr_full_mem = alloc_vtable (domain, vtable_size, imt_table_bytes);
if (gc_descr_full_bytes)
memcpy (gc_descr_full_mem, klass->gc_descr_full->pdata, gc_descr_full_bytes);
interface_offsets = (gpointer*)((char*)gc_descr_full_mem + gc_descr_full_bytes);
vt = (MonoVTable*) ((char*)interface_offsets + imt_table_bytes);
/* If on interp, skip the interp interface table */
if (use_interpreter)
interface_offsets = (gpointer*)((char*)interface_offsets + imt_table_bytes / 2);
interface_offsets = (gpointer*)((char*)interface_offsets + imt_table_bytes / 2);
g_assert (!((gsize)vt & 7));
vt->klass = klass;
@@ -2116,7 +2126,6 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro
MONO_PROFILER_RAISE (vtable_loading, (vt));
mono_class_compute_gc_descriptor (klass);
/*
* For Boehm:
* We can't use typed allocation in the non-root domains, since the
@@ -4137,7 +4146,7 @@ mono_nullable_init_from_handle (guint8 *buf, MonoObjectHandle value, MonoClass *
MONO_REQ_GC_UNSAFE_MODE;
if (!MONO_HANDLE_IS_NULL (value)) {
uint32_t value_gchandle = 0;
gpointer value_gchandle = 0;
gpointer src = mono_object_handle_pin_unbox (value, &value_gchandle);
mono_nullable_init_unboxed (buf, src, klass);
@@ -6232,7 +6241,7 @@ mono_array_clone_in_domain (MonoDomain *domain, MonoArrayHandle array_handle, Mo
error_init (error);
/* Pin source array here - if bounds is non-NULL, it's a pointer into the object data */
uint32_t src_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, array_handle), TRUE);
gpointer src_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, array_handle), TRUE);
MonoArrayBounds *array_bounds = MONO_HANDLE_GETVAL (array_handle, bounds);
MonoArrayHandle o;
@@ -6255,7 +6264,7 @@ mono_array_clone_in_domain (MonoDomain *domain, MonoArrayHandle array_handle, Mo
goto_if_nok (error, leave);
}
uint32_t dst_handle;
gpointer dst_handle;
dst_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, o), TRUE);
array_full_copy_unchecked_size (MONO_HANDLE_RAW (array_handle), MONO_HANDLE_RAW (o), klass, size);
mono_gchandle_free_internal (dst_handle);
+4 -4
View File
@@ -367,10 +367,10 @@ mono_property_get_value (MonoProperty *prop, void *obj, void **params, MonoObjec
* mono_gchandle_get_target () can be used to get the object referenced by both kinds
* of handle: for a weakref handle, if an object has been collected, it will return NULL.
*/
MONO_API MONO_RT_EXTERNAL_ONLY uint32_t mono_gchandle_new (MonoObject *obj, mono_bool pinned);
MONO_API MONO_RT_EXTERNAL_ONLY uint32_t mono_gchandle_new_weakref (MonoObject *obj, mono_bool track_resurrection);
MONO_API MONO_RT_EXTERNAL_ONLY MonoObject* mono_gchandle_get_target (uint32_t gchandle);
MONO_API MONO_RT_EXTERNAL_ONLY void mono_gchandle_free (uint32_t gchandle);
MONO_API MONO_RT_EXTERNAL_ONLY void* mono_gchandle_new (MonoObject *obj, mono_bool pinned);
MONO_API MONO_RT_EXTERNAL_ONLY void* mono_gchandle_new_weakref (MonoObject *obj, mono_bool track_resurrection);
MONO_API MONO_RT_EXTERNAL_ONLY MonoObject* mono_gchandle_get_target (void* gchandle);
MONO_API MONO_RT_EXTERNAL_ONLY void mono_gchandle_free (void* gchandle);
/* Reference queue support
*
+6 -6
View File
@@ -100,7 +100,7 @@ MonoReflectionTypeBuilderHandle
mono_class_get_ref_info (MonoClass *klass)
{
MONO_REQ_GC_UNSAFE_MODE;
guint32 ref_info_handle = mono_class_get_ref_info_handle (klass);
gpointer ref_info_handle = mono_class_get_ref_info_handle (klass);
if (ref_info_handle == 0)
return MONO_HANDLE_NEW (MonoReflectionTypeBuilder, NULL);
@@ -119,7 +119,7 @@ mono_class_get_ref_info_raw (MonoClass *klass)
{
/* FIXME callers of mono_class_get_ref_info_raw should use handles */
MONO_REQ_GC_UNSAFE_MODE;
guint32 ref_info_handle = mono_class_get_ref_info_handle (klass);
gpointer ref_info_handle = mono_class_get_ref_info_handle (klass);
if (ref_info_handle == 0)
return NULL;
@@ -131,8 +131,8 @@ mono_class_set_ref_info (MonoClass *klass, MonoObjectHandle obj)
{
MONO_REQ_GC_UNSAFE_MODE;
guint32 candidate = mono_gchandle_from_handle (obj, FALSE);
guint32 handle = mono_class_set_ref_info_handle (klass, candidate);
gpointer candidate = mono_gchandle_from_handle (obj, FALSE);
gpointer handle = mono_class_set_ref_info_handle (klass, candidate);
++class_ref_info_handle_count;
if (handle != candidate)
@@ -143,7 +143,7 @@ void
mono_class_free_ref_info (MonoClass *klass)
{
MONO_REQ_GC_NEUTRAL_MODE;
guint32 handle = mono_class_get_ref_info_handle (klass);
gpointer handle = mono_class_get_ref_info_handle (klass);
if (handle) {
mono_gchandle_free_internal (handle);
@@ -1309,7 +1309,7 @@ method_body_object_construct (MonoDomain *domain, MonoClass *unused_class, MonoM
MonoArrayHandle il_arr;
il_arr = mono_array_new_handle (domain, mono_defaults.byte_class, header->code_size, error);
goto_if_nok (error, fail);
uint32_t il_gchandle;
gpointer il_gchandle;
guint8* il_data;
il_data = MONO_ARRAY_HANDLE_PIN (il_arr, guint8, 0, &il_gchandle);
memcpy (il_data, header->code, header->code_size);
+2 -2
View File
@@ -2086,7 +2086,7 @@ mono_marshal_xdomain_copy_value_handle (MonoObjectHandle val, MonoError *error)
case MONO_TYPE_U8:
case MONO_TYPE_R4:
case MONO_TYPE_R8: {
uint32_t gchandle = mono_gchandle_from_handle (val, TRUE);
gpointer gchandle = mono_gchandle_from_handle (val, TRUE);
MonoObjectHandle res = MONO_HANDLE_NEW (MonoObject, mono_value_box_checked (domain, klass, ((char*)MONO_HANDLE_RAW (val)) + sizeof(MonoObject), error)); /* FIXME use handles in mono_value_box_checked */
mono_gchandle_free_internal (gchandle);
goto_if_nok (error, leave);
@@ -2095,7 +2095,7 @@ mono_marshal_xdomain_copy_value_handle (MonoObjectHandle val, MonoError *error)
}
case MONO_TYPE_STRING: {
MonoStringHandle str = MONO_HANDLE_CAST (MonoString, val);
uint32_t gchandle = mono_gchandle_from_handle (val, TRUE);
gpointer gchandle = mono_gchandle_from_handle (val, TRUE);
MonoStringHandle res = mono_string_new_utf16_handle (domain, mono_string_chars_internal (MONO_HANDLE_RAW (str)), mono_string_handle_length (str), error);
mono_gchandle_free_internal (gchandle);
goto_if_nok (error, leave);
+15 -21
View File
@@ -360,7 +360,7 @@ get_array_fill_vtable (void)
vtable->klass = klass;
bmap = 0;
vtable->gc_descr = mono_gc_make_descr_for_array (TRUE, &bmap, 0, 8);
vtable->gc_descr = mono_gc_make_descr_for_array (TRUE, &bmap, 0, 8, NULL);
vtable->rank = 1;
array_fill_vtable = vtable;
@@ -774,7 +774,7 @@ clear_domain_process_object (GCObject *obj, MonoDomain *domain)
remove = need_remove_object_for_domain (obj, domain);
if (remove && obj->synchronisation) {
guint32 dislink = mono_monitor_get_object_monitor_gchandle (obj);
gpointer dislink = mono_monitor_get_object_monitor_gchandle (obj);
if (dislink)
mono_gchandle_free_internal (dislink);
}
@@ -2167,8 +2167,6 @@ sgen_client_thread_detach_with_lock (SgenThreadInfo *p)
tid = mono_thread_info_get_tid (p);
mono_threads_add_joinable_runtime_thread (&p->client_info.info);
if (mono_gc_get_gc_callbacks ()->thread_detach_func) {
mono_gc_get_gc_callbacks ()->thread_detach_func (p->client_info.runtime_data);
p->client_info.runtime_data = NULL;
@@ -2176,10 +2174,6 @@ sgen_client_thread_detach_with_lock (SgenThreadInfo *p)
sgen_binary_protocol_thread_unregister ((gpointer)tid);
SGEN_LOG (3, "unregister thread %p (%p)", p, (gpointer)tid);
HandleStack *handles = p->client_info.info.handle_stack;
p->client_info.info.handle_stack = NULL;
mono_handle_stack_free (handles);
}
void
@@ -2572,7 +2566,7 @@ mono_gc_make_root_descr_user (MonoGCRootMarkFunc marker)
}
MonoGCDescriptor
mono_gc_make_descr_for_string (gsize *bitmap, int numbits)
mono_gc_make_descr_for_string (gsize *bitmap, int numbits, GPtrArray **gc_descr_full)
{
return SGEN_DESC_STRING;
}
@@ -2640,10 +2634,10 @@ sgen_client_metadata_for_object (GCObject *obj)
*
* \returns a handle that can be used to access the object from unmanaged code.
*/
guint32
gpointer
mono_gchandle_new_internal (MonoObject *obj, gboolean pinned)
{
return sgen_gchandle_new (obj, pinned);
return (gpointer)(size_t)sgen_gchandle_new (obj, pinned);
}
/**
@@ -2667,10 +2661,10 @@ mono_gchandle_new_internal (MonoObject *obj, gboolean pinned)
* \returns a handle that can be used to access the object from
* unmanaged code.
*/
guint32
gpointer
mono_gchandle_new_weakref_internal (GCObject *obj, gboolean track_resurrection)
{
return sgen_gchandle_new_weakref (obj, track_resurrection);
return (gpointer)(size_t)sgen_gchandle_new_weakref (obj, track_resurrection);
}
/**
@@ -2680,9 +2674,9 @@ mono_gchandle_new_weakref_internal (GCObject *obj, gboolean track_resurrection)
* \returns TRUE if the object wrapped by the \p gchandle belongs to the specific \p domain.
*/
gboolean
mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain)
mono_gchandle_is_in_domain (gpointer gchandle, MonoDomain *domain)
{
MonoDomain *gchandle_domain = (MonoDomain *)sgen_gchandle_get_metadata (gchandle);
MonoDomain *gchandle_domain = (MonoDomain *)sgen_gchandle_get_metadata ((guint32)gchandle);
return domain->domain_id == gchandle_domain->domain_id;
}
@@ -2695,9 +2689,9 @@ mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain)
* object wrapped.
*/
void
mono_gchandle_free_internal (guint32 gchandle)
mono_gchandle_free_internal (gpointer gchandle)
{
sgen_gchandle_free (gchandle);
sgen_gchandle_free ((guint32)gchandle);
}
/**
@@ -2723,9 +2717,9 @@ mono_gchandle_free_domain (MonoDomain *unloading)
* NULL for a collected object if using a weakref handle.
*/
MonoObject*
mono_gchandle_get_target_internal (guint32 gchandle)
mono_gchandle_get_target_internal (gpointer gchandle)
{
return sgen_gchandle_get_target (gchandle);
return sgen_gchandle_get_target ((guint32)gchandle);
}
static gpointer
@@ -2754,9 +2748,9 @@ sgen_null_links_for_domain (MonoDomain *domain)
}
void
mono_gchandle_set_target (guint32 gchandle, MonoObject *obj)
mono_gchandle_set_target (gpointer gchandle, MonoObject *obj)
{
sgen_gchandle_set_target (gchandle, obj);
sgen_gchandle_set_target ((gint32)gchandle, obj);
}
void
+2 -2
View File
@@ -1007,7 +1007,7 @@ reflection_sighelper_get_signature_local (MonoReflectionSigHelperHandle sig, Mon
MonoArrayHandle result;
result = mono_array_new_handle (mono_domain_get (), mono_defaults.byte_class, buflen, error);
goto_if_nok (error, fail);
uint32_t gchandle;
gpointer gchandle;
void *base;
base = MONO_ARRAY_HANDLE_PIN (result, char, 0, &gchandle);
memcpy (base, buf.buf, buflen);
@@ -1043,7 +1043,7 @@ reflection_sighelper_get_signature_field (MonoReflectionSigHelperHandle sig, Mon
MonoArrayHandle result;
result = mono_array_new_handle (mono_domain_get (), mono_defaults.byte_class, buflen, error);
goto_if_nok (error, fail);
uint32_t gchandle;
gpointer gchandle;
void *base;
base = MONO_ARRAY_HANDLE_PIN (result, char, 0, &gchandle);
memcpy (base, buf.buf, buflen);
+5 -5
View File
@@ -1029,7 +1029,7 @@ mono_image_insert_string (MonoReflectionModuleBuilderHandle ref_module, MonoStri
mono_metadata_encode_value (1 | (length * 2), b, &b);
idx = mono_image_add_stream_data (&assembly->us, buf, b-buf);
/* pinned */
uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, str), TRUE);
gpointer gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, str), TRUE);
const char *p = (const char*)mono_string_chars_internal (MONO_HANDLE_RAW (str));
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
{
@@ -4077,10 +4077,10 @@ free_dynamic_method (void *dynamic_method)
DynamicMethodReleaseData *data = (DynamicMethodReleaseData *)dynamic_method;
MonoDomain *domain = data->domain;
MonoMethod *method = data->handle;
guint32 dis_link;
gpointer dis_link;
mono_domain_lock (domain);
dis_link = (guint32)(size_t)g_hash_table_lookup (domain->method_to_dyn_method, method);
dis_link = g_hash_table_lookup (domain->method_to_dyn_method, method);
g_hash_table_remove (domain->method_to_dyn_method, method);
mono_domain_unlock (domain);
g_assert (dis_link);
@@ -4218,7 +4218,7 @@ reflection_create_dynamic_method (MonoReflectionDynamicMethodHandle ref_mb, Mono
mono_domain_lock (domain);
if (!domain->method_to_dyn_method)
domain->method_to_dyn_method = g_hash_table_new (NULL, NULL);
g_hash_table_insert (domain->method_to_dyn_method, handle, (gpointer)(size_t)mono_gchandle_new_weakref_internal ((MonoObject *)mb, TRUE));
g_hash_table_insert (domain->method_to_dyn_method, handle, mono_gchandle_new_weakref_internal ((MonoObject *)mb, TRUE));
mono_domain_unlock (domain);
return TRUE;
@@ -4655,7 +4655,7 @@ ves_icall_CustomAttributeBuilder_GetBlob (MonoReflectionAssemblyHandle assembly,
void
ves_icall_AssemblyBuilder_basic_init (MonoReflectionAssemblyBuilderHandle assemblyb, MonoError *error)
{
uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, assemblyb), TRUE);
gpointer gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, assemblyb), TRUE);
mono_reflection_dynimage_basic_init (MONO_HANDLE_RAW (assemblyb), error);
mono_gchandle_free_internal (gchandle);
}
+1 -1
View File
@@ -70,7 +70,7 @@ typedef void (*MonoThreadCleanupFunc) (MonoNativeThreadId tid);
/* INFO has type MonoThreadInfo* */
typedef void (*MonoThreadNotifyPendingExcFunc) (gpointer info);
void
G_EXTERN_C void
mono_thread_callbacks_init (void);
typedef enum {
+21 -15
View File
@@ -850,7 +850,7 @@ mono_thread_attach_internal (MonoThread *thread, gboolean force_attach, gboolean
MonoThreadInfo *info;
MonoInternalThread *internal;
MonoDomain *domain, *root_domain;
guint32 gchandle;
gpointer gchandle;
g_assert (thread);
@@ -865,7 +865,7 @@ mono_thread_attach_internal (MonoThread *thread, gboolean force_attach, gboolean
* - the MonoThreadInfo TLS key is destroyed: calls mono_thread_info_detach
* - it calls MonoThreadInfoCallbacks.thread_detach
* - mono_thread_internal_current returns NULL -> fails to detach the MonoInternalThread. */
mono_thread_info_set_internal_thread_gchandle (info, mono_gchandle_new_internal ((MonoObject*) internal, FALSE));
mono_thread_info_set_internal_thread_gchandle (info, mono_gchandle_new_internal ((MonoObject*) internal, TRUE));
internal->handle = mono_threads_open_thread_handle (info->handle);
internal->native_handle = MONO_NATIVE_THREAD_HANDLE_TO_GPOINTER (mono_threads_open_native_thread_handle (info->native_handle));
@@ -955,7 +955,7 @@ mono_thread_detach_internal (MonoInternalThread *thread)
MonoThreadInfo *info;
MonoInternalThread *value;
gboolean removed;
guint32 gchandle;
gpointer gchandle;
g_assert (mono_thread_internal_is_current (thread));
@@ -1626,7 +1626,7 @@ mono_thread_construct_internal (MonoThreadObjectHandle this_obj_handle)
internal->state = ThreadState_Unstarted;
int const thread_gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, this_obj_handle), TRUE);
gpointer thread_gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, this_obj_handle), TRUE);
MonoThreadObject *this_obj = MONO_HANDLE_RAW (this_obj_handle);
@@ -2045,7 +2045,7 @@ byte_array_to_domain (MonoArrayHandle arr, MonoDomain *domain, MonoError *error)
struct {
MonoArrayHandle handle;
gpointer p;
guint gchandle;
gpointer gchandle;
}
source = { arr },
dest = { mono_array_new_handle (domain, mono_defaults.byte_class, size, error) };
@@ -3265,7 +3265,7 @@ mono_threads_register_app_context (MonoAppContextHandle ctx, MonoError *error)
* handle in the reference queue callback.
*/
ContextStaticData *data = g_new0 (ContextStaticData, 1);
data->gc_handle = GPOINTER_TO_UINT (gch);
data->gc_handle = gch;
MONO_HANDLE_SETVAL (ctx, data, ContextStaticData*, data);
context_adjust_static_data (ctx);
@@ -3339,7 +3339,7 @@ static void
thread_detach (MonoThreadInfo *info)
{
MonoInternalThread *internal;
guint32 gchandle;
gpointer gchandle;
/* If a delegate is passed to native code and invoked on a thread we dont
* know about, marshal will register it with mono_threads_attach_coop, but
@@ -3363,6 +3363,12 @@ static void
thread_detach_with_lock (MonoThreadInfo *info)
{
mono_gc_thread_detach_with_lock (info);
mono_threads_add_joinable_runtime_thread (info);
HandleStack *handles = info->handle_stack;
info->handle_stack = NULL;
mono_handle_stack_free (handles);
}
static gboolean
@@ -3934,7 +3940,7 @@ get_thread_dump (MonoThreadInfo *info, gpointer ud)
typedef struct {
int nthreads, max_threads;
guint32 *threads;
gpointer *threads;
} CollectThreadsUserData;
typedef struct {
@@ -3957,7 +3963,7 @@ collect_thread (gpointer key, gpointer value, gpointer user)
* THREADS should be an array allocated on the stack.
*/
static int
collect_threads (guint32 *thread_handles, int max_threads)
collect_threads (gpointer *thread_handles, int max_threads)
{
CollectThreadsUserData ud;
@@ -4064,7 +4070,7 @@ mono_threads_perform_thread_dump (void)
{
FILE* output_file = NULL;
ThreadDumpUserData ud;
guint32 thread_array [128];
gpointer thread_array [128];
int tindex, nthreads;
if (!thread_dump_requested)
@@ -4096,7 +4102,7 @@ mono_threads_perform_thread_dump (void)
ud.max_frames = 256;
for (tindex = 0; tindex < nthreads; ++tindex) {
guint32 handle = thread_array [tindex];
gpointer handle = thread_array [tindex];
MonoInternalThread *thread = (MonoInternalThread *) mono_gchandle_get_target_internal (handle);
dump_thread (thread, &ud, output_file != NULL ? output_file : stdout);
mono_gchandle_free_internal (handle);
@@ -4118,7 +4124,7 @@ ves_icall_System_Threading_Thread_GetStackTraces (MonoArrayHandleOut out_threads
MONO_HANDLE_ASSIGN_RAW (out_threads_handle, NULL);
MONO_HANDLE_ASSIGN_RAW (out_stack_frames_handle, NULL);
guint32 handle = 0;
gpointer handle = 0;
MonoStackFrameHandle stack_frame_handle = MONO_HANDLE_NEW (MonoStackFrame, NULL);
MonoReflectionMethodHandle reflection_method_handle = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
@@ -4126,7 +4132,7 @@ ves_icall_System_Threading_Thread_GetStackTraces (MonoArrayHandleOut out_threads
MonoArrayHandle thread_frames_handle = MONO_HANDLE_NEW (MonoArray, NULL);
ThreadDumpUserData ud;
guint32 thread_array [128];
gpointer thread_array [128];
MonoDomain *domain = mono_domain_get ();
MonoDebugSourceLocation *location;
int tindex, nthreads;
@@ -4702,7 +4708,7 @@ alloc_thread_static_data_helper (gpointer key, gpointer value, gpointer user)
static void
alloc_context_static_data_helper (gpointer key, gpointer value, gpointer user)
{
MonoAppContext *ctx = (MonoAppContext *) mono_gchandle_get_target_internal (GPOINTER_TO_INT (key));
MonoAppContext *ctx = (MonoAppContext *) mono_gchandle_get_target_internal (key);
if (!ctx)
return;
@@ -4858,7 +4864,7 @@ free_thread_static_data_helper (gpointer key, gpointer value, gpointer user)
static void
free_context_static_data_helper (gpointer key, gpointer value, gpointer user)
{
MonoAppContext *ctx = (MonoAppContext *) mono_gchandle_get_target_internal (GPOINTER_TO_INT (key));
MonoAppContext *ctx = (MonoAppContext *) mono_gchandle_get_target_internal (key);
if (!ctx)
return;
+2 -2
View File
@@ -538,7 +538,7 @@ ves_icall_System_IO_MonoIO_Read (HANDLE handle, MonoArrayHandle dest,
return 0;
}
guint32 buffer_handle = 0;
gpointer buffer_handle = 0;
buffer = MONO_ARRAY_HANDLE_PIN (dest, guchar, dest_offset, &buffer_handle);
result = mono_w32file_read (handle, buffer, count, &n, io_error);
mono_gchandle_free_internal (buffer_handle);
@@ -568,7 +568,7 @@ ves_icall_System_IO_MonoIO_Write (HANDLE handle, MonoArrayHandle src,
return 0;
}
guint32 src_handle = 0;
gpointer src_handle = 0;
buffer = MONO_ARRAY_HANDLE_PIN (src, guchar, src_offset, &src_handle);
result = mono_w32file_write (handle, buffer, count, &n, io_error);
mono_gchandle_free_internal (src_handle);
+3
View File
@@ -17,6 +17,8 @@
#include "mono/utils/mono-coop-mutex.h"
#include "mono/utils/mono-error.h"
G_BEGIN_DECLS
#define MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS 64
#define MONO_INFINITE_WAIT ((guint32) 0xFFFFFFFF)
@@ -182,5 +184,6 @@ mono_w32handle_convert_wait_ret (guint32 res, guint32 numobjects)
}
#endif
G_END_DECLS
#endif /* _MONO_METADATA_W32HANDLE_H_ */
+1 -1
View File
@@ -74,7 +74,7 @@ typedef struct
TYPED_HANDLE_DECL (MonoW32ProcessStartInfo);
typedef uint32_t gchandle_t; // FIXME use this more, make it typesafe.
typedef gpointer gchandle_t; // FIXME use this more, make it typesafe.
typedef struct _MonoCreateProcessCoop {
gunichar2 *filename;
+8 -8
View File
@@ -1138,7 +1138,7 @@ create_sockaddr_from_handle (MonoObjectHandle saddr_obj, socklen_t *sa_size, gin
len = MONO_HANDLE_GET_FIELD_VAL (saddr_obj, int, domain->sockaddr_data_length_field);
g_assert (len >= 2);
uint32_t gchandle;
gpointer gchandle;
guint8 *buf = MONO_ARRAY_HANDLE_PIN (data, guint8, 0, &gchandle);
family = convert_family ((MonoAddressFamily)(buf[0] + (buf[1] << 8)));
if (family == AF_INET) {
@@ -1924,7 +1924,7 @@ ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal (gsize sock, gi
valsize = mono_array_handle_length (byte_val);
uint32_t gchandle;
gpointer gchandle;
guchar *buf = MONO_ARRAY_HANDLE_PIN (byte_val, guchar, 0, &gchandle);
ret = mono_w32socket_getsockopt (sock, system_level, system_name, buf, &valsize);
@@ -2162,7 +2162,7 @@ ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32
}
} else if (!MONO_HANDLE_IS_NULL (byte_val)) {
int valsize = mono_array_handle_length (byte_val);
uint32_t gchandle;
gpointer gchandle;
guchar *buf = MONO_ARRAY_HANDLE_PIN (byte_val, guchar, 0, &gchandle);
switch(name) {
@@ -2280,8 +2280,8 @@ ves_icall_System_Net_Sockets_Socket_IOControl_internal (gsize sock, gint32 code,
#endif
gchar *i_buffer, *o_buffer;
gint i_len, o_len;
uint32_t i_gchandle = 0;
uint32_t o_gchandle = 0;
gpointer i_gchandle = 0;
gpointer o_gchandle = 0;
gint ret;
error_init (error);
@@ -2594,8 +2594,8 @@ ves_icall_System_Net_Sockets_Socket_SendFile_internal (gsize sock, MonoStringHan
HANDLE file;
gboolean ret;
TRANSMIT_FILE_BUFFERS buffers;
uint32_t pre_buffer_gchandle = 0;
uint32_t post_buffer_gchandle = 0;
gpointer pre_buffer_gchandle = 0;
gpointer post_buffer_gchandle = 0;
error_init (error);
*werror = 0;
@@ -2605,7 +2605,7 @@ ves_icall_System_Net_Sockets_Socket_SendFile_internal (gsize sock, MonoStringHan
/* FIXME: replace file by a proper fd that we can call open and close on, as they are interruptible */
uint32_t filename_gchandle;
gpointer filename_gchandle;
gunichar2 *filename_chars = mono_string_handle_pin_chars (filename, &filename_gchandle);
file = mono_w32file_create (filename_chars, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, 0);
mono_gchandle_free_internal (filename_gchandle);
+2
View File
@@ -31,6 +31,8 @@
/TAGS
/mono-sgen
/mono-boehm
/mono-coregc
/buildver-sgen.h
/buildver-boehm.h
/buildver-coregc.h
/regressiontests.out
+57 -4
View File
@@ -41,6 +41,12 @@ sgen_libs = \
$(monodir)/mono/utils/libmonoutils.la \
$(glib_libs)
coregc_libs = \
$(monodir)/mono/metadata/libmonoruntimecoregc.la \
$(monodir)/mono/coregc/libmonocoregc.la \
$(monodir)/mono/utils/libmonoutils.la \
$(glib_libs)
if ENABLE_LLVM
include $(mono_build_root)/llvm/llvm_config.mk
@@ -120,14 +126,25 @@ boehm_static_libraries = libmini.la $(interp_libs_with_mini) $(dbg_libs_with_min
boehm_binaries = mono-boehm
endif
if SUPPORT_COREGC
coregc_binaries = mono-coregc
coregc_libraries = libmonocoregc-2.0.la
coregc_static_libraries = libmini.la $(interp_libs_with_mini) $(dbg_libs_with_mini) $(coregc_libs)
endif
endif # !ENABLE_MSVC_ONLY
if SUPPORT_SGEN
mono_bin_suffix = sgen
libmono_suffix = sgen
else
if SUPPORT_BOEHM
mono_bin_suffix = boehm
libmono_suffix = boehm
else
mono_bin_suffix = coregc
libmono_suffix = coregc
endif
endif
if DISABLE_EXECUTABLES
@@ -146,6 +163,9 @@ mono:
if SUPPORT_SGEN
ln -sf $(mono_msvc_build_bin_dir)/mono-$(mono_bin_suffix)$(EXEEXT) ./mono-sgen.exe
endif
if SUPPORT_COREGC
ln -sf $(mono_msvc_build_bin_dir)/mono-$(mono_bin_suffix)$(EXEEXT) ./mono-coregc.exe
endif
mono.exe: mono
@@ -168,9 +188,9 @@ if !ENABLE_MSVC_ONLY
if DISABLE_EXECUTABLES
else
if HOST_WIN32
bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries) monow
bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries) $(coregc_binaries) monow
else
bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries)
bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries) $(coregc_binaries)
endif
endif
@@ -181,10 +201,10 @@ noinst_PROGRAMS = mono
endif
if DISABLE_EXECUTABLES
shared_libraries = $(boehm_libraries) $(sgen_libraries)
shared_libraries = $(boehm_libraries) $(sgen_libraries) $(coregc_libraries)
else
if SHARED_MONO
shared_libraries = $(boehm_libraries) $(sgen_libraries)
shared_libraries = $(boehm_libraries) $(sgen_libraries) $(coregc_libraries)
endif
endif
@@ -208,6 +228,9 @@ libmain_a_SOURCES = main-sgen.c
if SUPPORT_BOEHM
libmain_a_SOURCES += main.c
endif
if SUPPORT_COREGC
libmain_a_SOURCES += main-coregc.c
endif
libmain_a_CFLAGS = $(AM_CFLAGS) @CXX_ADD_CFLAGS@
if LOADED_LLVM
@@ -232,6 +255,9 @@ AM_CPPFLAGS = $(LIBGC_CPPFLAGS)
mono_sgen_SOURCES =
mono_sgen_CFLAGS = $(AM_CFLAGS) @CXX_REMOVE_CFLAGS@
mono_coregc_SOURCES =
mono_coregc_CFLAGS = $(AM_CFLAGS) @CXX_REMOVE_CFLAGS@
# We build this after libmono was built so it contains the date when the final
# link was done
if SUPPORT_BOEHM
@@ -245,6 +271,11 @@ buildver-sgen.h: libmini.la $(monodir)/mono/metadata/libmonoruntimesgen.la $(mon
libmain_a-main-sgen.$(OBJEXT): buildver-sgen.h
buildver-coregc.h: libmini.la $(monodir)/mono/metadata/libmonoruntimecoregc.la $(monodir)/mono/coregc/libmonocoregc.la
@echo "const char *build_date = \"`date`\";" > buildver-coregc.h
libmain_a-main-coregc.$(OBJEXT): buildver-coregc.h
if DTRACE_G_REQUIRED
LIBMONO_DTRACE_OBJECT = .libs/mono-dtrace.$(OBJEXT)
if STATIC_MONO
@@ -262,9 +293,11 @@ if STATIC_MONO
# This leads to higher performance, especially with TLS
MONO_LIB=$(boehm_static_libraries)
MONO_SGEN_LIB=$(sgen_static_libraries)
MONO_COREGC_LIB=$(coregc_static_libraries)
else
MONO_LIB=libmonoboehm-2.0.la
MONO_SGEN_LIB=libmonosgen-2.0.la
MONO_COREGC_LIB=libmonocoregc-2.0.la
endif
if LOADED_LLVM
@@ -299,8 +332,22 @@ mono_sgen_LDADD = \
mono_sgen_LDFLAGS = $(static_flags) $(monobinldflags) $(monobin_platform_ldflags)
mono_coregc_LDADD = \
libmain_a-main-coregc.$(OBJEXT) \
$(MONO_COREGC_LIB) \
$(glib_libs) \
$(LLVMMONOF) \
$(LIBICONV) \
$(Z_LIBS) \
-lm \
$(MONO_DTRACE_OBJECT)
mono_coregc_LDFLAGS = $(static_flags) $(monobinldflags) $(monobin_platform_ldflags)
if ENABLE_STATIC_GCC_LIBS
mono_sgen_LDFLAGS += -all-static
mono_coregc_LDFLAGS += -all-static
endif
if BITCODE
@@ -779,6 +826,12 @@ libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS) @CXX_ADD_CFLAGS@
libmonosgen_2_0_la_LIBADD = libmini.la $(interp_libs_with_mini) $(dbg_libs_with_mini) $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
libmonosgen_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags)
libmonocoregc_2_0_la_SOURCES =
libmonocoregc_2_0_la_CFLAGS = $(mono_coregc_CFLAGS) @CXX_ADD_CFLAGS@
libmonocoregc_2_0_la_LIBADD = libmini.la $(interp_libs_with_mini) $(dbg_libs_with_mini) $(coregc_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
libmonocoregc_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags)
endif # !ENABLE_MSVC_ONLY
libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
+1 -1
View File
@@ -203,7 +203,7 @@ typedef struct {
* A weakref gc handle pointing to the object. The gc handle is used to
* detect if the object was garbage collected.
*/
guint32 handle;
gpointer handle;
} ObjRef;
+1 -1
View File
@@ -198,7 +198,7 @@ typedef struct {
/* Clause that we are resuming to */
MonoJitExceptionInfo *handler_ei;
/* Exception that is being thrown. Set with rest of resume state */
guint32 exc_gchandle;
gpointer exc_gchandle;
} ThreadContext;
typedef struct {
+5
View File
@@ -0,0 +1,5 @@
#include "buildver-coregc.h"
#define BUILDVER_INCLUDED
#include "main.c"
+3 -3
View File
@@ -2171,12 +2171,12 @@ setup_stack_trace (MonoException *mono_ex, GSList **dynamic_methods, GList *trac
MonoMList *list = (MonoMList*)mono_ex->dynamic_methods;
for (l = *dynamic_methods; l; l = l->next) {
guint32 dis_link;
gpointer dis_link;
MonoDomain *domain = mono_domain_get ();
if (domain->method_to_dyn_method) {
mono_domain_lock (domain);
dis_link = (guint32)(size_t)g_hash_table_lookup (domain->method_to_dyn_method, l->data);
dis_link = g_hash_table_lookup (domain->method_to_dyn_method, l->data);
mono_domain_unlock (domain);
if (dis_link) {
MonoObject *o = mono_gchandle_get_target_internal (dis_link);
@@ -2811,7 +2811,7 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
}
if (method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED && ftnptr_eh_callback) {
guint32 handle = mono_gchandle_new_internal (obj, FALSE);
gpointer handle = mono_gchandle_new_internal (obj, FALSE);
MONO_STACKDATA (stackptr);
mono_threads_enter_gc_safe_region_unbalanced_internal (&stackptr);
+3 -3
View File
@@ -111,12 +111,12 @@ struct MonoJitTlsData {
/*
* The current exception in flight
*/
guint32 thrown_exc;
gpointer thrown_exc;
/*
* If the current exception is not a subclass of Exception,
* the original exception.
*/
guint32 thrown_non_exc;
gpointer thrown_non_exc;
/*
* The calling assembly in llvmonly mode.
@@ -160,7 +160,7 @@ typedef struct {
#endif
} MonoLMFExt;
typedef void (*MonoFtnPtrEHCallback) (guint32 gchandle);
typedef void (*MonoFtnPtrEHCallback) (gpointer gchandle);
typedef struct MonoDebugOptions {
gboolean handle_sigint;
+6 -2
View File
@@ -22,6 +22,8 @@
#include "mono/sgen/sgen-conf.h"
#endif
G_BEGIN_DECLS
/* h indicates whether to hide or just tag.
* (-!!h ^ p) is used instead of (h ? ~p : p) to avoid multiple mentions of p.
*/
@@ -85,9 +87,9 @@ typedef void* MonoGCDescriptor;
gboolean mono_gc_parse_environment_string_extract_number (const char *str, size_t *out);
MonoGCDescriptor mono_gc_make_descr_for_object (gsize *bitmap, int numbits, size_t obj_size)
MonoGCDescriptor mono_gc_make_descr_for_object (gpointer klass, gsize *bitmap, int numbits, size_t obj_size, GPtrArray **gc_descr_full)
MONO_PERMIT (need (sgen_lock_gc));
MonoGCDescriptor mono_gc_make_descr_for_array (int vector, gsize *elem_bitmap, int numbits, size_t elem_size)
MonoGCDescriptor mono_gc_make_descr_for_array (int vector, gsize *elem_bitmap, int numbits, size_t elem_size, GPtrArray **gc_descr_full)
MONO_PERMIT (need (sgen_lock_gc));
/* simple interface for data structures needed in the runtime */
@@ -120,4 +122,6 @@ void mono_gc_params_set (const char* options);
/* equivalent to options set via MONO_GC_DEBUG */
void mono_gc_debug_set (const char* options);
G_END_DECLS
#endif
+2 -2
View File
@@ -113,7 +113,7 @@ sgen_get_complex_descriptor (SgenDescriptor desc)
* Descriptor builders.
*/
SgenDescriptor
mono_gc_make_descr_for_object (gsize *bitmap, int numbits, size_t obj_size)
mono_gc_make_descr_for_object (gpointer klass, gsize *bitmap, int numbits, size_t obj_size, GPtrArray **gc_descr_full)
{
int first_set = -1, num_set = 0, last_set = -1, i;
SgenDescriptor desc = 0;
@@ -165,7 +165,7 @@ mono_gc_make_descr_for_object (gsize *bitmap, int numbits, size_t obj_size)
/* If the array holds references, numbits == 1 and the first bit is set in elem_bitmap */
SgenDescriptor
mono_gc_make_descr_for_array (int vector, gsize *elem_bitmap, int numbits, size_t elem_size)
mono_gc_make_descr_for_array (int vector, gsize *elem_bitmap, int numbits, size_t elem_size, GPtrArray **gc_descr_full)
{
int first_set = -1, num_set = 0, last_set = -1, i;
SgenDescriptor desc = DESC_TYPE_VECTOR | (vector ? VECTOR_KIND_SZARRAY : VECTOR_KIND_ARRAY);
+5
View File
@@ -11,6 +11,9 @@
#define __MONO_UTILS_MEMFUNCS_H__
#include <stdlib.h>
#include <glib.h>
G_BEGIN_DECLS
/*
These functions must be used when it's possible that either destination is not
@@ -21,4 +24,6 @@ void mono_gc_bzero_aligned (void *dest, size_t size);
void mono_gc_memmove_atomic (void *dest, const void *src, size_t size);
void mono_gc_memmove_aligned (void *dest, const void *src, size_t size);
G_END_DECLS
#endif
+1 -1
View File
@@ -32,7 +32,7 @@ typedef union _MonoErrorInternal {
/* Valid if error_code == MONO_ERROR_EXCEPTION_INSTANCE.
* Generic error specified by a managed instance.
*/
uint32_t instance_handle;
gpointer instance_handle;
} exn;
const char *full_message;
const char *full_message_with_fields;
+6
View File
@@ -14,6 +14,9 @@
#include <glib.h>
#include <mono/utils/mono-publib.h>
#include <mono/utils/mono-compiler.h>
#include "mono-publib.h"
MONO_BEGIN_DECLS
/*
>>>> WARNING WARNING WARNING <<<<
@@ -166,4 +169,7 @@ mono_thread_set_coop_aware (void);
MONO_API MONO_RT_EXTERNAL_ONLY mono_bool
mono_thread_get_coop_aware (void);
MONO_END_DECLS
#endif /* __MONO_LOGGER_H__ */
+5 -6
View File
@@ -464,7 +464,7 @@ register_thread (MonoThreadInfo *info)
info->stack_end = staddr + stsize;
info->stackdata = g_byte_array_new ();
info->internal_thread_gchandle = G_MAXUINT32;
info->internal_thread_gchandle = NULL;
info->profiler_signal_ack = 1;
@@ -739,12 +739,12 @@ mono_thread_info_detach (void)
}
gboolean
mono_thread_info_try_get_internal_thread_gchandle (MonoThreadInfo *info, guint32 *gchandle)
mono_thread_info_try_get_internal_thread_gchandle (MonoThreadInfo *info, gpointer *gchandle)
{
g_assertf (info, ""); // f includes __func__
g_assert (mono_thread_info_is_current (info));
if (info->internal_thread_gchandle == G_MAXUINT32)
if (info->internal_thread_gchandle == NULL)
return FALSE;
*gchandle = info->internal_thread_gchandle;
@@ -752,11 +752,10 @@ mono_thread_info_try_get_internal_thread_gchandle (MonoThreadInfo *info, guint32
}
void
mono_thread_info_set_internal_thread_gchandle (MonoThreadInfo *info, guint32 gchandle)
mono_thread_info_set_internal_thread_gchandle (MonoThreadInfo *info, gpointer gchandle)
{
g_assertf (info, ""); // f includes __func__
g_assert (mono_thread_info_is_current (info));
g_assert (gchandle != G_MAXUINT32);
info->internal_thread_gchandle = gchandle;
}
@@ -765,7 +764,7 @@ mono_thread_info_unset_internal_thread_gchandle (THREAD_INFO_TYPE *info)
{
g_assertf (info, ""); // f includes __func__
g_assert (mono_thread_info_is_current (info));
info->internal_thread_gchandle = G_MAXUINT32;
info->internal_thread_gchandle = NULL;
}
/*
+23 -28
View File
@@ -23,6 +23,7 @@
#include <mono/utils/refcount.h>
#include <mono/utils/mono-error-internals.h>
#include "mono-publib.h"
#include <glib.h>
#include <config.h>
#ifdef HOST_WIN32
@@ -57,6 +58,8 @@ typedef pid_t MonoNativeThreadHandle;
#endif /* defined(__MACH__) */
MONO_BEGIN_DECLS
typedef pthread_t MonoNativeThreadId;
typedef void* mono_native_thread_return_t;
@@ -267,7 +270,7 @@ typedef struct _MonoThreadInfo {
gpointer stack_mark;
/* GCHandle to MonoInternalThread */
guint32 internal_thread_gchandle;
gpointer internal_thread_gchandle;
/*
* Used by the sampling code in mini-posix.c to ensure that a thread has
@@ -396,9 +399,9 @@ mono_thread_info_cleanup (void);
/*
* @thread_info_size is sizeof (GcThreadInfo), a struct the GC defines to make it possible to have
* a single block with info from both camps.
* a single block with info from both camps.
*/
void
G_EXTERN_C void
mono_thread_info_init (size_t thread_info_size);
/*
@@ -430,10 +433,10 @@ MONO_API void
mono_thread_info_detach (void);
gboolean
mono_thread_info_try_get_internal_thread_gchandle (THREAD_INFO_TYPE *info, guint32 *gchandle);
mono_thread_info_try_get_internal_thread_gchandle (THREAD_INFO_TYPE *info, gpointer *gchandle);
void
mono_thread_info_set_internal_thread_gchandle (THREAD_INFO_TYPE *info, guint32 gchandle);
mono_thread_info_set_internal_thread_gchandle (THREAD_INFO_TYPE *info, gpointer gchandle);
void
mono_thread_info_unset_internal_thread_gchandle (THREAD_INFO_TYPE *info);
@@ -441,9 +444,6 @@ mono_thread_info_unset_internal_thread_gchandle (THREAD_INFO_TYPE *info);
gboolean
mono_thread_info_is_exiting (void);
#ifdef HOST_WIN32
G_EXTERN_C // due to THREAD_INFO_TYPE varying
#endif
THREAD_INFO_TYPE *
mono_thread_info_current (void);
@@ -535,7 +535,6 @@ mono_thread_info_is_interrupt_state (THREAD_INFO_TYPE *info);
void
mono_thread_info_describe_interrupt_token (THREAD_INFO_TYPE *info, GString *text);
G_EXTERN_C // due to THREAD_INFO_TYPE varying
gboolean
mono_thread_info_is_live (THREAD_INFO_TYPE *info);
@@ -554,6 +553,7 @@ mono_threads_open_native_thread_handle (MonoNativeThreadHandle handle);
void
mono_threads_close_native_thread_handle (MonoNativeThreadHandle handle);
#if !defined(HOST_WIN32)
/*Use this instead of pthread_kill */
@@ -634,8 +634,8 @@ mono_native_thread_id_get (void);
/*
* This does _not_ return the same value as mono_native_thread_id_get, except on Windows.
* On POSIX, mono_native_thread_id_get returns the value from pthread_self, which is then
* passed around as an identifier to other pthread functions. However this function, where
* possible, returns the OS-unique thread id value, fetched in a platform-specific manner.
* passed around as an identifier to other pthread functions. However this function, where
* possible, returns the OS-unique thread id value, fetched in a platform-specific manner.
* It will not work with the various pthread functions, should never be used as a
* MonoNativeThreadId, and is intended solely to match the output of various diagonistic tools.
*/
@@ -651,15 +651,6 @@ mono_native_thread_id_equals (MonoNativeThreadId id1, MonoNativeThreadId id2);
MONO_API gboolean
mono_native_thread_create (MonoNativeThreadId *tid, gpointer func, gpointer arg);
#ifdef __cplusplus
template <typename T>
inline gboolean
mono_native_thread_create (MonoNativeThreadId *tid, T func, gpointer arg)
{
return mono_native_thread_create (tid, (gpointer)func, arg);
}
#endif
MONO_API void
mono_native_thread_set_name (MonoNativeThreadId tid, const char *name);
@@ -748,7 +739,6 @@ gboolean mono_threads_transition_peek_blocking_suspend_requested (THREAD_INFO_TY
void mono_threads_transition_begin_no_safepoints (THREAD_INFO_TYPE* info, const char *func);
void mono_threads_transition_end_no_safepoints (THREAD_INFO_TYPE* info, const char *func);
G_EXTERN_C // due to THREAD_INFO_TYPE varying
MonoThreadUnwindState* mono_thread_info_get_suspend_state (THREAD_INFO_TYPE *info);
gpointer
@@ -757,15 +747,12 @@ mono_threads_enter_gc_unsafe_region_cookie (void);
void mono_thread_info_wait_for_resume (THREAD_INFO_TYPE *info);
/* Advanced suspend API, used for suspending multiple threads as once. */
G_EXTERN_C // due to THREAD_INFO_TYPE varying
gboolean mono_thread_info_is_running (THREAD_INFO_TYPE *info);
gboolean mono_thread_info_is_live (THREAD_INFO_TYPE *info);
G_EXTERN_C // due to THREAD_INFO_TYPE varying
int mono_thread_info_suspend_count (THREAD_INFO_TYPE *info);
int mono_thread_info_current_state (THREAD_INFO_TYPE *info);
const char* mono_thread_state_name (int state);
gboolean mono_thread_is_gc_unsafe_mode (void);
G_EXTERN_C // due to THREAD_INFO_TYPE varying
gboolean mono_thread_info_will_not_safepoint (THREAD_INFO_TYPE *info);
/* Suspend phases:
@@ -797,13 +784,9 @@ typedef enum {
MONO_THREAD_BEGIN_SUSPEND_NEXT_PHASE = 2,
} MonoThreadBeginSuspendResult;
G_EXTERN_C // due to THREAD_INFO_TYPE varying
gboolean mono_thread_info_in_critical_location (THREAD_INFO_TYPE *info);
G_EXTERN_C // due to THREAD_INFO_TYPE varying
MonoThreadBeginSuspendResult mono_thread_info_begin_suspend (THREAD_INFO_TYPE *info, MonoThreadSuspendPhase phase);
G_EXTERN_C // due to THREAD_INFO_TYPE varying
gboolean mono_thread_info_begin_resume (THREAD_INFO_TYPE *info);
G_EXTERN_C // due to THREAD_INFO_TYPE varying
gboolean mono_thread_info_begin_pulse_resume_and_request_suspension (THREAD_INFO_TYPE *info);
@@ -857,6 +840,7 @@ mono_win32_interrupt_wait (PVOID thread_info, HANDLE native_thread_handle, DWORD
void
mono_win32_abort_blocking_io_call (THREAD_INFO_TYPE *info);
#define W32_DEFINE_LAST_ERROR_RESTORE_POINT \
const DWORD _last_error_restore_point = GetLastError ();
@@ -872,4 +856,15 @@ mono_win32_abort_blocking_io_call (THREAD_INFO_TYPE *info);
#endif
MONO_END_DECLS
#ifdef __cplusplus
template <typename T>
inline gboolean
mono_native_thread_create (MonoNativeThreadId *tid, T func, gpointer arg)
{
return mono_native_thread_create (tid, (gpointer)func, arg);
}
#endif
#endif /* __MONO_THREADS_H__ */
+4
View File
@@ -11,6 +11,10 @@
#include <glib.h>
#include <stdlib.h>
G_BEGIN_DECLS
gboolean mono_gc_parse_environment_string_extract_number (const char *str, size_t *out);
G_END_DECLS
#endif