You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by wj...@apache.org on 2007/07/30 23:17:14 UTC
svn commit: r561125 - in /harmony/enhanced/drlvm/trunk/vm:
include/open/hythread.h include/open/hythread_ext.h
thread/src/thread_native_basic.c
Author: wjwashburn
Date: Mon Jul 30 14:17:13 2007
New Revision: 561125
URL: http://svn.apache.org/viewvc?view=rev&rev=561125
Log:
Harmony-3490, a performance patch to threading
Modified:
harmony/enhanced/drlvm/trunk/vm/include/open/hythread.h
harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
Modified: harmony/enhanced/drlvm/trunk/vm/include/open/hythread.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/hythread.h?view=diff&rev=561125&r1=561124&r2=561125
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/hythread.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/hythread.h Mon Jul 30 14:17:13 2007
@@ -27,6 +27,14 @@
#include <stddef.h>
#include "hycomp.h"
+
+#ifdef _WIN32
+# if (_MSC_VER >= 1400)
+# include <intrin.h>
+# 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,21 +410,13 @@
-#ifdef _EM64T_
-# ifdef _WIN64
- //don't use optimized asm monitor enter and exit helpers
-# else
- //use optimized asm monitor enter and exit helpers
-# define ASM_MONITOR_HELPER
-# endif
-#else
#ifdef _IPF_
//don't use optimized asm monitor enter and exit helpers
#else
//use optimized asm monitor enter and exit helpers
# define ASM_MONITOR_HELPER
#endif
-#endif
+
#if defined (_WIN32)
# define HYTHREAD_FAST_TLS_ATTRIBUTE
@@ -468,11 +468,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())
Modified: harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h?view=diff&rev=561125&r1=561124&r2=561125
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h Mon Jul 30 14:17:13 2007
@@ -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) {
Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c?view=diff&rev=561125&r1=561124&r2=561125
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c Mon Jul 30 14:17:13 2007
@@ -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
/**