WTF::Function does not allow for reference / non-default constructible return types
[WebKit-https.git] / Source / WTF / ChangeLog
1 2017-08-09  Sam Weinig  <sam@webkit.org>
2
3         WTF::Function does not allow for reference / non-default constructible return types
4         https://bugs.webkit.org/show_bug.cgi?id=175244
5
6         Reviewed by Chris Dumez.
7
8         When Function, then NoncopyableFunction, was templatized to allow non-void return values
9         in r201493, it maintained the behavior of being callable even if the Function was null.
10         To accomplish this, when null, the default construction of the return parameter was used.
11         This means Function can't be used with return types that are not default constructible,
12         such as reference types and Ref.
13
14         This behavior of returning something when null is surprising, as this is not how normal
15         functions behave, and not very useful. Instead, we now assert that the function is not
16         null when being called.
17
18         * wtf/Function.h:
19         (WTF::Function operator(...)):
20         Instead of allowing a null callable wrapper by returning the default construction of
21         the return type, assert that the wrapper is there when calling a Function.
22
23 2017-08-08  Filip Pizlo  <fpizlo@apple.com>
24
25         Baseline JIT should do caging
26         https://bugs.webkit.org/show_bug.cgi?id=175037
27
28         Reviewed by Mark Lam.
29
30         * wtf/Gigacage.h:
31         (Gigacage::disableDisablingPrimitiveGigacageIfShouldBeEnabled):
32         (Gigacage::isDisablingPrimitiveGigacageDisabled):
33         (Gigacage::isPrimitiveGigacagePermanentlyEnabled):
34         (Gigacage::canPrimitiveGigacageBeDisabled):
35         (Gigacage::basePtr):
36
37 2017-08-08  Ryan Haddad  <ryanhaddad@apple.com>
38
39         Unreviewed, rolling out r220368.
40
41         This change caused WK1 tests to exit early with crashes.
42
43         Reverted changeset:
44
45         "Baseline JIT should do caging"
46         https://bugs.webkit.org/show_bug.cgi?id=175037
47         http://trac.webkit.org/changeset/220368
48
49 2017-08-08  Michael Catanzaro  <mcatanzaro@igalia.com>
50
51         [CMake] Properly test if compiler supports compiler flags
52         https://bugs.webkit.org/show_bug.cgi?id=174490
53
54         Reviewed by Konstantin Tokarev.
55
56         * wtf/Compiler.h:
57
58 2017-08-07  Filip Pizlo  <fpizlo@apple.com>
59
60         Baseline JIT should do caging
61         https://bugs.webkit.org/show_bug.cgi?id=175037
62
63         Reviewed by Mark Lam.
64
65         * wtf/Gigacage.h:
66         (Gigacage::disableDisablingPrimitiveGigacageIfShouldBeEnabled):
67         (Gigacage::isDisablingPrimitiveGigacageDisabled):
68         (Gigacage::isPrimitiveGigacagePermanentlyEnabled):
69         (Gigacage::canPrimitiveGigacageBeDisabled):
70
71 2017-08-07  Filip Pizlo  <fpizlo@apple.com>
72
73         Unreviewed, try to fix Windows build.
74
75         * wtf/Gigacage.cpp:
76         * wtf/Gigacage.h:
77
78 2017-08-06  Filip Pizlo  <fpizlo@apple.com>
79
80         Primitive auxiliaries and JSValue auxiliaries should have separate gigacages
81         https://bugs.webkit.org/show_bug.cgi?id=174919
82
83         Reviewed by Keith Miller.
84         
85         This mirrors the changes from bmalloc/Gigacage.h.
86         
87         Also it teaches CagedPtr how to reason about multiple gigacages.
88
89         * wtf/CagedPtr.h:
90         (WTF::CagedPtr::get const):
91         (WTF::CagedPtr::operator[] const):
92         * wtf/Gigacage.cpp:
93         (Gigacage::tryMalloc):
94         (Gigacage::tryAllocateVirtualPages):
95         (Gigacage::freeVirtualPages):
96         (Gigacage::tryAlignedMalloc):
97         (Gigacage::alignedFree):
98         (Gigacage::free):
99         * wtf/Gigacage.h:
100         (Gigacage::disablePrimitiveGigacage):
101         (Gigacage::addPrimitiveDisableCallback):
102         (Gigacage::removePrimitiveDisableCallback):
103         (Gigacage::name):
104         (Gigacage::basePtr):
105         (Gigacage::caged):
106         (Gigacage::isCaged):
107         (Gigacage::tryAlignedMalloc):
108         (Gigacage::alignedFree):
109         (Gigacage::free):
110         (Gigacage::disableGigacage): Deleted.
111         (Gigacage::addDisableCallback): Deleted.
112         (Gigacage::removeDisableCallback): Deleted.
113
114 2017-08-07  Brian Burg  <bburg@apple.com>
115
116         Remove CANVAS_PATH compilation guard
117         https://bugs.webkit.org/show_bug.cgi?id=175207
118
119         Reviewed by Sam Weinig.
120
121         * wtf/FeatureDefines.h:
122
123 2017-08-05  Filip Pizlo  <fpizlo@apple.com>
124
125         REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372
126         https://bugs.webkit.org/show_bug.cgi?id=175083
127
128         Reviewed by Oliver Hunt.
129         
130         Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is
131         guaranted to bias in favor of writers or not.
132
133         * WTF.xcodeproj/project.pbxproj:
134         * wtf/Condition.h:
135         (WTF::ConditionBase::construct):
136         (WTF::Condition::Condition):
137         * wtf/Lock.h:
138         (WTF::LockBase::construct):
139         (WTF::Lock::Lock):
140         * wtf/ReadWriteLock.cpp: Added.
141         (WTF::ReadWriteLockBase::construct):
142         (WTF::ReadWriteLockBase::readLock):
143         (WTF::ReadWriteLockBase::readUnlock):
144         (WTF::ReadWriteLockBase::writeLock):
145         (WTF::ReadWriteLockBase::writeUnlock):
146         * wtf/ReadWriteLock.h: Added.
147         (WTF::ReadWriteLockBase::ReadLock::tryLock):
148         (WTF::ReadWriteLockBase::ReadLock::lock):
149         (WTF::ReadWriteLockBase::ReadLock::unlock):
150         (WTF::ReadWriteLockBase::WriteLock::tryLock):
151         (WTF::ReadWriteLockBase::WriteLock::lock):
152         (WTF::ReadWriteLockBase::WriteLock::unlock):
153         (WTF::ReadWriteLockBase::read):
154         (WTF::ReadWriteLockBase::write):
155         (WTF::ReadWriteLock::ReadWriteLock):
156
157 2017-08-04  Matt Lewis  <jlewis3@apple.com>
158
159         Unreviewed, rolling out r220271.
160
161         Rolling out due to Layout Test failing on iOS Simulator.
162
163         Reverted changeset:
164
165         "Remove STREAMS_API compilation guard"
166         https://bugs.webkit.org/show_bug.cgi?id=175165
167         http://trac.webkit.org/changeset/220271
168
169 2017-08-04  Youenn Fablet  <youenn@apple.com>
170
171         Remove STREAMS_API compilation guard
172         https://bugs.webkit.org/show_bug.cgi?id=175165
173
174         Reviewed by Darin Adler.
175
176         * wtf/FeatureDefines.h:
177
178 2017-08-03  Brian Burg  <bburg@apple.com>
179
180         Remove ENABLE(WEB_SOCKET) guards
181         https://bugs.webkit.org/show_bug.cgi?id=167044
182
183         Reviewed by Joseph Pecoraro.
184
185         * wtf/FeatureDefines.h:
186
187 2017-08-03  Youenn Fablet  <youenn@apple.com>
188
189         Remove FETCH_API compilation guard
190         https://bugs.webkit.org/show_bug.cgi?id=175154
191
192         Reviewed by Chris Dumez.
193
194         * wtf/FeatureDefines.h:
195
196 2017-08-03  Brady Eidson  <beidson@apple.com>
197
198         Add SW IDLs and stub out basic functionality.
199         https://bugs.webkit.org/show_bug.cgi?id=175115
200
201         Reviewed by Chris Dumez.
202
203         * wtf/FeatureDefines.h:
204
205 2017-08-03  Yusuke Suzuki  <utatane.tea@gmail.com>
206
207         Unreviewed, build fix for Windows port
208         https://bugs.webkit.org/show_bug.cgi?id=175013
209
210         * wtf/Threading.h:
211
212 2017-08-03  Yusuke Suzuki  <utatane.tea@gmail.com>
213
214         Merge ThreadHolder to WTF::Thread itself
215         https://bugs.webkit.org/show_bug.cgi?id=175013
216
217         Reviewed by Mark Lam.
218
219         Currently, we store ThreadHolder* to the TLS, and ThreadHolder* holds Ref<Thread>.
220         When we get Thread& from the current thread TLS, we need to dereference the ThreadHolder*.
221         However, ideally, we can store Thread* directly to the current thread TLS.
222         While the ThreadHolder design is beautiful, it's worth optimizing by storing Thread* directly
223         since Thread::current() is so frequently executed.
224
225         This patch merges ThreadHolder to Thread. And we now store Thread* directly in the TLS.
226         When storing it to TLS, we call leakRef() to keep Thread ref count incremented by the TLS.
227         And when destroying the TLS, we call `deref()` to ensure that Thread* is dereferenced from
228         the TLS.
229
230         * WTF.xcodeproj/project.pbxproj:
231         * wtf/CMakeLists.txt:
232         * wtf/ThreadHolder.cpp: Removed.
233         * wtf/ThreadHolder.h: Removed.
234         * wtf/ThreadHolderPthreads.cpp: Removed.
235         * wtf/ThreadHolderWin.cpp: Removed.
236         * wtf/Threading.cpp:
237         (WTF::Thread::entryPoint):
238         (WTF::initializeThreading):
239         * wtf/Threading.h:
240         (WTF::Thread::currentMayBeNull):
241         (WTF::Thread::current):
242         * wtf/ThreadingPthreads.cpp:
243         (WTF::Thread::waitForCompletion):
244         (WTF::Thread::initializeCurrentTLS):
245         (WTF::Thread::initializeTLSKey):
246         (WTF::Thread::initializeTLS):
247         (WTF::Thread::destructTLS):
248         (WTF::Thread::createCurrentThread): Deleted.
249         * wtf/ThreadingWin.cpp:
250         (WTF::Thread::initializeCurrentTLS):
251         (WTF::threadMapMutex):
252         (WTF::Thread::initializeTLSKey):
253         (WTF::Thread::currentDying):
254         (WTF::Thread::get):
255         (WTF::Thread::initializeTLS):
256         (WTF::Thread::destructTLS):
257         (WTF::waitForThreadCompletion):
258         (WTF::Thread::createCurrentThread): Deleted.
259
260 2017-08-03  Yusuke Suzuki  <utatane.tea@gmail.com>
261
262         [Linux][WTF] Use one global semaphore to notify thread suspend and resume completion
263         https://bugs.webkit.org/show_bug.cgi?id=175124
264
265         Reviewed by Carlos Garcia Campos.
266
267         POSIX sem_t is used to notify thread suspend and resume completion in Linux ports
268         since sem_post is async-signal-safe function. Since we guard suspend() and resume()
269         with one global lock, this semaphore is also guarded by this lock. So we do not need
270         to have semaphore per WTF::Thread.
271
272         This patch introduces one global Semaphore. And drop per thread semaphore.
273
274         * wtf/Threading.h:
275         * wtf/ThreadingPthreads.cpp:
276         (WTF::Thread::~Thread):
277         (WTF::Semaphore::Semaphore):
278         (WTF::Semaphore::~Semaphore):
279         (WTF::Semaphore::wait):
280         (WTF::Semaphore::post):
281         (WTF::Thread::signalHandlerSuspendResume):
282         (WTF::Thread::initializePlatformThreading):
283         (WTF::Thread::suspend):
284         (WTF::Thread::resume):
285         (WTF::Thread::Thread): Deleted.
286         * wtf/ThreadingWin.cpp:
287         (WTF::Thread::Thread): Deleted.
288
289 2017-08-03  Yusuke Suzuki  <utatane.tea@gmail.com>
290
291         [Linux][WTF] Reduce sizeof(WTF::Thread) by using a pointer to PlatformRegisters
292         https://bugs.webkit.org/show_bug.cgi?id=175119
293
294         Reviewed by Carlos Garcia Campos.
295
296         sizeof(PlatformRegisters) is so large. In my Linux box, it is 256. It enlarges the sizeof(WTF::Thread).
297         However, it is not necessary to hold it in WTF::Thread member. Thread's ucontext data and its stack is
298         effective while suspending the thread. So, we can just use the pointer to the PlatformRegister instead
299         of copying it to the member of the WTF::Thread.
300
301         * wtf/Threading.h:
302         * wtf/ThreadingPthreads.cpp:
303         (WTF::Thread::signalHandlerSuspendResume):
304         (WTF::Thread::getRegisters):
305
306 2017-08-02  Yusuke Suzuki  <utatane.tea@gmail.com>
307
308         Unreviewed, build fix for Windows port
309         https://bugs.webkit.org/show_bug.cgi?id=174716
310
311         This ugliness will be fixed in https://bugs.webkit.org/show_bug.cgi?id=175013.
312
313         * wtf/ThreadHolder.h:
314         * wtf/Threading.h:
315
316 2017-08-02  Yusuke Suzuki  <utatane.tea@gmail.com>
317
318         Merge WTFThreadData to Thread::current
319         https://bugs.webkit.org/show_bug.cgi?id=174716
320
321         Reviewed by Mark Lam.
322
323         We placed thread specific data in WTFThreadData previously. But now, we have a new good place
324         to put thread specific data: WTF::Thread. Before this patch, WTFThreadData and WTF::Thread
325         sometimes have the completely same fields (m_stack etc.) due to initialization order limitations.
326         This patch merges WTFThreadData to WTF::Thread. We apply WTFThreadData's initialization style
327         to WTF::Thread. So, WTF::Thread's holder now uses fast TLS for darwin environment. Thus,
328         Thread::current() access is now accelerated. And WTF::Thread::current() can be accessed even
329         before calling WTF::initializeThreading.
330
331         * WTF.xcodeproj/project.pbxproj:
332         * wtf/CMakeLists.txt:
333         * wtf/LockAlgorithm.h:
334         * wtf/LockAlgorithmInlines.h:
335         * wtf/MainThread.h:
336         * wtf/ParkingLot.cpp:
337         * wtf/StackStats.cpp:
338         (WTF::StackStats::PerThreadStats::PerThreadStats):
339         (WTF::StackStats::CheckPoint::CheckPoint):
340         (WTF::StackStats::CheckPoint::~CheckPoint):
341         (WTF::StackStats::probe):
342         (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
343         * wtf/ThreadHolder.cpp:
344         (WTF::ThreadHolder::initializeCurrent):
345         * wtf/ThreadHolder.h:
346         (WTF::ThreadHolder::ThreadHolder):
347         (WTF::ThreadHolder::currentMayBeNull):
348         (WTF::ThreadHolder::current):
349         * wtf/ThreadHolderPthreads.cpp:
350         (WTF::ThreadHolder::initializeKey):
351         (WTF::ThreadHolder::initialize):
352         (WTF::ThreadHolder::destruct):
353         (WTF::ThreadHolder::initializeOnce): Deleted.
354         (WTF::ThreadHolder::current): Deleted.
355         * wtf/ThreadHolderWin.cpp:
356         (WTF::ThreadHolder::initializeKey):
357         (WTF::ThreadHolder::currentDying):
358         (WTF::ThreadHolder::initialize):
359         (WTF::ThreadHolder::initializeOnce): Deleted.
360         (WTF::ThreadHolder::current): Deleted.
361         * wtf/Threading.cpp:
362         (WTF::Thread::initializeInThread):
363         (WTF::Thread::entryPoint):
364         (WTF::Thread::create):
365         (WTF::Thread::didExit):
366         (WTF::initializeThreading):
367         (WTF::Thread::currentMayBeNull): Deleted.
368         * wtf/Threading.h:
369         (WTF::Thread::current):
370         (WTF::Thread::atomicStringTable):
371         (WTF::Thread::setCurrentAtomicStringTable):
372         (WTF::Thread::stackStats):
373         (WTF::Thread::savedStackPointerAtVMEntry):
374         (WTF::Thread::setSavedStackPointerAtVMEntry):
375         (WTF::Thread::savedLastStackTop):
376         (WTF::Thread::setSavedLastStackTop):
377         * wtf/ThreadingPrimitives.h:
378         * wtf/ThreadingPthreads.cpp:
379         (WTF::Thread::createCurrentThread):
380         (WTF::Thread::current): Deleted.
381         * wtf/ThreadingWin.cpp:
382         (WTF::Thread::createCurrentThread):
383         (WTF::Thread::current): Deleted.
384         * wtf/WTFThreadData.cpp: Removed.
385         * wtf/WTFThreadData.h: Removed.
386         * wtf/text/AtomicString.cpp:
387         * wtf/text/AtomicStringImpl.cpp:
388         (WTF::stringTable):
389         * wtf/text/AtomicStringTable.cpp:
390         (WTF::AtomicStringTable::create):
391         * wtf/text/AtomicStringTable.h:
392
393 2017-08-02  Joseph Pecoraro  <pecoraro@apple.com>
394
395         NeverDestroyed related leaks seen on bots
396         https://bugs.webkit.org/show_bug.cgi?id=175113
397
398         Reviewed by Yusuke Suzuki.
399
400         * wtf/NeverDestroyed.h:
401         (WTF::NeverDestroyed::NeverDestroyed):
402         Previously the result of makeNeverDestroyed was not always moving into
403         the `static NeverDestroyed` static local variable. In some cases it would
404         re-invoke the constructor, creating a new NeverDestroyed object. In the
405         case of a Vector it was causing leaks.
406
407         Adding a move constructor convinces the compiler to move the result
408         of makeNeverDestroyed into the NeverDestroyed static. It doesn't actually
409         invoke the move constructor here, which I believe means it is deciding
410         to perform optional copy elision optimization.
411         'http://en.cppreference.com/w/cpp/language/copy_elision
412
413 2017-08-02  Filip Pizlo  <fpizlo@apple.com>
414
415         All C++ accesses to JSObject::m_butterfly should do caging
416         https://bugs.webkit.org/show_bug.cgi?id=175039
417
418         Reviewed by Keith Miller.
419         
420         Adds a smart pointer class that does various kinds of caging for you.
421
422         * WTF.xcodeproj/project.pbxproj:
423         * wtf/CMakeLists.txt:
424         * wtf/CagedPtr.h: Added.
425         (WTF::CagedPtr::CagedPtr):
426         (WTF::CagedPtr::get const):
427         (WTF::CagedPtr::getMayBeNull const):
428         (WTF::CagedPtr::operator== const):
429         (WTF::CagedPtr::operator!= const):
430         (WTF::CagedPtr::operator bool const):
431         (WTF::CagedPtr::operator* const):
432         (WTF::CagedPtr::operator-> const):
433
434 2017-08-02  Filip Pizlo  <fpizlo@apple.com>
435
436         We should be OK with the gigacage being disabled on gmalloc
437         https://bugs.webkit.org/show_bug.cgi?id=175082
438
439         Reviewed by Michael Saboff.
440
441         * wtf/Gigacage.h:
442         (Gigacage::shouldBeEnabled):
443
444 2017-08-01  Filip Pizlo  <fpizlo@apple.com>
445
446         Bmalloc and GC should put auxiliaries (butterflies, typed array backing stores) in a gigacage (separate multi-GB VM region)
447         https://bugs.webkit.org/show_bug.cgi?id=174727
448
449         Reviewed by Mark Lam.
450         
451         For the Gigacage project to have minimal impact, we need to have some abstraction that allows code to
452         avoid having to guard itself with #if's. This adds a Gigacage abstraction that overlays the Gigacage
453         namespace from bmalloc, which always lets you call things like Gigacage::caged and Gigacage::tryMalloc.
454         
455         Because of how many places need to possibly allocate in a gigacage, or possibly perform caged accesses,
456         it's better to hide the question of whether or not it's enabled inside this API.
457
458         * WTF.xcodeproj/project.pbxproj:
459         * wtf/CMakeLists.txt:
460         * wtf/FastMalloc.cpp:
461         * wtf/Gigacage.cpp: Added.
462         (Gigacage::tryMalloc):
463         (Gigacage::tryAllocateVirtualPages):
464         (Gigacage::freeVirtualPages):
465         (Gigacage::tryAlignedMalloc):
466         (Gigacage::alignedFree):
467         (Gigacage::free):
468         * wtf/Gigacage.h: Added.
469         (Gigacage::ensureGigacage):
470         (Gigacage::disableGigacage):
471         (Gigacage::addDisableCallback):
472         (Gigacage::removeDisableCallback):
473         (Gigacage::caged):
474         (Gigacage::isCaged):
475         (Gigacage::tryAlignedMalloc):
476         (Gigacage::alignedFree):
477         (Gigacage::free):
478
479 2017-07-31  Matt Lewis  <jlewis3@apple.com>
480
481         Unreviewed, rolling out r220060.
482
483         This broke our internal builds. Contact reviewer of patch for
484         more information.
485
486         Reverted changeset:
487
488         "Merge WTFThreadData to Thread::current"
489         https://bugs.webkit.org/show_bug.cgi?id=174716
490         http://trac.webkit.org/changeset/220060
491
492 2017-07-31  Yusuke Suzuki  <utatane.tea@gmail.com>
493
494         Merge WTFThreadData to Thread::current
495         https://bugs.webkit.org/show_bug.cgi?id=174716
496
497         Reviewed by Sam Weinig.
498
499         We placed thread specific data in WTFThreadData previously. But now, we have a new good place
500         to put thread specific data: WTF::Thread. Before this patch, WTFThreadData and WTF::Thread
501         sometimes have the completely same fields (m_stack etc.) due to initialization order limitations.
502         This patch merges WTFThreadData to WTF::Thread. We apply WTFThreadData's initialization style
503         to WTF::Thread. So, WTF::Thread's holder now uses fast TLS for darwin environment. Thus,
504         Thread::current() access is now accelerated. And WTF::Thread::current() can be accessed even
505         before calling WTF::initializeThreading.
506
507         * WTF.xcodeproj/project.pbxproj:
508         * wtf/CMakeLists.txt:
509         * wtf/LockAlgorithm.h:
510         * wtf/LockAlgorithmInlines.h:
511         * wtf/MainThread.h:
512         * wtf/ParkingLot.cpp:
513         * wtf/StackStats.cpp:
514         (WTF::StackStats::PerThreadStats::PerThreadStats):
515         (WTF::StackStats::CheckPoint::CheckPoint):
516         (WTF::StackStats::CheckPoint::~CheckPoint):
517         (WTF::StackStats::probe):
518         (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
519         * wtf/ThreadHolder.cpp:
520         (WTF::ThreadHolder::initializeCurrent):
521         * wtf/ThreadHolder.h:
522         (WTF::ThreadHolder::ThreadHolder):
523         (WTF::ThreadHolder::currentMayBeNull):
524         (WTF::ThreadHolder::current):
525         * wtf/ThreadHolderPthreads.cpp:
526         (WTF::ThreadHolder::initialize):
527         (WTF::ThreadHolder::destruct):
528         (WTF::ThreadHolder::current): Deleted.
529         * wtf/ThreadHolderWin.cpp:
530         (WTF::ThreadHolder::currentDying):
531         (WTF::ThreadHolder::initialize):
532         (WTF::ThreadHolder::current): Deleted.
533         * wtf/Threading.cpp:
534         (WTF::Thread::initializeInThread):
535         (WTF::Thread::entryPoint):
536         (WTF::Thread::didExit):
537         (WTF::initializeThreading):
538         (WTF::Thread::currentMayBeNull): Deleted.
539         * wtf/Threading.h:
540         (WTF::Thread::atomicStringTable):
541         (WTF::Thread::setCurrentAtomicStringTable):
542         (WTF::Thread::stackStats):
543         (WTF::Thread::savedStackPointerAtVMEntry):
544         (WTF::Thread::setSavedStackPointerAtVMEntry):
545         (WTF::Thread::savedLastStackTop):
546         (WTF::Thread::setSavedLastStackTop):
547         (WTF::Thread::current):
548         * wtf/ThreadingPrimitives.h:
549         * wtf/ThreadingPthreads.cpp:
550         (WTF::Thread::createCurrentThread):
551         (WTF::Thread::current): Deleted.
552         * wtf/ThreadingWin.cpp:
553         (WTF::Thread::createCurrentThread):
554         (WTF::Thread::current): Deleted.
555         * wtf/WTFThreadData.cpp: Removed.
556         * wtf/WTFThreadData.h: Removed.
557         * wtf/text/AtomicString.cpp:
558         * wtf/text/AtomicStringImpl.cpp:
559         (WTF::stringTable):
560         * wtf/text/AtomicStringTable.cpp:
561         (WTF::AtomicStringTable::create):
562         * wtf/text/AtomicStringTable.h:
563
564 2017-07-31  Xabier Rodriguez Calvar  <calvaris@igalia.com>
565
566         Created a bool pretty printer at WTF for debugging purposes
567         https://bugs.webkit.org/show_bug.cgi?id=174893
568
569         Reviewed by Darin Adler.
570
571         * wtf/PrintStream.cpp:
572         (WTF::printInternal): The overload taking bool uses boolForPrinting
573         * wtf/PrintStream.h:
574         (WTF::boolForPrinting): Converts a bool in "true" or "false".
575
576 2017-07-30  Yusuke Suzuki  <utatane.tea@gmail.com>
577
578         [WTF] Introduce Private Symbols
579         https://bugs.webkit.org/show_bug.cgi?id=174935
580
581         Reviewed by Darin Adler.
582
583         Upcoming proposal of class fields[1] requires private fields.
584         The simple way to implement it is adding a property with a private symbol.
585         Currently, we have private symbols for internal properties. They are usual
586         Symbols managed by the hash table. So basically private symbols are statically
587         created in BuiltinNames. However this new proposal encourages users to create
588         such private symbols more and more.
589
590         So, this patch introduces notion of "Private" into WTF SymbolImpl. This patch
591         adds PrivateSymbolImpl. This is SymbolImpl with "Private" flag. We do not need
592         to look up the symbol from the hash table to check whether the given symbol
593         is a private one.
594
595         [1]: https://github.com/tc39/proposal-class-fields
596
597         * wtf/text/StringImpl.h:
598         * wtf/text/SymbolImpl.cpp:
599         (WTF::PrivateSymbolImpl::create):
600         (WTF::PrivateSymbolImpl::createNullSymbol):
601         * wtf/text/SymbolImpl.h:
602         (WTF::SymbolImpl::isPrivate):
603         (WTF::SymbolImpl::StaticSymbolImpl::StaticSymbolImpl):
604         (WTF::SymbolImpl::SymbolImpl):
605         (WTF::PrivateSymbolImpl::PrivateSymbolImpl):
606
607 2017-07-30  Brady Eidson  <beidson@apple.com>
608
609         Add URLSchemeHandler API tests that verify the lack of URLSchemeTask object leaks.
610         https://bugs.webkit.org/show_bug.cgi?id=174958
611
612         Reviewed by Darin Adler.
613
614         This patch adds a new template class "InstanceCounted<T>".
615         
616         For each specialization, "InstanceCounted" will keep track of the total number of
617         instances in existence.
618         
619         This makes explicate leak checking in API tests possible.
620         
621         Since this adds some runtime and storage overhead the code that actually does anything
622         is only compiled in debug builds.
623         
624         * WTF.xcodeproj/project.pbxproj:
625         * wtf/InstanceCounted.h: Added.
626         (WTF::InstanceCounted::InstanceCounted):
627         (WTF::InstanceCounted::instanceCount):
628         (WTF::InstanceCounted::~InstanceCounted):
629
630 2017-07-27  Yusuke Suzuki  <utatane.tea@gmail.com>
631
632         [WTF] Drop Thread initialization wait in some platforms by introducing StackBounds::newThreadStackBounds(PlatformThreadHandle&)
633         https://bugs.webkit.org/show_bug.cgi?id=174303
634
635         Reviewed by Mark Lam.
636
637         Currently, the caller thread of Thread::create() need to wait for completion of the initialization of the target thread.
638         This is because we need to initialize Thread::m_stack in the target thread. Before this patch, a target thread's
639         StackBounds can only be retrieved by the target thread itself. However, this potentially causes context-switching between
640         the caller and the target threads and hurts efficiency of creating threads.
641
642         Fortunately, in some platforms (including major platforms except for Windows), we can get StackBounds of a target
643         thread from a caller thread. This allows us to avoid waiting for completion of thread initialization.
644
645         In this patch, we introduce HAVE_STACK_BOUNDS_FOR_NEW_THREAD and StackBounds::newThreadStackBounds. When creating
646         a new thread, we will use StackBounds::newThreadStackBounds to get StackBounds if possible. As a result, we
647         do not need to wait for completion of thread initialization to ensure m_stack field of Thread is initialized.
648
649         While some documents claim that it is possible on Windows to get the StackBounds of another thread[1], the method relies on
650         undocumented Windows NT APIs (NtQueryInformationThread, NtReadVirtualMemory etc.). So in this patch, we just
651         use the conservative approach simply waiting for completion of thread initialization.
652
653         [1]: https://stackoverflow.com/questions/3918375/how-to-get-thread-stack-information-on-windows
654
655         * wtf/Platform.h:
656         * wtf/StackBounds.cpp:
657         (WTF::StackBounds::newThreadStackBounds):
658         (WTF::StackBounds::currentThreadStackBoundsInternal):
659         (WTF::StackBounds::initialize): Deleted.
660         * wtf/StackBounds.h:
661         (WTF::StackBounds::currentThreadStackBounds):
662         (WTF::StackBounds::StackBounds):
663         * wtf/Threading.cpp:
664         (WTF::Thread::NewThreadContext::NewThreadContext):
665         (WTF::Thread::entryPoint):
666         (WTF::Thread::create):
667         (WTF::Thread::initialize): Deleted.
668         * wtf/Threading.h:
669         * wtf/ThreadingPrimitives.h:
670         * wtf/ThreadingPthreads.cpp:
671         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
672         (WTF::wtfThreadEntryPoint):
673         (WTF::Thread::establishHandle):
674         (WTF::Thread::initializeCurrentThreadInternal):
675         (WTF::Thread::current):
676         * wtf/ThreadingWin.cpp:
677         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
678         (WTF::Thread::initializeCurrentThreadInternal):
679         (WTF::Thread::current):
680         * wtf/win/MainThreadWin.cpp:
681         (WTF::initializeMainThreadPlatform):
682
683 2017-07-27  JF Bastien  <jfbastien@apple.com>
684
685         Update lock benchmarks
686         https://bugs.webkit.org/show_bug.cgi?id=174907
687
688         Reviewed by Filip Pizlo.
689
690         * benchmarks/ConditionSpeedTest.cpp:
691         (main):
692         * benchmarks/LockFairnessTest.cpp:
693         * benchmarks/LockSpeedTest.cpp:
694         * benchmarks/ToyLocks.h:
695
696 2017-07-26  Brian Burg  <bburg@apple.com>
697
698         Remove WEB_TIMING feature flag
699         https://bugs.webkit.org/show_bug.cgi?id=174795
700
701         Reviewed by Alex Christensen.
702
703         * wtf/FeatureDefines.h:
704
705 2017-07-26  Claudio Saavedra  <csaavedra@igalia.com>
706
707         [WPE] Enable KeyboardEvent key and code attributes
708         https://bugs.webkit.org/show_bug.cgi?id=174822
709
710         Reviewed by Žan Doberšek.
711
712         There is no reason for this to be disabled from what I see.
713
714         * wtf/FeatureDefines.h: Enable KeyboardEvent key and code attributes.
715
716 2017-07-23  Filip Pizlo  <fpizlo@apple.com>
717
718         B3 should do LICM
719         https://bugs.webkit.org/show_bug.cgi?id=174750
720
721         Reviewed by Keith Miller and Saam Barati.
722         
723         Moved DFG::NaturalLoops to WTF. The new templatized NaturalLoops<> uses the same Graph abstraction as
724         Dominators<>. This allows us to add a B3::NaturalLoops for free.
725         
726         Also made small tweaks to RangeSet, which the LICM uses.
727
728         * WTF.xcodeproj/project.pbxproj:
729         * wtf/CMakeLists.txt:
730         * wtf/Dominators.h:
731         * wtf/NaturalLoops.h: Added.
732         (WTF::NaturalLoop::NaturalLoop):
733         (WTF::NaturalLoop::graph):
734         (WTF::NaturalLoop::header):
735         (WTF::NaturalLoop::size):
736         (WTF::NaturalLoop::at):
737         (WTF::NaturalLoop::operator[]):
738         (WTF::NaturalLoop::contains):
739         (WTF::NaturalLoop::index):
740         (WTF::NaturalLoop::isOuterMostLoop):
741         (WTF::NaturalLoop::dump):
742         (WTF::NaturalLoop::addBlock):
743         (WTF::NaturalLoops::NaturalLoops):
744         (WTF::NaturalLoops::graph):
745         (WTF::NaturalLoops::numLoops):
746         (WTF::NaturalLoops::loop):
747         (WTF::NaturalLoops::headerOf):
748         (WTF::NaturalLoops::innerMostLoopOf):
749         (WTF::NaturalLoops::innerMostOuterLoop):
750         (WTF::NaturalLoops::belongsTo):
751         (WTF::NaturalLoops::loopDepth):
752         (WTF::NaturalLoops::loopsOf):
753         (WTF::NaturalLoops::dump):
754         * wtf/RangeSet.h:
755         (WTF::RangeSet::begin):
756         (WTF::RangeSet::end):
757         (WTF::RangeSet::addAll):
758
759 2017-07-23  Michael Catanzaro  <mcatanzaro@igalia.com>
760
761         Implement FALLTHROUGH attribute for C with GCC
762         https://bugs.webkit.org/show_bug.cgi?id=174555
763
764         Reviewed by Darin Adler.
765
766         My previous attempt to silence the JSC -Wimplicit-fallthrough warnings failed because they
767         are coming from a C file, and our FALLTHROUGH macro is only implemented for C++. So
768         implement it for C as well, using C attribute syntax.
769  
770         Note this is only possible to do for GCC, because Clang only supports this attribute using
771         the [[C++ attribute syntax]].
772
773         * wtf/Compiler.h:
774
775 2017-07-14  Filip Pizlo  <fpizlo@apple.com>
776
777         It should be easy to decide how WebKit yields
778         https://bugs.webkit.org/show_bug.cgi?id=174298
779
780         Reviewed by Saam Barati.
781         
782         Created a Thread::yield() abstraction for sched_yield(), and made WTF use it everywhere that it
783         had previously used std::this_thread::yield().
784         
785         To make it less annoying to experiment with changes to the lock algorithm in the future, this also
786         moves the meat of the algorithm into LockAlgorithmInlines.h. Only two files include that header.
787         Since LockAlgorithm.h no longer includes ParkingLot.h, a bunch of files in WK now need to include
788         timing headers (Seconds, MonotonicTime, etc) manually.
789
790         * WTF.xcodeproj/project.pbxproj:
791         * benchmarks/ToyLocks.h:
792         * wtf/CMakeLists.txt:
793         * wtf/Lock.cpp:
794         * wtf/LockAlgorithm.h:
795         (WTF::LockAlgorithm::lockSlow): Deleted.
796         (WTF::LockAlgorithm::unlockSlow): Deleted.
797         * wtf/LockAlgorithmInlines.h: Added.
798         (WTF::hasParkedBit>::lockSlow):
799         (WTF::hasParkedBit>::unlockSlow):
800         * wtf/MainThread.cpp:
801         * wtf/RunLoopTimer.h:
802         * wtf/Threading.cpp:
803         * wtf/Threading.h:
804         * wtf/ThreadingPthreads.cpp:
805         (WTF::Thread::yield):
806         * wtf/ThreadingWin.cpp:
807         (WTF::Thread::yield):
808         * wtf/WordLock.cpp:
809         (WTF::WordLockBase::lockSlow):
810         (WTF::WordLockBase::unlockSlow):
811
812 2017-07-22  Yusuke Suzuki  <utatane.tea@gmail.com>
813
814         [WTF] Extend ThreadGroup::add results from bool to ThreadGroupAddResult
815         https://bugs.webkit.org/show_bug.cgi?id=174705
816
817         Reviewed by Mark Lam.
818
819         After starting using ThreadGroup to bookkeep active threads for Signals,
820         we would like to know tristate of ThreadGroup::add result, NewlyAdded, AlreadyAdded, NotAdded.
821         This patch extends the result of ThreadGroup::add from bool to ThreadGroupAddResult tristate.
822         Note that NotAdded is returned if the target thread is dying.
823
824         * wtf/ThreadGroup.cpp:
825         (WTF::ThreadGroup::add):
826         (WTF::ThreadGroup::addCurrentThread):
827         * wtf/ThreadGroup.h:
828         * wtf/Threading.cpp:
829         (WTF::Thread::addToThreadGroup):
830         * wtf/Threading.h:
831         * wtf/threads/Signals.cpp:
832         (WTF::registerThreadForMachExceptionHandling):
833
834 2017-07-21  Commit Queue  <commit-queue@webkit.org>
835
836         Unreviewed, rolling out r219732.
837         https://bugs.webkit.org/show_bug.cgi?id=174748
838
839         static is not threadsafe in WebKit tree (Requested by
840         yusukesuzuki on #webkit).
841
842         Reverted changeset:
843
844         "[WTF] Drop initializeDate"
845         https://bugs.webkit.org/show_bug.cgi?id=174714
846         http://trac.webkit.org/changeset/219732
847
848 2017-07-21  Yusuke Suzuki  <utatane.tea@gmail.com>
849
850         [WTF] Drop initializeDate
851         https://bugs.webkit.org/show_bug.cgi?id=174714
852
853         Reviewed by Darin Adler.
854
855         minYear static variable will be initialized in an exclusive manner, which is ensured by C++ "static" semantics.
856         Thus, we do not need to call initializeDate() explicitly.
857
858         * wtf/DateMath.cpp:
859         (WTF::equivalentYearForDST):
860         (WTF::initializeDates): Deleted.
861         * wtf/Threading.cpp:
862         (WTF::initializeThreading):
863
864 2017-07-21  Yusuke Suzuki  <utatane.tea@gmail.com>
865
866         [JSC] Introduce static symbols
867         https://bugs.webkit.org/show_bug.cgi?id=158863
868
869         Reviewed by Darin Adler.
870
871         We add a new class StaticSymbolImpl. StaticSymbolImpl can offer
872         the way to create static SymbolImpl. It can be shared between
873         multiple VMs and multiple threads.
874
875         * wtf/text/SymbolImpl.h:
876         (WTF::SymbolImpl::StaticSymbolImpl::StaticSymbolImpl):
877         (WTF::SymbolImpl::StaticSymbolImpl::operator SymbolImpl&):
878         For StaticSymbolImpl's hashForSymbol, we use usual string hash value.
879         Since all the SymbolImpls are unique, basically, any value is OK here.
880         Non-confilicting to the other SymbolImpls is ideal.
881
882 2017-07-21  Yusuke Suzuki  <utatane.tea@gmail.com>
883
884         [WTF] Newly added AtomicStringImpl should use BufferInternal static string if StringImpl is static
885         https://bugs.webkit.org/show_bug.cgi?id=174501
886
887         Reviewed by Darin Adler.
888
889         When creating AtomicStringImpl from static StringImpl, we can just use createWithoutCopying
890         to create a BufferInternal AtomicStringImpl which m_data{8,16} is static string's one.
891
892         * wtf/text/AtomicStringImpl.cpp:
893         (WTF::CStringTranslator::hash):
894         (WTF::CStringTranslator::equal):
895         (WTF::CStringTranslator::translate):
896         (WTF::AtomicStringImpl::add):
897         (WTF::HashTranslatorCharBuffer::HashTranslatorCharBuffer):
898         (WTF::UCharBufferTranslator::hash):
899         (WTF::UCharBufferTranslator::equal):
900         (WTF::UCharBufferTranslator::translate):
901         (WTF::LCharBufferTranslator::hash):
902         (WTF::LCharBufferTranslator::equal):
903         (WTF::LCharBufferTranslator::translate):
904         (WTF::BufferFromStaticDataTranslator::hash):
905         (WTF::BufferFromStaticDataTranslator::equal):
906         (WTF::BufferFromStaticDataTranslator::translate):
907         (WTF::AtomicStringImpl::addLiteral):
908         (WTF::addSymbol):
909         (WTF::addStatic):
910         (WTF::AtomicStringImpl::addSlowCase):
911         (WTF::AtomicStringImpl::lookUp):
912         (WTF::CharBufferFromLiteralDataTranslator::hash): Deleted.
913         (WTF::CharBufferFromLiteralDataTranslator::equal): Deleted.
914         (WTF::CharBufferFromLiteralDataTranslator::translate): Deleted.
915         (WTF::addSubstring): Deleted.
916         * wtf/text/StringImpl.h:
917
918 2017-07-21  Konstantin Tokarev  <annulen@yandex.ru>
919
920        [cmake] Unreviewed, add definitions necessary to use ICU shipped with macOS
921
922        macOS system ICU libraries are built with U_DISABLE_RENAMING=1 and
923        U_SHOW_CPLUSPLUS_API=0. After r219155 we have to pass this definitons
924        explicitly, because ICU headers in the tree are not modified anymore.
925
926         * wtf/PlatformMac.cmake: Rely on ICU_LIBRARIES instead of passing ICU
927         library name explicitly in WTF_LIBRARIES.
928
929 2017-07-20  Chris Dumez  <cdumez@apple.com>
930
931         Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable
932         https://bugs.webkit.org/show_bug.cgi?id=174660
933
934         Reviewed by Geoffrey Garen.
935
936         Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable.
937         This essentially replaces a branch to figure out if the new size is less or greater than the
938         current size by an assertion.
939
940         * wtf/IndexSparseSet.h:
941         (WTF::OverflowHandler>::IndexSparseSet):
942         (WTF::OverflowHandler>::clear):
943         * wtf/Insertion.h:
944         (WTF::executeInsertions):
945         * wtf/RangeSet.h:
946         (WTF::RangeSet::compact):
947         * wtf/Vector.h:
948         (WTF::removeRepeatedElements):
949         * wtf/persistence/Coders.h:
950
951 2017-07-20  Yusuke Suzuki  <utatane.tea@gmail.com>
952
953         [WTF] Use ThreadGroup to bookkeep active threads for Mach exception
954         https://bugs.webkit.org/show_bug.cgi?id=174678
955
956         Reviewed by Mark Lam.
957
958         We can use ThreadGroup to bookkeep active threads for Mach exceptions.
959         When the thread dies, it is automatically removed from the thread groups.
960         So we do not need to call unregisterThreadForMachExceptionHandling.
961
962         * wtf/ThreadGroup.cpp:
963         (WTF::ThreadGroup::~ThreadGroup):
964         (WTF::ThreadGroup::add):
965         * wtf/ThreadGroup.h:
966         * wtf/ThreadHolder.cpp:
967         (WTF::ThreadHolder::~ThreadHolder):
968         * wtf/Threading.cpp:
969         (WTF::Thread::addToThreadGroup):
970         (WTF::Thread::removeFromThreadGroup):
971         * wtf/Threading.h:
972         * wtf/threads/Signals.cpp:
973         (WTF::setExceptionPorts):
974         (WTF::activeThreads):
975         (WTF::registerThreadForMachExceptionHandling):
976         (WTF::installSignalHandler):
977         (WTF::unregisterThreadForMachExceptionHandling): Deleted.
978         * wtf/threads/Signals.h:
979
980 2017-07-19  Yusuke Suzuki  <utatane.tea@gmail.com>
981
982         [WTF] Remove unnecessary indirection of WTF::Thread entry point
983         https://bugs.webkit.org/show_bug.cgi?id=174291
984
985         Reviewed by Mark Lam.
986
987         Now wtfThreadEntryPoint is almost the same. Only the difference is function signature due to platform APIs.
988         We remove ThreadFunctionInvocation indirection in ThreadingPthread.cpp and ThreadingWin.cpp.
989
990         Also, ThreadFunctionInvocation keeps a RefPtr to the Thread object. This was previously needed to keep the
991         Thread object alive until the thread itself could install the ThreadHolder into its thread local storage.
992         The ThreadHolder has a Ref that keeps the Thread object alive for the lifetime of the thread. Since
993         Thread::create() now waits for the thread to be initialized before returning and Thread::create() hold a Ref
994         to the Thread object, we are guaranteed that the Thread object will be alive long enough for it to be installed
995         in the thread's ThreadHolder, and we no longer need ThreadFunctionInvocation.
996
997         And we also simplify ThreadHolder::initialize a bit. Now Thread::create waits for the completion of Thread
998         initialization. So, after establishing thread handle, we can call ThreadHolder::initialize before completing
999         Thread initialization.
1000
1001         Also we drop errno.h ifdefs in ThreadingWin.cpp. This is introduced to support WinCE. But now WinCE port is removed.
1002
1003         * WTF.xcodeproj/project.pbxproj:
1004         * wtf/ThreadFunctionInvocation.h: Removed.
1005         * wtf/ThreadHolder.h:
1006         * wtf/ThreadHolderWin.cpp:
1007         (WTF::ThreadHolder::initialize):
1008         * wtf/Threading.cpp:
1009         (WTF::Thread::entryPoint):
1010         (WTF::Thread::create):
1011         (WTF::threadEntryPoint): Deleted.
1012         * wtf/Threading.h:
1013         * wtf/ThreadingPthreads.cpp:
1014         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
1015         (WTF::wtfThreadEntryPoint):
1016         (WTF::Thread::establishHandle):
1017         (WTF::Thread::initializeCurrentThreadInternal):
1018         (WTF::Thread::current):
1019         (WTF::Thread::establishPlatformSpecificHandle):
1020         (WTF::Thread::createInternal): Deleted.
1021         (WTF::Thread::establish): Deleted.
1022         * wtf/ThreadingWin.cpp:
1023         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
1024         (WTF::Thread::initializeCurrentThreadInternal):
1025         (WTF::wtfThreadEntryPoint):
1026         (WTF::Thread::establishHandle):
1027         (WTF::Thread::current):
1028         (WTF::Thread::establishPlatformSpecificHandle):
1029         (WTF::Thread::createInternal): Deleted.
1030         (WTF::Thread::establish): Deleted.
1031         * wtf/win/MainThreadWin.cpp:
1032         (WTF::initializeMainThreadPlatform):
1033
1034 2017-07-19  Yusuke Suzuki  <utatane.tea@gmail.com>
1035
1036         [WTF] Implement WTF::ThreadGroup
1037         https://bugs.webkit.org/show_bug.cgi?id=174081
1038
1039         Reviewed by Mark Lam.
1040
1041         This patch implements WTF::ThreadGroup. It implements core of JSC::MachineThreads with more reliable way.
1042         JSC::MachineThreads was complicated because of managing dead threads. Each JSC::MachineThreads has its
1043         own TLS with a registered destructor. And everytime a thread dies, the registered TLS destructor is called.
1044         And this destructor will remove the current dying thread from JSC::MachineThreads.
1045
1046         However the above implementation is tricky. And each JSC::MachineThreads requires own TLS space, which is
1047         not considered in WTF's Windows ThreadSpecific implementation. Current design works well since we only
1048         have small number of MachineThreads right now.
1049
1050         Instead, we use more reliable way. After introducing WTF::Thread, WTF::Thread has WTF::Thread::didExit,
1051         which is called when associated TLS (with WTF::Thread) is destroyed. We leverage this mechanism to remove
1052         WTF::Thread from MachineThreads.
1053
1054         This patch introduces WTF::ThreadGroup. It is tightly integrated with WTF::Thread: WTF::Thread knows
1055         ThreadGroups which includes this thread. And WTF::ThreadGroup of course knows WTF::Threads added to it.
1056         WTF::Thread::didExit carefully remove itself from WTF::ThreadGroups.
1057
1058         The most important part of this patch is locking. WTF::Thread can die. And WTF::ThreadGroup can die.
1059         If we take a design using two fine grain locks in WTF::Thread and WTF::ThreadGroup, we easily encounter
1060         dead lock. Consider the following case.
1061
1062         1. When adding WTF::Thread (TH) to WTF::ThreadGroup (THG), we first hold a lock of THG, and hold a lock of TH (locking order is THG -> TH).
1063         2. When TH dies, TH need to hold a lock of TH to iterate THGs. And we hold a lock of THG to unregister TH from it (locking order is TH -> THG).
1064         3. When suspending and resuming THs in THG, we first hold a lock of THG. And then, we hold a lock of TH to suspend and resume it (locking order is THG -> TH).
1065         4. When destroying THG, we need to hold a lock of TH to unregister THG from TH. We can hold a lock of THG before that (locking order is THG -> TH).
1066
1067         Then, it easily causes dead lock. We cannot swap the locking order of (2) since iterating THG requires a lock of TH.
1068         To solve this problem, we use std::shared_ptr and std::weak_ptr.
1069
1070         1. When adding WTF::Thread (TH) to WTF::ThreadGroup (THG), we first hold THG, and hold a lock of TH. (THG -> TH)
1071         2. When TH dies, TH first hold lock of TH. And we use std::weak_ptr<>::lock() to retain non-destructed ThreadGroups.
1072         If some of ThreadGroups are dying, we just ignore them. It is ok because such a ThreadGroup will be destructed. So we do not need to unregister this thread from
1073         such a ThreadGroup. Then, we have Vector<std::shared_ptr<ThreadGroup>>. So we unlock a lock of TH. To unregister a thread from thread group, we first hold a
1074         lock of THG and then hold a lock of TH. Both lifetime is ensured: THG is retained by std::shared_ptr. And TH is itself. (TH), (THG -> TH).
1075         3. When suspending and resuming THs in THG, we first hold a lock of THG. And then, we hold a lock of TH to suspend and resume it (THG -> TH).
1076         4. When destroying THG, we hold a lock of THG. And hold a lock of TH. During holding THG's lock, registered thread never dies because (2) holds THG lock. (THG -> TH).
1077
1078         We also fix suspend and resume locking mechanism to avoid dead lock. We should hold the global lock when suspending and resuming.
1079         If we use per-thread lock, the suspended thread can hold the lock of the other threads. It causes dead lock.
1080
1081         * WTF.xcodeproj/project.pbxproj:
1082         * wtf/AutomaticThread.cpp:
1083         * wtf/CMakeLists.txt:
1084         * wtf/CrossThreadCopier.h:
1085         * wtf/ParkingLot.h:
1086         * wtf/ThreadGroup.cpp: Copied from Source/JavaScriptCore/wasm/WasmMachineThreads.cpp.
1087         (WTF::ThreadGroup::~ThreadGroup):
1088         (WTF::ThreadGroup::add):
1089         (WTF::ThreadGroup::addCurrentThread):
1090         * wtf/ThreadGroup.h: Copied from Source/JavaScriptCore/wasm/WasmMachineThreads.cpp.
1091         (WTF::ThreadGroup::create):
1092         (WTF::ThreadGroup::threads):
1093         (WTF::ThreadGroup::getLock):
1094         (WTF::ThreadGroup::weakFromThis):
1095         * wtf/Threading.cpp:
1096         (WTF::shouldRemoveThreadFromThreadGroup):
1097         (WTF::Thread::didExit):
1098         (WTF::Thread::addToThreadGroup):
1099         (WTF::Thread::removeFromThreadGroup):
1100         * wtf/Threading.h:
1101         * wtf/ThreadingPthreads.cpp:
1102         (WTF::Thread::resume):
1103         (WTF::Thread::getRegisters):
1104         * wtf/ThreadingWin.cpp:
1105         (WTF::Thread::resume):
1106         (WTF::Thread::getRegisters):
1107
1108 2017-07-18  Andy Estes  <aestes@apple.com>
1109
1110         [Xcode] Enable CLANG_WARN_RANGE_LOOP_ANALYSIS
1111         https://bugs.webkit.org/show_bug.cgi?id=174631
1112
1113         Reviewed by Tim Horton.
1114
1115         * Configurations/Base.xcconfig:
1116
1117 2017-07-18  Yusuke Suzuki  <utatane.tea@gmail.com>
1118
1119         WTF::Thread should have the threads stack bounds.
1120         https://bugs.webkit.org/show_bug.cgi?id=173975
1121
1122         Reviewed by Mark Lam.
1123
1124         We move StackBounds from WTFThreadData to WTF::Thread.
1125         One important thing is that we should make valid StackBounds
1126         visible to Thread::create() caller. When the caller get
1127         WTF::Thread from Thread::create(), this WTF::Thread should
1128         have a valid StackBounds. But StackBounds information can be
1129         retrived only in the WTF::Thread's thread itself.
1130
1131         We also clean up WTF::initializeThreading. StringImpl::empty()
1132         is now statically initialized by using constexpr constructor.
1133         Thus we do not need to call StringImpl::empty() explicitly here.
1134         And WTF::initializeThreading() does not have any main thread
1135         affinity right now in all the platforms. So we fix the comment
1136         in Threading.h. Then, now, WTF::initializeThreading() is called
1137         in UI thread when using Web thread in iOS.
1138
1139         * wtf/StackBounds.h:
1140         (WTF::StackBounds::emptyBounds):
1141         (WTF::StackBounds::StackBounds):
1142         * wtf/Threading.cpp:
1143         (WTF::threadEntryPoint):
1144         (WTF::Thread::create):
1145         (WTF::Thread::currentMayBeNull):
1146         (WTF::Thread::initialize):
1147         (WTF::initializeThreading):
1148         * wtf/Threading.h:
1149         (WTF::Thread::stack):
1150         * wtf/ThreadingPthreads.cpp:
1151         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
1152         (WTF::Thread::current):
1153         (WTF::initializeCurrentThreadEvenIfNonWTFCreated): Deleted.
1154         (WTF::Thread::currentMayBeNull): Deleted.
1155         * wtf/ThreadingWin.cpp:
1156         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
1157         (WTF::Thread::initializeCurrentThreadInternal):
1158         (WTF::Thread::current):
1159         * wtf/WTFThreadData.cpp:
1160         (WTF::WTFThreadData::WTFThreadData):
1161         * wtf/WTFThreadData.h:
1162         (WTF::WTFThreadData::stack):
1163
1164 2017-07-18  Andy Estes  <aestes@apple.com>
1165
1166         [Xcode] Enable CLANG_WARN_OBJC_LITERAL_CONVERSION
1167         https://bugs.webkit.org/show_bug.cgi?id=174631
1168
1169         Reviewed by Sam Weinig.
1170
1171         * Configurations/Base.xcconfig:
1172
1173 2017-07-18  Andy Estes  <aestes@apple.com>
1174
1175         [Xcode] Enable CLANG_WARN_NON_LITERAL_NULL_CONVERSION
1176         https://bugs.webkit.org/show_bug.cgi?id=174631
1177
1178         Reviewed by Dan Bernstein.
1179
1180         * Configurations/Base.xcconfig:
1181
1182 2017-07-18  Andy Estes  <aestes@apple.com>
1183
1184         [Xcode] Enable CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING
1185         https://bugs.webkit.org/show_bug.cgi?id=174631
1186
1187         Reviewed by Darin Adler.
1188
1189         * Configurations/Base.xcconfig:
1190
1191 2017-07-17  Konstantin Tokarev  <annulen@yandex.ru>
1192
1193         [cmake] Set library types before their targets are created
1194         https://bugs.webkit.org/show_bug.cgi?id=174600
1195
1196         Reviewed by Michael Catanzaro.
1197
1198         Since r219560 library targets are created before PlatformXXX.cmake
1199         files are processed, however library type must be passed in
1200         add_library() call and cannot be changed afterwards. Set these
1201         variables in OptionsXXX.cmake.
1202
1203         * wtf/PlatformGTK.cmake:
1204         * wtf/PlatformMac.cmake:
1205
1206 2017-07-17  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
1207
1208         Move USE_AVFOUNDATION definition on Windows to wtf/Platform.h
1209         https://bugs.webkit.org/show_bug.cgi?id=174356
1210
1211         Reviewed by Brent Fulgham.
1212
1213         Move the definition of USE_AVFOUNDATION on Windows to wtf/platform.h
1214
1215         Add a custom command to generate AVFoundationHeaderDetection.h, which
1216         is renamed from WebCoreHeaderDetection.h
1217
1218         * AVFoundationSupport.py: Moved from Source/WebCore/AVFoundationSupport.py.
1219         * wtf/Platform.h:
1220         * wtf/PlatformWin.cmake:
1221
1222 2017-07-17  Darin Adler  <darin@apple.com>
1223
1224         Improve use of NeverDestroyed
1225         https://bugs.webkit.org/show_bug.cgi?id=174348
1226
1227         Reviewed by Sam Weinig.
1228
1229         * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of
1230         const references. This is handy to add a bunch of values all at once. Later we can
1231         consider optimizing to grow the hash table only once instead of deciding whether to
1232         grow repeatedly as we add each value.
1233         (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here.
1234
1235         * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ...
1236         * wtf/MemoryPressureHandler.h: ... not here.
1237
1238         * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed.
1239         Added a makeNeverDestroyed function that deduces the type from the argument.
1240         With auto, this can be used to avoid writing out a long type twice.
1241
1242         * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h.
1243         * wtf/text/AtomicString.cpp: Ditto.
1244
1245 2017-07-17  Konstantin Tokarev  <annulen@yandex.ru>
1246
1247         [CMake] Create targets before WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS is called
1248         https://bugs.webkit.org/show_bug.cgi?id=174557
1249
1250         Reviewed by Michael Catanzaro.
1251
1252         * wtf/CMakeLists.txt:
1253
1254 2017-07-14  Jonathan Bedard  <jbedard@apple.com>
1255
1256         Add iOS 11 SPI
1257         https://bugs.webkit.org/show_bug.cgi?id=174430
1258         <rdar://problem/33269288>
1259
1260         Reviewed by Tim Horton.
1261
1262         * Configurations/WTF.xcconfig: Exclude MachExceptions.def when building iOS 11 for
1263         the iOS simulator.
1264
1265 2017-07-14  Commit Queue  <commit-queue@webkit.org>
1266
1267         Unreviewed, rolling out r219510.
1268         https://bugs.webkit.org/show_bug.cgi?id=174525
1269
1270         Need to revert length() == 0 check for null string (Requested
1271         by yusukesuzuki on #webkit).
1272
1273         Reverted changeset:
1274
1275         "[WTF] Newly added AtomicStringImpl should use BufferInternal
1276         static string if StringImpl is static"
1277         https://bugs.webkit.org/show_bug.cgi?id=174501
1278         http://trac.webkit.org/changeset/219510
1279
1280 2017-07-14  Yusuke Suzuki  <utatane.tea@gmail.com>
1281
1282         [WTF] Newly added AtomicStringImpl should use BufferInternal static string if StringImpl is static
1283         https://bugs.webkit.org/show_bug.cgi?id=174501
1284
1285         Reviewed by Darin Adler.
1286
1287         When creating AtomicStringImpl from static StringImpl, we can just use createWithoutCopying
1288         to create a BufferInternal AtomicStringImpl which m_data{8,16} is static string's one.
1289
1290         * wtf/text/AtomicStringImpl.cpp:
1291         (WTF::CStringTranslator::hash):
1292         (WTF::CStringTranslator::equal):
1293         (WTF::CStringTranslator::translate):
1294         (WTF::AtomicStringImpl::add):
1295         (WTF::HashTranslatorCharBuffer::HashTranslatorCharBuffer):
1296         (WTF::UCharBufferTranslator::hash):
1297         (WTF::UCharBufferTranslator::equal):
1298         (WTF::UCharBufferTranslator::translate):
1299         (WTF::LCharBufferTranslator::hash):
1300         (WTF::LCharBufferTranslator::equal):
1301         (WTF::LCharBufferTranslator::translate):
1302         (WTF::BufferFromStaticDataTranslator::hash):
1303         (WTF::BufferFromStaticDataTranslator::equal):
1304         (WTF::BufferFromStaticDataTranslator::translate):
1305         (WTF::AtomicStringImpl::addLiteral):
1306         (WTF::addSymbol):
1307         (WTF::addStatic):
1308         (WTF::AtomicStringImpl::addSlowCase):
1309         (WTF::AtomicStringImpl::lookUp):
1310         (WTF::CharBufferFromLiteralDataTranslator::hash): Deleted.
1311         (WTF::CharBufferFromLiteralDataTranslator::equal): Deleted.
1312         (WTF::CharBufferFromLiteralDataTranslator::translate): Deleted.
1313         (WTF::addSubstring): Deleted.
1314         * wtf/text/StringImpl.h:
1315
1316 2017-07-14  Yusuke Suzuki  <utatane.tea@gmail.com>
1317
1318         [WTF] Use std::unique_ptr for StackTrace
1319         https://bugs.webkit.org/show_bug.cgi?id=174495
1320
1321         Reviewed by Alex Christensen.
1322
1323         Instead of returning pointer to heap allocated StackTrace,
1324         we should return std::unique_ptr<StackTrace>.
1325         And we also move WTFGetBackTrace from Assertions.cpp to
1326         StackTrace.cpp to consolidate stack trace related operations
1327         into StackTrace.cpp.
1328
1329         * wtf/Assertions.cpp:
1330         * wtf/StackTrace.cpp:
1331         (WTFGetBacktrace):
1332         (WTF::StackTrace::captureStackTrace):
1333         * wtf/StackTrace.h:
1334
1335 2017-07-13  Yusuke Suzuki  <utatane.tea@gmail.com>
1336
1337         Unreviewed, annotate inline for operator==/!= for FastAllocator
1338         https://bugs.webkit.org/show_bug.cgi?id=174366
1339
1340         * wtf/FastMalloc.h:
1341         (WTF::operator==):
1342         (WTF::operator!=):
1343
1344 2017-07-12  Commit Queue  <commit-queue@webkit.org>
1345
1346         Unreviewed, rolling out r219176.
1347         https://bugs.webkit.org/show_bug.cgi?id=174436
1348
1349         "Can cause infinite recursion on iOS" (Requested by mlam on
1350         #webkit).
1351
1352         Reverted changeset:
1353
1354         "WTF::Thread should have the threads stack bounds."
1355         https://bugs.webkit.org/show_bug.cgi?id=173975
1356         http://trac.webkit.org/changeset/219176
1357
1358 2017-07-12  Adrian Perez de Castro  <aperez@igalia.com>
1359
1360         [WTF] Failure to build when the compiler specifically targets ARMv8-A / defines __ARM_ARCH_8A__
1361         https://bugs.webkit.org/show_bug.cgi?id=174425
1362
1363         Reviewed by Michael Catanzaro.
1364
1365         * wtf/Platform.h: Also check for __ARCH_ARM_8A__ to detect ARMv8.
1366
1367 2017-07-12  Michael Saboff  <msaboff@apple.com>
1368
1369         Unreviewed build fix when both DATA_LOG_TO_FILE and DATA_LOG_FILENAME are defined.
1370
1371         * wtf/DataLog.cpp:
1372         (WTF::initializeLogFileOnce): Changed declaration of logBasename from
1373         char* logBasename to const char* logBasename.
1374
1375 2017-07-12  Matt Lewis  <jlewis3@apple.com>
1376
1377         Unreviewed, rolling out r219401.
1378
1379         This revision rolled out the previous patch, but after talking
1380         with reviewer, a rebaseline is what was needed.Rolling back in
1381         before rebaseline.
1382
1383         Reverted changeset:
1384
1385         "Unreviewed, rolling out r219379."
1386         https://bugs.webkit.org/show_bug.cgi?id=174400
1387         http://trac.webkit.org/changeset/219401
1388
1389 2017-07-12  Matt Lewis  <jlewis3@apple.com>
1390
1391         Unreviewed, rolling out r219379.
1392
1393         This revision caused a consistent failure in the test
1394         fast/dom/Window/property-access-on-cached-window-after-frame-
1395         removed.html.
1396
1397         Reverted changeset:
1398
1399         "Remove NAVIGATOR_HWCONCURRENCY"
1400         https://bugs.webkit.org/show_bug.cgi?id=174400
1401         http://trac.webkit.org/changeset/219379
1402
1403 2017-07-12  Yusuke Suzuki  <utatane.tea@gmail.com>
1404
1405         Unreviewed, attempt to fix Windows build
1406         https://bugs.webkit.org/show_bug.cgi?id=174366
1407
1408         * wtf/FastMalloc.h:
1409         (WTF::operator==):
1410         (WTF::operator!=):
1411         (WTF::FastAllocator::operator==): Deleted.
1412         (WTF::FastAllocator::operator!=): Deleted.
1413
1414 2017-07-11  Carlos Garcia Campos  <cgarcia@igalia.com>
1415
1416         [GTK][WPE] Enable FILE_LOCK and implement lockFile and unlockFile
1417         https://bugs.webkit.org/show_bug.cgi?id=174357
1418
1419         Reviewed by Michael Catanzaro.
1420
1421         * wtf/Platform.h: Enable FILE_LOCK in GTK and WPE ports.
1422
1423 2017-07-11  Dean Jackson  <dino@apple.com>
1424
1425         Remove NAVIGATOR_HWCONCURRENCY
1426         https://bugs.webkit.org/show_bug.cgi?id=174400
1427
1428         Reviewed by Sam Weinig.
1429
1430         * wtf/FeatureDefines.h:
1431
1432 2017-07-11  Dean Jackson  <dino@apple.com>
1433
1434         Rolling out r219372.
1435
1436         * wtf/FeatureDefines.h:
1437
1438 2017-07-11  Dean Jackson  <dino@apple.com>
1439
1440         Remove NAVIGATOR_HWCONCURRENCY
1441         https://bugs.webkit.org/show_bug.cgi?id=174400
1442
1443         Reviewed by Sam Weinig.
1444
1445         * wtf/FeatureDefines.h:
1446
1447 2017-07-11  Yusuke Suzuki  <utatane.tea@gmail.com>
1448
1449         [WTF] Drop unnecessary AtomicString constructor since we have constexpr hash function
1450         https://bugs.webkit.org/show_bug.cgi?id=174347
1451
1452         Reviewed by Alex Christensen.
1453
1454         Previously, we calculate hash value in perl script and generate source code with that value.
1455         This AtomicString constructor takes this pre-calculated hash value to efficiently construct
1456         itself. But now, we have constexpr hash function, then we do not need to specify hash value
1457         directly in this way. Thus we drop this functionality.
1458
1459         * wtf/text/AtomicString.h:
1460         * wtf/text/AtomicStringImpl.cpp:
1461         (WTF::HashAndCharactersTranslator::hash): Deleted.
1462         (WTF::HashAndCharactersTranslator::equal): Deleted.
1463         (WTF::HashAndCharactersTranslator::translate): Deleted.
1464         * wtf/text/AtomicStringImpl.h:
1465         (WTF::AtomicStringImpl::add):
1466
1467 2017-07-10  Per Arne Vollan  <pvollan@apple.com>
1468
1469         [Win] Link error when building WTF from WTF.proj project file.
1470         https://bugs.webkit.org/show_bug.cgi?id=174316
1471         <rdar://problem/33178200>
1472
1473         Reviewed by Brent Fulgham.
1474
1475         WTF_CPU_X86 cmake variable needs to be set for link libraries directories to be correct.
1476
1477         * WTF.vcxproj/WTF.proj:
1478
1479 2017-07-03  Brian Burg  <bburg@apple.com>
1480
1481         Web Replay: remove some unused code
1482         https://bugs.webkit.org/show_bug.cgi?id=173903
1483
1484         Rubber-stamped by Joseph Pecoraro.
1485
1486         * wtf/FeatureDefines.h:
1487
1488 2017-07-10  Brady Eidson  <beidson@apple.com>
1489
1490         Cleanup lifetime issues of UniqueIDBDatabase and IDBBackingStore.
1491         <rdar://problem/32908525> and https://bugs.webkit.org/show_bug.cgi?id=174244
1492
1493         Reviewed by David Kilzer and Alex Christensen. 
1494
1495         Add proper "kill" support to CrossThreadQueue, as well as isEmpty() support.
1496
1497         * wtf/CrossThreadQueue.h:
1498         (WTF::CrossThreadQueue<DataType>::append):
1499         (WTF::CrossThreadQueue<DataType>::kill):
1500         (WTF::CrossThreadQueue<DataType>::isKilled):
1501         (WTF::CrossThreadQueue<DataType>::isEmpty):
1502         (WTF::CrossThreadQueue::isKilled): Deleted.
1503
1504 2017-07-09  Yusuke Suzuki  <utatane.tea@gmail.com>
1505
1506         [JSC] Use fastMalloc / fastFree for STL containers
1507         https://bugs.webkit.org/show_bug.cgi?id=174297
1508
1509         Reviewed by Sam Weinig.
1510
1511         * wtf/FastMalloc.h:
1512         (WTF::FastAllocator::FastAllocator):
1513         (WTF::FastAllocator::allocate):
1514         (WTF::FastAllocator::deallocate):
1515         (WTF::FastAllocator::operator==):
1516         (WTF::FastAllocator::operator!=):
1517
1518 2017-07-07  Brent Fulgham  <bfulgham@apple.com>
1519
1520         [WK2] Use a rolling 30-day uptime for processing statistics
1521         https://bugs.webkit.org/show_bug.cgi?id=174235
1522         <rdar://problem/33164381>
1523
1524         Reviewed by Chris Dumez.
1525
1526         Modify Deque to allow it to be used in a template specialization in KeyedDecoder.
1527
1528         * wtf/Deque.h:
1529
1530 2017-07-07  Commit Queue  <commit-queue@webkit.org>
1531
1532         Unreviewed, rolling out r219238, r219239, and r219241.
1533         https://bugs.webkit.org/show_bug.cgi?id=174265
1534
1535         "fast/workers/dedicated-worker-lifecycle.html is flaky"
1536         (Requested by yusukesuzuki on #webkit).
1537
1538         Reverted changesets:
1539
1540         "[WTF] Implement WTF::ThreadGroup"
1541         https://bugs.webkit.org/show_bug.cgi?id=174081
1542         http://trac.webkit.org/changeset/219238
1543
1544         "Unreviewed, build fix after r219238"
1545         https://bugs.webkit.org/show_bug.cgi?id=174081
1546         http://trac.webkit.org/changeset/219239
1547
1548         "Unreviewed, CLoop build fix after r219238"
1549         https://bugs.webkit.org/show_bug.cgi?id=174081
1550         http://trac.webkit.org/changeset/219241
1551
1552 2017-07-07  Yusuke Suzuki  <utatane.tea@gmail.com>
1553
1554         Unreviewed, Windows build fix after r219233 part 4
1555         https://bugs.webkit.org/show_bug.cgi?id=174231
1556
1557         * wtf/Assertions.h:
1558
1559 2017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
1560
1561         Unreviewed, Windows build fix after r219233 part 3
1562         https://bugs.webkit.org/show_bug.cgi?id=174231
1563
1564         * wtf/Assertions.h:
1565         (compilerFenceForCrash):
1566
1567 2017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
1568
1569         Unreviewed, Windows build fix after r219233 part 2
1570         https://bugs.webkit.org/show_bug.cgi?id=174231
1571
1572         * wtf/Assertions.h:
1573
1574 2017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
1575
1576         Unreviewed, Windows build fix after r219233
1577         https://bugs.webkit.org/show_bug.cgi?id=174231
1578
1579         * wtf/Compiler.h:
1580
1581 2017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
1582
1583         Unreviewed, build fix after r219238
1584         https://bugs.webkit.org/show_bug.cgi?id=174081
1585
1586         * wtf/Threading.cpp:
1587         (WTF::Thread::addToThreadGroup):
1588
1589 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
1590
1591         [WTF] Implement WTF::ThreadGroup
1592         https://bugs.webkit.org/show_bug.cgi?id=174081
1593
1594         Reviewed by Mark Lam.
1595
1596         This patch implements WTF::ThreadGroup. It implements core of JSC::MachineThreads with more reliable way.
1597         JSC::MachineThreads was complicated because of managing dead threads. Each JSC::MachineThreads has its
1598         own TLS with a registered destructor. And everytime a thread dies, the registered TLS destructor is called.
1599         And this destructor will remove the current dying thread from JSC::MachineThreads.
1600
1601         However the above implementation is tricky. And each JSC::MachineThreads requires own TLS space, which is
1602         not considered in WTF's Windows ThreadSpecific implementation. Current design works well since we only
1603         have small number of MachineThreads right now.
1604
1605         Instead, we use more reliable way. After introducing WTF::Thread, WTF::Thread has WTF::Thread::didExit,
1606         which is called when associated TLS (with WTF::Thread) is destroyed. We leverage this mechanism to remove
1607         WTF::Thread from MachineThreads.
1608
1609         This patch introduces WTF::ThreadGroup. It is tightly integrated with WTF::Thread: WTF::Thread knows
1610         ThreadGroups which includes this thread. And WTF::ThreadGroup of course knows WTF::Threads added to it.
1611         WTF::Thread::didExit carefully remove itself from WTF::ThreadGroups.
1612
1613         The most important part of this patch is locking. WTF::Thread can die. And WTF::ThreadGroup can die.
1614         If we take a design using two fine grain locks in WTF::Thread and WTF::ThreadGroup, we easily encounter
1615         dead lock. Consider the following case.
1616
1617         1. When adding WTF::Thread (TH) to WTF::ThreadGroup (THG), we first hold a lock of THG, and hold a lock of TH (locking order is THG -> TH).
1618         2. When TH dies, TH need to hold a lock of TH to iterate THGs. And we hold a lock of THG to unregister TH from it (locking order is TH -> THG).
1619         3. When suspending and resuming THs in THG, we first hold a lock of THG. And then, we hold a lock of TH to suspend and resume it (locking order is THG -> TH).
1620         4. When destroying THG, we need to hold a lock of TH to unregister THG from TH. We can hold a lock of THG before that (locking order is THG -> TH).
1621
1622         Then, it easily causes dead lock. We cannot swap the locking order of (2) since iterating THG requires a lock of TH.
1623         To solve this problem, we introduce one global lock ThreadGroup::destructionMutex (GL).
1624
1625         1. When adding WTF::Thread (TH) to WTF::ThreadGroup (THG), we first hold GL, and hold a lock of THG. Do not hold a
1626         lock of TH. TH's thread groups information is guarded by GL instead of a lock of TH (locking order is GL -> THG).
1627         2. When TH dies, TH need to hold GL to iterate THGs. And we hold a lock of THG to unregister TH from it (locking order is GL -> THG).
1628         3. When suspending and resuming THs in THG, we first hold a lock of THG. And then, we hold a lock of TH to suspend and resume it (locking order is THG -> TH).
1629         4. When destroying THG, we need to hold GL to unregister THG from TH. We can hold a lock of THG after that (locking order is GL -> THG).
1630
1631         We still have a lock of THG. By separating GL and THG's lock, we can hold a lock of THG while completely unrelated TH is destructed which takes a lock of GL and unrelated THG.
1632
1633         * WTF.xcodeproj/project.pbxproj:
1634         * wtf/AutomaticThread.cpp:
1635         * wtf/CMakeLists.txt:
1636         * wtf/CrossThreadCopier.h:
1637         * wtf/ParkingLot.h:
1638         * wtf/ThreadGroup.cpp: Copied from Source/JavaScriptCore/wasm/WasmMachineThreads.cpp.
1639         (WTF::ThreadGroup::destructionMutex):
1640         (WTF::ThreadGroup::~ThreadGroup):
1641         (WTF::ThreadGroup::add):
1642         (WTF::ThreadGroup::addCurrentThread):
1643         (WTF::ThreadGroup::removeCurrentThread):
1644         * wtf/ThreadGroup.h: Copied from Source/JavaScriptCore/wasm/WasmMachineThreads.cpp.
1645         (WTF::ThreadGroup::create):
1646         (WTF::ThreadGroup::threads):
1647         (WTF::ThreadGroup::getLock):
1648         * wtf/Threading.cpp:
1649         (WTF::Thread::didExit):
1650         (WTF::Thread::addToThreadGroup):
1651         (WTF::Thread::removeFromThreadGroup):
1652         * wtf/Threading.h:
1653         (WTF::Thread::canAddToThreadGroup):
1654
1655 2017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
1656
1657         [WTF] Clean up StringStatics.cpp by using LazyNeverDestroyed<> for Atoms
1658         https://bugs.webkit.org/show_bug.cgi?id=174150
1659
1660         Reviewed by Mark Lam.
1661
1662         This patch cleans up StringStatics.cpp and remove it from the tree.
1663
1664         1. Move StringImpl methods to appropriate place, "StringImpl.cpp".
1665
1666         StringImpl::hashSlowCase() and StringImpl::concurrentHash() are defined in
1667         StringStatics.cpp. But they should be defined in StringImpl.cpp.
1668         This patch just moves them to StringImpl.cpp.
1669
1670         2. Use LazyNeverDestroyed to initialize AtomicString atoms like emptyAtom.
1671
1672         Previously, we initialized AtomicString atoms like emptyAtom in a hacky way.
1673         We first define them as extern global variables. However, AtomicString has
1674         a non-trivial constructor. Thus, we cannot do this because it requires global
1675         constructor calls. This is why we have StringStatics.cpp. In this file, we
1676         include "StaticConstructors.h". After including this file, all the global
1677         constructor call disabled in Windows. And in GCC environment, we allocate
1678         void* storage for that variable. And we use placement new in AtomicString::init()
1679         to initialize these storage.
1680         However, we already have better way for that: LazyNeverDestroyed. It just allocates
1681         storage like the above. And it does not have any global constructors. Thus
1682         we can just declare it as a global variable. And we initialize them lazily in
1683         AtomicString::init(). This way effectively avoids "StaticConstructors.h" hacky way.
1684         And it makes "StringStatics.cpp" unnecessary.
1685         Then, we just move these variables and AtomicString::init() to AtomicString.cpp.
1686
1687         And we also change emptyAtom to emptyAtom() to get the value from LazyNeverDestroyed<>.
1688
1689         * WTF.xcodeproj/project.pbxproj:
1690         * wtf/CMakeLists.txt:
1691         * wtf/text/AtomicString.cpp:
1692         (WTF::AtomicString::convertASCIICase):
1693         (WTF::AtomicString::fromUTF8Internal):
1694         (WTF::AtomicString::init):
1695         * wtf/text/AtomicString.h:
1696         (WTF::nullAtom):
1697         (WTF::emptyAtom):
1698         (WTF::starAtom):
1699         (WTF::xmlAtom):
1700         (WTF::xmlnsAtom):
1701         (WTF::AtomicString::fromUTF8):
1702         * wtf/text/StringBuilder.h:
1703         (WTF::StringBuilder::toAtomicString):
1704         * wtf/text/StringImpl.cpp:
1705         (WTF::StringImpl::hashSlowCase):
1706         (WTF::StringImpl::concurrentHash):
1707         * wtf/text/StringStatics.cpp: Removed.
1708
1709 2017-07-06  Keith Miller  <keith_miller@apple.com>
1710
1711         Add extra insurance to prevent clang from making crash traces sad
1712         https://bugs.webkit.org/show_bug.cgi?id=174231
1713
1714         Reviewed by Saam Barati.
1715
1716         This patch makes it slightly harder for Clang to coalesce our crash calls.
1717         Additionally, it also makes Clang never tail call the WTFCrashWithInfo so
1718         our stack trace should always be "reasonable".
1719
1720         * wtf/Assertions.h:
1721         * wtf/Compiler.h:
1722
1723 2017-07-06  Matt Lewis  <jlewis3@apple.com>
1724
1725         Unreviewed, rolling out r219178.
1726
1727         This caused a consistent failure with the API test
1728         StringBuilderTest.ToAtomicStringOnEmpty on all Debug testers.
1729
1730         Reverted changeset:
1731
1732         "[WTF] Clean up StringStatics.cpp by using
1733         LazyNeverDestroyed<> for Atoms"
1734         https://bugs.webkit.org/show_bug.cgi?id=174150
1735         http://trac.webkit.org/changeset/219178
1736
1737 2017-07-05  Don Olmstead  <don.olmstead@sony.com>
1738
1739         [WTF] Move SoftLinking.h into WTF
1740         https://bugs.webkit.org/show_bug.cgi?id=174000
1741
1742         Reviewed by Alex Christensen.
1743
1744         * WTF.xcodeproj/project.pbxproj:
1745         * wtf/SoftLinking.h: Copied from Source/WebCore/platform/ios/QuickLookSoftLink.mm.
1746         * wtf/cocoa/SoftLinking.h: Renamed from Source/WebCore/platform/cocoa/SoftLinking.h.
1747         * wtf/win/SoftLinking.h: Renamed from Source/WebCore/platform/win/SoftLinking.h.
1748
1749 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
1750
1751         Upgrade GCC baseline
1752         https://bugs.webkit.org/show_bug.cgi?id=174155
1753
1754         Reviewed by Michael Catanzaro.
1755
1756         * wtf/Compiler.h:
1757
1758 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
1759
1760         WTF::StringImpl::copyChars segfaults when built with GCC 7
1761         https://bugs.webkit.org/show_bug.cgi?id=173407
1762
1763         Reviewed by Andreas Kling.
1764
1765         With GCC 7, StringImpl::copyChars() behaves as unexpected.
1766         This function violates strict aliasing rule.
1767
1768         This optimization is originally introduced to improve performance
1769         in SunSpider's string tests in 2008. When running it in my Linux
1770         box, it no longer causes any observable difference. So, we just
1771         remove this optimization.
1772
1773                                         baseline                  patched
1774
1775         string-base64                7.7544+-0.1761            7.6138+-0.2071          might be 1.0185x faster
1776         string-fasta                10.5429+-0.2746     ?     10.7500+-0.2669        ? might be 1.0196x slower
1777         string-tagcloud             14.8588+-0.2828           14.8039+-0.3039
1778         string-unpack-code          36.1769+-0.4251           35.3397+-0.5398          might be 1.0237x faster
1779         string-validate-input        8.5182+-0.2206            8.3514+-0.2179          might be 1.0200x faster
1780
1781         * wtf/text/StringImpl.h:
1782         (WTF::StringImpl::copyChars):
1783
1784 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
1785
1786         Use std::lock_guard instead of std::unique_lock if move semantics and try_lock is not necessary
1787         https://bugs.webkit.org/show_bug.cgi?id=174148
1788
1789         Reviewed by Mark Lam.
1790
1791         It is not necessary to use std::unique_lock if we do not use additional features compared to std::lock_guard.
1792
1793         (WTF::ThreadHolder::get):
1794         (WTF::ThreadHolder::initialize):
1795         (WTF::ThreadHolder::destruct):
1796         * wtf/Threading.cpp:
1797         (WTF::Thread::didExit):
1798         * wtf/ThreadingPthreads.cpp:
1799         (WTF::Thread::changePriority):
1800         (WTF::Thread::waitForCompletion):
1801         (WTF::Thread::detach):
1802         (WTF::Thread::signal):
1803         (WTF::Thread::resume):
1804         (WTF::Thread::getRegisters):
1805         (WTF::Thread::establish):
1806         * wtf/ThreadingWin.cpp:
1807         (WTF::Thread::changePriority):
1808         (WTF::Thread::waitForCompletion):
1809         (WTF::Thread::detach):
1810         (WTF::Thread::resume):
1811         (WTF::Thread::getRegisters):
1812         (WTF::Thread::establish):
1813         * wtf/WordLock.cpp:
1814         (WTF::WordLockBase::unlockSlow):
1815
1816 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
1817
1818         [WTF] Clean up StringStatics.cpp by using LazyNeverDestroyed<> for Atoms
1819         https://bugs.webkit.org/show_bug.cgi?id=174150
1820
1821         Reviewed by Mark Lam.
1822
1823         This patch cleans up StringStatics.cpp and remove it from the tree.
1824
1825         1. Move StringImpl methods to appropriate place, "StringImpl.cpp".
1826
1827         StringImpl::hashSlowCase() and StringImpl::concurrentHash() are defined in
1828         StringStatics.cpp. But they should be defined in StringImpl.cpp.
1829         This patch just moves them to StringImpl.cpp.
1830
1831         2. Use LazyNeverDestroyed to initialize AtomicString atoms like emptyAtom.
1832
1833         Previously, we initialized AtomicString atoms like emptyAtom in a hacky way.
1834         We first define them as extern global variables. However, AtomicString has
1835         a non-trivial constructor. Thus, we cannot do this because it requires global
1836         constructor calls. This is why we have StringStatics.cpp. In this file, we
1837         include "StaticConstructors.h". After including this file, all the global
1838         constructor call disabled in Windows. And in GCC environment, we allocate
1839         void* storage for that variable. And we use placement new in AtomicString::init()
1840         to initialize these storage.
1841         However, we already have better way for that: LazyNeverDestroyed. It just allocates
1842         storage like the above. And it does not have any global constructors. Thus
1843         we can just declare it as a global variable. And we initialize them lazily in
1844         AtomicString::init(). This way effectively avoids "StaticConstructors.h" hacky way.
1845         And it makes "StringStatics.cpp" unnecessary.
1846         Then, we just move these variables and AtomicString::init() to AtomicString.cpp.
1847
1848         And we also change emptyAtom to emptyAtom() to get the value from LazyNeverDestroyed<>.
1849
1850         * WTF.xcodeproj/project.pbxproj:
1851         * wtf/CMakeLists.txt:
1852         * wtf/text/AtomicString.cpp:
1853         (WTF::AtomicString::convertASCIICase):
1854         (WTF::AtomicString::fromUTF8Internal):
1855         (WTF::AtomicString::init):
1856         * wtf/text/AtomicString.h:
1857         (WTF::nullAtom):
1858         (WTF::emptyAtom):
1859         (WTF::starAtom):
1860         (WTF::xmlAtom):
1861         (WTF::xmlnsAtom):
1862         (WTF::AtomicString::fromUTF8):
1863         * wtf/text/StringBuilder.h:
1864         (WTF::StringBuilder::toAtomicString):
1865         * wtf/text/StringImpl.cpp:
1866         (WTF::StringImpl::hashSlowCase):
1867         (WTF::StringImpl::concurrentHash):
1868         * wtf/text/StringStatics.cpp: Removed.
1869
1870 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
1871
1872         WTF::Thread should have the threads stack bounds.
1873         https://bugs.webkit.org/show_bug.cgi?id=173975
1874
1875         Reviewed by Keith Miller.
1876
1877         We move StackBounds from WTFThreadData to WTF::Thread.
1878         One important thing is that we should make valid StackBounds
1879         visible to Thread::create() caller. When the caller get
1880         WTF::Thread from Thread::create(), this WTF::Thread should
1881         have a valid StackBounds. But StackBounds information can be
1882         retrived only in the WTF::Thread's thread itself.
1883
1884         We also clean up WTF::initializeThreading. StringImpl::empty()
1885         is now statically initialized by using constexpr constructor.
1886         Thus we do not need to call StringImpl::empty() explicitly here.
1887         And WTF::initializeThreading() does not have any main thread
1888         affinity right now in all the platforms. So we fix the comment
1889         in Threading.h. Then, now, WTF::initializeThreading() is called
1890         in UI thread when using Web thread in iOS.
1891
1892         * wtf/StackBounds.h:
1893         (WTF::StackBounds::emptyBounds):
1894         (WTF::StackBounds::StackBounds):
1895         * wtf/StackStats.cpp:
1896         (WTF::StackStats::PerThreadStats::PerThreadStats):
1897         * wtf/Threading.cpp:
1898         (WTF::threadEntryPoint):
1899         (WTF::Thread::create):
1900         (WTF::Thread::currentMayBeNull):
1901         (WTF::Thread::initialize):
1902         (WTF::initializeThreading):
1903         * wtf/Threading.h:
1904         (WTF::Thread::stack):
1905         * wtf/ThreadingPthreads.cpp:
1906         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
1907         (WTF::Thread::current):
1908         (WTF::initializeCurrentThreadEvenIfNonWTFCreated): Deleted.
1909         (WTF::Thread::currentMayBeNull): Deleted.
1910         * wtf/ThreadingWin.cpp:
1911         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
1912         (WTF::Thread::initializeCurrentThreadInternal):
1913         (WTF::Thread::current):
1914         * wtf/WTFThreadData.cpp:
1915         (WTF::WTFThreadData::WTFThreadData):
1916         * wtf/WTFThreadData.h:
1917         (WTF::WTFThreadData::stack): Deleted.
1918
1919 2017-07-05  Keith Miller  <keith_miller@apple.com>
1920
1921         Crashing with information should have an abort reason
1922         https://bugs.webkit.org/show_bug.cgi?id=174185
1923
1924         Reviewed by Saam Barati.
1925
1926         Fix an ifdef to actually work with X86_64. It turns out X64_64 is
1927         not an architecture... Whoops.
1928
1929         * wtf/Assertions.cpp:
1930
1931 2017-07-03  Myles C. Maxfield  <mmaxfield@apple.com>
1932
1933         Remove copy of ICU headers from WebKit
1934         https://bugs.webkit.org/show_bug.cgi?id=116407
1935
1936         Reviewed by Alex Christensen.
1937
1938         Add an extra rsync command to CopyWTFHeaders which copies the ICU headers
1939         to DSTROOT/usr/local/include/. These headers already live inside a
1940         "unicode" folder, so an example path of a header is
1941         DSTROOT/usr/local/include/unicode/uchar.h. This is already in the search
1942         path of the other WebKit projects, so those other projects can remove
1943         their explicit listing of the old place these headers lived.
1944
1945         Also add the remaining ICU 55.1 headers which the other projects (like
1946         WebCore) need. Revert any local changes to these headers in favor of
1947         using the GCC_PREPROCESSOR_DEFINITIONS build setting. This is so we can
1948         compile the same way against unmodified headers.
1949
1950         * Configurations/Base.xcconfig:
1951         * Configurations/CopyWTFHeaders.xcconfig:
1952         * WTF.xcodeproj/project.pbxproj:
1953         * icu/unicode/alphaindex.h: Added.
1954         * icu/unicode/appendable.h: Added.
1955         * icu/unicode/basictz.h: Added.
1956         * icu/unicode/brkiter.h: Added.
1957         (BreakIterator::isBufferClone):
1958         * icu/unicode/bytestrie.h: Added.
1959         * icu/unicode/bytestriebuilder.h: Added.
1960         * icu/unicode/calendar.h: Added.
1961         (Calendar::createInstance):
1962         (Calendar::roll):
1963         (Calendar::internalSet):
1964         (Calendar::weekNumber):
1965         * icu/unicode/caniter.h: Added.
1966         * icu/unicode/chariter.h: Renamed from Source/WebCore/icu/unicode/chariter.h.
1967         * icu/unicode/choicfmt.h: Added.
1968         * icu/unicode/coleitr.h: Added.
1969         (CollationElementIterator::primaryOrder):
1970         (CollationElementIterator::secondaryOrder):
1971         (CollationElementIterator::tertiaryOrder):
1972         (CollationElementIterator::isIgnorable):
1973         * icu/unicode/coll.h: Added.
1974         * icu/unicode/compactdecimalformat.h: Added.
1975         * icu/unicode/curramt.h: Added.
1976         (CurrencyAmount::getCurrency):
1977         (CurrencyAmount::getISOCurrency):
1978         * icu/unicode/currpinf.h: Added.
1979         (CurrencyPluralInfo::operator!=):
1980         * icu/unicode/currunit.h: Added.
1981         (CurrencyUnit::getISOCurrency):
1982         * icu/unicode/datefmt.h: Added.
1983         * icu/unicode/dbbi.h: Added.
1984         * icu/unicode/dcfmtsym.h: Added.
1985         (DecimalFormatSymbols::getSymbol):
1986         (DecimalFormatSymbols::getConstSymbol):
1987         (DecimalFormatSymbols::setSymbol):
1988         (DecimalFormatSymbols::getLocale):
1989         (DecimalFormatSymbols::getCurrencyPattern):
1990         * icu/unicode/decimfmt.h: Added.
1991         (DecimalFormat::getConstSymbol):
1992         * icu/unicode/docmain.h: Added.
1993         * icu/unicode/dtfmtsym.h: Added.
1994         * icu/unicode/dtintrv.h: Added.
1995         (DateInterval::getFromDate):
1996         (DateInterval::getToDate):
1997         (DateInterval::operator!=):
1998         * icu/unicode/dtitvfmt.h: Added.
1999         (DateIntervalFormat::operator!=):
2000         * icu/unicode/dtitvinf.h: Added.
2001         (DateIntervalInfo::operator!=):
2002         * icu/unicode/dtptngen.h: Added.
2003         * icu/unicode/dtrule.h: Added.
2004         * icu/unicode/enumset.h: Added.
2005         (EnumSet::EnumSet):
2006         (EnumSet::~EnumSet):
2007         (EnumSet::clear):
2008         (EnumSet::add):
2009         (EnumSet::remove):
2010         (EnumSet::contains):
2011         (EnumSet::set):
2012         (EnumSet::get):
2013         (EnumSet::isValidEnum):
2014         (EnumSet::isValidValue):
2015         (EnumSet::operator=):
2016         (EnumSet::getAll):
2017         (EnumSet::flag):
2018         * icu/unicode/errorcode.h: Added.
2019         * icu/unicode/fieldpos.h: Added.
2020         (FieldPosition::operator=):
2021         (FieldPosition::operator==):
2022         (FieldPosition::operator!=):
2023         * icu/unicode/filteredbrk.h: Added.
2024         * icu/unicode/fmtable.h: Added.
2025         (Formattable::getDate):
2026         (Formattable::getString):
2027         (Formattable::getLong):
2028         (Formattable::toUFormattable):
2029         (Formattable::fromUFormattable):
2030         * icu/unicode/format.h: Added.
2031         * icu/unicode/fpositer.h: Added.
2032         * icu/unicode/gender.h: Added.
2033         * icu/unicode/gregocal.h: Added.
2034         * icu/unicode/icudataver.h: Added.
2035         * icu/unicode/icuplug.h: Added.
2036         * icu/unicode/idna.h: Added.
2037         * icu/unicode/listformatter.h: Added.
2038         (ListFormatData::ListFormatData):
2039         * icu/unicode/locdspnm.h: Added.
2040         (LocaleDisplayNames::createInstance):
2041         * icu/unicode/locid.h: Added.
2042         (Locale::operator!=):
2043         (Locale::getCountry):
2044         (Locale::getLanguage):
2045         (Locale::getScript):
2046         (Locale::getVariant):
2047         (Locale::getName):
2048         (Locale::isBogus):
2049         * icu/unicode/measfmt.h: Added.
2050         * icu/unicode/measunit.h: Added.
2051         * icu/unicode/measure.h: Added.
2052         (Measure::getNumber):
2053         (Measure::getUnit):
2054         * icu/unicode/messagepattern.h: Added.
2055         * icu/unicode/msgfmt.h: Added.
2056         * icu/unicode/normalizer2.h: Added.
2057         * icu/unicode/normlzr.h: Added.
2058         (Normalizer::operator!= ):
2059         (Normalizer::quickCheck):
2060         (Normalizer::isNormalized):
2061         (Normalizer::compare):
2062         * icu/unicode/numfmt.h: Added.
2063         (NumberFormat::isParseIntegerOnly):
2064         (NumberFormat::isLenient):
2065         * icu/unicode/numsys.h: Added.
2066         * icu/unicode/parsepos.h: Added.
2067         (ParsePosition::operator=):
2068         (ParsePosition::operator==):
2069         (ParsePosition::operator!=):
2070         (ParsePosition::getIndex):
2071         (ParsePosition::setIndex):
2072         (ParsePosition::getErrorIndex):
2073         (ParsePosition::setErrorIndex):
2074         * icu/unicode/plurfmt.h: Added.
2075         * icu/unicode/plurrule.h: Added.
2076         * icu/unicode/rbbi.h: Added.
2077         (RuleBasedBreakIterator::operator!=):
2078         * icu/unicode/rbnf.h: Added.
2079         (RuleBasedNumberFormat::isLenient):
2080         (RuleBasedNumberFormat::getDefaultRuleSet):
2081         * icu/unicode/rbtz.h: Added.
2082         * icu/unicode/regex.h: Added.
2083         * icu/unicode/region.h: Added.
2084         * icu/unicode/reldatefmt.h: Added.
2085         * icu/unicode/resbund.h: Added.
2086         * icu/unicode/schriter.h: Added.
2087         * icu/unicode/scientificnumberformatter.h: Added.
2088         * icu/unicode/search.h: Added.
2089         (SearchIterator::operator!=):
2090         * icu/unicode/selfmt.h: Added.
2091         * icu/unicode/simpletz.h: Added.
2092         (SimpleTimeZone::setStartRule):
2093         (SimpleTimeZone::setEndRule):
2094         (SimpleTimeZone::getOffset):
2095         * icu/unicode/smpdtfmt.h: Added.
2096         (SimpleDateFormat::get2DigitYearStart):
2097         * icu/unicode/sortkey.h: Added.
2098         (CollationKey::operator!=):
2099         (CollationKey::isBogus):
2100         (CollationKey::getByteArray):
2101         * icu/unicode/stringtriebuilder.h: Added.
2102         * icu/unicode/stsearch.h: Added.
2103         * icu/unicode/symtable.h: Added.
2104         * icu/unicode/tblcoll.h: Added.
2105         * icu/unicode/timezone.h: Added.
2106         (TimeZone::getID):
2107         (TimeZone::setID):
2108         * icu/unicode/tmunit.h: Added.
2109         * icu/unicode/tmutamt.h: Added.
2110         (TimeUnitAmount::operator!=):
2111         * icu/unicode/tmutfmt.h: Added.
2112         (TimeUnitFormat::operator!=):
2113         * icu/unicode/translit.h: Added.
2114         (Transliterator::getMaximumContextLength):
2115         (Transliterator::setID):
2116         (Transliterator::integerToken):
2117         (Transliterator::pointerToken):
2118         * icu/unicode/tzfmt.h: Added.
2119         * icu/unicode/tznames.h: Added.
2120         * icu/unicode/tzrule.h: Added.
2121         * icu/unicode/tztrans.h: Added.
2122         * icu/unicode/ubidi.h: Added.
2123         * icu/unicode/ucal.h: Renamed from Source/JavaScriptCore/icu/unicode/ucal.h.
2124         * icu/unicode/ucasemap.h: Added.
2125         * icu/unicode/ucat.h: Added.
2126         * icu/unicode/ucharstrie.h: Added.
2127         * icu/unicode/ucharstriebuilder.h: Added.
2128         * icu/unicode/uchriter.h: Added.
2129         * icu/unicode/uclean.h: Added.
2130         * icu/unicode/ucnv_cb.h: Renamed from Source/WebCore/icu/unicode/ucnv_cb.h.
2131         * icu/unicode/ucnvsel.h: Added.
2132         * icu/unicode/ucoleitr.h: Renamed from Source/WebCore/icu/unicode/ucoleitr.h.
2133         * icu/unicode/uconfig.h:
2134         * icu/unicode/ucsdet.h: Renamed from Source/WebCore/icu/unicode/ucsdet.h.
2135         * icu/unicode/udat.h: Renamed from Source/JavaScriptCore/icu/unicode/udat.h.
2136         * icu/unicode/udata.h: Added.
2137         * icu/unicode/udateintervalformat.h: Added.
2138         * icu/unicode/udatpg.h: Renamed from Source/JavaScriptCore/icu/unicode/udatpg.h.
2139         * icu/unicode/udisplaycontext.h: Renamed from Source/JavaScriptCore/icu/unicode/udisplaycontext.h.
2140         * icu/unicode/ufieldpositer.h: Renamed from Source/JavaScriptCore/icu/unicode/ufieldpositer.h.
2141         * icu/unicode/uformattable.h: Renamed from Source/JavaScriptCore/icu/unicode/uformattable.h.
2142         * icu/unicode/ugender.h: Added.
2143         * icu/unicode/uidna.h: Renamed from Source/WebCore/icu/unicode/uidna.h.
2144         * icu/unicode/uldnames.h: Added.
2145         * icu/unicode/ulistformatter.h: Added.
2146         * icu/unicode/ulocdata.h: Added.
2147         * icu/unicode/umisc.h: Renamed from Source/JavaScriptCore/icu/unicode/umisc.h.
2148         * icu/unicode/umsg.h: Added.
2149         * icu/unicode/unifilt.h: Added.
2150         * icu/unicode/unifunct.h: Added.
2151         * icu/unicode/unimatch.h: Added.
2152         * icu/unicode/unirepl.h: Added.
2153         * icu/unicode/uniset.h: Added.
2154         (UnicodeSet::operator!=):
2155         (UnicodeSet::isFrozen):
2156         (UnicodeSet::containsSome):
2157         (UnicodeSet::isBogus):
2158         (UnicodeSet::fromUSet):
2159         (UnicodeSet::toUSet):
2160         (UnicodeSet::span):
2161         (UnicodeSet::spanBack):
2162         * icu/unicode/unum.h: Renamed from Source/JavaScriptCore/icu/unicode/unum.h.
2163         * icu/unicode/unumsys.h: Renamed from Source/JavaScriptCore/icu/unicode/unumsys.h.
2164         * icu/unicode/upluralrules.h: Added.
2165         * icu/unicode/uregex.h: Added.
2166         * icu/unicode/uregion.h: Added.
2167         * icu/unicode/urep.h: Added.
2168         * icu/unicode/ures.h: Added.
2169         (ures_getUnicodeString):
2170         (ures_getNextUnicodeString):
2171         (ures_getUnicodeStringByIndex):
2172         (ures_getUnicodeStringByKey):
2173         * icu/unicode/usearch.h: Renamed from Source/WebCore/icu/unicode/usearch.h.
2174         * icu/unicode/usetiter.h: Added.
2175         (UnicodeSetIterator::isString):
2176         (UnicodeSetIterator::getCodepoint):
2177         (UnicodeSetIterator::getCodepointEnd):
2178         * icu/unicode/ushape.h: Renamed from Source/WebCore/icu/unicode/ushape.h.
2179         * icu/unicode/uspoof.h: Added.
2180         * icu/unicode/usprep.h: Added.
2181         * icu/unicode/ustdio.h: Added.
2182         * icu/unicode/ustream.h: Added.
2183         * icu/unicode/ustringtrie.h: Added.
2184         * icu/unicode/utf32.h: Added.
2185         * icu/unicode/utmscale.h: Added.
2186         * icu/unicode/utrace.h: Added.
2187         * icu/unicode/utrans.h: Added.
2188         * icu/unicode/utypes.h:
2189         * icu/unicode/vtzone.h: Added.
2190
2191 2017-07-04  Yusuke Suzuki  <utatane.tea@gmail.com>
2192
2193         [WTF] Make double-conversion's cache data constant and drop double_conversion::initialize()
2194         https://bugs.webkit.org/show_bug.cgi?id=174124
2195
2196         Reviewed by Saam Barati.
2197
2198         We annotate double-conversion's cache data as const and constexpr. And move it out of function.
2199         Since they are not involving global constructors, they are compiled as rodata and initialized
2200         without calling double_conversion::initialize().
2201
2202         And we drop double_conversion::initialize() function since it is no longer necessary.
2203
2204         * wtf/Threading.cpp:
2205         (WTF::initializeThreading):
2206         * wtf/dtoa/cached-powers.cc:
2207         * wtf/dtoa/cached-powers.h:
2208
2209 2017-07-04  Yusuke Suzuki  <utatane.tea@gmail.com>
2210
2211         [WTF] Initialize srandom and srand with cryptographically random number
2212         https://bugs.webkit.org/show_bug.cgi?id=174123
2213
2214         Reviewed by Mark Lam.
2215
2216         Use cryptographically random number instead of current time as a seed.
2217
2218         * wtf/RandomNumberSeed.h:
2219         (WTF::initializeRandomNumberGenerator):
2220
2221 2017-07-04  Joseph Pecoraro  <pecoraro@apple.com>
2222
2223         Xcode duplicate UUID for DisallowCType.h and DispatchPtr.h
2224         https://bugs.webkit.org/show_bug.cgi?id=174117
2225
2226         Reviewed by Alexey Proskuryakov.
2227
2228         * WTF.xcodeproj/project.pbxproj:
2229         Give DisallowCType.h and DispatchPtr.h different UUIDs.
2230
2231 2017-07-03  Saam Barati  <sbarati@apple.com>
2232
2233         LayoutTest workers/bomb.html is a Crash
2234         https://bugs.webkit.org/show_bug.cgi?id=167757
2235         <rdar://problem/33086462>
2236
2237         Reviewed by Keith Miller.
2238
2239         * wtf/AutomaticThread.cpp:
2240         (WTF::AutomaticThreadCondition::waitFor):
2241         * wtf/AutomaticThread.h:
2242
2243 2017-07-03  Commit Queue  <commit-queue@webkit.org>
2244
2245         Unreviewed, rolling out r219060.
2246         https://bugs.webkit.org/show_bug.cgi?id=174108
2247
2248         crashing constantly when initializing UIWebView (Requested by
2249         thorton on #webkit).
2250
2251         Reverted changeset:
2252
2253         "WTF::Thread should have the threads stack bounds."
2254         https://bugs.webkit.org/show_bug.cgi?id=173975
2255         http://trac.webkit.org/changeset/219060
2256
2257 2017-07-03  Matt Lewis  <jlewis3@apple.com>
2258
2259         Unreviewed, rolling out r219103.
2260
2261         Caused multiple build failures.
2262
2263         Reverted changeset:
2264
2265         "Remove copy of ICU headers from WebKit"
2266         https://bugs.webkit.org/show_bug.cgi?id=116407
2267         http://trac.webkit.org/changeset/219103
2268
2269 2017-07-03  Myles C. Maxfield  <mmaxfield@apple.com>
2270
2271         Remove copy of ICU headers from WebKit
2272         https://bugs.webkit.org/show_bug.cgi?id=116407
2273
2274         Reviewed by Alex Christensen.
2275
2276         Add an extra rsync command to CopyWTFHeaders which copies the ICU headers
2277         to DSTROOT/usr/local/include/. These headers already live inside a
2278         "unicode" folder, so an example path of a header is
2279         DSTROOT/usr/local/include/unicode/uchar.h. This is already in the search
2280         path of the other WebKit projects, so those other projects can remove
2281         their explicit listing of the old place these headers lived.
2282
2283         Also add the remaining ICU 55.1 headers which the other projects (like
2284         WebCore) need. Revert any local changes to these headers in favor of
2285         using the GCC_PREPROCESSOR_DEFINITIONS build setting. This is so we can
2286         compile the same way against unmodified headers.
2287
2288         * Configurations/Base.xcconfig:
2289         * Configurations/CopyWTFHeaders.xcconfig:
2290         * WTF.xcodeproj/project.pbxproj:
2291         * icu/unicode/alphaindex.h: Added.
2292         * icu/unicode/appendable.h: Added.
2293         * icu/unicode/basictz.h: Added.
2294         * icu/unicode/brkiter.h: Added.
2295         (BreakIterator::isBufferClone):
2296         * icu/unicode/bytestrie.h: Added.
2297         * icu/unicode/bytestriebuilder.h: Added.
2298         * icu/unicode/calendar.h: Added.
2299         (Calendar::createInstance):
2300         (Calendar::roll):
2301         (Calendar::internalSet):
2302         (Calendar::weekNumber):
2303         * icu/unicode/caniter.h: Added.
2304         * icu/unicode/chariter.h: Renamed from Source/WebCore/icu/unicode/chariter.h.
2305         * icu/unicode/choicfmt.h: Added.
2306         * icu/unicode/coleitr.h: Added.
2307         (CollationElementIterator::primaryOrder):
2308         (CollationElementIterator::secondaryOrder):
2309         (CollationElementIterator::tertiaryOrder):
2310         (CollationElementIterator::isIgnorable):
2311         * icu/unicode/coll.h: Added.
2312         * icu/unicode/compactdecimalformat.h: Added.
2313         * icu/unicode/curramt.h: Added.
2314         (CurrencyAmount::getCurrency):
2315         (CurrencyAmount::getISOCurrency):
2316         * icu/unicode/currpinf.h: Added.
2317         (CurrencyPluralInfo::operator!=):
2318         * icu/unicode/currunit.h: Added.
2319         (CurrencyUnit::getISOCurrency):
2320         * icu/unicode/datefmt.h: Added.
2321         * icu/unicode/dbbi.h: Added.
2322         * icu/unicode/dcfmtsym.h: Added.
2323         (DecimalFormatSymbols::getSymbol):
2324         (DecimalFormatSymbols::getConstSymbol):
2325         (DecimalFormatSymbols::setSymbol):
2326         (DecimalFormatSymbols::getLocale):
2327         (DecimalFormatSymbols::getCurrencyPattern):
2328         * icu/unicode/decimfmt.h: Added.
2329         (DecimalFormat::getConstSymbol):
2330         * icu/unicode/docmain.h: Added.
2331         * icu/unicode/dtfmtsym.h: Added.
2332         * icu/unicode/dtintrv.h: Added.
2333         (DateInterval::getFromDate):
2334         (DateInterval::getToDate):
2335         (DateInterval::operator!=):
2336         * icu/unicode/dtitvfmt.h: Added.
2337         (DateIntervalFormat::operator!=):
2338         * icu/unicode/dtitvinf.h: Added.
2339         (DateIntervalInfo::operator!=):
2340         * icu/unicode/dtptngen.h: Added.
2341         * icu/unicode/dtrule.h: Added.
2342         * icu/unicode/enumset.h: Added.
2343         (EnumSet::EnumSet):
2344         (EnumSet::~EnumSet):
2345         (EnumSet::clear):
2346         (EnumSet::add):
2347         (EnumSet::remove):
2348         (EnumSet::contains):
2349         (EnumSet::set):
2350         (EnumSet::get):
2351         (EnumSet::isValidEnum):
2352         (EnumSet::isValidValue):
2353         (EnumSet::operator=):
2354         (EnumSet::getAll):
2355         (EnumSet::flag):
2356         * icu/unicode/errorcode.h: Added.
2357         * icu/unicode/fieldpos.h: Added.
2358         (FieldPosition::operator=):
2359         (FieldPosition::operator==):
2360         (FieldPosition::operator!=):
2361         * icu/unicode/filteredbrk.h: Added.
2362         * icu/unicode/fmtable.h: Added.
2363         (Formattable::getDate):
2364         (Formattable::getString):
2365         (Formattable::getLong):
2366         (Formattable::toUFormattable):
2367         (Formattable::fromUFormattable):
2368         * icu/unicode/format.h: Added.
2369         * icu/unicode/fpositer.h: Added.
2370         * icu/unicode/gender.h: Added.
2371         * icu/unicode/gregocal.h: Added.
2372         * icu/unicode/icudataver.h: Added.
2373         * icu/unicode/icuplug.h: Added.
2374         * icu/unicode/idna.h: Added.
2375         * icu/unicode/listformatter.h: Added.
2376         (ListFormatData::ListFormatData):
2377         * icu/unicode/locdspnm.h: Added.
2378         (LocaleDisplayNames::createInstance):
2379         * icu/unicode/locid.h: Added.
2380         (Locale::operator!=):
2381         (Locale::getCountry):
2382         (Locale::getLanguage):
2383         (Locale::getScript):
2384         (Locale::getVariant):
2385         (Locale::getName):
2386         (Locale::isBogus):
2387         * icu/unicode/measfmt.h: Added.
2388         * icu/unicode/measunit.h: Added.
2389         * icu/unicode/measure.h: Added.
2390         (Measure::getNumber):
2391         (Measure::getUnit):
2392         * icu/unicode/messagepattern.h: Added.
2393         * icu/unicode/msgfmt.h: Added.
2394         * icu/unicode/normalizer2.h: Added.
2395         * icu/unicode/normlzr.h: Added.
2396         (Normalizer::operator!= ):
2397         (Normalizer::quickCheck):
2398         (Normalizer::isNormalized):
2399         (Normalizer::compare):
2400         * icu/unicode/numfmt.h: Added.
2401         (NumberFormat::isParseIntegerOnly):
2402         (NumberFormat::isLenient):
2403         * icu/unicode/numsys.h: Added.
2404         * icu/unicode/parsepos.h: Added.
2405         (ParsePosition::operator=):
2406         (ParsePosition::operator==):
2407         (ParsePosition::operator!=):
2408         (ParsePosition::getIndex):
2409         (ParsePosition::setIndex):
2410         (ParsePosition::getErrorIndex):
2411         (ParsePosition::setErrorIndex):
2412         * icu/unicode/plurfmt.h: Added.
2413         * icu/unicode/plurrule.h: Added.
2414         * icu/unicode/rbbi.h: Added.
2415         (RuleBasedBreakIterator::operator!=):
2416         * icu/unicode/rbnf.h: Added.
2417         (RuleBasedNumberFormat::isLenient):
2418         (RuleBasedNumberFormat::getDefaultRuleSet):
2419         * icu/unicode/rbtz.h: Added.
2420         * icu/unicode/regex.h: Added.
2421         * icu/unicode/region.h: Added.
2422         * icu/unicode/reldatefmt.h: Added.
2423         * icu/unicode/resbund.h: Added.
2424         * icu/unicode/schriter.h: Added.
2425         * icu/unicode/scientificnumberformatter.h: Added.
2426         * icu/unicode/search.h: Added.
2427         (SearchIterator::operator!=):
2428         * icu/unicode/selfmt.h: Added.
2429         * icu/unicode/simpletz.h: Added.
2430         (SimpleTimeZone::setStartRule):
2431         (SimpleTimeZone::setEndRule):
2432         (SimpleTimeZone::getOffset):
2433         * icu/unicode/smpdtfmt.h: Added.
2434         (SimpleDateFormat::get2DigitYearStart):
2435         * icu/unicode/sortkey.h: Added.
2436         (CollationKey::operator!=):
2437         (CollationKey::isBogus):
2438         (CollationKey::getByteArray):
2439         * icu/unicode/stringtriebuilder.h: Added.
2440         * icu/unicode/stsearch.h: Added.
2441         * icu/unicode/symtable.h: Added.
2442         * icu/unicode/tblcoll.h: Added.
2443         * icu/unicode/timezone.h: Added.
2444         (TimeZone::getID):
2445         (TimeZone::setID):
2446         * icu/unicode/tmunit.h: Added.
2447         * icu/unicode/tmutamt.h: Added.
2448         (TimeUnitAmount::operator!=):
2449         * icu/unicode/tmutfmt.h: Added.
2450         (TimeUnitFormat::operator!=):
2451         * icu/unicode/translit.h: Added.
2452         (Transliterator::getMaximumContextLength):
2453         (Transliterator::setID):
2454         (Transliterator::integerToken):
2455         (Transliterator::pointerToken):
2456         * icu/unicode/tzfmt.h: Added.
2457         * icu/unicode/tznames.h: Added.
2458         * icu/unicode/tzrule.h: Added.
2459         * icu/unicode/tztrans.h: Added.
2460         * icu/unicode/ubidi.h: Added.
2461         * icu/unicode/ucal.h: Renamed from Source/JavaScriptCore/icu/unicode/ucal.h.
2462         * icu/unicode/ucasemap.h: Added.
2463         * icu/unicode/ucat.h: Added.
2464         * icu/unicode/ucharstrie.h: Added.
2465         * icu/unicode/ucharstriebuilder.h: Added.
2466         * icu/unicode/uchriter.h: Added.
2467         * icu/unicode/uclean.h: Added.
2468         * icu/unicode/ucnv_cb.h: Renamed from Source/WebCore/icu/unicode/ucnv_cb.h.
2469         * icu/unicode/ucnvsel.h: Added.
2470         * icu/unicode/ucoleitr.h: Renamed from Source/WebCore/icu/unicode/ucoleitr.h.
2471         * icu/unicode/uconfig.h:
2472         * icu/unicode/ucsdet.h: Renamed from Source/WebCore/icu/unicode/ucsdet.h.
2473         * icu/unicode/udat.h: Renamed from Source/JavaScriptCore/icu/unicode/udat.h.
2474         * icu/unicode/udata.h: Added.
2475         * icu/unicode/udateintervalformat.h: Added.
2476         * icu/unicode/udatpg.h: Renamed from Source/JavaScriptCore/icu/unicode/udatpg.h.
2477         * icu/unicode/udisplaycontext.h: Renamed from Source/JavaScriptCore/icu/unicode/udisplaycontext.h.
2478         * icu/unicode/ufieldpositer.h: Renamed from Source/JavaScriptCore/icu/unicode/ufieldpositer.h.
2479         * icu/unicode/uformattable.h: Renamed from Source/JavaScriptCore/icu/unicode/uformattable.h.
2480         * icu/unicode/ugender.h: Added.
2481         * icu/unicode/uidna.h: Renamed from Source/WebCore/icu/unicode/uidna.h.
2482         * icu/unicode/uldnames.h: Added.
2483         * icu/unicode/ulistformatter.h: Added.
2484         * icu/unicode/ulocdata.h: Added.
2485         * icu/unicode/umisc.h: Renamed from Source/JavaScriptCore/icu/unicode/umisc.h.
2486         * icu/unicode/umsg.h: Added.
2487         * icu/unicode/unifilt.h: Added.
2488         * icu/unicode/unifunct.h: Added.
2489         * icu/unicode/unimatch.h: Added.
2490         * icu/unicode/unirepl.h: Added.
2491         * icu/unicode/uniset.h: Added.
2492         (UnicodeSet::operator!=):
2493         (UnicodeSet::isFrozen):
2494         (UnicodeSet::containsSome):
2495         (UnicodeSet::isBogus):
2496         (UnicodeSet::fromUSet):
2497         (UnicodeSet::toUSet):
2498         (UnicodeSet::span):
2499         (UnicodeSet::spanBack):
2500         * icu/unicode/unum.h: Renamed from Source/JavaScriptCore/icu/unicode/unum.h.
2501         * icu/unicode/unumsys.h: Renamed from Source/JavaScriptCore/icu/unicode/unumsys.h.
2502         * icu/unicode/upluralrules.h: Added.
2503         * icu/unicode/uregex.h: Added.
2504         * icu/unicode/uregion.h: Added.
2505         * icu/unicode/urep.h: Added.
2506         * icu/unicode/ures.h: Added.
2507         (ures_getUnicodeString):
2508         (ures_getNextUnicodeString):
2509         (ures_getUnicodeStringByIndex):
2510         (ures_getUnicodeStringByKey):
2511         * icu/unicode/usearch.h: Renamed from Source/WebCore/icu/unicode/usearch.h.
2512         * icu/unicode/usetiter.h: Added.
2513         (UnicodeSetIterator::isString):
2514         (UnicodeSetIterator::getCodepoint):
2515         (UnicodeSetIterator::getCodepointEnd):
2516         * icu/unicode/ushape.h: Renamed from Source/WebCore/icu/unicode/ushape.h.
2517         * icu/unicode/usprep.h: Added.
2518         * icu/unicode/ustdio.h: Added.
2519         * icu/unicode/ustream.h: Added.
2520         * icu/unicode/ustringtrie.h: Added.
2521         * icu/unicode/utf32.h: Added.
2522         * icu/unicode/utmscale.h: Added.
2523         * icu/unicode/utrace.h: Added.
2524         * icu/unicode/utrans.h: Added.
2525         * icu/unicode/utypes.h:
2526         * icu/unicode/vtzone.h: Added.
2527
2528 2017-07-03  Keith Miller  <keith_miller@apple.com>
2529
2530         Fix ifndef in Assertions.h
2531         https://bugs.webkit.org/show_bug.cgi?id=174104
2532
2533         Reviewed by Saam Barati.
2534
2535         The ifndef should have been checking for
2536         CRASH_WITH_SECURITY_IMPLICATION_AND_INFO since that is what the
2537         ifndef defines.
2538
2539         * wtf/Assertions.h:
2540
2541 2017-07-03  Andy Estes  <aestes@apple.com>
2542
2543         [Xcode] Add an experimental setting to build with ccache
2544         https://bugs.webkit.org/show_bug.cgi?id=173875
2545
2546         Reviewed by Tim Horton.
2547
2548         * Configurations/DebugRelease.xcconfig: Included ccache.xcconfig.
2549
2550 2017-07-03  Daewoong Jang  <daewoong.jang@navercorp.com>
2551
2552         Remove an unused function export
2553         https://bugs.webkit.org/show_bug.cgi?id=174084
2554
2555         Reviewed by Yusuke Suzuki.
2556
2557         * wtf/Threading.h:
2558
2559 2017-07-02  Yusuke Suzuki  <utatane.tea@gmail.com>
2560
2561         WTF::Thread should have the threads stack bounds.
2562         https://bugs.webkit.org/show_bug.cgi?id=173975
2563
2564         Reviewed by Mark Lam.
2565
2566         We move StackBounds from WTFThreadData to WTF::Thread.
2567         One important thing is that we should make valid StackBounds
2568         visible to Thread::create() caller. When the caller get
2569         WTF::Thread from Thread::create(), this WTF::Thread should
2570         have a valid StackBounds. But StackBounds information can be
2571         retrived only in the WTF::Thread's thread itself.
2572
2573         * wtf/StackBounds.h:
2574         (WTF::StackBounds::emptyBounds):
2575         (WTF::StackBounds::StackBounds):
2576         * wtf/StackStats.cpp:
2577         (WTF::StackStats::PerThreadStats::PerThreadStats):
2578         * wtf/Threading.cpp:
2579         (WTF::threadEntryPoint):
2580         (WTF::Thread::create):
2581         (WTF::Thread::currentMayBeNull):
2582         (WTF::Thread::initialize):
2583         * wtf/Threading.h:
2584         (WTF::Thread::stack):
2585         * wtf/ThreadingPthreads.cpp:
2586         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
2587         (WTF::Thread::current):
2588         (WTF::initializeCurrentThreadEvenIfNonWTFCreated): Deleted.
2589         (WTF::Thread::currentMayBeNull): Deleted.
2590         * wtf/ThreadingWin.cpp:
2591         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
2592         (WTF::Thread::initializeCurrentThreadInternal):
2593         (WTF::Thread::current):
2594         * wtf/WTFThreadData.cpp:
2595         (WTF::WTFThreadData::WTFThreadData):
2596         * wtf/WTFThreadData.h:
2597         (WTF::WTFThreadData::stack): Deleted.
2598
2599 2017-07-01  Dan Bernstein  <mitz@apple.com>
2600
2601         [iOS] Remove code only needed when building for iOS 9.x
2602         https://bugs.webkit.org/show_bug.cgi?id=174068
2603
2604         Reviewed by Tim Horton.
2605
2606         * wtf/Platform.h:
2607         * wtf/mac/DeprecatedSymbolsUsedBySafari.mm:
2608         * wtf/spi/darwin/dyldSPI.h:
2609
2610 2017-07-01  Caio Lima  <ticaiolima@gmail.com>
2611
2612         [JSC] WTFGetBacktrace can return numberOfFrames == 0 in some architectures
2613         https://bugs.webkit.org/show_bug.cgi?id=172768
2614
2615         Reviewed by Mark Lam.
2616
2617         In some architectures, like ARMv6 running on a Raspberry pi, the
2618         backtrace function from "execinfo.h" is returning 0. In
2619         that case, the RELEASE_ASSERT in StackTrace::captureStackTrace
2620         fails causing a runtime crash.
2621         This patch is adding a guard for the case described above to
2622         avoid a runtime crash in such case.
2623
2624         * wtf/StackTrace.cpp:
2625         (WTF::StackTrace::captureStackTrace):
2626
2627 2017-07-01  Dan Bernstein  <mitz@apple.com>
2628
2629         [macOS] Remove code only needed when building for OS X Yosemite
2630         https://bugs.webkit.org/show_bug.cgi?id=174067
2631
2632         Reviewed by Tim Horton.
2633
2634         * Configurations/Base.xcconfig:
2635         * Configurations/DebugRelease.xcconfig:
2636         * wtf/Platform.h:
2637         * wtf/mac/AppKitCompatibilityDeclarations.h:
2638         * wtf/spi/cocoa/SecuritySPI.h:
2639         * wtf/text/TextBreakIterator.cpp:
2640
2641 2017-07-01  Joseph Pecoraro  <pecoraro@apple.com>
2642
2643         Add a warning if WEBGL2 is enabled without WEBGL
2644         https://bugs.webkit.org/show_bug.cgi?id=174054
2645
2646         Reviewed by Sam Weinig.
2647
2648         * wtf/FeatureDefines.h:
2649
2650 2017-06-30  Keith Miller  <keith_miller@apple.com>
2651
2652         Force crashWithInfo to be out of line.
2653         https://bugs.webkit.org/show_bug.cgi?id=174028
2654
2655         Reviewed by Filip Pizlo.
2656
2657         The first pass at making crashes hold information about why they
2658         were crashing had the problem that it would inline the assertion.
2659         This meant that clang could coalesce DFG_ASSERTS with other
2660         assertion failures in the same function. This patch moves it out
2661         of line to help fix that issue.
2662
2663         * wtf/Assertions.cpp:
2664         (WTFCrashWithInfo):
2665         * wtf/Assertions.h:
2666         (WTF::isIntegralType):
2667
2668 2017-06-30  Yusuke Suzuki  <utatane.tea@gmail.com>
2669
2670         [WTF] Drop SymbolRegistry::keyForSymbol
2671         https://bugs.webkit.org/show_bug.cgi?id=174052
2672
2673         Reviewed by Sam Weinig.
2674
2675         Since we can know whether a given symbol is registered by checking RegisteredSymbolImpl,
2676         we do not need to query key string for a given symbol by using SymbolRegistry::keyForSymbol.
2677
2678         * wtf/text/SymbolImpl.h:
2679         (WTF::SymbolImpl::extractFoldedString): Deleted.
2680         * wtf/text/SymbolRegistry.cpp:
2681         (WTF::SymbolRegistry::keyForSymbol): Deleted.
2682         * wtf/text/SymbolRegistry.h:
2683
2684 2017-06-29  Jer Noble  <jer.noble@apple.com>
2685
2686         Make Legacy EME API controlled by RuntimeEnabled setting.
2687         https://bugs.webkit.org/show_bug.cgi?id=173994
2688
2689         Reviewed by Sam Weinig.
2690
2691         * wtf/FeatureDefines.h:
2692
2693 2017-06-30  Ryosuke Niwa  <rniwa@webkit.org>
2694
2695         Ran sort-Xcode-project-file.
2696
2697         * WTF.xcodeproj/project.pbxproj:
2698
2699 2017-06-30  Matt Lewis  <jlewis3@apple.com>
2700
2701         Unreviewed, rolling out r218992.
2702
2703         The patch broke the iOS device builds.
2704
2705         Reverted changeset:
2706
2707         "DFG_ASSERT should allow stuffing registers before trapping."
2708         https://bugs.webkit.org/show_bug.cgi?id=174005
2709         http://trac.webkit.org/changeset/218992
2710
2711 2017-06-30  Keith Miller  <keith_miller@apple.com>
2712
2713         DFG_ASSERT should allow stuffing registers before trapping.
2714         https://bugs.webkit.org/show_bug.cgi?id=174005
2715
2716         Reviewed by Mark Lam.
2717
2718         Add new template functions that enable stuffing up to five values
2719         into registers before crashing.
2720
2721         * wtf/Assertions.h:
2722         (CRASH_WITH_INFO):
2723
2724 2017-06-28  Brent Fulgham  <bfulgham@apple.com>
2725
2726         Teach ResourceLoadStatistics to recognize changes in the file system
2727         https://bugs.webkit.org/show_bug.cgi?id=173800
2728         <rdar://problem/32937842>
2729
2730         Reviewed by Chris Dumez.
2731
2732         * wtf/DispatchPtr.h: Added (moved from WebKit2)
2733         * wtf/Platform.h: Make sure USE_FILE_LOCK is enabled.
2734
2735 2017-06-28  David Kilzer  <ddkilzer@apple.com>
2736
2737         Fix typo in comment: WordResult => WorkResult
2738
2739         * wtf/AutomaticThread.h:
2740
2741 2017-06-27  Caio Lima  <ticaiolima@gmail.com>
2742
2743         [ESnext] Implement Object Rest - Implementing Object Rest Destructuring
2744         https://bugs.webkit.org/show_bug.cgi?id=167962
2745
2746         Reviewed by Saam Barati.
2747
2748         * wtf/HashSet.h:
2749         (WTF::=):
2750
2751 2017-06-26  Yusuke Suzuki  <utatane.tea@gmail.com>
2752
2753         [WTF] Drop Thread::create(obsolete things) API since we can use lambda
2754         https://bugs.webkit.org/show_bug.cgi?id=173825
2755
2756         Reviewed by Saam Barati.
2757
2758         Thread::create(ThreadFunction, void* data, const char* name) is a bit old API.
2759         Since we have C++ lambda, the above API is simply unnecessary. And C++ lambda
2760         based one is better since the above API needs casting data to and from void*.
2761
2762         * wtf/Function.h:
2763         Avoid ambiguity.
2764         * wtf/ParallelJobsGeneric.cpp:
2765         (WTF::ParallelEnvironment::ThreadPrivate::tryLockFor):
2766         (WTF::ParallelEnvironment::ThreadPrivate::workerThread): Deleted.
2767         * wtf/ParallelJobsGeneric.h:
2768         * wtf/Threading.cpp:
2769         * wtf/ThreadingWin.cpp:
2770         (WTF::createThread):
2771
2772 2017-06-25  Yusuke Suzuki  <utatane.tea@gmail.com>
2773
2774         initializeThreading() [first] causes WTFCrash due to maxSingleAllocationSize not being initialized
2775         https://bugs.webkit.org/show_bug.cgi?id=173720
2776
2777         Reviewed by Mark Lam.
2778
2779         When using std::numeric_limits<size_t>::max() for global variable's initialization,
2780         it seems that it invokes static constructor to initialize this in VC++.
2781         We avoid this edge case by introducing a workaround using SIZE_MAX here.
2782
2783         When I perform git-grep, there is only one site (this) using std::numeric_limits<>::xxx()
2784         to initialize global variable.
2785
2786         * wtf/FastMalloc.cpp:
2787
2788 2017-06-25  Konstantin Tokarev  <annulen@yandex.ru>
2789
2790         Remove excessive headers from JavaScriptCore
2791         https://bugs.webkit.org/show_bug.cgi?id=173812
2792
2793         Reviewed by Darin Adler.
2794
2795         * wtf/Bag.h:
2796
2797 2017-06-23  Keith Miller  <keith_miller@apple.com>
2798
2799         Switch VMTraps to use halt instructions rather than breakpoint instructions
2800         https://bugs.webkit.org/show_bug.cgi?id=173677
2801         <rdar://problem/32178892>
2802
2803         Reviewed by JF Bastien.
2804
2805         Remove the Trap signal handler code since it plays badly with lldb and combine
2806         SIGBUS with SIGSEGV since distiguishing them is generally non-portable.
2807
2808         Also, update the platform code to only use signaling VMTraps
2809         on where we have an appropriate instruction (x86 and ARM64).
2810
2811         * wtf/Platform.h:
2812         * wtf/threads/Signals.cpp:
2813         (WTF::fromMachException):
2814         (WTF::toMachMask):
2815         (WTF::installSignalHandler):
2816         (WTF::jscSignalHandler):
2817         * wtf/threads/Signals.h:
2818         (WTF::toSystemSignal):
2819         (WTF::fromSystemSignal):
2820
2821 2017-06-23  Antti Koivisto  <antti@apple.com>
2822
2823         Add notifyutil registrations for going in and out of simulated low memory state
2824         https://bugs.webkit.org/show_bug.cgi?id=173797
2825
2826         Reviewed by Andreas Kling.
2827
2828         Add
2829
2830         notifyutil -p org.WebKit.lowMemory.begin
2831         notifyutil -p org.WebKit.lowMemory.end
2832
2833         for debugging.
2834
2835         * wtf/cocoa/MemoryPressureHandlerCocoa.mm:
2836         (WTF::MemoryPressureHandler::install):
2837
2838 2017-06-23  Konstantin Tokarev  <annulen@yandex.ru>
2839
2840         Remove more unused headers from WTF
2841         https://bugs.webkit.org/show_bug.cgi?id=173761
2842
2843         Reviewed by Yusuke Suzuki.
2844
2845         * wtf/Liveness.h:
2846         * wtf/PageAllocation.h:
2847         * wtf/ParallelJobs.h:
2848
2849 2017-06-22  Andreas Kling  <akling@apple.com>
2850
2851         Rename MemoryPressureHandler::setTabCount to setPageCount
2852         https://bugs.webkit.org/show_bug.cgi?id=173750
2853
2854         Reviewed by Daniel Bates.
2855
2856         This function is counting WebCore::Page objects (excluding utility Pages used
2857         by SVG-as-image and the web inspector) so let's name it appropriately.
2858         Not all WebKit clients have tabs.
2859
2860         * wtf/MemoryPressureHandler.cpp:
2861         (WTF::MemoryPressureHandler::setPageCount):
2862         (WTF::MemoryPressureHandler::thresholdForMemoryKill):
2863         (WTF::MemoryPressureHandler::measurementTimerFired):
2864         (WTF::MemoryPressureHandler::setTabCount): Deleted.
2865         * wtf/MemoryPressureHandler.h:
2866
2867 2017-06-21  Andreas Kling  <akling@apple.com>
2868
2869         Increase memory kill limits for WebContent processes that manage multiple tabs.
2870         https://bugs.webkit.org/show_bug.cgi?id=173674
2871
2872         Reviewed by Geoffrey Garen.
2873
2874         When opening <a target=_blank> links, we currently have to use the same WebContent
2875         process for the new tab, to support scripting the window.opener object.
2876         This means that some WebContent processes end up hosting multiple tabs, making it
2877         more likely that those processes will hit the memory limits.
2878
2879         Address this by adding some additional allowance for multi-tab processes:
2880
2881             For each additional tab, up to 4 tabs, add 1GB to the memory kill limit.
2882
2883         * wtf/MemoryPressureHandler.cpp:
2884         (WTF::thresholdForMemoryKillWithProcessState):
2885         (WTF::MemoryPressureHandler::setTabCount):
2886         (WTF::MemoryPressureHandler::thresholdForMemoryKill):
2887         (WTF::MemoryPressureHandler::measurementTimerFired):
2888         * wtf/MemoryPressureHandler.h:
2889
2890 2017-06-21  Chris Dumez  <cdumez@apple.com>
2891
2892         Allow constructing a WTF:Function from a function pointer
2893         https://bugs.webkit.org/show_bug.cgi?id=173660
2894
2895         Reviewed by Alex Christensen.
2896
2897         Allow constructing a WTF:Function from a function pointer and
2898         assigning a function pointer to a WTF:Function.
2899
2900         * wtf/Function.h:
2901
2902 2017-06-20  Simon Fraser  <simon.fraser@apple.com>
2903
2904         Remove WILL_REVEAL_EDGE_EVENTS code
2905         https://bugs.webkit.org/show_bug.cgi?id=173632
2906
2907         Reviewed by Sam Weinig, Beth Dakin.
2908
2909         Remove will-reveal-edge events, which never took off.
2910
2911         * wtf/FeatureDefines.h:
2912
2913 2017-06-20  Konstantin Tokarev  <annulen@yandex.ru>
2914
2915         Remove excessive include directives from WTF
2916         https://bugs.webkit.org/show_bug.cgi?id=173553
2917
2918         Reviewed by Saam Barati.
2919
2920         * wtf/AutomaticThread.h:
2921         * wtf/BagToHashMap.h:
2922         * wtf/CrossThreadCopier.h:
2923         * wtf/CrossThreadQueue.h:
2924         * wtf/DateMath.h:
2925         * wtf/Expected.h:
2926         * wtf/HashMap.h:
2927         * wtf/Indenter.h:
2928         * wtf/MessageQueue.h:
2929         * wtf/MetaAllocator.h:
2930         * wtf/MetaAllocatorHandle.h:
2931         * wtf/RandomNumberSeed.h:
2932         * wtf/Ref.h:
2933         * wtf/RefPtr.h:
2934         * wtf/RunLoop.h:
2935         * wtf/SchedulePair.h:
2936         * wtf/StackStats.h:
2937         * wtf/SynchronizedFixedQueue.h:
2938         * wtf/ThreadMessage.h:
2939         * wtf/Threading.cpp:
2940         * wtf/Threading.h:
2941         * wtf/ThreadingPthreads.cpp:
2942         * wtf/ThreadingWin.cpp:
2943         * wtf/WTFThreadData.h:
2944         * wtf/WorkQueue.h:
2945         * wtf/glib/GRefPtr.h:
2946         * wtf/text/AtomicStringTable.h:
2947         * wtf/text/LineBreakIteratorPoolICU.h:
2948
2949 2017-06-20  Yusuke Suzuki  <utatane.tea@gmail.com>
2950
2951         [WTF] Enable WTF::Signals only when HAVE(MACHINE_CONTEXT) is true
2952         https://bugs.webkit.org/show_bug.cgi?id=173590
2953
2954         Reviewed by Carlos Garcia Campos.
2955
2956         WTF::Signals require a feature rewriting a value of a machine context.
2957         This is only available under HAVE(MACHINE_CONTEXT).
2958         This patch disables WTF::Signals on !HAVE(MACHINE_CONTEXT) environments.
2959
2960         * wtf/threads/Signals.cpp:
2961         * wtf/threads/Signals.h:
2962
2963 2017-06-20  Yusuke Suzuki  <utatane.tea@gmail.com>
2964
2965         [WTF] Rebaseline std::optional
2966         https://bugs.webkit.org/show_bug.cgi?id=173582
2967
2968         Reviewed by JF Bastien.
2969
2970         Update the copy of our std::optional to the latest version.
2971         It adds std::optional::has_value() and std::optional::reset().
2972
2973         * wtf/Optional.h:
2974
2975 2017-06-18  Yusuke Suzuki  <utatane.tea@gmail.com>
2976
2977         [WTF] Include execinfo.h and dlfcn.h based on platform defines
2978         https://bugs.webkit.org/show_bug.cgi?id=173531
2979
2980         Reviewed by Alex Christensen.
2981
2982         execinfo.h and dlfcn.h can be missing in some libc libraries.
2983         When including it, we should honor platform defines like HAVE(DLADDR).
2984
2985         * wtf/StackTrace.cpp:
2986
2987 2017-06-18  Darin Adler  <darin@apple.com>
2988
2989         Fix Ref to deref before assignment, add tests for this to RefPtr, Ref, Function
2990         https://bugs.webkit.org/show_bug.cgi?id=173526
2991
2992         Reviewed by Sam Weinig.
2993
2994         * wtf/Ref.h: Changed operator= to not be defined inside the class definition.
2995         Added swap functions. Changed operator= implementations to use swap in the
2996         conventional manner, the same way that RefPtr does.
2997
2998 2017-06-18  Chris Dumez  <cdumez@apple.com>
2999
3000         Use WTF::Function instead of std::function in WTF/
3001         https://bugs.webkit.org/show_bug.cgi?id=173519
3002
3003         Reviewed by Sam Weinig.
3004
3005         Use WTF::Function instead of std::function in WTF/ to avoid
3006         copying.
3007
3008         * wtf/Brigand.h:
3009         * wtf/Condition.h:
3010         * wtf/Expected.h:
3011         * wtf/FunctionDispatcher.h:
3012         * wtf/MainThread.h:
3013         * wtf/MemoryPressureHandler.h:
3014         (WTF::MemoryPressureHandler::setMemoryKillCallback):
3015         (WTF::MemoryPressureHandler::setMemoryPressureStatusChangedCallback):
3016         (WTF::MemoryPressureHandler::setDidExceedInactiveLimitWhileActiveCallback):
3017         * wtf/Optional.h:
3018         * wtf/ParkingLot.h:
3019         * wtf/RefCounter.h:
3020         (WTF::RefCounter<T>::RefCounter):
3021         * wtf/WorkQueue.h:
3022         * wtf/linux/MemoryPressureHandlerLinux.cpp:
3023         (WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
3024         * wtf/text/WTFString.cpp:
3025         (WTF::String::split):
3026         * wtf/text/WTFString.h:
3027
3028 2017-06-16  Alex Christensen  <achristensen@webkit.org>
3029
3030         Fix Mac CMake build.
3031
3032         * wtf/PlatformMac.cmake:
3033         Generate MachExceptionsServer.h
3034
3035 2017-06-16  Wenson Hsieh  <wenson_hsieh@apple.com>
3036
3037         [iOS DnD] Upstream iOS drag and drop implementation into OpenSource WebKit
3038         https://bugs.webkit.org/show_bug.cgi?id=173366
3039         <rdar://problem/32767014>
3040
3041         Reviewed by Tim Horton.
3042
3043         Define ENABLE_DRAG_SUPPORT as 1 by default and 0 for iOS, and define ENABLE_DATA_INTERACTION as 0 by default.
3044         These are overridden to both be 1 for iOS 11+ in the FeatureDefines.xcconfig within each individual project.
3045
3046         * wtf/Platform.h:
3047
3048 2017-06-15  Chris Dumez  <cdumez@apple.com>
3049
3050         Fix typo in XPCSPI.h
3051         https://bugs.webkit.org/show_bug.cgi?id=173426
3052
3053         Reviewed by Alex Christensen.
3054
3055         We should check if xpc_release is defined before defining it,
3056         not xpc_retain.
3057
3058         * wtf/spi/darwin/XPCSPI.h:
3059
3060 2017-06-15  Konstantin Tokarev  <annulen@yandex.ru>
3061
3062         Implement FALLTHROUGH macro for compilers other than Clang
3063         https://bugs.webkit.org/show_bug.cgi?id=173385
3064
3065         Reviewed by Alex Christensen.
3066
3067         FALLTHROUGH should be able to use [[gnu::fallthrough]] attribute of
3068         GCC, and [[fallthrough]] from C++17, whichever is available.
3069
3070         * wtf/Compiler.h:
3071
3072 2017-06-14  Nael Ouedraogo  <nael.ouedraogo@crf.canon.fr>
3073
3074         MediaSource duration attribute should not be equal to Infinity when set to a value greater than 2^64
3075         https://bugs.webkit.org/show_bug.cgi?id=171668
3076
3077         Reviewed by Jer Noble.
3078
3079         MediaSource duration attribute is a double represented in MediaSource by a MediaTime instance created with
3080         MediaTime::CreateWithDouble(). This method implements an overflow control mechanism which sets MediaTime to
3081         Infinity when the double value passed as argument is greater than 2^64.
3082
3083         This patch removes the overflow control mechanism when time value is represented as a double. This patch also
3084         modifies the behavior of mathematical operations between a double MediaTime and rational MediaTime: the rational
3085         MediaTime is converted to a double before applying the operation. Double MediaTime precision is the same as for
3086         double. Overflow mechanisms still apply to the conversion of a double MediaTime to rational with setTimescale()
3087         method. No behavior change for rational MediaTime.
3088
3089         * wtf/MediaTime.cpp:
3090         (WTF::MediaTime::createWithFloat):
3091         (WTF::MediaTime::createWithDouble):
3092         (WTF::MediaTime::operator+):
3093         (WTF::MediaTime::operator-):
3094
3095 2017-06-13  Zan Dobersek  <zdobersek@igalia.com>
3096
3097         [GTK][WPE] Use CMAKE_THREAD_LIBS_INIT in WTF platform CMake files
3098         https://bugs.webkit.org/show_bug.cgi?id=173310
3099
3100         Reviewed by Xabier Rodriguez-Calvar.
3101
3102         In the WTF platform CMake files for the GTK+ and WPE ports, use the
3103         CMAKE_THREAD_LIBS_INIT variable to specify the threading library we
3104         should be linking against. On some platforms this variable will be
3105         empty because the given compiler will automatically handle the -pthread
3106         compiler flag and sort out linking on its own.
3107
3108         The same approach is already used for the JSCOnly configuration.
3109
3110         * wtf/PlatformGTK.cmake:
3111         * wtf/PlatformWPE.cmake:
3112
3113 2017-06-13  Youenn Fablet  <youenn@apple.com>
3114
3115         Filter SDP from ICE candidates in case of local ICE candidate filtering
3116         https://bugs.webkit.org/show_bug.cgi?id=173120
3117
3118         Reviewed by Eric Carlson.
3119
3120         Adding split helper routine with functor parameter.
3121
3122         * wtf/text/WTFString.cpp:
3123         (WTF::String::split):
3124         * wtf/text/WTFString.h:
3125         (WTF::String::contains):
3126
3127 2017-06-13  Don Olmstead  <don.olmstead@sony.com>
3128
3129         [WTF] Remove redundant includes in config.h
3130         https://bugs.webkit.org/show_bug.cgi?id=173292
3131
3132         Reviewed by Alex Christensen.
3133
3134         * config.h:
3135         * wtf/ExportMacros.h:
3136
3137 2017-06-12  Jer Noble  <jer.noble@apple.com>
3138
3139         Screen sleeps while doing WebRTC video
3140         https://bugs.webkit.org/show_bug.cgi?id=173278
3141
3142         Reviewed by Eric Carlson.
3143
3144         Drive-by fix: add some generic methods for iterating over collections.
3145
3146         * WTF.xcodeproj/project.pbxproj:
3147         * wtf/Algorithms.h: Added.
3148         (WTF::forEach):
3149         (WTF::anyOf):
3150         (WTF::allOf):
3151
3152 2017-06-12  Carlos Garcia Campos  <cgarcia@igalia.com>
3153
3154         [GTK] Move WebKit GType macros to WTF
3155         https://bugs.webkit.org/show_bug.cgi?id=173249
3156
3157         Reviewed by Žan Doberšek.
3158
3159         They can be used by glib-based ports and eventually by JavaScriptCore glib bindings too.
3160
3161         * wtf/glib/WTFGType.h: Copied from Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h.
3162
3163 2017-06-11  Yusuke Suzuki  <utatane.tea@gmail.com>
3164
3165         [WTF] Make ThreadMessage portable
3166         https://bugs.webkit.org/show_bug.cgi?id=172073
3167
3168         Reviewed by Keith Miller.
3169
3170         Recently, we change ThreadMessage semantics: message handler
3171         can be executed in the sender thread.
3172         This allows ThreadMessage to be implemented in a portable way.
3173
3174         This patch implements ThreadMessage for all the platforms.
3175         We use platform-independent Thread APIs, suspend(), resume(),
3176         and getRegisters().
3177
3178         * wtf/PlatformRegisters.h:
3179         (WTF::registersFromUContext):
3180         * wtf/ThreadMessage.cpp:
3181         (WTF::sendMessageScoped):
3182         (WTF::ThreadMessageData::ThreadMessageData): Deleted.
3183         (): Deleted.
3184         (WTF::initializeThreadMessages): Deleted.
3185         (WTF::sendMessageUsingSignal): Deleted.
3186         (WTF::sendMessageUsingMach): Deleted.
3187         (WTF::deliverMessagesUsingMach): Deleted.
3188         * wtf/ThreadMessage.h:
3189         * wtf/Threading.cpp:
3190         (WTF::initializeThreading):
3191         * wtf/Threading.h:
3192         (WTF::Thread::threadMessages): Deleted.
3193         * wtf/ThreadingPthreads.cpp:
3194         (WTF::Thread::signalHandlerSuspendResume):
3195         (WTF::threadStateMetadata):
3196         (WTF::Thread::getRegisters):
3197         * wtf/threads/Signals.cpp:
3198         (WTF::handleSignalsWithMach):
3199
3200 2017-06-11  Yusuke Suzuki  <utatane.tea@gmail.com>
3201
3202         [WTF] Drop unnecessary includes in Threading.h
3203         https://bugs.webkit.org/show_bug.cgi?id=173167
3204
3205         Reviewed by Darin Adler.
3206
3207         Threading.h includes bunch of headers. But some of them are not necessary.
3208         This patch cleans up it a bit.
3209
3210         * wtf/Assertions.cpp:
3211         * wtf/LocklessBag.h:
3212         * wtf/Threading.h:
3213         * wtf/ThreadingPrimitives.h:
3214
3215 2017-06-10  Yusuke Suzuki  <utatane.tea@gmail.com>
3216
3217         [WTF] Add RegisteredSymbolImpl
3218         https://bugs.webkit.org/show_bug.cgi?id=173230
3219
3220         Reviewed by Mark Lam.
3221
3222         Most symbols are not registered in SymbolRegistry. However, we currently always
3223         allocate a pointer member to point to a SymbolRegistry, and this pointer is always null.
3224         SymbolImpl is immutable, and it will never be registered with a SymbolRegistry
3225         after it is created. Hence, this member is wasteful.
3226
3227         Instead, we add a new derived class RegisteredSymbolImpl, which will set a flag in
3228         SymbolImpl to indicate that it is registered with a SymbolRegistry. The only way to
3229         create a RegisteredSymbolImpl is via a factory method provided by the SymbolRegistry.
3230         The factory method will pass the SymbolRegistry this pointer to the RegisteredSymbolImpl's
3231         constructor for initializing the RegisteredSymbolImpl's m_symbolRegistry field.
3232         By doing so,
3233
3234         1. We do not need to set m_symbolRegistry after creating a Symbol. It is clean.
3235         2. We reduce the size of SymbolImpls that do not need to be registered.
3236
3237         * wtf/text/StringImpl.cpp:
3238         (WTF::StringImpl::~StringImpl):
3239         * wtf/text/StringImpl.h:
3240         * wtf/text/SymbolImpl.cpp:
3241         (WTF::SymbolImpl::create):
3242         (WTF::RegisteredSymbolImpl::create):
3243         * wtf/text/SymbolImpl.h:
3244         (WTF::SymbolImpl::hashForSymbol):
3245         (WTF::SymbolImpl::isRegistered):
3246         (WTF::SymbolImpl::SymbolImpl):
3247         (WTF::RegisteredSymbolImpl::symbolRegistry):
3248         (WTF::RegisteredSymbolImpl::clearSymbolRegistry):
3249         (WTF::RegisteredSymbolImpl::RegisteredSymbolImpl):
3250         (WTF::SymbolImpl::symbolRegistry):
3251         * wtf/text/SymbolRegistry.cpp:
3252         (WTF::SymbolRegistry::~SymbolRegistry):
3253         (WTF::SymbolRegistry::symbolForKey):
3254         (WTF::SymbolRegistry::keyForSymbol):
3255         (WTF::SymbolRegistry::remove):
3256         * wtf/text/SymbolRegistry.h:
3257
3258 2017-06-10  Dan Bernstein  <mitz@apple.com>
3259
3260         Reverted r218056 because it made the IDE reindex constantly.
3261
3262         * Configurations/DebugRelease.xcconfig:
3263
3264 2017-06-10  Dan Bernstein  <mitz@apple.com>
3265
3266         [Xcode] With Xcode 9 developer beta, everything rebuilds when switching between command-line and IDE
3267         https://bugs.webkit.org/show_bug.cgi?id=173223
3268
3269         Reviewed by Sam Weinig.
3270
3271         The rebuilds were happening due to a difference in the compiler options that the IDE and
3272         xcodebuild were specifying. Only the IDE was passing the -index-store-path option. To make
3273         xcodebuild pass that option, too, set CLANG_INDEX_STORE_ENABLE to YES if it is unset, and
3274         specify an appropriate path in CLANG_INDEX_STORE_PATH.
3275
3276         * Configurations/DebugRelease.xcconfig:
3277
3278 2017-06-09  Chris Dumez  <cdumez@apple.com>
3279
3280         Update Thread::create() to take in a WTF::Function instead of a std::function
3281         https://bugs.webkit.org/show_bug.cgi?id=173175
3282
3283         Reviewed by Mark Lam.
3284
3285         Update Thread::create() to take in a WTF::Function instead of a std::function. Unlike
3286         std::function, WTF:Function is not copyable and does not make implicit copies of captured
3287         variables. Doing captures such as [string = string.isolatedCopy()] when passing an
3288         std::function to another thread has lead to bugs in the past due to implicit copying of
3289         the captured string.
3290
3291         * wtf/Threading.cpp:
3292         (WTF::Thread::create):
3293         * wtf/Threading.h:
3294
3295 2017-06-09  Chris Dumez  <cdumez@apple.com>
3296
3297         Update WorkQueue::concurrentApply() to take a WTF::Function instead of an std::function
3298         https://bugs.webkit.org/show_bug.cgi?id=173165
3299
3300         Reviewed by Saam Barati.
3301
3302         Update WorkQueue::concurrentApply() to take a WTF::Function instead of an std::function
3303         as std::function has issues with regards to thread safety.
3304
3305         * wtf/WorkQueue.h:
3306         * wtf/cocoa/WorkQueueCocoa.cpp:
3307         (WTF::WorkQueue::concurrentApply):
3308
3309 2017-06-08  Xabier Rodriguez Calvar  <calvaris@igalia.com>
3310
3311         MediaTime class has rounding issues in different platforms
3312         https://bugs.webkit.org/show_bug.cgi?id=172640
3313
3314         Reviewed by Jer Noble.
3315
3316         The way a timescale is set when creating a MediaTime from a double
3317         can create rounding issues in different platforms because in some
3318         rounding is made and in others, it truncates. This way we ensure a
3319         common behavior.
3320
3321         Dumping MediaTimes is also confusing and by the output you don't
3322         know if it's containing a double or a fraction. Now, if it
3323         contains a double, it only prints the double because printing the
3324         fraction is misleading (it currently prints the double read as an
3325         integer) and if it contains a fraction it shows the fraction and
3326         its double representation separated by an = instead of a ,.
3327
3328         * wtf/MediaTime.cpp:
3329         (WTF::MediaTime::createWithDouble): When creating MediaTime from
3330         double, we round instead of leaving it to the cast operation.
3331         (WTF::MediaTime::dump):
3332
3333 2017-06-07  Jer Noble  <jer.noble@apple.com>
3334
3335         Refactoring: MediaEngineSupportParameters should take a ContentType rather than separate type & codecs strings
3336         https://bugs.webkit.org/show_bug.cgi?id=173038
3337
3338         Reviewed by Eric Carlson.
3339
3340         Drive by fix: add a version of split that takes a UChar and returns a Vector<String>.
3341
3342         * wtf/text/WTFString.h:
3343         (WTF::String::split):
3344
3345 2017-06-07  Zan Dobersek  <zdobersek@igalia.com>
3346
3347         [GCrypt] RSA-PSS support
3348         https://bugs.webkit.org/show_bug.cgi?id=172856
3349
3350         Reviewed by Jiewen Tan.
3351
3352         * wtf/Platform.h: Define HAVE_RSA_PSS to 1 for USE(GCRYPT). Support for RSA-PSS
3353         is provided by default through the libgcrypt library.
3354
3355 2017-06-06  Chris Dumez  <cdumez@apple.com>
3356
3357         Unreviewed, rolling out r214974.
3358
3359         Causes some tabs to start using a huge amount of CPU after 8
3360         minutes in the background
3361
3362         Reverted changeset:
3363
3364         "Make inactive web processes behave as though under memory
3365         pressure."
3366         https://bugs.webkit.org/show_bug.cgi?id=170042
3367         http://trac.webkit.org/changeset/214974
3368
3369 2017-06-06  Don Olmstead  <don.olmstead@am.sony.com>
3370
3371         [WebCore] Enable REQUEST_ANIMATION_FRAME_TIMER for all ports
3372         https://bugs.webkit.org/show_bug.cgi?id=172780
3373
3374         Reviewed by Alex Christensen.
3375
3376         * wtf/Platform.h:
3377
3378 2017-06-06  Darin Adler  <darin@apple.com>
3379
3380         Cut down use of WTF_ARRAY_LENGTH
3381         https://bugs.webkit.org/show_bug.cgi?id=172997
3382
3383         Reviewed by Chris Dumez.
3384
3385         * wtf/DateMath.cpp:
3386         (WTF::equalLettersIgnoringASCIICase): Added helper function template.
3387         (WTF::parseDateFromNullTerminatedCharacters): Use a modern for loop instead of
3388         WTF_ARRAY_LENGTH. Use startsWithLettersIgnoringASCIICase and
3389         equalLettersIgnoringASCIICase instead of strncasecmp.
3390
3391         * wtf/text/IntegerToStringConversion.h:
3392         (WTF::numberToStringImpl): Use std::end instead of WTF_ARRAY_LENGTH.
3393         (WTF::writeNumberToBufferImpl): Ditto.
3394
3395 2017-06-06  Filip Pizlo  <fpizlo@apple.com>
3396
3397         index out of bound in bytecodebasicblock
3398         https://bugs.webkit.org/show_bug.cgi?id=172963
3399
3400         Reviewed by Saam Barati and Mark Lam.
3401
3402         * wtf/Assertions.h:
3403         (UNREACHABLE_FOR_PLATFORM):
3404
3405 2017-06-05  Jer Noble  <jer.noble@apple.com>
3406
3407         Allow clients to specify a list of codecs which should require hardware decode support.
3408         https://bugs.webkit.org/show_bug.cgi?id=172787
3409
3410         Reviewed by Alex Christensen.
3411
3412         Add a couple of convenience methods:
3413         - a String::split() that returns a vector (rather than taking an out-reference to a vector).
3414         - A Vector::map() template which takes a Callable and returns a Vector of a different type.
3415
3416         * wtf/Vector.h:
3417         (WTF::Vector::map):
3418         * wtf/text/WTFString.h:
3419         (WTF::String::split):
3420
3421 2017-06-04  Konstantin Tokarev  <annulen@yandex.ru>
3422
3423         Fix build of Windows-specific code with ICU 59.1
3424         https://bugs.webkit.org/show_bug.cgi?id=172729
3425
3426         Reviewed by Darin Adler.
3427
3428         * wtf/text/win/WCharStringExtras.h: Added new header file wuth helper
3429         functions for conversion between WTF::String and wchart_t*.
3430         (WTF::stringToNullTerminatedWChar):
3431         (WTF::wcharToString):
3432         (WTF::nullTerminatedWCharToString):
3433
3434 2017-06-02  Stephan Szabo  <stephan.szabo@am.sony.com>
3435
3436         [JSCOnly] Build static jsc.exe on Windows
3437         https://bugs.webkit.org/show_bug.cgi?id=172833
3438
3439         Reviewed by Konstantin Tokarev.
3440
3441         * wtf/PlatformJSCOnly.cmake:
3442
3443 2017-06-02  Simon Fraser  <simon.fraser@apple.com>
3444
3445         Get <chrono> out of StdLibExtras.h
3446         https://bugs.webkit.org/show_bug.cgi?id=172744
3447
3448         Reviewed by Zalan Bujtas.
3449
3450         We hates std::chrono. Don't include it everywhere to discourage use.
3451
3452         * wtf/StdLibExtras.h:
3453
3454 2017-06-02  Filip Pizlo  <fpizlo@apple.com>
3455
3456         Atomics.load and Atomics.store need to be fully fenced
3457         https://bugs.webkit.org/show_bug.cgi?id=172844
3458
3459         Reviewed by Keith Miller.
3460         
3461         Add loadFullyFenced and storeFullyFenced to Atomic<>.
3462
3463         * wtf/Atomics.h:
3464         (WTF::Atomic::loadFullyFenced):
3465         (WTF::Atomic::storeRelaxed):
3466         (WTF::Atomic::storeFullyFenced):
3467         (WTF::atomicLoadFullyFenced):
3468         (WTF::atomicStoreFullyFenced):
3469
3470 2017-06-01  Keith Miller  <keith_miller@apple.com>
3471
3472         Undo rollout in r217638 with bug fix
3473         https://bugs.webkit.org/show_bug.cgi?id=172824
3474
3475         Unreviewed, reland patch with unused set_state code removed.
3476
3477         * Configurations/WTF.xcconfig:
3478         * WTF.xcodeproj/project.pbxproj:
3479         * wtf/Platform.h:
3480         * wtf/PlatformRegisters.h:
3481         (WTF::registersFromUContext):
3482         * wtf/StackBounds.h:
3483         (WTF::StackBounds::StackBounds):
3484         * wtf/ThreadHolder.cpp:
3485         (WTF::ThreadHolder::~ThreadHolder):
3486         * wtf/ThreadMessage.cpp:
3487         (WTF::sendMessageUsingSignal):
3488         (WTF::sendMessageUsingMach):
3489         (WTF::deliverMessagesUsingMach):
3490         (WTF::sendMessageScoped):
3491         * wtf/ThreadMessage.h:
3492         (WTF::sendMessage):
3493         * wtf/Threading.h:
3494         (WTF::Thread::machThread):
3495         * wtf/mac/MachExceptions.defs: Copied from Source/WTF/wtf/ThreadMessage.h.
3496         * wtf/threads/Signals.cpp:
3497         (WTF::startMachExceptionHandlerThread):
3498         (WTF::fromMachException):
3499         (WTF::toMachMask):
3500         (WTF::handleSignalsWithMach):
3501         (WTF::setExceptionPorts):
3502         (WTF::activeThreads):
3503         (WTF::registerThreadForMachExceptionHandling):
3504         (WTF::unregisterThreadForMachExceptionHandling):
3505         (WTF::installSignalHandler):
3506         (WTF::jscSignalHandler):
3507         * wtf/threads/Signals.h:
3508
3509 2017-05-31  Commit Queue  <commit-queue@webkit.org>
3510
3511         Unreviewed, rolling out r217611 and r217631.
3512         https://bugs.webkit.org/show_bug.cgi?id=172785
3513
3514         "caused wasm-hashset-many.html to become flaky." (Requested by
3515         keith_miller on #webkit).
3516
3517         Reverted changesets:
3518
3519         "Reland r216808, underlying lldb bug has been fixed."
3520         https://bugs.webkit.org/show_bug.cgi?id=172759
3521         http://trac.webkit.org/changeset/217611
3522
3523         "Use dispatch queues for mach exceptions"
3524         https://bugs.webkit.org/show_bug.cgi?id=172775
3525         http://trac.webkit.org/changeset/217631
3526
3527 2017-05-31  Keith Miller  <keith_miller@apple.com>
3528
3529         Use dispatch queues for mach exceptions
3530         https://bugs.webkit.org/show_bug.cgi?id=172775
3531
3532         Reviewed by Geoffrey Garen.
3533
3534         This patch adds support for using a dispatch queue to handle our
3535         mach exceptions. We use a high priority concurrent dispatch queue
3536         to handle our mach exceptions. We don't know the priority of the
3537         thread whose exception we are handling so the most conservative
3538         answer is to respond with a high priority. These events are both
3539         rare and usually quite fast so it is likely not a significant cost
3540         when the thread with an exception has a low priority.
3541
3542         * wtf/threads/Signals.cpp:
3543         (WTF::startMachExceptionHandlerThread):
3544
3545 2017-05-31  Keith Miller  <keith_miller@apple.com>
3546
3547         Reland r216808, underlying lldb bug has been fixed.
3548         https://bugs.webkit.org/show_bug.cgi?id=172759
3549
3550         Unreviewed, relanding old patch. See: rdar://problem/31183352
3551
3552         * Configurations/WTF.xcconfig:
3553         * WTF.xcodeproj/project.pbxproj:
3554         * wtf/Platform.h:
3555         * wtf/PlatformRegisters.h:
3556         (WTF::registersFromUContext):
3557         * wtf/StackBounds.h:
3558         (WTF::StackBounds::StackBounds):
3559         * wtf/ThreadHolder.cpp:
3560         (WTF::ThreadHolder::~ThreadHolder):
3561         * wtf/ThreadMessage.cpp:
3562         (WTF::sendMessageUsingSignal):
3563         (WTF::sendMessageUsingMach):
3564         (WTF::deliverMessagesUsingMach):
3565         (WTF::sendMessageScoped):
3566         * wtf/ThreadMessage.h:
3567