You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2007/04/17 07:08:03 UTC
svn commit: r529487 - in /harmony/enhanced/drlvm/trunk:
build/make/components/vm/ vm/vmcore/include/ vm/vmcore/src/thread/
vm/vmcore/src/thread/linux/ vm/vmcore/src/thread/win/
Author: ndbeyer
Date: Mon Apr 16 22:08:00 2007
New Revision: 529487
URL: http://svn.apache.org/viewvc?view=rev&rev=529487
Log:
Rework atomics code so that it will work on P3 processors.
Added:
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/atomics_common.cpp
- copied unchanged from r529000, harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/atomics.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/linux/
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/linux/atomics.cpp (with props)
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/win/
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/win/atomics.cpp (with props)
Removed:
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/atomics.cpp
Modified:
harmony/enhanced/drlvm/trunk/build/make/components/vm/vmcore.xml
harmony/enhanced/drlvm/trunk/vm/vmcore/include/atomics.h
Modified: harmony/enhanced/drlvm/trunk/build/make/components/vm/vmcore.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/components/vm/vmcore.xml?view=diff&rev=529487&r1=529486&r2=529487
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/components/vm/vmcore.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/components/vm/vmcore.xml Mon Apr 16 22:08:00 2007
@@ -120,6 +120,7 @@
<fileset dir="${build.vm.home}/vmcore/src">
<select os="win">
+ <include name="thread/win/*.cpp" />
<include name="util/win/*.cpp" />
</select>
@@ -154,6 +155,7 @@
</select>
<select os="lnx">
+ <include name="thread/linux/*.cpp" />
<include name="util/linux/os_wrapper.cpp" />
<include name="util/linux/stubs.cpp" />
<include name="util/linux/crash_handler.cpp" />
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/atomics.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/atomics.h?view=diff&rev=529487&r1=529486&r2=529487
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/atomics.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/atomics.h Mon Apr 16 22:08:00 2007
@@ -14,10 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Andrey Chernyshev
- * @version $Revision: 1.1.2.1.4.4 $
- */
#ifndef _ATOMICS_H_
#define _ATOMICS_H_
@@ -25,84 +21,36 @@
#include "jni.h"
#include "Class.h"
-#if defined(_EM64T_) && defined(_WIN64)
-#include <intrin.h>
-#pragma intrinsic (_ReadWriteBarrier)
-#pragma intrinsic (_WriteBarrier)
-#endif
-
JNIEXPORT jlong getFieldOffset
- (JNIEnv * env, jobject field);
+ (JNIEnv * env, jobject field);
JNIEXPORT jboolean compareAndSetObjectField
- (JNIEnv * env, jobject self, jobject obj, jlong offset, jobject expected, jobject value);
-
+ (JNIEnv * env, jobject self, jobject obj, jlong offset, jobject expected, jobject value);
+
JNIEXPORT jboolean compareAndSetBooleanField
- (JNIEnv * env, jobject self, jobject obj, jlong offset, jboolean expected, jboolean value);
-
+ (JNIEnv * env, jobject self, jobject obj, jlong offset, jboolean expected, jboolean value);
+
JNIEXPORT jboolean compareAndSetIntField
- (JNIEnv * env, jobject self, jobject obj, jlong offset, jint expected, jint value);
-
+ (JNIEnv * env, jobject self, jobject obj, jlong offset, jint expected, jint value);
+
JNIEXPORT jboolean compareAndSetLongField
- (JNIEnv * env, jobject self, jobject obj, jlong offset, jlong expected, jlong value);
-
+ (JNIEnv * env, jobject self, jobject obj, jlong offset, jlong expected, jlong value);
+
JNIEXPORT jboolean compareAndSetObjectArray
-(JNIEnv * env, jobject self, jobjectArray array, jint index, jobject expected, jobject value);
+ (JNIEnv * env, jobject self, jobjectArray array, jint index, jobject expected, jobject value);
JNIEXPORT jboolean compareAndSetBooleanArray
-(JNIEnv * env, jobject self, jbooleanArray array, jint index, jboolean expected, jboolean value);
+ (JNIEnv * env, jobject self, jbooleanArray array, jint index, jboolean expected, jboolean value);
JNIEXPORT jboolean compareAndSetIntArray
-(JNIEnv * env, jobject self, jintArray array, jint index, jint expected, jint value);
+ (JNIEnv * env, jobject self, jintArray array, jint index, jint expected, jint value);
JNIEXPORT jboolean compareAndSetLongArray
-(JNIEnv * env, jobject self, jlongArray array, jint index, jlong expected, jlong value);
+ (JNIEnv * env, jobject self, jlongArray array, jint index, jlong expected, jlong value);
JNIEXPORT jboolean vmSupportsCAS8();
-//void MemoryReadWriteBarrier();
-
-#if defined (PLATFORM_POSIX)
- #if defined (_IPF_)
- inline void MemoryReadWriteBarrier() {
- asm volatile ("mf" ::: "memory");
- }
- inline void MemoryWriteBarrier() {
- asm volatile ("mf" ::: "memory");
- }
- #else
- inline void MemoryReadWriteBarrier() {
- __asm__("mfence");
- }
- inline void MemoryWriteBarrier() {
- __asm__("sfence");
- }
- #endif
-#else
- #if defined (_IPF_)
- inline void MemoryReadWriteBarrier() {
- __asm mf;
- }
- inline void MemoryWriteBarrier() {
- __asm mf;
- }
- #else
- inline void MemoryReadWriteBarrier() {
- #if defined(_EM64T_) && defined(_WIN64)
- _ReadWriteBarrier();
- #else
- __asm mfence;
- #endif
- }
- inline void MemoryWriteBarrier() {
- #if defined(_EM64T_) && defined(_WIN64)
- _WriteBarrier();
- #else
- __asm sfence;
- #endif
- }
- #endif
-#endif
+void MemoryReadWriteBarrier();
+void MemoryWriteBarrier();
#endif // _ATOMICS_H_
-
Added: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/linux/atomics.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/linux/atomics.cpp?view=auto&rev=529487
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/linux/atomics.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/linux/atomics.cpp Mon Apr 16 22:08:00 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "atomics.h"
+
+
+void MemoryReadWriteBarrier() {
+ /*
+ * This code must use a lock-prefixed assembly instruction, so that
+ * we can support P3 processors (SSE2 only). With P4 and SSE3, we
+ * could use 'mfence'.
+ * References:
+ * Java Memory Model cookbook
+ * - http://gee.cs.oswego.edu/dl/jmm/cookbook.html
+ * Linux Kernel, mb() function
+ * - http://lxr.linux.no/source/include/asm-i386/system.h
+ * This is a GCC inline assembly command. The final bit, "memory", will
+ * clobber all of the memory registers.
+ */
+ asm volatile("lock; addl $0,0(%%esp)" : : : "memory");
+}
+
+void MemoryWriteBarrier() {
+ /*
+ * We could use the same lock-prefixed assembly instruction above,
+ * but since we have support for P3 processors (SSE2) we'll just
+ * use 'sfence'.
+ */
+ asm volatile ("sfence" : : : "memory");
+}
+
Propchange: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/linux/atomics.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/win/atomics.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/win/atomics.cpp?view=auto&rev=529487
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/win/atomics.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/win/atomics.cpp Mon Apr 16 22:08:00 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "atomics.h"
+
+// MSVC barrier intrinsics setup
+#if _MSC_VER < 1400
+ // VC++ 2003
+ extern "C" void _ReadWriteBarrier();
+ extern "C" void _WriteBarrier();
+#else
+ // VC++ 2005
+ #include <intrin.h>
+#endif
+#pragma intrinsic (_ReadWriteBarrier)
+#pragma intrinsic (_WriteBarrier)
+
+void MemoryReadWriteBarrier() {
+ _ReadWriteBarrier();
+}
+
+void MemoryWriteBarrier() {
+ _WriteBarrier();
+}
+
Propchange: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/win/atomics.cpp
------------------------------------------------------------------------------
svn:eol-style = native