base/platform/mutex.h provides two mutex classes, "Mutex" for non-recursive 
use case and "RecursiveMutex" for recursive use case. However, both Windows 
implementations use CRITICAL_SECTION which is designed for recursive use 
case.

Win32 API provides lightweight SRWLOCK for non-recursive use cases (only 
available for Windows Vista and above).

>From my dummy non-recursive benchmark, SRWLOCK is consistently faster than 
CRITICAL_SECTION by about 20%.

It is safe for "Mutex" to use SRWLOCK because existing DCHECKs already 
ensure that all V8 code that use "Mutex" are indeed non-recursive.

My plan for another CL:

- Split base/platform/mutex.cc into base/platform/mutex-posix.cc and 
base/platform/mutex-win32.cc
- Move pthread implementation to base/platform/mutex-posix.cc with no extra 
modification.
- Implement "Mutex" with SRWLOCK and "RecursiveMutex" with CRITICAL_SECTION 
for windows in base/platform/mutex-win32.cc

By the way, Chromium also use SRWLOCK.

https://cs.chromium.org/chromium/src/base/synchronization/lock_impl.h

On Thursday, June 1, 2017 at 6:54:01 AM UTC+8, [email protected] wrote:
>
> Working CL: https://chromium-review.googlesource.com/c/519542/
>

-- 
-- 
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.

Reply via email to