Index: vm/include/open/hythread.h =================================================================== --- vm/include/open/hythread.h (revision 560419) +++ vm/include/open/hythread.h (working copy) @@ -27,6 +27,14 @@ #include #include "hycomp.h" + +#ifdef _WIN32 +# if (_MSC_VER >= 1400) +# include +# endif +#endif + + /* * Idea behind these declarations is to make some functions static inlined for * all files that include hythread_ext.h/hythread.h except one, that @@ -402,7 +410,8 @@ -#if (defined (_WIN32) && !defined (_WIN64)) +#if defined (_WIN32) + //use optimized asm monitor enter and exit helpers #define ASM_MONITOR_HELPER #endif @@ -457,11 +466,23 @@ #endif /* __cplusplus */ hy_inline hythread_t VMCALL hythread_self() { - register hythread_t t; - _asm { mov eax, fs:[0x14] - mov t, eax; - } - return t; +#ifndef _WIN64 +# if (_MSC_VER >= 1400) + // file winnt.h can't be included here + // 0x14 = offsetof(NT_TIB, ArbitraryUserPointer) + return (hythread_t) __readfsdword(0x14); +# else + register hythread_t t; + _asm { mov eax, fs:[0x14] + mov t, eax; + } + return t; +# endif +#else + // file winnt.h can't be included here + // 0x28 = offsetof(NT_TIB, ArbitraryUserPointer) + return (hythread_t) __readgsqword(0x28); +#endif } #define tm_self_tls (hythread_self()) Index: vm/include/open/hythread_ext.h =================================================================== --- vm/include/open/hythread_ext.h (revision 560419) +++ vm/include/open/hythread_ext.h (working copy) @@ -381,20 +381,11 @@ * point where safe suspension is possible. */ hy_inline void VMCALL hythread_suspend_enable() { + register hythread_t thread; assert(!hythread_is_suspend_enabled()); -#ifdef FS14_TLS_USE - // the macros could work for WIN32 - __asm { - mov eax, fs:[0x14] - dec[eax] HyThread_public.disable_count - } -#else - { - register hythread_t thread = tm_self_tls; - ((HyThread_public *)thread)->disable_count--; - } -#endif + thread = tm_self_tls; + ((HyThread_public *)thread)->disable_count--; } /** @@ -419,24 +410,8 @@ // default group only. assert(((HyThread_public *)hythread_self())->group == get_java_thread_group()); -#ifdef FS14_TLS_USE - // the macros could work for WIN32 - __asm { - mov eax, fs:[0x14] - inc[eax] HyThread_public.disable_count - mov eax,[eax] HyThread_public.request - test eax, eax - jnz suspended - } - return; - - suspended: thread = tm_self_tls; - -#else - thread = tm_self_tls; ((HyThread_public *)thread)->disable_count++; -#endif if (((HyThread_public *)thread)->request && ((HyThread_public *)thread)->disable_count == 1) { Index: vm/thread/src/thread_native_basic.c =================================================================== --- vm/thread/src/thread_native_basic.c (revision 560419) +++ vm/thread/src/thread_native_basic.c (working copy) @@ -382,11 +382,19 @@ } static void thread_set_self(hythread_t thread) { - //tm_self_tls = thread; - _asm{ - mov eax, thread - mov fs:[0x14], eax - } + // tm_self_tls = thread; +#ifndef _WIN64 +# if (_MSC_VER >= 1400) + __writefsdword(offsetof(NT_TIB, ArbitraryUserPointer), thread); +# else + _asm{ + mov eax, thread + mov fs:[0x14], eax + } +# endif +#else + __writegsqword(offsetof(NT_TIB, ArbitraryUserPointer), thread); +#endif } #else /**