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