Revision: 21938
Author: [email protected]
Date: Mon Jun 23 13:30:03 2014 UTC
Log: Partial revert of r21901 (2nd attempt)
Only disable runtime check for sse2 if __SSE2__ is not defined. This
is required for the x87 port
BUG=none
LOG=n
[email protected]
Review URL: https://codereview.chromium.org/331803006
http://code.google.com/p/v8/source/detail?r=21938
Modified:
/branches/bleeding_edge/src/base/atomicops_internals_x86_gcc.cc
/branches/bleeding_edge/src/base/atomicops_internals_x86_gcc.h
=======================================
--- /branches/bleeding_edge/src/base/atomicops_internals_x86_gcc.cc Mon Jun
23 10:31:12 2014 UTC
+++ /branches/bleeding_edge/src/base/atomicops_internals_x86_gcc.cc Mon Jun
23 13:30:03 2014 UTC
@@ -42,6 +42,9 @@
// default values should hopefully be pretty safe.
struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures = {
false, // bug can't exist before process spawns multiple threads
+#if !defined(__SSE2__)
+ false, // no SSE2
+#endif
};
} } // namespace v8::base
@@ -87,6 +90,11 @@
} else {
AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false;
}
+
+#if !defined(__SSE2__)
+ // edx bit 26 is SSE2 which we use to tell use whether we can use mfence
+ AtomicOps_Internalx86CPUFeatures.has_sse2 = ((edx >> 26) & 1);
+#endif
}
class AtomicOpsx86Initializer {
=======================================
--- /branches/bleeding_edge/src/base/atomicops_internals_x86_gcc.h Mon Jun
23 10:31:12 2014 UTC
+++ /branches/bleeding_edge/src/base/atomicops_internals_x86_gcc.h Mon Jun
23 13:30:03 2014 UTC
@@ -17,6 +17,9 @@
struct AtomicOps_x86CPUFeatureStruct {
bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do
lfence
// after acquire compare-and-swap.
+#if !defined(__SSE2__)
+ bool has_sse2; // Processor has SSE2.
+#endif
};
extern struct AtomicOps_x86CPUFeatureStruct
AtomicOps_Internalx86CPUFeatures;
@@ -91,7 +94,10 @@
*ptr = value;
}
-// We require SSE2, so mfence is guaranteed to exist.
+#if defined(__x86_64__) || defined(__SSE2__)
+
+// 64-bit implementations of memory barrier can be simpler, because it
+// "mfence" is guaranteed to exist.
inline void MemoryBarrier() {
__asm__ __volatile__("mfence" : : : "memory");
}
@@ -100,6 +106,28 @@
*ptr = value;
MemoryBarrier();
}
+
+#else
+
+inline void MemoryBarrier() {
+ if (AtomicOps_Internalx86CPUFeatures.has_sse2) {
+ __asm__ __volatile__("mfence" : : : "memory");
+ } else { // mfence is faster but not present on PIII
+ Atomic32 x = 0;
+ NoBarrier_AtomicExchange(&x, 0); // acts as a barrier on PIII
+ }
+}
+
+inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
+ if (AtomicOps_Internalx86CPUFeatures.has_sse2) {
+ *ptr = value;
+ __asm__ __volatile__("mfence" : : : "memory");
+ } else {
+ NoBarrier_AtomicExchange(ptr, value);
+ // acts as a barrier on PIII
+ }
+}
+#endif
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
ATOMICOPS_COMPILER_BARRIER();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.