[sgen] Move thread info to Mono client code.
[mono.git] / mono / metadata / sgen-client-mono.h
index b29b663db790d5bd53427e4030dccad74f0dde22..2b04ceab650f170855e59f7609f13f6cac6311d8 100644 (file)
 
 #ifdef SGEN_DEFINE_OBJECT_VTABLE
 
+#include "metadata/sgen-archdep.h"
 #include "utils/mono-threads.h"
 #include "utils/mono-mmap.h"
+#include "metadata/object-internals.h"
 
 typedef MonoObject GCObject;
 typedef MonoVTable GCVTable;
@@ -97,6 +99,12 @@ sgen_client_par_object_get_size (GCVTable *vtable, GCObject* o)
        return sgen_client_slow_object_get_size (vtable, o);
 }
 
+static inline size_t
+sgen_client_vtable_get_instance_size (MonoVTable *vtable)
+{
+       return vtable->klass->instance_size;
+}
+
 typedef struct _SgenClientThreadInfo SgenClientThreadInfo;
 struct _SgenClientThreadInfo {
        MonoThreadInfo info;
@@ -140,6 +148,9 @@ struct _SgenClientThreadInfo {
 #include "utils/dtrace.h"
 #include "utils/mono-counters.h"
 #include "utils/mono-logger-internal.h"
+#include "utils/mono-time.h"
+#include "utils/mono-semaphore.h"
+#include "metadata/sgen-bridge-internal.h"
 
 extern void mono_sgen_register_moved_object (void *obj, void *destination);
 extern void mono_sgen_gc_event_moves (void);
@@ -245,6 +256,48 @@ sgen_client_object_has_critical_finalizer (GCObject *obj)
 const char* sgen_client_vtable_get_namespace (GCVTable *vtable);
 const char* sgen_client_vtable_get_name (GCVTable *vtable);
 
+static gboolean G_GNUC_UNUSED
+sgen_client_bridge_need_processing (void)
+{
+       return sgen_need_bridge_processing ();
+}
+
+static void G_GNUC_UNUSED
+sgen_client_bridge_reset_data (void)
+{
+       sgen_bridge_reset_data ();
+}
+
+static void G_GNUC_UNUSED
+sgen_client_bridge_processing_stw_step (void)
+{
+       sgen_bridge_processing_stw_step ();
+}
+
+static void G_GNUC_UNUSED
+sgen_client_bridge_wait_for_processing (void)
+{
+       mono_gc_wait_for_bridge_processing ();
+}
+
+static void G_GNUC_UNUSED
+sgen_client_bridge_processing_finish (int generation)
+{
+       sgen_bridge_processing_finish (generation);
+}
+
+static gboolean G_GNUC_UNUSED
+sgen_client_bridge_is_bridge_object (GCObject *obj)
+{
+       return sgen_is_bridge_object (obj);
+}
+
+static void G_GNUC_UNUSED
+sgen_client_bridge_register_finalized_object (GCObject *object)
+{
+       sgen_bridge_register_finalized_object (object);
+}
+
 static void G_GNUC_UNUSED
 sgen_client_binary_protocol_collection_requested (int generation, size_t requested_size, gboolean force)
 {
@@ -257,6 +310,13 @@ sgen_client_binary_protocol_collection_begin (int minor_gc_count, int generation
        MONO_GC_BEGIN (generation);
 
        mono_profiler_gc_event (MONO_GC_EVENT_START, generation);
+
+#ifndef DISABLE_PERFCOUNTERS
+       if (generation == GENERATION_NURSERY)
+               mono_perfcounters->gc_collections0++;
+       else
+               mono_perfcounters->gc_collections1++;
+#endif
 }
 
 static void G_GNUC_UNUSED
@@ -510,9 +570,11 @@ gboolean sgen_resume_thread (SgenThreadInfo *info);
 void sgen_wait_for_suspend_ack (int count);
 
 #ifdef HAVE_KW_THREAD
+extern __thread SgenThreadInfo *sgen_thread_info;
 #define TLAB_ACCESS_INIT
 #define IN_CRITICAL_REGION sgen_thread_info->client_info.in_critical_region
 #else
+extern MonoNativeTlsKey thread_info_key;
 #define TLAB_ACCESS_INIT       SgenThreadInfo *__thread_info__ = mono_native_tls_get_value (thread_info_key)
 #define IN_CRITICAL_REGION (__thread_info__->client_info.in_critical_region)
 #endif
@@ -535,4 +597,14 @@ void sgen_wait_for_suspend_ack (int count);
 
 #endif
 
+#define SGEN_TV_DECLARE(name) gint64 name
+#define SGEN_TV_GETTIME(tv) tv = mono_100ns_ticks ()
+#define SGEN_TV_ELAPSED(start,end) (int)((end-start))
+
+typedef MonoSemType SgenSemaphore;
+
+#define SGEN_SEMAPHORE_INIT(sem,initial)       MONO_SEM_INIT ((sem), (initial))
+#define SGEN_SEMAPHORE_POST(sem)               MONO_SEM_POST ((sem))
+#define SGEN_SEMAPHORE_WAIT(sem)               MONO_SEM_WAIT ((sem))
+
 #endif