Permalink
Browse files

Merge remote-tracking branch 'joncham/sgen-msvc2'

Conflicts:
	mono/metadata/sgen-copy-object.h
	mono/metadata/sgen-gc.c
  • Loading branch information...
2 parents 99c3107 + 30951a5 commit d0baa99bcb8ef12231e24432d0b5710b3a0a4380 @kumpera kumpera committed Oct 10, 2012
@@ -28,7 +28,7 @@
#include <mono/utils/mono-sigcontext.h>
-#ifdef __i386__
+#if defined(__i386__) || defined(TARGET_X86)
#include <mono/utils/mono-context.h>
@@ -39,6 +39,18 @@
#ifdef MONO_ARCH_HAS_MONO_CONTEXT
#define USE_MONO_CTX
#else
+#ifdef _MSC_VER
+#define ARCH_STORE_REGS(ptr) __asm { \
+ __asm mov [ptr], edi \
+ __asm mov [ptr+4], esi \
+ __asm mov [ptr+8], ebx \
+ __asm mov [ptr+12], edx \
+ __asm mov [ptr+16], ecx \
+ __asm mov [ptr+20], eax \
+ __asm mov [ptr+24], ebp \
+ __asm mov [ptr+28], esp \
+ }
+#else
#define ARCH_STORE_REGS(ptr) \
__asm__ __volatile__( \
"mov %%edi,0(%0)\n" \
@@ -53,12 +65,13 @@
: "r" (ptr) \
)
#endif
+#endif
/*FIXME, move this to mono-sigcontext as this is generaly useful.*/
#define ARCH_SIGCTX_SP(ctx) (UCONTEXT_REG_ESP ((ctx)))
#define ARCH_SIGCTX_IP(ctx) (UCONTEXT_REG_EIP ((ctx)))
-#elif defined(__x86_64__)
+#elif defined(__x86_64__) || defined(TARGET_AMD64)
#include <mono/utils/mono-context.h>
@@ -44,7 +44,9 @@
//#define CARDTABLE_STATS
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
@@ -37,7 +37,9 @@ extern long long stat_slots_allocated_in_vain;
static inline void
par_copy_object_no_checks (char *destination, MonoVTable *vt, void *obj, mword objsize, SgenGrayQueue *queue)
{
+#ifdef __GNUC__
static const void *copy_labels [] = { &&LAB_0, &&LAB_1, &&LAB_2, &&LAB_3, &&LAB_4, &&LAB_5, &&LAB_6, &&LAB_7, &&LAB_8 };
+#endif
DEBUG (9, g_assert (vt->klass->inited));
DEBUG (9, fprintf (gc_debug_file, " (to %p, %s size: %lu)\n", destination, ((MonoObject*)obj)->vtable->klass->name, (unsigned long)objsize));
@@ -49,6 +51,7 @@ par_copy_object_no_checks (char *destination, MonoVTable *vt, void *obj, mword o
MONO_GC_OBJ_MOVED ((mword)destination, (mword)obj, dest_gen, src_gen, objsize, vt->klass->name_space, vt->klass->name);
}
+#ifdef __GNUC__
if (objsize <= sizeof (gpointer) * 8) {
mword *dest = (mword*)destination;
goto *copy_labels [objsize / sizeof (gpointer)];
@@ -74,6 +77,9 @@ par_copy_object_no_checks (char *destination, MonoVTable *vt, void *obj, mword o
/*can't trust memcpy doing word copies */
mono_gc_memmove (destination + sizeof (mword), (char*)obj + sizeof (mword), objsize - sizeof (mword));
}
+#else
+ mono_gc_memmove (destination + sizeof (mword), (char*)obj + sizeof (mword), objsize - sizeof (mword));
+#endif
/* adjust array->bounds */
DEBUG (9, g_assert (vt->gc_descr));
if (G_UNLIKELY (vt->rank && ((MonoArray*)obj)->bounds)) {
@@ -90,7 +96,11 @@ par_copy_object_no_checks (char *destination, MonoVTable *vt, void *obj, mword o
}
}
+#ifdef _MSC_VER
+static __declspec(noinline) void*
+#else
static G_GNUC_UNUSED void* __attribute__((noinline))
+#endif
copy_object_no_checks (void *obj, SgenGrayQueue *queue)
{
MonoVTable *vt = ((MonoObject*)obj)->vtable;
@@ -150,7 +160,11 @@ extern long long stat_nursery_copy_object_failed_to_space; /* from sgen-gc.c */
* copy_object could be made into a macro once debugged (use inline for now).
*/
+#ifdef _MSC_VER
+static __forceinline void
+#else
static inline void __attribute__((always_inline))
+#endif
serial_copy_object (void **obj_slot, SgenGrayQueue *queue)
{
char *forwarded;
View
@@ -3434,7 +3434,7 @@ update_current_thread_stack (void *start)
{
int stack_guard = 0;
#ifndef USE_MONO_CTX
- void *ptr = cur_thread_regs;
+ void *reg_ptr = cur_thread_regs;
#endif
SgenThreadInfo *info = mono_thread_info_current ();
@@ -3446,8 +3446,8 @@ update_current_thread_stack (void *start)
if (gc_callbacks.thread_suspend_func)
gc_callbacks.thread_suspend_func (info->runtime_data, NULL, info->monoctx);
#else
- ARCH_STORE_REGS (ptr);
- info->stopped_regs = ptr;
+ ARCH_STORE_REGS (reg_ptr);
+ info->stopped_regs = reg_ptr;
if (gc_callbacks.thread_suspend_func)
gc_callbacks.thread_suspend_func (info->runtime_data, NULL, NULL);
#endif
@@ -1597,7 +1597,7 @@ count_pinned_callback (char *obj, size_t size, void *data)
++count_pinned_nonref;
}
-static void __attribute__ ((unused))
+static G_GNUC_UNUSED void
count_ref_nonref_objs (void)
{
int total;
@@ -2,7 +2,7 @@
#if defined(HAVE_SGEN_GC) && defined(HOST_WIN32)
-#include <windows.h>
+#include "io-layer/io-layer.h"
#include "metadata/sgen-gc.h"
#include "metadata/gc-internal.h"
@@ -374,7 +374,7 @@ alloc_from_active_or_partial (MonoLockFreeAllocator *heap)
do {
unsigned int next;
- new_anchor = old_anchor = (Anchor)*(volatile gint32*)&desc->anchor.value;
+ new_anchor = old_anchor = *(volatile Anchor*)&desc->anchor.value;
if (old_anchor.data.state == STATE_EMPTY) {
/* We must free it because we own it. */
desc_retire (desc);
@@ -477,7 +477,7 @@ mono_lock_free_free (gpointer ptr)
g_assert (SB_HEADER_FOR_ADDR (ptr) == SB_HEADER_FOR_ADDR (sb));
do {
- new_anchor = old_anchor = (Anchor)*(volatile gint32*)&desc->anchor.value;
+ new_anchor = old_anchor = *(volatile Anchor*)&desc->anchor.value;
*(unsigned int*)ptr = old_anchor.data.avail;
new_anchor.data.avail = ((char*)ptr - (char*)sb) / desc->slot_size;
g_assert (new_anchor.data.avail < SB_USABLE_SIZE / desc->slot_size);
@@ -531,7 +531,11 @@ descriptor_check_consistency (Descriptor *desc, gboolean print)
{
int count = desc->anchor.data.count;
int max_count = SB_USABLE_SIZE / desc->slot_size;
+#if _MSC_VER
+ gboolean* linked = alloca(max_count*sizeof(gboolean));
+#else
gboolean linked [max_count];
+#endif
int i, last;
unsigned int index;
@@ -62,11 +62,11 @@ get_hazardous_pointer_with_mask (gpointer volatile *pp, MonoThreadHazardPointers
/*
Requires the world to be stoped
*/
-#define MONO_LLS_FOREACH(list, element) {\
+#define MONO_LLS_FOREACH(list, element, type) {\
MonoLinkedListSetNode *__cur; \
for (__cur = (list)->head; __cur; __cur = mono_lls_pointer_unmask (__cur->next)) \
if (!mono_lls_pointer_get_mark (__cur->next)) { \
- (element) = (typeof((element)))__cur; \
+ (element) = (type)__cur; \
#define MONO_LLS_END_FOREACH }}
@@ -81,15 +81,15 @@ mono_lls_info_step (MonoLinkedListSetNode *val, MonoThreadHazardPointers *hp)
/*
Provides snapshot iteration
*/
-#define MONO_LLS_FOREACH_SAFE(list, element) {\
+#define MONO_LLS_FOREACH_SAFE(list, element, type) {\
MonoThreadHazardPointers *__hp = mono_hazard_pointer_get (); \
MonoLinkedListSetNode *__cur, *__next; \
for (__cur = mono_lls_pointer_unmask (get_hazardous_pointer ((gpointer volatile*)&(list)->head, __hp, 1)); \
__cur; \
__cur = mono_lls_info_step (__next, __hp)) { \
__next = get_hazardous_pointer_with_mask ((gpointer volatile*)&__cur->next, __hp, 0); \
if (!mono_lls_pointer_get_mark (__next)) { \
- (element) = (typeof((element)))__cur;
+ (element) = (type)__cur;
#define MONO_LLS_END_FOREACH_SAFE \
} \
@@ -163,9 +163,9 @@ Acquire/release semantics macros.
LOAD_ACQUIRE_FENCE; \
__tmp; })
-#define mono_atomic_store_acquire(target,value) ({ \
+#define mono_atomic_store_acquire(target,value) { \
*target = value; \
STORE_ACQUIRE_FENCE; \
- })
+ }
#endif /* _MONO_UTILS_MONO_MEMMODEL_H_ */
@@ -142,13 +142,13 @@ typedef struct {
/*
Requires the world to be stoped
*/
-#define FOREACH_THREAD(thread) MONO_LLS_FOREACH (mono_thread_info_list_head (), thread)
+#define FOREACH_THREAD(thread) MONO_LLS_FOREACH (mono_thread_info_list_head (), thread, SgenThreadInfo*)
#define END_FOREACH_THREAD MONO_LLS_END_FOREACH
/*
Snapshot iteration.
*/
-#define FOREACH_THREAD_SAFE(thread) MONO_LLS_FOREACH_SAFE (mono_thread_info_list_head (), thread)
+#define FOREACH_THREAD_SAFE(thread) MONO_LLS_FOREACH_SAFE (mono_thread_info_list_head (), thread, SgenThreadInfo*)
#define END_FOREACH_THREAD_SAFE MONO_LLS_END_FOREACH_SAFE
#define mono_thread_info_get_tid(info) ((MonoNativeThreadId)((MonoThreadInfo*)info)->node.key)
View
@@ -320,9 +320,9 @@
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Link>
- <AdditionalDependencies>libgc.lib;libmonoruntime.lib;libmonoutils.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libgc.lib;libmonoruntimesgen.lib;libmonoutils.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>mono.def</ModuleDefinitionFile>
+ <ModuleDefinitionFile>monosgen.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
@@ -409,7 +409,7 @@
<Link>
<AdditionalDependencies>libgc.lib;libmonoruntime.lib;libmonoutils.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>mono.def</ModuleDefinitionFile>
+ <ModuleDefinitionFile>monosgen.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ImportLibrary>$(Platform)\lib\$(TargetName).lib</ImportLibrary>
<TargetMachine>MachineX64</TargetMachine>
@@ -479,9 +479,9 @@
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Link>
- <AdditionalDependencies>libgc.lib;libmonoruntime.lib;libmonoutils.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libgc.lib;libmonoruntimesgen.lib;libmonoutils.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>mono.def</ModuleDefinitionFile>
+ <ModuleDefinitionFile>monosgen.def</ModuleDefinitionFile>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
@@ -560,7 +560,7 @@
<Link>
<AdditionalDependencies>libgc.lib;libmonoruntime.lib;libmonoutils.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>mono.def</ModuleDefinitionFile>
+ <ModuleDefinitionFile>monosgen.def</ModuleDefinitionFile>
<ImportLibrary>$(Platform)\lib\$(TargetName).lib</ImportLibrary>
<TargetMachine>MachineX64</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -101,6 +101,7 @@
<ClCompile Include="..\mono\metadata\sgen-marksweep-fixed.c" />
<ClCompile Include="..\mono\metadata\sgen-marksweep-par.c" />
<ClCompile Include="..\mono\metadata\sgen-marksweep.c" />
+ <ClCompile Include="..\mono\metadata\sgen-memory-governor.c" />
<ClCompile Include="..\mono\metadata\sgen-nursery-allocator.c" />
<ClCompile Include="..\mono\metadata\sgen-os-mach.c" />
<ClCompile Include="..\mono\metadata\sgen-os-posix.c" />
@@ -109,6 +110,9 @@
<ClCompile Include="..\mono\metadata\sgen-pinning-stats.c" />
<ClCompile Include="..\mono\metadata\sgen-pinning.c" />
<ClCompile Include="..\mono\metadata\sgen-protocol.c" />
+ <ClCompile Include="..\mono\metadata\sgen-simple-nursery.c" />
+ <ClCompile Include="..\mono\metadata\sgen-split-nursery.c" />
+ <ClCompile Include="..\mono\metadata\sgen-ssb.c" />
<ClCompile Include="..\mono\metadata\sgen-toggleref.c" />
<ClCompile Include="..\mono\metadata\sgen-workers.c" />
<ClCompile Include="..\mono\metadata\socket-io.c" />
@@ -182,14 +186,19 @@
<ClInclude Include="..\mono\metadata\sgen-bridge.h" />
<ClInclude Include="..\mono\metadata\sgen-cardtable.h" />
<ClInclude Include="..\mono\metadata\sgen-conf.h" />
+ <ClInclude Include="..\mono\metadata\sgen-copy-object.h" />
<ClInclude Include="..\mono\metadata\sgen-descriptor.h" />
<ClInclude Include="..\mono\metadata\sgen-gc.h" />
<ClInclude Include="..\mono\metadata\sgen-gray.h" />
<ClInclude Include="..\mono\metadata\sgen-major-copy-object.h" />
<ClInclude Include="..\mono\metadata\sgen-major-scan-object.h" />
+ <ClInclude Include="..\mono\metadata\sgen-memory-governor.h" />
+ <ClInclude Include="..\mono\metadata\sgen-minor-copy-object.h" />
+ <ClInclude Include="..\mono\metadata\sgen-minor-scan-object.h" />
<ClInclude Include="..\mono\metadata\sgen-pinning.h" />
<ClInclude Include="..\mono\metadata\sgen-protocol.h" />
<ClInclude Include="..\mono\metadata\sgen-scan-object.h" />
+ <ClInclude Include="..\mono\metadata\sgen-ssb.h" />
<ClInclude Include="..\mono\metadata\sgen-toggleref.h" />
<ClInclude Include="..\mono\metadata\sgen-workers.h" />
<ClInclude Include="..\mono\metadata\socket-io.h" />
@@ -22,12 +22,7 @@
<ItemGroup>
<ClCompile Include="..\mono\utils\dlmalloc.c" />
<ClCompile Include="..\mono\utils\hazard-pointer.c" />
- <ClCompile Include="..\mono\utils\lock-free-alloc.c">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
- </ClCompile>
+ <ClCompile Include="..\mono\utils\lock-free-alloc.c" />
<ClCompile Include="..\mono\utils\lock-free-array-queue.c" />
<ClCompile Include="..\mono\utils\lock-free-queue.c" />
<ClCompile Include="..\mono\utils\mach-support-amd64.c" />
View
@@ -1,4 +1,3 @@
-
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Embedded Samples", "Embedded Samples", "{5FE09AA5-C3C9-45EA-A323-36A11B653CEC}"
@@ -102,6 +101,7 @@ Global
{B7098DFA-31E6-4006-8A15-1C9A4E925149}.Release|x64.ActiveCfg = Release|x64
{B7098DFA-31E6-4006-8A15-1C9A4E925149}.Release|x64.Build.0 = Release|x64
{CB0D9E92-293C-439C-9AC7-C5F59B6E0771}.Debug_SGen|Win32.ActiveCfg = Debug_SGen|Win32
+ {CB0D9E92-293C-439C-9AC7-C5F59B6E0771}.Debug_SGen|Win32.Build.0 = Debug_SGen|Win32
{CB0D9E92-293C-439C-9AC7-C5F59B6E0771}.Debug_SGen|x64.ActiveCfg = Debug_SGen|x64
{CB0D9E92-293C-439C-9AC7-C5F59B6E0771}.Debug_SGen|x64.Build.0 = Debug_SGen|x64
{CB0D9E92-293C-439C-9AC7-C5F59B6E0771}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -328,6 +328,7 @@ Global
{F51017F9-B7FB-4F87-B7B5-12799D965783}.Release|Win32.ActiveCfg = Release|Win32
{F51017F9-B7FB-4F87-B7B5-12799D965783}.Release|x64.ActiveCfg = Release|x64
{8FC2B0C8-51AD-49DF-851F-5D01A77A75E4}.Debug_SGen|Win32.ActiveCfg = Debug|Win32
+ {8FC2B0C8-51AD-49DF-851F-5D01A77A75E4}.Debug_SGen|Win32.Build.0 = Debug|Win32
{8FC2B0C8-51AD-49DF-851F-5D01A77A75E4}.Debug_SGen|x64.ActiveCfg = Debug|x64
{8FC2B0C8-51AD-49DF-851F-5D01A77A75E4}.Debug_SGen|x64.Build.0 = Debug|x64
{8FC2B0C8-51AD-49DF-851F-5D01A77A75E4}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -383,9 +384,9 @@ Global
{F51017F9-B7FB-4F87-B7B5-12799D965783} = {4CFD7702-60B2-4E82-BFAD-FCBB53EB4DA2}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- AMDCaPersistentConfig = Debug|Win32
- AMDCaPersistentStartup = mono
AMDCaProjectFile = C:\Users\Owner\Development\monogit\mono\msvc\CodeAnalyst\mono.caw
+ AMDCaPersistentStartup = mono
+ AMDCaPersistentConfig = Debug|Win32
EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
View
@@ -171,7 +171,7 @@
</ClCompile>
<ProjectReference />
<Link>
- <AdditionalDependencies>mono-2.0.lib;libgc.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>monosgen-2.0.lib;libgc.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
@@ -235,7 +235,7 @@
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Link>
- <AdditionalDependencies>mono-2.0.lib;libgc.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>monosgen-2.0.lib;libgc.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
@@ -286,7 +286,7 @@
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Link>
- <AdditionalDependencies>mono-2.0.lib;libgc.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>monosgen-2.0.lib;libgc.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
@@ -345,7 +345,7 @@
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Link>
- <AdditionalDependencies>mono-2.0.lib;libgc.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>monosgen-2.0.lib;libgc.lib;eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
Oops, something went wrong.

0 comments on commit d0baa99

Please sign in to comment.