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