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