1d0c14cfdcf57cc0778ca9ce3dfbed3b88059e09
[WebKit-https.git] / Source / WTF / ChangeLog
1 2017-05-09  Zan Dobersek  <zdobersek@igalia.com>
2
3         Upstream the WPE port
4         https://bugs.webkit.org/show_bug.cgi?id=171110
5
6         Reviewed by Alex Christensen.
7
8         * wtf/Platform.h:
9         * wtf/PlatformWPE.cmake: Added.
10         * wtf/glib/RunLoopSourcePriority.h:
11
12 2017-05-08  Mark Lam  <mark.lam@apple.com>
13
14         Speculative Windows build fix after r216428.
15         https://bugs.webkit.org/show_bug.cgi?id=171776
16
17         Not reviewed.
18
19         * wtf/StackTrace.h:
20
21 2017-05-08  Mark Lam  <mark.lam@apple.com>
22
23         Introduce ExceptionScope::assertNoException() and releaseAssertNoException().
24         https://bugs.webkit.org/show_bug.cgi?id=171776
25
26         Reviewed by Keith Miller.
27
28         1. Add an option to skip some number of top frames when capturing the StackTrace.
29         2. Add an option to use an indentation string when dumping the StackTrace.
30
31         * wtf/StackTrace.cpp:
32         (WTF::StackTrace::captureStackTrace):
33         (WTF::StackTrace::dump):
34         * wtf/StackTrace.h:
35
36 2017-05-05  Yusuke Suzuki  <utatane.tea@gmail.com>
37
38         [WTF] Use memoryFootprint for MemoryUsage retrieval in Linux
39         https://bugs.webkit.org/show_bug.cgi?id=171757
40
41         Reviewed by Michael Catanzaro.
42
43         This patch leverages memoryFootprint() to retrieve physical footprint in Linux.
44
45         * wtf/linux/MemoryPressureHandlerLinux.cpp:
46         (WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
47
48 2017-05-05  Don Olmstead  <don.olmstead@am.sony.com>
49
50         [WTF] Do not export deleted constructor in StringView
51         https://bugs.webkit.org/show_bug.cgi?id=171751
52
53         Reviewed by Alexey Proskuryakov.
54
55         * wtf/text/StringView.h:
56
57 2017-05-05  Yusuke Suzuki  <utatane.tea@gmail.com>
58
59         [GTK][JSCOnly] Merge MainThread implementations and use generic one
60         https://bugs.webkit.org/show_bug.cgi?id=171738
61
62         Reviewed by Michael Catanzaro.
63
64         GLib MainThread implementation is generic enough to be used in JSCOnly.
65         We move it to generic/ and GTK (GLib ports) and JSCOnly use it.
66         And we also drop GLib MainThread's isMainThread function because
67         generic thread ID one is enough.
68
69         This patch also cleans up initializing main thread code by using std::call_once.
70
71         * wtf/MainThread.cpp:
72         (WTF::initializeMainThread):
73         (WTF::isMainThread):
74         (WTF::initializeMainThreadToProcessMainThread):
75         (WTF::initializeWebThread):
76         (WTF::canAccessThreadLocalDataForThread):
77         (WTF::initializeMainThreadOnce): Deleted.
78         (WTF::initializeMainThreadToProcessMainThreadOnce): Deleted.
79         (WTF::initializeWebThreadOnce): Deleted.
80         * wtf/PlatformGTK.cmake:
81         * wtf/PlatformJSCOnly.cmake:
82         * wtf/generic/MainThreadGeneric.cpp:
83         (WTF::MainThreadDispatcher::MainThreadDispatcher):
84         (WTF::MainThreadDispatcher::schedule):
85         (WTF::MainThreadDispatcher::fired):
86         (WTF::scheduleDispatchFunctionsOnMainThread):
87         * wtf/glib/MainThreadGLib.cpp: Removed.
88
89 2017-05-04  Commit Queue  <commit-queue@webkit.org>
90
91         Unreviewed, rolling out r216206.
92         https://bugs.webkit.org/show_bug.cgi?id=171714
93
94         Multiple LayoutTests crashing in Document::page() (Requested
95         by ap on #webkit).
96
97         Reverted changeset:
98
99         "Remove support for legacy Notifications"
100         https://bugs.webkit.org/show_bug.cgi?id=171487
101         http://trac.webkit.org/changeset/216206
102
103 2017-05-04  Don Olmstead  <don.olmstead@am.sony.com>
104
105         [Win] Remove redundant macros that are set in the CMake config
106         https://bugs.webkit.org/show_bug.cgi?id=171571
107
108         Reviewed by Brent Fulgham.
109
110         * config.h:
111
112 2017-05-04  Mark Lam  <mark.lam@apple.com>
113
114         NeverDestroyed<String>(ASCIILiteral(...)) is not thread safe.
115         https://bugs.webkit.org/show_bug.cgi?id=171586
116         <rdar://problem/31873190>
117
118         Reviewed by Yusuke Suzuki.
119
120         StaticStringImpl is meant to be thread-safe.  However, it has a bug: it did not
121         set the s_hashFlagDidReportCost flag.  As a result, if cost() is called on it,
122         different threads may try to change its flags bits at the same time.  This patch
123         changes StaticStringImpl to always set the s_hashFlagDidReportCost flag.
124
125         Also factored out StringImplShape and made StringImpl and StaticStringImpl extend
126         it.  This makes it more clear that the 2 are intended to have the same shape.
127         Note: there is already a static_assert that the 2 have the same size.  This
128         change also ensures that they both have the same shape, which is a requirement in
129         order for StaticStringImpl to work.
130
131         Introduced the MAKE_STATIC_STRING_IMPL macro as a convenient way to instantiate
132         StaticStringImpls from literal strings.  This allows us to trivially change
133
134             NeverDestroyed<String> myString(ASCIILiteral("myString"));
135
136         to ...
137
138             NeverDestroyed<String> myString(MAKE_STATIC_STRING_IMPL("myString"));
139
140         and by so doing, make it thread-safe.
141
142         MAKE_STATIC_STRING_IMPL instantiates a lambda function to create the static
143         StaticStringImpls.
144
145         * wtf/text/StringImpl.h:
146         (WTF::StringImplShape::StringImplShape):
147         (WTF::StringImpl::StringImpl):
148         (WTF::StringImpl::cost):
149         (WTF::StringImpl::setHash):
150         (WTF::StringImpl::StaticStringImpl::StaticStringImpl):
151         (WTF::StringImpl::StaticStringImpl::operator StringImpl&):
152         * wtf/text/WTFString.h:
153         (WTF::String::String):
154         * wtf/text/icu/TextBreakIteratorICU.h:
155         (WTF::caretRules):
156
157 2017-05-04  Sam Weinig  <sam@webkit.org>
158
159         Remove support for legacy Notifications
160         https://bugs.webkit.org/show_bug.cgi?id=171487
161
162         Reviewed by Jon Lee.
163
164         * wtf/FeatureDefines.h:
165         Remove definition of ENABLE_LEGACY_NOTIFICATIONS.
166
167 2017-05-04  Yusuke Suzuki  <utatane.tea@gmail.com>
168
169         [GTK][JSCOnly] Implement memoryFootprint for Linux
170         https://bugs.webkit.org/show_bug.cgi?id=171680
171
172         Reviewed by Carlos Alberto Lopez Perez.
173
174         Darwin's phys_footprint returns the amount of dirty anonymous memory in the process.
175         This patch implements the same thing in Linux by reading /proc/self/smaps.
176         We sum sizes of private dirty pages in anonymous regions.
177
178         * wtf/MemoryFootprint.cpp:
179         (WTF::forEachLine):
180         (WTF::memoryFootprint):
181
182 2017-05-03  Mark Lam  <mark.lam@apple.com>
183
184         Use the CLoop for CPU(ARM64E).
185         https://bugs.webkit.org/show_bug.cgi?id=171620
186         <rdar://problem/31973027>
187
188         Reviewed by Geoffrey Garen.
189
190         * wtf/Platform.h:
191
192 2017-05-02  Daniel Bates  <dabates@apple.com>
193
194         Fix the build after <https://trac.webkit.org/changeset/216102>
195         (https://bugs.webkit.org/show_bug.cgi?id=170925)
196
197         Export into global scope ASCIICaseInsensitiveStringViewHashTranslator.
198
199         Also fix indentation of member functions of ASCIICaseInsensitiveStringViewHashTranslator.
200
201         * wtf/text/StringHash.h:
202
203 2017-05-02  Daniel Bates  <dabates@apple.com>
204
205         Using StringView.split() instead of String.split() in some places
206         https://bugs.webkit.org/show_bug.cgi?id=170925
207
208         Reviewed by Darin Adler and Sam Weinig.
209
210         * wtf/HashMap.h: Add HashMap::get() overload that takes a HashTranslator.
211         * wtf/text/StringHash.h:
212         (WebCore::ASCIICaseInsensitiveStringViewHashTranslator::hash): Added.
213         (WebCore::ASCIICaseInsensitiveStringViewHashTranslator::equal): Added.
214
215 2017-05-01  Dan Bernstein  <mitz@apple.com>
216
217         [Xcode] It’s easy to accidentally install a WTF header outside /usr/local/include/wtf
218         https://bugs.webkit.org/show_bug.cgi?id=171533
219
220         Reviewed by Andy Estes.
221
222         * WTF.xcodeproj/project.pbxproj: Removed the WTF target’s Headers build phase. Its existence
223           was making it easy to accidentally add a header to the target and make it Private, which
224           would have Xcode install a copy of it right under /usr/local/include, in addition to the
225           copy installed under /usr/local/include/wtf by the Copy WTF Headers target.
226           Also got rid of INSTALL_PATH_PREFIX in the script build phase in the Copy WTF Headers
227           target, because it is being never set anymore.
228
229 2017-05-01  Dan Bernstein  <mitz@apple.com>
230
231         WTF installs an extra copy of a header outside /usr/local/include/wtf
232
233         * WTF.xcodeproj/project.pbxproj: Demoted CPUTime.h from Private to Project.
234
235 2017-05-01  Daniel Bates  <dabates@apple.com>
236
237         Cleanup: Change ASCIICaseInsensitiveHash from a class to a struct
238         https://bugs.webkit.org/show_bug.cgi?id=171460
239
240         Reviewed by Sam Weinig.
241
242         All of the members of ASCIICaseInsensitiveHash have public visibility.
243         We are underutilizing the purpose of a class - defaults to private
244         visibility of members. We should change ASCIICaseInsensitiveHash from
245         a class to a struct, which by definition defaults to public visibility
246         for members.
247
248         * wtf/text/StringHash.h:
249
250 2017-04-29  Yusuke Suzuki  <utatane.tea@gmail.com>
251
252         Move WebCore CPUTime to WTF and implement it in all the platforms
253         https://bugs.webkit.org/show_bug.cgi?id=171477
254
255         Reviewed by Chris Dumez.
256
257         We move WebCore::CPUTime to WTF::CPUTime since it is useful even in JSC
258         and it does not depend on any external libraries.
259         And we additionally implement WTF::CPUTime in all the platforms: Windows and Unix.
260
261         In CPUTime, instead of holding int64_t, we hold MonotonicTime and Seconds.
262
263         * WTF.xcodeproj/project.pbxproj:
264         * wtf/CMakeLists.txt:
265         * wtf/CPUTime.cpp: Copied from Source/WebCore/platform/CPUTime.cpp.
266         (WTF::CPUTime::percentageCPUUsageSince):
267         * wtf/CPUTime.h: Renamed from Source/WebCore/platform/CPUTime.h.
268         * wtf/PlatformEfl.cmake:
269         * wtf/PlatformGTK.cmake:
270         * wtf/PlatformJSCOnly.cmake:
271         * wtf/PlatformMac.cmake:
272         * wtf/PlatformWin.cmake:
273         * wtf/cocoa/CPUTimeCocoa.mm: Renamed from Source/WebCore/platform/cocoa/CPUTimeCocoa.mm.
274         (WTF::timeValueToMicroseconds):
275         (WTF::CPUTime::get):
276         * wtf/unix/CPUTimeUnix.cpp: Renamed from Source/WebCore/platform/CPUTime.cpp.
277         (WTF::timevalToSeconds):
278         (WTF::CPUTime::get):
279         * wtf/win/CPUTimeWin.cpp: Added.
280         (WTF::fileTimeToSeconds):
281         (WTF::CPUTime::get):
282
283 2017-04-28  Simon Fraser  <simon.fraser@apple.com>
284
285         Add system trace points for Document::updateTouchEventRegions()
286         https://bugs.webkit.org/show_bug.cgi?id=171470
287         rdar://problem/31901239
288
289         Reviewed by Tim Horton.
290
291         Add trace markers for updateTouchEventRegions.
292
293         * wtf/SystemTracing.h:
294
295 2017-04-28  Daniel Bates  <dabates@apple.com>
296
297         Add StringView::toExistingAtomicString()
298         https://bugs.webkit.org/show_bug.cgi?id=171405
299
300         Reviewed by Andreas Kling.
301
302         Similar to the reasons for JSString::toExistingAtomicString() we should expose a way to
303         convert a StringView to an existing atomic string. Looking up an atomic string is more
304         efficient that creating one, which requires a lookup and memory allocation.
305
306         We are not making use of StringView::toExistingAtomicString() now, but will in the patch
307         for <https://bugs.webkit.org/show_bug.cgi?id=170925>.
308
309         * wtf/text/AtomicStringImpl.cpp:
310         (WTF::AtomicStringImpl::lookUp): Modified to take a const LChar*/UChar*.
311         (WTF::AtomicStringImpl::lookUpInternal): Renamed to AtomicStringImpl::lookup() to avoid
312         an extra function call.
313         * wtf/text/AtomicStringImpl.h:
314         * wtf/text/StringView.h:
315         (WTF::StringView::toExistingAtomicString): Added.
316
317 2017-04-28  Chris Dumez  <cdumez@apple.com>
318
319         Update DOMTokenList.replace() to match the latest DOM specification
320         https://bugs.webkit.org/show_bug.cgi?id=171388
321
322         Reviewed by Alex Christensen.
323
324         Add Vector::findMatching() API which takes in a lambda function for convenience.
325         Add optional startIndex parameter to Vector::removeFirstMatching() / removeAllMatching()
326         to remove items only after given index.
327
328         * wtf/Vector.h:
329         (WTF::minCapacity>::findMatching):
330         (WTF::minCapacity>::find):
331         (WTF::minCapacity>::removeFirstMatching):
332         (WTF::minCapacity>::removeAllMatching):
333
334 2017-04-27  Carlos Garcia Campos  <cgarcia@igalia.com>
335
336         Move UUID from WebCore/platform to WTF
337         https://bugs.webkit.org/show_bug.cgi?id=171372
338
339         Reviewed by Michael Catanzaro.
340
341         * WTF.xcodeproj/project.pbxproj:
342         * wtf/CMakeLists.txt:
343         * wtf/UUID.cpp: Renamed from Source/WebCore/platform/UUID.cpp.
344         * wtf/UUID.h: Renamed from Source/WebCore/platform/UUID.h.
345
346 2017-04-26  Keith Miller  <keith_miller@apple.com>
347
348         LocklessBag needs a destructor
349         https://bugs.webkit.org/show_bug.cgi?id=171334
350
351         Reviewed by Mark Lam.
352
353         Currently, if the bag is destructed any remaining nodes in the bag will
354         be leaked.
355
356         * wtf/LocklessBag.h:
357         (WTF::LocklessBag::consumeAll):
358         (WTF::LocklessBag::~LocklessBag):
359         * wtf/threads/Signals.cpp:
360         (WTF::jscSignalHandler):
361         (WTF::installSignalHandler):
362
363 2017-04-26  Don Olmstead  <don.olmstead@am.sony.com>
364
365         [ARM] Enable GCC visibility
366         https://bugs.webkit.org/show_bug.cgi?id=171296
367
368         Reviewed by Michael Catanzaro.
369
370         * wtf/Platform.h:
371
372 2017-04-26  Yusuke Suzuki  <utatane.tea@gmail.com>
373
374         sendMessageScoped's signal handler calls LocklessBag::consumeAll, which causes heap deallocation in signal handler and leads deadlock
375         https://bugs.webkit.org/show_bug.cgi?id=171319
376
377         Reviewed by Keith Miller.
378
379         In sendMessageScoped, we call LocklessBag<SignalHandler>::consumeAll `thread->threadMessages().consumeAll()`.
380         In LocklessBag::consumeAll, we call `delete` on Nodes.
381         The problem is that this is called under the context of signal handler. Thus, when calling this, the original
382         thread may hold the lock in bmalloc. In that case, this `delete` call attempts to lock the heap lock recursively,
383         and causes deadlock.
384
385         Instead, this patch transfers the LocklessBag's Node to the sender thread. And the sender thread deletes it instead.
386
387         * wtf/LocklessBag.h:
388         (WTF::LocklessBag::consumeAllWithNode):
389         * wtf/ThreadMessage.cpp:
390         (WTF::ThreadMessageData::ThreadMessageData):
391         (WTF::sendMessageScoped):
392
393 2017-04-25  Don Olmstead  <don.olmstead@am.sony.com>
394
395         [Win] Use Clang's __has_declspec_attribute for export macros
396         https://bugs.webkit.org/show_bug.cgi?id=171240
397
398         Reviewed by Alex Christensen.
399
400         * wtf/Compiler.h:
401         * wtf/ExportMacros.h:
402         * wtf/Platform.h:
403
404 2017-04-25  Keith Miller  <keith_miller@apple.com>
405
406         Our signal handler shouldn't print when sigaction succeeds
407         https://bugs.webkit.org/show_bug.cgi?id=171286
408
409         Reviewed by Michael Saboff.
410
411         It turns out !result is not the same as !!result.
412
413         * wtf/threads/Signals.cpp:
414         (WTF::jscSignalHandler):
415
416 2017-04-25  Myles C. Maxfield  <mmaxfield@apple.com>
417
418         Add performance test for FontCache::systemFallbackForCharacters()
419         https://bugs.webkit.org/show_bug.cgi?id=170842
420
421         Reviewed by Tim Horton.
422
423         * wtf/unicode/CharacterNames.h:
424
425 2017-04-24  Andy VanWagoner  <thetalecrafter@gmail.com>
426
427         Clean up ICU headers
428         https://bugs.webkit.org/show_bug.cgi?id=170997
429
430         Reviewed by JF Bastien.
431
432         Update all icu headers to 55.1
433
434         * icu/LICENSE: Update copyright
435         * icu/README: Explain ICU headers for OS X better
436         * icu/unicode/localpointer.h:
437         (LocalPointer::LocalPointer):
438         (LocalPointer::adoptInsteadAndCheckErrorCode):
439         * icu/unicode/platform.h:
440         * icu/unicode/putil.h:
441         * icu/unicode/std_string.h:
442         * icu/unicode/ubrk.h:
443         * icu/unicode/uchar.h:
444         * icu/unicode/ucnv.h:
445         * icu/unicode/ucol.h:
446         * icu/unicode/uconfig.h:
447         * icu/unicode/ucurr.h:
448         * icu/unicode/uloc.h:
449         * icu/unicode/umachine.h:
450         * icu/unicode/unistr.h:
451         (UnicodeString::getArrayStart):
452         (UnicodeString::UnicodeString):
453         (UnicodeString::hasShortLength):
454         (UnicodeString::getShortLength):
455         (UnicodeString::length):
456         (UnicodeString::getCapacity):
457         (UnicodeString::isBogus):
458         (UnicodeString::isWritable):
459         (UnicodeString::isBufferWritable):
460         (UnicodeString::getBuffer):
461         (UnicodeString::isEmpty):
462         (UnicodeString::setZeroLength):
463         (UnicodeString::setShortLength):
464         (UnicodeString::setLength):
465         (UnicodeString::setToEmpty):
466         (UnicodeString::remove):
467         * icu/unicode/urename.h:
468         * icu/unicode/uscript.h:
469         * icu/unicode/uset.h:
470         * icu/unicode/ustring.h:
471         * icu/unicode/utf8.h:
472         * icu/unicode/utypes.h:
473         * icu/unicode/uvernum.h:
474
475 2017-04-24  Yusuke Suzuki  <utatane.tea@gmail.com>
476
477         Unreviewed, fix Windows build after r215715
478         https://bugs.webkit.org/show_bug.cgi?id=171199
479
480         * wtf/StackTrace.h:
481
482 2017-04-24  Yusuke Suzuki  <utatane.tea@gmail.com>
483
484         [WTF] Move JSC tools/StackTrace to WTF and unify stack trace dump code
485         https://bugs.webkit.org/show_bug.cgi?id=171199
486
487         Reviewed by Mark Lam.
488
489         JSC tools/StackTrace's dump code is almost identical to WTF Assertions'
490         stack trace dump code. This patch moves tools/StackTrace to WTF and use
491         it in Assertions. It unifies the two duplicate implementations into one.
492
493         * WTF.xcodeproj/project.pbxproj:
494         * wtf/Assertions.cpp:
495         * wtf/CMakeLists.txt:
496         * wtf/Platform.h:
497         * wtf/StackTrace.cpp: Renamed from Source/JavaScriptCore/tools/StackTrace.cpp.
498         (WTF::StackTrace::captureStackTrace):
499         (WTF::StackTrace::dump):
500         * wtf/StackTrace.h: Copied from Source/JavaScriptCore/tools/StackTrace.h.
501         (WTF::StackTrace::StackTrace):
502         (WTF::StackTrace::stack):
503         (WTF::StackTrace::DemangleEntry::mangledName):
504         (WTF::StackTrace::DemangleEntry::demangledName):
505         (WTF::StackTrace::DemangleEntry::DemangleEntry):
506         * wtf/SystemFree.h: Renamed from Source/JavaScriptCore/tools/StackTrace.h.
507         (WTF::SystemFree::operator()):
508
509 2017-04-24  Yusuke Suzuki  <utatane.tea@gmail.com>
510
511         [AppleWin] The procedure entry point ?waitForThreadCompletion@WTF@@YAHI@Z could not be located in the dynamic link library WebKitQuartzCoreAdditions.dll
512         https://bugs.webkit.org/show_bug.cgi?id=171029
513
514         Reviewed by Brent Fulgham.
515
516         While WTF Threading APIs are updated, WebKitQuartzCoreAdditions.dll in Windows uses some of the old APIs,
517         waitForThreadCompletion and createThread. This patch implements both on top of the new APIs.
518         These APIs are only exposed in Windows for this compatibility problem and new code should not use it.
519
520         * wtf/ThreadHolder.cpp:
521         (WTF::ThreadHolder::initialize):
522         * wtf/ThreadHolder.h:
523         * wtf/ThreadHolderWin.cpp:
524         (WTF::ThreadHolder::get):
525         (WTF::ThreadHolder::platformInitialize):
526         (WTF::ThreadHolder::destruct):
527         * wtf/Threading.h:
528         * wtf/ThreadingWin.cpp:
529         (WTF::createThread):
530         (WTF::waitForThreadCompletion):
531
532 2017-04-24  Carlos Garcia Campos  <cgarcia@igalia.com>
533
534         [GTK] Switch to use ENABLE_REMOTE_INSPECTOR instead of ENABLE_INSPECTOR_SERVER for the remote inspector
535         https://bugs.webkit.org/show_bug.cgi?id=166680
536
537         Reviewed by Michael Catanzaro.
538
539         Add GRefPtr hash traits to allow using GRefPtr as a key of HashMaps.
540
541         * wtf/glib/GRefPtr.h:
542         (WTF::HashTraits<GRefPtr<P>>::emptyValue):
543         (WTF::HashTraits<GRefPtr<P>>::peek):
544         (WTF::HashTraits<GRefPtr<P>>::customDeleteBucket):
545
546 2017-04-22  Yusuke Suzuki  <utatane.tea@gmail.com>
547
548         [JSC] Get stack pointer without pthread attr
549         https://bugs.webkit.org/show_bug.cgi?id=171162
550
551         Reviewed by Mark Lam.
552
553         If HAVE(MACHINE_CONTEXT) is not enabled, we get stack base and boundary by using
554         pthread_attr functions. However, it is wrong since this function can be called
555         after the thread is suspended. In that case, we should not call any functions
556         that is not async signal safe. For example, pthread_getattr_np calls malloc.
557
558         Instead we use getApproximateStackPointer(), which returns approximate stack pointer.
559
560         * wtf/Threading.h:
561         * wtf/ThreadingPthreads.cpp:
562         (WTF::getApproximateStackPointer):
563         (WTF::isOnAlternativeSignalStack):
564         When gathering conservative roots, we should keep stack pointer pointing stack.
565         And if concurrent GC is enabled, we always need to keep the above invariant.
566         So, we do not support alternative signal stack.
567
568         (WTF::Thread::signalHandlerSuspendResume):
569         (WTF::Thread::getRegisters):
570
571 2017-04-22  Yusuke Suzuki  <utatane.tea@gmail.com>
572
573         REGRESSION(r215638): [Linux] Several worker tests are crashing in Thread::signalHandlerSuspendResume after r215638
574         https://bugs.webkit.org/show_bug.cgi?id=171159
575
576         Reviewed by Michael Catanzaro.
577
578         Now, SIGUSR2 is used by ThreadMessage. Instead SIGUSR1 becomes empty.
579         We should use some signal, that is not managed by WTF Signal mechanism
580         because the behaivor of this suspend and resume is a bit tricky.
581         For example, we set a bit tricky signal mask to sigaction to temporary
582         block SIGUSR2 in the handler to avoid nested SIGUSR2. And we cannot
583         use ThreadMessage to implement this mechanism because this suspend
584         and resume handler will stop in the middle of the handler by sigsuspend.
585         It is not the expected semantics by ThreadMessage.
586
587         So now, we use SIGUSR1 instead. And we note that SIGUSR1 is used for
588         pthread ports.
589
590         * wtf/ThreadingPthreads.cpp:
591         * wtf/threads/Signals.h:
592
593 2017-04-20  Sam Weinig  <sam@webkit.org>
594
595         Split cryptographic digest computation and parsing out of CSP code so it can be reused
596         https://bugs.webkit.org/show_bug.cgi?id=171076
597
598         Reviewed by Chris Dumez.
599
600         * wtf/text/Base64.cpp:
601         (WTF::base64Decode):
602         (WTF::base64URLDecode):
603         Add overloads for base64Decode and base64URLDecode that take a StringView, to avoid allocations
604         of Strings.
605
606         * wtf/text/Base64.h:
607         (WTF::isBase64OrBase64URLCharacter):
608         Move helper predicate used for parsing either type of Base64 encoded string from WebCore.
609
610 2017-04-21  Keith Miller  <keith_miller@apple.com>
611
612         Unreviewed, rolling out r215634.
613
614         underlying build issues should have been fixed
615
616         Reverted changeset:
617
618         "Unreviewed, rolling out r215620 and r215623."
619         https://bugs.webkit.org/show_bug.cgi?id=171139
620         http://trac.webkit.org/changeset/215634
621
622 2017-04-21  Keith Miller  <keith_miller@apple.com>
623
624         Remove LL/SC from Atomics
625         https://bugs.webkit.org/show_bug.cgi?id=171141
626
627         Reviewed by Saam Barati.
628
629         Adding load link and store conditionally was not an actual progression
630         and the existing code is causing problems for users of Atomics. So let's
631         get rid of it.
632
633         * wtf/Atomics.h:
634         (WTF::hasFence):
635         (WTF::Atomic::exchange):
636         (WTF::Atomic::transaction):
637         (WTF::Atomic::transactionRelaxed):
638         (WTF::Atomic::prepare): Deleted.
639         (WTF::Atomic::attempt): Deleted.
640         * wtf/Bitmap.h:
641         (WTF::WordType>::concurrentTestAndSet):
642         (WTF::WordType>::concurrentTestAndClear):
643         * wtf/LockAlgorithm.h:
644         (WTF::LockAlgorithm::lockFast):
645         (WTF::LockAlgorithm::unlockFast):
646
647 2017-04-21  Commit Queue  <commit-queue@webkit.org>
648
649         Unreviewed, rolling out r215620 and r215623.
650         https://bugs.webkit.org/show_bug.cgi?id=171139
651
652         broke arm64 build (Requested by keith_miller on #webkit).
653
654         Reverted changesets:
655
656         "Add signaling API"
657         https://bugs.webkit.org/show_bug.cgi?id=170976
658         http://trac.webkit.org/changeset/215620
659
660         "Unreviewed, fix Cloop build."
661         http://trac.webkit.org/changeset/215623
662
663 2017-04-20  Keith Miller  <keith_miller@apple.com>
664
665         Add signaling API
666         https://bugs.webkit.org/show_bug.cgi?id=170976
667
668         Reviewed by Filip Pizlo.
669
670         This patch adds a bunch of new functionality to WTF. First, it add
671         a new data structure of a lockless bag. The LocklessBag class can
672         be used as either a multi-writer multi-reader lockless bag or a
673         multi-writer single consumer lockless bag.
674
675         Next, this patch adds an abstraction around sigaction in WTF.
676         Basically, you can add a handler, which can be an arbitrary
677         lambda. Although it should still be safe for the signal you are
678         handling.  the signal handler manager will then do all the
679         appropriate handling of chaining:
680
681         In the SIGUSR case we always forward the signal to any other
682         non-default handler installed before us. We need to do this,
683         otherwise, since it's not possible to tell if a SIGUSR was
684         intended exlusively for our handlers. Signal handlers don't record
685         how many times they were sent only that there is at least one
686         unhandled signal.
687
688         In the faulting cases we require that every handle be able to
689         recognise a fault they installed, vs crashes. If none of our
690         handlers claim to have handled the fault we will forward the
691         fault. If a handler was installed before the first fault handler
692         we simply call that handler and rely on them to take the
693         appropriate action. If no handler was installed before our first
694         handler we restore the default handler and allow the fault to
695         happen again.
696
697         Finally, this patch adds a signal based messaging system.  This
698         system allows the user to run an arbitrary lambda from the SIGUSR2
699         signal handler of any target WTF::Thread. This is already in use
700         for the VMTraps API which allows us to kill rogue VMs by sending
701         the VM's running WTF::Thread a SIGUSR and requesting it jetison
702         all optimized code and throw an uncatchable exception from all
703         function entries/loop backedges.  In the future, we will also use
704         this API for Wasm to reset the instruction caches in currently
705         executing Wasm threads.
706
707         * WTF.xcodeproj/project.pbxproj:
708         * wtf/Atomics.h:
709         (WTF::Atomic::Atomic):
710         * wtf/LocklessBag.h: Added.
711         (WTF::LocklessBag::LocklessBag):
712         (WTF::LocklessBag::add):
713         (WTF::LocklessBag::iterate):
714         (WTF::LocklessBag::consumeAll):
715         * wtf/ThreadMessage.cpp: Added.
716         (WTF::ThreadMessageData::ThreadMessageData):
717         (WTF::initializeThreadMessages):
718         (WTF::sendMessageScoped):
719         * wtf/ThreadMessage.h: Added.
720         (WTF::sendMessage):
721         * wtf/Threading.cpp:
722         (WTF::initializeThreading):
723         * wtf/Threading.h:
724         (WTF::Thread::threadMessages):
725         * wtf/ThreadingPthreads.cpp:
726         (WTF::Thread::currentMayBeNull):
727         (WTF::Thread::current):
728         (WTF::Thread::signal):
729         * wtf/threads/Signals.cpp: Added.
730         (WTF::jscSignalHandler):
731         (WTF::installSignalHandler):
732         * wtf/threads/Signals.h: Added.
733         (WTF::toSystemSignal):
734         (WTF::fromSystemSignal):
735
736 2017-04-21  Konstantin Tokarev  <annulen@yandex.ru>
737
738         [cmake] WTF target should not have wtf and subdirectries in public interface
739         https://bugs.webkit.org/show_bug.cgi?id=171115
740
741         Reviewed by Michael Catanzaro.
742
743         In r209665 WEBCORE_FRAMEWORK macro started to export INCLUDE_DIRECTORIES of
744         targets as their public interface, so that linked targets can use them
745         implicitly without copying directory lists around. This matches existing
746         practice for all targets except WTF, headers from which are always included
747         with full path starting from "<wtf/...".
748
749         Since r209665 it became possible to include headers from wtf or its
750         subdirectories in CMake builds without using "<wtf/..." path. It should
751         not be allowed.
752
753         * wtf/CMakeLists.txt: WTF/wtf and its sudirectories should not be in
754         public include paths of WTF target.
755
756 2017-04-20  Sam Weinig  <sam@webkit.org>
757
758         Move notFound into its own file
759         https://bugs.webkit.org/show_bug.cgi?id=170972
760
761         Reviewed by Zalan Bujtas.
762
763         It is odd to require including <wtf/Vector.h> just to use WTF::notFound.
764         This is not causing any current problems, but does in few changes I have
765         queued up.
766
767         * WTF.xcodeproj/project.pbxproj:
768         * wtf/NotFound.h: Added.
769         * wtf/Vector.h:
770         * wtf/text/StringCommon.h:
771
772 2017-04-20  Filip Pizlo  <fpizlo@apple.com>
773
774         Optimize SharedArrayBuffer in the DFG+FTL
775         https://bugs.webkit.org/show_bug.cgi?id=164108
776
777         Reviewed by Saam Barati.
778         
779         Made small changes as part of benchmarking the JS versions of these locks.
780
781         * benchmarks/LockSpeedTest.cpp:
782         * benchmarks/ToyLocks.h:
783         * wtf/Range.h:
784         (WTF::Range::dump):
785
786 2017-04-19  Youenn Fablet  <youenn@apple.com>
787
788         [Win] Activate streams API by default
789         https://bugs.webkit.org/show_bug.cgi?id=171000
790
791         Reviewed by Brent Fulgham.
792
793         * wtf/FeatureDefines.h:
794
795 2017-04-19  David Kilzer  <ddkilzer@apple.com>
796
797         Vector.h: error: 'auto' not allowed in lambda parameter
798         <https://webkit.org/b/171010>
799         <rdar://problem/31716076>
800
801         Reviewed by Saam Barati.
802
803         * wtf/Vector.h:
804         (WTF::removeRepeatedElements): Replace 'auto' with a specific
805         type, 'T', based on a Vector<> template type.
806
807 2017-04-19  Ryan Haddad  <ryanhaddad@apple.com>
808
809         Unreviewed, rolling out r215518.
810
811         This change appears to have broken the Windows build.
812
813         Reverted changeset:
814
815         "Move notFound into its own file"
816         https://bugs.webkit.org/show_bug.cgi?id=170972
817         http://trac.webkit.org/changeset/215518
818
819 2017-04-19  Sam Weinig  <sam@webkit.org>
820
821         Move notFound into its own file
822         https://bugs.webkit.org/show_bug.cgi?id=170972
823
824         Reviewed by Zalan Bujtas.
825
826         It is odd to require including <wtf/Vector.h> just to use WTF::notFound.
827         This is not causing any current problems, but does in few changes I have
828         queued up.
829
830         * WTF.xcodeproj/project.pbxproj:
831         * wtf/NotFound.h: Added.
832         * wtf/Vector.h:
833         * wtf/text/StringCommon.h:
834
835 2017-04-18  Carlos Garcia Campos  <cgarcia@igalia.com>
836
837         [GLIB] Define priorities also for async network IO tasks
838         https://bugs.webkit.org/show_bug.cgi?id=170905
839
840         Reviewed by Žan Doberšek.
841
842         Add AsyncIONetwork, DiskCacheRead and DiskCacheWrite priorities.
843
844         * wtf/glib/RunLoopSourcePriority.h:
845
846 2017-04-18  Yusuke Suzuki  <utatane.tea@gmail.com>
847
848         [JSC][GTK] glib RunLoop does not accept negative start interval
849         https://bugs.webkit.org/show_bug.cgi?id=170775
850
851         Reviewed by Saam Barati.
852
853         RunLoop::Timer for glib does not accept negative start interval.
854         We use 0_s if the given value is negative.
855
856         * wtf/glib/RunLoopGLib.cpp:
857         (WTF::RunLoop::TimerBase::secondsUntilFire):
858
859 2017-04-17  Alex Christensen  <achristensen@webkit.org>
860
861         Allow Variants of RetainPtrs
862         https://bugs.webkit.org/show_bug.cgi?id=170923
863
864         Reviewed by Tim Horton and Sam Weinig.
865
866         * wtf/RetainPtr.h:
867         (WTF::RetainPtr::operator&): Deleted.
868         Operator& was causing a compile error when making Variant<RetainPtr<T>, ...>
869         and because it is strange and only used once, let's just remove it.
870         * wtf/Variant.h:
871         (WTF::get):
872         (WTF::get_if):
873         Use std::addressof instead of operator& which could be overloaded to return any type with any meaning.
874
875 2017-04-17  Youenn Fablet  <youenn@apple.com>
876
877         Disable outdated WritableStream API
878         https://bugs.webkit.org/show_bug.cgi?id=170749
879         <rdar://problem/31446233>
880
881         Reviewed by Alex Christensen.
882
883         Replacing READABLE_STREAM_API, READABLE_BYTE_STREAM_API and WRITABLE_STREAM_API compilation flag by:
884         - A STREAMS_API compilation flag.
885         - A ReadableByteStreamAPI and WritableStreamAPI runtime flags, turned off except for RWT and DRT.
886
887         * wtf/FeatureDefines.h:
888
889 2017-04-17  Dan Bernstein  <mitz@apple.com>
890
891         [Cocoa] Move isNullFunctionPointer down into WTF
892         https://bugs.webkit.org/show_bug.cgi?id=170892
893
894         Reviewed by Sam Weinig.
895
896         Test: TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp
897
898         * WTF.xcodeproj/project.pbxproj: Added reference to new file.
899         * wtf/darwin: Added.
900         * wtf/darwin/WeakLinking.h: Added.
901         (WTF::isNullFunctionPointer): Copied from ResourceLoadStatisticsClassifierCocoa.cpp in
902           WebKit2 and changed into a function template that works with any function pointer.
903
904 2017-04-17  Ryan Haddad  <ryanhaddad@apple.com>
905
906         Unreviewed, rolling out r215366.
907
908         This test is failing on performance bots.
909
910         Reverted changeset:
911
912         "Add performance test for asking the platform for a font for
913         U+2060 WORD JOINER"
914         https://bugs.webkit.org/show_bug.cgi?id=170842
915         http://trac.webkit.org/changeset/215366
916
917 2017-04-17  Yusuke Suzuki  <utatane.tea@gmail.com>
918
919         [JSCOnly] Fix build failures in macOS
920         https://bugs.webkit.org/show_bug.cgi?id=170887
921
922         Reviewed by Alex Christensen.
923
924         JSCOnly port does not use mac/MainThread.cpp.
925         We change the ifdef gurard to use generic implementaion in JSCOnly on macOS.
926
927         * wtf/MainThread.cpp:
928         * wtf/PlatformJSCOnly.cmake:
929
930 2017-04-17  JF Bastien  <jfbastien@apple.com>
931
932         B3: don't allow unsigned offsets in Value
933         https://bugs.webkit.org/show_bug.cgi?id=170692
934
935         Reviewed by Filip Pizlo.
936
937         Add C++17's std::conjunction type trait, except for Microsoft VS
938         2015 update 2 and later because it adds the logical operator type
939         traits, event when C++ is pre-2017:
940         https://blogs.msdn.microsoft.com/vcblog/2016/01/22/vs-2015-update-2s-stl-is-c17-so-far-feature-complete/
941
942         * wtf/StdLibExtras.h:
943
944 2017-04-14  Mark Lam  <mark.lam@apple.com>
945
946         Update architectures in xcconfig files.
947         https://bugs.webkit.org/show_bug.cgi?id=170867
948         <rdar://problem/31628104>
949
950         Reviewed by Joseph Pecoraro.
951
952         * Configurations/Base.xcconfig:
953
954 2017-04-14  Myles C. Maxfield  <mmaxfield@apple.com>
955
956         Add performance test for asking the platform for a font for U+2060 WORD JOINER
957         https://bugs.webkit.org/show_bug.cgi?id=170842
958
959         Reviewed by Tim Horton.
960
961         * wtf/unicode/CharacterNames.h:
962
963 2017-04-13  Yusuke Suzuki  <utatane.tea@gmail.com>
964
965         [JSC] Date.parse should accept wider range of representation
966         https://bugs.webkit.org/show_bug.cgi?id=170720
967
968         Reviewed by Darin Adler.
969
970         We would like to relax Date.parse to accept the representation "May 8".
971         At that time, we choose `2000` as a default year. This is because of
972         the following reason.
973
974         1. According to the V8, this default value is compatible to the old KJS. While current V8 uses 2001,
975            SpiderMonkey does not have such a fallback path. So this reason is not big deal.
976
977         2. It is a leap year. When using `new Date("Feb 29")`, we assume that people want to save month and day.
978            Leap year can save user inputs if they is valid. If we use the current year instead, the current year
979            may not be a leap year. In that case, `new Date("Feb 29").getMonth()` becomes 2 (March).
980
981         * wtf/DateMath.cpp:
982         (WTF::parseDateFromNullTerminatedCharacters):
983
984 2017-04-13  Dan Bernstein  <mitz@apple.com>
985
986         WTF installs an extra copy of a header outside /usr/local/include/wtf
987
988         * WTF.xcodeproj/project.pbxproj: Demoted PriorityQueue.h from Private to Project.
989
990 2017-04-13  Oliver Hunt  <oliver@apple.com>
991
992         allocationSize should use safe arithmetic by default
993         https://bugs.webkit.org/show_bug.cgi?id=170804
994
995         Reviewed by JF Bastien.
996
997         Make all allocationSize() functions work in terms
998         of Checked<size_t>
999
1000         * wtf/text/StringImpl.h:
1001         (WTF::StringImpl::allocationSize):
1002         (WTF::StringImpl::tailOffset):
1003
1004 2017-04-13  JF Bastien  <jfbastien@apple.com>
1005
1006         WebAssembly: manage memory better
1007         https://bugs.webkit.org/show_bug.cgi?id=170628
1008
1009         Reviewed by Keith Miller, Michael Saboff.
1010
1011         Re-use a VM tag which was intended for JavaScript core, was then
1012         used by our GC, and is now unused. If I don't do this then
1013         WebAssembly fast memories will make vmmap look super weird because
1014         it'll look like multi-gigabyte of virtual memory are allocated as
1015         part of our process' regular memory!
1016
1017         Separately I need to update vmmap and other tools to print the
1018         right name. Right now this tag gets identified as "JS garbage
1019         collector".
1020
1021         * wtf/OSAllocator.h:
1022         * wtf/VMTags.h:
1023
1024 2017-04-13  Yusuke Suzuki  <utatane.tea@gmail.com>
1025
1026         [JSC] Use proper ifdef guard for code using MachineContext
1027         https://bugs.webkit.org/show_bug.cgi?id=170800
1028
1029         Reviewed by Carlos Alberto Lopez Perez.
1030
1031         SamplingProfiler and FastMemory rely on MachineContext feature.
1032
1033         * wtf/Platform.h:
1034
1035 2017-04-12  Dan Bernstein  <mitz@apple.com>
1036
1037         [Mac] Future-proof .xcconfig files
1038         https://bugs.webkit.org/show_bug.cgi?id=170802
1039
1040         Reviewed by Tim Horton.
1041
1042         * Configurations/Base.xcconfig:
1043         * Configurations/DebugRelease.xcconfig:
1044
1045 2017-04-12  Yusuke Suzuki  <utatane.tea@gmail.com>
1046
1047         Use HAVE(MACHINE_CONTEXT) instead of USE(MACHINE_CONTEXT)
1048         https://bugs.webkit.org/show_bug.cgi?id=170770
1049
1050         Rubber stamped by Mark Lam.
1051
1052         * wtf/Platform.h:
1053         * wtf/PlatformRegisters.h:
1054         * wtf/ThreadingPthreads.cpp:
1055         (WTF::Thread::getRegisters):
1056
1057 2017-04-12  Yusuke Suzuki  <utatane.tea@gmail.com>
1058
1059         [JSC] Clean up heap/MachineStackMarker by introducing USE(MACHINE_CONTEXT)
1060         https://bugs.webkit.org/show_bug.cgi?id=170770
1061
1062         Reviewed by Mark Lam.
1063
1064         We add a new define USE_MACHINE_CONTEXT, which becomes true if mcontext_t exists
1065         and we know the way to retrieve values from mcontext_t.
1066
1067         * wtf/Platform.h:
1068         * wtf/PlatformRegisters.h:
1069         * wtf/ThreadingPthreads.cpp:
1070         (WTF::Thread::getRegisters):
1071
1072 2017-04-12  Yusuke Suzuki  <utatane.tea@gmail.com>
1073
1074         [WTF] Introduce Thread class and use RefPtr<Thread> and align Windows Threading implementation semantics to Pthread one
1075         https://bugs.webkit.org/show_bug.cgi?id=170502
1076
1077         Reviewed by Mark Lam.
1078
1079         This patch is refactoring of WTF Threading mechanism to merge JavaScriptCore's threading extension to WTF Threading.
1080         Previously, JavaScriptCore requires richer threading features (such as suspending and resuming threads), and they
1081         are implemented for PlatformThread in JavaScriptCore. But these features should be implemented in WTF Threading side
1082         instead of maintaining JSC's own threading features too. This patch removes these features from JSC and move it to
1083         WTF Threading.
1084
1085         However, current WTF Threading has one problem: Windows version of WTF Threading has different semantics from Pthreads
1086         one. In Windows WTF Threading, we cannot perform any operation after the target thread is detached: WTF Threading stop
1087         tracking the state of the thread once the thread is detached. But this is not the same to Pthreads one. In Pthreads,
1088         pthread_detach just means that the resource of the thread will be destroyed automatically. While some operations like
1089         pthread_join will be rejected, some operations like pthread_kill will be accepted.
1090
1091         The problem is that detached thread can be suspended and resumed in JSC. For example, in jsc.cpp, we start the worker
1092         thread and detach it immediately. In worker thread, we will create VM and thus concurrent GC will suspend and resume
1093         the detached thread. However, in Windows WTF Threading, we have no reference to the detached thread. Thus we cannot
1094         perform suspend and resume operations onto the detached thread.
1095
1096         To solve the problem, we change Windows Threading mechanism drastically to align it to the Pthread semantics. In the
1097         new Threading, we have RefPtr<Thread> class. It holds a handle to a platform thread. We can perform threading operations
1098         with this class. For example, Thread::suspend is offered. And we use destructor of the thread local variable to release
1099         the resources held by RefPtr<Thread>. In Windows, Thread::detach does nothing because the resource will be destroyed
1100         automatically by RefPtr<Thread>.
1101
1102         To do so, we introduce ThreadHolder for Windows. This is similar to the previous ThreadIdentifierData for Pthreads.
1103         It holds RefPtr<Thread> in the thread local storage (technically, it is Fiber Local Storage in Windows). Thread::current()
1104         will return this reference.
1105
1106         The problematic situation is that the order of the deallocation of the thread local storage is not defined. So we should
1107         not touch thread local storage in the destructor of the thread local storage. To avoid such edge cases, we have
1108         currentThread() / Thread::currentID() APIs. They are safe to be called even in the destructor of the other thread local
1109         storage. And in Windows, in the FLS destructor, we will create the thread_local variable to defer the destruction of
1110         the ThreadHolder. We ensure that this destructor is called after the other FLS destructors are called in Windows 10.
1111
1112         This patch is performance neutral.
1113
1114         * WTF.xcodeproj/project.pbxproj:
1115         * benchmarks/ConditionSpeedTest.cpp:
1116         * benchmarks/LockFairnessTest.cpp:
1117         * benchmarks/LockSpeedTest.cpp:
1118         * wtf/AutomaticThread.cpp:
1119         (WTF::AutomaticThread::start):
1120         * wtf/CMakeLists.txt:
1121         * wtf/MainThread.h:
1122         * wtf/MemoryPressureHandler.h:
1123         * wtf/ParallelJobsGeneric.cpp:
1124         (WTF::ParallelEnvironment::ThreadPrivate::tryLockFor):
1125         (WTF::ParallelEnvironment::ThreadPrivate::workerThread):
1126         * wtf/ParallelJobsGeneric.h:
1127         (WTF::ParallelEnvironment::ThreadPrivate::ThreadPrivate): Deleted.
1128         * wtf/ParkingLot.cpp:
1129         (WTF::ParkingLot::forEachImpl):
1130         * wtf/ParkingLot.h:
1131         (WTF::ParkingLot::forEach):
1132         * wtf/PlatformRegisters.h: Renamed from Source/JavaScriptCore/runtime/PlatformThread.h.
1133         * wtf/RefPtr.h:
1134         (WTF::RefPtr::RefPtr):
1135         * wtf/ThreadFunctionInvocation.h:
1136         (WTF::ThreadFunctionInvocation::ThreadFunctionInvocation):
1137         * wtf/ThreadHolder.cpp: Added.
1138         (WTF::ThreadHolder::~ThreadHolder):
1139         (WTF::ThreadHolder::initialize):
1140         * wtf/ThreadHolder.h: Renamed from Source/WTF/wtf/ThreadIdentifierDataPthreads.h.
1141         (WTF::ThreadHolder::thread):
1142         (WTF::ThreadHolder::ThreadHolder):
1143         * wtf/ThreadHolderPthreads.cpp: Renamed from Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp.
1144         (WTF::ThreadHolder::initializeOnce):
1145         (WTF::ThreadHolder::current):
1146         (WTF::ThreadHolder::destruct):
1147         * wtf/ThreadHolderWin.cpp: Added.
1148         (WTF::threadMapMutex):
1149         (WTF::threadMap):
1150         (WTF::ThreadHolder::initializeOnce):
1151         (WTF::ThreadHolder::current):
1152         (WTF::ThreadHolder::destruct):
1153         * wtf/ThreadSpecific.h:
1154         * wtf/Threading.cpp:
1155         (WTF::Thread::normalizeThreadName):
1156         (WTF::threadEntryPoint):
1157         (WTF::Thread::create):
1158         (WTF::Thread::setCurrentThreadIsUserInteractive):
1159         (WTF::Thread::setCurrentThreadIsUserInitiated):
1160         (WTF::Thread::setGlobalMaxQOSClass):
1161         (WTF::Thread::adjustedQOSClass):
1162         (WTF::Thread::dump):
1163         (WTF::initializeThreading):
1164         (WTF::normalizeThreadName): Deleted.
1165         (WTF::createThread): Deleted.
1166         (WTF::setCurrentThreadIsUserInteractive): Deleted.
1167         (WTF::setCurrentThreadIsUserInitiated): Deleted.
1168         (WTF::setGlobalMaxQOSClass): Deleted.
1169         (WTF::adjustedQOSClass): Deleted.
1170         * wtf/Threading.h:
1171         (WTF::Thread::id):
1172         (WTF::Thread::operator==):
1173         (WTF::Thread::operator!=):
1174         (WTF::Thread::joinableState):
1175         (WTF::Thread::didBecomeDetached):
1176         (WTF::Thread::didJoin):
1177         (WTF::Thread::hasExited):
1178         (WTF::currentThread):
1179         * wtf/ThreadingPthreads.cpp:
1180         (WTF::Thread::Thread):
1181         (WTF::Thread::~Thread):
1182         (WTF::Thread::signalHandlerSuspendResume):
1183         (WTF::Thread::initializePlatformThreading):
1184         (WTF::initializeCurrentThreadEvenIfNonWTFCreated):
1185         (WTF::wtfThreadEntryPoint):
1186         (WTF::Thread::createInternal):
1187         (WTF::Thread::initializeCurrentThreadInternal):
1188         (WTF::Thread::changePriority):
1189         (WTF::Thread::waitForCompletion):
1190         (WTF::Thread::detach):
1191         (WTF::Thread::current):
1192         (WTF::Thread::currentID):
1193         (WTF::Thread::signal):
1194         (WTF::Thread::resume):
1195         (WTF::Thread::getRegisters):
1196         (WTF::Thread::didExit):
1197         (WTF::Thread::establish):
1198         (WTF::PthreadState::PthreadState): Deleted.
1199         (WTF::PthreadState::joinableState): Deleted.
1200         (WTF::PthreadState::pthreadHandle): Deleted.
1201         (WTF::PthreadState::didBecomeDetached): Deleted.
1202         (WTF::PthreadState::didExit): Deleted.
1203         (WTF::PthreadState::didJoin): Deleted.
1204         (WTF::PthreadState::hasExited): Deleted.
1205         (WTF::threadMapMutex): Deleted.
1206         (WTF::initializeThreading): Deleted.
1207         (WTF::threadMap): Deleted.
1208         (WTF::identifierByPthreadHandle): Deleted.
1209         (WTF::establishIdentifierForPthreadHandle): Deleted.
1210         (WTF::pthreadHandleForIdentifierWithLockAlreadyHeld): Deleted.
1211         (WTF::createThreadInternal): Deleted.
1212         (WTF::initializeCurrentThreadInternal): Deleted.
1213         (WTF::changeThreadPriority): Deleted.
1214         (WTF::waitForThreadCompletion): Deleted.
1215         (WTF::detachThread): Deleted.
1216         (WTF::threadDidExit): Deleted.
1217         (WTF::currentThread): Deleted.
1218         (WTF::signalThread): Deleted.
1219         * wtf/ThreadingWin.cpp:
1220         (WTF::Thread::Thread):
1221         (WTF::Thread::~Thread):
1222         (WTF::Thread::initializeCurrentThreadInternal):
1223         (WTF::Thread::initializePlatformThreading):
1224         (WTF::wtfThreadEntryPoint):
1225         (WTF::Thread::createInternal):
1226         (WTF::Thread::changePriority):
1227         (WTF::Thread::waitForCompletion):
1228         (WTF::Thread::detach):
1229         (WTF::Thread::resume):
1230         (WTF::Thread::getRegisters):
1231         (WTF::Thread::current):
1232         (WTF::Thread::currentID):
1233         (WTF::Thread::didExit):
1234         (WTF::Thread::establish):
1235         (WTF::initializeCurrentThreadInternal): Deleted.
1236         (WTF::threadMapMutex): Deleted.
1237         (WTF::initializeThreading): Deleted.
1238         (WTF::threadMap): Deleted.
1239         (WTF::storeThreadHandleByIdentifier): Deleted.
1240         (WTF::threadHandleForIdentifier): Deleted.
1241         (WTF::clearThreadHandleForIdentifier): Deleted.
1242         (WTF::createThreadInternal): Deleted.
1243         (WTF::changeThreadPriority): Deleted.
1244         (WTF::waitForThreadCompletion): Deleted.
1245         (WTF::detachThread): Deleted.
1246         (WTF::currentThread): Deleted.
1247         * wtf/WorkQueue.cpp:
1248         (WTF::WorkQueue::concurrentApply):
1249         * wtf/WorkQueue.h:
1250         * wtf/cocoa/WorkQueueCocoa.cpp:
1251         (WTF::dispatchQOSClass):
1252         * wtf/generic/WorkQueueGeneric.cpp:
1253         (WorkQueue::platformInitialize):
1254         (WorkQueue::platformInvalidate):
1255         * wtf/linux/MemoryPressureHandlerLinux.cpp:
1256         (WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
1257         (WTF::MemoryPressureHandler::EventFDPoller::~EventFDPoller):
1258         * wtf/win/MainThreadWin.cpp:
1259         (WTF::initializeMainThreadPlatform):
1260
1261 2017-04-11  Zan Dobersek  <zdobersek@igalia.com>
1262
1263         [GTK] Use the DisplayRefreshMonitor facilities
1264         https://bugs.webkit.org/show_bug.cgi?id=170599
1265
1266         Reviewed by Carlos Garcia Campos.
1267
1268         * wtf/Platform.h: Enable USE_REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR for the GTK+ port.
1269         * wtf/glib/RunLoopSourcePriority.h: Add the DisplayRefreshMonitorTimer entry that
1270         matches the value of LayerFlushTimer.
1271
1272 2017-04-11  Yusuke Suzuki  <utatane.tea@gmail.com>
1273
1274         [WebCore][JSC] ResourceUsageData.{timeOfNextEdenCollection,timeOfNextFullCollection} should be MonotonicTime
1275         https://bugs.webkit.org/show_bug.cgi?id=170725
1276
1277         Reviewed by Sam Weinig.
1278
1279         Make MonotonicTime more constexpr friendly mainly to annotate MonotonicTime::nan() as constexpr.
1280
1281         * wtf/MonotonicTime.h:
1282         (WTF::MonotonicTime::MonotonicTime):
1283         (WTF::MonotonicTime::fromRawSeconds):
1284         (WTF::MonotonicTime::infinity):
1285         (WTF::MonotonicTime::nan):
1286         (WTF::MonotonicTime::secondsSinceEpoch):
1287         (WTF::MonotonicTime::operator bool):
1288         (WTF::MonotonicTime::operator+):
1289         (WTF::MonotonicTime::operator-):
1290         (WTF::MonotonicTime::operator==):
1291         (WTF::MonotonicTime::operator!=):
1292         (WTF::MonotonicTime::operator<):
1293         (WTF::MonotonicTime::operator>):
1294         (WTF::MonotonicTime::operator<=):
1295         (WTF::MonotonicTime::operator>=):
1296
1297 2017-04-11  Yusuke Suzuki  <utatane.tea@gmail.com>
1298
1299         Unreviewed, build fix for Windows port after r215228
1300         https://bugs.webkit.org/show_bug.cgi?id=170723
1301
1302         * wtf/win/RunLoopWin.cpp:
1303         (WTF::RunLoop::TimerBase::timerFired):
1304
1305 2017-04-11  Yusuke Suzuki  <utatane.tea@gmail.com>
1306
1307         [JSC][GTK] Use RunLoop::Timer in GTK port
1308         https://bugs.webkit.org/show_bug.cgi?id=170723
1309
1310         Reviewed by Carlos Garcia Campos.
1311
1312         Add secondsUntilFire method. And add setName and setPriority
1313         for GTK RunLoop::Timer.
1314
1315         * wtf/RunLoop.h:
1316         * wtf/cf/RunLoopCF.cpp:
1317         (WTF::RunLoop::TimerBase::secondsUntilFire):
1318         * wtf/generic/RunLoopGeneric.cpp:
1319         (WTF::RunLoop::TimerBase::secondsUntilFire):
1320         * wtf/glib/RunLoopGLib.cpp:
1321         (WTF::RunLoop::TimerBase::setName):
1322         (WTF::RunLoop::TimerBase::secondsUntilFire):
1323         * wtf/win/RunLoopWin.cpp:
1324         (WTF::RunLoop::TimerBase::timerFired):
1325         (WTF::RunLoop::TimerBase::start):
1326         (WTF::RunLoop::TimerBase::isActive):
1327         (WTF::RunLoop::TimerBase::secondsUntilFire):
1328
1329 2017-04-11  Yusuke Suzuki  <utatane.tea@gmail.com>
1330
1331         [JSC] Enable JSRunLoopTimer for JSCOnly and Windows
1332         https://bugs.webkit.org/show_bug.cgi?id=170655
1333
1334         Reviewed by Carlos Garcia Campos.
1335
1336         This patch makes RunLoop::Timer in Generic and Windows thread-safe to use it
1337         in JSC's JSRunLoopTimer. Eventually, we would like to replace JSRunLoopTimer's
1338         platform-dependent implementation to WTF::RunLoop::Timer.
1339
1340         * wtf/RunLoop.h:
1341         * wtf/cf/RunLoopCF.cpp:
1342         (WTF::RunLoop::TimerBase::start):
1343         * wtf/generic/RunLoopGeneric.cpp:
1344         (WTF::RunLoop::TimerBase::ScheduledTask::EarliestSchedule::operator()):
1345         (WTF::RunLoop::populateTasks):
1346         (WTF::RunLoop::runImpl):
1347         (WTF::RunLoop::schedule):
1348         (WTF::RunLoop::scheduleAndWakeUp):
1349         (WTF::RunLoop::TimerBase::~TimerBase):
1350         (WTF::RunLoop::TimerBase::start):
1351         (WTF::RunLoop::TimerBase::stop):
1352         (WTF::RunLoop::TimerBase::isActive):
1353         * wtf/glib/RunLoopGLib.cpp:
1354         (WTF::RunLoop::TimerBase::TimerBase):
1355         * wtf/win/RunLoopWin.cpp:
1356         (WTF::RunLoop::TimerBase::timerFired):
1357         (WTF::RunLoop::TimerBase::start):
1358         (WTF::RunLoop::TimerBase::stop):
1359         (WTF::RunLoop::TimerBase::isActive):
1360
1361 2017-04-11  Zan Dobersek  <zdobersek@igalia.com>
1362
1363         REGRESSION(r213645): It made JSC tests super slow and timeout on AArch64 Linux
1364         https://bugs.webkit.org/show_bug.cgi?id=169510
1365
1366         Reviewed by Saam Barati.
1367
1368         Add the `volatile` qualifiers for ASM statements that set up ldxr and stxr
1369         instruction calls when HAVE(LL_SC) is enabled for aarch64 platforms.
1370
1371         This avoids indefinite execution when running GCC-compiled JSC on Linux.
1372         Specific bug or expected behavior that differs from Clang wasn't determined.
1373
1374         HAVE(LL_SC) is re-enabled on non-Darwin aarch64 platforms.
1375
1376         * wtf/Atomics.h:
1377         * wtf/Platform.h:
1378
1379 2017-04-10  Thorsten Glaser  <tg@mirbsd.de>
1380
1381         [GTK] Fix x32 build
1382         https://bugs.webkit.org/show_bug.cgi?id=170673
1383
1384         Reviewed by Carlos Alberto Lopez Perez.
1385
1386         * wtf/Platform.h:
1387
1388 2017-04-09  Yusuke Suzuki  <utatane.tea@gmail.com>
1389
1390         [WTF] Annotate Seconds' member functions and operators with constexpr
1391         https://bugs.webkit.org/show_bug.cgi?id=170662
1392
1393         Reviewed by Daniel Bates.
1394
1395         Annotate Seconds' member functions and operators with constexpr.
1396         It allows us to use Seconds calculation in compile time and use these
1397         calculation for static const global variables.
1398
1399         operator% is an exception: it uses fmod and it is not offered as constexpr.
1400
1401         * wtf/MathExtras.h:
1402         (defaultMinimumForClamp):
1403         (defaultMaximumForClamp):
1404         (clampToAccepting64):
1405         Super unfortunate ugly code. This is because GCC 4.9 does not support C++14 relaxed constexpr.
1406
1407         * wtf/Seconds.h:
1408         (WTF::Seconds::Seconds):
1409         (WTF::Seconds::value):
1410         (WTF::Seconds::minutes):
1411         (WTF::Seconds::seconds):
1412         (WTF::Seconds::milliseconds):
1413         (WTF::Seconds::microseconds):
1414         (WTF::Seconds::nanoseconds):
1415         (WTF::Seconds::operator bool):
1416         (WTF::Seconds::operator+):
1417         (WTF::Seconds::operator-):
1418         (WTF::Seconds::operator*):
1419         (WTF::Seconds::operator/):
1420         (WTF::Seconds::operator==):
1421         (WTF::Seconds::operator!=):
1422         (WTF::Seconds::operator<):
1423         (WTF::Seconds::operator>):
1424         (WTF::Seconds::operator<=):
1425         (WTF::Seconds::operator>=):
1426
1427 2017-04-09  Chris Dumez  <cdumez@apple.com>
1428
1429         Start dropping Timer API dealing with double
1430         https://bugs.webkit.org/show_bug.cgi?id=170649
1431
1432         Reviewed by Yusuke Suzuki.
1433
1434         Start dropping Timer API dealing with double as people should use Seconds now.
1435
1436         * wtf/RunLoopTimer.h:
1437         * wtf/glib/MainThreadGLib.cpp:
1438         (WTF::MainThreadDispatcher::schedule):
1439
1440 2017-04-07  Keith Miller  <keith_miller@apple.com>
1441
1442         Unreviewed, remove constexpr function since GTK didn't like it.
1443
1444         * wtf/PriorityQueue.h:
1445         (WTF::PriorityQueue::parentOf):
1446
1447 2017-04-07  Chris Dumez  <cdumez@apple.com>
1448
1449         Start using MonotonicTime / Seconds in Timer class
1450         https://bugs.webkit.org/show_bug.cgi?id=170625
1451
1452         Reviewed by Simon Fraser.
1453
1454         Add modulo operator to MonotonicTime.
1455
1456         * wtf/MonotonicTime.h:
1457         (WTF::MonotonicTime::operator%):
1458
1459 2017-04-07  Keith Miller  <keith_miller@apple.com>
1460
1461         Add a PriorityQueue class
1462         https://bugs.webkit.org/show_bug.cgi?id=170579
1463
1464         Reviewed by Saam Barati.
1465
1466         This patch adds a new PriorityQueue class that is backed by
1467         WTF::Vector.  It also has a number of other niceties such as being
1468         able to iterate the queue and increase or decrease keys.
1469
1470         One note is that increaseKey and decreaseKey are O(n) rather than
1471         O(log(n)).  Traditionally, the lookup of the key is done with a
1472         hash map but that's not feasible here.  This is because unless the
1473         queue's element type is a pointer there is no good way maintain a
1474         persistent reference to every entry in the queue while we sift.
1475         The only way to update the location of an entry is to do a hash
1476         table lookup with the entry's hash but this is probably more
1477         expensive than just doing a linear search.
1478
1479         Also, add comparison operator functions, which can be passed to PriorityQueue.
1480
1481         * WTF.xcodeproj/project.pbxproj:
1482         * wtf/MathExtras.h:
1483         (isLessThan):
1484         (isLessThanEqual):
1485         (isGreaterThan):
1486         (isGreaterThanEqual):
1487         * wtf/PriorityQueue.h: Added.
1488         (WTF::PriorityQueue::size):
1489         (WTF::PriorityQueue::isEmpty):
1490         (WTF::PriorityQueue::enqueue):
1491         (WTF::PriorityQueue::peek):
1492         (WTF::PriorityQueue::dequeue):
1493         (WTF::PriorityQueue::decreaseKey):
1494         (WTF::PriorityQueue::increaseKey):
1495         (WTF::PriorityQueue::begin):
1496         (WTF::PriorityQueue::end):
1497         (WTF::PriorityQueue::isValidHeap):
1498         (WTF::PriorityQueue::parentOf):
1499         (WTF::PriorityQueue::leftChildOf):
1500         (WTF::PriorityQueue::rightChildOf):
1501         (WTF::PriorityQueue::siftUp):
1502         (WTF::PriorityQueue::siftDown):
1503
1504 2017-04-07  Alex Christensen  <achristensen@webkit.org>
1505
1506         Use audit_token_t instead of pid_t for checking sandbox of other processes
1507         https://bugs.webkit.org/show_bug.cgi?id=170616
1508         <rdar://problem/31158189>
1509
1510         Reviewed by Daniel Bates.
1511
1512         * wtf/spi/darwin/SandboxSPI.h:
1513         Declare more SPI.
1514
1515 2017-04-07  Ting-Wei Lan  <lantw44@gmail.com>
1516
1517         Include cstdio before using sscanf and stderr
1518         https://bugs.webkit.org/show_bug.cgi?id=170098
1519
1520         Reviewed by Michael Catanzaro.
1521
1522         * wtf/NumberOfCores.cpp:
1523
1524 2017-04-07  Saam Barati  <sbarati@apple.com>
1525
1526         WebAssembly: Make to a compilation API that allows for multi-VM concurrent compilations of Wasm Modules
1527         https://bugs.webkit.org/show_bug.cgi?id=170488
1528
1529         Reviewed by JF Bastien.
1530
1531         * wtf/SharedTask.h: Make SharedTaskFunctor forward its arguments.
1532
1533 2017-04-07  Carlos Garcia Campos  <cgarcia@igalia.com>
1534
1535         [GTK] Update the priorities used in glib main loop sources
1536         https://bugs.webkit.org/show_bug.cgi?id=170457
1537
1538         Reviewed by Žan Doberšek.
1539
1540         Add an enum to define prirorities used in different GLib main sources. It allows to give them a better name
1541         than high, low, medium, etc., but also to document them and other GLib based ports can define their own
1542         values without changing all the places where they are used. The default values are based on the priorities
1543         pre-defined by GLib.
1544
1545         * wtf/glib/MainThreadGLib.cpp:
1546         (WTF::MainThreadDispatcher::MainThreadDispatcher):
1547         * wtf/glib/RunLoopGLib.cpp:
1548         (WTF::RunLoop::RunLoop):
1549         (WTF::RunLoop::dispatchAfter):
1550         (WTF::RunLoop::TimerBase::TimerBase):
1551         * wtf/glib/RunLoopSourcePriority.h: Added.
1552         * wtf/linux/MemoryPressureHandlerLinux.cpp:
1553         (WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
1554
1555 2017-04-06  Filip Pizlo  <fpizlo@apple.com>
1556
1557         Linear scan should run liveness only once
1558         https://bugs.webkit.org/show_bug.cgi?id=170569
1559
1560         Reviewed by Keith Miller.
1561         
1562         Have Liveness<> call Adapter::prepareToCompute(), since this makes it a lot easier to implement
1563         constraint generation, since the constraint generator now gets to run after the Adapter is fully
1564         constructed.
1565         
1566         * wtf/IndexMap.h:
1567         (WTF::IndexMap::append): Also make this a bit more versatile.
1568         * wtf/Liveness.h:
1569         (WTF::Liveness::LocalCalc::Iterable::contains):
1570         (WTF::Liveness::Iterable::contains):
1571         (WTF::Liveness::compute):
1572
1573 2017-04-06  Andreas Kling  <akling@apple.com>
1574
1575         Kill any WebContent process using over 16 GB of memory.
1576         https://bugs.webkit.org/show_bug.cgi?id=170515
1577         <rdar://problem/29930931>
1578
1579         Reviewed by Antti Koivisto.
1580
1581         Restructure the code since it was getting out of sync with the intended behavior.
1582         Now there's a thresholdForMemoryKill() which returns the current memory limit based
1583         on the process status.
1584
1585         The memory usage policy is separated from the killing, and now only drives the
1586         asynchronous invocations of pressure relief that occur when we pass over one of
1587         the policy edges (now 1GB for Conservative, 2GB for Strict.)
1588
1589         Removed the "Panic" policy and moved the memory kill logic to shrinkOrDie().
1590
1591         Behavior as of this patch:
1592
1593             - Everyone gets killed over 16 GB.
1594             - Inactive processes get killed over 4 GB.
1595             - Strict memory usage policy kicks in at 2 GB.
1596             - Conservative memory usage policy at 1 GB.
1597
1598         Like before, we make a best-effort attempt to free up memory before killing the process.
1599
1600         * wtf/MemoryPressureHandler.cpp:
1601         (WTF::toString):
1602         (WTF::MemoryPressureHandler::thresholdForMemoryKill):
1603         (WTF::thresholdForPolicy):
1604         (WTF::policyForFootprint):
1605         (WTF::MemoryPressureHandler::shrinkOrDie):
1606         (WTF::MemoryPressureHandler::setMemoryUsagePolicyBasedOnFootprint):
1607         (WTF::MemoryPressureHandler::measurementTimerFired):
1608         * wtf/MemoryPressureHandler.h:
1609
1610 2017-04-05  Andreas Kling  <akling@apple.com>
1611
1612         Make inactive web processes behave as though under memory pressure.
1613         https://bugs.webkit.org/show_bug.cgi?id=170042
1614         <rdar://problem/31038445>
1615
1616         Reviewed by Antti Koivisto.
1617
1618         Once a web process becomes inactive, let's try to reduce its impact
1619         on memory usage by treating it as if it's under memory pressure until
1620         it becomes active.
1621
1622         * wtf/MemoryPressureHandler.cpp:
1623         (WTF::MemoryPressureHandler::setProcessState):
1624         (WTF::MemoryPressureHandler::isUnderMemoryPressure):
1625         * wtf/MemoryPressureHandler.h:
1626         (WTF::MemoryPressureHandler::isUnderMemoryPressure): Deleted.
1627
1628 2017-04-05  Yusuke Suzuki  <utatane.tea@gmail.com>
1629
1630         [JSC] Suppress warnings in GCC
1631         https://bugs.webkit.org/show_bug.cgi?id=170501
1632
1633         Reviewed by Keith Miller.
1634
1635         Add a new macro UNUSED_FUNCTION to annotate unused static functions.
1636         #pragma GCC diagnostic ignored "-Wunused-function" does not work.
1637
1638         * wtf/Compiler.h:
1639
1640 2017-04-04  Filip Pizlo  <fpizlo@apple.com>
1641
1642         Air::eliminateDeadCode() should not use a HashSet
1643         https://bugs.webkit.org/show_bug.cgi?id=170487
1644
1645         Reviewed by Saam Barati.
1646         
1647         BitVector::iterator knows when it's at the end. Expose this functionality.
1648
1649         * wtf/BitVector.h:
1650         (WTF::BitVector::iterator::isAtEnd):
1651
1652 2017-04-04  Keith Miller  <keith_miller@apple.com>
1653
1654         WebAssembly: ModuleInformation should be a ref counted thing that can be shared across threads.
1655         https://bugs.webkit.org/show_bug.cgi?id=170478
1656
1657         Reviewed by Saam Barati.
1658
1659         This adds a new String::fromUTF8 that converts a vector of characters to
1660         a string.
1661
1662         Also, it cleans up some style.
1663
1664         * wtf/text/WTFString.h:
1665         (WTF::String::fromUTF8):
1666         * wtf/unicode/UTF8.cpp:
1667         (WTF::Unicode::convertLatin1ToUTF8):
1668
1669 2017-04-04  Filip Pizlo  <fpizlo@apple.com>
1670
1671         B3::fixSSA() needs a tune-up
1672         https://bugs.webkit.org/show_bug.cgi?id=170485
1673
1674         Reviewed by Saam Barati.
1675         
1676         This makes IndexSparseSet capable of being used as a map if you instantiate it with
1677         KeyValuePair<unsigned, ValueType>.
1678
1679         * wtf/HashTraits.h:
1680         * wtf/IndexSparseSet.h:
1681         (WTF::DefaultIndexSparseSetTraits::create):
1682         (WTF::DefaultIndexSparseSetTraits::key):
1683         (WTF::OverflowHandler>::IndexSparseSet):
1684         (WTF::OverflowHandler>::add):
1685         (WTF::OverflowHandler>::set):
1686         (WTF::OverflowHandler>::remove):
1687         (WTF::OverflowHandler>::clear):
1688         (WTF::OverflowHandler>::size):
1689         (WTF::OverflowHandler>::isEmpty):
1690         (WTF::OverflowHandler>::contains):
1691         (WTF::OverflowHandler>::sort):
1692         (WTF::IndexSparseSet<OverflowHandler>::IndexSparseSet): Deleted.
1693         (WTF::IndexSparseSet<OverflowHandler>::add): Deleted.
1694         (WTF::IndexSparseSet<OverflowHandler>::remove): Deleted.
1695         (WTF::IndexSparseSet<OverflowHandler>::clear): Deleted.
1696         (WTF::IndexSparseSet<OverflowHandler>::size): Deleted.
1697         (WTF::IndexSparseSet<OverflowHandler>::isEmpty): Deleted.
1698         (WTF::IndexSparseSet<OverflowHandler>::contains): Deleted.
1699         (WTF::IndexSparseSet<OverflowHandler>::sort): Deleted.
1700         * wtf/Liveness.h:
1701         (WTF::Liveness::LocalCalc::Iterable::iterator::iterator):
1702         (WTF::Liveness::workset):
1703
1704 2017-04-04  Filip Pizlo  <fpizlo@apple.com>
1705
1706         Don't need to Air::reportUsedRegisters for wasm at -O1
1707         https://bugs.webkit.org/show_bug.cgi?id=170459
1708
1709         Reviewed by Saam Barati.
1710         
1711         Just moved the liveness computation into a method, which enabled me to do the profiling
1712         that I used to write this patch.
1713
1714         * wtf/Liveness.h:
1715         (WTF::Liveness::Liveness):
1716         (WTF::Liveness::compute):
1717
1718 2017-04-03  Filip Pizlo  <fpizlo@apple.com>
1719
1720         Air liveness should build constraints and solve them rather than repeatedly parsing IR
1721         https://bugs.webkit.org/show_bug.cgi?id=170421
1722
1723         Reviewed by Saam Barati.
1724
1725         * wtf/Vector.h:
1726         (WTF::minCapacity>::appendIfNotContains): Because sometimes Vector<> is the best kind of set.
1727
1728 2017-04-03  Yusuke Suzuki  <utatane.tea@gmail.com>
1729
1730         [WTF] Introduce WTF::RandomDevice which keeps /dev/urandom opened
1731         https://bugs.webkit.org/show_bug.cgi?id=170095
1732
1733         Reviewed by Michael Catanzaro.
1734
1735         In this patch, we introduce RandomDevice, which keeps /dev/urandom opened
1736         to avoid repeatedly open and close urandom file descriptor in Linux.
1737
1738         The purpose is similar to std::random_device, but WTF::RandomDevice explicitly
1739         avoids using ARC4, which is recently attempted to be removed from the WebKit
1740         tree[1].
1741
1742         [1]: https://trac.webkit.org/r214329
1743
1744         * WTF.xcodeproj/project.pbxproj:
1745         * wtf/CMakeLists.txt:
1746         * wtf/OSRandomSource.cpp:
1747         (WTF::cryptographicallyRandomValuesFromOS):
1748         (WTF::crashUnableToOpenURandom): Deleted.
1749         (WTF::crashUnableToReadFromURandom): Deleted.
1750         * wtf/RandomDevice.cpp: Copied from Source/WTF/wtf/OSRandomSource.cpp.
1751         (WTF::crashUnableToOpenURandom):
1752         (WTF::crashUnableToReadFromURandom):
1753         (WTF::RandomDevice::RandomDevice):
1754         (WTF::RandomDevice::~RandomDevice):
1755         (WTF::RandomDevice::cryptographicallyRandomValues):
1756         * wtf/RandomDevice.h: Added.
1757
1758 2017-04-03  Filip Pizlo  <fpizlo@apple.com>
1759
1760         WTF::Liveness should have an API that focuses on actions at instruction boundaries
1761         https://bugs.webkit.org/show_bug.cgi?id=170407
1762
1763         Reviewed by Keith Miller.
1764         
1765         Change the Liveness<> API to handle early and late things in one lump inside forEachUse
1766         and forEachDef functions. This reduces the amount of different functions that Liveness<>
1767         expects from its adaptor. This makes it easier to implement optimizations that cache the
1768         use/def behavior of each instruction boundary.
1769
1770         * wtf/Liveness.h:
1771         (WTF::Liveness::Liveness):
1772         (WTF::Liveness::LocalCalc::execute):
1773
1774 2017-04-01  Csaba Osztrogonác  <ossy@webkit.org>
1775
1776         Mac cmake buildfix after 214586.
1777         https://bugs.webkit.org/show_bug.cgi?id=170381
1778
1779         Unreviewed.
1780
1781         * wtf/BlockPtr.h:
1782
1783 2017-03-30  Filip Pizlo  <fpizlo@apple.com>
1784
1785         Air should support linear scan for optLevel<2
1786         https://bugs.webkit.org/show_bug.cgi?id=170161
1787
1788         Reviewed by Saam Barati.
1789         
1790         This change introduces a new low-latency register allocator. It can allocate registers very
1791         quickly by doing a relatively poor job. Implementing this algorithm required beefing up some of
1792         our core algorithms.
1793
1794         * WTF.xcodeproj/project.pbxproj:
1795         * wtf/CMakeLists.txt:
1796         * wtf/Deque.h: Make it possible to do some basic priority queueing with this data structure.
1797         (WTF::inlineCapacity>::removeAllMatching):
1798         (WTF::inlineCapacity>::appendAndBubble):
1799         (WTF::inlineCapacity>::takeLast):
1800         * wtf/IndexKeyType.h: Added. This makes it possible to use IndexMap and IndexSet with value or pointer types. Previously they just worked with pointer types.
1801         (WTF::IndexKeyType::index):
1802         * wtf/IndexMap.h: Adopt IndexKeyType.
1803         (WTF::IndexMap::operator[]):
1804         (WTF::IndexMap::append):
1805         * wtf/IndexSet.h: Adopt IndexKeyType.
1806         (WTF::IndexSet::add):
1807         (WTF::IndexSet::addAll):
1808         (WTF::IndexSet::remove):
1809         (WTF::IndexSet::contains):
1810         (WTF::IndexSet::Iterable::iterator::operator*):
1811         * wtf/Range.h: Added. This used to be B3::HeapRange. This generalizes that data structure to any kind of range stuff.
1812         (WTF::Range::Range):
1813         (WTF::Range::top):
1814         (WTF::Range::operator==):
1815         (WTF::Range::operator!=):
1816         (WTF::Range::operator bool):
1817         (WTF::Range::operator|):
1818         (WTF::Range::operator|=):
1819         (WTF::Range::begin):
1820         (WTF::Range::end):
1821         (WTF::Range::overlaps):
1822         (WTF::Range::dump):
1823         * wtf/RangeSet.h:
1824         (WTF::RangeSet::add):
1825
1826 2017-03-25  Yusuke Suzuki  <utatane.tea@gmail.com>
1827
1828         [JSC] Move platformThreadSignal to WTF
1829         https://bugs.webkit.org/show_bug.cgi?id=170097
1830
1831         Reviewed by Mark Lam.
1832
1833         * wtf/Threading.h:
1834         * wtf/ThreadingPthreads.cpp:
1835         (WTF::signalThread):
1836
1837 2017-03-26  Filip Pizlo  <fpizlo@apple.com>
1838
1839         B3::fixSSA should do liveness pruning
1840         https://bugs.webkit.org/show_bug.cgi?id=170111
1841
1842         Reviewed by Saam Barati.
1843         
1844         Move Air::Liveness<> to WTF::Liveness<>. This is pretty easy since Air::Liveness<> was
1845         already fairly generic. It leverages the CFG concept so that it can understand many
1846         different kinds of basic blocks. It doesn't try to understand the contents of basic
1847         blocks; it just asks the adaptor for the block size and asks for the early/late
1848         uses/defs of each thing in the block.
1849         
1850         This makes it easy to create a B3::VariableLiveness, which fixSSA then uses for
1851         pruning. One of the new features is the Liveness::LiveAtHead nested class, which you
1852         instantiate if you want to perform liveAtHead queries, which SSA construction wants to
1853         do.
1854         
1855         This also fixes https://bugs.webkit.org/show_bug.cgi?id=170102#c12
1856
1857         * WTF.xcodeproj/project.pbxproj:
1858         * wtf/CMakeLists.txt:
1859         * wtf/Liveness.h: Added.
1860         (WTF::Liveness::Liveness):
1861         (WTF::Liveness::LocalCalc::LocalCalc):
1862         (WTF::Liveness::LocalCalc::Iterable::Iterable):
1863         (WTF::Liveness::LocalCalc::Iterable::iterator::iterator):
1864         (WTF::Liveness::LocalCalc::Iterable::iterator::operator++):
1865         (WTF::Liveness::LocalCalc::Iterable::iterator::operator*):
1866         (WTF::Liveness::LocalCalc::Iterable::iterator::operator==):
1867         (WTF::Liveness::LocalCalc::Iterable::iterator::operator!=):
1868         (WTF::Liveness::LocalCalc::Iterable::begin):
1869         (WTF::Liveness::LocalCalc::Iterable::end):
1870         (WTF::Liveness::LocalCalc::Iterable::contains):
1871         (WTF::Liveness::LocalCalc::live):
1872         (WTF::Liveness::LocalCalc::isLive):
1873         (WTF::Liveness::LocalCalc::execute):
1874         (WTF::Liveness::rawLiveAtHead):
1875         (WTF::Liveness::Iterable::Iterable):
1876         (WTF::Liveness::Iterable::iterator::iterator):
1877         (WTF::Liveness::Iterable::iterator::operator*):
1878         (WTF::Liveness::Iterable::iterator::operator++):
1879         (WTF::Liveness::Iterable::iterator::operator==):
1880         (WTF::Liveness::Iterable::iterator::operator!=):
1881         (WTF::Liveness::Iterable::begin):
1882         (WTF::Liveness::Iterable::end):
1883         (WTF::Liveness::Iterable::contains):
1884         (WTF::Liveness::liveAtHead):
1885         (WTF::Liveness::liveAtTail):
1886         (WTF::Liveness::workset):
1887         (WTF::Liveness::LiveAtHead::LiveAtHead):
1888         (WTF::Liveness::LiveAtHead::isLiveAtHead):
1889
1890 2017-03-25  Filip Pizlo  <fpizlo@apple.com>
1891
1892         Air::Liveness shouldn't need HashSets
1893         https://bugs.webkit.org/show_bug.cgi?id=170102
1894
1895         Reviewed by Yusuke Suzuki.
1896
1897         * wtf/IndexSparseSet.h: Add some helpers for a HashSet-free liveness analysis.
1898         (WTF::IndexSparseSet::values):
1899         (WTF::IndexSparseSet<OverflowHandler>::sort):
1900         * wtf/StdLibExtras.h:
1901         (WTF::mergeDeduplicatedSorted): Rapidly merge two sorted lists that don't have duplicates to produce a new sorted list that doesn't have duplicates.
1902         * wtf/Vector.h:
1903         (WTF::minCapacity>::uncheckedAppend): Inline this!
1904         (WTF::removeRepeatedElements): This is a version of std::unique() that works naturally for Vectors.
1905
1906 2017-03-26  Filip Pizlo  <fpizlo@apple.com>
1907
1908         Air should use RegisterSet for RegLiveness
1909         https://bugs.webkit.org/show_bug.cgi?id=170108
1910
1911         Reviewed by Yusuke Suzuki.
1912
1913         * wtf/Atomics.h:
1914         (WTF::ensurePointer): This is a useful replacement for std::once, which requires less fencing.
1915         * wtf/Bitmap.h: Add more utilities.
1916         (WTF::Bitmap::iterator::iterator): An iterator for set bits.
1917         (WTF::Bitmap::iterator::operator*):
1918         (WTF::Bitmap::iterator::operator++):
1919         (WTF::Bitmap::iterator::operator==):
1920         (WTF::Bitmap::iterator::operator!=):
1921         (WTF::Bitmap::begin):
1922         (WTF::Bitmap::end):
1923         (WTF::WordType>::subsumes): a.subsumes(b) if all of b's set bits are set in a.
1924         (WTF::WordType>::findBit): find next set or clear bit.
1925
1926 2017-03-24  JF Bastien  <jfbastien@apple.com>
1927
1928         WebAssembly: store state in TLS instead of on VM
1929         https://bugs.webkit.org/show_bug.cgi?id=169611
1930
1931         Reviewed by Filip Pizlo.
1932
1933         * wtf/FastTLS.h: reserve one key for WebAssembly, delete a bunch
1934         of dead code which clang couldn't compile (it's valid GCC assembly
1935         which LLVM dislikes).
1936
1937 2017-03-24  Ryan Haddad  <ryanhaddad@apple.com>
1938
1939         Unreviewed, rolling out r214351.
1940
1941         This change caused API test
1942         WebKit1.DidCreateJavaScriptContextBackForwardCacheTest to
1943         fail.
1944
1945         Reverted changeset:
1946
1947         "Make inactive web processes behave as though under memory
1948         pressure."
1949         https://bugs.webkit.org/show_bug.cgi?id=170042
1950         http://trac.webkit.org/changeset/214351
1951
1952 2017-03-24  Chris Dumez  <cdumez@apple.com>
1953
1954         Unreviewed, rolling out r214329.
1955
1956         Significantly regressed Speedometer
1957
1958         Reverted changeset:
1959
1960         "window.crypto.getRandomValues() uses the insecure RC4 RNG"
1961         https://bugs.webkit.org/show_bug.cgi?id=169623
1962         http://trac.webkit.org/changeset/214329
1963
1964 2017-03-24  Andreas Kling  <akling@apple.com>
1965
1966         Make inactive web processes behave as though under memory pressure.
1967         <https://webkit.org/b/170042>
1968
1969         Reviewed by Antti Koivisto.
1970
1971         Once a web process becomes inactive, let's try to reduce its impact
1972         on memory usage by treating it as if it's under memory pressure until
1973         it becomes active.
1974
1975         * wtf/MemoryPressureHandler.cpp:
1976         (WTF::MemoryPressureHandler::setProcessState):
1977         (WTF::MemoryPressureHandler::isUnderMemoryPressure):
1978         * wtf/MemoryPressureHandler.h:
1979         (WTF::MemoryPressureHandler::isUnderMemoryPressure): Deleted.
1980
1981 2017-03-23  Michael Catanzaro  <mcatanzaro@igalia.com>
1982
1983         window.crypto.getRandomValues() uses the insecure RC4 RNG
1984         https://bugs.webkit.org/show_bug.cgi?id=169623
1985
1986         Reviewed by Alex Christensen.
1987
1988         Remove the RC4 random generator in favor of using OS randomness for now. This is basically
1989         a merge of https://codereview.chromium.org/1431233002 from Blink, original author "eroman".
1990
1991         * wtf/CryptographicallyRandomNumber.cpp:
1992         (WTF::cryptographicallyRandomNumber):
1993         (WTF::cryptographicallyRandomValues):
1994         (): Deleted.
1995
1996 2017-03-23  Tomas Popela  <tpopela@redhat.com>
1997
1998         Fix uninitialized public members in WTF
1999         https://bugs.webkit.org/show_bug.cgi?id=169676
2000
2001         Reviewed by Michael Catanzaro.
2002
2003         Found by Coverity scan.
2004
2005         * wtf/Bag.h:
2006         * wtf/HashTable.h:
2007         * wtf/HashTraits.h:
2008         * wtf/Insertion.h:
2009         * wtf/OrderMaker.h:
2010         * wtf/ParallelJobsGeneric.h:
2011
2012 2017-03-22  Andreas Kling  <akling@apple.com>
2013
2014         Let MemoryPressureHandler track whether the process is active or inactive.
2015         <https://webkit.org/b/169990>
2016
2017         Reviewed by Antti Koivisto.
2018
2019         An active process is a process that meets any of these criteria:
2020
2021             - Has had a visible Page in an active window in the last hour
2022             - Is playing audio
2023
2024         This replaces the old mechanism where MemoryPressureHandler would invoke
2025         a callback to know whether the process was eligible for a memory kill.
2026         Instead we now plumb the relevant information down from WebCore and kill
2027         based on this activity state.
2028
2029         * wtf/MemoryPressureHandler.cpp:
2030         (WTF::MemoryPressureHandler::measurementTimerFired):
2031         (WTF::MemoryPressureHandler::setProcessState):
2032         * wtf/MemoryPressureHandler.h:
2033         (WTF::MemoryPressureHandler::setMemoryKillCallback):
2034         (WTF::MemoryPressureHandler::processState):
2035         (WTF::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback): Deleted.
2036
2037 2017-03-20  Simon Fraser  <simon.fraser@apple.com>
2038
2039         Add a system trace point for memory warning handling
2040         https://bugs.webkit.org/show_bug.cgi?id=169893
2041
2042         Reviewed by Zalan Bujtas.
2043
2044         Make it possible to pass data to the Begin trace point.
2045
2046         * wtf/SystemTracing.h:
2047         (WTF::TraceScope::TraceScope):
2048
2049 2017-03-17  Said Abou-Hallawa  <sabouhallawa@apple.com>
2050
2051         Time channel attack on SVG Filters
2052         https://bugs.webkit.org/show_bug.cgi?id=118689
2053
2054         Reviewed by Simon Fraser.
2055
2056         Performing arithmetic operations on subnormal floating-point numbers is
2057         very expensive. Normalizing the floating-point number to the minimum normal
2058         value should accelerate the calculations and there won't be a noticeable
2059         difference in the result since all the subnormal values and the minimum
2060         normal value are all very close to zero.
2061
2062         * wtf/MathExtras.h:
2063         (normalizedFloat):
2064
2065 2017-03-11  Filip Pizlo  <fpizlo@apple.com>
2066
2067         Air should be powerful enough to support Tmp-splitting
2068         https://bugs.webkit.org/show_bug.cgi?id=169515
2069
2070         Reviewed by Saam Barati.
2071         
2072         Teach IndexMap how to handle types that don't have a default constructor. This makes it
2073         easy to create a IndexMap<BasicBlock, InsertionSet>, which is a super powerful
2074         construct.
2075
2076         * wtf/IndexMap.h:
2077         (WTF::IndexMap::IndexMap):
2078         (WTF::IndexMap::resize):
2079         (WTF::IndexMap::clear):
2080
2081 2017-03-16  Simon Fraser  <simon.fraser@apple.com>
2082
2083         Improve the system tracing points
2084         https://bugs.webkit.org/show_bug.cgi?id=169790
2085
2086         Reviewed by Zalan Bujtas.
2087
2088         Use a more cohesive set of system trace points that give a good overview of what
2089         WebKit is doing. Added points for resource loading, render tree building, sync messages
2090         to the web process, async image decode, WASM and fetching cookies.
2091
2092         * wtf/SystemTracing.h:
2093
2094 2017-03-16  Carlos Garcia Campos  <cgarcia@igalia.com>
2095
2096         [UNIX] Implement currentSearchLocaleID() and currentTextBreakLocaleID()
2097         https://bugs.webkit.org/show_bug.cgi?id=169745
2098
2099         Reviewed by Yusuke Suzuki.
2100
2101         Add a common implementation for Unix based ports using setlocale.
2102
2103         * wtf/PlatformGTK.cmake:
2104         * wtf/PlatformJSCOnly.cmake:
2105         * wtf/text/gtk/TextBreakIteratorInternalICUGtk.cpp: Removed.
2106         * wtf/text/unix/TextBreakIteratorInternalICUUnix.cpp: Renamed from Source/WTF/wtf/text/jsconly/TextBreakIteratorInternalICUJSCOnly.cpp.
2107         (WTF::currentSearchLocaleID):
2108         (WTF::currentTextBreakLocaleID):
2109
2110 2017-03-16  Carlos Garcia Campos  <cgarcia@igalia.com>
2111
2112         [GLIB] MainThread implementation is not GTK+ specific
2113         https://bugs.webkit.org/show_bug.cgi?id=169736
2114
2115         Reviewed by Yusuke Suzuki.
2116
2117         It's implemented in MainThreadGLib.cpp for glib based ports, so ifdefs in MainThread should not be
2118         PLATFORM(GTK) but USE(GLIB).
2119
2120         * wtf/MainThread.cpp:
2121         * wtf/MainThread.h:
2122
2123 2017-03-15  Carlos Alberto Lopez Perez  <clopez@igalia.com>
2124
2125         [CMake][JSCOnly] Fix build with GLib event loop
2126         https://bugs.webkit.org/show_bug.cgi?id=169730
2127
2128         Reviewed by Michael Catanzaro.
2129
2130         * wtf/MainThread.cpp:
2131         * wtf/PlatformJSCOnly.cmake: WorkQueueGLib was removed in r199713.
2132
2133 2017-03-15  Dean Jackson  <dino@apple.com>
2134
2135         Sort Xcode project files
2136         https://bugs.webkit.org/show_bug.cgi?id=169669
2137
2138         Reviewed by Antoine Quint.
2139
2140         * WTF.xcodeproj/project.pbxproj:
2141
2142 2017-03-14  Filip Pizlo  <fpizlo@apple.com>
2143
2144         Fix some typos in this benchmark.
2145
2146         Rubber stamped by Saam Barati.
2147
2148         * benchmarks/HashSetDFGReplay.cpp:
2149         (main):
2150
2151 2017-03-14  Filip Pizlo  <fpizlo@apple.com>
2152
2153         Record the HashSet/HashMap operations in DFG/FTL/B3 and replay them in a benchmark
2154         https://bugs.webkit.org/show_bug.cgi?id=169590
2155
2156         Reviewed by Saam Barati.
2157         
2158         This adds LoggingHashSet and LoggingHashMap, which are drop-in replacements for HashSet and
2159         HashMap that log everything that they do, so that you can replay it later.
2160         
2161         This also adds a benchmark (HashSetDFGReplay) based on doing a recording of some of the HashSets
2162         in the DFG compiler.
2163
2164         * WTF.xcodeproj/project.pbxproj:
2165         * benchmarks/HashSetDFGReplay.cpp: Added.
2166         (benchmark):
2167         (main):
2168         * wtf/CMakeLists.txt:
2169         * wtf/GlobalVersion.cpp: Added.
2170         (WTF::newGlobalVersion):
2171         * wtf/GlobalVersion.h: Added.
2172         * wtf/HashMap.h:
2173         (WTF::X>::swap):
2174         * wtf/HashSet.h:
2175         (WTF::V>::addVoid):
2176         * wtf/LoggingHashID.h: Added.
2177         (WTF::LoggingHashID::LoggingHashID):
2178         (WTF::LoggingHashID::dump):
2179         * wtf/LoggingHashMap.h: Added.
2180         * wtf/LoggingHashSet.h: Added.
2181         * wtf/LoggingHashTraits.h: Added.
2182         (WTF::LoggingHashKeyTraits::print):
2183         (WTF::LoggingHashValueTraits::print):
2184
2185 2017-03-13  Jer Noble  <jer.noble@apple.com>
2186
2187         Make classes used by Media Stream encode/decode friendly
2188         https://bugs.webkit.org/show_bug.cgi?id=169567
2189
2190         Reviewed by Eric Carlson.
2191
2192         * wtf/MediaTime.h:
2193         (WTF::MediaTime::encode):
2194         (WTF::MediaTime::decode):
2195
2196 2017-03-14  Yusuke Suzuki  <utatane.tea@gmail.com>
2197
2198         Add secondsAs<T> methods to Seconds to convert it to integers with clamp
2199         https://bugs.webkit.org/show_bug.cgi?id=169537
2200
2201         Reviewed by Carlos Garcia Campos.
2202
2203         When using the usual static_cast, infinity becomes 0 accidentally.
2204         It is not intended value when using Seconds for timeout value.
2205         Instead, we use clampToAccepting64 to convert Seconds to
2206         integer values to pass them to the system functions.
2207
2208         * wtf/MathExtras.h:
2209         (clampToAccepting64):
2210         * wtf/Seconds.h:
2211         (WTF::Seconds::minutesAs):
2212         (WTF::Seconds::secondsAs):
2213         (WTF::Seconds::millisecondsAs):
2214         (WTF::Seconds::microsecondsAs):
2215         (WTF::Seconds::nanosecondsAs):
2216         * wtf/cocoa/WorkQueueCocoa.cpp:
2217         (WTF::WorkQueue::dispatchAfter):
2218         * wtf/glib/RunLoopGLib.cpp:
2219         (WTF::RunLoop::dispatchAfter):
2220         (WTF::RunLoop::TimerBase::updateReadyTime):
2221
2222 2017-03-13  Yusuke Suzuki  <utatane.tea@gmail.com>
2223
2224         [JSC][Linux] Implement VMTrap in Linux ports
2225         https://bugs.webkit.org/show_bug.cgi?id=169436
2226
2227         Reviewed by Mark Lam.
2228
2229         Enable VMTrap mechanism for Linux and FreeBSD.
2230
2231         * wtf/Platform.h:
2232
2233 2017-03-13  Yusuke Suzuki  <utatane.tea@gmail.com>
2234
2235         [WTF] Clean up RunLoop and WorkQueue with Seconds and Function
2236         https://bugs.webkit.org/show_bug.cgi?id=169537
2237
2238         Reviewed by Sam Weinig.
2239
2240         This patch modernizes RunLoop and WorkQueue.
2241
2242         1. Use Ref<> aggressively
2243         2. Use Seconds instead of chrono times
2244         3. Use Function<> instead of std::function
2245
2246         * wtf/MainThread.cpp:
2247         (WTF::dispatchFunctionsFromMainThread):
2248         * wtf/RunLoop.h:
2249         * wtf/WorkQueue.h:
2250         * wtf/cocoa/WorkQueueCocoa.cpp:
2251         (WTF::WorkQueue::dispatch):
2252         (WTF::WorkQueue::dispatchAfter):
2253         (WTF::WorkQueue::concurrentApply):
2254         * wtf/generic/MainThreadGeneric.cpp:
2255         (WTF::scheduleDispatchFunctionsOnMainThread):
2256         * wtf/generic/RunLoopGeneric.cpp:
2257         (WTF::RunLoop::TimerBase::ScheduledTask::create):
2258         (WTF::RunLoop::TimerBase::ScheduledTask::EarliestSchedule::operator()):
2259         (WTF::RunLoop::populateTasks):
2260         (WTF::RunLoop::runImpl):
2261         (WTF::RunLoop::schedule):
2262         (WTF::RunLoop::scheduleAndWakeUp):
2263         (WTF::RunLoop::dispatchAfter):
2264         (WTF::RunLoop::TimerBase::start):
2265         * wtf/generic/WorkQueueGeneric.cpp:
2266         (WorkQueue::dispatch):
2267         (WorkQueue::dispatchAfter):
2268         * wtf/glib/RunLoopGLib.cpp:
2269         (WTF::DispatchAfterContext::DispatchAfterContext):
2270         (WTF::RunLoop::dispatchAfter):
2271         (WTF::RunLoop::TimerBase::updateReadyTime):
2272         (WTF::RunLoop::TimerBase::start):
2273         * wtf/win/WorkQueueWin.cpp:
2274         (WTF::WorkQueue::performWorkOnRegisteredWorkThread):
2275         (WTF::WorkQueue::dispatch):
2276         (WTF::WorkQueue::dispatchAfter):
2277
2278 2017-03-13  Chris Dumez  <cdumez@apple.com>
2279
2280         [WK2] Only report background WebProcesses as unresponsive in the background after 90 seconds
2281         https://bugs.webkit.org/show_bug.cgi?id=169425
2282         <rdar://problem/30954003>
2283
2284         Reviewed by Andreas Kling.
2285
2286         * wtf/RunLoop.h:
2287         (WTF::RunLoop::TimerBase::startRepeating):
2288         (WTF::RunLoop::TimerBase::startOneShot):
2289         Add overloads to RunLoop::Timer that take Seconds in parameter,
2290         for convenience.
2291
2292         * wtf/Seconds.h:
2293         (WTF::Seconds::fromHours):
2294         (WTF::seconds_literals::operator _h):
2295         Allow _h suffix for initializing Seconds type to hours.
2296
2297 2017-03-11  Csaba Osztrogonác  <ossy@webkit.org>
2298
2299         REGRESSION(r213645): It made JSC tests super slow and timeout on AArch64 Linux
2300         https://bugs.webkit.org/show_bug.cgi?id=169510
2301
2302         Unreviewed, disable LL_SC on Linux to unbreak this platform.
2303
2304         * wtf/Atomics.h:
2305         * wtf/Platform.h:
2306
2307 2017-03-10  Filip Pizlo  <fpizlo@apple.com>
2308
2309         The JITs should be able to emit fast TLS loads
2310         https://bugs.webkit.org/show_bug.cgi?id=169483
2311
2312         Reviewed by Keith Miller.
2313
2314         Consolidated what we know about fast TLS in FastTLS.h.
2315
2316         * WTF.xcodeproj/project.pbxproj:
2317         * wtf/CMakeLists.txt:
2318         * wtf/FastTLS.h: Added.
2319         (WTF::loadFastTLS):
2320         (WTF::fastTLSOffsetForKey):
2321         * wtf/Platform.h:
2322         * wtf/WTFThreadData.cpp:
2323         (WTF::WTFThreadData::createAndRegisterForGetspecificDirect):
2324         * wtf/WTFThreadData.h:
2325         (WTF::wtfThreadData):
2326
2327 2017-03-10  Mark Lam  <mark.lam@apple.com>
2328
2329         Turn ENABLE(MASM_PROBE) on by default for OS(DARWIN) release builds.
2330         https://bugs.webkit.org/show_bug.cgi?id=169493
2331
2332         Reviewed by Saam Barati.
2333
2334         MASM_PROBE was already enabled for debug builds.  This change makes it so that we
2335         don't have to rebuild the world every time we need to use it on a release build.
2336
2337         * wtf/Platform.h:
2338
2339 2017-03-10  Csaba Osztrogonác  <ossy@webkit.org>
2340
2341         Unreviewed AArch64 Linux buildfix after r213645.
2342         https://bugs.webkit.org/show_bug.cgi?id=169300
2343
2344         * wtf/Atomics.h: intptr_t and int64_t are typedefs for long int on Linux.
2345         They are different types only on Darwin platforms.
2346
2347 2017-03-09  Caio Lima  <ticaiolima@gmail.com>
2348
2349         [ESnext] Implement Object Rest - Implementing Object Rest Destructuring
2350         https://bugs.webkit.org/show_bug.cgi?id=167962
2351
2352         Reviewed by Keith Miller.
2353
2354         * wtf/HashSet.h:
2355         (WTF::=):
2356
2357 2017-03-09  Youenn Fablet  <youenn@apple.com>
2358
2359         Activate VideoToolbox when WebRTC is enabled on iOS
2360         https://bugs.webkit.org/show_bug.cgi?id=169423
2361
2362         Reviewed by Jon Lee.
2363
2364         * wtf/Platform.h: Activate VIDEOTOOLBOX if WEBRTC is enabled.
2365
2366 2017-03-09  Filip Pizlo  <fpizlo@apple.com>
2367
2368         std::isnan/isinf/isfinite should work with WTF time classes
2369         https://bugs.webkit.org/show_bug.cgi?id=164991
2370
2371         Reviewed by Darin Adler.
2372         
2373         The consensus view (see comments in https://bugs.webkit.org/show_bug.cgi?id=152045) of how
2374         to check if something is NaN is to use std::isnan(). To be able to do that for time
2375         classes, they need to provide their own isnan() overhload. This also provides isinf()
2376         overloads.
2377
2378         * wtf/MonotonicTime.h:
2379         (std::isnan):
2380         (std::isinf):
2381         * wtf/Seconds.h:
2382         (std::isnan):
2383         (std::isinf):
2384         * wtf/TimeWithDynamicClockType.h:
2385         (std::isnan):
2386         (std::isinf):
2387         * wtf/WallTime.h:
2388         (std::isnan):
2389         (std::isinf):
2390
2391 2017-03-09  Mark Lam  <mark.lam@apple.com>
2392
2393         Use const AbstractLocker& (instead of const LockHolder&) in more places.
2394         https://bugs.webkit.org/show_bug.cgi?id=169424
2395
2396         Reviewed by Filip Pizlo.
2397
2398         * wtf/RunLoop.h:
2399         * wtf/generic/RunLoopGeneric.cpp:
2400         (WTF::RunLoop::wakeUp):
2401         (WTF::RunLoop::schedule):
2402
2403 2017-03-09  Mark Lam  <mark.lam@apple.com>
2404
2405         Make the VM Traps mechanism non-polling for the DFG and FTL.
2406         https://bugs.webkit.org/show_bug.cgi?id=168920
2407         <rdar://problem/30738588>
2408
2409         Reviewed by Filip Pizlo.
2410
2411         Make StackBounds more useful for checking if a pointer is within stack bounds.
2412
2413         * wtf/MetaAllocator.cpp:
2414         (WTF::MetaAllocator::isInAllocatedMemory):
2415         * wtf/MetaAllocator.h:
2416         * wtf/Platform.h:
2417         * wtf/StackBounds.h:
2418         (WTF::StackBounds::emptyBounds):
2419         (WTF::StackBounds::StackBounds):
2420         (WTF::StackBounds::isEmpty):
2421         (WTF::StackBounds::contains):
2422
2423 2017-03-07  Filip Pizlo  <fpizlo@apple.com>
2424
2425         WTF should make it super easy to do ARM concurrency tricks
2426         https://bugs.webkit.org/show_bug.cgi?id=169300
2427
2428         Reviewed by Mark Lam.
2429         
2430         This adds Atomic<>::loadLink and Atomic<>::storeCond, available only when HAVE(LL_SC).
2431         
2432         It abstracts loadLink/storeCond behind prepare/attempt. You can write prepare/attempt
2433         loops whenever your loop fits into the least common denominator of LL/SC and CAS.
2434         
2435         This modifies Atomic<>::transaction to use prepare/attempt. So, if you write your loop
2436         using Atomic<>::transaction, then you get LL/SC for free.
2437
2438         Depending on the kind of transaction you are doing, you may not want to perform an LL
2439         until you have a chance to just load the current value. Atomic<>::transaction() assumes
2440         that you do not care to have any ordering guarantees in that case. If you think that
2441         the transaction has a good chance of aborting this way, you want
2442         Atomic<>::transaction() to first do a plain load. But if you don't think that such an
2443         abort is likely, then you want to go straight to the LL. The API supports this concept
2444         via TransactionAbortLikelihood.
2445         
2446         Additionally, this redoes the depend/consume API to be dead simple. Dependency is
2447         unsigned. You get a dependency on a loaded value by just saying
2448         dependency(loadedValue). You consume the dependency by using it as a bonus index to
2449         some pointer dereference. This is made easy with the consume<T*>(ptr, dependency)
2450         helper. In those cases where you want to pass around both a computed value and a
2451         dependency, there's DependencyWith<T>. But you won't need it in most cases. The loaded
2452         value or any value computed from the loaded value is a fine input to dependency()!
2453         
2454         This change updates a bunch of hot paths to use the new APIs. Using transaction() gives
2455         us optimal LL/SC loops for object marking and lock acquisition.
2456         
2457         This change also updates a bunch of hot paths to use dependency()/consume().
2458         
2459         This is a significant Octane/splay speed-up on ARM.
2460
2461         * wtf/Atomics.h:
2462         (WTF::hasFence):
2463         (WTF::Atomic::prepare):
2464         (WTF::Atomic::attempt):
2465         (WTF::Atomic::transaction):
2466         (WTF::Atomic::transactionRelaxed):
2467         (WTF::nullDependency):
2468         (WTF::dependency):
2469         (WTF::DependencyWith::DependencyWith):
2470         (WTF::dependencyWith):
2471         (WTF::consume):
2472         (WTF::Atomic::tryTransactionRelaxed): Deleted.
2473         (WTF::Atomic::tryTransaction): Deleted.
2474         (WTF::zeroWithConsumeDependency): Deleted.
2475         (WTF::consumeLoad): Deleted.
2476         * wtf/Bitmap.h:
2477         (WTF::WordType>::get):
2478         (WTF::WordType>::concurrentTestAndSet):
2479         (WTF::WordType>::concurrentTestAndClear):
2480         * wtf/LockAlgorithm.h:
2481         (WTF::LockAlgorithm::lockFast):
2482         (WTF::LockAlgorithm::unlockFast):
2483         (WTF::LockAlgorithm::unlockSlow):
2484         * wtf/Platform.h:
2485
2486 2017-03-08  Anders Carlsson  <andersca@apple.com>
2487
2488         Simplify the PaymentCoordinator interface
2489         https://bugs.webkit.org/show_bug.cgi?id=169382
2490         Part of rdar://problem/28880714.
2491
2492         Reviewed by Tim Horton.
2493
2494         * wtf/EnumTraits.h:
2495         Fix a build warning.
2496
2497 2017-03-06  Andreas Kling  <akling@apple.com>
2498
2499         [iOS] Report domains crashing under memory pressure via enhanced privacy logging.
2500         <https://webkit.org/b/169133>
2501         <rdar://problem/29964017>
2502
2503         Reviewed by Antti Koivisto.
2504
2505         Add a mechanism for getting a callback when the memory pressure status changes.
2506
2507         * wtf/MemoryPressureHandler.cpp:
2508         (WTF::MemoryPressureHandler::measurementTimerFired):
2509         (WTF::MemoryPressureHandler::beginSimulatedMemoryPressure):
2510         (WTF::MemoryPressureHandler::endSimulatedMemoryPressure):
2511         (WTF::MemoryPressureHandler::setUnderMemoryPressure):
2512         (WTF::MemoryPressureHandler::memoryPressureStatusChanged):
2513         * wtf/MemoryPressureHandler.h:
2514         (WTF::MemoryPressureHandler::setMemoryPressureStatusChangedCallback):
2515         (WTF::MemoryPressureHandler::setUnderMemoryPressure): Deleted.
2516
2517 2017-03-03  Jer Noble  <jer.noble@apple.com>
2518
2519         [Win64] '__int128_t': undeclared identifier in MediaTime.cpp
2520         https://bugs.webkit.org/show_bug.cgi?id=169123
2521
2522         Reviewed by Alex Christensen.
2523
2524         Don't perform the 128-bit optimized path on Windows, where the __int128_t intrinsic isn't available.
2525
2526         * wtf/MediaTime.cpp:
2527         (WTF::MediaTime::setTimeScale):
2528
2529 2017-03-03  Keith Miller  <keith_miller@apple.com>
2530
2531         WASM should support faster loads.
2532         https://bugs.webkit.org/show_bug.cgi?id=162693
2533
2534         Reviewed by Saam Barati.
2535
2536         Add new forms of dataLog that take a boolean which describes if the log should happen. This makes cases where we have a static const bool for printing nicer since you can do:
2537
2538         dataLogIf(verbose, things, to, print);
2539
2540         instead of:
2541
2542         if (verbose)
2543             dataLog(things, to, print);
2544
2545         Also, add a operator! to Ref that has the same semantics as C++ refs.
2546
2547         * wtf/DataLog.h:
2548         (WTF::dataLogLn):
2549         (WTF::dataLogIf):
2550         (WTF::dataLogLnIf):
2551         * wtf/Ref.h:
2552         (WTF::Ref::operator!):
2553
2554 2017-03-02  Jer Noble  <jer.noble@apple.com>
2555
2556         Sufficently large timeValue and timeScale arguments to MediaTime will cause wrapping in toTimeScale().
2557         https://bugs.webkit.org/show_bug.cgi?id=169098
2558
2559         Reviewed by Keith Miller.
2560
2561         Use a non-standard but Clang & GCC supported __int128_t type extension to do the 128-bit math rather than
2562         rolling our own. Since this is only available in 64-bit builds, for 32-bit, just fix the underlying 128-bit
2563         math.
2564
2565         * wtf/MediaTime.cpp:
2566         (WTF::MediaTime::setTimeScale):
2567
2568 2017-03-01  Konstantin Tokarev  <annulen@yandex.ru>
2569
2570         Removed unused WTF_COMPILER_SUPPORTS_CXX_USER_LITERALS macro
2571         https://bugs.webkit.org/show_bug.cgi?id=168969
2572
2573         Reviewed by Darin Adler.
2574
2575         * wtf/Compiler.h:
2576
2577 2017-03-01  Tomas Popela  <tpopela@redhat.com>
2578
2579         [WTF] va_list is not ended in StringPrintStream
2580         https://bugs.webkit.org/show_bug.cgi?id=169035
2581
2582         Reviewed by Michael Saboff.
2583
2584         Also fix whitespace errors while touching this file.
2585
2586         * wtf/StringPrintStream.cpp:
2587         (WTF::StringPrintStream::vprintf):
2588         (WTF::StringPrintStream::increaseSize):
2589
2590 2017-03-01  Andreas Kling  <akling@apple.com>
2591
2592         Move MemoryPressureHandler to WTF
2593         <https://webkit.org/b/168908>
2594
2595         Reviewed by Sam Weinig.
2596
2597         Move MemoryPressureHandler down to WTF so it can be used from JavaScriptCore.
2598
2599         I had to do a blind rewrite of the Windows memory checking timer since it can
2600         no longer use WebCore::Timer. I also moved the Win32Handle helper class to WTF.
2601
2602         * WTF.xcodeproj/project.pbxproj:
2603         * wtf/CMakeLists.txt:
2604         * wtf/MemoryPressureHandler.cpp: Renamed from Source/WebCore/platform/MemoryPressureHandler.cpp.
2605         (WTF::MemoryPressureHandler::singleton):
2606         (WTF::MemoryPressureHandler::MemoryPressureHandler):
2607         (WTF::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor):
2608         (WTF::toString):
2609         (WTF::thresholdForPolicy):
2610         (WTF::policyForFootprint):
2611         (WTF::MemoryPressureHandler::measurementTimerFired):
2612         (WTF::MemoryPressureHandler::beginSimulatedMemoryPressure):
2613         (WTF::MemoryPressureHandler::endSimulatedMemoryPressure):
2614         (WTF::MemoryPressureHandler::releaseMemory):
2615         (WTF::MemoryPressureHandler::ReliefLogger::logMemoryUsageChange):
2616         (WTF::MemoryPressureHandler::install):
2617         (WTF::MemoryPressureHandler::uninstall):
2618         (WTF::MemoryPressureHandler::holdOff):
2619         (WTF::MemoryPressureHandler::respondToMemoryPressure):
2620         (WTF::MemoryPressureHandler::platformReleaseMemory):
2621         (WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
2622         (WTF::MemoryPressureHandler::platformInitialize):
2623         * wtf/MemoryPressureHandler.h: Renamed from Source/WebCore/platform/MemoryPressureHandler.h.
2624         (WTF::MemoryPressureHandler::setMemoryKillCallback):
2625         (WTF::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback):
2626         (WTF::MemoryPressureHandler::setLowMemoryHandler):
2627         (WTF::MemoryPressureHandler::isUnderMemoryPressure):
2628         (WTF::MemoryPressureHandler::setUnderMemoryPressure):
2629         (WTF::MemoryPressureHandler::ReliefLogger::ReliefLogger):
2630         (WTF::MemoryPressureHandler::ReliefLogger::~ReliefLogger):
2631         (WTF::MemoryPressureHandler::ReliefLogger::logString):
2632         (WTF::MemoryPressureHandler::ReliefLogger::setLoggingEnabled):
2633         (WTF::MemoryPressureHandler::ReliefLogger::loggingEnabled):
2634         (WTF::MemoryPressureHandler::ReliefLogger::MemoryUsage::MemoryUsage):
2635         * wtf/PlatformEfl.cmake:
2636         * wtf/PlatformGTK.cmake:
2637         * wtf/PlatformMac.cmake:
2638         * wtf/PlatformWin.cmake:
2639         * wtf/cocoa/MemoryPressureHandlerCocoa.mm: Renamed from Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm.
2640         (WTF::MemoryPressureHandler::platformReleaseMemory):
2641         (WTF::MemoryPressureHandler::install):
2642         (WTF::MemoryPressureHandler::uninstall):
2643         (WTF::MemoryPressureHandler::holdOff):
2644         (WTF::MemoryPressureHandler::respondToMemoryPressure):
2645         (WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
2646         * wtf/linux/CurrentProcessMemoryStatus.cpp: Renamed from Source/WebCore/platform/linux/CurrentProcessMemoryStatus.cpp.
2647         (WTF::systemPageSize):
2648         (WTF::currentProcessMemoryStatus):
2649         * wtf/linux/CurrentProcessMemoryStatus.h: Renamed from Source/WebCore/platform/linux/CurrentProcessMemoryStatus.h.
2650         * wtf/linux/MemoryPressureHandlerLinux.cpp: Renamed from Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp.
2651         (WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
2652         * wtf/win/MemoryPressureHandlerWin.cpp: Renamed from Source/WebCore/platform/win/MemoryPressureHandlerWin.cpp.
2653         (WTF::MemoryPressureHandler::platformInitialize):
2654         (WTF::MemoryPressureHandler::windowsMeasurementTimerFired):
2655         (WTF::MemoryPressureHandler::platformReleaseMemory):
2656         (WTF::MemoryPressureHandler::install):
2657         (WTF::MemoryPressureHandler::uninstall):
2658         (WTF::MemoryPressureHandler::holdOff):
2659         (WTF::MemoryPressureHandler::respondToMemoryPressure):
2660         (WTF::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
2661         * wtf/win/Win32Handle.h: Renamed from Source/WebCore/platform/win/Win32Handle.h.
2662         (WTF::Win32Handle::Win32Handle):
2663         (WTF::Win32Handle::~Win32Handle):
2664         (WTF::Win32Handle::clear):
2665         (WTF::Win32Handle::isValid):
2666         (WTF::Win32Handle::get):
2667         (WTF::Win32Handle::release):
2668         (WTF::Win32Handle::operator=):
2669
2670 2017-02-28  Chris Dumez  <cdumez@apple.com>
2671
2672         [iOS] Throttle requestAnimationFrame to 30fps in low power mode
2673         https://bugs.webkit.org/show_bug.cgi?id=168837
2674         <rdar://problem/30700929>
2675
2676         Reviewed by Simon Fraser.
2677
2678         Add support for operator -= on WTF::OptionSet for convenience:
2679             set -= Enum::A;
2680         looks much better than:
2681             set = set - Enum::A;
2682
2683         * wtf/OptionSet.h:
2684         (WTF::OptionSet::operator-=):
2685
2686 2017-02-28  Michael Saboff  <msaboff@apple.com>
2687
2688         Add ability to configure JSC options from a file
2689         https://bugs.webkit.org/show_bug.cgi?id=168914
2690
2691         Reviewed by Filip Pizlo.
2692
2693         Added the ability to set options and DataLog file location via a configuration file.
2694         The pathname can include the printf style "%pid", which will be replaced with the
2695         current process id.
2696
2697         * wtf/DataLog.cpp:
2698         (WTF::initializeLogFileOnce):
2699         (WTF::setDataFile):
2700         * wtf/DataLog.h:
2701
2702 2017-02-27  Andy Estes  <aestes@apple.com>
2703
2704         [iOS] Enable file replacement
2705         https://bugs.webkit.org/show_bug.cgi?id=168907
2706         <rdar://problem/22258242>
2707
2708         Reviewed by David Kilzer.
2709
2710         * wtf/FeatureDefines.h: Set ENABLE_FILE_REPLACEMENT to 1 on all Cocoa platforms.
2711
2712 2017-02-27  Myles C. Maxfield  <mmaxfield@apple.com>
2713
2714         Rename ICU cursor iterator to caret iterator
2715         https://bugs.webkit.org/show_bug.cgi?id=168206
2716
2717         Reviewed by Simon Fraser.
2718
2719         * wtf/text/TextBreakIterator.cpp:
2720         (WTF::mapModeToBackingIterator):
2721         * wtf/text/TextBreakIterator.h:
2722         * wtf/text/cf/TextBreakIteratorCF.h:
2723         (WTF::TextBreakIteratorCF::TextBreakIteratorCF):
2724         * wtf/text/icu/TextBreakIteratorICU.h:
2725         (WTF::caretRules):
2726         (WTF::TextBreakIteratorICU::TextBreakIteratorICU):
2727         (WTF::cursorRules): Deleted.
2728         * wtf/text/mac/TextBreakIteratorInternalICUMac.mm:
2729         (WTF::mapModeToBackingIterator):
2730
2731 2017-02-27  Myles C. Maxfield  <mmaxfield@apple.com>
2732
2733         Use RAII for ICU breaking iterators
2734         https://bugs.webkit.org/show_bug.cgi?id=168203
2735
2736         Reviewed by Simon Fraser.
2737
2738         * wtf/text/TextBreakIterator.h:
2739         (WTF::CachedTextBreakIterator::CachedTextBreakIterator):
2740         (WTF::CachedTextBreakIterator::~CachedTextBreakIterator):
2741         (WTF::CachedTextBreakIterator::preceding):
2742         (WTF::CachedTextBreakIterator::following):
2743         (WTF::CachedTextBreakIterator::isBoundary):
2744
2745 2017-02-24  Jer Noble  <jer.noble@apple.com>
2746
2747         Add public method to MediaTime for doing timeScale conversion.
2748         https://bugs.webkit.org/show_bug.cgi?id=168860
2749
2750         Reviewed by Eric Carlson.
2751
2752         The newly public method, modeled on CMTimeConvertScale, allows callers to specify what rounding technique
2753         will be used when converting to a new time scale.
2754
2755         * wtf/MediaTime.cpp:
2756         (WTF::MediaTime::toTimeScale):
2757         (WTF::MediaTime::setTimeScale):
2758         * wtf/MediaTime.h:
2759
2760 2017-02-26  Myles C. Maxfield  <mmaxfield@apple.com>
2761
2762         Stop compiling our own cursorMovementIterator()
2763         https://bugs.webkit.org/show_bug.cgi?id=168211
2764
2765         Reviewed by David Hyatt.
2766
2767         This patch creates a unified Text Breaking API, which can be backed by either ICU
2768         or CoreFoundation (for ports which can use it). Rather than using inheritance and
2769         virtual functions to implement this, because there are only two subclasses, the
2770         simpler option of just using a Variant is used instead. There is also a cache which
2771         allows you to reuse iterators without reconstructing them. This cache is better
2772         than the previous method of having a single static iterator because the cache
2773         lets you use two iterators simultaneously.
2774
2775         In the future, I will hook up all iterators to use this shared class. However, for
2776         this patch, I've only hooked up the caret position iterator (backed by CoreFoundation
2777         on Cocoa ports and UBRK_CHARACTER on other ports). 
2778
2779         * WTF.xcodeproj/project.pbxproj:
2780         * wtf/spi/cf/CFStringSPI.h: Added.
2781         * wtf/text/TextBreakIterator.cpp:
2782         (WTF::initializeIteratorWithRules): Deleted.
2783         (WTF::cursorMovementIterator): Deleted.
2784         * wtf/text/TextBreakIterator.h:
2785         (WTF::TextBreakIterator::preceding):
2786         (WTF::TextBreakIterator::following):
2787         (WTF::TextBreakIterator::isBoundary):
2788         (WTF::TextBreakIterator::setText):
2789         (WTF::TextBreakIterator::mode):
2790         (WTF::TextBreakIterator::locale):
2791         (WTF::TextBreakIteratorCache::singleton):
2792         (WTF::TextBreakIteratorCache::take):
2793         (WTF::TextBreakIteratorCache::put):
2794         (WTF::TextBreakIteratorCache::TextBreakIteratorCache):
2795         * wtf/text/cf/TextBreakIteratorCF.h: Added.
2796         (WTF::TextBreakIteratorCF::TextBreakIteratorCF):
2797         (WTF::TextBreakIteratorCF::setText):
2798         (WTF::TextBreakIteratorCF::preceding):
2799         (WTF::TextBreakIteratorCF::following):
2800         (WTF::TextBreakIteratorCF::isBoundary):
2801         * wtf/text/icu/TextBreakIteratorICU.h: Added.
2802         (WTF::TextBreakIteratorICU::set8BitText):
2803         (WTF::TextBreakIteratorICU::TextBreakIteratorICU):
2804         (WTF::TextBreakIteratorICU::operator=):
2805         (WTF::TextBreakIteratorICU::~TextBreakIteratorICU):
2806         (WTF::TextBreakIteratorICU::setText):
2807         (WTF::TextBreakIteratorICU::preceding):
2808         (WTF::TextBreakIteratorICU::following):
2809         (WTF::TextBreakIteratorICU::isBoundary):
2810         * wtf/text/icu/UTextProviderLatin1.h:
2811         * wtf/text/mac/TextBreakIteratorInternalICUMac.mm:
2812         (WTF::mapModeToBackingIterator):
2813         (WTF::TextBreakIterator::TextBreakIterator):
2814
2815 2017-02-24  Joseph Pecoraro  <pecoraro@apple.com>
2816
2817         [Resource Timing] Gather timing information with reliable responseEnd time
2818         https://bugs.webkit.org/show_bug.cgi?id=168351
2819
2820         Reviewed by Alex Christensen.
2821
2822         * wtf/persistence/Coders.h:
2823         (WTF::Persistence::Coder<Seconds>::encode):
2824         (WTF::Persistence::Coder<Seconds>::decode):
2825
2826 2017-02-24  Keith Miller  <keith_miller@apple.com>
2827
2828         Rubber-stamped by Chris Dumez.
2829
2830         Replace typename Bool with typename BoolType because X11 has
2831         #define Bool int for some unknown reason...
2832
2833         * wtf/HashFunctions.h:
2834         (WTF::TupleHash::allTrue):
2835         * wtf/HashTraits.h:
2836         (WTF::TupleHashTraits::allTrue):
2837
2838 2017-02-24  Chris Dumez  <cdumez@apple.com>
2839
2840         Unreviewed, rolling out r212944.
2841
2842         Caused a lot of failures on the debug bots
2843
2844         Reverted changeset:
2845
2846         "[Resource Timing] Gather timing information with reliable
2847         responseEnd time"
2848         https://bugs.webkit.org/show_bug.cgi?id=168351
2849         http://trac.webkit.org/changeset/212944
2850
2851 2017-02-24  Keith Miller  <keith_miller@apple.com>
2852
2853         We should be able to use std::tuples as keys in HashMap
2854         https://bugs.webkit.org/show_bug.cgi?id=168805
2855
2856         Reviewed by Filip Pizlo.
2857
2858         This patch adds support for using std::tupeles as the key
2859         type in HashMap. It is equivalent to doing a sequence of
2860         std::pairs but has a nicer syntax.
2861
2862         * wtf/HashFunctions.h:
2863         (WTF::TupleHash::hash):
2864         (WTF::TupleHash::equal):
2865         (WTF::TupleHash::allTrue):
2866         * wtf/HashTraits.h:
2867         (WTF::TupleHashTraits::allTrue):
2868         (WTF::TupleHashTraits::emptyValue):
2869         (WTF::TupleHashTraits::constructDeletedValue):
2870         (WTF::TupleHashTraits::isDeletedValue):
2871
2872 2017-02-24  Alex Christensen  <achristensen@webkit.org>
2873
2874         Prepare to enable WebRTC on iOS
2875         https://bugs.webkit.org/show_bug.cgi?id=168811
2876
2877         Reviewed by Youenn Fablet.
2878
2879         * wtf/Platform.h:
2880
2881 2017-02-23  Joseph Pecoraro  <pecoraro@apple.com>
2882
2883         [Resource Timing] Gather timing information with reliable responseEnd time
2884         https://bugs.webkit.org/show_bug.cgi?id=168351
2885
2886         Reviewed by Alex Christensen.
2887
2888         * wtf/persistence/Coders.h:
2889         (WTF::Persistence::Coder<Seconds>::encode):
2890         (WTF::Persistence::Coder<Seconds>::decode):
2891
2892 2017-02-22  Carlos Garcia Campos  <cgarcia@igalia.com>
2893
2894         Better handle Thread and RunLoop initialization
2895         https://bugs.webkit.org/show_bug.cgi?id=167828
2896
2897         Reviewed by Yusuke Suzuki.
2898
2899         Make initialization functions more independent so that they can run in different
2900         order. WTF::initializeMainThread initializes WTF threading, so that neither WTF nor JSC theading need to be
2901         initialized before. RunLoop::initializeMainRunLoop() requires main thread to be initialized in some
2902         ports, so it initializes main thread too. WebKit1 always calls WTF::initializeMainThreadToProcessMainThread()
2903         before RunLoop::initializeMainRunLoop() so there's no problem there. GC threads are initialized alwayas by the
2904         main thread. The rules should be simpler now:
2905
2906           - JSC::initializeThreading: should always be called when JSC is used.
2907           - WTF::initializeThreading: only needs to be explicitly called when JSC is not used and process doesn't
2908             initialize a main thread or main run loop.
2909           - WTF::initializeMainThread: only needs to be explicitly called if process initializes a main thread but not a
2910             main run loop.
2911           - WTF::initializeMainThreadToProcessMainThread(): should always be called in WebKit1 before
2912             RunLoop::initializeMainRunLoop().
2913           - RunLoop::initializeMainRunLoop(): to initialize the main run loop. The only requirement is JSC::initializeThreading()
2914             to be called before if JSC is used.
2915
2916         * wtf/MainThread.cpp:
2917         (WTF::initializeMainThreadOnce): Use pthread_once to initialize the main thread also in GTK+ port.
2918         (WTF::initializeMainThreadToProcessMainThreadOnce): Call initializeThreading() before the platform
2919         initialization and initializeGCThreads() after it.
2920         (WTF::initializeMainThread): Ditto.
2921         * wtf/RunLoop.cpp:
2922         (WTF::RunLoop::initializeMainRunLoop): Call initializeMainThread().
2923         * wtf/glib/MainThreadGLib.cpp:
2924         (WTF::initializeMainThreadPlatform):
2925         (WTF::isMainThread):
2926         * wtf/mac/MainThreadMac.mm:
2927         (WTF::initializeMainThreadPlatform): Remove call to initializeGCThreads().
2928         (WTF::initializeMainThreadToProcessMainThreadPlatform): Ditto.
2929
2930 2017-02-22  Myles C. Maxfield  <mmaxfield@apple.com>
2931
2932         [Cocoa] Remove Yosemite-specific font lookup code
2933         https://bugs.webkit.org/show_bug.cgi?id=168682
2934
2935         Reviewed by Zalan Bujtas.
2936
2937         * wtf/Platform.h:
2938
2939 2017-02-22  Keith Miller  <keith_miller@apple.com>
2940
2941         Remove the demand executable allocator
2942         https://bugs.webkit.org/show_bug.cgi?id=168754
2943
2944         Reviewed by Saam Barati.
2945
2946         * wtf/Platform.h:
2947
2948 2017-02-22  Alex Christensen  <achristensen@webkit.org>
2949
2950         Re-commit part of r212812 accidentally rolled out with r212841.
2951         https://bugs.webkit.org/show_bug.cgi?id=167293
2952
2953         * wtf/Platform.h:
2954         Use libwebrtc on Mac if webrtc is enabled.
2955
2956 2017-02-22  Alex Christensen  <achristensen@webkit.org>
2957
2958         Fix ASAN build after activating libwebrtc.
2959
2960         * wtf/Ref.h:
2961         __asan_address_is_poisoned returns an int, not a bool.
2962         This didn't cause a problem before because we didn't include the real definition anywhere,
2963         but libwebrtc includes <sanitizer/asan_interface.h> directly now so the return types need to be correct.
2964
2965 2017-02-22  Carlos Garcia Campos  <cgarcia@igalia.com>
2966
2967         [GTK] Test fast/events/message-port-postMessage-recursive.html times out
2968         https://bugs.webkit.org/show_bug.cgi?id=168570
2969
2970         Reviewed by Michael Catanzaro.
2971
2972         This has recently been added and the patch is good. It's just revealing a problem with our timers. The test is
2973         posting a message recursively, and also starts a timeout timer to finish the test. The timeout timer is never
2974         fired for us, because WebCore timers have lower priority than the one used by postMessage. ScriptExecutionContext
2975         uses Document::postTask, that uses scheduleOnMainThread, that uses RunLoop::dispatch(). We are not setting any
2976         priority for the timer used by RunLoop::dispatch, so it's using the default.
2977         Use a RunLoop::Timer to schedule tasks to the main thread instead of using RunLoop::dispatch(). This allows us
2978         to use a different priority, that is now set to G_PRIORITY_HIGH_IDLE + 20 to match WebCore timers. But it also
2979         avoids the double queue we had with RunLoop::dispatch(), because scheduleOnMainThread() also queues the tasks.
2980
2981         * wtf/glib/MainThreadGLib.cpp:
2982         (WTF::MainThreadDispatcher::MainThreadDispatcher):
2983         (WTF::MainThreadDispatcher::schedule):
2984         (WTF::MainThreadDispatcher::fired):
2985         (WTF::scheduleDispatchFunctionsOnMainThread):
2986
2987 2017-02-21  Youenn Fablet  <youenn@apple.com>
2988
2989         [WebRTC][Mac] Activate libwebrtc
2990         https://bugs.webkit.org/show_bug.cgi?id=167293
2991
2992         Reviewed by Alex Christensen.
2993
2994         * wtf/Platform.h:
2995
2996 2017-02-20  Filip Pizlo  <fpizlo@apple.com>
2997
2998         The collector thread should only start when the mutator doesn't have heap access
2999         https://bugs.webkit.org/show_bug.cgi?id=167737
3000
3001         Reviewed by Keith Miller.
3002         
3003         Extend the use of AbstractLocker so that we can use more locking idioms.
3004
3005         * wtf/AutomaticThread.cpp:
3006         (WTF::AutomaticThreadCondition::notifyOne):
3007         (WTF::AutomaticThreadCondition::notifyAll):
3008         (WTF::AutomaticThreadCondition::add):
3009         (WTF::AutomaticThreadCondition::remove):
3010         (WTF::AutomaticThreadCondition::contains):
3011         (WTF::AutomaticThread::AutomaticThread):
3012         (WTF::AutomaticThread::tryStop):
3013         (WTF::AutomaticThread::isWaiting):
3014         (WTF::AutomaticThread::notify):
3015         (WTF::AutomaticThread::start):
3016         (WTF::AutomaticThread::threadIsStopping):
3017         * wtf/AutomaticThread.h:
3018         * wtf/NumberOfCores.cpp:
3019         (WTF::numberOfProcessorCores):
3020         * wtf/ParallelHelperPool.cpp:
3021         (WTF::ParallelHelperClient::finish):
3022         (WTF::ParallelHelperClient::claimTask):
3023         (WTF::ParallelHelperPool::Thread::Thread):
3024         (WTF::ParallelHelperPool::didMakeWorkAvailable):
3025         (WTF::ParallelHelperPool::hasClientWithTask):
3026         (WTF::ParallelHelperPool::getClientWithTask):
3027         * wtf/ParallelHelperPool.h:
3028
3029 2017-02-21  Alex Christensen  <achristensen@webkit.org>
3030
3031         Unreviewed, rolling out r212699.
3032
3033         Internal build not ready
3034
3035         Reverted changeset:
3036
3037         "[WebRTC][Mac] Activate libwebrtc"
3038         https://bugs.webkit.org/show_bug.cgi?id=167293
3039         http://trac.webkit.org/changeset/212699
3040
3041 2017-02-20  Youenn Fablet  <youenn@apple.com>
3042
3043         [WebRTC][Mac] Activate libwebrtc
3044         https://bugs.webkit.org/show_bug.cgi?id=167293
3045
3046         Reviewed by Alex Christensen.
3047
3048         * wtf/Platform.h:
3049
3050 2017-02-20  Mark Lam  <mark.lam@apple.com>
3051
3052         [Re-landing] CachedCall should let GC know to keep its arguments alive.
3053         https://bugs.webkit.org/show_bug.cgi?id=168567
3054         <rdar://problem/30475767>
3055
3056         Reviewed by Saam Barati.
3057
3058         Added a WTF_FORBID_HEAP_ALLOCATION that will cause a compilation failure if
3059         a class declared with it is malloced.
3060
3061         While this doesn't prevent that class declared WTF_FORBID_HEAP_ALLOCATION from
3062         being embedded in another class that is heap allocated, it does at minimum
3063         document the intent and gives the users of this class a chance to do the
3064         right thing.
3065
3066         * WTF.xcodeproj/project.pbxproj:
3067         * wtf/ForbidHeapAllocation.h: Added.
3068
3069 2017-02-20  Ryan Haddad  <ryanhaddad@apple.com>
3070
3071         Unreviewed, rolling out r212685.
3072
3073         This change broke the 32-bit Sierra build.
3074
3075         Reverted changeset:
3076
3077         "Resource Load Statistics: Add alternate classification
3078         method"
3079         https://bugs.webkit.org/show_bug.cgi?id=168347
3080         http://trac.webkit.org/changeset/212685
3081
3082 2017-02-20  John Wilander  <wilander@apple.com>
3083
3084         Resource Load Statistics: Add alternate classification method
3085         https://bugs.webkit.org/show_bug.cgi?id=168347
3086         <rdar://problem/30352793>
3087
3088         Reviewed by Alex Christensen.
3089
3090         * wtf/Platform.h:
3091             Added support for HAVE(CORE_PREDICTION).
3092
3093 2017-02-20  Commit Queue  <commit-queue@webkit.org>
3094
3095         Unreviewed, rolling out r212618.
3096         https://bugs.webkit.org/show_bug.cgi?id=168609
3097
3098         "Appears to cause PLT regression" (Requested by mlam on
3099         #webkit).
3100
3101         Reverted changeset:
3102
3103         "CachedCall should let GC know to keep its arguments alive."
3104         https://bugs.webkit.org/show_bug.cgi?id=168567
3105         http://trac.webkit.org/changeset/212618
3106
3107 2017-02-20  Carlos Garcia Campos  <cgarcia@igalia.com>
3108
3109         Unreviewed, rolling out r212622.
3110
3111         Caused several test failures
3112
3113         Reverted changeset:
3114
3115         "[GTK] Test fast/events/message-port-postMessage-
3116         recursive.html times out"
3117         https://bugs.webkit.org/show_bug.cgi?id=168570
3118         http://trac.webkit.org/changeset/212622
3119
3120 2017-02-19  Carlos Garcia Campos  <cgarcia@igalia.com>
3121
3122         [GTK] Test fast/events/message-port-postMessage-recursive.html times out
3123         https://bugs.webkit.org/show_bug.cgi?id=168570
3124
3125         Reviewed by Michael Catanzaro.
3126
3127         This has recently been added and the patch is good. It's just revealing a problem with our timers. The test is
3128         posting a message recursively, and also starts a timeout timer to finish the test. The timeout timer is never
3129         fired for us, because WebCore timers have lower priority than the one used by
3130         postMessage. ScriptExecutionContext uses Document::postTask, that uses scheduleOnMainThread, that uses
3131         RunLoop::dispatch(). We are not setting any priority for the timer used by RunLoop::dispatch, so it's using the
3132         default. RunLoop::dispatch is normally used to schedule tasks between threads, or just to ensure something is
3133         run in a different run loop iteration, but in general nothing urgent as a graphics redraw or something like
3134         that. It's quite common to use g_idle_add to schedule tasks between threads, so I think it makes sense to use
3135         G_PRIORITY_DEFAULT_IDLE for the RunLoop timer.
3136
3137         * wtf/glib/RunLoopGLib.cpp:
3138         (WTF::RunLoop::RunLoop):
3139
3140 2017-02-19  Mark Lam  <mark.lam@apple.com>
3141
3142         CachedCall should let GC know to keep its arguments alive.
3143         https://bugs.webkit.org/show_bug.cgi?id=168567
3144         <rdar://problem/30475767>
3145
3146         Reviewed by Saam Barati.
3147
3148         Added a WTF_FORBID_HEAP_ALLOCATION that will cause a compilation failure if
3149         a class declared with it is malloced.
3150
3151         While this doesn't prevent that class declared WTF_FORBID_HEAP_ALLOCATION from
3152         being embedded in another class that is heap allocated, it does at minimum
3153         document the intent and gives the users of this class a chance to do the
3154         right thing.
3155
3156         * WTF.xcodeproj/project.pbxproj:
3157         * wtf/ForbidHeapAllocation.h: Added.
3158
3159 2017-02-19  Commit Queue  <commit-queue@webkit.org>
3160
3161         Unreviewed, rolling out r212466.
3162         https://bugs.webkit.org/show_bug.cgi?id=168577
3163
3164         causes crashes on AArch64 on linux, maybe it's causing crashes
3165         on iOS too (Requested by pizlo on #webkit).
3166
3167         Reverted changeset:
3168
3169         "The collector thread should only start when the mutator
3170         doesn't have heap access"
3171         https://bugs.webkit.org/show_bug.cgi?id=167737
3172         http://trac.webkit.org/changeset/212466
3173
3174 2017-02-18  Chris Dumez  <cdumez@apple.com>
3175
3176         Recursive MessagePort.postMessage() calls causes tab to become unresponsive
3177         https://bugs.webkit.org/show_bug.cgi?id=168548
3178         <rdar://problem/29808005>
3179
3180         Reviewed by Darin Adler.
3181
3182         Add API to retrieve all messages in the queue at once.
3183
3184         * wtf/MessageQueue.h:
3185
3186 2017-02-16  Alex Christensen  <achristensen@webkit.org>
3187
3188         Remove EFL-specific files in Source.
3189
3190         Rubber-stamped by Anders Carlsson.
3191
3192         * wtf/text/efl: Removed.
3193         * wtf/text/efl/TextBreakIteratorInternalICUEfl.cpp: Removed.
3194
3195 2017-02-10  Filip Pizlo  <fpizlo@apple.com>
3196
3197         The collector thread should only start when the mutator doesn't have heap access
3198         https://bugs.webkit.org/show_bug.cgi?id=167737
3199
3200         Reviewed by Keith Miller.
3201         
3202         Extend the use of AbstractLocker so that we can use more locking idioms.
3203
3204         * wtf/AutomaticThread.cpp:
3205         (WTF::AutomaticThreadCondition::notifyOne):
3206         (WTF::AutomaticThreadCondition::notifyAll):
3207         (WTF::AutomaticThreadCondition::add):
3208         (WTF::AutomaticThreadCondition::remove):
3209         (WTF::AutomaticThreadCondition::contains):
3210         (WTF::AutomaticThread::AutomaticThread):
3211         (WTF::AutomaticThread::tryStop):
3212         (WTF::AutomaticThread::isWaiting):
3213         (WTF::AutomaticThread::notify):
3214         (WTF::AutomaticThread::start):
3215         (WTF::AutomaticThread::threadIsStopping):
3216         * wtf/AutomaticThread.h:
3217         * wtf/NumberOfCores.cpp:
3218         (WTF::numberOfProcessorCores): Allow this to be overridden for testing.
3219         * wtf/ParallelHelperPool.cpp:
3220         (WTF::ParallelHelperClient::finish):
3221         (WTF::ParallelHelperClient::claimTask):
3222         (WTF::ParallelHelperPool::Thread::Thread):
3223         (WTF::ParallelHelperPool::didMakeWorkAvailable):
3224         (WTF::ParallelHelperPool::hasClientWithTask):
3225         (WTF::ParallelHelperPool::getClientWithTask):
3226         * wtf/ParallelHelperPool.h:
3227
3228 2017-02-16  Anders Carlsson  <andersca@apple.com>
3229
3230         Remove EFL from WTF
3231         https://bugs.webkit.org/show_bug.cgi?id=168452
3232
3233         Reviewed by Alex Christensen.
3234
3235         * wtf/CurrentTime.cpp:
3236         * wtf/DisallowCType.h:
3237         * wtf/FeatureDefines.h:
3238         * wtf/MainThread.cpp:
3239         * wtf/MainThread.h:
3240         * wtf/Platform.h:
3241         * wtf/RunLoop.h:
3242         * wtf/WorkQueue.h:
3243         * wtf/efl/DispatchQueueEfl.cpp: Removed.
3244         * wtf/efl/DispatchQueueEfl.h: Removed.
3245         * wtf/efl/DispatchQueueWorkItemEfl.h: Removed.
3246         * wtf/efl/EflTypedefs.h: Removed.
3247         * wtf/efl/MainThreadEfl.cpp: Removed.
3248         * wtf/efl/RunLoopEfl.cpp: Removed.
3249         * wtf/efl/UniquePtrEfl.h: Removed.
3250         * wtf/efl/WorkQueueEfl.cpp: Removed.
3251
3252 2017-02-13  Alex Christensen  <achristensen@webkit.org>
3253
3254         URLs with an invalid IPv4 address should be invalid
3255         https://bugs.webkit.org/show_bug.cgi?id=168260
3256
3257         Reviewed by Tim Horton.
3258
3259         * wtf/Expected.h:
3260         (WTF::Expected::value):
3261         Added missing WTFMove for rvalue Expected::value().
3262
3263 2017-02-13  Said Abou-Hallawa  <sabouhallawa@apple.com>
3264
3265         The current frame of an image should not deleted if another frame is asynchronously being decoded
3266         https://bugs.webkit.org/show_bug.cgi?id=167618
3267
3268         Reviewed by Simon Fraser.
3269
3270         Add ASSERT_IMPLIES() which should fire when a condition is true but the
3271         assertion is false.
3272
3273         * wtf/Assertions.h:
3274
3275 2017-02-13  Brady Eidson  <beidson@apple.com>
3276
3277         Followup to: Replace all WebKit Library Version checks in WK2 with SDK version checks.
3278         https://bugs.webkit.org/show_bug.cgi?id=168124
3279
3280         Reviewed by Geoffrey Garen.
3281
3282         * wtf/spi/darwin/dyldSPI.h:
3283
3284 2017-02-13  Myles C. Maxfield  <mmaxfield@apple.com>
3285
3286         Update custom line breaking iterators to the latest version of Unicode
3287         https://bugs.webkit.org/show_bug.cgi?id=168182
3288
3289         Reviewed by Zalan Bujtas.
3290
3291         ICU 55.1 supports loose / normal / strict line breaking rules. The oldest platform we ship
3292         on has a version of ICU >= that one. Therefore, we don't need to compile our own rules;
3293         we can just use ICU's rules.
3294
3295         * wtf/text/LineBreakIteratorPoolICU.h:
3296         (WTF::LineBreakIteratorPool::makeLocaleWithBreakKeyword):
3297         (WTF::LineBreakIteratorPool::take):
3298         * wtf/text/TextBreakIterator.cpp:
3299         (WTF::acquireLineBreakIterator):
3300         (WTF::openLineBreakIterator):
3301         (WTF::mapLineIteratorModeToRules): Deleted.
3302         (WTF::isCJKLocale): Deleted.
3303         * wtf/text/TextBreakIterator.h:
3304         (WTF::LazyLineBreakIterator::LazyLineBreakIterator):
3305         (WTF::LazyLineBreakIterator::mode):
3306         (WTF::LazyLineBreakIterator::get):
3307         (WTF::LazyLineBreakIterator::resetStringAndReleaseIterator):
3308         (WTF::LazyLineBreakIterator::isLooseCJKMode): Deleted.
3309
3310 2017-02-10  Dan Bernstein  <mitz@apple.com>
3311
3312         [Xcode] WTF installs extra copies of two headers outside /usr/local/include/wtf
3313         https://bugs.webkit.org/show_bug.cgi?id=168160
3314
3315         Reviewed by Sam Weinig.
3316
3317         * WTF.xcodeproj/project.pbxproj: Demoted OrdinalNumber.h MemoryFootprint.h from Private to
3318           Project.
3319
3320 2017-02-10  Commit Queue  <commit-queue@webkit.org>
3321
3322         Unreviewed, rolling out r212139.
3323         https://bugs.webkit.org/show_bug.cgi?id=168152
3324
3325         Caused some assertions (Requested by JoePeck on #webkit).
3326
3327         Reverted changeset:
3328
3329         "Fix misleading comment in RunLoop.h"
3330         https://bugs.webkit.org/show_bug.cgi?id=167832
3331         http://trac.webkit.org/changeset/212139
3332
3333 2017-02-10  Joseph Pecoraro  <pecoraro@apple.com>
3334
3335         Fix misleading comment in RunLoop.h
3336         https://bugs.webkit.org/show_bug.cgi?id=167832
3337
3338         Reviewed by Sam Weinig.
3339
3340         * wtf/RunLoop.h:
3341         Mac initialization used to force using CFRunLoopGetMain(). Now however it just
3342         uses RunLoop::current which uses CFRunLoopGetCurrent(). So this comment that
3343         it can be done on any thread is misleading and can lead to incorrect behavior
3344         if it is actually done on a non-main thread on Mac.
3345
3346 2017-02-09  Alex Christensen  <achristensen@webkit.org>
3347
3348         Unreviewed, rolling out r212040.
3349
3350         Broke build.  I'm not surprised
3351
3352         Reverted changeset:
3353
3354         "[WebRTC][Mac] Activate libwebrtc"
3355         https://bugs.webkit.org/show_bug.cgi?id=167293
3356         http://trac.webkit.org/changeset/212040
3357
3358 2017-02-09  Youenn Fablet  <youenn@apple.com>
3359
3360         [WebRTC][Mac] Activate libwebrtc
3361         https://bugs.webkit.org/show_bug.cgi?id=167293
3362
3363         Reviewed by Alex Christensen.
3364
3365         * wtf/Platform.h:
3366
3367 2017-02-09  Brady Eidson  <beidson@apple.com>
3368
3369         Transition "WebKit Library Version" checks to SDK version checks.
3370         <rdar://problem/30313696> and https://bugs.webkit.org/show_bug.cgi?id=168056
3371
3372         Reviewed by Geoffrey Garen.
3373
3374         * wtf/spi/darwin/dyldSPI.h: Add entries for the iOS 10.3, macOS 10.11, and macOS 10.12.4 SDKs.
3375
3376 2017-02-09  Commit Queue  <commit-queue@webkit.org>
3377
3378         Unreviewed, rolling out r211980 and r211987.
3379         https://bugs.webkit.org/show_bug.cgi?id=168072
3380
3381         Caused API test WebKit2.DuplicateCompletionHandlerCalls to
3382         fail (Requested by ryanhaddad on #webkit).
3383
3384         Reverted changesets:
3385
3386         "Transition "WebKit Library Version" checks to SDK version
3387         checks."
3388         https://bugs.webkit.org/show_bug.cgi?id=168056
3389         http://trac.webkit.org/changeset/211980
3390
3391         "Build fix for APPLE_INTERNAL_SDK builds after r211980."
3392         http://trac.webkit.org/changeset/211987
3393
3394 2017-02-09  Alexey Proskuryakov  <ap@apple.com>
3395
3396         Remove unused WebThreadRunSync
3397         https://bugs.webkit.org/show_bug.cgi?id=168024
3398
3399         Reviewed by Tim Horton.
3400
3401         * wtf/ios/WebCoreThread.cpp:
3402         * wtf/ios/WebCoreThread.h:
3403
3404 2017-02-09  Brady Eidson  <beidson@apple.com>
3405
3406         Build fix for APPLE_INTERNAL_SDK builds after r211980.
3407
3408         Unreviewed.
3409
3410         * wtf/spi/darwin/dyldSPI.h:
3411
3412 2017-02-09  Brady Eidson  <beidson@apple.com>
3413
3414         Transition "WebKit Library Version" checks to SDK version checks.
3415         <rdar://problem/30313696> and https://bugs.webkit.org/show_bug.cgi?id=168056
3416
3417         Reviewed by Geoffrey Garen.
3418
3419         * wtf/spi/darwin/dyldSPI.h: Add entries for the iOS 10.3, macOS 10.11, and macOS 10.12.4 SDKs.
3420
3421 2017-02-06  Jer Noble  <jer.noble@apple.com>
3422
3423         Playback stalls when a SourceBuffer append causes frame eviction
3424         https://bugs.webkit.org/show_bug.cgi?id=167834
3425
3426         Reviewed by Eric Carlson.
3427
3428         Optimize the MediaTime class; specifically the compare() method. The class only
3429         needs 6 bits to store the TimeFlags, so make that a uint8_t rather than uint32_t.
3430         The implementation is slightly simpler if the TimeScale is unsigned, so make that
3431         a uint32_t rather than int32_t. Inline the comparison operators. Optimize the equality
3432         comparison by bitwise-and'ing the flags together and masking the result. Optimize for
3433         common comparison scenarios (equal timeScales, equal timeValues(), etc.). Attempt the
3434         mathematically simpler simpler method for comparing ratios, and only fall back to the
3435         complex method if the results of multiplying the timeScale by the timeValue overflows.
3436
3437         * wtf/MediaTime.cpp:
3438         (WTF::greatestCommonDivisor):
3439         (WTF::leastCommonMultiple):
3440         (WTF::signum):
3441         (WTF::MediaTime::MediaTime):
3442         (WTF::MediaTime::createWithFloat):
3443         (WTF::MediaTime::createWithDouble):
3444         (WTF::MediaTime::operator+):
3445         (WTF::MediaTime::operator-):
3446         (WTF::MediaTime::operator!):
3447         (WTF::MediaTime::operator bool):
3448         (WTF::MediaTime::compare):
3449         (WTF::MediaTime::setTimeScale):
3450         (WTF::abs):
3451         (WTF::MediaTime::operator<): Deleted.
3452         (WTF::MediaTime::operator>): Deleted.
3453         (WTF::MediaTime::operator!=): Deleted.
3454         (WTF::MediaTime::operator==): Deleted.
3455         (WTF::MediaTime::operator>=): Deleted.
3456         (WTF::MediaTime::operator<=): Deleted.
3457         * wtf/MediaTime.h:
3458
3459 2017-02-04  Michael Catanzaro  <mcatanzaro@igalia.com>
3460
3461         [GTK] Fix huge ENABLE_RESOURCE_USAGE warning spam
3462
3463         Unreviewed. We shouldn't redefine ENABLE_RESOURCE_USAGE in Platform.h as
3464         it's already defined in cmakeconfig.h.
3465
3466         * wtf/Platform.h:
3467
3468 2017-02-03  Joseph Pecoraro  <pecoraro@apple.com>
3469
3470         Performance Timing: Convert WTF::MonotonicTime and WTF::Seconds
3471         https://bugs.webkit.org/show_bug.cgi?id=167768
3472
3473         Reviewed by Geoffrey Garen.
3474
3475         * wtf/Stopwatch.h:
3476         (WTF::Stopwatch::elapsedTimeSince):
3477         (WTF::Stopwatch::elapsedTimeSinceMonotonicTime): Deleted.
3478
3479 2017-02-03  Carlos Garcia Campos  <cgarcia@igalia.com>
3480
3481         [GTK] Add initial implementation of resource usage overlay
3482         https://bugs.webkit.org/show_bug.cgi?id=167731
3483
3484         Reviewed by Michael Catanzaro.
3485
3486         Enable RESOURCE_USAGE for GTK+ port too.
3487
3488         * wtf/Platform.h:
3489
3490 2017-02-02  Andreas Kling  <akling@apple.com>
3491
3492         [Mac] In-process memory pressure monitor for WebContent processes AKA websam
3493         <https://webkit.org/b/167491>
3494         <rdar://problem/30116072>
3495
3496         Reviewed by Antti Koivisto.
3497
3498         Add a WTF helper function for getting the current process's memory footprint.
3499
3500         * WTF.xcodeproj/project.pbxproj:
3501         * wtf/CMakeLists.txt:
3502         * wtf/MemoryFootprint.cpp:
3503         (WTF::memoryFootprint):
3504         * wtf/MemoryFootprint.h:
3505
3506 2017-02-02  Mark Lam  <mark.lam@apple.com>
3507
3508         Add a SIGILL crash analyzer to make debugging SIGILLs easier.
3509         https://bugs.webkit.org/show_bug.cgi?id=167714
3510         <rdar://problem/30318237>
3511
3512         Reviewed by Filip Pizlo.
3513
3514         * wtf/StdLibExtras.h:
3515
3516 2017-02-02  Commit Queue  <commit-queue@webkit.org>
3517
3518         Unreviewed, rolling out r211571 and r211582.
3519         https://bugs.webkit.org/show_bug.cgi?id=167751
3520
3521         This change caused API test WebKit1.MemoryPressureHandler to
3522         fail with an assertion. (Requested by ryanhaddad on #webkit).
3523
3524         Reverted changesets:
3525
3526         "[Mac] In-process memory pressure monitor for WebContent
3527         processes."
3528         https://bugs.webkit.org/show_bug.cgi?id=167491
3529         http://trac.webkit.org/changeset/211571
3530
3531         "Unreviewed attempt to fix the Windows build after r211571."
3532         http://trac.webkit.org/changeset/211582
3533
3534 2017-02-02  Andreas Kling  <akling@apple.com>
3535
3536         [Mac] In-process memory pressure monitor for WebContent processes.
3537         <https://webkit.org/b/167491>
3538         <rdar://problem/30116072>
3539
3540         Reviewed by Antti Koivisto.
3541
3542         Add a WTF helper function for getting the current process's memory footprint.
3543
3544         * WTF.xcodeproj/project.pbxproj:
3545         * wtf/CMakeLists.txt:
3546         * wtf/MemoryFootprint.cpp:
3547         (WTF::memoryFootprint):
3548         * wtf/MemoryFootprint.h:
3549
3550 2017-02-01  Wenson Hsieh  <wenson_hsieh@apple.com>
3551
3552         Unreviewed, fix the WebKit nightly open source build
3553         <rdar://problem/30308635>
3554
3555         We cannot assume all internal SDKs have the latest WebKitAdditions, so we need an explicit header check here.
3556
3557         * wtf/Platform.h:
3558
3559 2017-02-01  Andreas Kling  <akling@apple.com>
3560
3561         Implement the alwaysRunsAtBackgroundPriority WK2 setting using thread QoS.
3562         <https://webkit.org/b/167387>
3563         <rdar://problem/29711409>
3564
3565         Reviewed by Antti Koivisto.
3566
3567         Add a new mechanism for overriding the max thread QoS level globally:
3568
3569             void setGlobalMaxQOSClass(qos_class_t)
3570             qos_class_t adjustedQOSClass(qos_class_t)
3571
3572         The QoS cap applies to all newly created threads, threads that try to override
3573         their QoS class manually, and also passed down to bmalloc.
3574
3575         * wtf/Threading.cpp:
3576         (WTF::setCurrentThreadIsUserInteractive):
3577         (WTF::setCurrentThreadIsUserInitiated):
3578         (WTF::setGlobalMaxQOSClass):
3579         (WTF::adjustedQOSClass):
3580         * wtf/Threading.h:
3581         * wtf/ThreadingPthreads.cpp:
3582         (WTF::createThreadInternal):
3583         * wtf/cocoa/WorkQueueCocoa.cpp:
3584         (WTF::dispatchQOSClass):
3585
3586 2017-01-31  Antti Koivisto  <antti@apple.com>
3587
3588         Teach cache coders to encode time_points
3589         https://bugs.webkit.org/show_bug.cgi?id=167670
3590
3591         Reviewed by Andreas Kling.
3592
3593         * wtf/persistence/Coders.h:
3594         (WTF::Persistence::Coder<std::chrono::system_clock::time_point>::encode):
3595         (WTF::Persistence::Coder<std::chrono::system_clock::time_point>::decode):
3596
3597 2017-01-31  Joseph Pecoraro  <pecoraro@apple.com>
3598
3599         Removed unused m_nestedCount from RunLoop
3600         https://bugs.webkit.org/show_bug.cgi?id=167674
3601
3602         Reviewed by Sam Weinig.
3603
3604         * wtf/RunLoop.h:
3605         * wtf/cf/RunLoopCF.cpp:
3606         (WTF::RunLoop::RunLoop):
3607         (WTF::RunLoop::run):
3608
3609 2017-01-31  Filip Pizlo  <fpizlo@apple.com>
3610
3611         The mutator should be able to perform increments of GC work
3612         https://bugs.webkit.org/show_bug.cgi?id=167528
3613
3614         Reviewed by Keith Miller and Geoffrey Garen.
3615
3616         We want dataLog to be locked even if you're not logging to a file!
3617
3618         * wtf/DataLog.cpp:
3619         (WTF::initializeLogFileOnce):
3620
3621 2017-01-28  Wenson Hsieh  <wenson_hsieh@apple.com>
3622
3623         Check USE(APPLE_INTERNAL_SDK) instead of specific headers when importing from WebKitAdditions
3624         https://bugs.webkit.org/show_bug.cgi?id=167555
3625
3626         Reviewed by Dan Bernstein.
3627
3628         Instead of guarding #import <WebKitAdditions/*> on the existence of the imported file, consult
3629         USE(APPLE_INTERNAL_SDK) instead.
3630
3631         * wtf/Platform.h:
3632
3633 2017-01-26  Saam Barati  <sbarati@apple.com>
3634
3635         Harden how the compiler references GC objects
3636         https://bugs.webkit.org/show_bug.cgi?id=167277
3637         <rdar://problem/30179506>
3638
3639         Reviewed by Filip Pizlo.
3640
3641         I made TinyPtrSet use bitwise_cast instead of static_cast
3642         for its singleEntry() function so that it can work on pointer-like
3643         types just as it can on actual pointer types.
3644         
3645         An example of where this matters is when you have TinyPtrSet<T>
3646         where T is defined to be a struct which wraps a pointer, e.g:
3647         
3648         struct T {
3649             void* m_pointer;
3650         }
3651
3652         * wtf/TinyPtrSet.h:
3653         (WTF::TinyPtrSet::singleEntry):
3654
3655 2017-01-25  Wenson Hsieh  <wenson_hsieh@apple.com>
3656
3657         Introduce an item-provider-based pasteboard wrapper
3658         https://bugs.webkit.org/show_bug.cgi?id=167410
3659
3660         Reviewed by Enrica Casucci.
3661
3662         Adds an additional feature flag.
3663
3664         * wtf/FeatureDefines.h:
3665
3666 2017-01-25  Konstantin Tokarev  <annulen@yandex.ru>
3667
3668         Removed leftovers of pre-2015 VisualStudio support
3669         https://bugs.webkit.org/show_bug.cgi?id=167434
3670
3671         Reviewed by Alex Christensen.
3672
3673         * wtf/Compiler.h:
3674         * wtf/Platform.h:
3675         * wtf/StringExtras.h:
3676
3677 2017-01-25  Chris Dumez  <cdumez@apple.com>
3678
3679         Disable Download attribute support on iOS
3680         https://bugs.webkit.org/show_bug.cgi?id=167337
3681         <rdar://problem/30154148>
3682
3683         Reviewed by Alexey Proskuryakov.
3684
3685         Disable Download attribute support on iOS as it currently does not work.
3686
3687         * wtf/FeatureDefines.h:
3688
3689 2017-01-25  Wenson Hsieh  <wenson_hsieh@apple.com>
3690
3691         Add a hook to include additional feature defines
3692         https://bugs.webkit.org/show_bug.cgi?id=167403
3693
3694         Reviewed by Enrica Casucci.
3695
3696         * wtf/Platform.h: Include AdditionalFeatureDefines.h, if it exists.
3697
3698 2017-01-24  Joseph Pecoraro  <pecoraro@apple.com>
3699
3700         Fold USER_TIMING into WEB_TIMING and make it a RuntimeEnabledFeature
3701         https://bugs.webkit.org/show_bug.cgi?id=167394
3702
3703         Reviewed by Ryosuke Niwa.
3704
3705         * wtf/FeatureDefines.h:
3706
3707 2017-01-24  Konstantin Tokarev  <annulen@yandex.ru>
3708
3709         VS2015 supports ref qualifiers
3710         https://bugs.webkit.org/show_bug.cgi?id=167368
3711
3712         Reviewed by Sam Weinig.
3713
3714         * wtf/Compiler.h: Enable
3715         WTF_COMPILER_SUPPORTS_CXX_REFERENCE_QUALIFIED_FUNCTIONS for VS2015
3716
3717 2017-01-24  Daniel Bates  <dabates@apple.com>
3718
3719         StringView.split() should use an iterator design pattern instead of allocating a Vector
3720         https://bugs.webkit.org/show_bug.cgi?id=163225
3721
3722         Reviewed by Darin Adler.
3723
3724         Implement StringView.split() using an iterator design.
3725
3726         Using an iterator design avoids the need to allocate a Vector of StringView objects,
3727         which is space-inefficient and error prone as the returned Vector may outlive the
3728         lifetime of the underlying string associated with the split (as StringView is a non-
3729         owning reference to a string).
3730
3731         StringView.split() now returns a StringView::SplitResult object that implements begin()/end()
3732         to support iterating over StringView substrings delimited by the specified separator
3733         character. For example, to iterate over the 'c'-separated substrings of a StringView v,
3734         you can write:
3735
3736         for (StringView substring : v.split('c'))
3737             // Do something with substring.
3738
3739         * wtf/text/StringView.cpp:
3740         (WTF::StringView::SplitResult::Iterator::findNextSubstring): Advances the iterator to point to the
3741         next substring.
3742         (WTF::StringView::split): Modified to return a SplitResult::Iterator object instead of a Vector<StringView>.
3743         * wtf/text/StringView.h:
3744         (WTF::StringView::SplitResult::SplitResult):
3745         (WTF::StringView::SplitResult::Iterator::Iterator):
3746         (WTF::StringView::SplitResult::Iterator::operator*):
3747         (WTF::StringView::SplitResult::Iterator::operator==):
3748         (WTF::StringView::SplitResult::Iterator::operator!=):
3749         Implements the iterator interface.
3750
3751 2017-01-20  Joseph Pecoraro  <pecoraro@apple.com>
3752
3753         Remove outdated ENABLE(CSP_NEXT) build flag
3754         https://bugs.webkit.org/show_bug.cgi?id=167252
3755
3756         Reviewed by Brent Fulgham.
3757
3758         * wtf/FeatureDefines.h:
3759
3760 2017-01-17  Andreas Kling  <akling@apple.com>
3761
3762         Annotate FastMalloc functions with returns_nonnull attribute.
3763         <https://webkit.org/b/167144>
3764
3765         Reviewed by Antti Koivisto.
3766
3767         Decorate fastMalloc() and friends with __attribute__((returns_nonnull)) for supporting
3768         compilers that can do useful things with that information.
3769
3770         * wtf/Compiler.h:
3771         * wtf/FastMalloc.h:
3772
3773 2017-01-17  Joseph Pecoraro  <pecoraro@apple.com>
3774
3775         ENABLE(USER_TIMING) Not Defined for Apple Windows or OS X Ports
3776         https://bugs.webkit.org/show_bug.cgi?id=116551
3777         <rdar://problem/13949830>
3778
3779         Reviewed by Alex Christensen.
3780
3781         * wtf/FeatureDefines.h:
3782
3783 2017-01-16  Joseph Pecoraro  <pecoraro@apple.com>
3784
3785         Remove the REQUEST_ANIMATION_FRAME flag
3786         https://bugs.webkit.org/show_bug.cgi?id=156980
3787         <rdar://problem/25906849>
3788
3789         Reviewed by Simon Fraser.
3790
3791         * wtf/FeatureDefines.h:
3792
3793 2017-01-15  Sam Weinig  <sam@webkit.org>
3794
3795         Add the ability to use numbers in makeString()
3796         https://bugs.webkit.org/show_bug.cgi?id=167087
3797
3798         Reviewed by Darin Adler.
3799
3800         Allow numbers to be easily used in makeString() and tryMakeString().
3801
3802         For instance, you can now write:
3803             int amount = 7;
3804             auto foo = makeString("There are ", amount, " apples in the cart");
3805
3806         * WTF.xcodeproj/project.pbxproj:
3807         Add new file.
3808
3809         * wtf/text/IntegerToStringConversion.h:
3810         (WTF::writeNumberToBufferImpl):
3811         (WTF::writeNumberToBufferSigned):
3812         (WTF::writeNumberToBufferUnsigned):
3813         (WTF::lengthOfNumberAsStringImpl):
3814         (WTF::lengthOfNumberAsStringSigned):
3815         (WTF::lengthOfNumberAsStringUnsigned):
3816         Add variants of integer writing code that compute the length of the string
3817         that would be produced and writes the string to an existing buffer.
3818
3819         (WTF::IntegerToStringConversionTrait<AtomicString>::flush): Deleted.
3820         (WTF::IntegerToStringConversionTrait<String>::flush): Deleted.
3821         (WTF::IntegerToStringConversionTrait<StringBuilder>::flush): Deleted.
3822         Move these traits to their respective classes.
3823
3824         * wtf/text/AtomicString.h:
3825         (WTF::IntegerToStringConversionTrait<AtomicString>::flush):
3826         * wtf/text/StringBuilder.h:
3827         (WTF::IntegerToStringConversionTrait<StringBuilder>::flush):
3828         * wtf/text/WTFString.h:
3829         (WTF::IntegerToStringConversionTrait<String>::flush):
3830         Traits moved here from IntegerToStringConversion.h
3831
3832         * wtf/text/StringConcatenateNumbers.h: Added.
3833         (WTF::StringTypeAdapter<int>::StringTypeAdapter<int>):
3834         (WTF::StringTypeAdapter<int>::length):
3835         (WTF::StringTypeAdapter<int>::is8Bit):
3836         (WTF::StringTypeAdapter<int>::writeTo):
3837         (WTF::StringTypeAdapter<int>::toString):
3838         (WTF::StringTypeAdapter<unsigned>::StringTypeAdapter<unsigned>):
3839         (WTF::StringTypeAdapter<unsigned>::length):
3840         (WTF::StringTypeAdapter<unsigned>::is8Bit):
3841         (WTF::StringTypeAdapter<unsigned>::writeTo):
3842         (WTF::StringTypeAdapter<unsigned>::toString):
3843         (WTF::StringTypeAdapter<float>::StringTypeAdapter<float>):
3844         (WTF::StringTypeAdapter<float>::length):
3845         (WTF::StringTypeAdapter<float>::is8Bit):
3846         (WTF::StringTypeAdapter<float>::writeTo):
3847         (WTF::StringTypeAdapter<float>::toString):
3848         (WTF::StringTypeAdapter<double>::StringTypeAdapter<double>):
3849         (WTF::StringTypeAdapter<double>::length):
3850         (WTF::StringTypeAdapter<double>::is8Bit):
3851         (WTF::StringTypeAdapter<double>::writeTo):
3852         (WTF::StringTypeAdapter<double>::toString):
3853         Add basic adaptors for int, unsigned, float, and double.
3854
3855         (WTF::FormattedNumber::fixedPrecision):
3856         (WTF::FormattedNumber::fixedWidth):
3857         (WTF::FormattedNumber::length):
3858         (WTF::FormattedNumber::buffer):
3859         (WTF::FormattedNumber::stringView):
3860         (WTF::StringTypeAdapter<FormattedNumber>::StringTypeAdapter<FormattedNumber>):
3861         (WTF::StringTypeAdapter<FormattedNumber>::length):
3862         (WTF::StringTypeAdapter<FormattedNumber>::is8Bit):
3863         (WTF::StringTypeAdapter<FormattedNumber>::writeTo):
3864         (WTF::StringTypeAdapter<FormattedNumber>::toString):
3865         Add a special class, FormattedNumber, and an adaptor for it, allowing for
3866         fixedPrecision and fixedWidth representation of doubles.
3867
3868 2017-01-14  Yusuke Suzuki  <utatane.tea@gmail.com>
3869
3870         WebAssembly: Suppress warnings & errors in GCC
3871         https://bugs.webkit.org/show_bug.cgi?id=167049
3872
3873         Reviewed by Sam Weinig.
3874
3875         * wtf/LEBDecoder.h:
3876         (WTF::LEBDecoder::decodeInt):
3877         If T = int, it performs `-1 << shift`. It causes
3878         warning in GCC. Instead, we first cast it to the
3879         UnsignedT, perform operation and re-cast to the
3880         T.
3881
3882 2017-01-13  Joseph Pecoraro  <pecoraro@apple.com>
3883
3884         Remove ENABLE(DETAILS_ELEMENT) guards
3885         https://bugs.webkit.org/show_bug.cgi?id=167042
3886
3887         Reviewed by Alex Christensen.
3888
3889         * wtf/FeatureDefines.h:
3890
3891 2017-01-11  Darin Adler  <darin@apple.com>
3892
3893         Remove PassRefPtr from more of "platform"
3894         https://bugs.webkit.org/show_bug.cgi?id=166809
3895
3896         Reviewed by Sam Weinig.
3897
3898         * wtf/Ref.h: Changed the template so that a const Ref<T> does not prohibit non-const
3899         use of T. We can still use const Ref<const T> to express that. The earlier design
3900         was intentional, but was not consistent with either actual references or with
3901         other smart pointer classes like RefPtr. One way to see how much better this is,
3902         is to see all the many, many cases where we have const_cast just to work around
3903         this. I searched for those and included fixes for many in this patch.
3904
3905 2017-01-12  Chris Dumez  <cdumez@apple.com>
3906
3907         [iOS] Implement support for KeyboardEvent.code
3908         https://bugs.webkit.org/show_bug.cgi?id=166932
3909         <rdar://problem/29972518>
3910
3911         Reviewed by Darin Adler.
3912
3913         Enable KEYBOARD_CODE_ATTRIBUTE feature on iOS.
3914
3915         * wtf/FeatureDefines.h:
3916
3917 2017-01-11  Andreas Kling  <akling@apple.com>
3918
3919         Crash when WebCore's GC heap grows way too large.
3920         <https://webkit.org/b/166875>
3921         <rdar://problem/27896585>
3922
3923         Reviewed by Mark Lam.
3924
3925         Publish the WTF::GB constant.
3926
3927         * wtf/StdLibExtras.h:
3928
3929 2017-01-11  Anders Carlsson  <andersca@apple.com>
3930
3931         navigator.plugins.refresh and WKContextRefreshPlugIns doesn't pick up changes to already-present plug-ins
3932         https://bugs.webkit.org/show_bug.cgi?id=166942
3933         rdar://problem/29839194
3934
3935         Reviewed by Sam Weinig.
3936
3937         * wtf/spi/cf/CFBundleSPI.h:
3938         Add SPI declaration.
3939
3940 2017-01-06  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
3941
3942         [GTK] Should support key and code properties on keyboard events
3943         https://bugs.webkit.org/show_bug.cgi?id=166759
3944
3945         Reviewed by Carlos Garcia Campos.
3946
3947         * wtf/FeatureDefines.h: enable key and code properties support for GTK.
3948
3949 2017-01-08  Antti Koivisto  <antti@apple.com>
3950
3951         Move cache coders to WTF
3952         https://bugs.webkit.org/show_bug.cgi?id=166825
3953
3954         Rubber-stamped by Sam Weinig.
3955
3956         Make it possible to use robust serialization of WTF types on the lower levels of the stack.
3957
3958         * WTF.xcodeproj/project.pbxproj:
3959         * wtf/persistence: Added.
3960         * wtf/persistence/Coder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoder.h.
3961         (WebKit::NetworkCache::Coder::encode): Deleted.
3962         (WebKit::NetworkCache::Coder::decode): Deleted.
3963         * wtf/persistence/Coders.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp.
3964         (WebKit::NetworkCache::Coder<AtomicString>::encode): Deleted.
3965         (WebKit::NetworkCache::Coder<AtomicString>::decode): Deleted.
3966         (WebKit::NetworkCache::Coder<CString>::encode): Deleted.
3967         (WebKit::NetworkCache::Coder<CString>::decode): Deleted.
3968         (WebKit::NetworkCache::Coder<String>::encode): Deleted.
3969         (WebKit::NetworkCache::decodeStringText): Deleted.
3970         (WebKit::NetworkCache::Coder<String>::decode): Deleted.
3971         (WebKit::NetworkCache::Coder<SHA1::Digest>::encode): Deleted.
3972         (WebKit::NetworkCache::Coder<SHA1::Digest>::decode): Deleted.
3973         (WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::encode): Deleted.
3974         (WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::decode): Deleted.
3975         * wtf/persistence/Coders.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h.
3976         (WebKit::NetworkCache::Coder<std::optional<T>>::encode): Deleted.
3977         (WebKit::NetworkCache::Coder<std::optional<T>>::decode): Deleted.
3978         * wtf/persistence/Decoder.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheDecoder.cpp.
3979         (WebKit::NetworkCache::Decoder::Decoder): Deleted.
3980         (WebKit::NetworkCache::Decoder::~Decoder): Deleted.
3981         (WebKit::NetworkCache::Decoder::bufferIsLargeEnoughToContain): Deleted.
3982         (WebKit::NetworkCache::Decoder::decodeFixedLengthData): Deleted.
3983         (WebKit::NetworkCache::Decoder::decodeNumber): Deleted.
3984         (WebKit::NetworkCache::Decoder::decode): Deleted.
3985         (WebKit::NetworkCache::Decoder::verifyChecksum): Deleted.
3986         * wtf/persistence/Decoder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheDecoder.h.
3987         (WebKit::NetworkCache::Decoder::length): Deleted.
3988         (WebKit::NetworkCache::Decoder::currentOffset): Deleted.
3989         (WebKit::NetworkCache::Decoder::decodeEnum): Deleted.
3990         (WebKit::NetworkCache::Decoder::decode): Deleted.
3991         (WebKit::NetworkCache::Decoder::bufferIsLargeEnoughToContain): Deleted.
3992         * wtf/persistence/Encoder.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.cpp.
3993         (WebKit::NetworkCache::Encoder::Encoder): Deleted.
3994         (WebKit::NetworkCache::Encoder::~Encoder): Deleted.
3995         (WebKit::NetworkCache::Encoder::grow): Deleted.
3996         (WebKit::NetworkCache::Encoder::updateChecksumForData): Deleted.
3997         (WebKit::NetworkCache::Encoder::encodeFixedLengthData): Deleted.
3998         (WebKit::NetworkCache::Encoder::encodeNumber): Deleted.
3999         (WebKit::NetworkCache::Encoder::encode): Deleted.
4000         (WebKit::NetworkCache::Encoder::encodeChecksum): Deleted.
4001         * wtf/persistence/Encoder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.h.
4002         (WebKit::NetworkCache::Encoder::encodeEnum): Deleted.
4003         (WebKit::NetworkCache::Encoder::encode): Deleted.
4004         (WebKit::NetworkCache::Encoder::operator<<): Deleted.
4005         (WebKit::NetworkCache::Encoder::buffer): Deleted.
4006         (WebKit::NetworkCache::Encoder::bufferSize): Deleted.
4007         (WebKit::NetworkCache::Encoder::updateChecksumForNumber): Deleted.
4008
4009 2017-01-08  Konstantin Tokarev  <annulen@yandex.ru>
4010
4011         Introduce CPU(X86_SSE2) instead of various SSE2 checks
4012         https://bugs.webkit.org/show_bug.cgi?id=166808
4013
4014         Reviewed by Michael Catanzaro.
4015
4016         Now copyLCharsFromUCharSource can use SSE2 implementation on non-Darwin
4017         OSes, and all SSE2 code paths are available for MSVC on x86 if /arch:SSE2
4018         or higher is enabled, and for MSVC on x86_64.
4019
4020         * wtf/Platform.h:
4021         * wtf/text/ASCIIFastPath.h:
4022         (WTF::copyLCharsFromUCharSource):
4023
4024 2017-01-05  Myles C. Maxfield  <mmaxfield@apple.com>
4025
4026         Carets can split up marriages and families
4027         https://bugs.webkit.org/show_bug.cgi?id=166711
4028         <rdar://problem/29019333>
4029
4030         Reviewed by Alex Christensen.
4031
4032         There are four code points which should be allowed to accept emoji modifiers:
4033         - U+1F46A FAMILY
4034         - U+1F46B MAN AND WOMAN HOLDING HANDS
4035         - U+1F46C TWO MEN HOLDING HANDS
4036         - U+1F46D TWO WOMEN HOLDING HANDS
4037
4038         Even though macOS's and iOS's emoji keyboard don't allow users to actually type
4039         these combinations, we may still receive them from other platforms. We should
4040         therefore treat these as joining sequences. Rendering isn't a problem because
4041         the fonts accept the emoji modifiers, but our caret placement code isn't educated
4042         about it. Currently, we treat these emoji groups as ligatures, allowing the caret
4043         to be placed between the two code points, which visually shows as being horizontally
4044         centered in the glyph. Instead, we should treat these code points as accepting
4045         emoji modifiers.
4046
4047         Tests: editing/caret/emoji.html
4048                editing/caret/ios/emoji.html
4049
4050         * wtf/text/TextBreakIterator.cpp:
4051         (WTF::cursorMovementIterator):
4052
4053 2017-01-05  Filip Pizlo  <fpizlo@apple.com>
4054
4055         AutomaticThread timeout shutdown leaves a small window where notify() would think that the thread is still running
4056         https://bugs.webkit.org/show_bug.cgi?id=166742
4057
4058         Reviewed by Geoffrey Garen.
4059         
4060         Remove the use of the RAII ThreadScope, since the use of RAII helped make this bug possible:
4061         we'd do ~ThreadScope after we had done ~LockHolder, so in between when we decided to shut
4062         down a thread and when it reported itself as being shut down, there was a window where a
4063         notify() call would get confused.
4064         
4065         Now, we run all thread shutdown stuff while the lock is held. We release the lock last. One
4066         API implication is that threadWillStop becomes threadIsStopping and it's called while the
4067         lock is held. This seems benign.
4068
4069         * wtf/AutomaticThread.cpp:
4070         (WTF::AutomaticThread::start):
4071         (WTF::AutomaticThread::threadIsStopping):
4072         (WTF::AutomaticThread::ThreadScope::ThreadScope): Deleted.
4073         (WTF::AutomaticThread::ThreadScope::~ThreadScope): Deleted.
4074         (WTF::AutomaticThread::threadWillStop): Deleted.
4075         * wtf/AutomaticThread.h:
4076
4077 2017-01-04  Darin Adler  <darin@apple.com>
4078
4079         Remove PassRefPtr use from the "html" directory, other improvements
4080         https://bugs.webkit.org/show_bug.cgi?id=166635
4081
4082         Reviewed by Alex Christensen.
4083
4084         * wtf/RefPtr.h:
4085         (WTF::makeRefPtr): Added.
4086
4087 2017-01-04  Yusuke Suzuki  <utatane.tea@gmail.com>
4088
4089         Unreviewed build fix after r210313
4090         https://bugs.webkit.org/show_bug.cgi?id=166676
4091
4092         Revert `#pragma once` to ifdefs due to build failure.
4093
4094         * wtf/text/StringView.h:
4095
4096 2017-01-04  Yusuke Suzuki  <utatane.tea@gmail.com>
4097
4098         Limit thread name appropriately
4099         https://bugs.webkit.org/show_bug.cgi?id=166676
4100
4101         Reviewed by Sam Weinig.
4102
4103         In some platform, the max length of thread names are limited.
4104         For example, the number of the max length is 32 in Windows and
4105         16 in Linux. But the specified thread name is typically long
4106         in WebKit like "com.apple.CoreIPC.ReceiveQueue"
4107
4108         We port the logic substring the thread name in
4109         generic/WorkQueueGeneric.cpp to Threading. It retrieves the name
4110         "ReceiveQueue" from "com.apple.CoreIPC.ReceiveQueue". And apply
4111         the appropriate the thread name limit and use it on Linux and
4112         Windows environment.
4113
4114         * wtf/Threading.cpp:
4115         (WTF::normalizeThreadName):
4116         (WTF::createThread):
4117         * wtf/Threading.h:
4118         * wtf/ThreadingPthreads.cpp:
4119         (WTF::initializeCurrentThreadInternal):
4120         * wtf/ThreadingWin.cpp:
4121         (WTF::initializeCurrentThreadInternal):
4122         * wtf/generic/WorkQueueGeneric.cpp:
4123         (WorkQueue::platformInitialize):
4124         * wtf/text/StringView.h:
4125         (WTF::StringView::left):
4126         (WTF::StringView::right):
4127         (WTF::StringView::reverseFind):
4128
4129 2017-01-04  Sam Weinig  <sam@webkit.org>
4130
4131         REGRESSION (r210257): com.apple.WebKit.WebContent.Development crashed in com.apple.WebCore: WebCore::ExceptionOr<WTF::Ref<WebCore::Database> >::operator= + 14
4132         <rdar://problem/29866398> 
4133
4134         * wtf/Expected.h:
4135         (WTF::Expected::swap):
4136         Add missing calls to destroy() when moving things over each other in a union.
4137
4138 2017-01-03  Yusuke Suzuki  <utatane.tea@gmail.com>
4139
4140         Use prctl to name thread on Linux
4141         https://bugs.webkit.org/show_bug.cgi?id=166663
4142
4143         Reviewed by Michael Catanzaro.
4144
4145         It is quite useful if we can name threads. This name will be shown in GDB.
4146         While macOS uses pthread_setname_np, we can use prctl on Linux.
4147
4148         * wtf/ThreadingPthreads.cpp:
4149         (WTF::initializeCurrentThreadInternal):
4150
4151 2017-01-03  Yusuke Suzuki  <utatane.tea@gmail.com>
4152
4153         WorkQueueGeneric's platformInvalidate() can deadlock when called on the RunLoop's thread
4154         https://bugs.webkit.org/show_bug.cgi?id=166645
4155
4156         Reviewed by Carlos Garcia Campos.
4157
4158         WorkQueue can be destroyed on its invoking thread itself.
4159         The scenario is the following.
4160
4161             1. Create WorkQueue (in thread A).
4162             2. Dispatch a task (in thread A, dispatching a task to thread B).
4163             3. Deref in thread A.
4164             4. The task is executed in thread B.
4165             5. Deref in thread B.
4166             6. The WorkQueue is destroyed, calling platformInvalidate in thread B.
4167
4168         In that case, if platformInvalidate waits thread B's termination, it causes deadlock.
4169         We do not need to wait the thread termination.
4170
4171         * wtf/WorkQueue.h:
4172         * wtf/generic/WorkQueueGeneric.cpp:
4173         (WorkQueue::platformInitialize):
4174         (WorkQueue::platformInvalidate):
4175
4176 2017-01-03  Sam Weinig  <sam@webkit.org>
4177
4178         Make WTF::Expected support Ref template parameters
4179         https://bugs.webkit.org/show_bug.cgi?id=166662
4180
4181         Reviewed by Alex Christensen.
4182
4183         Tests: Added to TestWebKitAPI/Expected.cpp
4184
4185         * wtf/Expected.h:
4186         (WTF::UnexpectedType::value):
4187         Add overloads based on this value type to allow getting at the value
4188         as an rvalue for moving the error into the Expected.
4189
4190         (WTF::Expected::Expected):
4191         Add overload that takes an ErrorType/UnexpectedType<ErrorType> as an rvalue.
4192
4193         (WTF::Expected::swap):
4194         Move the temporary value/error rather than copying.
4195
4196 2017-01-02  Julien Brianceau  <jbriance@cisco.com>
4197
4198         Remove sh4 specific code from JavaScriptCore
4199         https://bugs.webkit.org/show_bug.cgi?id=166640
4200
4201         Reviewed by Filip Pizlo.
4202
4203         * wtf/Platform.h:
4204
4205 2017-01-02  Yusuke Suzuki  <utatane.tea@gmail.com>
4206
4207         Leverage Substring to create new AtomicStringImpl for StaticStringImpl and SymbolImpl
4208         https://bugs.webkit.org/show_bug.cgi?id=166636
4209
4210         Reviewed by Darin Adler.
4211
4212         Previously we always create the full atomic string if we need to create the same string
4213         based on the given value. For example, when generating AtomicStringImpl from the SymbolImpl,
4214         we need to create a new AtomicStringImpl since SymbolImpl never becomes `isAtomic() == true`.
4215         But it is costly.
4216
4217         This patch leverages the substring system of StringImpl. Instead of allocating the completely
4218         duplicate string, we create a substring StringImpl that shares the same content with the
4219         base string.
4220
4221         * wtf/text/AtomicStringImpl.cpp:
4222         (WTF::stringTable):
4223         (WTF::addToStringTable):
4224         (WTF::addSubstring):
4225         (WTF::AtomicStringImpl::addSlowCase):
4226         (WTF::AtomicStringImpl::remove):
4227         (WTF::AtomicStringImpl::lookUpSlowCase):
4228         * wtf/text/StringImpl.h:
4229         (WTF::StringImpl::StaticStringImpl::operator StringImpl&):
4230
4231 2017-01-02  Yusuke Suzuki  <utatane.tea@gmail.com>
4232
4233         Use StaticStringImpl instead of StaticASCIILiteral
4234         https://bugs.webkit.org/show_bug.cgi?id=166586
4235
4236         Reviewed by Darin Adler.
4237
4238         It is more handy way to define static StringImpl. It calculates the length
4239         and hash value by using the constexpr constructor and function. So we do
4240         not need to calculate these things in Perl script.
4241         And it allows us to use StaticStringImpl in the hand written C++ code.
4242         Previously, we need to calculate the length and hash value by hand if we
4243         would like to use StaticASCIILiteral in the hand written C++ code, and it
4244         meant that we cannot use it at all in the hand written C++ code.
4245
4246         * wtf/text/AtomicStringImpl.cpp:
4247         (WTF: