WebKit Bugzilla
Attachment 360419 Details for
Bug 193929
: Move platform-specific files out of WTF root directory.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-193929-20190128191545.patch (text/plain), 146.89 KB, created by
Ross Kirsling
on 2019-01-28 19:15:46 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Ross Kirsling
Created:
2019-01-28 19:15:46 PST
Size:
146.89 KB
patch
obsolete
>Subversion Revision: 240632 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index cccca497e797f8dc9f435cce42c6932a63e86112..6fa5cddaa37397724df46201c7527bf218121080 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,28 @@ >+2019-01-28 Ross Kirsling <ross.kirsling@sony.com> >+ >+ Move platform-specific files out of WTF root directory. >+ https://bugs.webkit.org/show_bug.cgi?id=193929 >+ >+ Reviewed by Alex Christensen. >+ >+ * WTF.xcodeproj/project.pbxproj: >+ * wtf/CMakeLists.txt: >+ * wtf/PlatformGTK.cmake: >+ * wtf/PlatformJSCOnly.cmake: >+ * wtf/PlatformMac.cmake: >+ * wtf/PlatformPlayStation.cmake: >+ * wtf/PlatformWPE.cmake: >+ * wtf/PlatformWin.cmake: >+ * wtf/cf/RunLoopTimerCF.cpp: Renamed from Source/WTF/wtf/RunLoopTimerCF.cpp. >+ * wtf/cf/SchedulePairCF.cpp: Renamed from Source/WTF/wtf/SchedulePairCF.cpp. >+ * wtf/mac/SchedulePairMac.mm: Renamed from Source/WTF/wtf/SchedulePairMac.mm. >+ * wtf/posix/OSAllocatorPOSIX.cpp: Renamed from Source/WTF/wtf/OSAllocatorPosix.cpp. >+ * wtf/posix/ThreadingPOSIX.cpp: Renamed from Source/WTF/wtf/ThreadingPthreads.cpp. >+ * wtf/win/CONTRIBUTORS.pthreads-win32: Renamed from Source/WTF/wtf/CONTRIBUTORS.pthreads-win32. >+ * wtf/win/OSAllocatorWin.cpp: Renamed from Source/WTF/wtf/OSAllocatorWin.cpp. >+ * wtf/win/ThreadSpecificWin.cpp: Renamed from Source/WTF/wtf/ThreadSpecificWin.cpp. >+ * wtf/win/ThreadingWin.cpp: Renamed from Source/WTF/wtf/ThreadingWin.cpp. >+ > 2019-01-28 Ross Kirsling <ross.kirsling@sony.com> > > [JSCOnly][WTF] Expose FileSystem. >diff --git a/Source/WTF/WTF.xcodeproj/project.pbxproj b/Source/WTF/WTF.xcodeproj/project.pbxproj >index d953b1baf7e727189d008caa8adb1f32819f1686..127ca509d727d092acdfac2abe717daf1a30debe 100644 >--- a/Source/WTF/WTF.xcodeproj/project.pbxproj >+++ b/Source/WTF/WTF.xcodeproj/project.pbxproj >@@ -46,9 +46,6 @@ > 14022F4118F5C3FC007FF0EB /* libbmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14022F4018F5C3FC007FF0EB /* libbmalloc.a */; }; > 143DDE9620C8BC37007F76FA /* Entitlements.mm in Sources */ = {isa = PBXBuildFile; fileRef = 143DDE9520C8BC37007F76FA /* Entitlements.mm */; }; > 143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 143F611D1565F0F900DB514A /* RAMSize.cpp */; }; >- 1469419316EAAF6D0024E146 /* RunLoopTimerCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1469419116EAAF6D0024E146 /* RunLoopTimerCF.cpp */; }; >- 1469419716EAAFF80024E146 /* SchedulePairMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1469419516EAAFF80024E146 /* SchedulePairMac.mm */; }; >- 1469419916EAB0410024E146 /* SchedulePairCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1469419816EAB0410024E146 /* SchedulePairCF.cpp */; }; > 1469419D16EAB10A0024E146 /* AutodrainedPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1469419B16EAB10A0024E146 /* AutodrainedPool.cpp */; }; > 1A1D8B9E1731879800141DA4 /* FunctionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D8B9D1731879800141DA4 /* FunctionDispatcher.cpp */; }; > 1ACADD841884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */; }; >@@ -90,6 +87,7 @@ > 93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */; }; > 93F1993E19D7958D00C2390B /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1993D19D7958D00C2390B /* StringView.cpp */; }; > 9BC70F05176C379D00101DEC /* AtomicStringTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC70F04176C379D00101DEC /* AtomicStringTable.cpp */; }; >+ A32D8FA521FFFAB400780662 /* ThreadingPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */; }; > A331D95B21F24992009F02AA /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D95A21F24992009F02AA /* FileSystem.cpp */; }; > A331D95D21F249E4009F02AA /* FileSystemCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D95C21F249E4009F02AA /* FileSystemCF.cpp */; }; > A331D95F21F249F6009F02AA /* FileSystemCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A331D95E21F249F6009F02AA /* FileSystemCocoa.mm */; }; >@@ -97,6 +95,10 @@ > A331D96721F24ABD009F02AA /* FileSystemPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */; }; > A3B725EC987446AD93F1A440 /* RandomDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C8F597CA2A57417FBAB92FD6 /* RandomDevice.cpp */; }; > A3E4DD931F3A803400DED0B4 /* TextStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3E4DD911F3A803400DED0B4 /* TextStream.cpp */; }; >+ A3EE5C3A21FFAC5F00FABD61 /* OSAllocatorPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */; }; >+ A3EE5C3D21FFAC7D00FABD61 /* SchedulePairCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3EE5C3B21FFAC7C00FABD61 /* SchedulePairCF.cpp */; }; >+ A3EE5C3E21FFAC7D00FABD61 /* RunLoopTimerCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3EE5C3C21FFAC7D00FABD61 /* RunLoopTimerCF.cpp */; }; >+ A3EE5C4021FFACA200FABD61 /* SchedulePairMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A3EE5C3F21FFACA200FABD61 /* SchedulePairMac.mm */; }; > A5BA15F3182433A900A82E69 /* StringCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15F2182433A900A82E69 /* StringCocoa.mm */; }; > A5BA15F51824348000A82E69 /* StringImplCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15F41824348000A82E69 /* StringImplCocoa.mm */; }; > A5BA15FA182435A600A82E69 /* AtomicStringImplCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15F7182435A600A82E69 /* AtomicStringImplCF.cpp */; }; >@@ -126,7 +128,6 @@ > A8A473E9151A825B004123FF /* MD5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472CA151A825B004123FF /* MD5.cpp */; }; > A8A473EC151A825B004123FF /* MetaAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472CD151A825B004123FF /* MetaAllocator.cpp */; }; > A8A473F4151A825B004123FF /* NumberOfCores.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472D5151A825B004123FF /* NumberOfCores.cpp */; }; >- A8A473F7151A825B004123FF /* OSAllocatorPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472D8151A825B004123FF /* OSAllocatorPosix.cpp */; }; > A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472DA151A825B004123FF /* OSRandomSource.cpp */; }; > A8A47402151A825B004123FF /* PageBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472E3151A825B004123FF /* PageBlock.cpp */; }; > A8A47414151A825B004123FF /* RandomNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472FB151A825B004123FF /* RandomNumber.cpp */; }; >@@ -140,7 +141,6 @@ > A8A47440151A825B004123FF /* StringImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A47328151A825B004123FF /* StringImpl.cpp */; }; > A8A47445151A825B004123FF /* WTFString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A4732D151A825B004123FF /* WTFString.cpp */; }; > A8A4744A151A825B004123FF /* Threading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A47332151A825B004123FF /* Threading.cpp */; }; >- A8A4744E151A825B004123FF /* ThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A47336151A825B004123FF /* ThreadingPthreads.cpp */; }; > A8A47451151A825B004123FF /* BinarySemaphore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A4733A151A825B004123FF /* BinarySemaphore.cpp */; }; > A8A47460151A825B004123FF /* CollatorDefault.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A4734B151A825B004123FF /* CollatorDefault.cpp */; }; > A8A47463151A825B004123FF /* CollatorICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A47350151A825B004123FF /* CollatorICU.cpp */; }; >@@ -281,10 +281,7 @@ > 1447AEC518FCE57700B3D7FF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; > 1447AECA18FCE5B900B3D7FF /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = /usr/lib/libicucore.dylib; sourceTree = "<absolute>"; }; > 1469419016EAAF6D0024E146 /* RunLoopTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoopTimer.h; sourceTree = "<group>"; }; >- 1469419116EAAF6D0024E146 /* RunLoopTimerCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopTimerCF.cpp; sourceTree = "<group>"; }; > 1469419416EAAFF80024E146 /* SchedulePair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SchedulePair.h; sourceTree = "<group>"; }; >- 1469419516EAAFF80024E146 /* SchedulePairMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SchedulePairMac.mm; sourceTree = "<group>"; }; >- 1469419816EAB0410024E146 /* SchedulePairCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SchedulePairCF.cpp; sourceTree = "<group>"; }; > 1469419A16EAB10A0024E146 /* AutodrainedPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutodrainedPool.h; sourceTree = "<group>"; }; > 1469419B16EAB10A0024E146 /* AutodrainedPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutodrainedPool.cpp; sourceTree = "<group>"; }; > 149EF16216BBFE0D000A4331 /* TriState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriState.h; sourceTree = "<group>"; }; >@@ -437,6 +434,7 @@ > 9C67C542589348E285B49699 /* IndexedContainerIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexedContainerIterator.h; sourceTree = "<group>"; }; > A30D412C1F0DE0BA00B71954 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; }; > A30D412D1F0DE13F00B71954 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; }; >+ A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadingPOSIX.cpp; sourceTree = "<group>"; }; > A331D95821F24978009F02AA /* FileMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileMetadata.h; sourceTree = "<group>"; }; > A331D95921F24992009F02AA /* FileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileSystem.h; sourceTree = "<group>"; }; > A331D95A21F24992009F02AA /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystem.cpp; sourceTree = "<group>"; }; >@@ -449,6 +447,10 @@ > A3D273B921F2EE9100866971 /* MetadataSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetadataSPI.h; sourceTree = "<group>"; }; > A3E4DD911F3A803400DED0B4 /* TextStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextStream.cpp; sourceTree = "<group>"; }; > A3E4DD921F3A803400DED0B4 /* TextStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextStream.h; sourceTree = "<group>"; }; >+ A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSAllocatorPOSIX.cpp; sourceTree = "<group>"; }; >+ A3EE5C3B21FFAC7C00FABD61 /* SchedulePairCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SchedulePairCF.cpp; sourceTree = "<group>"; }; >+ A3EE5C3C21FFAC7D00FABD61 /* RunLoopTimerCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopTimerCF.cpp; sourceTree = "<group>"; }; >+ A3EE5C3F21FFACA200FABD61 /* SchedulePairMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SchedulePairMac.mm; sourceTree = "<group>"; }; > A5098AFF1C169E0700087797 /* SandboxSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SandboxSPI.h; sourceTree = "<group>"; }; > A5098B011C16A4F900087797 /* SecuritySPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecuritySPI.h; sourceTree = "<group>"; }; > A561F30F1DF2642100FF675D /* DeprecatedOptional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeprecatedOptional.h; sourceTree = "<group>"; }; >@@ -540,7 +542,6 @@ > A8A472D5151A825B004123FF /* NumberOfCores.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NumberOfCores.cpp; sourceTree = "<group>"; }; > A8A472D6151A825B004123FF /* NumberOfCores.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumberOfCores.h; sourceTree = "<group>"; }; > A8A472D7151A825B004123FF /* OSAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSAllocator.h; sourceTree = "<group>"; }; >- A8A472D8151A825B004123FF /* OSAllocatorPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSAllocatorPosix.cpp; sourceTree = "<group>"; }; > A8A472DA151A825B004123FF /* OSRandomSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSRandomSource.cpp; sourceTree = "<group>"; }; > A8A472DB151A825B004123FF /* OSRandomSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSRandomSource.h; sourceTree = "<group>"; }; > A8A472DF151A825B004123FF /* PackedIntVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackedIntVector.h; sourceTree = "<group>"; }; >@@ -595,7 +596,6 @@ > A8A47332151A825B004123FF /* Threading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Threading.cpp; sourceTree = "<group>"; }; > A8A47333151A825B004123FF /* Threading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Threading.h; sourceTree = "<group>"; }; > A8A47335151A825B004123FF /* ThreadingPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadingPrimitives.h; sourceTree = "<group>"; }; >- A8A47336151A825B004123FF /* ThreadingPthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadingPthreads.cpp; sourceTree = "<group>"; }; > A8A4733A151A825B004123FF /* BinarySemaphore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinarySemaphore.cpp; sourceTree = "<group>"; }; > A8A4733B151A825B004123FF /* BinarySemaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinarySemaphore.h; sourceTree = "<group>"; }; > A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadSafeRefCounted.h; sourceTree = "<group>"; }; >@@ -735,6 +735,8 @@ > A331D95C21F249E4009F02AA /* FileSystemCF.cpp */, > C2BCFC411F61D61600C9222C /* LanguageCF.cpp */, > 2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */, >+ A3EE5C3C21FFAC7D00FABD61 /* RunLoopTimerCF.cpp */, >+ A3EE5C3B21FFAC7C00FABD61 /* SchedulePairCF.cpp */, > 1AFDE647195201C300C48FFA /* TypeCastsCF.h */, > 5C1F0594216437B30039302C /* URLCF.cpp */, > ); >@@ -794,6 +796,8 @@ > isa = PBXGroup; > children = ( > A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */, >+ A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */, >+ A32D8FA421FFFAB400780662 /* ThreadingPOSIX.cpp */, > ); > path = posix; > sourceTree = "<group>"; >@@ -1034,7 +1038,6 @@ > 1A4656181C7FC68E00F5920F /* OptionSet.h */, > 0F9495831C571CC900413A48 /* OrderMaker.h */, > A8A472D7151A825B004123FF /* OSAllocator.h */, >- A8A472D8151A825B004123FF /* OSAllocatorPosix.cpp */, > 7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */, > A8A472DA151A825B004123FF /* OSRandomSource.cpp */, > A8A472DB151A825B004123FF /* OSRandomSource.h */, >@@ -1090,11 +1093,8 @@ > 2CDED0F118115C85004DBA70 /* RunLoop.cpp */, > 2CDED0F218115C85004DBA70 /* RunLoop.h */, > 1469419016EAAF6D0024E146 /* RunLoopTimer.h */, >- 1469419116EAAF6D0024E146 /* RunLoopTimerCF.cpp */, > 14F3B0F615E45E4600210069 /* SaturatedArithmetic.h */, > 1469419416EAAFF80024E146 /* SchedulePair.h */, >- 1469419816EAB0410024E146 /* SchedulePairCF.cpp */, >- 1469419516EAAFF80024E146 /* SchedulePairMac.mm */, > 1A3524AA1D63A2FF0031729B /* Scope.h */, > 0FEC84B01BDACD390080FF74 /* ScopedLambda.h */, > 0F66B2841DC97BAB004A1D3F /* Seconds.cpp */, >@@ -1145,7 +1145,6 @@ > A8A47332151A825B004123FF /* Threading.cpp */, > A8A47333151A825B004123FF /* Threading.h */, > A8A47335151A825B004123FF /* ThreadingPrimitives.h */, >- A8A47336151A825B004123FF /* ThreadingPthreads.cpp */, > 5311BD5B1EA822F900525281 /* ThreadMessage.cpp */, > 5311BD591EA81A9600525281 /* ThreadMessage.h */, > A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */, >@@ -1229,6 +1228,7 @@ > 1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */, > A331D96021F24A0A009F02AA /* FileSystemMac.mm */, > 53534F291EC0E10E00141B2F /* MachExceptions.defs */, >+ A3EE5C3F21FFACA200FABD61 /* SchedulePairMac.mm */, > ); > path = mac; > sourceTree = "<group>"; >@@ -1548,7 +1548,7 @@ > 0F66B28C1DC97BAB004A1D3F /* MonotonicTime.cpp in Sources */, > 5CC0EE8A2162BC2200A1A842 /* NSURLExtras.mm in Sources */, > A8A473F4151A825B004123FF /* NumberOfCores.cpp in Sources */, >- A8A473F7151A825B004123FF /* OSAllocatorPosix.cpp in Sources */, >+ A3EE5C3A21FFAC5F00FABD61 /* OSAllocatorPOSIX.cpp in Sources */, > A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */, > A8A47402151A825B004123FF /* PageBlock.cpp in Sources */, > 0FFF19DC1BB334EB00886D91 /* ParallelHelperPool.cpp in Sources */, >@@ -1566,9 +1566,9 @@ > A8A4741A151A825B004123FF /* RefCountedLeakCounter.cpp in Sources */, > 2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */, > 2CDED0EF18115C38004DBA70 /* RunLoopCF.cpp in Sources */, >- 1469419316EAAF6D0024E146 /* RunLoopTimerCF.cpp in Sources */, >- 1469419916EAB0410024E146 /* SchedulePairCF.cpp in Sources */, >- 1469419716EAAFF80024E146 /* SchedulePairMac.mm in Sources */, >+ A3EE5C3E21FFAC7D00FABD61 /* RunLoopTimerCF.cpp in Sources */, >+ A3EE5C3D21FFAC7D00FABD61 /* SchedulePairCF.cpp in Sources */, >+ A3EE5C4021FFACA200FABD61 /* SchedulePairMac.mm in Sources */, > 0F66B28E1DC97BAB004A1D3F /* Seconds.cpp in Sources */, > A8A47421151A825B004123FF /* SHA1.cpp in Sources */, > 5311BD531EA71CAD00525281 /* Signals.cpp in Sources */, >@@ -1597,7 +1597,7 @@ > A3E4DD931F3A803400DED0B4 /* TextStream.cpp in Sources */, > E311FB171F0A568B003C08DE /* ThreadGroup.cpp in Sources */, > A8A4744A151A825B004123FF /* Threading.cpp in Sources */, >- A8A4744E151A825B004123FF /* ThreadingPthreads.cpp in Sources */, >+ A32D8FA521FFFAB400780662 /* ThreadingPOSIX.cpp in Sources */, > 5311BD5C1EA822F900525281 /* ThreadMessage.cpp in Sources */, > 0F66B2901DC97BAB004A1D3F /* TimeWithDynamicClockType.cpp in Sources */, > 0F7075F51FBF53CD00489AF0 /* TimingScope.cpp in Sources */, >diff --git a/Source/WTF/wtf/CMakeLists.txt b/Source/WTF/wtf/CMakeLists.txt >index 6bfbcf5b0bc14f2ccd6dbec069f44e137ff0e605..178383dff491b4b1bb1a2d69000d2f6a430e0b52 100644 >--- a/Source/WTF/wtf/CMakeLists.txt >+++ b/Source/WTF/wtf/CMakeLists.txt >@@ -492,23 +492,6 @@ list(APPEND WTF_LIBRARIES > ${ICU_LIBRARIES} > ) > >-if (WIN32) >- list(APPEND WTF_SOURCES >- OSAllocatorWin.cpp >- ThreadSpecificWin.cpp >- ThreadingWin.cpp >- ) >- list(APPEND WTF_LIBRARIES >- DbgHelp >- winmm >- ) >-else () >- list(APPEND WTF_SOURCES >- OSAllocatorPosix.cpp >- ThreadingPthreads.cpp >- ) >-endif () >- > WEBKIT_FRAMEWORK_DECLARE(WTF) > WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS() > >diff --git a/Source/WTF/wtf/CONTRIBUTORS.pthreads-win32 b/Source/WTF/wtf/CONTRIBUTORS.pthreads-win32 >deleted file mode 100644 >index 7de0f260659e44e4e6f728dd87fe9cd9b0d98d14..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/CONTRIBUTORS.pthreads-win32 >+++ /dev/null >@@ -1,137 +0,0 @@ >-This is a copy of CONTRIBUTORS file for the Pthreads-win32 library, downloaded >-from http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/pthreads/CONTRIBUTORS?rev=1.32&cvsroot=pthreads-win32 >- >-Included here to compliment the Pthreads-win32 license header in wtf/ThreadingWin.cpp file. >-WebKit is using derived sources of ThreadCondition code from Pthreads-win32. >- >-------------------------------------------------------------------------------- >- >-Contributors (in approximate order of appearance) >- >-[See also the ChangeLog file where individuals are >-attributed in log entries. Likewise in the FAQ file.] >- >-Ben Elliston bje at cygnus dot com >- Initiated the project; >- setup the project infrastructure (CVS, web page, etc.); >- early prototype routines. >-Ross Johnson rpj at callisto dot canberra dot edu dot au >- early prototype routines; >- ongoing project coordination/maintenance; >- implementation of spin locks and barriers; >- various enhancements; >- bug fixes; >- documentation; >- testsuite. >-Robert Colquhoun rjc at trump dot net dot au >- Early bug fixes. >-John E. Bossom John dot Bossom at cognos dot com >- Contributed substantial original working implementation; >- bug fixes; >- ongoing guidance and standards interpretation. >-Anders Norlander anorland at hem2 dot passagen dot se >- Early enhancements and runtime checking for supported >- Win32 routines. >-Tor Lillqvist tml at iki dot fi >- General enhancements; >- early bug fixes to condition variables. >-Scott Lightner scott at curriculum dot com >- Bug fix. >-Kevin Ruland Kevin dot Ruland at anheuser-busch dot com >- Various bug fixes. >-Mike Russo miker at eai dot com >- Bug fix. >-Mark E. Armstrong avail at pacbell dot net >- Bug fixes. >-Lorin Hochstein lmh at xiphos dot ca >- general bug fixes; bug fixes to condition variables. >-Peter Slacik Peter dot Slacik at tatramed dot sk >- Bug fixes. >-Mumit Khan khan at xraylith dot wisc dot edu >- Fixes to work with Mingw32. >-Milan Gardian mg at tatramed dot sk >- Bug fixes and reports/analyses of obscure problems. >-Aurelio Medina aureliom at crt dot com >- First implementation of read-write locks. >-Graham Dumpleton Graham dot Dumpleton at ra dot pad dot otc dot telstra dot com dot au >- Bug fix in condition variables. >-Tristan Savatier tristan at mpegtv dot com >- WinCE port. >-Erik Hensema erik at hensema dot xs4all dot nl >- Bug fixes. >-Rich Peters rpeters at micro-magic dot com >-Todd Owen towen at lucidcalm dot dropbear dot id dot au >- Bug fixes to dll loading. >-Jason Nye jnye at nbnet dot nb dot ca >- Implementation of async cancelation. >-Fred Forester fforest at eticomm dot net >-Kevin D. Clark kclark at cabletron dot com >-David Baggett dmb at itasoftware dot com >- Bug fixes. >-Paul Redondo paul at matchvision dot com >-Scott McCaskill scott at 3dfx dot com >- Bug fixes. >-Jef Gearhart jgearhart at tpssys dot com >- Bug fix. >-Arthur Kantor akantor at bexusa dot com >- Mutex enhancements. >-Steven Reddie smr at essemer dot com dot au >- Bug fix. >-Alexander Terekhov TEREKHOV at de dot ibm dot com >- Re-implemented and improved read-write locks; >- (with Louis Thomas) re-implemented and improved >- condition variables; >- enhancements to semaphores; >- enhancements to mutexes; >- new mutex implementation in 'futex' style; >- suggested a robust implementation of pthread_once >- similar to that implemented by V.Kliathcko; >- system clock change handling re CV timeouts; >- bug fixes. >-Thomas Pfaff tpfaff at gmx dot net >- Changes to make C version usable with C++ applications; >- re-implemented mutex routines to avoid Win32 mutexes >- and TryEnterCriticalSection; >- procedure to fix Mingw32 thread-safety issues. >-Franco Bez franco dot bez at gmx dot de >- procedure to fix Mingw32 thread-safety issues. >-Louis Thomas lthomas at arbitrade dot com >- (with Alexander Terekhov) re-implemented and improved >- condition variables. >-David Korn dgk at research dot att dot com >- Ported to UWIN. >-Phil Frisbie, Jr. phil at hawksoft dot com >- Bug fix. >-Ralf Brese Ralf dot Brese at pdb4 dot siemens dot de >- Bug fix. >-prionx at juno dot com prionx at juno dot com >- Bug fixes. >-Max Woodbury mtew at cds dot duke dot edu >- POSIX versioning conditionals; >- reduced namespace pollution; >- idea to separate routines to reduce statically >- linked image sizes. >-Rob Fanner rfanner at stonethree dot com >- Bug fix. >-Michael Johnson michaelj at maine dot rr dot com >- Bug fix. >-Nicolas Barry boozai at yahoo dot com >- Bug fixes. >-Piet van Bruggen pietvb at newbridges dot nl >- Bug fix. >-Makoto Kato raven at oldskool dot jp >- AMD64 port. >-Panagiotis E. Hadjidoukas peh at hpclab dot ceid dot upatras dot gr >- Contributed the QueueUserAPCEx package which >- makes preemptive async cancelation possible. >-Will Bryant will dot bryant at ecosm dot com >- Borland compiler patch and makefile. >-Anuj Goyal anuj dot goyal at gmail dot com >- Port to Digital Mars compiler. >-Gottlob Frege gottlobfrege at gmail dot com >- re-implemented pthread_once (version 2) >- (pthread_once cancellation added by rpj). >-Vladimir Kliatchko vladimir at kliatchko dot com >- reimplemented pthread_once with the same form >- as described by A.Terekhov (later version 2); >- implementation of MCS (Mellor-Crummey/Scott) locks. >\ No newline at end of file >diff --git a/Source/WTF/wtf/OSAllocatorPosix.cpp b/Source/WTF/wtf/OSAllocatorPosix.cpp >deleted file mode 100644 >index 923a8843eeb7ad4b6584824e0e9d9c333d114ad6..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/OSAllocatorPosix.cpp >+++ /dev/null >@@ -1,186 +0,0 @@ >-/* >- * Copyright (C) 2010 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >- * THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include <wtf/OSAllocator.h> >- >-#if OS(UNIX) >- >-#include <errno.h> >-#include <sys/mman.h> >-#include <wtf/Assertions.h> >-#include <wtf/PageAllocation.h> >- >-namespace WTF { >- >-void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) >-{ >-#if OS(LINUX) >- UNUSED_PARAM(usage); >- UNUSED_PARAM(writable); >- UNUSED_PARAM(executable); >- UNUSED_PARAM(includesGuardPages); >- >- void* result = mmap(0, bytes, PROT_NONE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANON, -1, 0); >- if (result == MAP_FAILED) >- CRASH(); >- madvise(result, bytes, MADV_DONTNEED); >-#else >- void* result = reserveAndCommit(bytes, usage, writable, executable, includesGuardPages); >-#if HAVE(MADV_FREE_REUSE) >- if (result) { >- // To support the "reserve then commit" model, we have to initially decommit. >- while (madvise(result, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } >- } >-#endif >- >-#endif >- >- return result; >-} >- >-void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) >-{ >- // All POSIX reservations start out logically committed. >- int protection = PROT_READ; >- if (writable) >- protection |= PROT_WRITE; >- if (executable) >- protection |= PROT_EXEC; >- >- int flags = MAP_PRIVATE | MAP_ANON; >-#if OS(DARWIN) >- if (executable) >- flags |= MAP_JIT; >-#endif >- >-#if OS(DARWIN) >- int fd = usage; >-#else >- UNUSED_PARAM(usage); >- int fd = -1; >-#endif >- >- void* result = 0; >-#if (OS(DARWIN) && CPU(X86_64)) >- if (executable) { >- ASSERT(includesGuardPages); >- // Cook up an address to allocate at, using the following recipe: >- // 17 bits of zero, stay in userspace kids. >- // 26 bits of randomness for ASLR. >- // 21 bits of zero, at least stay aligned within one level of the pagetables. >- // >- // But! - as a temporary workaround for some plugin problems (rdar://problem/6812854), >- // for now instead of 2^26 bits of ASLR lets stick with 25 bits of randomization plus >- // 2^24, which should put up somewhere in the middle of userspace (in the address range >- // 0x200000000000 .. 0x5fffffffffff). >- intptr_t randomLocation = 0; >- randomLocation = arc4random() & ((1 << 25) - 1); >- randomLocation += (1 << 24); >- randomLocation <<= 21; >- result = reinterpret_cast<void*>(randomLocation); >- } >-#endif >- >- result = mmap(result, bytes, protection, flags, fd, 0); >- if (result == MAP_FAILED) { >- if (executable) >- result = 0; >- else >- CRASH(); >- } >- if (result && includesGuardPages) { >- // We use mmap to remap the guardpages rather than using mprotect as >- // mprotect results in multiple references to the code region. This >- // breaks the madvise based mechanism we use to return physical memory >- // to the OS. >- mmap(result, pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0); >- mmap(static_cast<char*>(result) + bytes - pageSize(), pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0); >- } >- return result; >-} >- >-void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) >-{ >-#if OS(LINUX) >- int protection = PROT_READ; >- if (writable) >- protection |= PROT_WRITE; >- if (executable) >- protection |= PROT_EXEC; >- if (mprotect(address, bytes, protection)) >- CRASH(); >- madvise(address, bytes, MADV_WILLNEED); >-#elif HAVE(MADV_FREE_REUSE) >- UNUSED_PARAM(writable); >- UNUSED_PARAM(executable); >- while (madvise(address, bytes, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { } >-#else >- // Non-MADV_FREE_REUSE reservations automatically commit on demand. >- UNUSED_PARAM(address); >- UNUSED_PARAM(bytes); >- UNUSED_PARAM(writable); >- UNUSED_PARAM(executable); >-#endif >-} >- >-void OSAllocator::decommit(void* address, size_t bytes) >-{ >-#if OS(LINUX) >- madvise(address, bytes, MADV_DONTNEED); >- if (mprotect(address, bytes, PROT_NONE)) >- CRASH(); >-#elif HAVE(MADV_FREE_REUSE) >- while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } >-#elif HAVE(MADV_FREE) >- while (madvise(address, bytes, MADV_FREE) == -1 && errno == EAGAIN) { } >-#elif HAVE(MADV_DONTNEED) >- while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } >-#else >- UNUSED_PARAM(address); >- UNUSED_PARAM(bytes); >-#endif >-} >- >-void OSAllocator::hintMemoryNotNeededSoon(void* address, size_t bytes) >-{ >-#if HAVE(MADV_DONTNEED) >- while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } >-#else >- UNUSED_PARAM(address); >- UNUSED_PARAM(bytes); >-#endif >-} >- >-void OSAllocator::releaseDecommitted(void* address, size_t bytes) >-{ >- int result = munmap(address, bytes); >- if (result == -1) >- CRASH(); >-} >- >-} // namespace WTF >- >-#endif // OS(UNIX) >diff --git a/Source/WTF/wtf/OSAllocatorWin.cpp b/Source/WTF/wtf/OSAllocatorWin.cpp >deleted file mode 100644 >index d615498c994fca5d8b51954c5f652543a97c4b74..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/OSAllocatorWin.cpp >+++ /dev/null >@@ -1,102 +0,0 @@ >-/* >- * Copyright (C) 2010, 2014 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >- * THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include <wtf/OSAllocator.h> >- >-#if OS(WINDOWS) >- >-#include <wtf/Assertions.h> >-#include <windows.h> >- >-namespace WTF { >- >-static inline DWORD protection(bool writable, bool executable) >-{ >- return executable ? >- (writable ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ) : >- (writable ? PAGE_READWRITE : PAGE_READONLY); >-} >- >-void* OSAllocator::reserveUncommitted(size_t bytes, Usage, bool writable, bool executable, bool) >-{ >- void* result = VirtualAlloc(0, bytes, MEM_RESERVE, protection(writable, executable)); >- if (!result) >- CRASH(); >- return result; >-} >- >-void* OSAllocator::reserveAndCommit(size_t bytes, Usage, bool writable, bool executable, bool) >-{ >- void* result = VirtualAlloc(0, bytes, MEM_RESERVE | MEM_COMMIT, protection(writable, executable)); >- if (!result) >- CRASH(); >- return result; >-} >- >-void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) >-{ >- void* result = VirtualAlloc(address, bytes, MEM_COMMIT, protection(writable, executable)); >- if (!result) >- CRASH(); >-} >- >-void OSAllocator::decommit(void* address, size_t bytes) >-{ >- // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx, >- // bytes (i.e. dwSize) being 0 when dwFreeType is MEM_DECOMMIT means that we'll >- // decommit the entire region allocated by VirtualAlloc() instead of decommitting >- // nothing as we would expect. Hence, we should check if bytes is 0 and handle it >- // appropriately before calling VirtualFree(). >- // See: https://bugs.webkit.org/show_bug.cgi?id=121972. >- if (!bytes) >- return; >- // Silence warning about using MEM_DECOMMIT instead of MEM_RELEASE: >-#pragma warning(suppress: 6250) >- bool result = VirtualFree(address, bytes, MEM_DECOMMIT); >- if (!result) >- CRASH(); >-} >- >-void OSAllocator::releaseDecommitted(void* address, size_t bytes) >-{ >- // See comment in OSAllocator::decommit(). Similarly, when bytes is 0, we >- // don't want to release anything. So, don't call VirtualFree() below. >- if (!bytes) >- return; >- // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx, >- // dwSize must be 0 if dwFreeType is MEM_RELEASE. >- bool result = VirtualFree(address, 0, MEM_RELEASE); >- if (!result) >- CRASH(); >-} >- >-void OSAllocator::hintMemoryNotNeededSoon(void*, size_t) >-{ >-} >- >-} // namespace WTF >- >-#endif // OS(WINDOWS) >diff --git a/Source/WTF/wtf/PlatformGTK.cmake b/Source/WTF/wtf/PlatformGTK.cmake >index 7fec12dc2fc315bc5168f02b3bf76470c0d9cbad..297d0fa2c78f3961b0f4c3e17193fba6e5e4a3f5 100644 >--- a/Source/WTF/wtf/PlatformGTK.cmake >+++ b/Source/WTF/wtf/PlatformGTK.cmake >@@ -28,6 +28,9 @@ list(APPEND WTF_SOURCES > glib/RunLoopGLib.cpp > glib/URLGLib.cpp > >+ posix/OSAllocatorPOSIX.cpp >+ posix/ThreadingPOSIX.cpp >+ > text/unix/TextBreakIteratorInternalICUUnix.cpp > > unix/CPUTimeUnix.cpp >diff --git a/Source/WTF/wtf/PlatformJSCOnly.cmake b/Source/WTF/wtf/PlatformJSCOnly.cmake >index ebaf6ba7a3f4b876b3b43835480f78d6713907f8..3542fef6f90ee0a65891b3a37606545c9ac77c41 100644 >--- a/Source/WTF/wtf/PlatformJSCOnly.cmake >+++ b/Source/WTF/wtf/PlatformJSCOnly.cmake >@@ -11,7 +11,10 @@ if (WIN32) > win/FileSystemWin.cpp > win/LanguageWin.cpp > win/MainThreadWin.cpp >+ win/OSAllocatorWin.cpp > win/PathWalker.cpp >+ win/ThreadSpecificWin.cpp >+ win/ThreadingWin.cpp > ) > list(APPEND WTF_PUBLIC_HEADERS > win/DbgHelperWin.h >@@ -20,7 +23,9 @@ if (WIN32) > text/win/WCharStringExtras.h > ) > list(APPEND WTF_LIBRARIES >+ DbgHelp > shlwapi >+ winmm > ) > else () > list(APPEND WTF_SOURCES >@@ -29,6 +34,8 @@ else () > generic/MainThreadGeneric.cpp > > posix/FileSystemPOSIX.cpp >+ posix/OSAllocatorPOSIX.cpp >+ posix/ThreadingPOSIX.cpp > > text/unix/TextBreakIteratorInternalICUUnix.cpp > >diff --git a/Source/WTF/wtf/PlatformMac.cmake b/Source/WTF/wtf/PlatformMac.cmake >index 0e3e14160912b78617734350a925d99dba2cda01..9a1f510b409f10e0232f1f1e0e2e2e59df14cb16 100644 >--- a/Source/WTF/wtf/PlatformMac.cmake >+++ b/Source/WTF/wtf/PlatformMac.cmake >@@ -39,14 +39,13 @@ list(APPEND WTF_PUBLIC_HEADERS > > list(APPEND WTF_SOURCES > BlockObjCExceptions.mm >- RunLoopTimerCF.cpp >- SchedulePairCF.cpp >- SchedulePairMac.mm > > cf/CFURLExtras.cpp > cf/FileSystemCF.cpp > cf/LanguageCF.cpp > cf/RunLoopCF.cpp >+ cf/RunLoopTimerCF.cpp >+ cf/SchedulePairCF.cpp > cf/URLCF.cpp > > cocoa/AutodrainedPool.cpp >@@ -63,8 +62,11 @@ list(APPEND WTF_SOURCES > > mac/DeprecatedSymbolsUsedBySafari.mm > mac/FileSystemMac.mm >+ mac/SchedulePairMac.mm > > posix/FileSystemPOSIX.cpp >+ posix/OSAllocatorPOSIX.cpp >+ posix/ThreadingPOSIX.cpp > > text/cf/AtomicStringImplCF.cpp > text/cf/StringCF.cpp >diff --git a/Source/WTF/wtf/PlatformPlayStation.cmake b/Source/WTF/wtf/PlatformPlayStation.cmake >index 3e9e75c928a6c94605b4bfcaa7fbb2b9f42f8390..4b6919076f391051b85e39b06f215dc9ab458681 100644 >--- a/Source/WTF/wtf/PlatformPlayStation.cmake >+++ b/Source/WTF/wtf/PlatformPlayStation.cmake >@@ -6,6 +6,8 @@ list(APPEND WTF_SOURCES > generic/WorkQueueGeneric.cpp > > posix/FileSystemPOSIX.cpp >+ posix/OSAllocatorPOSIX.cpp >+ posix/ThreadingPOSIX.cpp > > text/unix/TextBreakIteratorInternalICUUnix.cpp > >diff --git a/Source/WTF/wtf/PlatformWPE.cmake b/Source/WTF/wtf/PlatformWPE.cmake >index 086add3aa919fc49239d71c1cc8685c5fc739bd4..38e632c3ef8b3137aa9711990e71455fbaa032cc 100644 >--- a/Source/WTF/wtf/PlatformWPE.cmake >+++ b/Source/WTF/wtf/PlatformWPE.cmake >@@ -26,6 +26,9 @@ list(APPEND WTF_SOURCES > linux/MemoryFootprintLinux.cpp > linux/MemoryPressureHandlerLinux.cpp > >+ posix/OSAllocatorPOSIX.cpp >+ posix/ThreadingPOSIX.cpp >+ > text/unix/TextBreakIteratorInternalICUUnix.cpp > > unix/CPUTimeUnix.cpp >diff --git a/Source/WTF/wtf/PlatformWin.cmake b/Source/WTF/wtf/PlatformWin.cmake >index b6c0ac6f4de5e05f27d4d9ac0ffbd5cc4097a6e3..2c34022549d8840eb9230284a1ddd9d285239aae 100644 >--- a/Source/WTF/wtf/PlatformWin.cmake >+++ b/Source/WTF/wtf/PlatformWin.cmake >@@ -17,13 +17,18 @@ list(APPEND WTF_SOURCES > win/MainThreadWin.cpp > win/MemoryFootprintWin.cpp > win/MemoryPressureHandlerWin.cpp >+ win/OSAllocatorWin.cpp > win/PathWalker.cpp > win/RunLoopWin.cpp >+ win/ThreadSpecificWin.cpp >+ win/ThreadingWin.cpp > win/WorkQueueWin.cpp > ) > > list(APPEND WTF_LIBRARIES >+ DbgHelp > shlwapi >+ winmm > ) > > if (USE_CF) >diff --git a/Source/WTF/wtf/RunLoopTimerCF.cpp b/Source/WTF/wtf/RunLoopTimerCF.cpp >deleted file mode 100644 >index 7418fdd3ea27dbf8940502e90d9143b528352a85..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/RunLoopTimerCF.cpp >+++ /dev/null >@@ -1,92 +0,0 @@ >-/* >- * Copyright (C) 2009, 2013 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * 3. Neither the name of Apple Inc. ("Apple") nor the names of >- * its contributors may be used to endorse or promote products derived >- * from this software without specific prior written permission. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >- >-#if PLATFORM(COCOA) && HAVE(RUNLOOP_TIMER) >- >-#include <wtf/RunLoopTimer.h> >- >-#include <wtf/AutodrainedPool.h> >- >-namespace WTF { >- >-RunLoopTimerBase::~RunLoopTimerBase() >-{ >- stop(); >-} >- >-static void timerFired(CFRunLoopTimerRef, void* context) >-{ >- // CFRunLoopTimer does not create an NSAutoreleasePool, like NSTimer does. This can lead to >- // autoreleased objects being pushed into NSAutoreleasePools underneath the run loop, which >- // are very infrequently drained. Create a new autorelease pool here to give autoreleased objects >- // a place to collect. >- AutodrainedPool pool; >- RunLoopTimerBase* timer = static_cast<RunLoopTimerBase*>(context); >- timer->fired(); >-} >- >-void RunLoopTimerBase::start(Seconds nextFireInterval, Seconds repeatInterval) >-{ >- if (m_timer) >- CFRunLoopTimerInvalidate(m_timer.get()); >- CFRunLoopTimerContext context = { 0, this, 0, 0, 0 }; >- m_timer = adoptCF(CFRunLoopTimerCreate(0, CFAbsoluteTimeGetCurrent() + nextFireInterval.seconds(), repeatInterval.seconds(), 0, 0, timerFired, &context)); >-} >- >-void RunLoopTimerBase::schedule(const SchedulePair* schedulePair) >-{ >- ASSERT_ARG(schedulePair, schedulePair); >- ASSERT_WITH_MESSAGE(m_timer, "Timer must have one of the start functions called before calling schedule()."); >- CFRunLoopAddTimer(schedulePair->runLoop(), m_timer.get(), schedulePair->mode()); >-} >- >-void RunLoopTimerBase::schedule(const SchedulePairHashSet& schedulePairs) >-{ >- SchedulePairHashSet::const_iterator end = schedulePairs.end(); >- for (SchedulePairHashSet::const_iterator it = schedulePairs.begin(); it != end; ++it) >- schedule((*it).get()); >-} >- >-void RunLoopTimerBase::stop() >-{ >- if (!m_timer) >- return; >- CFRunLoopTimerInvalidate(m_timer.get()); >- m_timer = 0; >-} >- >-bool RunLoopTimerBase::isActive() const >-{ >- return m_timer && CFRunLoopTimerIsValid(m_timer.get()); >-} >- >-} // namespace WTF >- >-#endif // PLATFORM(COCOA) && HAVE(RUNLOOP_TIMER) >diff --git a/Source/WTF/wtf/SchedulePairCF.cpp b/Source/WTF/wtf/SchedulePairCF.cpp >deleted file mode 100644 >index 46f65c33f00b7da152f80e5268f04730135cca35..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/SchedulePairCF.cpp >+++ /dev/null >@@ -1,45 +0,0 @@ >-/* >- * Copyright (C) 2008, 2013 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * 3. Neither the name of Apple Inc. ("Apple") nor the names of >- * its contributors may be used to endorse or promote products derived >- * from this software without specific prior written permission. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include <wtf/SchedulePair.h> >- >-namespace WTF { >- >-bool SchedulePair::operator==(const SchedulePair& other) const >-{ >- if (runLoop() != other.runLoop()) >- return false; >- CFStringRef thisMode = mode(); >- CFStringRef otherMode = other.mode(); >- if (!thisMode || !otherMode) >- return thisMode == otherMode; >- return CFEqual(thisMode, otherMode); >-} >- >-} // namespace >diff --git a/Source/WTF/wtf/SchedulePairMac.mm b/Source/WTF/wtf/SchedulePairMac.mm >deleted file mode 100644 >index 62261ad3f9d6a661203bdb1416c318eb2e4ee77a..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/SchedulePairMac.mm >+++ /dev/null >@@ -1,42 +0,0 @@ >-/* >- * Copyright (C) 2008, 2013 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * 3. Neither the name of Apple Inc. ("Apple") nor the names of >- * its contributors may be used to endorse or promote products derived >- * from this software without specific prior written permission. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include <wtf/SchedulePair.h> >- >-namespace WTF { >- >-SchedulePair::SchedulePair(NSRunLoop* runLoop, CFStringRef mode) >- : m_nsRunLoop(runLoop) >- , m_runLoop([runLoop getCFRunLoop]) >-{ >- if (mode) >- m_mode = adoptCF(CFStringCreateCopy(0, mode)); >-} >- >-} // namespace >diff --git a/Source/WTF/wtf/ThreadSpecificWin.cpp b/Source/WTF/wtf/ThreadSpecificWin.cpp >deleted file mode 100644 >index ae7ae847cbabfc40362872ca3606dbfa09127fde..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/ThreadSpecificWin.cpp >+++ /dev/null >@@ -1,47 +0,0 @@ >-/* >- * Copyright (C) 2009 Jian Li <jianli@chromium.org> >- * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com> >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- * >- */ >- >-#include "config.h" >-#include <wtf/ThreadSpecific.h> >- >-#if OS(WINDOWS) >- >-#if !USE(PTHREADS) >- >-namespace WTF { >- >-long& flsKeyCount() >-{ >- static long count; >- return count; >-} >- >-DWORD* flsKeys() >-{ >- static DWORD keys[kMaxFlsKeySize]; >- return keys; >-} >- >-} // namespace WTF >- >-#endif // !USE(PTHREADS) >- >-#endif // OS(WINDOWS) >diff --git a/Source/WTF/wtf/ThreadingPthreads.cpp b/Source/WTF/wtf/ThreadingPthreads.cpp >deleted file mode 100644 >index e48dd9b57edd4cf55f25331645823f3109da4221..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/ThreadingPthreads.cpp >+++ /dev/null >@@ -1,565 +0,0 @@ >-/* >- * Copyright (C) 2007, 2009, 2015 Apple Inc. All rights reserved. >- * Copyright (C) 2007 Justin Haygood <jhaygood@reaktix.com> >- * Copyright (C) 2011 Research In Motion Limited. All rights reserved. >- * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com> >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * 3. Neither the name of Apple Inc. ("Apple") nor the names of >- * its contributors may be used to endorse or promote products derived >- * from this software without specific prior written permission. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include <wtf/Threading.h> >- >-#if USE(PTHREADS) >- >-#include <errno.h> >-#include <wtf/DataLog.h> >-#include <wtf/NeverDestroyed.h> >-#include <wtf/RawPointer.h> >-#include <wtf/StdLibExtras.h> >-#include <wtf/ThreadGroup.h> >-#include <wtf/ThreadingPrimitives.h> >-#include <wtf/WordLock.h> >- >-#if OS(LINUX) >-#include <sys/prctl.h> >-#endif >- >-#if !COMPILER(MSVC) >-#include <limits.h> >-#include <sched.h> >-#include <sys/time.h> >-#endif >- >-#if !OS(DARWIN) && OS(UNIX) >- >-#include <semaphore.h> >-#include <sys/mman.h> >-#include <unistd.h> >-#include <pthread.h> >- >-#if HAVE(PTHREAD_NP_H) >-#include <pthread_np.h> >-#endif >- >-#endif >- >-namespace WTF { >- >-static Lock globalSuspendLock; >- >-Thread::~Thread() >-{ >-} >- >-#if !OS(DARWIN) >-class Semaphore { >- WTF_MAKE_NONCOPYABLE(Semaphore); >- WTF_MAKE_FAST_ALLOCATED; >-public: >- explicit Semaphore(unsigned initialValue) >- { >- int sharedBetweenProcesses = 0; >- sem_init(&m_platformSemaphore, sharedBetweenProcesses, initialValue); >- } >- >- ~Semaphore() >- { >- sem_destroy(&m_platformSemaphore); >- } >- >- void wait() >- { >- sem_wait(&m_platformSemaphore); >- } >- >- void post() >- { >- sem_post(&m_platformSemaphore); >- } >- >-private: >- sem_t m_platformSemaphore; >-}; >-static LazyNeverDestroyed<Semaphore> globalSemaphoreForSuspendResume; >- >-// We use SIGUSR1 to suspend and resume machine threads in JavaScriptCore. >-static constexpr const int SigThreadSuspendResume = SIGUSR1; >-static std::atomic<Thread*> targetThread { nullptr }; >- >-void Thread::signalHandlerSuspendResume(int, siginfo_t*, void* ucontext) >-{ >- // Touching a global variable atomic types from signal handlers is allowed. >- Thread* thread = targetThread.load(); >- >- if (thread->m_suspendCount) { >- // This is signal handler invocation that is intended to be used to resume sigsuspend. >- // So this handler invocation itself should not process. >- // >- // When signal comes, first, the system calls signal handler. And later, sigsuspend will be resumed. Signal handler invocation always precedes. >- // So, the problem never happens that suspended.store(true, ...) will be executed before the handler is called. >- // http://pubs.opengroup.org/onlinepubs/009695399/functions/sigsuspend.html >- return; >- } >- >- void* approximateStackPointer = currentStackPointer(); >- if (!thread->m_stack.contains(approximateStackPointer)) { >- // This happens if we use an alternative signal stack. >- // 1. A user-defined signal handler is invoked with an alternative signal stack. >- // 2. In the middle of the execution of the handler, we attempt to suspend the target thread. >- // 3. A nested signal handler is executed. >- // 4. The stack pointer saved in the machine context will be pointing to the alternative signal stack. >- // In this case, we back off the suspension and retry a bit later. >- thread->m_platformRegisters = nullptr; >- globalSemaphoreForSuspendResume->post(); >- return; >- } >- >-#if HAVE(MACHINE_CONTEXT) >- ucontext_t* userContext = static_cast<ucontext_t*>(ucontext); >- thread->m_platformRegisters = ®istersFromUContext(userContext); >-#else >- UNUSED_PARAM(ucontext); >- PlatformRegisters platformRegisters { approximateStackPointer }; >- thread->m_platformRegisters = &platformRegisters; >-#endif >- >- // Allow suspend caller to see that this thread is suspended. >- // sem_post is async-signal-safe function. It means that we can call this from a signal handler. >- // http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03 >- // >- // And sem_post emits memory barrier that ensures that PlatformRegisters are correctly saved. >- // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_11 >- globalSemaphoreForSuspendResume->post(); >- >- // Reaching here, SigThreadSuspendResume is blocked in this handler (this is configured by sigaction's sa_mask). >- // So before calling sigsuspend, SigThreadSuspendResume to this thread is deferred. This ensures that the handler is not executed recursively. >- sigset_t blockedSignalSet; >- sigfillset(&blockedSignalSet); >- sigdelset(&blockedSignalSet, SigThreadSuspendResume); >- sigsuspend(&blockedSignalSet); >- >- thread->m_platformRegisters = nullptr; >- >- // Allow resume caller to see that this thread is resumed. >- globalSemaphoreForSuspendResume->post(); >-} >- >-#endif // !OS(DARWIN) >- >-void Thread::initializePlatformThreading() >-{ >-#if !OS(DARWIN) >- globalSemaphoreForSuspendResume.construct(0); >- >- // Signal handlers are process global configuration. >- // Intentionally block SigThreadSuspendResume in the handler. >- // SigThreadSuspendResume will be allowed in the handler by sigsuspend. >- struct sigaction action; >- sigemptyset(&action.sa_mask); >- sigaddset(&action.sa_mask, SigThreadSuspendResume); >- >- action.sa_sigaction = &signalHandlerSuspendResume; >- action.sa_flags = SA_RESTART | SA_SIGINFO; >- sigaction(SigThreadSuspendResume, &action, 0); >-#endif >-} >- >-void Thread::initializeCurrentThreadEvenIfNonWTFCreated() >-{ >-#if !OS(DARWIN) >- sigset_t mask; >- sigemptyset(&mask); >- sigaddset(&mask, SigThreadSuspendResume); >- pthread_sigmask(SIG_UNBLOCK, &mask, 0); >-#endif >-} >- >-static void* wtfThreadEntryPoint(void* context) >-{ >- Thread::entryPoint(reinterpret_cast<Thread::NewThreadContext*>(context)); >- return nullptr; >-} >- >-bool Thread::establishHandle(NewThreadContext* context) >-{ >- pthread_t threadHandle; >- pthread_attr_t attr; >- pthread_attr_init(&attr); >-#if HAVE(QOS_CLASSES) >- pthread_attr_set_qos_class_np(&attr, adjustedQOSClass(QOS_CLASS_USER_INITIATED), 0); >-#endif >- int error = pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, context); >- pthread_attr_destroy(&attr); >- if (error) { >- LOG_ERROR("Failed to create pthread at entry point %p with context %p", wtfThreadEntryPoint, context); >- return false; >- } >- establishPlatformSpecificHandle(threadHandle); >- return true; >-} >- >-void Thread::initializeCurrentThreadInternal(const char* threadName) >-{ >-#if HAVE(PTHREAD_SETNAME_NP) >- pthread_setname_np(normalizeThreadName(threadName)); >-#elif OS(LINUX) >- prctl(PR_SET_NAME, normalizeThreadName(threadName)); >-#else >- UNUSED_PARAM(threadName); >-#endif >- initializeCurrentThreadEvenIfNonWTFCreated(); >-} >- >-void Thread::changePriority(int delta) >-{ >-#if HAVE(PTHREAD_SETSCHEDPARAM) >- auto locker = holdLock(m_mutex); >- >- int policy; >- struct sched_param param; >- >- if (pthread_getschedparam(m_handle, &policy, ¶m)) >- return; >- >- param.sched_priority += delta; >- >- pthread_setschedparam(m_handle, policy, ¶m); >-#endif >-} >- >-int Thread::waitForCompletion() >-{ >- pthread_t handle; >- { >- auto locker = holdLock(m_mutex); >- handle = m_handle; >- } >- >- int joinResult = pthread_join(handle, 0); >- >- if (joinResult == EDEADLK) >- LOG_ERROR("Thread %p was found to be deadlocked trying to quit", this); >- else if (joinResult) >- LOG_ERROR("Thread %p was unable to be joined.\n", this); >- >- auto locker = holdLock(m_mutex); >- ASSERT(joinableState() == Joinable); >- >- // If the thread has already exited, then do nothing. If the thread hasn't exited yet, then just signal that we've already joined on it. >- // In both cases, Thread::destructTLS() will take care of destroying Thread. >- if (!hasExited()) >- didJoin(); >- >- return joinResult; >-} >- >-void Thread::detach() >-{ >- auto locker = holdLock(m_mutex); >- int detachResult = pthread_detach(m_handle); >- if (detachResult) >- LOG_ERROR("Thread %p was unable to be detached\n", this); >- >- if (!hasExited()) >- didBecomeDetached(); >-} >- >-Thread& Thread::initializeCurrentTLS() >-{ >- // Not a WTF-created thread, Thread is not established yet. >- Ref<Thread> thread = adoptRef(*new Thread()); >- thread->establishPlatformSpecificHandle(pthread_self()); >- thread->initializeInThread(); >- initializeCurrentThreadEvenIfNonWTFCreated(); >- >- return initializeTLS(WTFMove(thread)); >-} >- >-bool Thread::signal(int signalNumber) >-{ >- auto locker = holdLock(m_mutex); >- if (hasExited()) >- return false; >- int errNo = pthread_kill(m_handle, signalNumber); >- return !errNo; // A 0 errNo means success. >-} >- >-auto Thread::suspend() -> Expected<void, PlatformSuspendError> >-{ >- RELEASE_ASSERT_WITH_MESSAGE(this != &Thread::current(), "We do not support suspending the current thread itself."); >- // During suspend, suspend or resume should not be executed from the other threads. >- // We use global lock instead of per thread lock. >- // Consider the following case, there are threads A and B. >- // And A attempt to suspend B and B attempt to suspend A. >- // A and B send signals. And later, signals are delivered to A and B. >- // In that case, both will be suspended. >- // >- // And it is important to use a global lock to suspend and resume. Let's consider using per-thread lock. >- // Your issuing thread (A) attempts to suspend the target thread (B). Then, you will suspend the thread (C) additionally. >- // This case frequently happens if you stop threads to perform stack scanning. But thread (B) may hold the lock of thread (C). >- // In that case, dead lock happens. Using global lock here avoids this dead lock. >- LockHolder locker(globalSuspendLock); >-#if OS(DARWIN) >- kern_return_t result = thread_suspend(m_platformThread); >- if (result != KERN_SUCCESS) >- return makeUnexpected(result); >- return { }; >-#else >- if (!m_suspendCount) { >- // Ideally, we would like to use pthread_sigqueue. It allows us to pass the argument to the signal handler. >- // But it can be used in a few platforms, like Linux. >- // Instead, we use Thread* stored in a global variable to pass it to the signal handler. >- targetThread.store(this); >- >- while (true) { >- int result = pthread_kill(m_handle, SigThreadSuspendResume); >- if (result) >- return makeUnexpected(result); >- globalSemaphoreForSuspendResume->wait(); >- if (m_platformRegisters) >- break; >- // Because of an alternative signal stack, we failed to suspend this thread. >- // Retry suspension again after yielding. >- Thread::yield(); >- } >- } >- ++m_suspendCount; >- return { }; >-#endif >-} >- >-void Thread::resume() >-{ >- // During resume, suspend or resume should not be executed from the other threads. >- LockHolder locker(globalSuspendLock); >-#if OS(DARWIN) >- thread_resume(m_platformThread); >-#else >- if (m_suspendCount == 1) { >- // When allowing SigThreadSuspendResume interrupt in the signal handler by sigsuspend and SigThreadSuspendResume is actually issued, >- // the signal handler itself will be called once again. >- // There are several ways to distinguish the handler invocation for suspend and resume. >- // 1. Use different signal numbers. And check the signal number in the handler. >- // 2. Use some arguments to distinguish suspend and resume in the handler. If pthread_sigqueue can be used, we can take this. >- // 3. Use thread's flag. >- // In this implementaiton, we take (3). m_suspendCount is used to distinguish it. >- targetThread.store(this); >- if (pthread_kill(m_handle, SigThreadSuspendResume) == ESRCH) >- return; >- globalSemaphoreForSuspendResume->wait(); >- } >- --m_suspendCount; >-#endif >-} >- >-#if OS(DARWIN) >-struct ThreadStateMetadata { >- unsigned userCount; >- thread_state_flavor_t flavor; >-}; >- >-static ThreadStateMetadata threadStateMetadata() >-{ >-#if CPU(X86) >- unsigned userCount = sizeof(PlatformRegisters) / sizeof(int); >- thread_state_flavor_t flavor = i386_THREAD_STATE; >-#elif CPU(X86_64) >- unsigned userCount = x86_THREAD_STATE64_COUNT; >- thread_state_flavor_t flavor = x86_THREAD_STATE64; >-#elif CPU(PPC) >- unsigned userCount = PPC_THREAD_STATE_COUNT; >- thread_state_flavor_t flavor = PPC_THREAD_STATE; >-#elif CPU(PPC64) >- unsigned userCount = PPC_THREAD_STATE64_COUNT; >- thread_state_flavor_t flavor = PPC_THREAD_STATE64; >-#elif CPU(ARM) >- unsigned userCount = ARM_THREAD_STATE_COUNT; >- thread_state_flavor_t flavor = ARM_THREAD_STATE; >-#elif CPU(ARM64) >- unsigned userCount = ARM_THREAD_STATE64_COUNT; >- thread_state_flavor_t flavor = ARM_THREAD_STATE64; >-#else >-#error Unknown Architecture >-#endif >- return ThreadStateMetadata { userCount, flavor }; >-} >-#endif // OS(DARWIN) >- >-size_t Thread::getRegisters(PlatformRegisters& registers) >-{ >- LockHolder locker(globalSuspendLock); >-#if OS(DARWIN) >- auto metadata = threadStateMetadata(); >- kern_return_t result = thread_get_state(m_platformThread, metadata.flavor, (thread_state_t)®isters, &metadata.userCount); >- if (result != KERN_SUCCESS) { >- WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, "JavaScript garbage collection failed because thread_get_state returned an error (%d). This is probably the result of running inside Rosetta, which is not supported.", result); >- CRASH(); >- } >- return metadata.userCount * sizeof(uintptr_t); >-#else >- ASSERT_WITH_MESSAGE(m_suspendCount, "We can get registers only if the thread is suspended."); >- ASSERT(m_platformRegisters); >- registers = *m_platformRegisters; >- return sizeof(PlatformRegisters); >-#endif >-} >- >-void Thread::establishPlatformSpecificHandle(pthread_t handle) >-{ >- auto locker = holdLock(m_mutex); >- m_handle = handle; >-#if OS(DARWIN) >- m_platformThread = pthread_mach_thread_np(handle); >-#endif >-} >- >-#if !HAVE(FAST_TLS) >-void Thread::initializeTLSKey() >-{ >- threadSpecificKeyCreate(&s_key, destructTLS); >-} >-#endif >- >-Thread& Thread::initializeTLS(Ref<Thread>&& thread) >-{ >- // We leak the ref to keep the Thread alive while it is held in TLS. destructTLS will deref it later at thread destruction time. >- auto& threadInTLS = thread.leakRef(); >-#if !HAVE(FAST_TLS) >- ASSERT(s_key != InvalidThreadSpecificKey); >- threadSpecificSet(s_key, &threadInTLS); >-#else >- _pthread_setspecific_direct(WTF_THREAD_DATA_KEY, &threadInTLS); >- pthread_key_init_np(WTF_THREAD_DATA_KEY, &destructTLS); >-#endif >- return threadInTLS; >-} >- >-void Thread::destructTLS(void* data) >-{ >- Thread* thread = static_cast<Thread*>(data); >- ASSERT(thread); >- >- if (thread->m_isDestroyedOnce) { >- thread->didExit(); >- thread->deref(); >- return; >- } >- >- thread->m_isDestroyedOnce = true; >- // Re-setting the value for key causes another destructTLS() call after all other thread-specific destructors were called. >-#if !HAVE(FAST_TLS) >- ASSERT(s_key != InvalidThreadSpecificKey); >- threadSpecificSet(s_key, thread); >-#else >- _pthread_setspecific_direct(WTF_THREAD_DATA_KEY, thread); >- pthread_key_init_np(WTF_THREAD_DATA_KEY, &destructTLS); >-#endif >-} >- >-Mutex::~Mutex() >-{ >- int result = pthread_mutex_destroy(&m_mutex); >- ASSERT_UNUSED(result, !result); >-} >- >-void Mutex::lock() >-{ >- int result = pthread_mutex_lock(&m_mutex); >- ASSERT_UNUSED(result, !result); >-} >- >-bool Mutex::tryLock() >-{ >- int result = pthread_mutex_trylock(&m_mutex); >- >- if (result == 0) >- return true; >- if (result == EBUSY) >- return false; >- >- ASSERT_NOT_REACHED(); >- return false; >-} >- >-void Mutex::unlock() >-{ >- int result = pthread_mutex_unlock(&m_mutex); >- ASSERT_UNUSED(result, !result); >-} >- >-ThreadCondition::~ThreadCondition() >-{ >- pthread_cond_destroy(&m_condition); >-} >- >-void ThreadCondition::wait(Mutex& mutex) >-{ >- int result = pthread_cond_wait(&m_condition, &mutex.impl()); >- ASSERT_UNUSED(result, !result); >-} >- >-bool ThreadCondition::timedWait(Mutex& mutex, WallTime absoluteTime) >-{ >- if (absoluteTime < WallTime::now()) >- return false; >- >- if (absoluteTime > WallTime::fromRawSeconds(INT_MAX)) { >- wait(mutex); >- return true; >- } >- >- double rawSeconds = absoluteTime.secondsSinceEpoch().value(); >- >- int timeSeconds = static_cast<int>(rawSeconds); >- int timeNanoseconds = static_cast<int>((rawSeconds - timeSeconds) * 1E9); >- >- timespec targetTime; >- targetTime.tv_sec = timeSeconds; >- targetTime.tv_nsec = timeNanoseconds; >- >- return pthread_cond_timedwait(&m_condition, &mutex.impl(), &targetTime) == 0; >-} >- >-void ThreadCondition::signal() >-{ >- int result = pthread_cond_signal(&m_condition); >- ASSERT_UNUSED(result, !result); >-} >- >-void ThreadCondition::broadcast() >-{ >- int result = pthread_cond_broadcast(&m_condition); >- ASSERT_UNUSED(result, !result); >-} >- >-void Thread::yield() >-{ >- sched_yield(); >-} >- >-} // namespace WTF >- >-#endif // USE(PTHREADS) >diff --git a/Source/WTF/wtf/ThreadingWin.cpp b/Source/WTF/wtf/ThreadingWin.cpp >deleted file mode 100644 >index 10d46ac8ad8c9471a933ac7816298705071a2e02..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/ThreadingWin.cpp >+++ /dev/null >@@ -1,464 +0,0 @@ >-/* >- * Copyright (C) 2007, 2008, 2015 Apple Inc. All rights reserved. >- * Copyright (C) 2009 Google Inc. All rights reserved. >- * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * 3. Neither the name of Apple Inc. ("Apple") nor the names of >- * its contributors may be used to endorse or promote products derived >- * from this software without specific prior written permission. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-/* >- * There are numerous academic and practical works on how to implement pthread_cond_wait/pthread_cond_signal/pthread_cond_broadcast >- * functions on Win32. Here is one example: http://www.cs.wustl.edu/~schmidt/win32-cv-1.html which is widely credited as a 'starting point' >- * of modern attempts. There are several more or less proven implementations, one in Boost C++ library (http://www.boost.org) and another >- * in pthreads-win32 (http://sourceware.org/pthreads-win32/). >- * >- * The number of articles and discussions is the evidence of significant difficulties in implementing these primitives correctly. >- * The brief search of revisions, ChangeLog entries, discussions in comp.programming.threads and other places clearly documents >- * numerous pitfalls and performance problems the authors had to overcome to arrive to the suitable implementations. >- * Optimally, WebKit would use one of those supported/tested libraries directly. To roll out our own implementation is impractical, >- * if even for the lack of sufficient testing. However, a faithful reproduction of the code from one of the popular supported >- * libraries seems to be a good compromise. >- * >- * The early Boost implementation (http://www.boxbackup.org/trac/browser/box/nick/win/lib/win32/boost_1_32_0/libs/thread/src/condition.cpp?rev=30) >- * is identical to pthreads-win32 (http://sourceware.org/cgi-bin/cvsweb.cgi/pthreads/pthread_cond_wait.c?rev=1.10&content-type=text/x-cvsweb-markup&cvsroot=pthreads-win32). >- * Current Boost uses yet another (although seemingly equivalent) algorithm which came from their 'thread rewrite' effort. >- * >- * This file includes timedWait/signal/broadcast implementations translated to WebKit coding style from the latest algorithm by >- * Alexander Terekhov and Louis Thomas, as captured here: http://sourceware.org/cgi-bin/cvsweb.cgi/pthreads/pthread_cond_wait.c?rev=1.10&content-type=text/x-cvsweb-markup&cvsroot=pthreads-win32 >- * It replaces the implementation of their previous algorithm, also documented in the same source above. >- * The naming and comments are left very close to original to enable easy cross-check. >- * >- * The corresponding Pthreads-win32 License is included below, and CONTRIBUTORS file which it refers to is added to >- * source directory (as CONTRIBUTORS.pthreads-win32). >- */ >- >-/* >- * Pthreads-win32 - POSIX Threads Library for Win32 >- * Copyright(C) 1998 John E. Bossom >- * Copyright(C) 1999,2005 Pthreads-win32 contributors >- * >- * Contact Email: rpj@callisto.canberra.edu.au >- * >- * The current list of contributors is contained >- * in the file CONTRIBUTORS included with the source >- * code distribution. The list can also be seen at the >- * following World Wide Web location: >- * http://sources.redhat.com/pthreads-win32/contributors.html >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Lesser General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Lesser General Public License for more details. >- * >- * You should have received a copy of the GNU Lesser General Public >- * License along with this library in the file COPYING.LIB; >- * if not, write to the Free Software Foundation, Inc., >- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA >- */ >- >-#include "config.h" >-#include <wtf/Threading.h> >- >-#if OS(WINDOWS) >- >-#include <errno.h> >-#include <process.h> >-#include <windows.h> >-#include <wtf/HashMap.h> >-#include <wtf/Lock.h> >-#include <wtf/MainThread.h> >-#include <wtf/MathExtras.h> >-#include <wtf/NeverDestroyed.h> >-#include <wtf/ThreadingPrimitives.h> >- >-namespace WTF { >- >-static Lock globalSuspendLock; >- >-Thread::~Thread() >-{ >- // It is OK because FLSAlloc's callback will be called even before there are some open handles. >- // This easily ensures that all the thread resources are automatically closed. >- if (m_handle != INVALID_HANDLE_VALUE) >- CloseHandle(m_handle); >-} >- >-void Thread::initializeCurrentThreadEvenIfNonWTFCreated() >-{ >-} >- >-// MS_VC_EXCEPTION, THREADNAME_INFO, and setThreadNameInternal all come from <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>. >-static const DWORD MS_VC_EXCEPTION = 0x406D1388; >- >-#pragma pack(push, 8) >-typedef struct tagTHREADNAME_INFO { >- DWORD dwType; // must be 0x1000 >- LPCSTR szName; // pointer to name (in user addr space) >- DWORD dwThreadID; // thread ID (-1=caller thread) >- DWORD dwFlags; // reserved for future use, must be zero >-} THREADNAME_INFO; >-#pragma pack(pop) >- >-void Thread::initializeCurrentThreadInternal(const char* szThreadName) >-{ >-#if COMPILER(MINGW) >- // FIXME: Implement thread name setting with MingW. >- UNUSED_PARAM(szThreadName); >-#else >- THREADNAME_INFO info; >- info.dwType = 0x1000; >- info.szName = Thread::normalizeThreadName(szThreadName); >- info.dwThreadID = GetCurrentThreadId(); >- info.dwFlags = 0; >- >- __try { >- RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), reinterpret_cast<ULONG_PTR*>(&info)); >- } __except (EXCEPTION_CONTINUE_EXECUTION) { >- } >-#endif >- initializeCurrentThreadEvenIfNonWTFCreated(); >-} >- >-void Thread::initializePlatformThreading() >-{ >-} >- >-static unsigned __stdcall wtfThreadEntryPoint(void* data) >-{ >- Thread::entryPoint(reinterpret_cast<Thread::NewThreadContext*>(data)); >- return 0; >-} >- >-bool Thread::establishHandle(NewThreadContext* data) >-{ >- unsigned threadIdentifier = 0; >- HANDLE threadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, wtfThreadEntryPoint, data, 0, &threadIdentifier)); >- if (!threadHandle) { >- LOG_ERROR("Failed to create thread at entry point %p with data %p: %ld", wtfThreadEntryPoint, data, errno); >- return false; >- } >- establishPlatformSpecificHandle(threadHandle, threadIdentifier); >- return true; >-} >- >-void Thread::changePriority(int delta) >-{ >- auto locker = holdLock(m_mutex); >- SetThreadPriority(m_handle, THREAD_PRIORITY_NORMAL + delta); >-} >- >-int Thread::waitForCompletion() >-{ >- HANDLE handle; >- { >- auto locker = holdLock(m_mutex); >- handle = m_handle; >- } >- >- DWORD joinResult = WaitForSingleObject(handle, INFINITE); >- if (joinResult == WAIT_FAILED) >- LOG_ERROR("Thread %p was found to be deadlocked trying to quit", this); >- >- auto locker = holdLock(m_mutex); >- ASSERT(joinableState() == Joinable); >- >- // The thread has already exited, do nothing. >- // The thread hasn't exited yet, so don't clean anything up. Just signal that we've already joined on it so that it will clean up after itself. >- if (!hasExited()) >- didJoin(); >- >- return joinResult; >-} >- >-void Thread::detach() >-{ >- // We follow the pthread semantics: even after the detach is called, >- // we can still perform various operations onto the thread. For example, >- // we can do pthread_kill for the detached thread. The problem in Windows >- // is that closing HANDLE loses the way to do such operations. >- // To do so, we do nothing here in Windows. Original detach's purpose, >- // releasing thread resource when the thread exits, will be achieved by >- // FlsCallback automatically. FlsCallback will call CloseHandle to clean up >- // resource. So in this function, we just mark the thread as detached to >- // avoid calling waitForCompletion for this thread. >- auto locker = holdLock(m_mutex); >- if (!hasExited()) >- didBecomeDetached(); >-} >- >-auto Thread::suspend() -> Expected<void, PlatformSuspendError> >-{ >- RELEASE_ASSERT_WITH_MESSAGE(this != &Thread::current(), "We do not support suspending the current thread itself."); >- LockHolder locker(globalSuspendLock); >- DWORD result = SuspendThread(m_handle); >- if (result != (DWORD)-1) >- return { }; >- return makeUnexpected(result); >-} >- >-// During resume, suspend or resume should not be executed from the other threads. >-void Thread::resume() >-{ >- LockHolder locker(globalSuspendLock); >- ResumeThread(m_handle); >-} >- >-size_t Thread::getRegisters(PlatformRegisters& registers) >-{ >- LockHolder locker(globalSuspendLock); >- registers.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL; >- GetThreadContext(m_handle, ®isters); >- return sizeof(CONTEXT); >-} >- >-Thread& Thread::initializeCurrentTLS() >-{ >- // Not a WTF-created thread, ThreadIdentifier is not established yet. >- Ref<Thread> thread = adoptRef(*new Thread()); >- >- HANDLE handle; >- bool isSuccessful = DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &handle, 0, FALSE, DUPLICATE_SAME_ACCESS); >- RELEASE_ASSERT(isSuccessful); >- >- thread->establishPlatformSpecificHandle(handle, currentID()); >- thread->initializeInThread(); >- initializeCurrentThreadEvenIfNonWTFCreated(); >- >- return initializeTLS(WTFMove(thread)); >-} >- >-ThreadIdentifier Thread::currentID() >-{ >- return static_cast<ThreadIdentifier>(GetCurrentThreadId()); >-} >- >-void Thread::establishPlatformSpecificHandle(HANDLE handle, ThreadIdentifier threadID) >-{ >- auto locker = holdLock(m_mutex); >- m_handle = handle; >- m_id = threadID; >-} >- >-#define InvalidThread reinterpret_cast<Thread*>(static_cast<uintptr_t>(0xbbadbeef)) >- >-static WordLock threadMapMutex; >- >-static HashMap<ThreadIdentifier, Thread*>& threadMap() >-{ >- static NeverDestroyed<HashMap<ThreadIdentifier, Thread*>> map; >- return map.get(); >-} >- >-void Thread::initializeTLSKey() >-{ >- threadMap(); >- threadSpecificKeyCreate(&s_key, destructTLS); >-} >- >-Thread* Thread::currentDying() >-{ >- ASSERT(s_key != InvalidThreadSpecificKey); >- // After FLS is destroyed, this map offers the value until the second thread exit callback is called. >- auto locker = holdLock(threadMapMutex); >- return threadMap().get(currentID()); >-} >- >-// FIXME: Remove this workaround code once <rdar://problem/31793213> is fixed. >-RefPtr<Thread> Thread::get(ThreadIdentifier id) >-{ >- auto locker = holdLock(threadMapMutex); >- Thread* thread = threadMap().get(id); >- if (thread) >- return thread; >- return nullptr; >-} >- >-Thread& Thread::initializeTLS(Ref<Thread>&& thread) >-{ >- ASSERT(s_key != InvalidThreadSpecificKey); >- // FIXME: Remove this workaround code once <rdar://problem/31793213> is fixed. >- auto id = thread->id(); >- // We leak the ref to keep the Thread alive while it is held in TLS. destructTLS will deref it later at thread destruction time. >- auto& threadInTLS = thread.leakRef(); >- threadSpecificSet(s_key, &threadInTLS); >- { >- auto locker = holdLock(threadMapMutex); >- threadMap().add(id, &threadInTLS); >- } >- return threadInTLS; >-} >- >-void Thread::destructTLS(void* data) >-{ >- if (data == InvalidThread) >- return; >- >- Thread* thread = static_cast<Thread*>(data); >- ASSERT(thread); >- >- // Delay the deallocation of Thread more. >- // It defers Thread deallocation after the other ThreadSpecific values are deallocated. >- static thread_local class ThreadExitCallback { >- public: >- ThreadExitCallback(Thread* thread) >- : m_thread(thread) >- { >- } >- >- ~ThreadExitCallback() >- { >- Thread::destructTLS(m_thread); >- } >- >- private: >- Thread* m_thread; >- } callback(thread); >- >- if (thread->m_isDestroyedOnce) { >- { >- auto locker = holdLock(threadMapMutex); >- ASSERT(threadMap().contains(thread->id())); >- threadMap().remove(thread->id()); >- } >- thread->didExit(); >- thread->deref(); >- >- // Fill the FLS with the non-nullptr value. While FLS destructor won't be called for that, >- // non-nullptr value tells us that we already destructed Thread. This allows us to >- // detect incorrect use of Thread::current() after this point because it will crash. >- threadSpecificSet(s_key, InvalidThread); >- return; >- } >- threadSpecificSet(s_key, InvalidThread); >- thread->m_isDestroyedOnce = true; >-} >- >-Mutex::~Mutex() >-{ >-} >- >-void Mutex::lock() >-{ >- AcquireSRWLockExclusive(&m_mutex); >-} >- >-bool Mutex::tryLock() >-{ >- return TryAcquireSRWLockExclusive(&m_mutex); >-} >- >-void Mutex::unlock() >-{ >- ReleaseSRWLockExclusive(&m_mutex); >-} >- >-// Returns an interval in milliseconds suitable for passing to one of the Win32 wait functions (e.g., ::WaitForSingleObject). >-static DWORD absoluteTimeToWaitTimeoutInterval(WallTime absoluteTime) >-{ >- WallTime currentTime = WallTime::now(); >- >- // Time is in the past - return immediately. >- if (absoluteTime < currentTime) >- return 0; >- >- // Time is too far in the future (and would overflow unsigned long) - wait forever. >- if ((absoluteTime - currentTime) > Seconds::fromMilliseconds(INT_MAX)) >- return INFINITE; >- >- return static_cast<DWORD>((absoluteTime - currentTime).milliseconds()); >-} >- >-ThreadCondition::~ThreadCondition() >-{ >-} >- >-void ThreadCondition::wait(Mutex& mutex) >-{ >- SleepConditionVariableSRW(&m_condition, &mutex.impl(), INFINITE, 0); >-} >- >-bool ThreadCondition::timedWait(Mutex& mutex, WallTime absoluteTime) >-{ >- // https://msdn.microsoft.com/en-us/library/windows/desktop/ms686304(v=vs.85).aspx >- DWORD interval = absoluteTimeToWaitTimeoutInterval(absoluteTime); >- if (!interval) { >- // Consider the wait to have timed out, even if our condition has already been signaled, to >- // match the pthreads implementation. >- return false; >- } >- >- if (SleepConditionVariableSRW(&m_condition, &mutex.impl(), interval, 0)) >- return true; >- ASSERT(GetLastError() == ERROR_TIMEOUT); >- return false; >-} >- >-void ThreadCondition::signal() >-{ >- WakeConditionVariable(&m_condition); >-} >- >-void ThreadCondition::broadcast() >-{ >- WakeAllConditionVariable(&m_condition); >-} >- >-// Remove this workaround code when <rdar://problem/31793213> is fixed. >-ThreadIdentifier createThread(ThreadFunction function, void* data, const char* threadName) >-{ >- return Thread::create(threadName, [function, data] { >- function(data); >- })->id(); >-} >- >-int waitForThreadCompletion(ThreadIdentifier threadID) >-{ >- // This function is implemented based on the old Threading implementation. >- // It remains only due to the support library using old Threading APIs and >- // it should not be used in new code. >- ASSERT(threadID); >- >- RefPtr<Thread> thread = Thread::get(threadID); >- if (!thread) { >- LOG_ERROR("ThreadIdentifier %u did not correspond to an active thread when trying to quit", threadID); >- return WAIT_FAILED; >- } >- return thread->waitForCompletion(); >- >-} >- >-void Thread::yield() >-{ >- SwitchToThread(); >-} >- >-} // namespace WTF >- >-#endif // OS(WINDOWS) >diff --git a/Source/WTF/wtf/cf/RunLoopTimerCF.cpp b/Source/WTF/wtf/cf/RunLoopTimerCF.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..7418fdd3ea27dbf8940502e90d9143b528352a85 >--- /dev/null >+++ b/Source/WTF/wtf/cf/RunLoopTimerCF.cpp >@@ -0,0 +1,92 @@ >+/* >+ * Copyright (C) 2009, 2013 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if PLATFORM(COCOA) && HAVE(RUNLOOP_TIMER) >+ >+#include <wtf/RunLoopTimer.h> >+ >+#include <wtf/AutodrainedPool.h> >+ >+namespace WTF { >+ >+RunLoopTimerBase::~RunLoopTimerBase() >+{ >+ stop(); >+} >+ >+static void timerFired(CFRunLoopTimerRef, void* context) >+{ >+ // CFRunLoopTimer does not create an NSAutoreleasePool, like NSTimer does. This can lead to >+ // autoreleased objects being pushed into NSAutoreleasePools underneath the run loop, which >+ // are very infrequently drained. Create a new autorelease pool here to give autoreleased objects >+ // a place to collect. >+ AutodrainedPool pool; >+ RunLoopTimerBase* timer = static_cast<RunLoopTimerBase*>(context); >+ timer->fired(); >+} >+ >+void RunLoopTimerBase::start(Seconds nextFireInterval, Seconds repeatInterval) >+{ >+ if (m_timer) >+ CFRunLoopTimerInvalidate(m_timer.get()); >+ CFRunLoopTimerContext context = { 0, this, 0, 0, 0 }; >+ m_timer = adoptCF(CFRunLoopTimerCreate(0, CFAbsoluteTimeGetCurrent() + nextFireInterval.seconds(), repeatInterval.seconds(), 0, 0, timerFired, &context)); >+} >+ >+void RunLoopTimerBase::schedule(const SchedulePair* schedulePair) >+{ >+ ASSERT_ARG(schedulePair, schedulePair); >+ ASSERT_WITH_MESSAGE(m_timer, "Timer must have one of the start functions called before calling schedule()."); >+ CFRunLoopAddTimer(schedulePair->runLoop(), m_timer.get(), schedulePair->mode()); >+} >+ >+void RunLoopTimerBase::schedule(const SchedulePairHashSet& schedulePairs) >+{ >+ SchedulePairHashSet::const_iterator end = schedulePairs.end(); >+ for (SchedulePairHashSet::const_iterator it = schedulePairs.begin(); it != end; ++it) >+ schedule((*it).get()); >+} >+ >+void RunLoopTimerBase::stop() >+{ >+ if (!m_timer) >+ return; >+ CFRunLoopTimerInvalidate(m_timer.get()); >+ m_timer = 0; >+} >+ >+bool RunLoopTimerBase::isActive() const >+{ >+ return m_timer && CFRunLoopTimerIsValid(m_timer.get()); >+} >+ >+} // namespace WTF >+ >+#endif // PLATFORM(COCOA) && HAVE(RUNLOOP_TIMER) >diff --git a/Source/WTF/wtf/cf/SchedulePairCF.cpp b/Source/WTF/wtf/cf/SchedulePairCF.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..46f65c33f00b7da152f80e5268f04730135cca35 >--- /dev/null >+++ b/Source/WTF/wtf/cf/SchedulePairCF.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2008, 2013 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include <wtf/SchedulePair.h> >+ >+namespace WTF { >+ >+bool SchedulePair::operator==(const SchedulePair& other) const >+{ >+ if (runLoop() != other.runLoop()) >+ return false; >+ CFStringRef thisMode = mode(); >+ CFStringRef otherMode = other.mode(); >+ if (!thisMode || !otherMode) >+ return thisMode == otherMode; >+ return CFEqual(thisMode, otherMode); >+} >+ >+} // namespace >diff --git a/Source/WTF/wtf/mac/SchedulePairMac.mm b/Source/WTF/wtf/mac/SchedulePairMac.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..62261ad3f9d6a661203bdb1416c318eb2e4ee77a >--- /dev/null >+++ b/Source/WTF/wtf/mac/SchedulePairMac.mm >@@ -0,0 +1,42 @@ >+/* >+ * Copyright (C) 2008, 2013 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include <wtf/SchedulePair.h> >+ >+namespace WTF { >+ >+SchedulePair::SchedulePair(NSRunLoop* runLoop, CFStringRef mode) >+ : m_nsRunLoop(runLoop) >+ , m_runLoop([runLoop getCFRunLoop]) >+{ >+ if (mode) >+ m_mode = adoptCF(CFStringCreateCopy(0, mode)); >+} >+ >+} // namespace >diff --git a/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp b/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..e011d6191bfc8483512cf676593324165c77d656 >--- /dev/null >+++ b/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp >@@ -0,0 +1,182 @@ >+/* >+ * Copyright (C) 2010 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include <wtf/OSAllocator.h> >+ >+#include <errno.h> >+#include <sys/mman.h> >+#include <wtf/Assertions.h> >+#include <wtf/PageAllocation.h> >+ >+namespace WTF { >+ >+void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) >+{ >+#if OS(LINUX) >+ UNUSED_PARAM(usage); >+ UNUSED_PARAM(writable); >+ UNUSED_PARAM(executable); >+ UNUSED_PARAM(includesGuardPages); >+ >+ void* result = mmap(0, bytes, PROT_NONE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANON, -1, 0); >+ if (result == MAP_FAILED) >+ CRASH(); >+ madvise(result, bytes, MADV_DONTNEED); >+#else >+ void* result = reserveAndCommit(bytes, usage, writable, executable, includesGuardPages); >+#if HAVE(MADV_FREE_REUSE) >+ if (result) { >+ // To support the "reserve then commit" model, we have to initially decommit. >+ while (madvise(result, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } >+ } >+#endif >+ >+#endif >+ >+ return result; >+} >+ >+void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) >+{ >+ // All POSIX reservations start out logically committed. >+ int protection = PROT_READ; >+ if (writable) >+ protection |= PROT_WRITE; >+ if (executable) >+ protection |= PROT_EXEC; >+ >+ int flags = MAP_PRIVATE | MAP_ANON; >+#if OS(DARWIN) >+ if (executable) >+ flags |= MAP_JIT; >+#endif >+ >+#if OS(DARWIN) >+ int fd = usage; >+#else >+ UNUSED_PARAM(usage); >+ int fd = -1; >+#endif >+ >+ void* result = 0; >+#if (OS(DARWIN) && CPU(X86_64)) >+ if (executable) { >+ ASSERT(includesGuardPages); >+ // Cook up an address to allocate at, using the following recipe: >+ // 17 bits of zero, stay in userspace kids. >+ // 26 bits of randomness for ASLR. >+ // 21 bits of zero, at least stay aligned within one level of the pagetables. >+ // >+ // But! - as a temporary workaround for some plugin problems (rdar://problem/6812854), >+ // for now instead of 2^26 bits of ASLR lets stick with 25 bits of randomization plus >+ // 2^24, which should put up somewhere in the middle of userspace (in the address range >+ // 0x200000000000 .. 0x5fffffffffff). >+ intptr_t randomLocation = 0; >+ randomLocation = arc4random() & ((1 << 25) - 1); >+ randomLocation += (1 << 24); >+ randomLocation <<= 21; >+ result = reinterpret_cast<void*>(randomLocation); >+ } >+#endif >+ >+ result = mmap(result, bytes, protection, flags, fd, 0); >+ if (result == MAP_FAILED) { >+ if (executable) >+ result = 0; >+ else >+ CRASH(); >+ } >+ if (result && includesGuardPages) { >+ // We use mmap to remap the guardpages rather than using mprotect as >+ // mprotect results in multiple references to the code region. This >+ // breaks the madvise based mechanism we use to return physical memory >+ // to the OS. >+ mmap(result, pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0); >+ mmap(static_cast<char*>(result) + bytes - pageSize(), pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0); >+ } >+ return result; >+} >+ >+void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) >+{ >+#if OS(LINUX) >+ int protection = PROT_READ; >+ if (writable) >+ protection |= PROT_WRITE; >+ if (executable) >+ protection |= PROT_EXEC; >+ if (mprotect(address, bytes, protection)) >+ CRASH(); >+ madvise(address, bytes, MADV_WILLNEED); >+#elif HAVE(MADV_FREE_REUSE) >+ UNUSED_PARAM(writable); >+ UNUSED_PARAM(executable); >+ while (madvise(address, bytes, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { } >+#else >+ // Non-MADV_FREE_REUSE reservations automatically commit on demand. >+ UNUSED_PARAM(address); >+ UNUSED_PARAM(bytes); >+ UNUSED_PARAM(writable); >+ UNUSED_PARAM(executable); >+#endif >+} >+ >+void OSAllocator::decommit(void* address, size_t bytes) >+{ >+#if OS(LINUX) >+ madvise(address, bytes, MADV_DONTNEED); >+ if (mprotect(address, bytes, PROT_NONE)) >+ CRASH(); >+#elif HAVE(MADV_FREE_REUSE) >+ while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } >+#elif HAVE(MADV_FREE) >+ while (madvise(address, bytes, MADV_FREE) == -1 && errno == EAGAIN) { } >+#elif HAVE(MADV_DONTNEED) >+ while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } >+#else >+ UNUSED_PARAM(address); >+ UNUSED_PARAM(bytes); >+#endif >+} >+ >+void OSAllocator::hintMemoryNotNeededSoon(void* address, size_t bytes) >+{ >+#if HAVE(MADV_DONTNEED) >+ while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } >+#else >+ UNUSED_PARAM(address); >+ UNUSED_PARAM(bytes); >+#endif >+} >+ >+void OSAllocator::releaseDecommitted(void* address, size_t bytes) >+{ >+ int result = munmap(address, bytes); >+ if (result == -1) >+ CRASH(); >+} >+ >+} // namespace WTF >diff --git a/Source/WTF/wtf/posix/ThreadingPOSIX.cpp b/Source/WTF/wtf/posix/ThreadingPOSIX.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..e48dd9b57edd4cf55f25331645823f3109da4221 >--- /dev/null >+++ b/Source/WTF/wtf/posix/ThreadingPOSIX.cpp >@@ -0,0 +1,565 @@ >+/* >+ * Copyright (C) 2007, 2009, 2015 Apple Inc. All rights reserved. >+ * Copyright (C) 2007 Justin Haygood <jhaygood@reaktix.com> >+ * Copyright (C) 2011 Research In Motion Limited. All rights reserved. >+ * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com> >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include <wtf/Threading.h> >+ >+#if USE(PTHREADS) >+ >+#include <errno.h> >+#include <wtf/DataLog.h> >+#include <wtf/NeverDestroyed.h> >+#include <wtf/RawPointer.h> >+#include <wtf/StdLibExtras.h> >+#include <wtf/ThreadGroup.h> >+#include <wtf/ThreadingPrimitives.h> >+#include <wtf/WordLock.h> >+ >+#if OS(LINUX) >+#include <sys/prctl.h> >+#endif >+ >+#if !COMPILER(MSVC) >+#include <limits.h> >+#include <sched.h> >+#include <sys/time.h> >+#endif >+ >+#if !OS(DARWIN) && OS(UNIX) >+ >+#include <semaphore.h> >+#include <sys/mman.h> >+#include <unistd.h> >+#include <pthread.h> >+ >+#if HAVE(PTHREAD_NP_H) >+#include <pthread_np.h> >+#endif >+ >+#endif >+ >+namespace WTF { >+ >+static Lock globalSuspendLock; >+ >+Thread::~Thread() >+{ >+} >+ >+#if !OS(DARWIN) >+class Semaphore { >+ WTF_MAKE_NONCOPYABLE(Semaphore); >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ explicit Semaphore(unsigned initialValue) >+ { >+ int sharedBetweenProcesses = 0; >+ sem_init(&m_platformSemaphore, sharedBetweenProcesses, initialValue); >+ } >+ >+ ~Semaphore() >+ { >+ sem_destroy(&m_platformSemaphore); >+ } >+ >+ void wait() >+ { >+ sem_wait(&m_platformSemaphore); >+ } >+ >+ void post() >+ { >+ sem_post(&m_platformSemaphore); >+ } >+ >+private: >+ sem_t m_platformSemaphore; >+}; >+static LazyNeverDestroyed<Semaphore> globalSemaphoreForSuspendResume; >+ >+// We use SIGUSR1 to suspend and resume machine threads in JavaScriptCore. >+static constexpr const int SigThreadSuspendResume = SIGUSR1; >+static std::atomic<Thread*> targetThread { nullptr }; >+ >+void Thread::signalHandlerSuspendResume(int, siginfo_t*, void* ucontext) >+{ >+ // Touching a global variable atomic types from signal handlers is allowed. >+ Thread* thread = targetThread.load(); >+ >+ if (thread->m_suspendCount) { >+ // This is signal handler invocation that is intended to be used to resume sigsuspend. >+ // So this handler invocation itself should not process. >+ // >+ // When signal comes, first, the system calls signal handler. And later, sigsuspend will be resumed. Signal handler invocation always precedes. >+ // So, the problem never happens that suspended.store(true, ...) will be executed before the handler is called. >+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/sigsuspend.html >+ return; >+ } >+ >+ void* approximateStackPointer = currentStackPointer(); >+ if (!thread->m_stack.contains(approximateStackPointer)) { >+ // This happens if we use an alternative signal stack. >+ // 1. A user-defined signal handler is invoked with an alternative signal stack. >+ // 2. In the middle of the execution of the handler, we attempt to suspend the target thread. >+ // 3. A nested signal handler is executed. >+ // 4. The stack pointer saved in the machine context will be pointing to the alternative signal stack. >+ // In this case, we back off the suspension and retry a bit later. >+ thread->m_platformRegisters = nullptr; >+ globalSemaphoreForSuspendResume->post(); >+ return; >+ } >+ >+#if HAVE(MACHINE_CONTEXT) >+ ucontext_t* userContext = static_cast<ucontext_t*>(ucontext); >+ thread->m_platformRegisters = ®istersFromUContext(userContext); >+#else >+ UNUSED_PARAM(ucontext); >+ PlatformRegisters platformRegisters { approximateStackPointer }; >+ thread->m_platformRegisters = &platformRegisters; >+#endif >+ >+ // Allow suspend caller to see that this thread is suspended. >+ // sem_post is async-signal-safe function. It means that we can call this from a signal handler. >+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03 >+ // >+ // And sem_post emits memory barrier that ensures that PlatformRegisters are correctly saved. >+ // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_11 >+ globalSemaphoreForSuspendResume->post(); >+ >+ // Reaching here, SigThreadSuspendResume is blocked in this handler (this is configured by sigaction's sa_mask). >+ // So before calling sigsuspend, SigThreadSuspendResume to this thread is deferred. This ensures that the handler is not executed recursively. >+ sigset_t blockedSignalSet; >+ sigfillset(&blockedSignalSet); >+ sigdelset(&blockedSignalSet, SigThreadSuspendResume); >+ sigsuspend(&blockedSignalSet); >+ >+ thread->m_platformRegisters = nullptr; >+ >+ // Allow resume caller to see that this thread is resumed. >+ globalSemaphoreForSuspendResume->post(); >+} >+ >+#endif // !OS(DARWIN) >+ >+void Thread::initializePlatformThreading() >+{ >+#if !OS(DARWIN) >+ globalSemaphoreForSuspendResume.construct(0); >+ >+ // Signal handlers are process global configuration. >+ // Intentionally block SigThreadSuspendResume in the handler. >+ // SigThreadSuspendResume will be allowed in the handler by sigsuspend. >+ struct sigaction action; >+ sigemptyset(&action.sa_mask); >+ sigaddset(&action.sa_mask, SigThreadSuspendResume); >+ >+ action.sa_sigaction = &signalHandlerSuspendResume; >+ action.sa_flags = SA_RESTART | SA_SIGINFO; >+ sigaction(SigThreadSuspendResume, &action, 0); >+#endif >+} >+ >+void Thread::initializeCurrentThreadEvenIfNonWTFCreated() >+{ >+#if !OS(DARWIN) >+ sigset_t mask; >+ sigemptyset(&mask); >+ sigaddset(&mask, SigThreadSuspendResume); >+ pthread_sigmask(SIG_UNBLOCK, &mask, 0); >+#endif >+} >+ >+static void* wtfThreadEntryPoint(void* context) >+{ >+ Thread::entryPoint(reinterpret_cast<Thread::NewThreadContext*>(context)); >+ return nullptr; >+} >+ >+bool Thread::establishHandle(NewThreadContext* context) >+{ >+ pthread_t threadHandle; >+ pthread_attr_t attr; >+ pthread_attr_init(&attr); >+#if HAVE(QOS_CLASSES) >+ pthread_attr_set_qos_class_np(&attr, adjustedQOSClass(QOS_CLASS_USER_INITIATED), 0); >+#endif >+ int error = pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, context); >+ pthread_attr_destroy(&attr); >+ if (error) { >+ LOG_ERROR("Failed to create pthread at entry point %p with context %p", wtfThreadEntryPoint, context); >+ return false; >+ } >+ establishPlatformSpecificHandle(threadHandle); >+ return true; >+} >+ >+void Thread::initializeCurrentThreadInternal(const char* threadName) >+{ >+#if HAVE(PTHREAD_SETNAME_NP) >+ pthread_setname_np(normalizeThreadName(threadName)); >+#elif OS(LINUX) >+ prctl(PR_SET_NAME, normalizeThreadName(threadName)); >+#else >+ UNUSED_PARAM(threadName); >+#endif >+ initializeCurrentThreadEvenIfNonWTFCreated(); >+} >+ >+void Thread::changePriority(int delta) >+{ >+#if HAVE(PTHREAD_SETSCHEDPARAM) >+ auto locker = holdLock(m_mutex); >+ >+ int policy; >+ struct sched_param param; >+ >+ if (pthread_getschedparam(m_handle, &policy, ¶m)) >+ return; >+ >+ param.sched_priority += delta; >+ >+ pthread_setschedparam(m_handle, policy, ¶m); >+#endif >+} >+ >+int Thread::waitForCompletion() >+{ >+ pthread_t handle; >+ { >+ auto locker = holdLock(m_mutex); >+ handle = m_handle; >+ } >+ >+ int joinResult = pthread_join(handle, 0); >+ >+ if (joinResult == EDEADLK) >+ LOG_ERROR("Thread %p was found to be deadlocked trying to quit", this); >+ else if (joinResult) >+ LOG_ERROR("Thread %p was unable to be joined.\n", this); >+ >+ auto locker = holdLock(m_mutex); >+ ASSERT(joinableState() == Joinable); >+ >+ // If the thread has already exited, then do nothing. If the thread hasn't exited yet, then just signal that we've already joined on it. >+ // In both cases, Thread::destructTLS() will take care of destroying Thread. >+ if (!hasExited()) >+ didJoin(); >+ >+ return joinResult; >+} >+ >+void Thread::detach() >+{ >+ auto locker = holdLock(m_mutex); >+ int detachResult = pthread_detach(m_handle); >+ if (detachResult) >+ LOG_ERROR("Thread %p was unable to be detached\n", this); >+ >+ if (!hasExited()) >+ didBecomeDetached(); >+} >+ >+Thread& Thread::initializeCurrentTLS() >+{ >+ // Not a WTF-created thread, Thread is not established yet. >+ Ref<Thread> thread = adoptRef(*new Thread()); >+ thread->establishPlatformSpecificHandle(pthread_self()); >+ thread->initializeInThread(); >+ initializeCurrentThreadEvenIfNonWTFCreated(); >+ >+ return initializeTLS(WTFMove(thread)); >+} >+ >+bool Thread::signal(int signalNumber) >+{ >+ auto locker = holdLock(m_mutex); >+ if (hasExited()) >+ return false; >+ int errNo = pthread_kill(m_handle, signalNumber); >+ return !errNo; // A 0 errNo means success. >+} >+ >+auto Thread::suspend() -> Expected<void, PlatformSuspendError> >+{ >+ RELEASE_ASSERT_WITH_MESSAGE(this != &Thread::current(), "We do not support suspending the current thread itself."); >+ // During suspend, suspend or resume should not be executed from the other threads. >+ // We use global lock instead of per thread lock. >+ // Consider the following case, there are threads A and B. >+ // And A attempt to suspend B and B attempt to suspend A. >+ // A and B send signals. And later, signals are delivered to A and B. >+ // In that case, both will be suspended. >+ // >+ // And it is important to use a global lock to suspend and resume. Let's consider using per-thread lock. >+ // Your issuing thread (A) attempts to suspend the target thread (B). Then, you will suspend the thread (C) additionally. >+ // This case frequently happens if you stop threads to perform stack scanning. But thread (B) may hold the lock of thread (C). >+ // In that case, dead lock happens. Using global lock here avoids this dead lock. >+ LockHolder locker(globalSuspendLock); >+#if OS(DARWIN) >+ kern_return_t result = thread_suspend(m_platformThread); >+ if (result != KERN_SUCCESS) >+ return makeUnexpected(result); >+ return { }; >+#else >+ if (!m_suspendCount) { >+ // Ideally, we would like to use pthread_sigqueue. It allows us to pass the argument to the signal handler. >+ // But it can be used in a few platforms, like Linux. >+ // Instead, we use Thread* stored in a global variable to pass it to the signal handler. >+ targetThread.store(this); >+ >+ while (true) { >+ int result = pthread_kill(m_handle, SigThreadSuspendResume); >+ if (result) >+ return makeUnexpected(result); >+ globalSemaphoreForSuspendResume->wait(); >+ if (m_platformRegisters) >+ break; >+ // Because of an alternative signal stack, we failed to suspend this thread. >+ // Retry suspension again after yielding. >+ Thread::yield(); >+ } >+ } >+ ++m_suspendCount; >+ return { }; >+#endif >+} >+ >+void Thread::resume() >+{ >+ // During resume, suspend or resume should not be executed from the other threads. >+ LockHolder locker(globalSuspendLock); >+#if OS(DARWIN) >+ thread_resume(m_platformThread); >+#else >+ if (m_suspendCount == 1) { >+ // When allowing SigThreadSuspendResume interrupt in the signal handler by sigsuspend and SigThreadSuspendResume is actually issued, >+ // the signal handler itself will be called once again. >+ // There are several ways to distinguish the handler invocation for suspend and resume. >+ // 1. Use different signal numbers. And check the signal number in the handler. >+ // 2. Use some arguments to distinguish suspend and resume in the handler. If pthread_sigqueue can be used, we can take this. >+ // 3. Use thread's flag. >+ // In this implementaiton, we take (3). m_suspendCount is used to distinguish it. >+ targetThread.store(this); >+ if (pthread_kill(m_handle, SigThreadSuspendResume) == ESRCH) >+ return; >+ globalSemaphoreForSuspendResume->wait(); >+ } >+ --m_suspendCount; >+#endif >+} >+ >+#if OS(DARWIN) >+struct ThreadStateMetadata { >+ unsigned userCount; >+ thread_state_flavor_t flavor; >+}; >+ >+static ThreadStateMetadata threadStateMetadata() >+{ >+#if CPU(X86) >+ unsigned userCount = sizeof(PlatformRegisters) / sizeof(int); >+ thread_state_flavor_t flavor = i386_THREAD_STATE; >+#elif CPU(X86_64) >+ unsigned userCount = x86_THREAD_STATE64_COUNT; >+ thread_state_flavor_t flavor = x86_THREAD_STATE64; >+#elif CPU(PPC) >+ unsigned userCount = PPC_THREAD_STATE_COUNT; >+ thread_state_flavor_t flavor = PPC_THREAD_STATE; >+#elif CPU(PPC64) >+ unsigned userCount = PPC_THREAD_STATE64_COUNT; >+ thread_state_flavor_t flavor = PPC_THREAD_STATE64; >+#elif CPU(ARM) >+ unsigned userCount = ARM_THREAD_STATE_COUNT; >+ thread_state_flavor_t flavor = ARM_THREAD_STATE; >+#elif CPU(ARM64) >+ unsigned userCount = ARM_THREAD_STATE64_COUNT; >+ thread_state_flavor_t flavor = ARM_THREAD_STATE64; >+#else >+#error Unknown Architecture >+#endif >+ return ThreadStateMetadata { userCount, flavor }; >+} >+#endif // OS(DARWIN) >+ >+size_t Thread::getRegisters(PlatformRegisters& registers) >+{ >+ LockHolder locker(globalSuspendLock); >+#if OS(DARWIN) >+ auto metadata = threadStateMetadata(); >+ kern_return_t result = thread_get_state(m_platformThread, metadata.flavor, (thread_state_t)®isters, &metadata.userCount); >+ if (result != KERN_SUCCESS) { >+ WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, "JavaScript garbage collection failed because thread_get_state returned an error (%d). This is probably the result of running inside Rosetta, which is not supported.", result); >+ CRASH(); >+ } >+ return metadata.userCount * sizeof(uintptr_t); >+#else >+ ASSERT_WITH_MESSAGE(m_suspendCount, "We can get registers only if the thread is suspended."); >+ ASSERT(m_platformRegisters); >+ registers = *m_platformRegisters; >+ return sizeof(PlatformRegisters); >+#endif >+} >+ >+void Thread::establishPlatformSpecificHandle(pthread_t handle) >+{ >+ auto locker = holdLock(m_mutex); >+ m_handle = handle; >+#if OS(DARWIN) >+ m_platformThread = pthread_mach_thread_np(handle); >+#endif >+} >+ >+#if !HAVE(FAST_TLS) >+void Thread::initializeTLSKey() >+{ >+ threadSpecificKeyCreate(&s_key, destructTLS); >+} >+#endif >+ >+Thread& Thread::initializeTLS(Ref<Thread>&& thread) >+{ >+ // We leak the ref to keep the Thread alive while it is held in TLS. destructTLS will deref it later at thread destruction time. >+ auto& threadInTLS = thread.leakRef(); >+#if !HAVE(FAST_TLS) >+ ASSERT(s_key != InvalidThreadSpecificKey); >+ threadSpecificSet(s_key, &threadInTLS); >+#else >+ _pthread_setspecific_direct(WTF_THREAD_DATA_KEY, &threadInTLS); >+ pthread_key_init_np(WTF_THREAD_DATA_KEY, &destructTLS); >+#endif >+ return threadInTLS; >+} >+ >+void Thread::destructTLS(void* data) >+{ >+ Thread* thread = static_cast<Thread*>(data); >+ ASSERT(thread); >+ >+ if (thread->m_isDestroyedOnce) { >+ thread->didExit(); >+ thread->deref(); >+ return; >+ } >+ >+ thread->m_isDestroyedOnce = true; >+ // Re-setting the value for key causes another destructTLS() call after all other thread-specific destructors were called. >+#if !HAVE(FAST_TLS) >+ ASSERT(s_key != InvalidThreadSpecificKey); >+ threadSpecificSet(s_key, thread); >+#else >+ _pthread_setspecific_direct(WTF_THREAD_DATA_KEY, thread); >+ pthread_key_init_np(WTF_THREAD_DATA_KEY, &destructTLS); >+#endif >+} >+ >+Mutex::~Mutex() >+{ >+ int result = pthread_mutex_destroy(&m_mutex); >+ ASSERT_UNUSED(result, !result); >+} >+ >+void Mutex::lock() >+{ >+ int result = pthread_mutex_lock(&m_mutex); >+ ASSERT_UNUSED(result, !result); >+} >+ >+bool Mutex::tryLock() >+{ >+ int result = pthread_mutex_trylock(&m_mutex); >+ >+ if (result == 0) >+ return true; >+ if (result == EBUSY) >+ return false; >+ >+ ASSERT_NOT_REACHED(); >+ return false; >+} >+ >+void Mutex::unlock() >+{ >+ int result = pthread_mutex_unlock(&m_mutex); >+ ASSERT_UNUSED(result, !result); >+} >+ >+ThreadCondition::~ThreadCondition() >+{ >+ pthread_cond_destroy(&m_condition); >+} >+ >+void ThreadCondition::wait(Mutex& mutex) >+{ >+ int result = pthread_cond_wait(&m_condition, &mutex.impl()); >+ ASSERT_UNUSED(result, !result); >+} >+ >+bool ThreadCondition::timedWait(Mutex& mutex, WallTime absoluteTime) >+{ >+ if (absoluteTime < WallTime::now()) >+ return false; >+ >+ if (absoluteTime > WallTime::fromRawSeconds(INT_MAX)) { >+ wait(mutex); >+ return true; >+ } >+ >+ double rawSeconds = absoluteTime.secondsSinceEpoch().value(); >+ >+ int timeSeconds = static_cast<int>(rawSeconds); >+ int timeNanoseconds = static_cast<int>((rawSeconds - timeSeconds) * 1E9); >+ >+ timespec targetTime; >+ targetTime.tv_sec = timeSeconds; >+ targetTime.tv_nsec = timeNanoseconds; >+ >+ return pthread_cond_timedwait(&m_condition, &mutex.impl(), &targetTime) == 0; >+} >+ >+void ThreadCondition::signal() >+{ >+ int result = pthread_cond_signal(&m_condition); >+ ASSERT_UNUSED(result, !result); >+} >+ >+void ThreadCondition::broadcast() >+{ >+ int result = pthread_cond_broadcast(&m_condition); >+ ASSERT_UNUSED(result, !result); >+} >+ >+void Thread::yield() >+{ >+ sched_yield(); >+} >+ >+} // namespace WTF >+ >+#endif // USE(PTHREADS) >diff --git a/Source/WTF/wtf/win/CONTRIBUTORS.pthreads-win32 b/Source/WTF/wtf/win/CONTRIBUTORS.pthreads-win32 >new file mode 100644 >index 0000000000000000000000000000000000000000..24fac006c3083e2cd73773d438a36147d09f4e02 >--- /dev/null >+++ b/Source/WTF/wtf/win/CONTRIBUTORS.pthreads-win32 >@@ -0,0 +1,137 @@ >+This is a copy of CONTRIBUTORS file for the Pthreads-win32 library, downloaded >+from http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/pthreads/CONTRIBUTORS?rev=1.32&cvsroot=pthreads-win32 >+ >+Included here to compliment the Pthreads-win32 license header in ThreadingWin.cpp file. >+WebKit is using derived sources of ThreadCondition code from Pthreads-win32. >+ >+------------------------------------------------------------------------------- >+ >+Contributors (in approximate order of appearance) >+ >+[See also the ChangeLog file where individuals are >+attributed in log entries. Likewise in the FAQ file.] >+ >+Ben Elliston bje at cygnus dot com >+ Initiated the project; >+ setup the project infrastructure (CVS, web page, etc.); >+ early prototype routines. >+Ross Johnson rpj at callisto dot canberra dot edu dot au >+ early prototype routines; >+ ongoing project coordination/maintenance; >+ implementation of spin locks and barriers; >+ various enhancements; >+ bug fixes; >+ documentation; >+ testsuite. >+Robert Colquhoun rjc at trump dot net dot au >+ Early bug fixes. >+John E. Bossom John dot Bossom at cognos dot com >+ Contributed substantial original working implementation; >+ bug fixes; >+ ongoing guidance and standards interpretation. >+Anders Norlander anorland at hem2 dot passagen dot se >+ Early enhancements and runtime checking for supported >+ Win32 routines. >+Tor Lillqvist tml at iki dot fi >+ General enhancements; >+ early bug fixes to condition variables. >+Scott Lightner scott at curriculum dot com >+ Bug fix. >+Kevin Ruland Kevin dot Ruland at anheuser-busch dot com >+ Various bug fixes. >+Mike Russo miker at eai dot com >+ Bug fix. >+Mark E. Armstrong avail at pacbell dot net >+ Bug fixes. >+Lorin Hochstein lmh at xiphos dot ca >+ general bug fixes; bug fixes to condition variables. >+Peter Slacik Peter dot Slacik at tatramed dot sk >+ Bug fixes. >+Mumit Khan khan at xraylith dot wisc dot edu >+ Fixes to work with Mingw32. >+Milan Gardian mg at tatramed dot sk >+ Bug fixes and reports/analyses of obscure problems. >+Aurelio Medina aureliom at crt dot com >+ First implementation of read-write locks. >+Graham Dumpleton Graham dot Dumpleton at ra dot pad dot otc dot telstra dot com dot au >+ Bug fix in condition variables. >+Tristan Savatier tristan at mpegtv dot com >+ WinCE port. >+Erik Hensema erik at hensema dot xs4all dot nl >+ Bug fixes. >+Rich Peters rpeters at micro-magic dot com >+Todd Owen towen at lucidcalm dot dropbear dot id dot au >+ Bug fixes to dll loading. >+Jason Nye jnye at nbnet dot nb dot ca >+ Implementation of async cancelation. >+Fred Forester fforest at eticomm dot net >+Kevin D. Clark kclark at cabletron dot com >+David Baggett dmb at itasoftware dot com >+ Bug fixes. >+Paul Redondo paul at matchvision dot com >+Scott McCaskill scott at 3dfx dot com >+ Bug fixes. >+Jef Gearhart jgearhart at tpssys dot com >+ Bug fix. >+Arthur Kantor akantor at bexusa dot com >+ Mutex enhancements. >+Steven Reddie smr at essemer dot com dot au >+ Bug fix. >+Alexander Terekhov TEREKHOV at de dot ibm dot com >+ Re-implemented and improved read-write locks; >+ (with Louis Thomas) re-implemented and improved >+ condition variables; >+ enhancements to semaphores; >+ enhancements to mutexes; >+ new mutex implementation in 'futex' style; >+ suggested a robust implementation of pthread_once >+ similar to that implemented by V.Kliathcko; >+ system clock change handling re CV timeouts; >+ bug fixes. >+Thomas Pfaff tpfaff at gmx dot net >+ Changes to make C version usable with C++ applications; >+ re-implemented mutex routines to avoid Win32 mutexes >+ and TryEnterCriticalSection; >+ procedure to fix Mingw32 thread-safety issues. >+Franco Bez franco dot bez at gmx dot de >+ procedure to fix Mingw32 thread-safety issues. >+Louis Thomas lthomas at arbitrade dot com >+ (with Alexander Terekhov) re-implemented and improved >+ condition variables. >+David Korn dgk at research dot att dot com >+ Ported to UWIN. >+Phil Frisbie, Jr. phil at hawksoft dot com >+ Bug fix. >+Ralf Brese Ralf dot Brese at pdb4 dot siemens dot de >+ Bug fix. >+prionx at juno dot com prionx at juno dot com >+ Bug fixes. >+Max Woodbury mtew at cds dot duke dot edu >+ POSIX versioning conditionals; >+ reduced namespace pollution; >+ idea to separate routines to reduce statically >+ linked image sizes. >+Rob Fanner rfanner at stonethree dot com >+ Bug fix. >+Michael Johnson michaelj at maine dot rr dot com >+ Bug fix. >+Nicolas Barry boozai at yahoo dot com >+ Bug fixes. >+Piet van Bruggen pietvb at newbridges dot nl >+ Bug fix. >+Makoto Kato raven at oldskool dot jp >+ AMD64 port. >+Panagiotis E. Hadjidoukas peh at hpclab dot ceid dot upatras dot gr >+ Contributed the QueueUserAPCEx package which >+ makes preemptive async cancelation possible. >+Will Bryant will dot bryant at ecosm dot com >+ Borland compiler patch and makefile. >+Anuj Goyal anuj dot goyal at gmail dot com >+ Port to Digital Mars compiler. >+Gottlob Frege gottlobfrege at gmail dot com >+ re-implemented pthread_once (version 2) >+ (pthread_once cancellation added by rpj). >+Vladimir Kliatchko vladimir at kliatchko dot com >+ reimplemented pthread_once with the same form >+ as described by A.Terekhov (later version 2); >+ implementation of MCS (Mellor-Crummey/Scott) locks. >\ No newline at end of file >diff --git a/Source/WTF/wtf/win/OSAllocatorWin.cpp b/Source/WTF/wtf/win/OSAllocatorWin.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..b3058133d516e2cf7feb9b693253ea04fafd704a >--- /dev/null >+++ b/Source/WTF/wtf/win/OSAllocatorWin.cpp >@@ -0,0 +1,98 @@ >+/* >+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include <wtf/OSAllocator.h> >+ >+#include <windows.h> >+#include <wtf/Assertions.h> >+ >+namespace WTF { >+ >+static inline DWORD protection(bool writable, bool executable) >+{ >+ return executable ? >+ (writable ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ) : >+ (writable ? PAGE_READWRITE : PAGE_READONLY); >+} >+ >+void* OSAllocator::reserveUncommitted(size_t bytes, Usage, bool writable, bool executable, bool) >+{ >+ void* result = VirtualAlloc(0, bytes, MEM_RESERVE, protection(writable, executable)); >+ if (!result) >+ CRASH(); >+ return result; >+} >+ >+void* OSAllocator::reserveAndCommit(size_t bytes, Usage, bool writable, bool executable, bool) >+{ >+ void* result = VirtualAlloc(0, bytes, MEM_RESERVE | MEM_COMMIT, protection(writable, executable)); >+ if (!result) >+ CRASH(); >+ return result; >+} >+ >+void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) >+{ >+ void* result = VirtualAlloc(address, bytes, MEM_COMMIT, protection(writable, executable)); >+ if (!result) >+ CRASH(); >+} >+ >+void OSAllocator::decommit(void* address, size_t bytes) >+{ >+ // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx, >+ // bytes (i.e. dwSize) being 0 when dwFreeType is MEM_DECOMMIT means that we'll >+ // decommit the entire region allocated by VirtualAlloc() instead of decommitting >+ // nothing as we would expect. Hence, we should check if bytes is 0 and handle it >+ // appropriately before calling VirtualFree(). >+ // See: https://bugs.webkit.org/show_bug.cgi?id=121972. >+ if (!bytes) >+ return; >+ // Silence warning about using MEM_DECOMMIT instead of MEM_RELEASE: >+#pragma warning(suppress: 6250) >+ bool result = VirtualFree(address, bytes, MEM_DECOMMIT); >+ if (!result) >+ CRASH(); >+} >+ >+void OSAllocator::releaseDecommitted(void* address, size_t bytes) >+{ >+ // See comment in OSAllocator::decommit(). Similarly, when bytes is 0, we >+ // don't want to release anything. So, don't call VirtualFree() below. >+ if (!bytes) >+ return; >+ // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx, >+ // dwSize must be 0 if dwFreeType is MEM_RELEASE. >+ bool result = VirtualFree(address, 0, MEM_RELEASE); >+ if (!result) >+ CRASH(); >+} >+ >+void OSAllocator::hintMemoryNotNeededSoon(void*, size_t) >+{ >+} >+ >+} // namespace WTF >diff --git a/Source/WTF/wtf/win/ThreadSpecificWin.cpp b/Source/WTF/wtf/win/ThreadSpecificWin.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..2a8ef32c0af3c6266787fa0e89449656d115001f >--- /dev/null >+++ b/Source/WTF/wtf/win/ThreadSpecificWin.cpp >@@ -0,0 +1,43 @@ >+/* >+ * Copyright (C) 2009 Jian Li <jianli@chromium.org> >+ * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com> >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#include "config.h" >+#include <wtf/ThreadSpecific.h> >+ >+#if !USE(PTHREADS) >+ >+namespace WTF { >+ >+long& flsKeyCount() >+{ >+ static long count; >+ return count; >+} >+ >+DWORD* flsKeys() >+{ >+ static DWORD keys[kMaxFlsKeySize]; >+ return keys; >+} >+ >+} // namespace WTF >+ >+#endif // !USE(PTHREADS) >diff --git a/Source/WTF/wtf/win/ThreadingWin.cpp b/Source/WTF/wtf/win/ThreadingWin.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..36fed1bb0d2baed332da1b57e31e7583af832cf3 >--- /dev/null >+++ b/Source/WTF/wtf/win/ThreadingWin.cpp >@@ -0,0 +1,459 @@ >+/* >+ * Copyright (C) 2007, 2008, 2015 Apple Inc. All rights reserved. >+ * Copyright (C) 2009 Google Inc. All rights reserved. >+ * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+/* >+ * There are numerous academic and practical works on how to implement pthread_cond_wait/pthread_cond_signal/pthread_cond_broadcast >+ * functions on Win32. Here is one example: http://www.cs.wustl.edu/~schmidt/win32-cv-1.html which is widely credited as a 'starting point' >+ * of modern attempts. There are several more or less proven implementations, one in Boost C++ library (http://www.boost.org) and another >+ * in pthreads-win32 (http://sourceware.org/pthreads-win32/). >+ * >+ * The number of articles and discussions is the evidence of significant difficulties in implementing these primitives correctly. >+ * The brief search of revisions, ChangeLog entries, discussions in comp.programming.threads and other places clearly documents >+ * numerous pitfalls and performance problems the authors had to overcome to arrive to the suitable implementations. >+ * Optimally, WebKit would use one of those supported/tested libraries directly. To roll out our own implementation is impractical, >+ * if even for the lack of sufficient testing. However, a faithful reproduction of the code from one of the popular supported >+ * libraries seems to be a good compromise. >+ * >+ * The early Boost implementation (http://www.boxbackup.org/trac/browser/box/nick/win/lib/win32/boost_1_32_0/libs/thread/src/condition.cpp?rev=30) >+ * is identical to pthreads-win32 (http://sourceware.org/cgi-bin/cvsweb.cgi/pthreads/pthread_cond_wait.c?rev=1.10&content-type=text/x-cvsweb-markup&cvsroot=pthreads-win32). >+ * Current Boost uses yet another (although seemingly equivalent) algorithm which came from their 'thread rewrite' effort. >+ * >+ * This file includes timedWait/signal/broadcast implementations translated to WebKit coding style from the latest algorithm by >+ * Alexander Terekhov and Louis Thomas, as captured here: http://sourceware.org/cgi-bin/cvsweb.cgi/pthreads/pthread_cond_wait.c?rev=1.10&content-type=text/x-cvsweb-markup&cvsroot=pthreads-win32 >+ * It replaces the implementation of their previous algorithm, also documented in the same source above. >+ * The naming and comments are left very close to original to enable easy cross-check. >+ * >+ * The corresponding Pthreads-win32 License is included below, and CONTRIBUTORS file which it refers to is added to >+ * source directory (as CONTRIBUTORS.pthreads-win32). >+ */ >+ >+/* >+ * Pthreads-win32 - POSIX Threads Library for Win32 >+ * Copyright(C) 1998 John E. Bossom >+ * Copyright(C) 1999,2005 Pthreads-win32 contributors >+ * >+ * Contact Email: rpj@callisto.canberra.edu.au >+ * >+ * The current list of contributors is contained >+ * in the file CONTRIBUTORS included with the source >+ * code distribution. The list can also be seen at the >+ * following World Wide Web location: >+ * http://sources.redhat.com/pthreads-win32/contributors.html >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Lesser General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Lesser General Public License for more details. >+ * >+ * You should have received a copy of the GNU Lesser General Public >+ * License along with this library in the file COPYING.LIB; >+ * if not, write to the Free Software Foundation, Inc., >+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA >+ */ >+ >+#include "config.h" >+#include <wtf/Threading.h> >+ >+#include <errno.h> >+#include <process.h> >+#include <windows.h> >+#include <wtf/HashMap.h> >+#include <wtf/Lock.h> >+#include <wtf/MainThread.h> >+#include <wtf/MathExtras.h> >+#include <wtf/NeverDestroyed.h> >+#include <wtf/ThreadingPrimitives.h> >+ >+namespace WTF { >+ >+static Lock globalSuspendLock; >+ >+Thread::~Thread() >+{ >+ // It is OK because FLSAlloc's callback will be called even before there are some open handles. >+ // This easily ensures that all the thread resources are automatically closed. >+ if (m_handle != INVALID_HANDLE_VALUE) >+ CloseHandle(m_handle); >+} >+ >+void Thread::initializeCurrentThreadEvenIfNonWTFCreated() >+{ >+} >+ >+// MS_VC_EXCEPTION, THREADNAME_INFO, and setThreadNameInternal all come from <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>. >+static const DWORD MS_VC_EXCEPTION = 0x406D1388; >+ >+#pragma pack(push, 8) >+typedef struct tagTHREADNAME_INFO { >+ DWORD dwType; // must be 0x1000 >+ LPCSTR szName; // pointer to name (in user addr space) >+ DWORD dwThreadID; // thread ID (-1=caller thread) >+ DWORD dwFlags; // reserved for future use, must be zero >+} THREADNAME_INFO; >+#pragma pack(pop) >+ >+void Thread::initializeCurrentThreadInternal(const char* szThreadName) >+{ >+#if COMPILER(MINGW) >+ // FIXME: Implement thread name setting with MingW. >+ UNUSED_PARAM(szThreadName); >+#else >+ THREADNAME_INFO info; >+ info.dwType = 0x1000; >+ info.szName = Thread::normalizeThreadName(szThreadName); >+ info.dwThreadID = GetCurrentThreadId(); >+ info.dwFlags = 0; >+ >+ __try { >+ RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), reinterpret_cast<ULONG_PTR*>(&info)); >+ } __except(EXCEPTION_CONTINUE_EXECUTION) { } >+#endif >+ initializeCurrentThreadEvenIfNonWTFCreated(); >+} >+ >+void Thread::initializePlatformThreading() >+{ >+} >+ >+static unsigned __stdcall wtfThreadEntryPoint(void* data) >+{ >+ Thread::entryPoint(reinterpret_cast<Thread::NewThreadContext*>(data)); >+ return 0; >+} >+ >+bool Thread::establishHandle(NewThreadContext* data) >+{ >+ unsigned threadIdentifier = 0; >+ HANDLE threadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, wtfThreadEntryPoint, data, 0, &threadIdentifier)); >+ if (!threadHandle) { >+ LOG_ERROR("Failed to create thread at entry point %p with data %p: %ld", wtfThreadEntryPoint, data, errno); >+ return false; >+ } >+ establishPlatformSpecificHandle(threadHandle, threadIdentifier); >+ return true; >+} >+ >+void Thread::changePriority(int delta) >+{ >+ auto locker = holdLock(m_mutex); >+ SetThreadPriority(m_handle, THREAD_PRIORITY_NORMAL + delta); >+} >+ >+int Thread::waitForCompletion() >+{ >+ HANDLE handle; >+ { >+ auto locker = holdLock(m_mutex); >+ handle = m_handle; >+ } >+ >+ DWORD joinResult = WaitForSingleObject(handle, INFINITE); >+ if (joinResult == WAIT_FAILED) >+ LOG_ERROR("Thread %p was found to be deadlocked trying to quit", this); >+ >+ auto locker = holdLock(m_mutex); >+ ASSERT(joinableState() == Joinable); >+ >+ // The thread has already exited, do nothing. >+ // The thread hasn't exited yet, so don't clean anything up. Just signal that we've already joined on it so that it will clean up after itself. >+ if (!hasExited()) >+ didJoin(); >+ >+ return joinResult; >+} >+ >+void Thread::detach() >+{ >+ // We follow the pthread semantics: even after the detach is called, >+ // we can still perform various operations onto the thread. For example, >+ // we can do pthread_kill for the detached thread. The problem in Windows >+ // is that closing HANDLE loses the way to do such operations. >+ // To do so, we do nothing here in Windows. Original detach's purpose, >+ // releasing thread resource when the thread exits, will be achieved by >+ // FlsCallback automatically. FlsCallback will call CloseHandle to clean up >+ // resource. So in this function, we just mark the thread as detached to >+ // avoid calling waitForCompletion for this thread. >+ auto locker = holdLock(m_mutex); >+ if (!hasExited()) >+ didBecomeDetached(); >+} >+ >+auto Thread::suspend() -> Expected<void, PlatformSuspendError> >+{ >+ RELEASE_ASSERT_WITH_MESSAGE(this != &Thread::current(), "We do not support suspending the current thread itself."); >+ LockHolder locker(globalSuspendLock); >+ DWORD result = SuspendThread(m_handle); >+ if (result != (DWORD)-1) >+ return { }; >+ return makeUnexpected(result); >+} >+ >+// During resume, suspend or resume should not be executed from the other threads. >+void Thread::resume() >+{ >+ LockHolder locker(globalSuspendLock); >+ ResumeThread(m_handle); >+} >+ >+size_t Thread::getRegisters(PlatformRegisters& registers) >+{ >+ LockHolder locker(globalSuspendLock); >+ registers.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL; >+ GetThreadContext(m_handle, ®isters); >+ return sizeof(CONTEXT); >+} >+ >+Thread& Thread::initializeCurrentTLS() >+{ >+ // Not a WTF-created thread, ThreadIdentifier is not established yet. >+ Ref<Thread> thread = adoptRef(*new Thread()); >+ >+ HANDLE handle; >+ bool isSuccessful = DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &handle, 0, FALSE, DUPLICATE_SAME_ACCESS); >+ RELEASE_ASSERT(isSuccessful); >+ >+ thread->establishPlatformSpecificHandle(handle, currentID()); >+ thread->initializeInThread(); >+ initializeCurrentThreadEvenIfNonWTFCreated(); >+ >+ return initializeTLS(WTFMove(thread)); >+} >+ >+ThreadIdentifier Thread::currentID() >+{ >+ return static_cast<ThreadIdentifier>(GetCurrentThreadId()); >+} >+ >+void Thread::establishPlatformSpecificHandle(HANDLE handle, ThreadIdentifier threadID) >+{ >+ auto locker = holdLock(m_mutex); >+ m_handle = handle; >+ m_id = threadID; >+} >+ >+#define InvalidThread reinterpret_cast<Thread*>(static_cast<uintptr_t>(0xbbadbeef)) >+ >+static WordLock threadMapMutex; >+ >+static HashMap<ThreadIdentifier, Thread*>& threadMap() >+{ >+ static NeverDestroyed<HashMap<ThreadIdentifier, Thread*>> map; >+ return map.get(); >+} >+ >+void Thread::initializeTLSKey() >+{ >+ threadMap(); >+ threadSpecificKeyCreate(&s_key, destructTLS); >+} >+ >+Thread* Thread::currentDying() >+{ >+ ASSERT(s_key != InvalidThreadSpecificKey); >+ // After FLS is destroyed, this map offers the value until the second thread exit callback is called. >+ auto locker = holdLock(threadMapMutex); >+ return threadMap().get(currentID()); >+} >+ >+// FIXME: Remove this workaround code once <rdar://problem/31793213> is fixed. >+RefPtr<Thread> Thread::get(ThreadIdentifier id) >+{ >+ auto locker = holdLock(threadMapMutex); >+ Thread* thread = threadMap().get(id); >+ if (thread) >+ return thread; >+ return nullptr; >+} >+ >+Thread& Thread::initializeTLS(Ref<Thread>&& thread) >+{ >+ ASSERT(s_key != InvalidThreadSpecificKey); >+ // FIXME: Remove this workaround code once <rdar://problem/31793213> is fixed. >+ auto id = thread->id(); >+ // We leak the ref to keep the Thread alive while it is held in TLS. destructTLS will deref it later at thread destruction time. >+ auto& threadInTLS = thread.leakRef(); >+ threadSpecificSet(s_key, &threadInTLS); >+ { >+ auto locker = holdLock(threadMapMutex); >+ threadMap().add(id, &threadInTLS); >+ } >+ return threadInTLS; >+} >+ >+void Thread::destructTLS(void* data) >+{ >+ if (data == InvalidThread) >+ return; >+ >+ Thread* thread = static_cast<Thread*>(data); >+ ASSERT(thread); >+ >+ // Delay the deallocation of Thread more. >+ // It defers Thread deallocation after the other ThreadSpecific values are deallocated. >+ static thread_local class ThreadExitCallback { >+ public: >+ ThreadExitCallback(Thread* thread) >+ : m_thread(thread) >+ { >+ } >+ >+ ~ThreadExitCallback() >+ { >+ Thread::destructTLS(m_thread); >+ } >+ >+ private: >+ Thread* m_thread; >+ } callback(thread); >+ >+ if (thread->m_isDestroyedOnce) { >+ { >+ auto locker = holdLock(threadMapMutex); >+ ASSERT(threadMap().contains(thread->id())); >+ threadMap().remove(thread->id()); >+ } >+ thread->didExit(); >+ thread->deref(); >+ >+ // Fill the FLS with the non-nullptr value. While FLS destructor won't be called for that, >+ // non-nullptr value tells us that we already destructed Thread. This allows us to >+ // detect incorrect use of Thread::current() after this point because it will crash. >+ threadSpecificSet(s_key, InvalidThread); >+ return; >+ } >+ threadSpecificSet(s_key, InvalidThread); >+ thread->m_isDestroyedOnce = true; >+} >+ >+Mutex::~Mutex() >+{ >+} >+ >+void Mutex::lock() >+{ >+ AcquireSRWLockExclusive(&m_mutex); >+} >+ >+bool Mutex::tryLock() >+{ >+ return TryAcquireSRWLockExclusive(&m_mutex); >+} >+ >+void Mutex::unlock() >+{ >+ ReleaseSRWLockExclusive(&m_mutex); >+} >+ >+// Returns an interval in milliseconds suitable for passing to one of the Win32 wait functions (e.g., ::WaitForSingleObject). >+static DWORD absoluteTimeToWaitTimeoutInterval(WallTime absoluteTime) >+{ >+ WallTime currentTime = WallTime::now(); >+ >+ // Time is in the past - return immediately. >+ if (absoluteTime < currentTime) >+ return 0; >+ >+ // Time is too far in the future (and would overflow unsigned long) - wait forever. >+ if ((absoluteTime - currentTime) > Seconds::fromMilliseconds(INT_MAX)) >+ return INFINITE; >+ >+ return static_cast<DWORD>((absoluteTime - currentTime).milliseconds()); >+} >+ >+ThreadCondition::~ThreadCondition() >+{ >+} >+ >+void ThreadCondition::wait(Mutex& mutex) >+{ >+ SleepConditionVariableSRW(&m_condition, &mutex.impl(), INFINITE, 0); >+} >+ >+bool ThreadCondition::timedWait(Mutex& mutex, WallTime absoluteTime) >+{ >+ // https://msdn.microsoft.com/en-us/library/windows/desktop/ms686304(v=vs.85).aspx >+ DWORD interval = absoluteTimeToWaitTimeoutInterval(absoluteTime); >+ if (!interval) { >+ // Consider the wait to have timed out, even if our condition has already been signaled, to >+ // match the pthreads implementation. >+ return false; >+ } >+ >+ if (SleepConditionVariableSRW(&m_condition, &mutex.impl(), interval, 0)) >+ return true; >+ ASSERT(GetLastError() == ERROR_TIMEOUT); >+ return false; >+} >+ >+void ThreadCondition::signal() >+{ >+ WakeConditionVariable(&m_condition); >+} >+ >+void ThreadCondition::broadcast() >+{ >+ WakeAllConditionVariable(&m_condition); >+} >+ >+// Remove this workaround code when <rdar://problem/31793213> is fixed. >+ThreadIdentifier createThread(ThreadFunction function, void* data, const char* threadName) >+{ >+ return Thread::create(threadName, [function, data] { >+ function(data); >+ })->id(); >+} >+ >+int waitForThreadCompletion(ThreadIdentifier threadID) >+{ >+ // This function is implemented based on the old Threading implementation. >+ // It remains only due to the support library using old Threading APIs and >+ // it should not be used in new code. >+ ASSERT(threadID); >+ >+ RefPtr<Thread> thread = Thread::get(threadID); >+ if (!thread) { >+ LOG_ERROR("ThreadIdentifier %u did not correspond to an active thread when trying to quit", threadID); >+ return WAIT_FAILED; >+ } >+ return thread->waitForCompletion(); >+ >+} >+ >+void Thread::yield() >+{ >+ SwitchToThread(); >+} >+ >+} // namespace WTF
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193929
:
360384
| 360419