Allow WTF::map to use any class that is iterable and has a size getter
[WebKit-https.git] / Source / WTF / ChangeLog
1 2017-09-19  Youenn Fablet  <youenn@apple.com>
2
3         Allow WTF::map to use any class that is iterable and has a size getter
4         https://bugs.webkit.org/show_bug.cgi?id=177026
5
6         Reviewed by Darin Adler.
7
8         Computing the Item type given to the lambda using the iterator instead of ValueType which is specific to Vector.
9         Adding the possibility to pass a non const container reference and a lambda taking non const references as well. 
10
11         * wtf/Vector.h:
12         (WTF::MapFunctionInspector::acceptsReference):
13         (WTF::Mapper::map):
14         (WTF::map):
15
16 2017-09-19  Jer Noble  <jer.noble@apple.com>
17
18         [Cocoa] Add an ImageDecoder subclass backed by AVFoundation
19         https://bugs.webkit.org/show_bug.cgi?id=176825
20
21         Reviewed by Eric Carlson.
22
23         * wtf/Platform.h:
24
25 2017-09-18  Andy Estes  <aestes@apple.com>
26
27         [Cocoa] Upstream sandbox-related WebKitSystemInterface functions
28         https://bugs.webkit.org/show_bug.cgi?id=177047
29
30         Reviewed by Daniel Bates.
31
32         * wtf/spi/darwin/SandboxSPI.h:
33
34 2017-09-18  Ryan Haddad  <ryanhaddad@apple.com>
35
36         Unreviewed, rolling out r222170.
37
38         The API test added with this change is failing.
39
40         Reverted changeset:
41
42         "Allow WTF::map to use any class that is iterable and has a
43         size getter"
44         https://bugs.webkit.org/show_bug.cgi?id=177026
45         http://trac.webkit.org/changeset/222170
46
47 2017-09-18  Youenn Fablet  <youenn@apple.com>
48
49         Allow WTF::map to use any class that is iterable and has a size getter
50         https://bugs.webkit.org/show_bug.cgi?id=177026
51
52         Reviewed by Darin Adler.
53
54         Computing the Item type given to the lambda using the iterator instead of ValueType which is specific to Vector.
55         Adding the possibility to pass a non const container reference and a lambda taking non const references as well. 
56
57         * wtf/Vector.h:
58         (WTF::MapFunctionInspector::acceptsReference):
59         (WTF::Mapper::map):
60         (WTF::map):
61
62 2017-09-15  JF Bastien  <jfbastien@apple.com>
63
64         WTF: use Forward.h when appropriate instead of Vector.h
65         https://bugs.webkit.org/show_bug.cgi?id=176984
66
67         Reviewed by Saam Barati.
68
69         There's no need to include Vector.h when Forward.h will suffice. All we need is to move the template default parameters from Vector, and then the forward declaration can be used in so many new places: if a header only takes Vector by reference, rvalue reference, pointer, returns any of these, or has them as members then the header doesn't need to see the definition because the declaration will suffice.
70
71         * wtf/Forward.h:
72         * wtf/Vector.h:
73         * wtf/text/StringVector.h:
74
75 2017-09-15  Keith Miller  <keith_miller@apple.com>
76
77         generate-unified-source-bundles.rb shouldn't write a file that isn't going to change
78         https://bugs.webkit.org/show_bug.cgi?id=177021
79
80         Reviewed by Tim Horton.
81
82         * generate-unified-source-bundles.rb:
83
84 2017-09-14  Saam Barati  <sbarati@apple.com>
85
86         We should have a way of preventing a caller from making a tail call and we should use it for ProxyObject instead of using build flags
87         https://bugs.webkit.org/show_bug.cgi?id=176863
88
89         Reviewed by Keith Miller.
90
91         This patch adds a way for a particular function to mark
92         that none of its calls should be tail calls.
93         
94         It's useful in the following example if you don't want foo
95         to do a tail call to bar or baz:
96         
97         int foo(bool b)
98         {
99             NO_TAIL_CALLS();
100             if (b)
101                 return baz();
102             return bar();
103         }
104         
105         Note that we're not saying that bar/baz should not be tail callable. bar/baz
106         may have other callers that are allowed to tail call it. This macro just says
107         that foo itself will not perform any tail calls.
108
109         * WTF.xcodeproj/project.pbxproj:
110         * wtf/NoTailCalls.h: Added.
111         (WTF::NoTailCalls::~NoTailCalls):
112
113 2017-09-14  Mark Lam  <mark.lam@apple.com>
114
115         AddressSanitizer: stack-buffer-underflow in JSC::Probe::Page::Page
116         https://bugs.webkit.org/show_bug.cgi?id=176874
117         <rdar://problem/34436415>
118
119         Reviewed by Saam Barati.
120
121         Added a convenience version of roundUpToMultipleOf() so that it can be applied to
122         pointers without the client having to cast explicitly.
123
124         * wtf/StdLibExtras.h:
125         (WTF::roundUpToMultipleOf):
126
127 2017-09-14  Youenn Fablet  <youenn@apple.com>
128
129         Allow WTF::map to take function as parameter
130         https://bugs.webkit.org/show_bug.cgi?id=176909
131
132         Reviewed by Jer Noble.
133
134         * wtf/Vector.h:
135         (WTF::map):
136
137 2017-09-13  Youenn Fablet  <youenn@apple.com>
138
139         Add a lambda-based map for Vectors
140         https://bugs.webkit.org/show_bug.cgi?id=176487
141
142         Reviewed by Darin Adler.
143
144         This helper routine allows refactoring the reserveInitialCapacity/uncheckedAppend pattern, the mapper between source and destination item being a lambda.
145
146         * wtf/Vector.h:
147         (WTF::Mapper::transform):
148         (WTF::Mapper::map):
149         (WTF::map):
150
151 2017-09-12  Yusuke Suzuki  <utatane.tea@gmail.com>
152
153         [DFG] Optimize WeakMap::get by adding intrinsic and fixup
154         https://bugs.webkit.org/show_bug.cgi?id=176010
155
156         Reviewed by Filip Pizlo.
157
158         Add inlineGet method with HashTranslator.
159
160         * wtf/HashMap.h:
161         (WTF::X>::inlineGet const):
162         (WTF::MappedTraits>::inlineGet const):
163         (WTF::MappedTraits>::fastGet const): Deleted.
164         * wtf/LoggingHashMap.h:
165
166 2017-09-12  Keith Miller  <keith_miller@apple.com>
167
168         Do unified source builds for JSC
169         https://bugs.webkit.org/show_bug.cgi?id=176076
170
171         Reviewed by Geoffrey Garen.
172
173         This patch adds a script that will automatically bundle source
174         files, which is currently only used by the CMake build. It's
175         important that we use the same script to generate the bundles
176         for the CMake build as the Xcode build. If we didn't do this then
177         it's likely that there would be build errors that occur in only
178         one build system. On the same note, we also need to be careful to
179         not bundle platform specific source files with platform
180         independent ones. There are a couple of things the script does not
181         currently handle but are not essential for the CMake build. First,
182         it does not handle the max bundle size restrictions that the Xcode
183         build will require. It also does not handle C files.
184
185         The unified source generator script works by collecting groups of
186         up to 8 files from the same directory. We don't bundle files from
187         across directories since I didn't see a speedup from doing
188         so. Additionally, splitting at the directory boundary means that
189         it is less likely that adding a new file will force a "clean"
190         build. This would happen because the new file will shift every
191         subsequent file into the next unified source bundle.
192
193         Using unified sources appears to be a roughly 3.5x build time
194         speed up for clean builds on my MBP and appears to have a
195         negligible effect in incremental builds.
196
197         * generate-unified-source-bundles.rb: Added.
198         * wtf/Assertions.h:
199
200 2017-09-12  Joseph Pecoraro  <pecoraro@apple.com>
201
202         QualifiedName::init should assume AtomicStrings::init was already called
203         https://bugs.webkit.org/show_bug.cgi?id=176639
204
205         Reviewed by Sam Weinig.
206
207         * wtf/NeverDestroyed.h:
208         (WTF::LazyNeverDestroyed::isConstructed const):
209
210 2017-09-12  Brent Fulgham  <bfulgham@apple.com>
211
212         Show punycode to user if a URL mixes Armenian Seh or Vo with other scripts
213         https://bugs.webkit.org/show_bug.cgi?id=176578
214         <rdar://problem/33906231>
215
216         Reviewed by Alex Christensen.
217
218         * wtf/ASCIICType.h:
219         (WTF::isASCIIDigitOrPunctuation): Added helper function to recognize ASCII digits
220         and punctuation characters.
221
222 2017-09-12  Sam Weinig  <sam@webkit.org>
223
224         [Cleanup] Follow up cleanup for DOMFormData implementation
225         https://bugs.webkit.org/show_bug.cgi?id=176740
226
227         Reviewed by Alex Christensen.
228
229         * WTF.xcodeproj/project.pbxproj:
230         * wtf/HashTraits.h:
231         (WTF::KeyValuePair::KeyValuePair): Deleted.
232         * wtf/KeyValuePair.h: Added.
233         (WTF::KeyValuePair::KeyValuePair):
234         (WTF::makeKeyValuePair):
235
236             Move KeyValuePair to its own header and add a makeKeyValuePair helper.
237
238 2017-09-11  Ryan Haddad  <ryanhaddad@apple.com>
239
240         Unreviewed, rolling out r221854.
241
242         The test added with this change fails on 32-bit JSC bots.
243
244         Reverted changeset:
245
246         "[DFG] Optimize WeakMap::get by adding intrinsic and fixup"
247         https://bugs.webkit.org/show_bug.cgi?id=176010
248         http://trac.webkit.org/changeset/221854
249
250 2017-09-03  Yusuke Suzuki  <utatane.tea@gmail.com>
251
252         [DFG] Optimize WeakMap::get by adding intrinsic and fixup
253         https://bugs.webkit.org/show_bug.cgi?id=176010
254
255         Reviewed by Filip Pizlo.
256
257         Add inlineGet method with HashTranslator.
258
259         * wtf/HashMap.h:
260         (WTF::X>::inlineGet const):
261         (WTF::MappedTraits>::inlineGet const):
262         (WTF::MappedTraits>::fastGet const): Deleted.
263         * wtf/LoggingHashMap.h:
264
265 2017-09-07  Myles C. Maxfield  <mmaxfield@apple.com>
266
267         [PAL] Unify PlatformUserPreferredLanguages.h with Language.h
268         https://bugs.webkit.org/show_bug.cgi?id=176561
269
270         Reviewed by Brent Fulgham.
271
272         WebCore/platform/Language was the only* user of PlatformUserPreferredLanguages (with 1 exception).
273         That exception is that JavaScriptCore needed the functionality of WebCore/platform/Language, but it
274         couldn't get it because of the layering violation, so instead it erroneously called into
275         PlatformUserPreferredLanguages instead. This patch merges these two files into WTF so JSC gets the
276         right function and the PAL effort has one less file to move from WebCore/platform into PAL.
277
278         * WTF.xcodeproj/project.pbxproj:
279         * wtf/CMakeLists.txt:
280         * wtf/Language.cpp: Renamed from Source/WebCore/platform/Language.cpp.
281         (WTF::addLanguageChangeObserver):
282         (WTF::userPreferredLanguages):
283         * wtf/Language.h: Renamed from Source/WebCore/platform/Language.h.
284         * wtf/PlatformGTK.cmake:
285         * wtf/PlatformJSCOnly.cmake:
286         * wtf/PlatformMac.cmake:
287         * wtf/PlatformUserPreferredLanguages.h: Removed.
288         * wtf/PlatformWPE.cmake:
289         * wtf/PlatformWin.cmake:
290         * wtf/cf/LanguageCF.cpp: Renamed from Source/WTF/wtf/PlatformUserPreferredLanguagesMac.mm.
291         (WTF::httpStyleLanguageCode):
292         (WTF::languagePreferencesDidChange):
293         (WTF::platformUserPreferredLanguages):
294         * wtf/unix/LanguageUnix.cpp: Renamed from Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp.
295         * wtf/win/LanguageWin.cpp: Renamed from Source/WTF/wtf/PlatformUserPreferredLanguagesWin.cpp.
296
297 2017-09-06  Eric Carlson  <eric.carlson@apple.com>
298
299         Require LoggingHelper overrides to provide identifier
300         https://bugs.webkit.org/show_bug.cgi?id=176477
301
302         Reviewed by Jer Noble.
303
304         * wtf/Assertions.cpp: No more WTFLogLevelNotice.
305         * wtf/Assertions.h: Ditto.
306
307 2017-09-06  Per Arne Vollan  <pvollan@apple.com>
308
309         [Win] WebCore failed to build, InbandTextTrackPrivateAVF: base class undefined.
310         https://bugs.webkit.org/show_bug.cgi?id=176431
311
312         Reviewed by Alex Christensen.
313
314         AVFoundation header detection should be done in WebCore because of build dependencies. 
315
316         * AVFoundationSupport.py: Removed.
317         * wtf/Platform.h:
318         * wtf/PlatformWin.cmake:
319
320 2017-09-05  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
321
322         [Win] Fix the wincairo build after r221558 and r221583
323         https://bugs.webkit.org/show_bug.cgi?id=176353
324
325         Reviewed by Yusuke Suzuki.
326
327         * wtf/Assertions.cpp:
328
329 2017-09-04  Eric Carlson  <eric.carlson@apple.com>
330
331         Switch HTMLMediaElement to release logging
332         https://bugs.webkit.org/show_bug.cgi?id=176065
333
334         Reviewed by Jer Noble.
335
336         * wtf/MediaTime.cpp:
337         (WTF::MediaTime::dump const): Use toString.
338         (WTF::MediaTime::toString const): New.
339
340 2017-09-04  Yusuke Suzuki  <utatane.tea@gmail.com>
341
342         Remove OS(SOLARIS) support
343         https://bugs.webkit.org/show_bug.cgi?id=176341
344
345         Reviewed by Sam Weinig.
346
347         WebKit project does not have stake holders supporting Solaris right now.
348         And Solaris + SPARC in 64bit environment does not work well since its
349         address space includes non-48bit area. It breaks our JSVALUE64 in JSC.
350         In addition, Solaris a bit complicates our threading implementation
351         because of its special threading stack.
352
353         This patch removes OS(SOLARIS) and COMPILER(SUNCC) support from WebKit.
354
355         * wtf/Compiler.h:
356         * wtf/InlineASM.h:
357         * wtf/MathExtras.h:
358         (std::isfinite): Deleted.
359         (std::signbit): Deleted.
360         (std::isinf): Deleted.
361         * wtf/NumberOfCores.cpp:
362         (WTF::numberOfProcessorCores):
363         * wtf/Platform.h:
364         * wtf/StackBounds.cpp:
365         * wtf/ThreadingPthreads.cpp:
366
367 2017-09-04  Commit Queue  <commit-queue@webkit.org>
368
369         Unreviewed, rolling out r221494 and r221500.
370         https://bugs.webkit.org/show_bug.cgi?id=176258
371
372         This caused the windows build to fail. (Requested by mlewis13
373         on #webkit).
374
375         Reverted changesets:
376
377         "Switch HTMLMediaElement to release logging"
378         https://bugs.webkit.org/show_bug.cgi?id=176065
379         http://trac.webkit.org/changeset/221494
380
381         "Switch HTMLMediaElement to release logging"
382         https://bugs.webkit.org/show_bug.cgi?id=176065
383         http://trac.webkit.org/changeset/221500
384
385 2017-09-03  Yusuke Suzuki  <utatane.tea@gmail.com>
386
387         Remove "malloc" and "free" use
388         https://bugs.webkit.org/show_bug.cgi?id=176310
389
390         Reviewed by Darin Adler.
391
392         Use Vector instead.
393
394         * wtf/Assertions.cpp:
395
396 2017-09-04  Yusuke Suzuki  <utatane.tea@gmail.com>
397
398         Unreviewed, support libstdc++ use with clang
399         https://bugs.webkit.org/show_bug.cgi?id=176301
400
401         * wtf/FastMalloc.h:
402
403 2017-09-03  Yusuke Suzuki  <utatane.tea@gmail.com>
404
405         [WTF] Add C++03 allocator interface for GCC < 6
406         https://bugs.webkit.org/show_bug.cgi?id=176301
407
408         Reviewed by Darin Adler.
409
410         Unfortunately, std::list in GCC < 6 does not support C++11 allocator interface.
411         This patch adds C++03 allocator interface to FastAllocator to make it usable
412         for std::list. It also allows us to use FastAllocator for data structures that
413         only support C++03 interface.
414
415         * wtf/FastMalloc.h:
416         (WTF::FastAllocator::allocate):
417         (WTF::FastAllocator::construct):
418         (WTF::FastAllocator::destroy):
419         (WTF::FastAllocator::max_size const):
420         (WTF::FastAllocator::select_on_container_copy_construction const):
421
422 2017-09-03  Chris Dumez  <cdumez@apple.com>
423
424         Unreviewed, rolling out r221552.
425
426         Broke the build
427
428         Reverted changeset:
429
430         "[WTF] Add C++03 allocator interface for GCC < 6"
431         https://bugs.webkit.org/show_bug.cgi?id=176301
432         http://trac.webkit.org/changeset/221552
433
434 2017-09-03  Yusuke Suzuki  <utatane.tea@gmail.com>
435
436         [WTF] Add C++03 allocator interface for GCC < 6
437         https://bugs.webkit.org/show_bug.cgi?id=176301
438
439         Reviewed by Darin Adler.
440
441         Unfortunately, std::list in GCC < 6 does not support C++11 allocator interface.
442         This patch adds C++03 allocator interface to FastAllocator to make it usable
443         for std::list. It also allows us to use FastAllocator for data structures that
444         only support C++03 interface.
445
446         * wtf/FastMalloc.h:
447         (WTF::FastAllocator::allocate):
448         (WTF::FastAllocator::construct):
449         (WTF::FastAllocator::destroy):
450         (WTF::FastAllocator::max_size const):
451         (WTF::FastAllocator::select_on_container_copy_construction const):
452
453 2017-09-03  Sam Weinig  <sam@webkit.org>
454
455         Remove CanvasProxy
456         https://bugs.webkit.org/show_bug.cgi?id=176288
457
458         Reviewed by Yusuke Suzuki.
459
460         CanvasProxy does not appear to be in any current HTML spec
461         and was disabled and unimplemented in our tree. Time to 
462         get rid of it.
463
464         * wtf/FeatureDefines.h:
465
466 2017-09-01  Eric Carlson  <eric.carlson@apple.com>
467
468         Switch HTMLMediaElement to release logging
469         https://bugs.webkit.org/show_bug.cgi?id=176065
470
471         Reviewed by Jer Noble.
472
473         * wtf/MediaTime.cpp:
474         (WTF::MediaTime::dump const): Use toString.
475         (WTF::MediaTime::toString const): New.
476         * wtf/MediaTime.h:
477         (PAL::LogArgument<WTF::MediaTime>::toString): Logger template.
478
479 2017-08-31  Don Olmstead  <don.olmstead@sony.com>
480
481         [CMake] Make USE_CF conditional within Windows
482         https://bugs.webkit.org/show_bug.cgi?id=176173
483
484         Reviewed by Alex Christensen.
485
486         * wtf/Platform.h:
487         * wtf/PlatformWin.cmake:
488
489 2017-08-31  Ryan Haddad  <ryanhaddad@apple.com>
490
491         Unreviewed, rolling out r221445.
492
493         This change broke Sierra Release builds.
494
495         Reverted changeset:
496
497         "Switch HTMLMediaElement to release logging"
498         https://bugs.webkit.org/show_bug.cgi?id=176065
499         http://trac.webkit.org/changeset/221445
500
501 2017-08-31  Eric Carlson  <eric.carlson@apple.com>
502
503         Switch HTMLMediaElement to release logging
504         https://bugs.webkit.org/show_bug.cgi?id=176065
505
506         Reviewed by Jer Noble.
507
508         * wtf/MediaTime.cpp:
509         (WTF::MediaTime::dump const): Use toString.
510         (WTF::MediaTime::toString const): New.
511         * wtf/MediaTime.h:
512         (PAL::LogArgument<WTF::MediaTime>::toString): Logger template.
513
514 2017-08-31  Filip Pizlo  <fpizlo@apple.com>
515
516         All of the different ArrayBuffer::data's should be CagedPtr<>
517         https://bugs.webkit.org/show_bug.cgi?id=175515
518
519         Reviewed by Michael Saboff.
520         
521         Added a specialization so that CagedPtr<void> is valid.
522
523         * wtf/CagedPtr.h:
524
525 2017-08-31  Per Arne Vollan  <pvollan@apple.com>
526
527         [Win] Crash under WorkQueue::performWorkOnRegisteredWorkThread in layout tests.
528         https://bugs.webkit.org/show_bug.cgi?id=176163
529
530         Reviewed by Alex Christensen.
531
532         My previous attempt at fixing this crash in <http://trac.webkit.org/changeset/221323>
533         was incorrect, since it is still crashing on the bot(s). The current theory of why this
534         is failing is that the WorkQueue object deletes itself in the middle of the
535         performWorkOnRegisteredWorkThread method when calling deref(). There is no need to
536         increase the reference count of the work queue for each function we want to call on the
537         work thread. It is sufficient to increase it for every work thread we start, and then
538         dereference it when the thread ends. We should also not attempt to access members after
539         the deref() call, which can potentially be unsafe.
540  
541         * wtf/win/WorkQueueWin.cpp:
542         (WTF::WorkQueue::workThreadCallback):
543         (WTF::WorkQueue::performWorkOnRegisteredWorkThread):
544         (WTF::WorkQueue::dispatch):
545
546 2017-08-22  Filip Pizlo  <fpizlo@apple.com>
547
548         Strings need to be in some kind of gigacage
549         https://bugs.webkit.org/show_bug.cgi?id=174924
550
551         Reviewed by Oliver Hunt.
552         
553         This makes all strings allocations come from the string gigacage. Because we expect string allocation
554         to be a hot path, I created specialized allocation paths for the string gigacage. These paths are
555         accessible via <wtf/text/StringMalloc.h>. However, those paths are equivalent to saying
556         Gigacage::malloc and friends with the Gigacage::String kind.
557
558         * WTF.xcodeproj/project.pbxproj:
559         * wtf/CMakeLists.txt:
560         * wtf/Deque.h:
561         * wtf/FastMalloc.cpp:
562         (WTF::fastFree):
563         * wtf/FastMalloc.h:
564         (WTF::FastMalloc::malloc):
565         (WTF::FastMalloc::tryMalloc):
566         (WTF::FastMalloc::realloc):
567         (WTF::FastMalloc::free):
568         * wtf/Forward.h:
569         * wtf/Gigacage.cpp:
570         (Gigacage::tryMalloc):
571         * wtf/Gigacage.h:
572         (Gigacage::name):
573         * wtf/Vector.h:
574         (WTF::VectorBufferBase::allocateBuffer):
575         (WTF::VectorBufferBase::tryAllocateBuffer):
576         (WTF::VectorBufferBase::reallocateBuffer):
577         (WTF::VectorBufferBase::deallocateBuffer):
578         (WTF::Malloc>::Vector):
579         (WTF::=):
580         (WTF::Malloc>::contains const):
581         (WTF::Malloc>::findMatching const):
582         (WTF::Malloc>::find const):
583         (WTF::Malloc>::reverseFind const):
584         (WTF::Malloc>::appendIfNotContains):
585         (WTF::Malloc>::fill):
586         (WTF::Malloc>::appendRange):
587         (WTF::Malloc>::expandCapacity):
588         (WTF::Malloc>::tryExpandCapacity):
589         (WTF::Malloc>::resize):
590         (WTF::Malloc>::resizeToFit):
591         (WTF::Malloc>::shrink):
592         (WTF::Malloc>::grow):
593         (WTF::Malloc>::asanSetInitialBufferSizeTo):
594         (WTF::Malloc>::asanSetBufferSizeToFullCapacity):
595         (WTF::Malloc>::asanBufferSizeWillChangeTo):
596         (WTF::Malloc>::reserveCapacity):
597         (WTF::Malloc>::tryReserveCapacity):
598         (WTF::Malloc>::reserveInitialCapacity):
599         (WTF::Malloc>::shrinkCapacity):
600         (WTF::Malloc>::append):
601         (WTF::Malloc>::tryAppend):
602         (WTF::Malloc>::constructAndAppend):
603         (WTF::Malloc>::tryConstructAndAppend):
604         (WTF::Malloc>::appendSlowCase):
605         (WTF::Malloc>::constructAndAppendSlowCase):
606         (WTF::Malloc>::tryConstructAndAppendSlowCase):
607         (WTF::Malloc>::uncheckedAppend):
608         (WTF::Malloc>::appendVector):
609         (WTF::Malloc>::insert):
610         (WTF::Malloc>::insertVector):
611         (WTF::Malloc>::remove):
612         (WTF::Malloc>::removeFirst):
613         (WTF::Malloc>::removeFirstMatching):
614         (WTF::Malloc>::removeAll):
615         (WTF::Malloc>::removeAllMatching):
616         (WTF::Malloc>::reverse):
617         (WTF::Malloc>::map const):
618         (WTF::Malloc>::releaseBuffer):
619         (WTF::Malloc>::checkConsistency):
620         (WTF::swap):
621         (WTF::operator==):
622         (WTF::operator!=):
623         (WTF::removeRepeatedElements):
624         (WTF::minCapacity>::Vector): Deleted.
625         (WTF::minCapacity>::contains const): Deleted.
626         (WTF::minCapacity>::findMatching const): Deleted.
627         (WTF::minCapacity>::find const): Deleted.
628         (WTF::minCapacity>::reverseFind const): Deleted.
629         (WTF::minCapacity>::appendIfNotContains): Deleted.
630         (WTF::minCapacity>::fill): Deleted.
631         (WTF::minCapacity>::appendRange): Deleted.
632         (WTF::minCapacity>::expandCapacity): Deleted.
633         (WTF::minCapacity>::tryExpandCapacity): Deleted.
634         (WTF::minCapacity>::resize): Deleted.
635         (WTF::minCapacity>::resizeToFit): Deleted.
636         (WTF::minCapacity>::shrink): Deleted.
637         (WTF::minCapacity>::grow): Deleted.
638         (WTF::minCapacity>::asanSetInitialBufferSizeTo): Deleted.
639         (WTF::minCapacity>::asanSetBufferSizeToFullCapacity): Deleted.
640         (WTF::minCapacity>::asanBufferSizeWillChangeTo): Deleted.
641         (WTF::minCapacity>::reserveCapacity): Deleted.
642         (WTF::minCapacity>::tryReserveCapacity): Deleted.
643         (WTF::minCapacity>::reserveInitialCapacity): Deleted.
644         (WTF::minCapacity>::shrinkCapacity): Deleted.
645         (WTF::minCapacity>::append): Deleted.
646         (WTF::minCapacity>::tryAppend): Deleted.
647         (WTF::minCapacity>::constructAndAppend): Deleted.
648         (WTF::minCapacity>::tryConstructAndAppend): Deleted.
649         (WTF::minCapacity>::appendSlowCase): Deleted.
650         (WTF::minCapacity>::constructAndAppendSlowCase): Deleted.
651         (WTF::minCapacity>::tryConstructAndAppendSlowCase): Deleted.
652         (WTF::minCapacity>::uncheckedAppend): Deleted.
653         (WTF::minCapacity>::appendVector): Deleted.
654         (WTF::minCapacity>::insert): Deleted.
655         (WTF::minCapacity>::insertVector): Deleted.
656         (WTF::minCapacity>::remove): Deleted.
657         (WTF::minCapacity>::removeFirst): Deleted.
658         (WTF::minCapacity>::removeFirstMatching): Deleted.
659         (WTF::minCapacity>::removeAll): Deleted.
660         (WTF::minCapacity>::removeAllMatching): Deleted.
661         (WTF::minCapacity>::reverse): Deleted.
662         (WTF::minCapacity>::map const): Deleted.
663         (WTF::minCapacity>::releaseBuffer): Deleted.
664         (WTF::minCapacity>::checkConsistency): Deleted.
665         * wtf/text/AtomicStringImpl.h:
666         * wtf/text/CString.cpp:
667         (WTF::CStringBuffer::createUninitialized):
668         * wtf/text/CString.h:
669         * wtf/text/StringBuffer.h:
670         (WTF::StringBuffer::StringBuffer):
671         (WTF::StringBuffer::~StringBuffer):
672         (WTF::StringBuffer::resize):
673         * wtf/text/StringImpl.cpp:
674         (WTF::StringImpl::~StringImpl):
675         (WTF::StringImpl::destroy):
676         (WTF::StringImpl::createUninitializedInternalNonEmpty):
677         (WTF::StringImpl::reallocateInternal):
678         (WTF::StringImpl::releaseAssertCaged const):
679         * wtf/text/StringImpl.h:
680         (WTF::StringImpl::createSubstringSharingImpl):
681         (WTF::StringImpl::tryCreateUninitialized):
682         (WTF::StringImpl::adopt):
683         (WTF::StringImpl::bufferOwnership const):
684         (WTF::StringImpl::assertCaged const):
685         * wtf/text/StringMalloc.cpp: Added.
686         (WTF::tryStringMalloc):
687         (WTF::stringMalloc):
688         (WTF::stringRealloc):
689         (WTF::stringFree):
690         * wtf/text/StringMalloc.h: Added.
691         (WTF::StringMalloc::malloc):
692         (WTF::StringMalloc::tryMalloc):
693         (WTF::StringMalloc::realloc):
694         (WTF::StringMalloc::free):
695         * wtf/text/StringVector.h: Added.
696         * wtf/text/SymbolImpl.h:
697         * wtf/text/UniquedStringImpl.h:
698         * wtf/text/WTFString.h:
699         (WTF::String::adopt):
700         (WTF::String::assertCaged const):
701         (WTF::String::releaseAssertCaged const):
702
703 2017-08-30  Chris Dumez  <cdumez@apple.com>
704
705         Implement FileSystemDirectoryReader.readEntries()
706         https://bugs.webkit.org/show_bug.cgi?id=176091
707         <rdar://problem/34168015>
708
709         Reviewed by Andreas Kling.
710
711         * wtf/CrossThreadCopier.h:
712         (WTF::crossThreadCopy):
713         * wtf/CrossThreadTask.h:
714         Move crossThreadCopy() from CrossThreadTask.h to CrossThreadCopier.h and
715         add "using WTF::crossThreadCopy" statement to make it more easily usable
716         from WebCore.
717
718 2017-08-30  Matt Lewis  <jlewis3@apple.com>
719
720         Unreviewed, rolling out r221384.
721
722         This patch caused multiple 32-bit JSC test failures.
723
724         Reverted changeset:
725
726         "Strings need to be in some kind of gigacage"
727         https://bugs.webkit.org/show_bug.cgi?id=174924
728         http://trac.webkit.org/changeset/221384
729
730 2017-08-30  Brady Eidson  <beidson@apple.com>
731
732         Add "Identified" base class to replace a whole bunch of custom identifier generators.
733         https://bugs.webkit.org/show_bug.cgi?id=176120
734
735         Reviewed by Alex Christensen.
736
737         * WTF.xcodeproj/project.pbxproj:
738         * wtf/Identified.h: Added.
739         (WTF::IdentifiedBase::identifier const):
740         (WTF::IdentifiedBase::IdentifiedBase):
741         (WTF::Identified::Identified):
742         (WTF::ThreadSafeIdentified::ThreadSafeIdentified):
743
744 2017-08-22  Filip Pizlo  <fpizlo@apple.com>
745
746         Strings need to be in some kind of gigacage
747         https://bugs.webkit.org/show_bug.cgi?id=174924
748
749         Reviewed by Oliver Hunt.
750         
751         This makes all strings allocations come from the string gigacage. Because we expect string allocation
752         to be a hot path, I created specialized allocation paths for the string gigacage. These paths are
753         accessible via <wtf/text/StringMalloc.h>. However, those paths are equivalent to saying
754         Gigacage::malloc and friends with the Gigacage::String kind.
755
756         * WTF.xcodeproj/project.pbxproj:
757         * wtf/CMakeLists.txt:
758         * wtf/Deque.h:
759         * wtf/FastMalloc.cpp:
760         (WTF::fastFree):
761         * wtf/FastMalloc.h:
762         (WTF::FastMalloc::malloc):
763         (WTF::FastMalloc::tryMalloc):
764         (WTF::FastMalloc::realloc):
765         (WTF::FastMalloc::free):
766         * wtf/Forward.h:
767         * wtf/Gigacage.cpp:
768         (Gigacage::tryMalloc):
769         * wtf/Gigacage.h:
770         (Gigacage::name):
771         * wtf/Vector.h:
772         (WTF::VectorBufferBase::allocateBuffer):
773         (WTF::VectorBufferBase::tryAllocateBuffer):
774         (WTF::VectorBufferBase::reallocateBuffer):
775         (WTF::VectorBufferBase::deallocateBuffer):
776         (WTF::Malloc>::Vector):
777         (WTF::=):
778         (WTF::Malloc>::contains const):
779         (WTF::Malloc>::findMatching const):
780         (WTF::Malloc>::find const):
781         (WTF::Malloc>::reverseFind const):
782         (WTF::Malloc>::appendIfNotContains):
783         (WTF::Malloc>::fill):
784         (WTF::Malloc>::appendRange):
785         (WTF::Malloc>::expandCapacity):
786         (WTF::Malloc>::tryExpandCapacity):
787         (WTF::Malloc>::resize):
788         (WTF::Malloc>::resizeToFit):
789         (WTF::Malloc>::shrink):
790         (WTF::Malloc>::grow):
791         (WTF::Malloc>::asanSetInitialBufferSizeTo):
792         (WTF::Malloc>::asanSetBufferSizeToFullCapacity):
793         (WTF::Malloc>::asanBufferSizeWillChangeTo):
794         (WTF::Malloc>::reserveCapacity):
795         (WTF::Malloc>::tryReserveCapacity):
796         (WTF::Malloc>::reserveInitialCapacity):
797         (WTF::Malloc>::shrinkCapacity):
798         (WTF::Malloc>::append):
799         (WTF::Malloc>::tryAppend):
800         (WTF::Malloc>::constructAndAppend):
801         (WTF::Malloc>::tryConstructAndAppend):
802         (WTF::Malloc>::appendSlowCase):
803         (WTF::Malloc>::constructAndAppendSlowCase):
804         (WTF::Malloc>::tryConstructAndAppendSlowCase):
805         (WTF::Malloc>::uncheckedAppend):
806         (WTF::Malloc>::appendVector):
807         (WTF::Malloc>::insert):
808         (WTF::Malloc>::insertVector):
809         (WTF::Malloc>::remove):
810         (WTF::Malloc>::removeFirst):
811         (WTF::Malloc>::removeFirstMatching):
812         (WTF::Malloc>::removeAll):
813         (WTF::Malloc>::removeAllMatching):
814         (WTF::Malloc>::reverse):
815         (WTF::Malloc>::map const):
816         (WTF::Malloc>::releaseBuffer):
817         (WTF::Malloc>::checkConsistency):
818         (WTF::swap):
819         (WTF::operator==):
820         (WTF::operator!=):
821         (WTF::removeRepeatedElements):
822         (WTF::minCapacity>::Vector): Deleted.
823         (WTF::minCapacity>::contains const): Deleted.
824         (WTF::minCapacity>::findMatching const): Deleted.
825         (WTF::minCapacity>::find const): Deleted.
826         (WTF::minCapacity>::reverseFind const): Deleted.
827         (WTF::minCapacity>::appendIfNotContains): Deleted.
828         (WTF::minCapacity>::fill): Deleted.
829         (WTF::minCapacity>::appendRange): Deleted.
830         (WTF::minCapacity>::expandCapacity): Deleted.
831         (WTF::minCapacity>::tryExpandCapacity): Deleted.
832         (WTF::minCapacity>::resize): Deleted.
833         (WTF::minCapacity>::resizeToFit): Deleted.
834         (WTF::minCapacity>::shrink): Deleted.
835         (WTF::minCapacity>::grow): Deleted.
836         (WTF::minCapacity>::asanSetInitialBufferSizeTo): Deleted.
837         (WTF::minCapacity>::asanSetBufferSizeToFullCapacity): Deleted.
838         (WTF::minCapacity>::asanBufferSizeWillChangeTo): Deleted.
839         (WTF::minCapacity>::reserveCapacity): Deleted.
840         (WTF::minCapacity>::tryReserveCapacity): Deleted.
841         (WTF::minCapacity>::reserveInitialCapacity): Deleted.
842         (WTF::minCapacity>::shrinkCapacity): Deleted.
843         (WTF::minCapacity>::append): Deleted.
844         (WTF::minCapacity>::tryAppend): Deleted.
845         (WTF::minCapacity>::constructAndAppend): Deleted.
846         (WTF::minCapacity>::tryConstructAndAppend): Deleted.
847         (WTF::minCapacity>::appendSlowCase): Deleted.
848         (WTF::minCapacity>::constructAndAppendSlowCase): Deleted.
849         (WTF::minCapacity>::tryConstructAndAppendSlowCase): Deleted.
850         (WTF::minCapacity>::uncheckedAppend): Deleted.
851         (WTF::minCapacity>::appendVector): Deleted.
852         (WTF::minCapacity>::insert): Deleted.
853         (WTF::minCapacity>::insertVector): Deleted.
854         (WTF::minCapacity>::remove): Deleted.
855         (WTF::minCapacity>::removeFirst): Deleted.
856         (WTF::minCapacity>::removeFirstMatching): Deleted.
857         (WTF::minCapacity>::removeAll): Deleted.
858         (WTF::minCapacity>::removeAllMatching): Deleted.
859         (WTF::minCapacity>::reverse): Deleted.
860         (WTF::minCapacity>::map const): Deleted.
861         (WTF::minCapacity>::releaseBuffer): Deleted.
862         (WTF::minCapacity>::checkConsistency): Deleted.
863         * wtf/text/AtomicStringImpl.h:
864         * wtf/text/CString.cpp:
865         (WTF::CStringBuffer::createUninitialized):
866         * wtf/text/CString.h:
867         * wtf/text/StringBuffer.h:
868         (WTF::StringBuffer::StringBuffer):
869         (WTF::StringBuffer::~StringBuffer):
870         (WTF::StringBuffer::resize):
871         * wtf/text/StringImpl.cpp:
872         (WTF::StringImpl::~StringImpl):
873         (WTF::StringImpl::destroy):
874         (WTF::StringImpl::createUninitializedInternalNonEmpty):
875         (WTF::StringImpl::reallocateInternal):
876         (WTF::StringImpl::releaseAssertCaged const):
877         * wtf/text/StringImpl.h:
878         (WTF::StringImpl::createSubstringSharingImpl):
879         (WTF::StringImpl::tryCreateUninitialized):
880         (WTF::StringImpl::adopt):
881         (WTF::StringImpl::bufferOwnership const):
882         (WTF::StringImpl::assertCaged const):
883         * wtf/text/StringMalloc.cpp: Added.
884         (WTF::tryStringMalloc):
885         (WTF::stringMalloc):
886         (WTF::stringRealloc):
887         (WTF::stringFree):
888         * wtf/text/StringMalloc.h: Added.
889         (WTF::StringMalloc::malloc):
890         (WTF::StringMalloc::tryMalloc):
891         (WTF::StringMalloc::realloc):
892         (WTF::StringMalloc::free):
893         * wtf/text/StringVector.h: Added.
894         * wtf/text/SymbolImpl.h:
895         * wtf/text/UniquedStringImpl.h:
896         * wtf/text/WTFString.h:
897         (WTF::String::adopt):
898         (WTF::String::assertCaged const):
899         (WTF::String::releaseAssertCaged const):
900
901 2017-08-28  Yusuke Suzuki  <utatane.tea@gmail.com>
902
903         [JSC] Use table based approach for JSON.stringify's Quote
904         https://bugs.webkit.org/show_bug.cgi?id=176044
905
906         Reviewed by Darin Adler.
907
908         We change escape operation of JSON Quote from branch-based to table-based.
909         This patch partially adopts SpiderMonkey's change to StringBuilderJSON.cpp
910         to optimize this escaping operation. We separate changes from StringBuilder.cpp
911         to apply MPL to StringBuilderJSON.cpp file. Since WebKit already adopts MPL in
912         some files (like, DateMath.h), it is acceptable.
913
914         Kraken json-stringify-tinderbox shows 7.2% improvement.
915
916                                            baseline                  patched
917
918         json-stringify-tinderbox        40.429+-0.771      ^      37.693+-0.862         ^ definitely 1.0726x faster
919
920         * WTF.xcodeproj/project.pbxproj:
921         * wtf/CMakeLists.txt:
922         * wtf/text/StringBuilder.cpp:
923         (WTF::appendQuotedJSONStringInternalSlow): Deleted.
924         (WTF::appendQuotedJSONStringInternal): Deleted.
925         (WTF::StringBuilder::appendQuotedJSONString): Deleted.
926         * wtf/text/StringBuilderJSON.cpp: Added.
927         (WTF::appendQuotedJSONStringInternal):
928         (WTF::StringBuilder::appendQuotedJSONString):
929
930 2017-08-29  Per Arne Vollan  <pvollan@apple.com>
931
932         [Win] Crash under WorkQueue::performWorkOnRegisteredWorkThread in layout tests.
933         https://bugs.webkit.org/show_bug.cgi?id=176064
934
935         Reviewed by Saam Barati.
936
937         The crash log indicates that the function pointer is null in this case.
938
939         * wtf/win/WorkQueueWin.cpp:
940         (WTF::WorkQueue::dispatch):
941
942 2017-08-28  Andy Estes  <aestes@apple.com>
943
944         [Cocoa] Upstream WKGetWebDefaultCFStringEncoding()
945         https://bugs.webkit.org/show_bug.cgi?id=176039
946
947         Reviewed by Alex Christensen.
948
949         * wtf/spi/cf/CFStringSPI.h:
950
951 2017-08-26  Yusuke Suzuki  <utatane.tea@gmail.com>
952
953         Unreviewed, suppress warnings in GTK port
954
955         Add printf format attribute.
956
957         * wtf/text/WTFString.cpp:
958
959 2017-08-25  Eric Carlson  <eric.carlson@apple.com>
960
961         Add Logger::logAlways
962         https://bugs.webkit.org/show_bug.cgi?id=175996
963
964         Reviewed by Jer Noble.
965
966         * wtf/Assertions.cpp:
967         * wtf/Assertions.h:
968
969 2017-08-25  Daniel Bates  <dabates@apple.com>
970
971         Demarcate code added due to lack of NSDMI for aggregates
972         https://bugs.webkit.org/show_bug.cgi?id=175990
973
974         Reviewed by Andy Estes.
975
976         * wtf/Compiler.h:
977
978 2017-08-25  Don Olmstead  <don.olmstead@sony.com>
979
980         Define *_GIGACAGE_MASK when Gigacage is not supported
981         https://bugs.webkit.org/show_bug.cgi?id=175994
982
983         Reviewed by Mark Lam.
984
985         * wtf/Gigacage.h:
986
987 2017-08-25  Eric Carlson  <eric.carlson@apple.com>
988
989         Add String::format variant that takes va_args
990         https://bugs.webkit.org/show_bug.cgi?id=175988
991
992         Reviewed by Jer Noble.
993
994         * wtf/text/WTFString.cpp:
995         (WTF::createWithFormatAndArguments): Created with the guts of String::format.
996         (WTF::String::formatWithArguments): New, call createWithFormatAndArguments.
997         (WTF::String::format): Move logic to createWithFormatAndArguments, use it.
998         * wtf/text/WTFString.h:
999
1000 2017-08-25  Saam Barati  <sbarati@apple.com>
1001
1002         Support compiling catch in the DFG
1003         https://bugs.webkit.org/show_bug.cgi?id=174590
1004         <rdar://problem/34047845>
1005
1006         Reviewed by Filip Pizlo.
1007
1008         This patch generalizes the BackwardsGraph fake root into a more generalizable
1009         class called SingleRootGraph. SingleRootGraph exposes the general graph interface
1010         used in Dominators and NaturalLoops. SingleRootGraph takes as input a graph with
1011         the normal graph interface, but also allows the input graph to contain more than
1012         one root. SingleRootGraph then exposes a single root, which it creates, that has
1013         an outgoing edge to all the roots in the original graph.
1014
1015         * WTF.xcodeproj/project.pbxproj:
1016         * wtf/BackwardsGraph.h:
1017         (WTF::BackwardsGraph::dump const):
1018         (WTF::BackwardsGraph::rootName): Deleted.
1019         (WTF::BackwardsGraph::Node::Node): Deleted.
1020         (WTF::BackwardsGraph::Node::root): Deleted.
1021         (WTF::BackwardsGraph::Node::operator== const): Deleted.
1022         (WTF::BackwardsGraph::Node::operator!= const): Deleted.
1023         (WTF::BackwardsGraph::Node::operator bool const): Deleted.
1024         (WTF::BackwardsGraph::Node::isRoot const): Deleted.
1025         (WTF::BackwardsGraph::Node::node const): Deleted.
1026         (): Deleted.
1027         (WTF::BackwardsGraph::Set::Set): Deleted.
1028         (WTF::BackwardsGraph::Set::add): Deleted.
1029         (WTF::BackwardsGraph::Set::remove): Deleted.
1030         (WTF::BackwardsGraph::Set::contains): Deleted.
1031         (WTF::BackwardsGraph::Set::dump const): Deleted.
1032         (WTF::BackwardsGraph::Map::Map): Deleted.
1033         (WTF::BackwardsGraph::Map::clear): Deleted.
1034         (WTF::BackwardsGraph::Map::size const): Deleted.
1035         (WTF::BackwardsGraph::Map::operator[]): Deleted.
1036         (WTF::BackwardsGraph::Map::operator[] const): Deleted.
1037         * wtf/Dominators.h:
1038         (WTF::Dominators::Dominators):
1039         (WTF::Dominators::forAllBlocksInIteratedDominanceFrontierOf):
1040         (WTF::Dominators::forAllBlocksInPrunedIteratedDominanceFrontierOf):
1041         (WTF::Dominators::iteratedDominanceFrontierOf const):
1042         (WTF::Dominators::forAllBlocksInIteratedDominanceFrontierOfImpl const):
1043         * wtf/SingleRootGraph.h: Added.
1044         (WTF::SingleRootGraphNode::rootName):
1045         (WTF::SingleRootGraphNode::SingleRootGraphNode):
1046         (WTF::SingleRootGraphNode::root):
1047         (WTF::SingleRootGraphNode::operator== const):
1048         (WTF::SingleRootGraphNode::operator!= const):
1049         (WTF::SingleRootGraphNode::operator bool const):
1050         (WTF::SingleRootGraphNode::isRoot const):
1051         (WTF::SingleRootGraphNode::node const):
1052         (WTF::SingleRootGraphSet::add):
1053         (WTF::SingleRootGraphSet::remove):
1054         (WTF::SingleRootGraphSet::contains):
1055         (WTF::SingleRootGraphSet::dump const):
1056         (WTF::SingleRootMap::SingleRootMap):
1057         (WTF::SingleRootMap::clear):
1058         (WTF::SingleRootMap::size const):
1059         (WTF::SingleRootMap::operator[]):
1060         (WTF::SingleRootMap::operator[] const):
1061         (WTF::SingleRootGraph::SingleRootGraph):
1062         (WTF::SingleRootGraph::root const):
1063         (WTF::SingleRootGraph::newMap):
1064         (WTF::SingleRootGraph::successors const):
1065         (WTF::SingleRootGraph::predecessors const):
1066         (WTF::SingleRootGraph::index const):
1067         (WTF::SingleRootGraph::node const):
1068         (WTF::SingleRootGraph::numNodes const):
1069         (WTF::SingleRootGraph::dump const):
1070         (WTF::SingleRootGraph::assertIsConsistent const):
1071
1072 2017-08-24  Commit Queue  <commit-queue@webkit.org>
1073
1074         Unreviewed, rolling out r221119, r221124, and r221143.
1075         https://bugs.webkit.org/show_bug.cgi?id=175973
1076
1077         "I think it regressed JSBench by 20%" (Requested by saamyjoon
1078         on #webkit).
1079
1080         Reverted changesets:
1081
1082         "Support compiling catch in the DFG"
1083         https://bugs.webkit.org/show_bug.cgi?id=174590
1084         http://trac.webkit.org/changeset/221119
1085
1086         "Unreviewed, build fix in GTK port"
1087         https://bugs.webkit.org/show_bug.cgi?id=174590
1088         http://trac.webkit.org/changeset/221124
1089
1090         "DFG::JITCode::osrEntry should get sorted since we perform a
1091         binary search on it"
1092         https://bugs.webkit.org/show_bug.cgi?id=175893
1093         http://trac.webkit.org/changeset/221143
1094
1095 2017-08-23  Filip Pizlo  <fpizlo@apple.com>
1096
1097         Reduce Gigacage sizes
1098         https://bugs.webkit.org/show_bug.cgi?id=175920
1099
1100         Reviewed by Mark Lam.
1101
1102         Provide filler API for the no-bmalloc/no-Gigacage case.
1103
1104         * wtf/Gigacage.h:
1105         (Gigacage::mask):
1106
1107 2017-08-23  Yusuke Suzuki  <utatane.tea@gmail.com>
1108
1109         Unreviewed, build fix in GTK port
1110         https://bugs.webkit.org/show_bug.cgi?id=174590
1111
1112         * wtf/SingleRootGraph.h:
1113         (WTF::SingleRootGraph::successors const):
1114         (WTF::SingleRootGraph::predecessors const):
1115
1116 2017-08-23  Saam Barati  <sbarati@apple.com>
1117
1118         Support compiling catch in the DFG
1119         https://bugs.webkit.org/show_bug.cgi?id=174590
1120
1121         Reviewed by Filip Pizlo.
1122
1123         This patch generalizes the BackwardsGraph fake root into a more generalizable
1124         class called SingleRootGraph. SingleRootGraph exposes the general graph interface
1125         used in Dominators and NaturalLoops. SingleRootGraph takes as input a graph with
1126         the normal graph interface, but also allows the input graph to contain more than
1127         one root. SingleRootGraph then exposes a single root, which it creates, that has
1128         an outgoing edge to all the roots in the original graph.
1129
1130         * WTF.xcodeproj/project.pbxproj:
1131         * wtf/BackwardsGraph.h:
1132         (WTF::BackwardsGraph::dump const):
1133         (WTF::BackwardsGraph::rootName): Deleted.
1134         (WTF::BackwardsGraph::Node::Node): Deleted.
1135         (WTF::BackwardsGraph::Node::root): Deleted.
1136         (WTF::BackwardsGraph::Node::operator== const): Deleted.
1137         (WTF::BackwardsGraph::Node::operator!= const): Deleted.
1138         (WTF::BackwardsGraph::Node::operator bool const): Deleted.
1139         (WTF::BackwardsGraph::Node::isRoot const): Deleted.
1140         (WTF::BackwardsGraph::Node::node const): Deleted.
1141         (): Deleted.
1142         (WTF::BackwardsGraph::Set::Set): Deleted.
1143         (WTF::BackwardsGraph::Set::add): Deleted.
1144         (WTF::BackwardsGraph::Set::remove): Deleted.
1145         (WTF::BackwardsGraph::Set::contains): Deleted.
1146         (WTF::BackwardsGraph::Set::dump const): Deleted.
1147         (WTF::BackwardsGraph::Map::Map): Deleted.
1148         (WTF::BackwardsGraph::Map::clear): Deleted.
1149         (WTF::BackwardsGraph::Map::size const): Deleted.
1150         (WTF::BackwardsGraph::Map::operator[]): Deleted.
1151         (WTF::BackwardsGraph::Map::operator[] const): Deleted.
1152         * wtf/Dominators.h:
1153         (WTF::Dominators::Dominators):
1154         (WTF::Dominators::forAllBlocksInIteratedDominanceFrontierOf):
1155         (WTF::Dominators::forAllBlocksInPrunedIteratedDominanceFrontierOf):
1156         (WTF::Dominators::iteratedDominanceFrontierOf const):
1157         (WTF::Dominators::forAllBlocksInIteratedDominanceFrontierOfImpl const):
1158         * wtf/SingleRootGraph.h: Added.
1159         (WTF::SingleRootGraphNode::rootName):
1160         (WTF::SingleRootGraphNode::SingleRootGraphNode):
1161         (WTF::SingleRootGraphNode::root):
1162         (WTF::SingleRootGraphNode::operator== const):
1163         (WTF::SingleRootGraphNode::operator!= const):
1164         (WTF::SingleRootGraphNode::operator bool const):
1165         (WTF::SingleRootGraphNode::isRoot const):
1166         (WTF::SingleRootGraphNode::node const):
1167         (WTF::SingleRootGraphSet::add):
1168         (WTF::SingleRootGraphSet::remove):
1169         (WTF::SingleRootGraphSet::contains):
1170         (WTF::SingleRootGraphSet::dump const):
1171         (WTF::SingleRootMap::SingleRootMap):
1172         (WTF::SingleRootMap::clear):
1173         (WTF::SingleRootMap::size const):
1174         (WTF::SingleRootMap::operator[]):
1175         (WTF::SingleRootMap::operator[] const):
1176         (WTF::SingleRootGraph::SingleRootGraph):
1177         (WTF::SingleRootGraph::root const):
1178         (WTF::SingleRootGraph::newMap):
1179         (WTF::SingleRootGraph::successors const):
1180         (WTF::SingleRootGraph::predecessors const):
1181         (WTF::SingleRootGraph::index const):
1182         (WTF::SingleRootGraph::node const):
1183         (WTF::SingleRootGraph::numNodes const):
1184         (WTF::SingleRootGraph::dump const):
1185         (WTF::SingleRootGraph::assertIsConsistent const):
1186
1187 2017-08-23  Youenn Fablet  <youenn@apple.com>
1188
1189         [Cache API] Enable persistent coder to encode FetchOptions
1190         https://bugs.webkit.org/show_bug.cgi?id=175883
1191
1192         Reviewed by Alex Christensen.
1193
1194         Enabling encoding/decoding of enums with EnumTraits.
1195         This code is similar to the one of IPC encoder/decoder.
1196
1197         * wtf/persistence/PersistentDecoder.h:
1198         (WTF::Persistence::Decoder::decode):
1199         * wtf/persistence/PersistentEncoder.h:
1200         (WTF::Persistence::Encoder::encode):
1201
1202 2017-08-23  Per Arne Vollan  <pvollan@apple.com>
1203
1204         [Win] Compile error, include file <wtf/AVFoundationHeaderDetection.h> is not found.
1205         https://bugs.webkit.org/show_bug.cgi?id=175853
1206
1207         Reviewed by Brent Fulgham.
1208
1209         Copy generated WTF header files to the same place as we copy forwarding headers.
1210  
1211         * WTF.vcxproj/WTF.proj:
1212
1213 2017-08-22  Chris Dumez  <cdumez@apple.com>
1214
1215         Introduce a new CompletionHandler type and use it for NetworkDataTaskClient's completion handlers to help catch bugs
1216         https://bugs.webkit.org/show_bug.cgi?id=175832
1217
1218         Reviewed by Alex Christensen.
1219
1220         Introduce a new CompletionHandler type which wraps a WTF::Function and ensures via assertions
1221         that the function is always called once and only once.
1222
1223         * WTF.xcodeproj/project.pbxproj:
1224         * wtf/CompletionHandler.h: Added.
1225         (WTF::CompletionHandler<Out):
1226
1227 2017-08-22  Alex Christensen  <achristensen@webkit.org>
1228
1229         Fix Windows build after r221017.
1230         https://bugs.webkit.org/show_bug.cgi?id=157053
1231
1232         * wtf/PlatformWin.cmake:
1233
1234 2017-08-22  Per Arne Vollan  <pvollan@apple.com>
1235
1236         Implement 64-bit MacroAssembler::probe support for Windows.
1237         https://bugs.webkit.org/show_bug.cgi?id=175724
1238
1239         Reviewed by Mark Lam.
1240
1241         Enable masm probe and DFG.
1242
1243         * wtf/Platform.h:
1244
1245 2017-08-21  Mark Lam  <mark.lam@apple.com>
1246
1247         [Follow up]: Add back the ability to disable MASM_PROBE from the build.
1248         https://bugs.webkit.org/show_bug.cgi?id=175656
1249         <rdar://problem/33933720>
1250
1251         Not reviewed.
1252
1253         Fixed a typo: should be "OS(WINDOWS)", not "OS(WINDOW)".
1254
1255         * wtf/Platform.h:
1256
1257 2017-08-21  Carlos Alberto Lopez Perez  <clopez@igalia.com>
1258
1259         [GTK] ARMv7 build fails to build MacroAssemblerARMv7.cpp.
1260         https://bugs.webkit.org/show_bug.cgi?id=175514
1261
1262         Reviewed by Keith Miller.
1263
1264         * wtf/Platform.h: Enable DFG and MASM_PROBE back for GTK ARM_THUMB2.
1265
1266 2017-08-20  Sam Weinig  <sam@webkit.org>
1267
1268         StringView could use a function to strip leading/trailing characters without allocation
1269         https://bugs.webkit.org/show_bug.cgi?id=175757
1270
1271         Reviewed by Darin Adler.
1272
1273         There are many places in WebCore/WebKit that we call functions like, 
1274         WebCore::stripLeadingAndTrailingHTMLSpaces,  or String::stripWhiteSpace() only to use 
1275         the allocated String as a temporary for either another transformation or a comparison.
1276         Now that we have StringView, we can avoid that extra allocation, by having returning a
1277         StringView  substring in these scenarios.
1278
1279         For instance, the check (from ScriptElement.cpp:287):
1280
1281         if (!stripLeadingAndTrailingHTMLSpaces(sourceURL).isEmpty()) {
1282             ...
1283         }
1284
1285         currently allocates a string just to make this check. With a new 
1286         stripLeadingAndTrailingHTMLSpaces such as:
1287
1288         StringView stripLeadingAndTrailingHTMLSpaces(StringView stringView)
1289         {
1290             return stringView.stripLeadingAndTrailingMatchedCharacters([] (auto c) {
1291                 return isHTMLSpace(c);
1292             });
1293         }
1294
1295         We could instead have exact same code from ScriptElement.cpp now avoid an allocation.
1296
1297         * wtf/text/StringView.h:
1298         (WTF::StringView::stripLeadingAndTrailingMatchedCharacters):
1299
1300 2017-08-21  Eric Carlson  <eric.carlson@apple.com>
1301
1302         Add WTFLogChannel level to allow runtime log filtering
1303         https://bugs.webkit.org/show_bug.cgi?id=175731
1304         <rdar://problem/33967234>
1305
1306         Reviewed by Jer Noble.
1307         
1308         Add WTFLog*, LOG, and RELEASE_LOG variants that take a "log level" parameter so code
1309         can include logging statements that are only conditionally emitted.
1310
1311         * wtf/Assertions.cpp:
1312         * wtf/Assertions.h:
1313         * wtf/MemoryPressureHandler.cpp:
1314         * wtf/RefCountedLeakCounter.cpp:
1315
1316 2017-08-20  Mark Lam  <mark.lam@apple.com>
1317
1318         Gardening: fix CLoop build.
1319         https://bugs.webkit.org/show_bug.cgi?id=175688
1320         <rdar://problem/33436870>
1321
1322         Not reviewed.
1323
1324         Disable MASM_PROBE if !ENABLE(JIT).
1325
1326         * wtf/Platform.h:
1327
1328 2017-08-18  Ryan Haddad  <ryanhaddad@apple.com>
1329
1330         Unreviewed, rolling out r220938.
1331
1332         The API tests added with this change are failing.
1333
1334         Reverted changeset:
1335
1336         "Add WTFLogChannel level to allow runtime log filtering"
1337         https://bugs.webkit.org/show_bug.cgi?id=175731
1338         http://trac.webkit.org/changeset/220938
1339
1340 2017-08-18  Eric Carlson  <eric.carlson@apple.com>
1341
1342         Add WTFLogChannel level to allow runtime log filtering
1343         https://bugs.webkit.org/show_bug.cgi?id=175731
1344         <rdar://problem/33967234>
1345
1346         Reviewed by Jer Noble.
1347         
1348         Add WTFLog*, LOG, and RELEASE_LOG variants that take a "log level" parameter so code
1349         can include logging statements that are only conditionally emitted.
1350
1351         * wtf/Assertions.cpp:
1352         * wtf/Assertions.h:
1353         * wtf/MemoryPressureHandler.cpp:
1354         * wtf/RefCountedLeakCounter.cpp:
1355
1356 2017-08-18  Per Arne Vollan  <pvollan@apple.com>
1357
1358         Implement 32-bit MacroAssembler::probe support for Windows.
1359         https://bugs.webkit.org/show_bug.cgi?id=175449
1360
1361         Reviewed by Mark Lam.
1362
1363         Enable the DFG on Win32. 
1364
1365         * wtf/Platform.h:
1366
1367 2017-08-17  Mark Lam  <mark.lam@apple.com>
1368
1369         Only use 16 VFP registers if !CPU(ARM_NEON).
1370         https://bugs.webkit.org/show_bug.cgi?id=175514
1371
1372         Reviewed by JF Bastien.
1373
1374         If CPU(ARM_NEON) is not enabled, we'll conservatively assume only VFP2 support is
1375         available. Hence, we'll only the first 16 FPDoubleRegisterIDs are available.
1376
1377         For reference, see:
1378         NEON registers: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0473c/CJACABEJ.html
1379         VFP2 and VFP3 registers: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0473c/CIHDIBDG.html
1380         NEON to VFP register mapping: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0473c/CJAIJHFC.html
1381
1382         This is mostly for GTK toolchains which may target older ARM CPUs which only have
1383         VFP2 support.
1384
1385         * wtf/Platform.h:
1386
1387 2017-08-16  Mark Lam  <mark.lam@apple.com>
1388
1389         Add back the ability to disable MASM_PROBE from the build.
1390         https://bugs.webkit.org/show_bug.cgi?id=175656
1391         <rdar://problem/33933720>
1392
1393         Reviewed by Yusuke Suzuki.
1394
1395         * wtf/Platform.h:
1396
1397 2017-08-16  Mark Lam  <mark.lam@apple.com>
1398
1399         Gardening: fix GTK ARM_THUMB2 build.
1400         https://bugs.webkit.org/show_bug.cgi?id=175446
1401
1402         Not reviewed.
1403
1404         Disable the use of the DFG for GTK ARM_THUMB2 builds until
1405         https://bugs.webkit.org/show_bug.cgi?id=175514 is fixed.
1406
1407         * wtf/Platform.h:
1408
1409 2017-08-16  Andy Estes  <aestes@apple.com>
1410
1411         [Payment Request] Add an ENABLE flag and an experimental feature preference
1412         https://bugs.webkit.org/show_bug.cgi?id=175622
1413
1414         Reviewed by Tim Horton.
1415
1416         * wtf/FeatureDefines.h:
1417
1418 2017-08-14  Simon Fraser  <simon.fraser@apple.com>
1419
1420         Remove Proximity Events and related code
1421         https://bugs.webkit.org/show_bug.cgi?id=175545
1422
1423         Reviewed by Daniel Bates.
1424
1425         No platform enables Proximity Events, so remove code inside ENABLE(PROXIMITY_EVENTS)
1426         and other related code.
1427
1428         * wtf/FeatureDefines.h:
1429
1430 2017-08-14  Simon Fraser  <simon.fraser@apple.com>
1431
1432         Remove ENABLE(REQUEST_AUTOCOMPLETE) code, which was disabled everywhere
1433         https://bugs.webkit.org/show_bug.cgi?id=175504
1434
1435         Reviewed by Sam Weinig.
1436
1437         * wtf/FeatureDefines.h:
1438
1439 2017-08-14  Simon Fraser  <simon.fraser@apple.com>
1440
1441         Remove ENABLE_VIEW_MODE_CSS_MEDIA and related code
1442         https://bugs.webkit.org/show_bug.cgi?id=175557
1443
1444         Reviewed by Jon Lee.
1445
1446         No port cares about the ENABLE(VIEW_MODE_CSS_MEDIA) feature, so remove it.
1447
1448         * wtf/FeatureDefines.h:
1449
1450 2017-08-12  Filip Pizlo  <fpizlo@apple.com>
1451
1452         Put the ScopedArgumentsTable's ScopeOffset array in some gigacage
1453         https://bugs.webkit.org/show_bug.cgi?id=174921
1454
1455         Reviewed by Mark Lam.
1456         
1457         If you want to std::unique_ptr a class that knows that it should be in the Gigacage, then we
1458         would create the Gigacage equivalent of WTF_MAKE_FAST_ALLOCATED and it would just work.
1459         
1460         But this does not work if we want to std::unique_ptr a primitive type. So, this patch adds a
1461         solution for this problem: CagedUniquePtr<>. This will handle allocation
1462         (CagedUniquePtr<>::create()) and deallocation (in the style of std::unique_ptr). It has three
1463         variants:
1464         
1465         - Non-array types.
1466         - Arrays that don't have destructors.
1467         - Arrays that have destructors.
1468         
1469         Just like std::unique_ptr, the array case is triggered by saying "[]" at the end of the type.
1470         
1471         Unlike std::unique_ptr and most other smart pointers, the whole point of this smart pointer is
1472         to dictate where the thing you're pointing at is allocated. For this reason, it has to know how
1473         to do things like the array destructor protocol. So it creates its own: the CagedUniquePtr for
1474         arrays with destructors is a fat pointer that remembers the length of the array.
1475         
1476         CagedUniquePtr<> makes it impossible to leak/release the pointer. This is stricter than what
1477         std::unique_ptr does, and is probably appropriate for all of the places where we would use this
1478         type.
1479         
1480         So far, we only use it for ScopedArgumentsTable::m_arguments, but I suspect that it will be
1481         useful in other places.
1482
1483         * WTF.xcodeproj/project.pbxproj:
1484         * wtf/CMakeLists.txt:
1485         * wtf/CagedUniquePtr.h: Added.
1486         (WTF::CagedUniquePtr::CagedUniquePtr):
1487         (WTF::CagedUniquePtr::create):
1488         (WTF::CagedUniquePtr::operator=):
1489         (WTF::CagedUniquePtr::~CagedUniquePtr):
1490         (WTF::CagedUniquePtr::get const):
1491         (WTF::CagedUniquePtr::getMayBeNull const):
1492         (WTF::CagedUniquePtr::operator== const):
1493         (WTF::CagedUniquePtr::operator!= const):
1494         (WTF::CagedUniquePtr::operator bool const):
1495         (WTF::CagedUniquePtr::operator* const):
1496         (WTF::CagedUniquePtr::operator-> const):
1497         (WTF::CagedUniquePtr::operator[] const):
1498         (WTF::CagedUniquePtr::destroy):
1499         * wtf/Gigacage.cpp:
1500         (Gigacage::tryMallocArray):
1501         (Gigacage::malloc):
1502         (Gigacage::mallocArray):
1503         * wtf/Gigacage.h:
1504
1505 2017-08-11  Ryosuke Niwa  <rniwa@webkit.org>
1506
1507         Replace DATA_TRANSFER_ITEMS by a runtime flag and add a stub implementation
1508         https://bugs.webkit.org/show_bug.cgi?id=175474
1509
1510         Reviewed by Wenson Hsieh.
1511
1512         * wtf/FeatureDefines.h:
1513
1514 2017-08-11  Don Olmstead  <don.olmstead@sony.com>
1515
1516         [WTF] Move ValueToString into WTF
1517         https://bugs.webkit.org/show_bug.cgi?id=175469
1518
1519         Reviewed by Sam Weinig.
1520
1521         * WTF.xcodeproj/project.pbxproj:
1522         * wtf/CMakeLists.txt:
1523         * wtf/text/ValueToString.h: Renamed from Source/WebCore/platform/ValueToString.h.
1524
1525 2017-08-11  Tim Horton  <timothy_horton@apple.com>
1526
1527         Fix the build with modern Clang's -Wexpansion-to-defined
1528         https://bugs.webkit.org/show_bug.cgi?id=175467
1529         <rdar://problem/33667497>
1530
1531         Reviewed by Simon Fraser.
1532
1533         * wtf/FeatureDefines.h:
1534         * wtf/Platform.h:
1535         Avoid object-like macros that expand to include defined(), because this
1536         behaves inconsistently between different compilers (though in ways
1537         that don't matter for these particular defines, which aren't used on MSVC),
1538         and Clang has added a warning for it.
1539
1540         Move ENABLE_WEBASSEMBLY to Platform.h since it depends on things that
1541         are defined there and can't be evaluated at time-of-use because of the
1542         aforementioned new rules. Previously, there was a cycle between
1543         ENABLE_WEBASSEMBLY and ENABLE_B3_JIT -- break that so that it just
1544         goes FTL_JIT->B3_JIT->WASM instead.
1545
1546 2017-08-10  Sam Weinig  <sam@webkit.org>
1547
1548         WTF::Function does not allow for reference / non-default constructible return types
1549         https://bugs.webkit.org/show_bug.cgi?id=175244
1550
1551         Reviewed by Chris Dumez.
1552
1553         When Function, then NoncopyableFunction, was templatized to allow non-void return values
1554         in r201493, it maintained the behavior of being callable even if the Function was null.
1555         To accomplish this, when null, the default construction of the return parameter was used.
1556         This means Function can't be used with return types that are not default constructible,
1557         such as reference types and Ref.
1558
1559         This behavior of returning something when null is surprising, as this is not how normal
1560         functions behave, and not very useful. Instead, we now assert that the function is not
1561         null when being called.
1562
1563         * wtf/Function.h:
1564         (WTF::Function operator(...)):
1565         Instead of allowing a null callable wrapper by returning the default construction of
1566         the return type, assert that the wrapper is there when calling a Function.
1567
1568 2017-08-10  Mark Lam  <mark.lam@apple.com>
1569
1570         Make the MASM_PROBE mechanism mandatory for DFG and FTL builds.
1571         https://bugs.webkit.org/show_bug.cgi?id=175446
1572         <rdar://problem/33836545>
1573
1574         Reviewed by Saam Barati.
1575
1576         This is needed in order to support https://bugs.webkit.org/show_bug.cgi?id=174645.
1577         One consequence of this is that the DFG will now be disabled for the MIPS and
1578         Windows ports. See:
1579             https://bugs.webkit.org/show_bug.cgi?id=175447
1580             https://bugs.webkit.org/show_bug.cgi?id=175449
1581
1582         Also, we should only ENABLE_SIGNAL_BASED_VM_TRAPS if the DFG is enabled.  It was
1583         never meaningful to use SIGNAL_BASED_VM_TRAPS with the baseline JIT anyway.  This
1584         is a mis-configuration error that is now fixed.
1585
1586         * wtf/Platform.h:
1587
1588 2017-08-10  Brady Eidson  <beidson@apple.com>
1589
1590         Rename the source files for the WTF persistent coders.
1591         https://bugs.webkit.org/show_bug.cgi?id=175441
1592
1593         Reviewed by Tim Horton.
1594
1595         * WTF.xcodeproj/project.pbxproj:
1596         * wtf/CMakeLists.txt:
1597
1598         * wtf/persistence/PersistentCoder.h: Renamed from Source/WTF/wtf/persistence/Coder.h.
1599         * wtf/persistence/PersistentCoders.cpp: Renamed from Source/WTF/wtf/persistence/Coders.cpp.
1600         * wtf/persistence/PersistentCoders.h: Renamed from Source/WTF/wtf/persistence/Coders.h.
1601         * wtf/persistence/PersistentDecoder.cpp: Renamed from Source/WTF/wtf/persistence/Decoder.cpp.
1602         * wtf/persistence/PersistentDecoder.h: Renamed from Source/WTF/wtf/persistence/Decoder.h.
1603         * wtf/persistence/PersistentEncoder.cpp: Renamed from Source/WTF/wtf/persistence/Encoder.cpp.
1604         * wtf/persistence/PersistentEncoder.h: Renamed from Source/WTF/wtf/persistence/Encoder.h.
1605
1606 2017-08-10  Yusuke Suzuki  <utatane.tea@gmail.com>
1607
1608         Unreviewed, attempt to fix build failure with VC2017
1609
1610         * wtf/PriorityQueue.h:
1611
1612 2017-08-10  Yusuke Suzuki  <utatane.tea@gmail.com>
1613
1614         Run more WTF tests
1615         https://bugs.webkit.org/show_bug.cgi?id=174970
1616
1617         Reviewed by Michael Catanzaro.
1618
1619         CHAR_BIT is not defined.
1620
1621         * wtf/LEBDecoder.h:
1622
1623 2017-08-09  Yusuke Suzuki  <utatane.tea@gmail.com>
1624
1625         [WTF] ThreadSpecific should not introduce additional indirection
1626         https://bugs.webkit.org/show_bug.cgi?id=175187
1627
1628         Reviewed by Mark Lam.
1629
1630         ThreadSpecific sets Data* to the TLS. And Data holds T*, which
1631         is fast allocated actual data. But ideally, we should store T
1632         instance directly in Data instead of introducing an additional
1633         indirection.
1634
1635         This patch adds storage in Data in order to embed the instance of T. The constructor
1636         for Data will invoke the constructor for T on the embedded storage. We also drop
1637         ThreadSpecific::replace which is only used by the web thread to set its thread specific
1638         ThreadGlobalData to the one shared from the main thread. The existing implementation
1639         relies on the main thread and the web thread never exiting in order for the shared
1640         ThreadGlobalData to stay alive. We can achieve the same semantics by using a
1641         ThreadSpecific<std::unique_ptr<T>> to hold the ThreadGlobalData instance instead.
1642
1643         * wtf/ThreadSpecific.h:
1644         (WTF::ThreadSpecific::Data::construct):
1645         (WTF::ThreadSpecific::Data::Data):
1646         We make it fast allocated since we previously allocated ThreadSpecific T data by fastMalloc.
1647
1648         (WTF::ThreadSpecific::Data::~Data):
1649         (WTF::ThreadSpecific::Data::storagePointer const):
1650         (WTF::canBeGCThread>::get):
1651         We also drop RELEASE_ASSERT from ::get(). We already inserted this assert to setAndConstruct(),
1652         so when creating the member to this TLS, we execute this release assert. So it is
1653         not necessary to execute this assertion every time we get data from this TLS.
1654
1655         (WTF::canBeGCThread>::set):
1656         (WTF::canBeGCThread>::destroy):
1657         (WTF::canBeGCThread>::setAndConstruct):
1658         (WTF::T):
1659         (WTF::canBeGCThread>::replace): Deleted.
1660
1661 2017-08-10  Tim Horton  <timothy_horton@apple.com>
1662
1663         Fix a silly typo in Compiler.h
1664
1665         * wtf/Compiler.h:
1666         Heature, indeed.
1667
1668 2017-08-10  Michael Catanzaro  <mcatanzaro@igalia.com>
1669
1670         Remove ENABLE_GAMEPAD_DEPRECATED
1671         https://bugs.webkit.org/show_bug.cgi?id=175361
1672
1673         Reviewed by Carlos Garcia Campos.
1674
1675         * wtf/FeatureDefines.h:
1676
1677 2017-08-09  Don Olmstead  <don.olmstead@sony.com>
1678
1679         [WTF] Move TextStream into WTF
1680         https://bugs.webkit.org/show_bug.cgi?id=175211
1681
1682         Reviewed by Myles C. Maxfield.
1683
1684         * WTF.xcodeproj/project.pbxproj:
1685         * wtf/CMakeLists.txt:
1686         * wtf/text/TextStream.cpp: Renamed from Source/WebCore/platform/text/TextStream.cpp.
1687         (WTF::TextStream::writeIndent):
1688         * wtf/text/TextStream.h: Renamed from Source/WebCore/platform/text/TextStream.h.
1689         (WTF::TextStream::FormatNumberRespectingIntegers::FormatNumberRespectingIntegers):
1690
1691 2017-08-09  Commit Queue  <commit-queue@webkit.org>
1692
1693         Unreviewed, rolling out r220466, r220477, and r220487.
1694         https://bugs.webkit.org/show_bug.cgi?id=175411
1695
1696         This change broke existing API tests and follow up fixes did
1697         not resolve all the issues. (Requested by ryanhaddad on
1698         #webkit).
1699
1700         Reverted changesets:
1701
1702         https://bugs.webkit.org/show_bug.cgi?id=175244
1703         http://trac.webkit.org/changeset/220466
1704
1705         "WTF::Function does not allow for reference / non-default
1706         constructible return types"
1707         https://bugs.webkit.org/show_bug.cgi?id=175244
1708         http://trac.webkit.org/changeset/220477
1709
1710         https://bugs.webkit.org/show_bug.cgi?id=175244
1711         http://trac.webkit.org/changeset/220487
1712
1713 2017-08-09  Sam Weinig  <sam@webkit.org>
1714
1715         WTF::Function does not allow for reference / non-default constructible return types
1716         https://bugs.webkit.org/show_bug.cgi?id=175244
1717
1718         Reviewed by Chris Dumez.
1719
1720         When Function, then NoncopyableFunction, was templatized to allow non-void return values
1721         in r201493, it maintained the behavior of being callable even if the Function was null.
1722         To accomplish this, when null, the default construction of the return parameter was used.
1723         This means Function can't be used with return types that are not default constructible,
1724         such as reference types and Ref.
1725
1726         This behavior of returning something when null is surprising, as this is not how normal
1727         functions behave, and not very useful. Instead, we now assert that the function is not
1728         null when being called.
1729
1730         * wtf/Function.h:
1731         (WTF::Function operator(...)):
1732         Instead of allowing a null callable wrapper by returning the default construction of
1733         the return type, assert that the wrapper is there when calling a Function.
1734
1735 2017-08-09  Ryan Haddad  <ryanhaddad@apple.com>
1736
1737         Unreviewed, rolling out r220457.
1738
1739         This change introduced API test failures.
1740
1741         Reverted changeset:
1742
1743         "WTF::Function does not allow for reference / non-default
1744         constructible return types"
1745         https://bugs.webkit.org/show_bug.cgi?id=175244
1746         http://trac.webkit.org/changeset/220457
1747
1748 2017-08-09  Sam Weinig  <sam@webkit.org>
1749
1750         WTF::Function does not allow for reference / non-default constructible return types
1751         https://bugs.webkit.org/show_bug.cgi?id=175244
1752
1753         Reviewed by Chris Dumez.
1754
1755         When Function, then NoncopyableFunction, was templatized to allow non-void return values
1756         in r201493, it maintained the behavior of being callable even if the Function was null.
1757         To accomplish this, when null, the default construction of the return parameter was used.
1758         This means Function can't be used with return types that are not default constructible,
1759         such as reference types and Ref.
1760
1761         This behavior of returning something when null is surprising, as this is not how normal
1762         functions behave, and not very useful. Instead, we now assert that the function is not
1763         null when being called.
1764
1765         * wtf/Function.h:
1766         (WTF::Function operator(...)):
1767         Instead of allowing a null callable wrapper by returning the default construction of
1768         the return type, assert that the wrapper is there when calling a Function.
1769
1770 2017-08-08  Filip Pizlo  <fpizlo@apple.com>
1771
1772         Baseline JIT should do caging
1773         https://bugs.webkit.org/show_bug.cgi?id=175037
1774
1775         Reviewed by Mark Lam.
1776
1777         * wtf/Gigacage.h:
1778         (Gigacage::disableDisablingPrimitiveGigacageIfShouldBeEnabled):
1779         (Gigacage::isDisablingPrimitiveGigacageDisabled):
1780         (Gigacage::isPrimitiveGigacagePermanentlyEnabled):
1781         (Gigacage::canPrimitiveGigacageBeDisabled):
1782         (Gigacage::basePtr):
1783
1784 2017-08-08  Ryan Haddad  <ryanhaddad@apple.com>
1785
1786         Unreviewed, rolling out r220368.
1787
1788         This change caused WK1 tests to exit early with crashes.
1789
1790         Reverted changeset:
1791
1792         "Baseline JIT should do caging"
1793         https://bugs.webkit.org/show_bug.cgi?id=175037
1794         http://trac.webkit.org/changeset/220368
1795
1796 2017-08-08  Michael Catanzaro  <mcatanzaro@igalia.com>
1797
1798         [CMake] Properly test if compiler supports compiler flags
1799         https://bugs.webkit.org/show_bug.cgi?id=174490
1800
1801         Reviewed by Konstantin Tokarev.
1802
1803         * wtf/Compiler.h:
1804
1805 2017-08-07  Filip Pizlo  <fpizlo@apple.com>
1806
1807         Baseline JIT should do caging
1808         https://bugs.webkit.org/show_bug.cgi?id=175037
1809
1810         Reviewed by Mark Lam.
1811
1812         * wtf/Gigacage.h:
1813         (Gigacage::disableDisablingPrimitiveGigacageIfShouldBeEnabled):
1814         (Gigacage::isDisablingPrimitiveGigacageDisabled):
1815         (Gigacage::isPrimitiveGigacagePermanentlyEnabled):
1816         (Gigacage::canPrimitiveGigacageBeDisabled):
1817
1818 2017-08-07  Filip Pizlo  <fpizlo@apple.com>
1819
1820         Unreviewed, try to fix Windows build.
1821
1822         * wtf/Gigacage.cpp:
1823         * wtf/Gigacage.h:
1824
1825 2017-08-06  Filip Pizlo  <fpizlo@apple.com>
1826
1827         Primitive auxiliaries and JSValue auxiliaries should have separate gigacages
1828         https://bugs.webkit.org/show_bug.cgi?id=174919
1829
1830         Reviewed by Keith Miller.
1831         
1832         This mirrors the changes from bmalloc/Gigacage.h.
1833         
1834         Also it teaches CagedPtr how to reason about multiple gigacages.
1835
1836         * wtf/CagedPtr.h:
1837         (WTF::CagedPtr::get const):
1838         (WTF::CagedPtr::operator[] const):
1839         * wtf/Gigacage.cpp:
1840         (Gigacage::tryMalloc):
1841         (Gigacage::tryAllocateVirtualPages):
1842         (Gigacage::freeVirtualPages):
1843         (Gigacage::tryAlignedMalloc):
1844         (Gigacage::alignedFree):
1845         (Gigacage::free):
1846         * wtf/Gigacage.h:
1847         (Gigacage::disablePrimitiveGigacage):
1848         (Gigacage::addPrimitiveDisableCallback):
1849         (Gigacage::removePrimitiveDisableCallback):
1850         (Gigacage::name):
1851         (Gigacage::basePtr):
1852         (Gigacage::caged):
1853         (Gigacage::isCaged):
1854         (Gigacage::tryAlignedMalloc):
1855         (Gigacage::alignedFree):
1856         (Gigacage::free):
1857         (Gigacage::disableGigacage): Deleted.
1858         (Gigacage::addDisableCallback): Deleted.
1859         (Gigacage::removeDisableCallback): Deleted.
1860
1861 2017-08-07  Brian Burg  <bburg@apple.com>
1862
1863         Remove CANVAS_PATH compilation guard
1864         https://bugs.webkit.org/show_bug.cgi?id=175207
1865
1866         Reviewed by Sam Weinig.
1867
1868         * wtf/FeatureDefines.h:
1869
1870 2017-08-05  Filip Pizlo  <fpizlo@apple.com>
1871
1872         REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372
1873         https://bugs.webkit.org/show_bug.cgi?id=175083
1874
1875         Reviewed by Oliver Hunt.
1876         
1877         Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is
1878         guaranted to bias in favor of writers or not.
1879
1880         * WTF.xcodeproj/project.pbxproj:
1881         * wtf/Condition.h:
1882         (WTF::ConditionBase::construct):
1883         (WTF::Condition::Condition):
1884         * wtf/Lock.h:
1885         (WTF::LockBase::construct):
1886         (WTF::Lock::Lock):
1887         * wtf/ReadWriteLock.cpp: Added.
1888         (WTF::ReadWriteLockBase::construct):
1889         (WTF::ReadWriteLockBase::readLock):
1890         (WTF::ReadWriteLockBase::readUnlock):
1891         (WTF::ReadWriteLockBase::writeLock):
1892         (WTF::ReadWriteLockBase::writeUnlock):
1893         * wtf/ReadWriteLock.h: Added.
1894         (WTF::ReadWriteLockBase::ReadLock::tryLock):
1895         (WTF::ReadWriteLockBase::ReadLock::lock):
1896         (WTF::ReadWriteLockBase::ReadLock::unlock):
1897         (WTF::ReadWriteLockBase::WriteLock::tryLock):
1898         (WTF::ReadWriteLockBase::WriteLock::lock):
1899         (WTF::ReadWriteLockBase::WriteLock::unlock):
1900         (WTF::ReadWriteLockBase::read):
1901         (WTF::ReadWriteLockBase::write):
1902         (WTF::ReadWriteLock::ReadWriteLock):
1903
1904 2017-08-04  Matt Lewis  <jlewis3@apple.com>
1905
1906         Unreviewed, rolling out r220271.
1907
1908         Rolling out due to Layout Test failing on iOS Simulator.
1909
1910         Reverted changeset:
1911
1912         "Remove STREAMS_API compilation guard"
1913         https://bugs.webkit.org/show_bug.cgi?id=175165
1914         http://trac.webkit.org/changeset/220271
1915
1916 2017-08-04  Youenn Fablet  <youenn@apple.com>
1917
1918         Remove STREAMS_API compilation guard
1919         https://bugs.webkit.org/show_bug.cgi?id=175165
1920
1921         Reviewed by Darin Adler.
1922
1923         * wtf/FeatureDefines.h:
1924
1925 2017-08-03  Brian Burg  <bburg@apple.com>
1926
1927         Remove ENABLE(WEB_SOCKET) guards
1928         https://bugs.webkit.org/show_bug.cgi?id=167044
1929
1930         Reviewed by Joseph Pecoraro.
1931
1932         * wtf/FeatureDefines.h:
1933
1934 2017-08-03  Youenn Fablet  <youenn@apple.com>
1935
1936         Remove FETCH_API compilation guard
1937         https://bugs.webkit.org/show_bug.cgi?id=175154
1938
1939         Reviewed by Chris Dumez.
1940
1941         * wtf/FeatureDefines.h:
1942
1943 2017-08-03  Brady Eidson  <beidson@apple.com>
1944
1945         Add SW IDLs and stub out basic functionality.
1946         https://bugs.webkit.org/show_bug.cgi?id=175115
1947
1948         Reviewed by Chris Dumez.
1949
1950         * wtf/FeatureDefines.h:
1951
1952 2017-08-03  Yusuke Suzuki  <utatane.tea@gmail.com>
1953
1954         Unreviewed, build fix for Windows port
1955         https://bugs.webkit.org/show_bug.cgi?id=175013
1956
1957         * wtf/Threading.h:
1958
1959 2017-08-03  Yusuke Suzuki  <utatane.tea@gmail.com>
1960
1961         Merge ThreadHolder to WTF::Thread itself
1962         https://bugs.webkit.org/show_bug.cgi?id=175013
1963
1964         Reviewed by Mark Lam.
1965
1966         Currently, we store ThreadHolder* to the TLS, and ThreadHolder* holds Ref<Thread>.
1967         When we get Thread& from the current thread TLS, we need to dereference the ThreadHolder*.
1968         However, ideally, we can store Thread* directly to the current thread TLS.
1969         While the ThreadHolder design is beautiful, it's worth optimizing by storing Thread* directly
1970         since Thread::current() is so frequently executed.
1971
1972         This patch merges ThreadHolder to Thread. And we now store Thread* directly in the TLS.
1973         When storing it to TLS, we call leakRef() to keep Thread ref count incremented by the TLS.
1974         And when destroying the TLS, we call `deref()` to ensure that Thread* is dereferenced from
1975         the TLS.
1976
1977         * WTF.xcodeproj/project.pbxproj:
1978         * wtf/CMakeLists.txt:
1979         * wtf/ThreadHolder.cpp: Removed.
1980         * wtf/ThreadHolder.h: Removed.
1981         * wtf/ThreadHolderPthreads.cpp: Removed.
1982         * wtf/ThreadHolderWin.cpp: Removed.
1983         * wtf/Threading.cpp:
1984         (WTF::Thread::entryPoint):
1985         (WTF::initializeThreading):
1986         * wtf/Threading.h:
1987         (WTF::Thread::currentMayBeNull):
1988         (WTF::Thread::current):
1989         * wtf/ThreadingPthreads.cpp:
1990         (WTF::Thread::waitForCompletion):
1991         (WTF::Thread::initializeCurrentTLS):
1992         (WTF::Thread::initializeTLSKey):
1993         (WTF::Thread::initializeTLS):
1994         (WTF::Thread::destructTLS):
1995         (WTF::Thread::createCurrentThread): Deleted.
1996         * wtf/ThreadingWin.cpp:
1997         (WTF::Thread::initializeCurrentTLS):
1998         (WTF::threadMapMutex):
1999         (WTF::Thread::initializeTLSKey):
2000         (WTF::Thread::currentDying):
2001         (WTF::Thread::get):
2002         (WTF::Thread::initializeTLS):
2003         (WTF::Thread::destructTLS):
2004         (WTF::waitForThreadCompletion):
2005         (WTF::Thread::createCurrentThread): Deleted.
2006
2007 2017-08-03  Yusuke Suzuki  <utatane.tea@gmail.com>
2008
2009         [Linux][WTF] Use one global semaphore to notify thread suspend and resume completion
2010         https://bugs.webkit.org/show_bug.cgi?id=175124
2011
2012         Reviewed by Carlos Garcia Campos.
2013
2014         POSIX sem_t is used to notify thread suspend and resume completion in Linux ports
2015         since sem_post is async-signal-safe function. Since we guard suspend() and resume()
2016         with one global lock, this semaphore is also guarded by this lock. So we do not need
2017         to have semaphore per WTF::Thread.
2018
2019         This patch introduces one global Semaphore. And drop per thread semaphore.
2020
2021         * wtf/Threading.h:
2022         * wtf/ThreadingPthreads.cpp:
2023         (WTF::Thread::~Thread):
2024         (WTF::Semaphore::Semaphore):
2025         (WTF::Semaphore::~Semaphore):
2026         (WTF::Semaphore::wait):
2027         (WTF::Semaphore::post):
2028         (WTF::Thread::signalHandlerSuspendResume):
2029         (WTF::Thread::initializePlatformThreading):
2030         (WTF::Thread::suspend):
2031         (WTF::Thread::resume):
2032         (WTF::Thread::Thread): Deleted.
2033         * wtf/ThreadingWin.cpp:
2034         (WTF::Thread::Thread): Deleted.
2035
2036 2017-08-03  Yusuke Suzuki  <utatane.tea@gmail.com>
2037
2038         [Linux][WTF] Reduce sizeof(WTF::Thread) by using a pointer to PlatformRegisters
2039         https://bugs.webkit.org/show_bug.cgi?id=175119
2040
2041         Reviewed by Carlos Garcia Campos.
2042
2043         sizeof(PlatformRegisters) is so large. In my Linux box, it is 256. It enlarges the sizeof(WTF::Thread).
2044         However, it is not necessary to hold it in WTF::Thread member. Thread's ucontext data and its stack is
2045         effective while suspending the thread. So, we can just use the pointer to the PlatformRegister instead
2046         of copying it to the member of the WTF::Thread.
2047
2048         * wtf/Threading.h:
2049         * wtf/ThreadingPthreads.cpp:
2050         (WTF::Thread::signalHandlerSuspendResume):
2051         (WTF::Thread::getRegisters):
2052
2053 2017-08-02  Yusuke Suzuki  <utatane.tea@gmail.com>
2054
2055         Unreviewed, build fix for Windows port
2056         https://bugs.webkit.org/show_bug.cgi?id=174716
2057
2058         This ugliness will be fixed in https://bugs.webkit.org/show_bug.cgi?id=175013.
2059
2060         * wtf/ThreadHolder.h:
2061         * wtf/Threading.h:
2062
2063 2017-08-02  Yusuke Suzuki  <utatane.tea@gmail.com>
2064
2065         Merge WTFThreadData to Thread::current
2066         https://bugs.webkit.org/show_bug.cgi?id=174716
2067
2068         Reviewed by Mark Lam.
2069
2070         We placed thread specific data in WTFThreadData previously. But now, we have a new good place
2071         to put thread specific data: WTF::Thread. Before this patch, WTFThreadData and WTF::Thread
2072         sometimes have the completely same fields (m_stack etc.) due to initialization order limitations.
2073         This patch merges WTFThreadData to WTF::Thread. We apply WTFThreadData's initialization style
2074         to WTF::Thread. So, WTF::Thread's holder now uses fast TLS for darwin environment. Thus,
2075         Thread::current() access is now accelerated. And WTF::Thread::current() can be accessed even
2076         before calling WTF::initializeThreading.
2077
2078         * WTF.xcodeproj/project.pbxproj:
2079         * wtf/CMakeLists.txt:
2080         * wtf/LockAlgorithm.h:
2081         * wtf/LockAlgorithmInlines.h:
2082         * wtf/MainThread.h:
2083         * wtf/ParkingLot.cpp:
2084         * wtf/StackStats.cpp:
2085         (WTF::StackStats::PerThreadStats::PerThreadStats):
2086         (WTF::StackStats::CheckPoint::CheckPoint):
2087         (WTF::StackStats::CheckPoint::~CheckPoint):
2088         (WTF::StackStats::probe):
2089         (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
2090         * wtf/ThreadHolder.cpp:
2091         (WTF::ThreadHolder::initializeCurrent):
2092         * wtf/ThreadHolder.h:
2093         (WTF::ThreadHolder::ThreadHolder):
2094         (WTF::ThreadHolder::currentMayBeNull):
2095         (WTF::ThreadHolder::current):
2096         * wtf/ThreadHolderPthreads.cpp:
2097         (WTF::ThreadHolder::initializeKey):
2098         (WTF::ThreadHolder::initialize):
2099         (WTF::ThreadHolder::destruct):
2100         (WTF::ThreadHolder::initializeOnce): Deleted.
2101         (WTF::ThreadHolder::current): Deleted.
2102         * wtf/ThreadHolderWin.cpp:
2103         (WTF::ThreadHolder::initializeKey):
2104         (WTF::ThreadHolder::currentDying):
2105         (WTF::ThreadHolder::initialize):
2106         (WTF::ThreadHolder::initializeOnce): Deleted.
2107         (WTF::ThreadHolder::current): Deleted.
2108         * wtf/Threading.cpp:
2109         (WTF::Thread::initializeInThread):
2110         (WTF::Thread::entryPoint):
2111         (WTF::Thread::create):
2112         (WTF::Thread::didExit):
2113         (WTF::initializeThreading):
2114         (WTF::Thread::currentMayBeNull): Deleted.
2115         * wtf/Threading.h:
2116         (WTF::Thread::current):
2117         (WTF::Thread::atomicStringTable):
2118         (WTF::Thread::setCurrentAtomicStringTable):
2119         (WTF::Thread::stackStats):
2120         (WTF::Thread::savedStackPointerAtVMEntry):
2121         (WTF::Thread::setSavedStackPointerAtVMEntry):
2122         (WTF::Thread::savedLastStackTop):
2123         (WTF::Thread::setSavedLastStackTop):
2124         * wtf/ThreadingPrimitives.h:
2125         * wtf/ThreadingPthreads.cpp:
2126         (WTF::Thread::createCurrentThread):
2127         (WTF::Thread::current): Deleted.
2128         * wtf/ThreadingWin.cpp:
2129         (WTF::Thread::createCurrentThread):
2130         (WTF::Thread::current): Deleted.
2131         * wtf/WTFThreadData.cpp: Removed.
2132         * wtf/WTFThreadData.h: Removed.
2133         * wtf/text/AtomicString.cpp:
2134         * wtf/text/AtomicStringImpl.cpp:
2135         (WTF::stringTable):
2136         * wtf/text/AtomicStringTable.cpp:
2137         (WTF::AtomicStringTable::create):
2138         * wtf/text/AtomicStringTable.h:
2139
2140 2017-08-02  Joseph Pecoraro  <pecoraro@apple.com>
2141
2142         NeverDestroyed related leaks seen on bots
2143         https://bugs.webkit.org/show_bug.cgi?id=175113
2144
2145         Reviewed by Yusuke Suzuki.
2146
2147         * wtf/NeverDestroyed.h:
2148         (WTF::NeverDestroyed::NeverDestroyed):
2149         Previously the result of makeNeverDestroyed was not always moving into
2150         the `static NeverDestroyed` static local variable. In some cases it would
2151         re-invoke the constructor, creating a new NeverDestroyed object. In the
2152         case of a Vector it was causing leaks.
2153
2154         Adding a move constructor convinces the compiler to move the result
2155         of makeNeverDestroyed into the NeverDestroyed static. It doesn't actually
2156         invoke the move constructor here, which I believe means it is deciding
2157         to perform optional copy elision optimization.
2158         'http://en.cppreference.com/w/cpp/language/copy_elision
2159
2160 2017-08-02  Filip Pizlo  <fpizlo@apple.com>
2161
2162         All C++ accesses to JSObject::m_butterfly should do caging
2163         https://bugs.webkit.org/show_bug.cgi?id=175039
2164
2165         Reviewed by Keith Miller.
2166         
2167         Adds a smart pointer class that does various kinds of caging for you.
2168
2169         * WTF.xcodeproj/project.pbxproj:
2170         * wtf/CMakeLists.txt:
2171         * wtf/CagedPtr.h: Added.
2172         (WTF::CagedPtr::CagedPtr):
2173         (WTF::CagedPtr::get const):
2174         (WTF::CagedPtr::getMayBeNull const):
2175         (WTF::CagedPtr::operator== const):
2176         (WTF::CagedPtr::operator!= const):
2177         (WTF::CagedPtr::operator bool const):
2178         (WTF::CagedPtr::operator* const):
2179         (WTF::CagedPtr::operator-> const):
2180
2181 2017-08-02  Filip Pizlo  <fpizlo@apple.com>
2182
2183         We should be OK with the gigacage being disabled on gmalloc
2184         https://bugs.webkit.org/show_bug.cgi?id=175082
2185
2186         Reviewed by Michael Saboff.
2187
2188         * wtf/Gigacage.h:
2189         (Gigacage::shouldBeEnabled):
2190
2191 2017-08-01  Filip Pizlo  <fpizlo@apple.com>
2192
2193         Bmalloc and GC should put auxiliaries (butterflies, typed array backing stores) in a gigacage (separate multi-GB VM region)
2194         https://bugs.webkit.org/show_bug.cgi?id=174727
2195
2196         Reviewed by Mark Lam.
2197         
2198         For the Gigacage project to have minimal impact, we need to have some abstraction that allows code to
2199         avoid having to guard itself with #if's. This adds a Gigacage abstraction that overlays the Gigacage
2200         namespace from bmalloc, which always lets you call things like Gigacage::caged and Gigacage::tryMalloc.
2201         
2202         Because of how many places need to possibly allocate in a gigacage, or possibly perform caged accesses,
2203         it's better to hide the question of whether or not it's enabled inside this API.
2204
2205         * WTF.xcodeproj/project.pbxproj:
2206         * wtf/CMakeLists.txt:
2207         * wtf/FastMalloc.cpp:
2208         * wtf/Gigacage.cpp: Added.
2209         (Gigacage::tryMalloc):
2210         (Gigacage::tryAllocateVirtualPages):
2211         (Gigacage::freeVirtualPages):
2212         (Gigacage::tryAlignedMalloc):
2213         (Gigacage::alignedFree):
2214         (Gigacage::free):
2215         * wtf/Gigacage.h: Added.
2216         (Gigacage::ensureGigacage):
2217         (Gigacage::disableGigacage):
2218         (Gigacage::addDisableCallback):
2219         (Gigacage::removeDisableCallback):
2220         (Gigacage::caged):
2221         (Gigacage::isCaged):
2222         (Gigacage::tryAlignedMalloc):
2223         (Gigacage::alignedFree):
2224         (Gigacage::free):
2225
2226 2017-07-31  Matt Lewis  <jlewis3@apple.com>
2227
2228         Unreviewed, rolling out r220060.
2229
2230         This broke our internal builds. Contact reviewer of patch for
2231         more information.
2232
2233         Reverted changeset:
2234
2235         "Merge WTFThreadData to Thread::current"
2236         https://bugs.webkit.org/show_bug.cgi?id=174716
2237         http://trac.webkit.org/changeset/220060
2238
2239 2017-07-31  Yusuke Suzuki  <utatane.tea@gmail.com>
2240
2241         Merge WTFThreadData to Thread::current
2242         https://bugs.webkit.org/show_bug.cgi?id=174716
2243
2244         Reviewed by Sam Weinig.
2245
2246         We placed thread specific data in WTFThreadData previously. But now, we have a new good place
2247         to put thread specific data: WTF::Thread. Before this patch, WTFThreadData and WTF::Thread
2248         sometimes have the completely same fields (m_stack etc.) due to initialization order limitations.
2249         This patch merges WTFThreadData to WTF::Thread. We apply WTFThreadData's initialization style
2250         to WTF::Thread. So, WTF::Thread's holder now uses fast TLS for darwin environment. Thus,
2251         Thread::current() access is now accelerated. And WTF::Thread::current() can be accessed even
2252         before calling WTF::initializeThreading.
2253
2254         * WTF.xcodeproj/project.pbxproj:
2255         * wtf/CMakeLists.txt:
2256         * wtf/LockAlgorithm.h:
2257         * wtf/LockAlgorithmInlines.h:
2258         * wtf/MainThread.h:
2259         * wtf/ParkingLot.cpp:
2260         * wtf/StackStats.cpp:
2261         (WTF::StackStats::PerThreadStats::PerThreadStats):
2262         (WTF::StackStats::CheckPoint::CheckPoint):
2263         (WTF::StackStats::CheckPoint::~CheckPoint):
2264         (WTF::StackStats::probe):
2265         (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
2266         * wtf/ThreadHolder.cpp:
2267         (WTF::ThreadHolder::initializeCurrent):
2268         * wtf/ThreadHolder.h:
2269         (WTF::ThreadHolder::ThreadHolder):
2270         (WTF::ThreadHolder::currentMayBeNull):
2271         (WTF::ThreadHolder::current):
2272         * wtf/ThreadHolderPthreads.cpp:
2273         (WTF::ThreadHolder::initialize):
2274         (WTF::ThreadHolder::destruct):
2275         (WTF::ThreadHolder::current): Deleted.
2276         * wtf/ThreadHolderWin.cpp:
2277         (WTF::ThreadHolder::currentDying):
2278         (WTF::ThreadHolder::initialize):
2279         (WTF::ThreadHolder::current): Deleted.
2280         * wtf/Threading.cpp:
2281         (WTF::Thread::initializeInThread):
2282         (WTF::Thread::entryPoint):
2283         (WTF::Thread::didExit):
2284         (WTF::initializeThreading):
2285         (WTF::Thread::currentMayBeNull): Deleted.
2286         * wtf/Threading.h:
2287         (WTF::Thread::atomicStringTable):
2288         (WTF::Thread::setCurrentAtomicStringTable):
2289         (WTF::Thread::stackStats):
2290         (WTF::Thread::savedStackPointerAtVMEntry):
2291         (WTF::Thread::setSavedStackPointerAtVMEntry):
2292         (WTF::Thread::savedLastStackTop):
2293         (WTF::Thread::setSavedLastStackTop):
2294         (WTF::Thread::current):
2295         * wtf/ThreadingPrimitives.h:
2296         * wtf/ThreadingPthreads.cpp:
2297         (WTF::Thread::createCurrentThread):
2298         (WTF::Thread::current): Deleted.
2299         * wtf/ThreadingWin.cpp:
2300         (WTF::Thread::createCurrentThread):
2301         (WTF::Thread::current): Deleted.
2302         * wtf/WTFThreadData.cpp: Removed.
2303         * wtf/WTFThreadData.h: Removed.
2304         * wtf/text/AtomicString.cpp:
2305         * wtf/text/AtomicStringImpl.cpp:
2306         (WTF::stringTable):
2307         * wtf/text/AtomicStringTable.cpp:
2308         (WTF::AtomicStringTable::create):
2309         * wtf/text/AtomicStringTable.h:
2310
2311 2017-07-31  Xabier Rodriguez Calvar  <calvaris@igalia.com>
2312
2313         Created a bool pretty printer at WTF for debugging purposes
2314         https://bugs.webkit.org/show_bug.cgi?id=174893
2315
2316         Reviewed by Darin Adler.
2317
2318         * wtf/PrintStream.cpp:
2319         (WTF::printInternal): The overload taking bool uses boolForPrinting
2320         * wtf/PrintStream.h:
2321         (WTF::boolForPrinting): Converts a bool in "true" or "false".
2322
2323 2017-07-30  Yusuke Suzuki  <utatane.tea@gmail.com>
2324
2325         [WTF] Introduce Private Symbols
2326         https://bugs.webkit.org/show_bug.cgi?id=174935
2327
2328         Reviewed by Darin Adler.
2329
2330         Upcoming proposal of class fields[1] requires private fields.
2331         The simple way to implement it is adding a property with a private symbol.
2332         Currently, we have private symbols for internal properties. They are usual
2333         Symbols managed by the hash table. So basically private symbols are statically
2334         created in BuiltinNames. However this new proposal encourages users to create
2335         such private symbols more and more.
2336
2337         So, this patch introduces notion of "Private" into WTF SymbolImpl. This patch
2338         adds PrivateSymbolImpl. This is SymbolImpl with "Private" flag. We do not need
2339         to look up the symbol from the hash table to check whether the given symbol
2340         is a private one.
2341
2342         [1]: https://github.com/tc39/proposal-class-fields
2343
2344         * wtf/text/StringImpl.h:
2345         * wtf/text/SymbolImpl.cpp:
2346         (WTF::PrivateSymbolImpl::create):
2347         (WTF::PrivateSymbolImpl::createNullSymbol):
2348         * wtf/text/SymbolImpl.h:
2349         (WTF::SymbolImpl::isPrivate):
2350         (WTF::SymbolImpl::StaticSymbolImpl::StaticSymbolImpl):
2351         (WTF::SymbolImpl::SymbolImpl):
2352         (WTF::PrivateSymbolImpl::PrivateSymbolImpl):
2353
2354 2017-07-30  Brady Eidson  <beidson@apple.com>
2355
2356         Add URLSchemeHandler API tests that verify the lack of URLSchemeTask object leaks.
2357         https://bugs.webkit.org/show_bug.cgi?id=174958
2358
2359         Reviewed by Darin Adler.
2360
2361         This patch adds a new template class "InstanceCounted<T>".
2362         
2363         For each specialization, "InstanceCounted" will keep track of the total number of
2364         instances in existence.
2365         
2366         This makes explicate leak checking in API tests possible.
2367         
2368         Since this adds some runtime and storage overhead the code that actually does anything
2369         is only compiled in debug builds.
2370         
2371         * WTF.xcodeproj/project.pbxproj:
2372         * wtf/InstanceCounted.h: Added.
2373         (WTF::InstanceCounted::InstanceCounted):
2374         (WTF::InstanceCounted::instanceCount):
2375         (WTF::InstanceCounted::~InstanceCounted):
2376
2377 2017-07-27  Yusuke Suzuki  <utatane.tea@gmail.com>
2378
2379         [WTF] Drop Thread initialization wait in some platforms by introducing StackBounds::newThreadStackBounds(PlatformThreadHandle&)
2380         https://bugs.webkit.org/show_bug.cgi?id=174303
2381
2382         Reviewed by Mark Lam.
2383
2384         Currently, the caller thread of Thread::create() need to wait for completion of the initialization of the target thread.
2385         This is because we need to initialize Thread::m_stack in the target thread. Before this patch, a target thread's
2386         StackBounds can only be retrieved by the target thread itself. However, this potentially causes context-switching between
2387         the caller and the target threads and hurts efficiency of creating threads.
2388
2389         Fortunately, in some platforms (including major platforms except for Windows), we can get StackBounds of a target
2390         thread from a caller thread. This allows us to avoid waiting for completion of thread initialization.
2391
2392         In this patch, we introduce HAVE_STACK_BOUNDS_FOR_NEW_THREAD and StackBounds::newThreadStackBounds. When creating
2393         a new thread, we will use StackBounds::newThreadStackBounds to get StackBounds if possible. As a result, we
2394         do not need to wait for completion of thread initialization to ensure m_stack field of Thread is initialized.
2395
2396         While some documents claim that it is possible on Windows to get the StackBounds of another thread[1], the method relies on
2397         undocumented Windows NT APIs (NtQueryInformationThread, NtReadVirtualMemory etc.). So in this patch, we just
2398         use the conservative approach simply waiting for completion of thread initialization.
2399
2400         [1]: https://stackoverflow.com/questions/3918375/how-to-get-thread-stack-information-on-windows
2401
2402         * wtf/Platform.h:
2403         * wtf/StackBounds.cpp:
2404         (WTF::StackBounds::newThreadStackBounds):
2405         (WTF::StackBounds::currentThreadStackBoundsInternal):
2406         (WTF::StackBounds::initialize): Deleted.
2407         * wtf/StackBounds.h:
2408         (WTF::StackBounds::currentThreadStackBounds):
2409         (WTF::StackBounds::StackBounds):
2410         * wtf/Threading.cpp:
2411         (WTF::Thread::NewThreadContext::NewThreadContext):
2412         (WTF::Thread::entryPoint):
2413         (WTF::Thread::create):
2414         (WTF::Thread::initialize): Deleted.
2415         * wtf/Threading.h:
2416         * wtf/ThreadingPrimitives.h:
2417         * wtf/ThreadingPthreads.cpp:
2418         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
2419         (WTF::wtfThreadEntryPoint):
2420         (WTF::Thread::establishHandle):
2421         (WTF::Thread::initializeCurrentThreadInternal):
2422         (WTF::Thread::current):
2423         * wtf/ThreadingWin.cpp:
2424         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
2425         (WTF::Thread::initializeCurrentThreadInternal):
2426         (WTF::Thread::current):
2427         * wtf/win/MainThreadWin.cpp:
2428         (WTF::initializeMainThreadPlatform):
2429
2430 2017-07-27  JF Bastien  <jfbastien@apple.com>
2431
2432         Update lock benchmarks
2433         https://bugs.webkit.org/show_bug.cgi?id=174907
2434
2435         Reviewed by Filip Pizlo.
2436
2437         * benchmarks/ConditionSpeedTest.cpp:
2438         (main):
2439         * benchmarks/LockFairnessTest.cpp:
2440         * benchmarks/LockSpeedTest.cpp:
2441         * benchmarks/ToyLocks.h:
2442
2443 2017-07-26  Brian Burg  <bburg@apple.com>
2444
2445         Remove WEB_TIMING feature flag
2446         https://bugs.webkit.org/show_bug.cgi?id=174795
2447
2448         Reviewed by Alex Christensen.
2449
2450         * wtf/FeatureDefines.h:
2451
2452 2017-07-26  Claudio Saavedra  <csaavedra@igalia.com>
2453
2454         [WPE] Enable KeyboardEvent key and code attributes
2455         https://bugs.webkit.org/show_bug.cgi?id=174822
2456
2457         Reviewed by Žan Doberšek.
2458
2459         There is no reason for this to be disabled from what I see.
2460
2461         * wtf/FeatureDefines.h: Enable KeyboardEvent key and code attributes.
2462
2463 2017-07-23  Filip Pizlo  <fpizlo@apple.com>
2464
2465         B3 should do LICM
2466         https://bugs.webkit.org/show_bug.cgi?id=174750
2467
2468         Reviewed by Keith Miller and Saam Barati.
2469         
2470         Moved DFG::NaturalLoops to WTF. The new templatized NaturalLoops<> uses the same Graph abstraction as
2471         Dominators<>. This allows us to add a B3::NaturalLoops for free.
2472         
2473         Also made small tweaks to RangeSet, which the LICM uses.
2474
2475         * WTF.xcodeproj/project.pbxproj:
2476         * wtf/CMakeLists.txt:
2477         * wtf/Dominators.h:
2478         * wtf/NaturalLoops.h: Added.
2479         (WTF::NaturalLoop::NaturalLoop):
2480         (WTF::NaturalLoop::graph):
2481         (WTF::NaturalLoop::header):
2482         (WTF::NaturalLoop::size):
2483         (WTF::NaturalLoop::at):
2484         (WTF::NaturalLoop::operator[]):
2485         (WTF::NaturalLoop::contains):
2486         (WTF::NaturalLoop::index):
2487         (WTF::NaturalLoop::isOuterMostLoop):
2488         (WTF::NaturalLoop::dump):
2489         (WTF::NaturalLoop::addBlock):
2490         (WTF::NaturalLoops::NaturalLoops):
2491         (WTF::NaturalLoops::graph):
2492         (WTF::NaturalLoops::numLoops):
2493         (WTF::NaturalLoops::loop):
2494         (WTF::NaturalLoops::headerOf):
2495         (WTF::NaturalLoops::innerMostLoopOf):
2496         (WTF::NaturalLoops::innerMostOuterLoop):
2497         (WTF::NaturalLoops::belongsTo):
2498         (WTF::NaturalLoops::loopDepth):
2499         (WTF::NaturalLoops::loopsOf):
2500         (WTF::NaturalLoops::dump):
2501         * wtf/RangeSet.h:
2502         (WTF::RangeSet::begin):
2503         (WTF::RangeSet::end):
2504         (WTF::RangeSet::addAll):
2505
2506 2017-07-23  Michael Catanzaro  <mcatanzaro@igalia.com>
2507
2508         Implement FALLTHROUGH attribute for C with GCC
2509         https://bugs.webkit.org/show_bug.cgi?id=174555
2510
2511         Reviewed by Darin Adler.
2512
2513         My previous attempt to silence the JSC -Wimplicit-fallthrough warnings failed because they
2514         are coming from a C file, and our FALLTHROUGH macro is only implemented for C++. So
2515         implement it for C as well, using C attribute syntax.
2516  
2517         Note this is only possible to do for GCC, because Clang only supports this attribute using
2518         the [[C++ attribute syntax]].
2519
2520         * wtf/Compiler.h:
2521
2522 2017-07-14  Filip Pizlo  <fpizlo@apple.com>
2523
2524         It should be easy to decide how WebKit yields
2525         https://bugs.webkit.org/show_bug.cgi?id=174298
2526
2527         Reviewed by Saam Barati.
2528         
2529         Created a Thread::yield() abstraction for sched_yield(), and made WTF use it everywhere that it
2530         had previously used std::this_thread::yield().
2531         
2532         To make it less annoying to experiment with changes to the lock algorithm in the future, this also
2533         moves the meat of the algorithm into LockAlgorithmInlines.h. Only two files include that header.
2534         Since LockAlgorithm.h no longer includes ParkingLot.h, a bunch of files in WK now need to include
2535         timing headers (Seconds, MonotonicTime, etc) manually.
2536
2537         * WTF.xcodeproj/project.pbxproj:
2538         * benchmarks/ToyLocks.h:
2539         * wtf/CMakeLists.txt:
2540         * wtf/Lock.cpp:
2541         * wtf/LockAlgorithm.h:
2542         (WTF::LockAlgorithm::lockSlow): Deleted.
2543         (WTF::LockAlgorithm::unlockSlow): Deleted.
2544         * wtf/LockAlgorithmInlines.h: Added.
2545         (WTF::hasParkedBit>::lockSlow):
2546         (WTF::hasParkedBit>::unlockSlow):
2547         * wtf/MainThread.cpp:
2548         * wtf/RunLoopTimer.h:
2549         * wtf/Threading.cpp:
2550         * wtf/Threading.h:
2551         * wtf/ThreadingPthreads.cpp:
2552         (WTF::Thread::yield):
2553         * wtf/ThreadingWin.cpp:
2554         (WTF::Thread::yield):
2555         * wtf/WordLock.cpp:
2556         (WTF::WordLockBase::lockSlow):
2557         (WTF::WordLockBase::unlockSlow):
2558
2559 2017-07-22  Yusuke Suzuki  <utatane.tea@gmail.com>
2560
2561         [WTF] Extend ThreadGroup::add results from bool to ThreadGroupAddResult
2562         https://bugs.webkit.org/show_bug.cgi?id=174705
2563
2564         Reviewed by Mark Lam.
2565
2566         After starting using ThreadGroup to bookkeep active threads for Signals,
2567         we would like to know tristate of ThreadGroup::add result, NewlyAdded, AlreadyAdded, NotAdded.
2568         This patch extends the result of ThreadGroup::add from bool to ThreadGroupAddResult tristate.
2569         Note that NotAdded is returned if the target thread is dying.
2570
2571         * wtf/ThreadGroup.cpp:
2572         (WTF::ThreadGroup::add):
2573         (WTF::ThreadGroup::addCurrentThread):
2574         * wtf/ThreadGroup.h:
2575         * wtf/Threading.cpp:
2576         (WTF::Thread::addToThreadGroup):
2577         * wtf/Threading.h:
2578         * wtf/threads/Signals.cpp:
2579         (WTF::registerThreadForMachExceptionHandling):
2580
2581 2017-07-21  Commit Queue  <commit-queue@webkit.org>
2582
2583         Unreviewed, rolling out r219732.
2584         https://bugs.webkit.org/show_bug.cgi?id=174748
2585
2586         static is not threadsafe in WebKit tree (Requested by
2587         yusukesuzuki on #webkit).
2588
2589         Reverted changeset:
2590
2591         "[WTF] Drop initializeDate"
2592         https://bugs.webkit.org/show_bug.cgi?id=174714
2593         http://trac.webkit.org/changeset/219732
2594
2595 2017-07-21  Yusuke Suzuki  <utatane.tea@gmail.com>
2596
2597         [WTF] Drop initializeDate
2598         https://bugs.webkit.org/show_bug.cgi?id=174714
2599
2600         Reviewed by Darin Adler.
2601
2602         minYear static variable will be initialized in an exclusive manner, which is ensured by C++ "static" semantics.
2603         Thus, we do not need to call initializeDate() explicitly.
2604
2605         * wtf/DateMath.cpp:
2606         (WTF::equivalentYearForDST):
2607         (WTF::initializeDates): Deleted.
2608         * wtf/Threading.cpp:
2609         (WTF::initializeThreading):
2610
2611 2017-07-21  Yusuke Suzuki  <utatane.tea@gmail.com>
2612
2613         [JSC] Introduce static symbols
2614         https://bugs.webkit.org/show_bug.cgi?id=158863
2615
2616         Reviewed by Darin Adler.
2617
2618         We add a new class StaticSymbolImpl. StaticSymbolImpl can offer
2619         the way to create static SymbolImpl. It can be shared between
2620         multiple VMs and multiple threads.
2621
2622         * wtf/text/SymbolImpl.h:
2623         (WTF::SymbolImpl::StaticSymbolImpl::StaticSymbolImpl):
2624         (WTF::SymbolImpl::StaticSymbolImpl::operator SymbolImpl&):
2625         For StaticSymbolImpl's hashForSymbol, we use usual string hash value.
2626         Since all the SymbolImpls are unique, basically, any value is OK here.
2627         Non-confilicting to the other SymbolImpls is ideal.
2628
2629 2017-07-21  Yusuke Suzuki  <utatane.tea@gmail.com>
2630
2631         [WTF] Newly added AtomicStringImpl should use BufferInternal static string if StringImpl is static
2632         https://bugs.webkit.org/show_bug.cgi?id=174501
2633
2634         Reviewed by Darin Adler.
2635
2636         When creating AtomicStringImpl from static StringImpl, we can just use createWithoutCopying
2637         to create a BufferInternal AtomicStringImpl which m_data{8,16} is static string's one.
2638
2639         * wtf/text/AtomicStringImpl.cpp:
2640         (WTF::CStringTranslator::hash):
2641         (WTF::CStringTranslator::equal):
2642         (WTF::CStringTranslator::translate):
2643         (WTF::AtomicStringImpl::add):
2644         (WTF::HashTranslatorCharBuffer::HashTranslatorCharBuffer):
2645         (WTF::UCharBufferTranslator::hash):
2646         (WTF::UCharBufferTranslator::equal):
2647         (WTF::UCharBufferTranslator::translate):
2648         (WTF::LCharBufferTranslator::hash):
2649         (WTF::LCharBufferTranslator::equal):
2650         (WTF::LCharBufferTranslator::translate):
2651         (WTF::BufferFromStaticDataTranslator::hash):
2652         (WTF::BufferFromStaticDataTranslator::equal):
2653         (WTF::BufferFromStaticDataTranslator::translate):
2654         (WTF::AtomicStringImpl::addLiteral):
2655         (WTF::addSymbol):
2656         (WTF::addStatic):
2657         (WTF::AtomicStringImpl::addSlowCase):
2658         (WTF::AtomicStringImpl::lookUp):
2659         (WTF::CharBufferFromLiteralDataTranslator::hash): Deleted.
2660         (WTF::CharBufferFromLiteralDataTranslator::equal): Deleted.
2661         (WTF::CharBufferFromLiteralDataTranslator::translate): Deleted.
2662         (WTF::addSubstring): Deleted.
2663         * wtf/text/StringImpl.h:
2664
2665 2017-07-21  Konstantin Tokarev  <annulen@yandex.ru>
2666
2667        [cmake] Unreviewed, add definitions necessary to use ICU shipped with macOS
2668
2669        macOS system ICU libraries are built with U_DISABLE_RENAMING=1 and
2670        U_SHOW_CPLUSPLUS_API=0. After r219155 we have to pass this definitons
2671        explicitly, because ICU headers in the tree are not modified anymore.
2672
2673         * wtf/PlatformMac.cmake: Rely on ICU_LIBRARIES instead of passing ICU
2674         library name explicitly in WTF_LIBRARIES.
2675
2676 2017-07-20  Chris Dumez  <cdumez@apple.com>
2677
2678         Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable
2679         https://bugs.webkit.org/show_bug.cgi?id=174660
2680
2681         Reviewed by Geoffrey Garen.
2682
2683         Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable.
2684         This essentially replaces a branch to figure out if the new size is less or greater than the
2685         current size by an assertion.
2686
2687         * wtf/IndexSparseSet.h:
2688         (WTF::OverflowHandler>::IndexSparseSet):
2689         (WTF::OverflowHandler>::clear):
2690         * wtf/Insertion.h:
2691         (WTF::executeInsertions):
2692         * wtf/RangeSet.h:
2693         (WTF::RangeSet::compact):
2694         * wtf/Vector.h:
2695         (WTF::removeRepeatedElements):
2696         * wtf/persistence/Coders.h:
2697
2698 2017-07-20  Yusuke Suzuki  <utatane.tea@gmail.com>
2699
2700         [WTF] Use ThreadGroup to bookkeep active threads for Mach exception
2701         https://bugs.webkit.org/show_bug.cgi?id=174678
2702
2703         Reviewed by Mark Lam.
2704
2705         We can use ThreadGroup to bookkeep active threads for Mach exceptions.
2706         When the thread dies, it is automatically removed from the thread groups.
2707         So we do not need to call unregisterThreadForMachExceptionHandling.
2708
2709         * wtf/ThreadGroup.cpp:
2710         (WTF::ThreadGroup::~ThreadGroup):
2711         (WTF::ThreadGroup::add):
2712         * wtf/ThreadGroup.h:
2713         * wtf/ThreadHolder.cpp:
2714         (WTF::ThreadHolder::~ThreadHolder):
2715         * wtf/Threading.cpp:
2716         (WTF::Thread::addToThreadGroup):
2717         (WTF::Thread::removeFromThreadGroup):
2718         * wtf/Threading.h:
2719         * wtf/threads/Signals.cpp:
2720         (WTF::setExceptionPorts):
2721         (WTF::activeThreads):
2722         (WTF::registerThreadForMachExceptionHandling):
2723         (WTF::installSignalHandler):
2724         (WTF::unregisterThreadForMachExceptionHandling): Deleted.
2725         * wtf/threads/Signals.h:
2726
2727 2017-07-19  Yusuke Suzuki  <utatane.tea@gmail.com>
2728
2729         [WTF] Remove unnecessary indirection of WTF::Thread entry point
2730         https://bugs.webkit.org/show_bug.cgi?id=174291
2731
2732         Reviewed by Mark Lam.
2733
2734         Now wtfThreadEntryPoint is almost the same. Only the difference is function signature due to platform APIs.
2735         We remove ThreadFunctionInvocation indirection in ThreadingPthread.cpp and ThreadingWin.cpp.
2736
2737         Also, ThreadFunctionInvocation keeps a RefPtr to the Thread object. This was previously needed to keep the
2738         Thread object alive until the thread itself could install the ThreadHolder into its thread local storage.
2739         The ThreadHolder has a Ref that keeps the Thread object alive for the lifetime of the thread. Since
2740         Thread::create() now waits for the thread to be initialized before returning and Thread::create() hold a Ref
2741         to the Thread object, we are guaranteed that the Thread object will be alive long enough for it to be installed
2742         in the thread's ThreadHolder, and we no longer need ThreadFunctionInvocation.
2743
2744         And we also simplify ThreadHolder::initialize a bit. Now Thread::create waits for the completion of Thread
2745         initialization. So, after establishing thread handle, we can call ThreadHolder::initialize before completing
2746         Thread initialization.
2747
2748         Also we drop errno.h ifdefs in ThreadingWin.cpp. This is introduced to support WinCE. But now WinCE port is removed.
2749
2750         * WTF.xcodeproj/project.pbxproj:
2751         * wtf/ThreadFunctionInvocation.h: Removed.
2752         * wtf/ThreadHolder.h:
2753         * wtf/ThreadHolderWin.cpp:
2754         (WTF::ThreadHolder::initialize):
2755         * wtf/Threading.cpp:
2756         (WTF::Thread::entryPoint):
2757         (WTF::Thread::create):
2758         (WTF::threadEntryPoint): Deleted.
2759         * wtf/Threading.h:
2760         * wtf/ThreadingPthreads.cpp:
2761         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
2762         (WTF::wtfThreadEntryPoint):
2763         (WTF::Thread::establishHandle):
2764         (WTF::Thread::initializeCurrentThreadInternal):
2765         (WTF::Thread::current):
2766         (WTF::Thread::establishPlatformSpecificHandle):
2767         (WTF::Thread::createInternal): Deleted.
2768         (WTF::Thread::establish): Deleted.
2769         * wtf/ThreadingWin.cpp:
2770         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
2771         (WTF::Thread::initializeCurrentThreadInternal):
2772         (WTF::wtfThreadEntryPoint):
2773         (WTF::Thread::establishHandle):
2774         (WTF::Thread::current):
2775         (WTF::Thread::establishPlatformSpecificHandle):
2776         (WTF::Thread::createInternal): Deleted.
2777         (WTF::Thread::establish): Deleted.
2778         * wtf/win/MainThreadWin.cpp:
2779         (WTF::initializeMainThreadPlatform):
2780
2781 2017-07-19  Yusuke Suzuki  <utatane.tea@gmail.com>
2782
2783         [WTF] Implement WTF::ThreadGroup
2784         https://bugs.webkit.org/show_bug.cgi?id=174081
2785
2786         Reviewed by Mark Lam.
2787
2788         This patch implements WTF::ThreadGroup. It implements core of JSC::MachineThreads with more reliable way.
2789         JSC::MachineThreads was complicated because of managing dead threads. Each JSC::MachineThreads has its
2790         own TLS with a registered destructor. And everytime a thread dies, the registered TLS destructor is called.
2791         And this destructor will remove the current dying thread from JSC::MachineThreads.
2792
2793         However the above implementation is tricky. And each JSC::MachineThreads requires own TLS space, which is
2794         not considered in WTF's Windows ThreadSpecific implementation. Current design works well since we only
2795         have small number of MachineThreads right now.
2796
2797         Instead, we use more reliable way. After introducing WTF::Thread, WTF::Thread has WTF::Thread::didExit,
2798         which is called when associated TLS (with WTF::Thread) is destroyed. We leverage this mechanism to remove
2799         WTF::Thread from MachineThreads.
2800
2801         This patch introduces WTF::ThreadGroup. It is tightly integrated with WTF::Thread: WTF::Thread knows
2802         ThreadGroups which includes this thread. And WTF::ThreadGroup of course knows WTF::Threads added to it.
2803         WTF::Thread::didExit carefully remove itself from WTF::ThreadGroups.
2804
2805         The most important part of this patch is locking. WTF::Thread can die. And WTF::ThreadGroup can die.
2806         If we take a design using two fine grain locks in WTF::Thread and WTF::ThreadGroup, we easily encounter
2807         dead lock. Consider the following case.
2808
2809         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).
2810         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).
2811         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).
2812         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).
2813
2814         Then, it easily causes dead lock. We cannot swap the locking order of (2) since iterating THG requires a lock of TH.
2815         To solve this problem, we use std::shared_ptr and std::weak_ptr.
2816
2817         1. When adding WTF::Thread (TH) to WTF::ThreadGroup (THG), we first hold THG, and hold a lock of TH. (THG -> TH)
2818         2. When TH dies, TH first hold lock of TH. And we use std::weak_ptr<>::lock() to retain non-destructed ThreadGroups.
2819         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
2820         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
2821         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).
2822         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).
2823         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).
2824
2825         We also fix suspend and resume locking mechanism to avoid dead lock. We should hold the global lock when suspending and resuming.
2826         If we use per-thread lock, the suspended thread can hold the lock of the other threads. It causes dead lock.
2827
2828         * WTF.xcodeproj/project.pbxproj:
2829         * wtf/AutomaticThread.cpp:
2830         * wtf/CMakeLists.txt:
2831         * wtf/CrossThreadCopier.h:
2832         * wtf/ParkingLot.h:
2833         * wtf/ThreadGroup.cpp: Copied from Source/JavaScriptCore/wasm/WasmMachineThreads.cpp.
2834         (WTF::ThreadGroup::~ThreadGroup):
2835         (WTF::ThreadGroup::add):
2836         (WTF::ThreadGroup::addCurrentThread):
2837         * wtf/ThreadGroup.h: Copied from Source/JavaScriptCore/wasm/WasmMachineThreads.cpp.
2838         (WTF::ThreadGroup::create):
2839         (WTF::ThreadGroup::threads):
2840         (WTF::ThreadGroup::getLock):
2841         (WTF::ThreadGroup::weakFromThis):
2842         * wtf/Threading.cpp:
2843         (WTF::shouldRemoveThreadFromThreadGroup):
2844         (WTF::Thread::didExit):
2845         (WTF::Thread::addToThreadGroup):
2846         (WTF::Thread::removeFromThreadGroup):
2847         * wtf/Threading.h:
2848         * wtf/ThreadingPthreads.cpp:
2849         (WTF::Thread::resume):
2850         (WTF::Thread::getRegisters):
2851         * wtf/ThreadingWin.cpp:
2852         (WTF::Thread::resume):
2853         (WTF::Thread::getRegisters):
2854
2855 2017-07-18  Andy Estes  <aestes@apple.com>
2856
2857         [Xcode] Enable CLANG_WARN_RANGE_LOOP_ANALYSIS
2858         https://bugs.webkit.org/show_bug.cgi?id=174631
2859
2860         Reviewed by Tim Horton.
2861
2862         * Configurations/Base.xcconfig:
2863
2864 2017-07-18  Yusuke Suzuki  <utatane.tea@gmail.com>
2865
2866         WTF::Thread should have the threads stack bounds.
2867         https://bugs.webkit.org/show_bug.cgi?id=173975
2868
2869         Reviewed by Mark Lam.
2870
2871         We move StackBounds from WTFThreadData to WTF::Thread.
2872         One important thing is that we should make valid StackBounds
2873         visible to Thread::create() caller. When the caller get
2874         WTF::Thread from Thread::create(), this WTF::Thread should
2875         have a valid StackBounds. But StackBounds information can be
2876         retrived only in the WTF::Thread's thread itself.
2877
2878         We also clean up WTF::initializeThreading. StringImpl::empty()
2879         is now statically initialized by using constexpr constructor.
2880         Thus we do not need to call StringImpl::empty() explicitly here.
2881         And WTF::initializeThreading() does not have any main thread
2882         affinity right now in all the platforms. So we fix the comment
2883         in Threading.h. Then, now, WTF::initializeThreading() is called
2884         in UI thread when using Web thread in iOS.
2885
2886         * wtf/StackBounds.h:
2887         (WTF::StackBounds::emptyBounds):
2888         (WTF::StackBounds::StackBounds):
2889         * wtf/Threading.cpp:
2890         (WTF::threadEntryPoint):
2891         (WTF::Thread::create):
2892         (WTF::Thread::currentMayBeNull):
2893         (WTF::Thread::initialize):
2894         (WTF::initializeThreading):
2895         * wtf/Threading.h:
2896         (WTF::Thread::stack):
2897         * wtf/ThreadingPthreads.cpp:
2898         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
2899         (WTF::Thread::current):
2900         (WTF::initializeCurrentThreadEvenIfNonWTFCreated): Deleted.
2901         (WTF::Thread::currentMayBeNull): Deleted.
2902         * wtf/ThreadingWin.cpp:
2903         (WTF::Thread::initializeCurrentThreadEvenIfNonWTFCreated):
2904         (WTF::Thread::initializeCurrentThreadInternal):
2905         (WTF::Thread::current):
2906         * wtf/WTFThreadData.cpp:
2907         (WTF::WTFThreadData::WTFThreadData):
2908         * wtf/WTFThreadData.h:
2909         (WTF::WTFThreadData::stack):
2910
2911 2017-07-18  Andy Estes  <aestes@apple.com>
2912
2913         [Xcode] Enable CLANG_WARN_OBJC_LITERAL_CONVERSION
2914         https://bugs.webkit.org/show_bug.cgi?id=174631
2915
2916         Reviewed by Sam Weinig.
2917
2918         * Configurations/Base.xcconfig:
2919
2920 2017-07-18  Andy Estes  <aestes@apple.com>
2921
2922         [Xcode] Enable CLANG_WARN_NON_LITERAL_NULL_CONVERSION
2923         https://bugs.webkit.org/show_bug.cgi?id=174631
2924
2925         Reviewed by Dan Bernstein.
2926
2927         * Configurations/Base.xcconfig:
2928
2929 2017-07-18  Andy Estes  <aestes@apple.com>
2930
2931         [Xcode] Enable CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING
2932         https://bugs.webkit.org/show_bug.cgi?id=174631
2933
2934         Reviewed by Darin Adler.
2935
2936         * Configurations/Base.xcconfig:
2937
2938 2017-07-17  Konstantin Tokarev  <annulen@yandex.ru>
2939
2940         [cmake] Set library types before their targets are created
2941         https://bugs.webkit.org/show_bug.cgi?id=174600
2942
2943         Reviewed by Michael Catanzaro.
2944
2945         Since r219560 library targets are created before PlatformXXX.cmake
2946         files are processed, however library type must be passed in
2947         add_library() call and cannot be changed afterwards. Set these
2948         variables in OptionsXXX.cmake.
2949
2950         * wtf/PlatformGTK.cmake:
2951         * wtf/PlatformMac.cmake:
2952
2953 2017-07-17  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
2954
2955         Move USE_AVFOUNDATION definition on Windows to wtf/Platform.h
2956         https://bugs.webkit.org/show_bug.cgi?id=174356
2957
2958         Reviewed by Brent Fulgham.
2959
2960         Move the definition of USE_AVFOUNDATION on Windows to wtf/platform.h
2961
2962         Add a custom command to generate AVFoundationHeaderDetection.h, which
2963         is renamed from WebCoreHeaderDetection.h
2964
2965         * AVFoundationSupport.py: Moved from Source/WebCore/AVFoundationSupport.py.
2966         * wtf/Platform.h:
2967         * wtf/PlatformWin.cmake:
2968
2969 2017-07-17  Darin Adler  <darin@apple.com>
2970
2971         Improve use of NeverDestroyed
2972         https://bugs.webkit.org/show_bug.cgi?id=174348
2973
2974         Reviewed by Sam Weinig.
2975
2976         * wtf/HashSet.h: Added an overload of HashSet::add that takes an initializer list of
2977         const references. This is handy to add a bunch of values all at once. Later we can
2978         consider optimizing to grow the hash table only once instead of deciding whether to
2979         grow repeatedly as we add each value.
2980         (WTF::copyToVector): Changed to use std::copy, removing 4 of the 6 lines of code here.
2981
2982         * wtf/MemoryPressureHandler.cpp: Include NeverDestroyed.h here ...
2983         * wtf/MemoryPressureHandler.h: ... not here.
2984
2985         * wtf/NeverDestroyed.h: Added the ability to have a const NeverDestroyed.
2986         Added a makeNeverDestroyed function that deduces the type from the argument.
2987         With auto, this can be used to avoid writing out a long type twice.
2988
2989         * wtf/ThreadingPthreads.cpp: Removed unneeded include of NeverDestroyed.h.
2990         * wtf/text/AtomicString.cpp: Ditto.
2991
2992 2017-07-17  Konstantin Tokarev  <annulen@yandex.ru>
2993
2994         [CMake] Create targets before WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS is called
2995         https://bugs.webkit.org/show_bug.cgi?id=174557
2996
2997         Reviewed by Michael Catanzaro.
2998
2999         * wtf/CMakeLists.txt:
3000
3001 2017-07-14  Jonathan Bedard  <jbedard@apple.com>
3002
3003         Add iOS 11 SPI
3004         https://bugs.webkit.org/show_bug.cgi?id=174430
3005         <rdar://problem/33269288>
3006
3007         Reviewed by Tim Horton.
3008
3009         * Configurations/WTF.xcconfig: Exclude MachExceptions.def when building iOS 11 for
3010         the iOS simulator.
3011
3012 2017-07-14  Commit Queue  <commit-queue@webkit.org>
3013
3014         Unreviewed, rolling out r219510.
3015         https://bugs.webkit.org/show_bug.cgi?id=174525
3016
3017         Need to revert length() == 0 check for null string (Requested
3018         by yusukesuzuki on #webkit).
3019
3020         Reverted changeset:
3021
3022         "[WTF] Newly added AtomicStringImpl should use BufferInternal
3023         static string if StringImpl is static"
3024         https://bugs.webkit.org/show_bug.cgi?id=174501
3025         http://trac.webkit.org/changeset/219510
3026
3027 2017-07-14  Yusuke Suzuki  <utatane.tea@gmail.com>
3028
3029         [WTF] Newly added AtomicStringImpl should use BufferInternal static string if StringImpl is static
3030         https://bugs.webkit.org/show_bug.cgi?id=174501
3031
3032         Reviewed by Darin Adler.
3033
3034         When creating AtomicStringImpl from static StringImpl, we can just use createWithoutCopying
3035         to create a BufferInternal AtomicStringImpl which m_data{8,16} is static string's one.
3036
3037         * wtf/text/AtomicStringImpl.cpp:
3038         (WTF::CStringTranslator::hash):
3039         (WTF::CStringTranslator::equal):
3040         (WTF::CStringTranslator::translate):
3041         (WTF::AtomicStringImpl::add):
3042         (WTF::HashTranslatorCharBuffer::HashTranslatorCharBuffer):
3043         (WTF::UCharBufferTranslator::hash):
3044         (WTF::UCharBufferTranslator::equal):
3045         (WTF::UCharBufferTranslator::translate):
3046         (WTF::LCharBufferTranslator::hash):
3047         (WTF::LCharBufferTranslator::equal):
3048         (WTF::LCharBufferTranslator::translate):
3049         (WTF::BufferFromStaticDataTranslator::hash):
3050         (WTF::BufferFromStaticDataTranslator::equal):
3051         (WTF::BufferFromStaticDataTranslator::translate):
3052         (WTF::AtomicStringImpl::addLiteral):
3053         (WTF::addSymbol):
3054         (WTF::addStatic):
3055         (WTF::AtomicStringImpl::addSlowCase):
3056         (WTF::AtomicStringImpl::lookUp):
3057         (WTF::CharBufferFromLiteralDataTranslator::hash): Deleted.
3058         (WTF::CharBufferFromLiteralDataTranslator::equal): Deleted.
3059         (WTF::CharBufferFromLiteralDataTranslator::translate): Deleted.
3060         (WTF::addSubstring): Deleted.
3061         * wtf/text/StringImpl.h:
3062
3063 2017-07-14  Yusuke Suzuki  <utatane.tea@gmail.com>
3064
3065         [WTF] Use std::unique_ptr for StackTrace
3066         https://bugs.webkit.org/show_bug.cgi?id=174495
3067
3068         Reviewed by Alex Christensen.
3069
3070         Instead of returning pointer to heap allocated StackTrace,
3071         we should return std::unique_ptr<StackTrace>.
3072         And we also move WTFGetBackTrace from Assertions.cpp to
3073         StackTrace.cpp to consolidate stack trace related operations
3074         into StackTrace.cpp.
3075
3076         * wtf/Assertions.cpp:
3077         * wtf/StackTrace.cpp:
3078         (WTFGetBacktrace):
3079         (WTF::StackTrace::captureStackTrace):
3080         * wtf/StackTrace.h:
3081
3082 2017-07-13  Yusuke Suzuki  <utatane.tea@gmail.com>
3083
3084         Unreviewed, annotate inline for operator==/!= for FastAllocator
3085         https://bugs.webkit.org/show_bug.cgi?id=174366
3086
3087         * wtf/FastMalloc.h:
3088         (WTF::operator==):
3089         (WTF::operator!=):
3090
3091 2017-07-12  Commit Queue  <commit-queue@webkit.org>
3092
3093         Unreviewed, rolling out r219176.
3094         https://bugs.webkit.org/show_bug.cgi?id=174436
3095
3096         "Can cause infinite recursion on iOS" (Requested by mlam on
3097         #webkit).
3098
3099         Reverted changeset:
3100
3101         "WTF::Thread should have the threads stack bounds."
3102         https://bugs.webkit.org/show_bug.cgi?id=173975
3103         http://trac.webkit.org/changeset/219176
3104
3105 2017-07-12  Adrian Perez de Castro  <aperez@igalia.com>
3106
3107         [WTF] Failure to build when the compiler specifically targets ARMv8-A / defines __ARM_ARCH_8A__
3108         https://bugs.webkit.org/show_bug.cgi?id=174425
3109
3110         Reviewed by Michael Catanzaro.
3111
3112         * wtf/Platform.h: Also check for __ARCH_ARM_8A__ to detect ARMv8.
3113
3114 2017-07-12  Michael Saboff  <msaboff@apple.com>
3115
3116         Unreviewed build fix when both DATA_LOG_TO_FILE and DATA_LOG_FILENAME are defined.
3117
3118         * wtf/DataLog.cpp:
3119         (WTF::initializeLogFileOnce): Changed declaration of logBasename from
3120         char* logBasename to const char* logBasename.
3121
3122 2017-07-12  Matt Lewis  <jlewis3@apple.com>
3123
3124         Unreviewed, rolling out r219401.
3125
3126         This revision rolled out the previous patch, but after talking
3127         with reviewer, a rebaseline is what was needed.Rolling back in
3128         before rebaseline.
3129
3130         Reverted changeset:
3131
3132         "Unreviewed, rolling out r219379."
3133         https://bugs.webkit.org/show_bug.cgi?id=174400
3134         http://trac.webkit.org/changeset/219401
3135
3136 2017-07-12  Matt Lewis  <jlewis3@apple.com>
3137
3138         Unreviewed, rolling out r219379.
3139
3140         This revision caused a consistent failure in the test
3141         fast/dom/Window/property-access-on-cached-window-after-frame-
3142         removed.html.
3143
3144         Reverted changeset:
3145
3146         "Remove NAVIGATOR_HWCONCURRENCY"
3147         https://bugs.webkit.org/show_bug.cgi?id=174400
3148         http://trac.webkit.org/changeset/219379
3149
3150 2017-07-12  Yusuke Suzuki  <utatane.tea@gmail.com>
3151
3152         Unreviewed, attempt to fix Windows build
3153         https://bugs.webkit.org/show_bug.cgi?id=174366
3154
3155         * wtf/FastMalloc.h:
3156         (WTF::operator==):
3157         (WTF::operator!=):
3158         (WTF::FastAllocator::operator==): Deleted.
3159         (WTF::FastAllocator::operator!=): Deleted.
3160
3161 2017-07-11  Carlos Garcia Campos  <cgarcia@igalia.com>
3162
3163         [GTK][WPE] Enable FILE_LOCK and implement lockFile and unlockFile
3164         https://bugs.webkit.org/show_bug.cgi?id=174357
3165
3166         Reviewed by Michael Catanzaro.
3167
3168         * wtf/Platform.h: Enable FILE_LOCK in GTK and WPE ports.
3169
3170 2017-07-11  Dean Jackson  <dino@apple.com>
3171
3172         Remove NAVIGATOR_HWCONCURRENCY
3173         https://bugs.webkit.org/show_bug.cgi?id=174400
3174
3175         Reviewed by Sam Weinig.
3176
3177         * wtf/FeatureDefines.h:
3178
3179 2017-07-11  Dean Jackson  <dino@apple.com>
3180
3181         Rolling out r219372.
3182
3183         * wtf/FeatureDefines.h:
3184
3185 2017-07-11  Dean Jackson  <dino@apple.com>
3186
3187         Remove NAVIGATOR_HWCONCURRENCY
3188         https://bugs.webkit.org/show_bug.cgi?id=174400
3189
3190         Reviewed by Sam Weinig.
3191
3192         * wtf/FeatureDefines.h:
3193
3194 2017-07-11  Yusuke Suzuki  <utatane.tea@gmail.com>
3195
3196         [WTF] Drop unnecessary AtomicString constructor since we have constexpr hash function
3197         https://bugs.webkit.org/show_bug.cgi?id=174347
3198
3199         Reviewed by Alex Christensen.
3200
3201         Previously, we calculate hash value in perl script and generate source code with that value.
3202         This AtomicString constructor takes this pre-calculated hash value to efficiently construct
3203         itself. But now, we have constexpr hash function, then we do not need to specify hash value
3204         directly in this way. Thus we drop this functionality.
3205
3206         * wtf/text/AtomicString.h:
3207         * wtf/text/AtomicStringImpl.cpp:
3208         (WTF::HashAndCharactersTranslator::hash): Deleted.
3209         (WTF::HashAndCharactersTranslator::equal): Deleted.
3210         (WTF::HashAndCharactersTranslator::translate): Deleted.
3211         * wtf/text/AtomicStringImpl.h:
3212         (WTF::AtomicStringImpl::add):
3213
3214 2017-07-10  Per Arne Vollan  <pvollan@apple.com>
3215
3216         [Win] Link error when building WTF from WTF.proj project file.
3217         https://bugs.webkit.org/show_bug.cgi?id=174316
3218         <rdar://problem/33178200>
3219
3220         Reviewed by Brent Fulgham.
3221
3222         WTF_CPU_X86 cmake variable needs to be set for link libraries directories to be correct.
3223
3224         * WTF.vcxproj/WTF.proj:
3225
3226 2017-07-03  Brian Burg  <bburg@apple.com>
3227
3228         Web Replay: remove some unused code
3229         https://bugs.webkit.org/show_bug.cgi?id=173903
3230
3231         Rubber-stamped by Joseph Pecoraro.
3232
3233         * wtf/FeatureDefines.h:
3234
3235 2017-07-10  Brady Eidson  <beidson@apple.com>
3236
3237         Cleanup lifetime issues of UniqueIDBDatabase and IDBBackingStore.
3238         <rdar://problem/32908525> and https://bugs.webkit.org/show_bug.cgi?id=174244
3239
3240         Reviewed by David Kilzer and Alex Christensen. 
3241
3242         Add proper "kill" support to CrossThreadQueue, as well as isEmpty() support.
3243
3244         * wtf/CrossThreadQueue.h:
3245         (WTF::CrossThreadQueue<DataType>::append):
3246         (WTF::CrossThreadQueue<DataType>::kill):
3247         (WTF::CrossThreadQueue<DataType>::isKilled):
3248         (WTF::CrossThreadQueue<DataType>::isEmpty):
3249         (WTF::CrossThreadQueue::isKilled): Deleted.
3250
3251 2017-07-09  Yusuke Suzuki  <utatane.tea@gmail.com>
3252
3253         [JSC] Use fastMalloc / fastFree for STL containers
3254         https://bugs.webkit.org/show_bug.cgi?id=174297
3255
3256         Reviewed by Sam Weinig.
3257
3258         * wtf/FastMalloc.h:
3259         (WTF::FastAllocator::FastAllocator):
3260         (WTF::FastAllocator::allocate):
3261         (WTF::FastAllocator::deallocate):
3262         (WTF::FastAllocator::operator==):
3263         (WTF::FastAllocator::operator!=):
3264
3265 2017-07-07  Brent Fulgham  <bfulgham@apple.com>
3266
3267         [WK2] Use a rolling 30-day uptime for processing statistics
3268         https://bugs.webkit.org/show_bug.cgi?id=174235
3269         <rdar://problem/33164381>
3270
3271         Reviewed by Chris Dumez.
3272
3273         Modify Deque to allow it to be used in a template specialization in KeyedDecoder.
3274
3275         * wtf/Deque.h:
3276
3277 2017-07-07  Commit Queue  <commit-queue@webkit.org>
3278
3279         Unreviewed, rolling out r219238, r219239, and r219241.
3280         https://bugs.webkit.org/show_bug.cgi?id=174265
3281
3282         "fast/workers/dedicated-worker-lifecycle.html is flaky"
3283         (Requested by yusukesuzuki on #webkit).
3284
3285         Reverted changesets:
3286
3287         "[WTF] Implement WTF::ThreadGroup"
3288         https://bugs.webkit.org/show_bug.cgi?id=174081
3289         http://trac.webkit.org/changeset/219238
3290
3291         "Unreviewed, build fix after r219238"
3292         https://bugs.webkit.org/show_bug.cgi?id=174081
3293         http://trac.webkit.org/changeset/219239
3294
3295         "Unreviewed, CLoop build fix after r219238"
3296         https://bugs.webkit.org/show_bug.cgi?id=174081
3297         http://trac.webkit.org/changeset/219241
3298
3299 2017-07-07  Yusuke Suzuki  <utatane.tea@gmail.com>
3300
3301         Unreviewed, Windows build fix after r219233 part 4
3302         https://bugs.webkit.org/show_bug.cgi?id=174231
3303
3304         * wtf/Assertions.h:
3305
3306 2017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
3307
3308         Unreviewed, Windows build fix after r219233 part 3
3309         https://bugs.webkit.org/show_bug.cgi?id=174231
3310
3311         * wtf/Assertions.h:
3312         (compilerFenceForCrash):
3313
3314 2017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
3315
3316         Unreviewed, Windows build fix after r219233 part 2
3317         https://bugs.webkit.org/show_bug.cgi?id=174231
3318
3319         * wtf/Assertions.h:
3320
3321 2017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
3322
3323         Unreviewed, Windows build fix after r219233
3324         https://bugs.webkit.org/show_bug.cgi?id=174231
3325
3326         * wtf/Compiler.h:
3327
3328 2017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
3329
3330         Unreviewed, build fix after r219238
3331         https://bugs.webkit.org/show_bug.cgi?id=174081
3332
3333         * wtf/Threading.cpp:
3334         (WTF::Thread::addToThreadGroup):
3335
3336 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
3337
3338         [WTF] Implement WTF::ThreadGroup
3339         https://bugs.webkit.org/show_bug.cgi?id=174081
3340
3341         Reviewed by Mark Lam.
3342
3343         This patch implements WTF::ThreadGroup. It implements core of JSC::MachineThreads with more reliable way.
3344         JSC::MachineThreads was complicated because of managing dead threads. Each JSC::MachineThreads has its
3345         own TLS with a registered destructor. And everytime a thread dies, the registered TLS destructor is called.
3346         And this destructor will remove the current dying thread from JSC::MachineThreads.
3347
3348         However the above implementation is tricky. And each JSC::MachineThreads requires own TLS space, which is
3349         not considered in WTF's Windows ThreadSpecific implementation. Current design works well since we only
3350         have small number of MachineThreads right now.
3351
3352         Instead, we use more reliable way. After introducing WTF::Thread, WTF::Thread has WTF::Thread::didExit,
3353         which is called when associated TLS (with WTF::Thread) is destroyed. We leverage this mechanism to remove
3354         WTF::Thread from MachineThreads.
3355
3356         This patch introduces WTF::ThreadGroup. It is tightly integrated with WTF::Thread: WTF::Thread knows
3357         ThreadGroups which includes this thread. And WTF::ThreadGroup of course knows WTF::Threads added to it.
3358         WTF::Thread::didExit carefully remove itself from WTF::ThreadGroups.
3359
3360         The most important part of this patch is locking. WTF::Thread can die. And WTF::ThreadGroup can die.
3361         If we take a design using two fine grain locks in WTF::Thread and WTF::ThreadGroup, we easily encounter
3362         dead lock. Consider the following case.
3363
3364         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).
3365         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).
3366         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).
3367         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).
3368
3369         Then, it easily causes dead lock. We cannot swap the locking order of (2) since iterating THG requires a lock of TH.
3370         To solve this problem, we introduce one global lock ThreadGroup::destructionMutex (GL).
3371
3372         1. When adding WTF::Thread (TH) to WTF::ThreadGroup (THG), we first hold GL, and hold a lock of THG. Do not hold a
3373         lock of TH. TH's thread groups information is guarded by GL instead of a lock of TH (locking order is GL -> THG).
3374         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).
3375         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).
3376         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).
3377
3378         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.
3379
3380         * WTF.xcodeproj/project.pbxproj:
3381         * wtf/AutomaticThread.cpp:
3382         * wtf/CMakeLists.txt:
3383         * wtf/CrossThreadCopier.h:
3384         * wtf/ParkingLot.h:
3385         * wtf/ThreadGroup.cpp: Copied from Source/JavaScriptCore/wasm/WasmMachineThreads.cpp.
3386         (WTF::ThreadGroup::destructionMutex):
3387         (WTF::ThreadGroup::~ThreadGroup):
3388         (WTF::ThreadGroup::add):
3389         (WTF::ThreadGroup::addCurrentThread):
3390         (WTF::ThreadGroup::removeCurrentThread):
3391         * wtf/ThreadGroup.h: Copied from Source/JavaScriptCore/wasm/WasmMachineThreads.cpp.
3392         (WTF::ThreadGroup::create):
3393         (WTF::ThreadGroup::threads):
3394         (WTF::ThreadGroup::getLock):
3395         * wtf/Threading.cpp:
3396         (WTF::Thread::didExit):
3397         (WTF::Thread::addToThreadGroup):
3398         (WTF::Thread::removeFromThreadGroup):
3399         * wtf/Threading.h:
3400         (WTF::Thread::canAddToThreadGroup):
3401
3402 2017-07-06  Yusuke Suzuki  <utatane.tea@gmail.com>
3403
3404         [WTF] Clean up StringStatics.cpp by using LazyNeverDestroyed<> for Atoms
3405         https://bugs.webkit.org/show_bug.cgi?id=174150
3406
3407         Reviewed by Mark Lam.
3408
3409         This patch cleans up StringStatics.cpp and remove it from the tree.
3410
3411         1. Move StringImpl methods to appropriate place, "StringImpl.cpp".
3412
3413         StringImpl::hashSlowCase() and StringImpl::concurrentHash() are defined in
3414         StringStatics.cpp. But they should be defined in StringImpl.cpp.
3415         This patch just moves them to StringImpl.cpp.
3416
3417         2. Use LazyNeverDestroyed to initialize AtomicString atoms like emptyAtom.
3418
3419         Previously, we initialized AtomicString atoms like emptyAtom in a hacky way.
3420         We first define them as extern global variables. However, AtomicString has
3421         a non-trivial constructor. Thus, we cannot do this because it requires global
3422         constructor calls. This is why we have StringStatics.cpp. In this file, we
3423         include "StaticConstructors.h". After including this file, all the global
3424         constructor call disabled in Windows. And in GCC environment, we allocate
3425         void* storage for that variable. And we use placement new in AtomicString::init()
3426         to initialize these storage.
3427         However, we already have better way for that: LazyNeverDestroyed. It just allocates
3428         storage like the above. And it does not have any global constructors. Thus
3429         we can just declare it as a global variable. And we initialize them lazily in
3430         AtomicString::init(). This way effectively avoids "StaticConstructors.h" hacky way.
3431         And it makes "StringStatics.cpp" unnecessary.
3432         Then, we just move these variables and AtomicString::init() to AtomicString.cpp.
3433
3434         And we also change emptyAtom to emptyAtom() to get the value from LazyNeverDestroyed<>.
3435
3436         * WTF.xcodeproj/project.pbxproj:
3437         * wtf/CMakeLists.txt:
3438         * wtf/text/AtomicString.cpp:
3439         (WTF::AtomicString::convertASCIICase):
3440         (WTF::AtomicString::fromUTF8Internal):
3441         (WTF::AtomicString::init):
3442         * wtf/text/AtomicString.h:
3443         (WTF::nullAtom):
3444         (WTF::emptyAtom):
3445         (WTF::starAtom):
3446         (WTF::xmlAtom):
3447         (WTF::xmlnsAtom):
3448         (WTF::AtomicString::fromUTF8):
3449         * wtf/text/StringBuilder.h:
3450         (WTF::StringBuilder::toAtomicString):
3451         * wtf/text/StringImpl.cpp:
3452         (WTF::StringImpl::hashSlowCase):
3453         (WTF::StringImpl::concurrentHash):
3454         * wtf/text/StringStatics.cpp: Removed.
3455
3456 2017-07-06  Keith Miller  <keith_miller@apple.com>
3457
3458         Add extra insurance to prevent clang from making crash traces sad
3459         https://bugs.webkit.org/show_bug.cgi?id=174231
3460
3461         Reviewed by Saam Barati.
3462
3463         This patch makes it slightly harder for Clang to coalesce our crash calls.
3464         Additionally, it also makes Clang never tail call the WTFCrashWithInfo so
3465         our stack trace should always be "reasonable".
3466
3467         * wtf/Assertions.h:
3468         * wtf/Compiler.h:
3469
3470 2017-07-06  Matt Lewis  <jlewis3@apple.com>
3471
3472         Unreviewed, rolling out r219178.
3473
3474         This caused a consistent failure with the API test
3475         StringBuilderTest.ToAtomicStringOnEmpty on all Debug testers.
3476
3477         Reverted changeset:
3478
3479         "[WTF] Clean up StringStatics.cpp by using
3480         LazyNeverDestroyed<> for Atoms"
3481         https://bugs.webkit.org/show_bug.cgi?id=174150
3482         http://trac.webkit.org/changeset/219178
3483
3484 2017-07-05  Don Olmstead  <don.olmstead@sony.com>
3485
3486         [WTF] Move SoftLinking.h into WTF
3487         https://bugs.webkit.org/show_bug.cgi?id=174000
3488
3489         Reviewed by Alex Christensen.
3490
3491         * WTF.xcodeproj/project.pbxproj:
3492         * wtf/SoftLinking.h: Copied from Source/WebCore/platform/ios/QuickLookSoftLink.mm.
3493         * wtf/cocoa/SoftLinking.h: Renamed from Source/WebCore/platform/cocoa/SoftLinking.h.
3494         * wtf/win/SoftLinking.h: Renamed from Source/WebCore/platform/win/SoftLinking.h.
3495
3496 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
3497
3498         Upgrade GCC baseline
3499         https://bugs.webkit.org/show_bug.cgi?id=174155
3500
3501         Reviewed by Michael Catanzaro.
3502
3503         * wtf/Compiler.h:
3504
3505 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
3506
3507         WTF::StringImpl::copyChars segfaults when built with GCC 7
3508         https://bugs.webkit.org/show_bug.cgi?id=173407
3509
3510         Reviewed by Andreas Kling.
3511
3512         With GCC 7, StringImpl::copyChars() behaves as unexpected.
3513         This function violates strict aliasing rule.
3514
3515         This optimization is originally introduced to improve performance
3516         in SunSpider's string tests in 2008. When running it in my Linux
3517         box, it no longer causes any observable difference. So, we just
3518         remove this optimization.
3519
3520                                         baseline                  patched
3521
3522         string-base64                7.7544+-0.1761            7.6138+-0.2071          might be 1.0185x faster
3523         string-fasta                10.5429+-0.2746     ?     10.7500+-0.2669        ? might be 1.0196x slower
3524         string-tagcloud             14.8588+-0.2828           14.8039+-0.3039
3525         string-unpack-code          36.1769+-0.4251           35.3397+-0.5398          might be 1.0237x faster
3526         string-validate-input        8.5182+-0.2206            8.3514+-0.2179          might be 1.0200x faster
3527
3528         * wtf/text/StringImpl.h:
3529         (WTF::StringImpl::copyChars):
3530
3531 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
3532
3533         Use std::lock_guard instead of std::unique_lock if move semantics and try_lock is not necessary
3534         https://bugs.webkit.org/show_bug.cgi?id=174148
3535
3536         Reviewed by Mark Lam.
3537
3538         It is not necessary to use std::unique_lock if we do not use additional features compared to std::lock_guard.
3539
3540         (WTF::ThreadHolder::get):
3541         (WTF::ThreadHolder::initialize):
3542         (WTF::ThreadHolder::destruct):
3543         * wtf/Threading.cpp:
3544         (WTF::Thread::didExit):
3545         * wtf/ThreadingPthreads.cpp:
3546         (WTF::Thread::changePriority):
3547         (WTF::Thread::waitForCompletion):
3548         (WTF::Thread::detach):
3549         (WTF::Thread::signal):
3550         (WTF::Thread::resume):
3551         (WTF::Thread::getRegisters):
3552         (WTF::Thread::establish):
3553         * wtf/ThreadingWin.cpp:
3554         (WTF::Thread::changePriority):
3555         (WTF::Thread::waitForCompletion):
3556         (WTF::Thread::detach):
3557         (WTF::Thread::resume):
3558         (WTF::Thread::getRegisters):
3559         (WTF::Thread::establish):
3560         * wtf/WordLock.cpp:
3561         (WTF::WordLockBase::unlockSlow):
3562
3563 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
3564
3565  &nbs