Title: [227424] trunk/Source
- Revision
- 227424
- Author
- fpi...@apple.com
- Date
- 2018-01-23 10:26:35 -0800 (Tue, 23 Jan 2018)
Log Message
JSC should use a speculation fence on VM entry/exit
https://bugs.webkit.org/show_bug.cgi?id=181991
Reviewed by JF Bastien and Mark Lam.
Source/_javascript_Core:
This adds a WTF::speculationFence on VM entry and exit.
For a microbenchmark that just calls a native function (supplied via an Objective-C block) in a
tight loop from JS is a 0% regression on x86 and a 11% regression on ARM64.
* runtime/JSLock.cpp:
(JSC::JSLock::didAcquireLock):
(JSC::JSLock::willReleaseLock):
Source/WTF:
Implement speculationFence as lfence on x86 and isb on ARM64. I'm not sure if isb is
appropriate for all ARM64's.
* wtf/Atomics.h:
(WTF::speculationFence):
(WTF::x86_lfence):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (227423 => 227424)
--- trunk/Source/_javascript_Core/ChangeLog 2018-01-23 18:22:50 UTC (rev 227423)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-01-23 18:26:35 UTC (rev 227424)
@@ -1,3 +1,19 @@
+2018-01-23 Filip Pizlo <fpi...@apple.com>
+
+ JSC should use a speculation fence on VM entry/exit
+ https://bugs.webkit.org/show_bug.cgi?id=181991
+
+ Reviewed by JF Bastien and Mark Lam.
+
+ This adds a WTF::speculationFence on VM entry and exit.
+
+ For a microbenchmark that just calls a native function (supplied via an Objective-C block) in a
+ tight loop from JS is a 0% regression on x86 and a 11% regression on ARM64.
+
+ * runtime/JSLock.cpp:
+ (JSC::JSLock::didAcquireLock):
+ (JSC::JSLock::willReleaseLock):
+
2018-01-23 Yusuke Suzuki <utatane....@gmail.com>
[JSC] JIT requires sizeof(bool) == 1
Modified: trunk/Source/_javascript_Core/runtime/JSLock.cpp (227423 => 227424)
--- trunk/Source/_javascript_Core/runtime/JSLock.cpp 2018-01-23 18:22:50 UTC (rev 227423)
+++ trunk/Source/_javascript_Core/runtime/JSLock.cpp 2018-01-23 18:26:35 UTC (rev 227424)
@@ -123,6 +123,8 @@
void JSLock::didAcquireLock()
{
+ WTF::speculationFence();
+
// FIXME: What should happen to the per-thread identifier table if we don't have a VM?
if (!m_vm)
return;
@@ -191,6 +193,8 @@
void JSLock::willReleaseLock()
{
+ WTF::speculationFence();
+
RefPtr<VM> vm = m_vm;
if (vm) {
vm->drainMicrotasks();
Modified: trunk/Source/WTF/ChangeLog (227423 => 227424)
--- trunk/Source/WTF/ChangeLog 2018-01-23 18:22:50 UTC (rev 227423)
+++ trunk/Source/WTF/ChangeLog 2018-01-23 18:26:35 UTC (rev 227424)
@@ -1,3 +1,17 @@
+2018-01-23 Filip Pizlo <fpi...@apple.com>
+
+ JSC should use a speculation fence on VM entry/exit
+ https://bugs.webkit.org/show_bug.cgi?id=181991
+
+ Reviewed by JF Bastien and Mark Lam.
+
+ Implement speculationFence as lfence on x86 and isb on ARM64. I'm not sure if isb is
+ appropriate for all ARM64's.
+
+ * wtf/Atomics.h:
+ (WTF::speculationFence):
+ (WTF::x86_lfence):
+
2018-01-22 Alex Christensen <achristen...@webkit.org>
Begin removing QTKit code
Modified: trunk/Source/WTF/wtf/Atomics.h (227423 => 227424)
--- trunk/Source/WTF/wtf/Atomics.h 2018-01-23 18:22:50 UTC (rev 227423)
+++ trunk/Source/WTF/wtf/Atomics.h 2018-01-23 18:26:35 UTC (rev 227424)
@@ -276,9 +276,17 @@
inline void memoryBarrierAfterLock() { arm_dmb(); }
inline void memoryBarrierBeforeUnlock() { arm_dmb(); }
inline void crossModifyingCodeFence() { arm_isb(); }
+inline void speculationFence() { arm_isb(); }
#elif CPU(X86) || CPU(X86_64)
+inline void x86_lfence()
+{
+#if !OS(WINDOWS)
+ asm volatile("lfence" ::: "memory");
+#endif
+}
+
inline void x86_ortop()
{
#if OS(WINDOWS)
@@ -326,6 +334,7 @@
inline void memoryBarrierAfterLock() { compilerFence(); }
inline void memoryBarrierBeforeUnlock() { compilerFence(); }
inline void crossModifyingCodeFence() { x86_cpuid(); }
+inline void speculationFence() { x86_lfence(); }
#else
@@ -336,6 +345,7 @@
inline void memoryBarrierAfterLock() { std::atomic_thread_fence(std::memory_order_seq_cst); }
inline void memoryBarrierBeforeUnlock() { std::atomic_thread_fence(std::memory_order_seq_cst); }
inline void crossModifyingCodeFence() { std::atomic_thread_fence(std::memory_order_seq_cst); } // Probably not strong enough.
+inline void speculationFence() { } // Probably not strong enough.
#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes