[WTF] Set canInitializeWithMemset = true if T is an integral type
[WebKit-https.git] / Source / WTF / ChangeLog
1 2018-03-06  Yusuke Suzuki  <utatane.tea@gmail.com>
2
3         [WTF] Set canInitializeWithMemset = true if T is an integral type
4         https://bugs.webkit.org/show_bug.cgi?id=183357
5
6         Reviewed by Darin Adler.
7
8         This patch set `canInitializeWithMemset = true` if T is an integral type.
9         This can offer a chance to use memset if we use UniqueArray<T> where T is
10         an integral type. We also rename VectorTypeOperations::initialize to
11         VectorTypeOperations::initializeIfNonPOD, VectorTypeOperations::forceInitialize
12         to VectorTypeOperations::initialize respectively.
13
14         * wtf/RefCountedArray.h:
15         (WTF::RefCountedArray::RefCountedArray):
16         * wtf/UniqueArray.h:
17         * wtf/Vector.h:
18         (WTF::VectorTypeOperations::initializeIfNonPOD):
19         (WTF::VectorTypeOperations::initialize):
20         (WTF::Vector::Vector):
21         (WTF::Malloc>::resize):
22         (WTF::Malloc>::grow):
23         (WTF::VectorTypeOperations::forceInitialize): Deleted.
24         * wtf/VectorTraits.h:
25
26 2018-03-07  Keith Miller  <keith_miller@apple.com>
27
28         Meta-program setupArguments and callOperation
29         https://bugs.webkit.org/show_bug.cgi?id=183263
30
31         Rubber-stamped by Filip Pizlo.
32
33         Add a new function traits struct that provides interesting
34         information about the provided function pointer. Right now it only
35         provides information for function pointers, in theory we could
36         also get it to work for other types.
37
38         * WTF.xcodeproj/project.pbxproj:
39         * wtf/Bitmap.h:
40         (WTF::WordType>::Bitmap):
41         * wtf/CMakeLists.txt:
42         * wtf/FunctionTraits.h: Added.
43         (WTF::slotsForCCallArgument):
44         (WTF::computeCCallSlots):
45         (WTF::FunctionTraits<Result):
46
47 2018-03-07  Tim Horton  <timothy_horton@apple.com>
48
49         Shuffle around some feature flags for minimal simulator mode
50         https://bugs.webkit.org/show_bug.cgi?id=183419
51         <rdar://problem/37694987>
52
53         Reviewed by Beth Dakin.
54
55         * wtf/FeatureDefines.h:
56         * wtf/Platform.h:
57
58 2018-03-06  Mark Lam  <mark.lam@apple.com>
59
60         Prepare LLInt code to support pointer profiling.
61         https://bugs.webkit.org/show_bug.cgi?id=183387
62         <rdar://problem/38199678>
63
64         Reviewed by JF Bastien.
65
66         * wtf/Platform.h:
67
68 2018-03-06  Commit Queue  <commit-queue@webkit.org>
69
70         Unreviewed, rolling out r229330.
71         https://bugs.webkit.org/show_bug.cgi?id=183379
72
73         Broke some Apple internal code (Requested by ap on #webkit).
74
75         Reverted changeset:
76
77         "Remove unused crash hook functionality"
78         https://bugs.webkit.org/show_bug.cgi?id=183369
79         https://trac.webkit.org/changeset/229330
80
81 2018-03-06  Michael Catanzaro  <mcatanzaro@igalia.com>
82
83         Remove unused crash hook functionality
84         https://bugs.webkit.org/show_bug.cgi?id=183369
85
86         Reviewed by Alexey Proskuryakov.
87
88         WTFSetCrashHook and WTFInstallReportBacktraceOnCrashHook are not used on any platforms and
89         can be removed.
90
91         * wtf/Assertions.cpp:
92         * wtf/Assertions.h:
93
94 2018-03-05  Yusuke Suzuki  <utatane.tea@gmail.com>
95
96         Fix std::make_unique / new[] using system malloc
97         https://bugs.webkit.org/show_bug.cgi?id=182975
98
99         Reviewed by JF Bastien.
100
101         If we use `make_unique<char[]>(num)` or `new char[num]`, allocation is
102         done by the system malloc instead of bmalloc. This patch fixes this issue
103         by following three changes.
104
105         1. Introduce UniqueArray<T>. It allocates memory from FastMalloc. While C++
106         array with `new` need to hold the size to call destructor correctly, our
107         UniqueArray only supports type T which does not have a non trivial destructor.
108         It reduces the allocation size since we do not need to track the size of the
109         array compared to standard `new T[]`. This is basically usable if we want to
110         have raw array which pointer won't be changed even if the container is moved.
111         In addition, we also extend UniqueArray<T> for types which have non trivial
112         destructors.
113
114         2. Use Vector<T> instead.
115
116         3. Annotate allocated types with MAKE_FAST_ALLOCATED. Since it introduces
117         new[] and delete[] operators, make_unique<T[]>(num) will allocate memory
118         from FastMalloc.
119
120         * WTF.xcodeproj/project.pbxproj:
121         * wtf/Assertions.cpp:
122         * wtf/CMakeLists.txt:
123         * wtf/FastMalloc.h:
124         (WTF::FastFree::operator() const):
125         (WTF::FastFree<T::operator() const):
126         * wtf/MallocPtr.h:
127         (WTF::MallocPtr::operator bool const):
128         * wtf/StackShot.h:
129         (WTF::StackShot::StackShot):
130         (WTF::StackShot::operator=):
131         * wtf/SystemFree.h:
132         (WTF::SystemFree<T::operator() const):
133         * wtf/UniqueArray.h: Copied from Source/WebKit/Platform/win/LoggingWin.cpp.
134         (WTF::makeUniqueArray):
135         * wtf/Vector.h:
136         (WTF::VectorTypeOperations::forceInitialize):
137
138 2018-03-05  Michael Saboff  <msaboff@apple.com>
139
140         Start using MAP_JIT for macOS
141         https://bugs.webkit.org/show_bug.cgi?id=183353
142
143         Reviewed by Filip Pizlo.
144
145         Unify setting this flag for both iOS and macOS.
146
147         * wtf/OSAllocatorPosix.cpp:
148         (WTF::OSAllocator::reserveAndCommit):
149
150 2018-03-05  Yusuke Suzuki  <utatane.tea@gmail.com>
151
152         Unreviewed, follow-up after r229209
153         https://bugs.webkit.org/show_bug.cgi?id=183312
154
155         Add RELEASE_ASSERT to ensure success.
156
157         * wtf/cocoa/CPUTimeCocoa.mm:
158         (WTF::CPUTime::forCurrentThread):
159         * wtf/unix/CPUTimeUnix.cpp:
160         (WTF::CPUTime::forCurrentThread):
161         * wtf/win/CPUTimeWin.cpp:
162         (WTF::CPUTime::forCurrentThread):
163
164 2018-03-05  Yusuke Suzuki  <utatane.tea@gmail.com>
165
166         Unreviewed, fix MediaTime test
167         https://bugs.webkit.org/show_bug.cgi?id=183319
168
169         __builtin_xxx_overflow writes overflowed data into ResultType value even if overflow happens.
170         This is different from the original CheckedArithmetic semantics.
171
172         * wtf/CheckedArithmetic.h:
173
174 2018-03-04  Yusuke Suzuki  <utatane.tea@gmail.com>
175
176         [WTF] Move currentCPUTime and sleep(Seconds) to CPUTime.h and Seconds.h respectively
177         https://bugs.webkit.org/show_bug.cgi?id=183312
178
179         Reviewed by Mark Lam.
180
181         1. currentCPUTime to CPUTime.h. It is now defined as CPUTime::forCurrentThread.
182         We also removes fallback implementation for currentCPUTime since (1) that implementation
183         is wrong and (2) no environments we support needs this.
184
185         2. sleep(Seconds) to Seconds.h. Since sleep(MonotonicTime) and sleep(WallTime) are defined
186         in MonotonicTime.h and WallTime.h, this code move is natural.
187
188         3. Remove wtf/CurrentTime.h since nothing is defined now. But we keep CurrentTime.cpp to
189         consolidate various time-source implementations in one place.
190
191         * WTF.xcodeproj/project.pbxproj:
192         * benchmarks/ConditionSpeedTest.cpp:
193         * benchmarks/LockFairnessTest.cpp:
194         * benchmarks/LockSpeedTest.cpp:
195         * wtf/CMakeLists.txt:
196         * wtf/CPUTime.h:
197         * wtf/CurrentTime.cpp:
198         (WTF::currentCPUTime): Deleted.
199         (WTF::sleep): Deleted.
200         * wtf/CurrentTime.h: Removed.
201         * wtf/DateMath.cpp:
202         * wtf/DebugUtilities.h:
203         * wtf/FastMalloc.cpp:
204         * wtf/MainThread.cpp:
205         * wtf/MonotonicTime.cpp:
206         * wtf/ParkingLot.cpp:
207         * wtf/Seconds.cpp:
208         (WTF::sleep):
209         * wtf/Seconds.h:
210         * wtf/StackShotProfiler.h:
211         * wtf/Stopwatch.h:
212         * wtf/ThreadingPthreads.cpp:
213         * wtf/ThreadingWin.cpp:
214         * wtf/cocoa/CPUTimeCocoa.mm:
215         (WTF::CPUTime::forCurrentThread):
216         * wtf/cocoa/MemoryPressureHandlerCocoa.mm:
217         * wtf/linux/MemoryPressureHandlerLinux.cpp:
218         * wtf/unix/CPUTimeUnix.cpp:
219         (WTF::CPUTime::forCurrentThread):
220         * wtf/win/CPUTimeWin.cpp:
221         (WTF::CPUTime::forCurrentThread):
222         * wtf/win/RunLoopWin.cpp:
223
224 2018-03-04  Yusuke Suzuki  <utatane.tea@gmail.com>
225
226         [WTF] Use __builtin_xxx_overflow for CheckedArithmetic
227         https://bugs.webkit.org/show_bug.cgi?id=183319
228
229         Reviewed by Darin Adler.
230
231         GCC and Clang has the builtins for arithmetic operations with overflow flags.
232         CheckedArithmetic operations can be done with this builtins. Since the compiler
233         can use overflow flags, potentially this is more efficient. CheckedArithmetic
234         already has TestWebKitAPI tests and we ensured the tests pass.
235
236         * wtf/CheckedArithmetic.h:
237
238 2018-03-02  Yusuke Suzuki  <utatane.tea@gmail.com>
239
240         [WTF] Remove RunLoop and RunLoop::Timer's interface using double as seconds
241         https://bugs.webkit.org/show_bug.cgi?id=183293
242
243         Reviewed by Alex Christensen.
244
245         This patch mainly drops startRepeating(double) and startOneShot(double) interfaces.
246         Use startRepeating(Seconds) and startOneShot(Seconds) instead.
247
248         * wtf/MemoryPressureHandler.cpp:
249         (WTF::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor):
250         * wtf/RunLoop.h:
251         (WTF::RunLoop::TimerBase::startRepeating):
252         (WTF::RunLoop::TimerBase::startOneShot):
253         (WTF::RunLoop::TimerBase::startInternal):
254         * wtf/RunLoopTimer.h:
255         * wtf/RunLoopTimerCF.cpp:
256         (WTF::RunLoopTimerBase::start):
257         * wtf/cf/RunLoopCF.cpp:
258         (WTF::RunLoop::runForDuration):
259         (WTF::RunLoop::TimerBase::start):
260         * wtf/generic/RunLoopGeneric.cpp:
261         (WTF::RunLoop::TimerBase::start):
262         * wtf/glib/RunLoopGLib.cpp:
263         (WTF::RunLoop::TimerBase::start):
264         * wtf/win/MemoryPressureHandlerWin.cpp:
265         (WTF::MemoryPressureHandler::install):
266         * wtf/win/RunLoopWin.cpp:
267         (WTF::RunLoop::TimerBase::start):
268
269 2018-03-02  Christopher Reid  <chris.reid@sony.com>
270
271         Build fix after r229174
272         https://bugs.webkit.org/show_bug.cgi?id=183301
273
274         Reviewed by Alex Christensen.
275
276         Updating MemoryPressureHandler::holdOff to use Seconds instead of unsigned.
277
278         * wtf/MemoryPressureHandler.cpp:
279
280 2018-03-02  Tim Horton  <timothy_horton@apple.com>
281
282         Make it possible to build for iOS without Celestial
283         https://bugs.webkit.org/show_bug.cgi?id=183295
284         <rdar://problem/38074468>
285
286         Reviewed by Dan Bernstein.
287
288         * wtf/Platform.h:
289
290 2018-03-02  Tim Horton  <timothy_horton@apple.com>
291
292         Make it possible to disable WKPDFView
293         https://bugs.webkit.org/show_bug.cgi?id=183281
294         <rdar://problem/38060815>
295
296         Reviewed by Dan Bates.
297
298         * wtf/FeatureDefines.h:
299
300 2018-03-02  Yusuke Suzuki  <utatane.tea@gmail.com>
301
302         [JSC] Annotate more classes with WTF_MAKE_FAST_ALLOCATED
303         https://bugs.webkit.org/show_bug.cgi?id=183279
304
305         Reviewed by JF Bastien.
306
307         * wtf/SimpleStats.h:
308         * wtf/ThreadGroup.h:
309
310 2018-03-01  Yusuke Suzuki  <utatane.tea@gmail.com>
311
312         Remove monotonicallyIncreasingTime
313         https://bugs.webkit.org/show_bug.cgi?id=182911
314
315         Reviewed by Michael Catanzaro.
316
317         This patch drops monotonicallyIncreasingTime and monotonicallyIncreasingTimeMS.
318         We have MonotonicTime API instead. This offers strongly typed MonotonicTime,
319         Seconds etc. This reduces the chance of bugs mixing doubles which represent milliseconds
320         and seconds.
321
322         Large part of this patch is mechanical one: replacing monotonicallyIncreasingTime with
323         MonotonicTime, using MonotonicTime and Seconds instead of raw doubles.
324
325         But this patch actually finds some bugs (but it is a bit difficult to show it as a test).
326         One is mixing media time (CACurrentMediaTime()) and MonotonicTime. Basically they are
327         super close because both uses mach_absolute_time(). But they would be slightly different.
328         So we should not mix them.
329
330         The second bug is GraphicsLayer::suspendAnimations(double). While CA ports (Apple, AppleWin,
331         iOS etc.) use this double as MonotonicTime, GTK and WPE use this double as Seconds (timeOffset).
332         This patch fixes it and now the signature becomes GraphicsLayer::suspendAnimations(MonotonicTime).
333
334         In this patch, we still uses bunch of double for Seconds. But fixing them at this patch increases
335         the size of this larger and larger. So some of them remains double. This should be fixed in
336         subsequent patches.
337
338         * benchmarks/ConditionSpeedTest.cpp:
339         * benchmarks/LockSpeedTest.cpp:
340         * wtf/CurrentTime.cpp:
341         (WTF::MonotonicTime::now):
342         (WTF::monotonicallyIncreasingTime): Deleted.
343         * wtf/CurrentTime.h:
344         (WTF::monotonicallyIncreasingTimeMS): Deleted.
345         * wtf/MemoryPressureHandler.h:
346         * wtf/MonotonicTime.cpp:
347         (WTF::MonotonicTime::now): Deleted.
348         * wtf/MonotonicTime.h:
349         * wtf/ParkingLot.cpp:
350         * wtf/Seconds.h:
351         (WTF::Seconds::nan):
352         * wtf/Stopwatch.h:
353         (WTF::Stopwatch::reset):
354         (WTF::Stopwatch::start):
355         (WTF::Stopwatch::stop):
356         (WTF::Stopwatch::elapsedTime):
357         (WTF::Stopwatch::elapsedTimeSince):
358         * wtf/cocoa/MemoryPressureHandlerCocoa.mm:
359         (WTF::MemoryPressureHandler::holdOff):
360         (WTF::MemoryPressureHandler::respondToMemoryPressure):
361         * wtf/linux/MemoryPressureHandlerLinux.cpp:
362         (WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
363         (WTF::MemoryPressureHandler::holdOff):
364         (WTF::MemoryPressureHandler::respondToMemoryPressure):
365         * wtf/win/MemoryPressureHandlerWin.cpp:
366         (WTF::MemoryPressureHandler::holdOff):
367
368 2018-03-02  Dan Bernstein  <mitz@apple.com>
369
370         Safari uses WebContent.Development when loading injected bundle embedded in its app bundle
371         https://bugs.webkit.org/show_bug.cgi?id=183275
372
373         Reviewed by Tim Horton.
374
375         * wtf/spi/cocoa/SecuritySPI.h: Declared SecTaskGetCodeSignStatus.
376
377 2018-02-27  Karlen Simonyan  <szkarlen@gmail.com>
378
379         [Win64] JSCOnly compile error using VS2017 and cmake
380         https://bugs.webkit.org/show_bug.cgi?id=183176
381
382         Reviewed by Alex Christensen.
383
384         * wtf/PlatformJSCOnly.cmake:
385
386 2018-02-26  Carlos Garcia Campos  <cgarcia@igalia.com>
387
388         [GStreamer] User current executable name instead of g_get_prgname() for gst_init
389         https://bugs.webkit.org/show_bug.cgi?id=183119
390
391         Reviewed by Philippe Normand.
392
393         Add getCurrentExecutableName() helper function to get the name of the current executable.
394
395         * wtf/glib/GLibUtilities.cpp:
396         (getCurrentExecutableName): Get the basename of getCurrentExecutablePath() falling back to g_get_prgname().
397         * wtf/glib/GLibUtilities.h:
398
399 2018-02-23  John Wilander  <wilander@apple.com>
400
401         Introduce ITP debug logging as an opt-in developer feature
402         https://bugs.webkit.org/show_bug.cgi?id=183065
403         <rdar://problem/37803761>
404
405         Reviewed by Brent Fulgham.
406
407         * wtf/Assertions.h:
408             Introduces RELEASE_LOG_INFO() and RELEASE_LOG_INFO_IF().
409
410 2018-02-23  Fujii Hironori  <Hironori.Fujii@sony.com>
411
412         warning: unused variable 'InitialBufferSize' in Assertions.cpp
413         https://bugs.webkit.org/show_bug.cgi?id=183076
414
415         Reviewed by Yusuke Suzuki.
416
417         * wtf/Assertions.cpp: Moved the definition of InitialBufferSize to inside #if.
418
419 2018-02-22  Yusuke Suzuki  <utatane.tea@gmail.com>
420
421         Remove currentTime() / currentTimeMS()
422         https://bugs.webkit.org/show_bug.cgi?id=183052
423
424         Reviewed by Mark Lam.
425
426         This patch removes WTF::currentTime() and WTF::currentTimeMS().
427         We have fancy WallTime APIs. It has strong types like WallTime and Seconds,
428         and this reduces the chance of bugs mixing doubles which represent milliseconds
429         and seconds.
430
431         * wtf/Condition.h:
432         * wtf/CurrentTime.cpp:
433         (WTF::currentTime):
434         (WTF::WallTime::now):
435         * wtf/CurrentTime.h:
436         (WTF::currentTimeMS): Deleted.
437         * wtf/DateMath.h:
438         (WTF::jsCurrentTime):
439         * wtf/ParkingLot.cpp:
440         (WTF::ParkingLot::parkConditionallyImpl):
441         * wtf/ThreadingPrimitives.h:
442         * wtf/ThreadingPthreads.cpp:
443         (WTF::ThreadCondition::timedWait):
444         * wtf/ThreadingWin.cpp:
445         (WTF::ThreadCondition::timedWait):
446         (WTF::absoluteTimeToWaitTimeoutInterval):
447         * wtf/WallTime.cpp:
448         (WTF::WallTime::now): Deleted.
449         * wtf/WallTime.h:
450
451 2018-02-22  Yusuke Suzuki  <utatane.tea@gmail.com>
452
453         Remove sleep(double) and sleepMS(double) interfaces
454         https://bugs.webkit.org/show_bug.cgi?id=183038
455
456         Reviewed by Mark Lam.
457
458         This patch removes sleep(double) and sleepMS(double) interfaces.
459         We can just use sleep(Seconds) instead.
460
461         * benchmarks/LockFairnessTest.cpp:
462         * benchmarks/LockSpeedTest.cpp:
463         * wtf/CurrentTime.cpp:
464         (WTF::sleep):
465         * wtf/CurrentTime.h:
466         (WTF::sleepMS): Deleted.
467         * wtf/DebugUtilities.h:
468         * wtf/Seconds.cpp:
469         (WTF::sleep): Deleted.
470         * wtf/Seconds.h:
471         * wtf/StackShotProfiler.h:
472
473 2018-02-21  Don Olmstead  <don.olmstead@sony.com>
474
475         [CMake][Win] Use cmakeconfig.h rather than config.h and Platform.h
476         https://bugs.webkit.org/show_bug.cgi?id=182883
477
478         Reviewed by Per Arne Vollan.
479
480         * wtf/Platform.h:
481
482 2018-02-14  Brian Burg  <bburg@apple.com>
483
484         Web Automation: combine session commands to resize and move top-level browsing contexts
485         https://bugs.webkit.org/show_bug.cgi?id=182749
486         <rdar://problem/37515170>
487
488         Reviewed by Andy Estes.
489
490         * wtf/JSONValues.h: add a getDouble() implementation that returns a std::optional<T>
491         rather than using an out-parameter. I'd like to move more code to this style.
492
493 2018-02-20  Tim Horton  <timothy_horton@apple.com>
494
495         Introduce HAVE(IOSURFACE_ACCELERATOR)
496         https://bugs.webkit.org/show_bug.cgi?id=182955
497         <rdar://problem/37699510>
498
499         Reviewed by Sam Weinig.
500
501         * wtf/Platform.h:
502
503 2018-02-20  Chris Dumez  <cdumez@apple.com>
504
505         Provisional load may get committed before receiving the decidePolicyForNavigationResponse response
506         https://bugs.webkit.org/show_bug.cgi?id=182720
507         <rdar://problem/37515204>
508
509         Reviewed by Alex Christensen.
510
511         Add convenience CompletionHandlerCallingScope class which calls its CompletionHandler
512         when destroyed, and provides a release() methods to manually call the completionHandler.
513
514         * wtf/CompletionHandler.h:
515         (WTF::CompletionHandlerCallingScope::CompletionHandlerCallingScope):
516         (WTF::CompletionHandlerCallingScope::~CompletionHandlerCallingScope):
517         (WTF::CompletionHandlerCallingScope::CompletionHandler<void):
518
519 2018-02-20  Tim Horton  <timothy_horton@apple.com>
520
521         Always inline soft linking functions to work around a clang bug
522         https://bugs.webkit.org/show_bug.cgi?id=182985
523         <rdar://problem/37587017>
524
525         Reviewed by Dan Bernstein.
526
527         * wtf/cocoa/SoftLinking.h:
528         In some cases, clang will emit a weak extern symbol for a re-declared
529         symbol that has availability attributes on it. To avoid this, always
530         inline to avoid emitting a second symbol.
531
532 2018-02-16  Dean Jackson  <dino@apple.com>
533
534         Use OPENGL macros to be more clear about which OpenGL/ES WebGL uses on Cocoa
535         https://bugs.webkit.org/show_bug.cgi?id=182894
536
537         Reviewed by Tim Horton.
538
539         If we're on a Cocoa platform, define USE_OPENGL/USE_OPENGL_ES
540         depending on what we're actually going to use. In this case,
541         they are exclusive, but it doesn't appear that other platforms
542         use this approach. Ultimately the idea is to be more concerned
543         with the type of OpenGL we're using, rather than the platform.
544
545         * wtf/Platform.h: Define USE_OPENGL(_ES) for PLATFORM(COCOA).
546
547 2018-02-16  Filip Pizlo  <fpizlo@apple.com>
548
549         Unreviewed, roll out r228306 (custom memcpy/memset) because the bots say that it was not a
550         progression.
551
552         * WTF.xcodeproj/project.pbxproj:
553         * wtf/BitVector.cpp:
554         (WTF::BitVector::setSlow):
555         (WTF::BitVector::clearAll):
556         (WTF::BitVector::resizeOutOfLine):
557         * wtf/BitVector.h:
558         (WTF::BitVector::OutOfLineBits::numWords const):
559         (WTF::BitVector::wordCount): Deleted.
560         * wtf/CMakeLists.txt:
561         * wtf/ConcurrentBuffer.h:
562         (WTF::ConcurrentBuffer::growExact):
563         * wtf/FastBitVector.h:
564         (WTF::FastBitVectorWordOwner::operator=):
565         (WTF::FastBitVectorWordOwner::clearAll):
566         (WTF::FastBitVectorWordOwner::set):
567         * wtf/FastCopy.h: Removed.
568         * wtf/FastMalloc.cpp:
569         (WTF::fastZeroedMalloc):
570         (WTF::fastStrDup):
571         (WTF::tryFastZeroedMalloc):
572         * wtf/FastZeroFill.h: Removed.
573         * wtf/OSAllocator.h:
574         (WTF::OSAllocator::reallocateCommitted):
575         * wtf/StringPrintStream.cpp:
576         (WTF::StringPrintStream::increaseSize):
577         * wtf/Vector.h:
578         * wtf/persistence/PersistentDecoder.cpp:
579         (WTF::Persistence::Decoder::decodeFixedLengthData):
580         * wtf/persistence/PersistentEncoder.cpp:
581         (WTF::Persistence::Encoder::encodeFixedLengthData):
582         * wtf/text/CString.cpp:
583         (WTF::CString::init):
584         (WTF::CString::copyBufferIfNeeded):
585         * wtf/text/LineBreakIteratorPoolICU.h:
586         (WTF::LineBreakIteratorPool::makeLocaleWithBreakKeyword):
587         * wtf/text/StringBuilder.cpp:
588         (WTF::StringBuilder::allocateBuffer):
589         (WTF::StringBuilder::append):
590         * wtf/text/StringConcatenate.h:
591         * wtf/text/StringImpl.h:
592         (WTF::StringImpl::copyCharacters):
593         * wtf/text/icu/UTextProvider.cpp:
594         (WTF::uTextCloneImpl):
595         * wtf/text/icu/UTextProviderLatin1.cpp:
596         (WTF::uTextLatin1Clone):
597         (WTF::openLatin1UTextProvider):
598         * wtf/threads/Signals.cpp:
599
600 2018-02-16  Keith Miller  <keith_miller@apple.com>
601
602         Remove unused line from Platform.h
603         https://bugs.webkit.org/show_bug.cgi?id=182871
604
605         Reviewed by Mark Lam.
606
607         * wtf/Platform.h:
608
609 2018-02-14  Michael Saboff  <msaboff@apple.com>
610
611         REGRESSION(225695) : com.apple.WebKit.WebContent at com.apple.JavaScriptCore: JSC::RegExp::match + 630 :: stack overflow
612         https://bugs.webkit.org/show_bug.cgi?id=182705
613
614         Reviewed by Mark Lam.
615
616         Moved the setting of ENABLE_YARR_JIT_ALL_PARENS_EXPRESSIONS to Platform.h since more than just the YARR
617         code needs to know if that feature is enabled.
618
619         * wtf/Platform.h:
620
621 2018-02-12  Mark Lam  <mark.lam@apple.com>
622
623         Add more support for pointer preparations.
624         https://bugs.webkit.org/show_bug.cgi?id=182703
625         <rdar://problem/37469451>
626
627         Reviewed by Saam Barati.
628
629         * wtf/PointerPreparations.h:
630
631 2018-02-09  Ross Kirsling  <ross.kirsling@sony.com>
632
633         Use REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR on any non-Windows port.
634         https://bugs.webkit.org/show_bug.cgi?id=182623
635
636         Reviewed by Alex Christensen.
637
638         * wtf/Platform.h:
639         Simplify #if.
640
641 2018-02-08  Filip Pizlo  <fpizlo@apple.com>
642
643         Experiment with alternative implementation of memcpy/memset
644         https://bugs.webkit.org/show_bug.cgi?id=182563
645
646         Reviewed by Michael Saboff and Mark Lam.
647         
648         Adds a faster x86_64-specific implementation of memcpy and memset. These versions go by
649         different names than memcpy/memset and have a different API:
650         
651         WTF::fastCopy<T>(T* dst, T* src, size_t N): copies N values of type T from src to dst.
652         WTF::fastZeroFill(T* dst, size_T N): writes N * sizeof(T) zeroes to dst.
653         
654         There are also *Bytes variants that take void* for dst and src and size_t numBytes. Those are
655         most appropriate in places where the code is already computing bytes.
656         
657         These will just call memcpy/memset on platforms where the optimized versions are not supported.
658         
659         These new functions are not known to the compiler to be memcpy/memset. This has the effect that
660         the compiler will not try to replace them with anything else. This could be good or bad:
661         
662         - It's *good* if the size is *not known* at compile time. In that case, by my benchmarks, these
663           versions are faster than either the memcpy/memset call or whatever else the compiler could
664           emit. This is because of a combination of inlining and the algorithm itself (see below).
665         
666         - It's *bad* if the size is *known* at compile time. In that case, the compiler could
667           potentially emit a fully unrolled memcpy/memset. That might not happen if the size is large
668           (even if it's known), but in this patch I avoid replacing any memcpy/memset calls when the
669           size is a constant. In particular, this totally avoids the call overhead -- if the size is
670           small, then the compiler will emit a nice inlined copy or set. If the size is large, then the
671           most optimal thing to do is emit the shortest piece of code possible, and that's a call to
672           memcpy/memset.
673         
674         It's unfortunate that you have to choose between them on your own. One way to avoid that might
675         have been to override the memcpy/memset symbols, so that the compiler can still do its
676         reasoning. But that's not quite right, since then we would lose inlining in the unknonw-size
677         case. Also, it's possible that for some unknown-size cases, the compiler could choose to emit
678         something on its own because it might think that some property of aliasing or alignment could
679         help it. I think it's a bit better to use our own copy/set implementations even in those cases.
680         Another way that I tried avoiding this is to detect inside fastCopy/fastZeroFill if the size is
681         constant. But there is no good way to do that in C++. There is a builtin for doing that inside a
682         macro, but that feels janky, so I didn't want to do it in this patch.
683         
684         The reason why these new fastCopy/fastZeroFill functions are faster is that:
685         
686         - They can be inlined. There is no function call. Only a few registers get clobbered. So, the
687           impact on the quality of the code surrounding the memcpy/memset is smaller.
688         
689         - They use type information to select the implementation. For sizes that are multiples of 2, 4,
690           or 8, the resulting code performs dramatically better on small arrays than memcpy because it
691           uses fewer cycles. The difference is greatest for 2 and 4 byte types, since memcpy usually
692           handles small arrays by tiering from a 8-byte word copy loop to a byte copy loop. So, for 2
693           or 4 byte arrays, we use an algorithm that tiers from 8-byte word down to a 2-byte or 4-byte
694           (depending on type) copy loop. So, for example, when copying a 16-bit string that has 1, 2, or
695           3 characters, this means doing 1, 2, or 3 word copies rather than 2, 4, or 6 byte copies. For
696           8-byte types, the resulting savings are mainly that there is no check to see if a tier-down to
697           the byte-copy loop is needed -- so really that means reducing code size. 1-byte types don't
698           get this inherent advantage over memcpy/memset, but they still benefit from all of the other
699           advantages of these functions. Of course, this advantage isn't inherent to our approach. The
700           compiler could also notice that the arguments to memcpy/memset have some alignment properties.
701           It could do it even more generally than we do - for example a copy over bytes where the size
702           is a multiple of 4 can use the 4-byte word algorithm. But based on my tests, the compiler does
703           not do this (even though it does other things, like turn a memset call with a zero value
704           argument into a bzero call).
705         
706         - They use a very nicely written word copy/set loop for small arrays. I spent a lot of time
707           getting the assembly just right. When we use memcpy/memset, sometimes we would optimize the
708           call by having a fast path word copy loop for small sizes. That's not necessary with this
709           implementation, since the assembly copy loop gets inlined.
710         
711         - They use `rep movs` or `rep stos` for copies of 200 bytes or more. This decision benchmarks
712           poorly on every synthetic memcpy/memset benchmark I have built, and so unsurprisingly, it's
713           not what system memcpy/memset does. Most system memcpy/memset implementations end up doing
714           some SSE for medium-sized copies,. However, I previously found that this decision is bad for
715           one of the memset calls in GC (see clearArray() and friends in ArrayConventions.h|cpp) - I was
716           able to make the overhead of that call virtually disappear by doing `rep stos` more
717           aggressively. The theory behind this change is that it's not just the GC that prefers smaller
718           `rep` threshold and no SSE. I am betting that `rep`ing more is better when the heap gets
719           chaotic and the data being copied is used in interesting ways -- hence, synthetic
720           memcpy/memset benchmarks think it's bad (they don't do enough chaotic memory accesses) while
721           it's good for real-world uses. Also, when I previously worked on JVMs, I had found that the
722           best memcpy/memset heuristics when dealing with GC'd objects in a crazy heap were different
723           than any memcpy/memset in any system library.
724         
725         This appears to be a 0.9% speed-up on PLT. I'm not sure if it's more because of the inlining or
726         the `rep`. I think it's both. I'll leave figuring out the exact tuning for future patches.
727
728         * wtf/BitVector.cpp:
729         (WTF::BitVector::setSlow):
730         (WTF::BitVector::clearAll):
731         (WTF::BitVector::resizeOutOfLine):
732         * wtf/BitVector.h:
733         (WTF::BitVector::wordCount):
734         (WTF::BitVector::OutOfLineBits::numWords const):
735         * wtf/ConcurrentBuffer.h:
736         (WTF::ConcurrentBuffer::growExact):
737         * wtf/FastBitVector.h:
738         (WTF::FastBitVectorWordOwner::operator=):
739         (WTF::FastBitVectorWordOwner::clearAll):
740         (WTF::FastBitVectorWordOwner::set):
741         * wtf/FastCopy.h: Added.
742         (WTF::fastCopy):
743         (WTF::fastCopyBytes):
744         * wtf/FastMalloc.cpp:
745         (WTF::fastZeroedMalloc):
746         (WTF::fastStrDup):
747         (WTF::tryFastZeroedMalloc):
748         * wtf/FastZeroFill.h: Added.
749         (WTF::fastZeroFill):
750         (WTF::fastZeroFillBytes):
751         * wtf/MD5.cpp:
752         * wtf/OSAllocator.h:
753         (WTF::OSAllocator::reallocateCommitted):
754         * wtf/StringPrintStream.cpp:
755         (WTF::StringPrintStream::increaseSize):
756         * wtf/Vector.h:
757         * wtf/persistence/PersistentDecoder.cpp:
758         (WTF::Persistence::Decoder::decodeFixedLengthData):
759         * wtf/persistence/PersistentEncoder.cpp:
760         (WTF::Persistence::Encoder::encodeFixedLengthData):
761         * wtf/text/CString.cpp:
762         (WTF::CString::init):
763         (WTF::CString::copyBufferIfNeeded):
764         * wtf/text/LineBreakIteratorPoolICU.h:
765         (WTF::LineBreakIteratorPool::makeLocaleWithBreakKeyword):
766         * wtf/text/StringBuilder.cpp:
767         (WTF::StringBuilder::allocateBuffer):
768         (WTF::StringBuilder::append):
769         * wtf/text/StringConcatenate.h:
770         * wtf/text/StringImpl.h:
771         (WTF::StringImpl::copyCharacters):
772         * wtf/text/icu/UTextProvider.cpp:
773         (WTF::uTextCloneImpl):
774         * wtf/text/icu/UTextProviderLatin1.cpp:
775         (WTF::uTextLatin1Clone):
776         (WTF::openLatin1UTextProvider):
777         * wtf/threads/Signals.cpp:
778
779 2018-02-06  Darin Adler  <darin@apple.com>
780
781         Event improvements
782         https://bugs.webkit.org/show_bug.cgi?id=179591
783
784         Reviewed by Chris Dumez.
785
786         * wtf/text/OrdinalNumber.h: Added som missing const.
787         * wtf/text/TextPosition.h: Ditto.
788
789 2018-02-06  Fujii Hironori  <Hironori.Fujii@sony.com>
790
791         [GTK] fast/events/message-channel-gc-4.html is flaky
792         https://bugs.webkit.org/show_bug.cgi?id=182104
793
794         Reviewed by Carlos Garcia Campos.
795
796         Revert r228001 because RunLoop::current isn't called in GC thread
797         anymore since r228152.
798
799         * wtf/RunLoop.cpp:
800         (WTF::RunLoop::current): Removed a template argument
801         CanBeGCThread::True of ThreadSpecific.
802
803 2018-02-05  Konstantin Tokarev  <annulen@yandex.ru>
804
805         [cmake] Fix build with ICU configured without collation support
806         https://bugs.webkit.org/show_bug.cgi?id=182498
807
808         Reviewed by Alex Christensen.
809
810         WebKit has CollatorDefault.cpp providing necessary stubs when
811         UCONFIG_NO_COLLATION is defined, however it is not included in cmake
812         file list.
813
814         * wtf/CMakeLists.txt:
815
816 2018-02-05  Alicia Boya GarcĂ­a  <aboya@igalia.com>
817
818         Fix bug in MediaTime comparison for negative values with different scale.
819         https://bugs.webkit.org/show_bug.cgi?id=182433
820
821         Reviewed by Xabier Rodriguez-Calvar.
822
823         * wtf/MediaTime.cpp:
824         (WTF::MediaTime::compare const):
825
826 2018-02-02  Mark Lam  <mark.lam@apple.com>
827
828         More ARM64_32 fixes.
829         https://bugs.webkit.org/show_bug.cgi?id=182441
830         <rdar://problem/37162310>
831
832         Reviewed by Dan Bernstein.
833
834         My previous speculative ARM64_32 build fix in copyLCharsFromUCharSource() was wrong.
835         I've now fixed it to choose the default implementation case instead of the ARM64
836         case if the target is ARM64_32.
837
838         * wtf/text/ASCIIFastPath.h:
839         (WTF::copyLCharsFromUCharSource):
840
841 2018-02-02  Konstantin Tokarev  <annulen@yandex.ru>
842
843         Unreviewed build fix for JSCOnly on macOS after r227845.
844         https://bugs.webkit.org/show_bug.cgi?id=182274
845
846         Reverted part of r227845 that moved CommonCryptoSPI.h
847         handling into PlatformMac, because it is needed for all
848         ports which can be built on macOS.
849
850         * wtf/CMakeLists.txt:
851         * wtf/PlatformMac.cmake:
852
853 2018-02-02  Fujii Hironori  <Hironori.Fujii@sony.com>
854
855         [GTK] fast/events/message-channel-gc-4.html is flaky
856         https://bugs.webkit.org/show_bug.cgi?id=182104
857
858         Reviewed by Carlos Garcia Campos.
859
860         RELEASE_ASSERT of ThreadSpecific::set fails because
861         RunLoop::current is called even in GC thread since r227275.
862
863         * wtf/RunLoop.cpp:
864         (WTF::RunLoop::current):
865         Let the second template argument of ThreadSpecific CanBeGCThread::True.
866
867 2018-02-01  Michael Catanzaro  <mcatanzaro@igalia.com>
868
869         [WPE][GTK] Make RunLoop::TimerBase robust to its own deletion inside its source callback
870         https://bugs.webkit.org/show_bug.cgi?id=182271
871
872         Reviewed by Carlos Garcia Campos.
873
874         RunLoopTimer::fired executes the user's callback, which could delete the RunLoopTimer
875         itself. But the source callback is not prepared to handle this case. We can detect it
876         easily, because TimerBase's destructor will call g_source_destroy(), which confusingly
877         removes the GSource from its GMainContext without actually destroying the GSource. Then we
878         can check if the GSource is still attached using g_source_is_destroyed().
879
880         * wtf/glib/RunLoopGLib.cpp:
881         (WTF::RunLoop::TimerBase::TimerBase):
882
883 2018-01-31  Saam Barati  <sbarati@apple.com>
884
885         Replace tryLargeMemalignVirtual with tryLargeZeroedMemalignVirtual and use it to allocate large zeroed memory in Wasm
886         https://bugs.webkit.org/show_bug.cgi?id=182064
887         <rdar://problem/36840132>
888
889         Reviewed by Geoffrey Garen.
890
891         * wtf/Gigacage.cpp:
892         (Gigacage::tryAllocateZeroedVirtualPages):
893         (Gigacage::freeVirtualPages):
894         (Gigacage::tryAllocateVirtualPages): Deleted.
895         * wtf/Gigacage.h:
896         * wtf/OSAllocator.h:
897
898 2018-01-31  Mark Lam  <mark.lam@apple.com>
899
900         Fix some ARM64_32 build failures.
901         https://bugs.webkit.org/show_bug.cgi?id=182356
902         <rdar://problem/37057690>
903
904         Reviewed by Michael Saboff.
905
906         * wtf/MathExtras.h:
907         (WTF::dynamicPoison):
908         * wtf/text/ASCIIFastPath.h:
909         (WTF::copyLCharsFromUCharSource):
910
911 2018-01-30  Mark Lam  <mark.lam@apple.com>
912
913         Apply poisoning to TypedArray vector pointers.
914         https://bugs.webkit.org/show_bug.cgi?id=182155
915         <rdar://problem/36286266>
916
917         Reviewed by JF Bastien.
918
919         1. Added the ability to poison a CagedPtr.
920
921         2. Prevent CagedPtr from being implicitly instantiated, and add operator= methods
922            instead.  This is because implicitly instantiated CagedPtrs with a poisoned
923            trait may silently use a wrong poison value.
924
925         * wtf/CagedPtr.h:
926         (WTF::CagedPtr::CagedPtr):
927         (WTF::CagedPtr::get const):
928         (WTF::CagedPtr::operator=):
929
930 2018-01-30  Fujii Hironori  <Hironori.Fujii@sony.com>
931
932         [Win] Warning fix.
933         https://bugs.webkit.org/show_bug.cgi?id=177007
934
935         Reviewed by Yusuke Suzuki.
936
937         A 32 bit integer should not be casted to a pointer directly in 64
938         bit Windows. It should be casted to a uintptr_t beforehand.
939
940         Rules for Using Pointers (Windows)
941         https://msdn.microsoft.com/library/windows/desktop/aa384242
942
943         * wtf/ThreadingWin.cpp (InvalidThread): Casted 0xbbadbeef to uintptr_t.
944
945 2018-01-30  Don Olmstead  <don.olmstead@sony.com>
946
947         Unreviewed build fix for JSCOnly after r227845.
948         https://bugs.webkit.org/show_bug.cgi?id=182274
949
950         * wtf/PlatformJSCOnly.cmake:
951
952 2018-01-30  Don Olmstead  <don.olmstead@sony.com>
953
954         [CMake] Make WTF headers copies
955         https://bugs.webkit.org/show_bug.cgi?id=182274
956
957         Reviewed by Alex Christensen.
958
959         * wtf/CMakeLists.txt:
960         * wtf/PlatformGTK.cmake:
961         * wtf/PlatformJSCOnly.cmake:
962         * wtf/PlatformMac.cmake:
963         * wtf/PlatformWPE.cmake:
964         * wtf/PlatformWin.cmake:
965
966 2018-01-30  Mark Lam  <mark.lam@apple.com>
967
968         Move ENABLE_POISON to Platform.h.
969         https://bugs.webkit.org/show_bug.cgi?id=182298
970         <rdar://problem/37032686>
971
972         Reviewed by Michael Saboff and JF Bastien.
973
974         ENABLE_POISON belongs in Platform.h to ensure that all places that depend on
975         ENABLE(POISON) will see it properly defined.
976
977         * wtf/Platform.h:
978         * wtf/Poisoned.h:
979
980 2018-01-26  Mark Lam  <mark.lam@apple.com>
981
982         Add infrastructure for pointer preparation.
983         https://bugs.webkit.org/show_bug.cgi?id=182191
984         <rdar://problem/36889194>
985
986         Reviewed by JF Bastien.
987
988         * WTF.xcodeproj/project.pbxproj:
989         * wtf/CMakeLists.txt:
990         * wtf/PointerPreparations.h: Added.
991
992 2018-01-26  Chris Nardi  <cnardi@chromium.org>
993
994         Addressing post-review comments after r226614
995         https://bugs.webkit.org/show_bug.cgi?id=182151
996
997         Reviewed by Myles C. Maxfield.
998
999         * wtf/text/StringImpl.h:
1000         (WTF::isSpaceOrNewline):
1001         * wtf/text/TextBreakIterator.cpp:
1002         (WTF::numCodeUnitsInGraphemeClusters):
1003         * wtf/text/TextBreakIterator.h:
1004
1005 2018-01-26  Filip Pizlo  <fpizlo@apple.com>
1006
1007         Fix style - need to use C comments.
1008
1009         * wtf/Platform.h:
1010
1011 2018-01-26  Filip Pizlo  <fpizlo@apple.com>
1012
1013         Disable TLS-based TLCs
1014         https://bugs.webkit.org/show_bug.cgi?id=182175
1015
1016         Reviewed by Saam Barati.
1017
1018         Add a flag for TLS-based TLCs and set it to 0. We can re-enable this feature when we need to use TLCs for
1019         actual thread-local allocation and when we fix the fact that WebCore context switches JSC VMs without telling
1020         us.
1021
1022         * wtf/Platform.h:
1023
1024 2018-01-25  Filip Pizlo  <fpizlo@apple.com>
1025
1026         Unreviewed, fix windows build.
1027
1028         * wtf/MathExtras.h:
1029         (WTF::opaque):
1030
1031 2018-01-24  Filip Pizlo  <fpizlo@apple.com>
1032
1033         DirectArguments should protect itself using dynamic poisoning and precise index masking
1034         https://bugs.webkit.org/show_bug.cgi?id=182086
1035
1036         Reviewed by Saam Barati.
1037         
1038         Add helpers for:
1039         
1040         Dynamic poisoning: this means arranging to have the pointer you will dereference become an
1041         invalid pointer if the type check you were relying on would have failed.
1042         
1043         Precise index masking: a variant of index masking that does not depend on distancing. I figured
1044         I'd just try this first for DirectArguments, since I didn't think that arguments[i] was ever
1045         hot enough to warrant anything better. Turns out that in all of the benchmarks that care about
1046         arguments performance, we optimize things to the point that the index masking isn't on a hot
1047         path anymore. Turns out, it's neutral!
1048
1049         * wtf/MathExtras.h:
1050         (WTF::preciseIndexMask):
1051         (WTF::dynamicPoison):
1052
1053 2018-01-25  Jer Noble  <jer.noble@apple.com>
1054
1055         Unreviewed build fix after r227631; make USE_VIDEOTOOLBOX universally enabled on iOS.
1056
1057         * wtf/Platform.h:
1058
1059 2018-01-25  Jer Noble  <jer.noble@apple.com>
1060
1061         Move ImageDecoderAVFObjC from using AVSampleBufferGenerator to AVAssetReaderOutput for parsing
1062         https://bugs.webkit.org/show_bug.cgi?id=182091
1063
1064         Reviewed by Eric Carlson.
1065
1066         * wtf/Platform.h:
1067
1068 2018-01-25  Mark Lam  <mark.lam@apple.com>
1069
1070         Rename the Poisoned::isPoisoned constant to Poisoned::isPoisonedType.
1071         https://bugs.webkit.org/show_bug.cgi?id=182143
1072         <rdar://problem/36880970>
1073
1074         Reviewed by JF Bastien.
1075
1076         This is so that it doesn't conflict with the isPoisoned() debugging methods that
1077         are normally not built.  Also renamed PoisonedUniquePtr::isPoisonedUniquePtr to
1078         PoisonedUniquePtr::isPoisonedUniquePtrType to be consistent.
1079
1080         * wtf/Poisoned.h:
1081         * wtf/PoisonedUniquePtr.h:
1082
1083 2018-01-25  Filip Pizlo  <fpizlo@apple.com>
1084
1085         JSC GC should support TLCs (thread local caches)
1086         https://bugs.webkit.org/show_bug.cgi?id=181559
1087
1088         Reviewed by Mark Lam and Saam Barati.
1089
1090         * wtf/Bitmap.h: Just fixing a compile error.
1091
1092 2018-01-25  Commit Queue  <commit-queue@webkit.org>
1093
1094         Unreviewed, rolling out r227592.
1095         https://bugs.webkit.org/show_bug.cgi?id=182110
1096
1097         it made ARM64 (Linux and iOS) crash (Requested by pizlo-mbp on
1098         #webkit).
1099
1100         Reverted changeset:
1101
1102         "JSC GC should support TLCs (thread local caches)"
1103         https://bugs.webkit.org/show_bug.cgi?id=181559
1104         https://trac.webkit.org/changeset/227592
1105
1106 2018-01-20  Filip Pizlo  <fpizlo@apple.com>
1107
1108         JSC GC should support TLCs (thread local caches)
1109         https://bugs.webkit.org/show_bug.cgi?id=181559
1110
1111         Reviewed by Mark Lam and Saam Barati.
1112
1113         * wtf/Bitmap.h: Just fixing a compile error.
1114
1115 2018-01-23  Mark Lam  <mark.lam@apple.com>
1116
1117         Update Poisoned pointers to take a Poison class instead of a uintptr_t&.
1118         https://bugs.webkit.org/show_bug.cgi?id=182017
1119         <rdar://problem/36795513>
1120
1121         Reviewed by Filip Pizlo and JF Bastien.
1122
1123         This paves the way for custom poison values which we'll need for use in
1124         TypedArrays later.
1125
1126         * wtf/Bag.h:
1127         * wtf/DumbPtrTraits.h:
1128         (WTF::DumbPtrTraits::poison): Deleted.
1129         * wtf/DumbValueTraits.h:
1130         (WTF::DumbValueTraits::poison): Deleted.
1131         * wtf/Poisoned.h:
1132         (WTF::Poison::key):
1133         (WTF::Poisoned::swap):
1134         (WTF::Poisoned::poison const):
1135         (WTF::Poisoned::unpoison const):
1136         (WTF::Poisoned::poison):
1137         (WTF::Poisoned::unpoison):
1138         (WTF::PoisonedPtrTraits::swap):
1139         (WTF::PoisonedValueTraits::swap):
1140         (WTF::PoisonedPtrTraits::poison): Deleted.
1141         (WTF::PoisonedValueTraits::poison): Deleted.
1142         * wtf/PoisonedUniquePtr.h:
1143         * wtf/Ref.h:
1144         * wtf/RefCountedArray.h:
1145         * wtf/RefPtr.h:
1146         * wtf/WTFAssertions.cpp:
1147
1148 2018-01-23  Alex Christensen  <achristensen@webkit.org>
1149
1150         Remove pre-Sierra-OS-specific code in WTF and JavaScriptCore
1151         https://bugs.webkit.org/show_bug.cgi?id=182028
1152
1153         Reviewed by Keith Miller.
1154
1155         * wtf/Platform.h:
1156         * wtf/mac/AppKitCompatibilityDeclarations.h:
1157         * wtf/mac/DeprecatedSymbolsUsedBySafari.mm:
1158         (WTF::MainThreadFunctionTracker::singleton): Deleted.
1159         (WTF::MainThreadFunctionTracker::callOnMainThread): Deleted.
1160         (WTF::MainThreadFunctionTracker::cancelCallOnMainThread): Deleted.
1161         (WTF::MainThreadFunctionTracker::addFunction): Deleted.
1162         (WTF::MainThreadFunctionTracker::removeIdentifier): Deleted.
1163         (WTF::MainThreadFunctionTracker::removeFunctions): Deleted.
1164         (WTF::callOnMainThread): Deleted.
1165         (WTF::cancelCallOnMainThread): Deleted.
1166         * wtf/spi/cocoa/SecuritySPI.h:
1167         * wtf/spi/darwin/dyldSPI.h:
1168         * wtf/text/icu/TextBreakIteratorICU.h:
1169         (WTF::TextBreakIteratorICU::TextBreakIteratorICU):
1170         (WTF::caretRules): Deleted.
1171
1172 2018-01-23  Filip Pizlo  <fpizlo@apple.com>
1173
1174         JSC should use a speculation fence on VM entry/exit
1175         https://bugs.webkit.org/show_bug.cgi?id=181991
1176
1177         Reviewed by JF Bastien and Mark Lam.
1178         
1179         Implement speculationFence as lfence on x86 and isb on ARM64. I'm not sure if isb is
1180         appropriate for all ARM64's.
1181
1182         * wtf/Atomics.h:
1183         (WTF::speculationFence):
1184         (WTF::x86_lfence):
1185
1186 2018-01-22  Alex Christensen  <achristensen@webkit.org>
1187
1188         Begin removing QTKit code
1189         https://bugs.webkit.org/show_bug.cgi?id=181951
1190
1191         Reviewed by Jer Noble.
1192
1193         * wtf/Platform.h:
1194
1195 2018-01-21  Wenson Hsieh  <wenson_hsieh@apple.com>
1196
1197         Add a new feature flag for EXTRA_ZOOM_MODE and reintroduce AdditionalFeatureDefines.h
1198         https://bugs.webkit.org/show_bug.cgi?id=181918
1199
1200         Reviewed by Tim Horton.
1201
1202         Include AdditionalFeatureDefines.h, if possible. This allows WebKitAdditions to override
1203         the value of certain feature flags in the OpenSource WebKit repository.
1204
1205         * wtf/Platform.h:
1206
1207 2018-01-19  Alex Christensen  <achristensen@webkit.org>
1208
1209         Fix jsc-only build
1210         https://bugs.webkit.org/show_bug.cgi?id=181874
1211
1212         Reviewed by JF Bastien.
1213
1214         This makes "build-webkit --jsc-only" work on Mac!
1215
1216         * wtf/PlatformJSCOnly.cmake:
1217
1218 2018-01-19  Keith Miller  <keith_miller@apple.com>
1219
1220         HaveInternalSDK includes should be "#include?"
1221         https://bugs.webkit.org/show_bug.cgi?id=179670
1222
1223         Reviewed by Dan Bernstein.
1224
1225         * Configurations/Base.xcconfig:
1226
1227 2018-01-19  Alexey Proskuryakov  <ap@apple.com>
1228
1229         Update XPCSPI.h
1230         https://bugs.webkit.org/show_bug.cgi?id=181827
1231         rdar://problem/36393031
1232
1233         Reviewed by Daniel Bates.
1234
1235         * wtf/spi/darwin/XPCSPI.h:
1236
1237 2018-01-18  Chris Dumez  <cdumez@apple.com>
1238
1239         We should be able to terminate service workers that are unresponsive
1240         https://bugs.webkit.org/show_bug.cgi?id=181563
1241         <rdar://problem/35280031>
1242
1243         Reviewed by Alex Christensen.
1244
1245         * wtf/ObjectIdentifier.h:
1246         (WTF::ObjectIdentifier::loggingString const):
1247         Allow using loggingString() from RELEASE_LOG().
1248
1249 2018-01-18  Dan Bernstein  <mitz@apple.com>
1250
1251         [Xcode] Streamline and future-proof target-macOS-version-dependent build setting definitions
1252         https://bugs.webkit.org/show_bug.cgi?id=181803
1253
1254         Reviewed by Tim Horton.
1255
1256         * Configurations/Base.xcconfig: Updated.
1257         * Configurations/DebugRelease.xcconfig: Updated.
1258
1259 2018-01-17  Daniel Bates  <dabates@apple.com>
1260
1261         REGRESSION (r222795): Cardiogram never signs in
1262         https://bugs.webkit.org/show_bug.cgi?id=181693
1263         <rdar://problem/36286293>
1264
1265         Reviewed by Ryosuke Niwa.
1266
1267         Add macro define for future iOS.
1268
1269         * wtf/spi/darwin/dyldSPI.h:
1270
1271 2018-01-17  Per Arne Vollan  <pvollan@apple.com>
1272
1273         [Win] Compile error: 'wtf/text/icu/TextBreakIteratorICU.h' not found.
1274         https://bugs.webkit.org/show_bug.cgi?id=181744
1275         <rdar://problem/36582562>
1276
1277         Reviewed by Alex Christensen.
1278
1279         Add WTF folders to forwarding headers directories.
1280
1281         * wtf/PlatformWin.cmake:
1282
1283 2018-01-16  Per Arne Vollan  <pvollan@apple.com>
1284
1285         [Win] JSC compile error in runtime/DateConversion.cpp.
1286         https://bugs.webkit.org/show_bug.cgi?id=181690
1287         <rdar://problem/36480409>
1288  
1289         Reviewed by Brent Fulgham.
1290
1291         Add 'text/win' folder to list of forwarding headers directories.
1292  
1293         * wtf/PlatformWin.cmake:
1294
1295 2018-01-15  Michael Catanzaro  <mcatanzaro@igalia.com>
1296
1297         Improve use of ExportMacros
1298         https://bugs.webkit.org/show_bug.cgi?id=181652
1299
1300         Reviewed by Konstantin Tokarev.
1301
1302         * wtf/ExportMacros.h: Simplify the #defines in this file.
1303         * wtf/Platform.h: Remove unneeded define. Remove comment that expects all ports to
1304           eventually enable the export macros. WPE will never want these. We don't currently want
1305           them for GTK either, though how we link GTK has been in flux recently.
1306
1307 2018-01-15  JF Bastien  <jfbastien@apple.com>
1308
1309         Remove makePoisonedUnique
1310         https://bugs.webkit.org/show_bug.cgi?id=181630
1311         <rdar://problem/36498623>
1312
1313         Reviewed by Mark Lam.
1314
1315         I added a conversion from std::unique_ptr, so we can just use
1316         std::make_unique and it'll auto-poison when converted.
1317
1318         * wtf/PoisonedUniquePtr.h:
1319         (WTF::makePoisonedUnique): Deleted.
1320
1321 2018-01-13  Mark Lam  <mark.lam@apple.com>
1322
1323         Replace all use of ConstExprPoisoned with Poisoned.
1324         https://bugs.webkit.org/show_bug.cgi?id=181542
1325         <rdar://problem/36442138>
1326
1327         Reviewed by JF Bastien.
1328
1329         1. Removed ConstExprPoisoned and its artifacts.
1330
1331         2. Consolidated Poisoned into PoisonedImpl.  PoisonedImpl is not more.
1332
1333         3. Changed all clients of ConstExprPoisoned to use Poisoned instead.
1334
1335         4. Worked around the GCC and Clang compiler bug that confuses an intptr_t&
1336            template arg with intptr_t.
1337            See use of std::enable_if_t<Other::isPoisoned> in Poisoned.h.
1338
1339         5. Removed ENABLE(MIXED_POISON) since we now have a workaround (3) that makes it
1340            possible to use the mixed poison code.
1341
1342         6. Also fixed broken implementation of comparison operators in Poisoned.
1343
1344         * wtf/Bag.h:
1345         * wtf/DumbPtrTraits.h:
1346         (WTF::DumbPtrTraits::poison):
1347         * wtf/DumbValueTraits.h:
1348         (WTF::DumbValueTraits::poison):
1349         * wtf/Poisoned.h:
1350         (WTF::Poisoned::Poisoned):
1351         (WTF::Poisoned::operator== const):
1352         (WTF::Poisoned::operator!= const):
1353         (WTF::Poisoned::operator< const):
1354         (WTF::Poisoned::operator<= const):
1355         (WTF::Poisoned::operator> const):
1356         (WTF::Poisoned::operator>= const):
1357         (WTF::Poisoned::operator=):
1358         (WTF::Poisoned::swap):
1359         (WTF::swap):
1360         (WTF::PoisonedPtrTraits::poison):
1361         (WTF::PoisonedPtrTraits::swap):
1362         (WTF::PoisonedValueTraits::poison):
1363         (WTF::PoisonedValueTraits::swap):
1364         (WTF::PoisonedImpl::PoisonedImpl): Deleted.
1365         (WTF::PoisonedImpl::assertIsPoisoned const): Deleted.
1366         (WTF::PoisonedImpl::assertIsNotPoisoned const): Deleted.
1367         (WTF::PoisonedImpl::unpoisoned const): Deleted.
1368         (WTF::PoisonedImpl::clear): Deleted.
1369         (WTF::PoisonedImpl::operator* const): Deleted.
1370         (WTF::PoisonedImpl::operator-> const): Deleted.
1371         (WTF::PoisonedImpl::bits const): Deleted.
1372         (WTF::PoisonedImpl::operator! const): Deleted.
1373         (WTF::PoisonedImpl::operator bool const): Deleted.
1374         (WTF::PoisonedImpl::operator== const): Deleted.
1375         (WTF::PoisonedImpl::operator!= const): Deleted.
1376         (WTF::PoisonedImpl::operator< const): Deleted.
1377         (WTF::PoisonedImpl::operator<= const): Deleted.
1378         (WTF::PoisonedImpl::operator> const): Deleted.
1379         (WTF::PoisonedImpl::operator>= const): Deleted.
1380         (WTF::PoisonedImpl::operator=): Deleted.
1381         (WTF::PoisonedImpl::swap): Deleted.
1382         (WTF::PoisonedImpl::exchange): Deleted.
1383         (WTF::PoisonedImpl::poison): Deleted.
1384         (WTF::PoisonedImpl::unpoison): Deleted.
1385         (WTF::constExprPoisonRandom): Deleted.
1386         (WTF::makeConstExprPoison): Deleted.
1387         (WTF::ConstExprPoisonedPtrTraits::exchange): Deleted.
1388         (WTF::ConstExprPoisonedPtrTraits::swap): Deleted.
1389         (WTF::ConstExprPoisonedPtrTraits::unwrap): Deleted.
1390         (WTF::ConstExprPoisonedValueTraits::exchange): Deleted.
1391         (WTF::ConstExprPoisonedValueTraits::swap): Deleted.
1392         (WTF::ConstExprPoisonedValueTraits::unwrap): Deleted.
1393         * wtf/PoisonedUniquePtr.h:
1394         (WTF::PoisonedUniquePtr::PoisonedUniquePtr):
1395         (WTF::PoisonedUniquePtr::operator=):
1396         * wtf/Ref.h:
1397         * wtf/RefCountedArray.h:
1398         (WTF::RefCountedArray::RefCountedArray):
1399         * wtf/RefPtr.h:
1400         * wtf/WTFAssertions.cpp:
1401
1402 2018-01-12  JF Bastien  <jfbastien@apple.com>
1403
1404         PoisonedWriteBarrier
1405         https://bugs.webkit.org/show_bug.cgi?id=181599
1406         <rdar://problem/36474351>
1407
1408         Reviewed by Mark Lam.
1409
1410         Supporting changes needed to allow poisoning of WriteBarrier
1411         objects.
1412
1413         * WTF.xcodeproj/project.pbxproj:
1414         * wtf/DumbPtrTraits.h:
1415         * wtf/DumbValueTraits.h: Copied from Source/WTF/wtf/DumbPtrTraits.h.
1416         (WTF::DumbValueTraits::exchange):
1417         (WTF::DumbValueTraits::swap):
1418         (WTF::DumbValueTraits::unwrap):
1419         * wtf/Forward.h:
1420         * wtf/Poisoned.h:
1421         (WTF::ConstExprPoisonedValueTraits::exchange):
1422         (WTF::ConstExprPoisonedValueTraits::swap):
1423         (WTF::ConstExprPoisonedValueTraits::unwrap):
1424
1425 2018-01-11  Basuke Suzuki  <Basuke.Suzuki@sony.com>
1426
1427         Remove noexcept from definition of std::tie()
1428         https://bugs.webkit.org/show_bug.cgi?id=181577
1429
1430         Reviewed by Yusuke Suzuki.
1431
1432         * wtf/StdLibExtras.h:
1433         (WTF::tie):
1434
1435 2018-01-11  Filip Pizlo  <fpizlo@apple.com>
1436
1437         Reserve a fast TLS key for GC TLC
1438         https://bugs.webkit.org/show_bug.cgi?id=181539
1439
1440         Reviewed by Alexey Proskuryakov.
1441         
1442         Who knew that thread-local caches would be a mitigation for timing attacks. Here's how it
1443         works: if we have TLCs then we can "context switch" them when we "context switch" origins. 
1444         This allows us to put some minimal distance between objects from different origins, which
1445         gives us the ability to allow small overflows when doing certain bounds checks without
1446         creating a useful Spectre information leak.
1447         
1448         So I think that means we have to implement thread-local caches (also known as thread-local
1449         allocation buffers, but I prefer the TLC terminology).
1450
1451         * wtf/FastTLS.h:
1452
1453 2018-01-04  Filip Pizlo  <fpizlo@apple.com>
1454
1455         CodeBlocks should be in IsoSubspaces
1456         https://bugs.webkit.org/show_bug.cgi?id=180884
1457
1458         Reviewed by Saam Barati.
1459         
1460         Deque<>::contains() is helpful for a debug ASSERT.
1461
1462         * wtf/Deque.h:
1463         (WTF::inlineCapacity>::contains):
1464
1465 2018-01-11  JF Bastien  <jfbastien@apple.com>
1466
1467         NFC reorder headers
1468         https://bugs.webkit.org/show_bug.cgi?id=181521
1469
1470         Reviewed by Darin Adler.
1471
1472         Follow-up on r226752. I misunderstood the header include order
1473         style. No functional change.
1474
1475         * wtf/Poisoned.h:
1476         * wtf/PoisonedUniquePtr.h:
1477
1478 2018-01-10  JF Bastien  <jfbastien@apple.com>
1479
1480         Poison small JSObject derivatives which only contain pointers
1481         https://bugs.webkit.org/show_bug.cgi?id=181483
1482         <rdar://problem/36407127>
1483
1484         Reviewed by Mark Lam.
1485
1486         The associated JSC poisoning change requires some template
1487         "improvements" to our poisoning machinery. Worth noting is that
1488         I'm making PoisonedUniquePtr move-assignable and
1489         move-constructible from unique_ptr, which makes it a better
1490         drop-in replacement because we don't need to use
1491         makePoisonedUniquePtr. This means function-locals can be
1492         unique_ptr and get the nice RAII pattern, and once the function is
1493         done you can just move to the class' PoisonedUniquePtr without
1494         worrying.
1495
1496         * wtf/Poisoned.h:
1497         (WTF::PoisonedImpl::PoisonedImpl):
1498         * wtf/PoisonedUniquePtr.h:
1499         (WTF::PoisonedUniquePtr::PoisonedUniquePtr):
1500         (WTF::PoisonedUniquePtr::operator=):
1501
1502 2018-01-10  Don Olmstead  <don.olmstead@sony.com>
1503
1504         Add nullptr_t specialization of poison
1505         https://bugs.webkit.org/show_bug.cgi?id=181469
1506
1507         Reviewed by JF Bastien.
1508
1509         * wtf/Poisoned.h:
1510         (WTF::PoisonedImpl::poison):
1511
1512 2018-01-10  Commit Queue  <commit-queue@webkit.org>
1513
1514         Unreviewed, rolling out r226667 and r226673.
1515         https://bugs.webkit.org/show_bug.cgi?id=181488
1516
1517         This caused a flaky crash. (Requested by mlewis13 on #webkit).
1518
1519         Reverted changesets:
1520
1521         "CodeBlocks should be in IsoSubspaces"
1522         https://bugs.webkit.org/show_bug.cgi?id=180884
1523         https://trac.webkit.org/changeset/226667
1524
1525         "REGRESSION (r226667): CodeBlocks should be in IsoSubspaces"
1526         https://bugs.webkit.org/show_bug.cgi?id=180884
1527         https://trac.webkit.org/changeset/226673
1528
1529 2018-01-04  Filip Pizlo  <fpizlo@apple.com>
1530
1531         CodeBlocks should be in IsoSubspaces
1532         https://bugs.webkit.org/show_bug.cgi?id=180884
1533
1534         Reviewed by Saam Barati.
1535         
1536         Deque<>::contains() is helpful for a debug ASSERT.
1537
1538         * wtf/Deque.h:
1539         (WTF::inlineCapacity>::contains):
1540
1541 2018-01-08  Don Olmstead  <don.olmstead@sony.com>
1542
1543         Add WTF_EXPORTs to UniStdExtras
1544         https://bugs.webkit.org/show_bug.cgi?id=181415
1545
1546         Reviewed by Alex Christensen.
1547
1548         * wtf/UniStdExtras.h:
1549
1550 2018-01-07  Mark Lam  <mark.lam@apple.com>
1551
1552         Apply poisoning to more pointers in JSC.
1553         https://bugs.webkit.org/show_bug.cgi?id=181096
1554         <rdar://problem/36182970>
1555
1556         Reviewed by JF Bastien.
1557
1558         Added support for PoisonedBag and PoisonedRefCountedArray.
1559
1560         * wtf/Bag.h:
1561         (WTF::Private::BagNode::BagNode):
1562         (WTF::Bag::Bag):
1563         (WTF::Bag::operator=):
1564         (WTF::Bag::clear):
1565         (WTF::Bag::add):
1566         (WTF::Bag::begin):
1567         (WTF::Bag::unwrappedHead):
1568         (WTF::Bag::Node::Node): Deleted.
1569         * wtf/BagToHashMap.h:
1570         (WTF::toHashMap):
1571         * wtf/Poisoned.h:
1572         (WTF::constExprPoisonRandom):
1573         (WTF::makeConstExprPoison):
1574         * wtf/RefCountedArray.h:
1575         (WTF::RefCountedArray::RefCountedArray):
1576         (WTF::RefCountedArray::clone const):
1577         (WTF::RefCountedArray::operator=):
1578         (WTF::RefCountedArray::~RefCountedArray):
1579         (WTF::RefCountedArray::refCount const):
1580         (WTF::RefCountedArray::size const):
1581         (WTF::RefCountedArray::data):
1582         (WTF::RefCountedArray::begin):
1583         (WTF::RefCountedArray::end):
1584         (WTF::RefCountedArray::data const):
1585         (WTF::RefCountedArray::begin const):
1586         (WTF::RefCountedArray::operator== const):
1587         (WTF::RefCountedArray::Header::fromPayload):
1588         * wtf/WTFAssertions.cpp:
1589
1590 2018-01-05  JF Bastien  <jfbastien@apple.com>
1591
1592         WebAssembly: poison JS object's secrets
1593         https://bugs.webkit.org/show_bug.cgi?id=181339
1594         <rdar://problem/36325001>
1595
1596         Reviewed by Mark Lam.
1597
1598         swapping a poisoned pointer with a non-poisoned one (as is done in
1599         JSWebAssembyMemory::adopt) was missing.
1600
1601         * wtf/Poisoned.h:
1602         (WTF::PoisonedImpl::swap):
1603         (WTF::ConstExprPoisonedPtrTraits::swap):
1604
1605 2018-01-05  David Kilzer  <ddkilzer@apple.com>
1606
1607         Re-enable -Wcast-qual in WebCore for Apple ports
1608         <https://webkit.org/b/177895>
1609         <rdar://problem/34960830>
1610
1611         Reviewed by Joseph Pecoraro.
1612
1613         * wtf/RetainPtr.h:
1614         (WTF::RetainPtr::fromStorageTypeHelper const): Add const_cast<>
1615         operator here since some CFTypes are not defined as const
1616         pointers, which triggers a warning in C++ source with
1617         -Wcast-qual when casting from CFTypeRef back to the original
1618         type.  Note that we use const_cast<CF_BRIDGED_TYPE(id) void*>()
1619         here (and in TypeCastsCF.h below) since this is what CFTypeRef
1620         is defined as in CFBase.h, but without the 'const' modifier.
1621         (WTF::RetainPtr::fromStorageType const): Ditto.
1622
1623         * wtf/cf/TypeCastsCF.h: Use #pragma once.
1624         (WTF_DECLARE_CF_TYPE_TRAIT): Rename from DECLARE_CF_TYPE_TRAIT.
1625         Don't #undef it so that it can be used in other source files.
1626         (WTF_DECLARE_CF_MUTABLE_TYPE_TRAIT): Add new macro that is used
1627         for declaring CFMutable types.  The CFTypeID for CF_Foo_ and
1628         CFMutable_Foo_ are the same, so we have to use a different macro
1629         to declare type traits for those types.
1630         (WTF::dynamic_cf_cast): Add assertion to catch issues in Debug
1631         builds.
1632         (WTF::checked_cf_cast): Inline code from WTF::dynamic_cf_cast
1633         and change behavior to be more consistent between Debug and
1634         Release builds, as well as other "checked" functions.
1635         Previously this function would return nullptr in Release builds
1636         if nullptr or the wrong type of object was passed in, but crash
1637         in both cases on Debug builds.  The new behavior always returns
1638         nullptr if nullptr was passed in (but never crashes), and always
1639         crashes if the wrong type of object is passed in.
1640
1641 2018-01-04  Keith Miller  <keith_miller@apple.com>
1642
1643         TypedArrays and Wasm should use index masking.
1644         https://bugs.webkit.org/show_bug.cgi?id=181313
1645
1646         Reviewed by Michael Saboff.
1647
1648         * wtf/MathExtras.h:
1649         (WTF::computeIndexingMask):
1650
1651 2018-01-03  Michael Saboff  <msaboff@apple.com>
1652
1653         Disable SharedArrayBuffers from Web API
1654         https://bugs.webkit.org/show_bug.cgi?id=181266
1655
1656         Reviewed by Saam Barati.
1657
1658         Turn off SharedArrayBuffers using a compile time flag ENABLE_SHARED_ARRAY_BUFFER.
1659
1660         * wtf/Platform.h:
1661
1662 2017-12-28  Yusuke Suzuki  <utatane.tea@gmail.com>
1663
1664         Remove std::chrono completely
1665         https://bugs.webkit.org/show_bug.cgi?id=181186
1666
1667         Reviewed by Alex Christensen.
1668
1669         std::chrono's overflow unaware design is dangerous[1]. Even small code like
1670         `condition.wait_for(std::chrono::seconds::max())` is broken in some platforms
1671         due to overflow of std::chrono::time_point. So we intentionally avoid using
1672         std::chrono, and use WallTime, MonotonicTime, Seconds instead.
1673
1674         This patch removes all the remaining use of std::chrono from WebKit tree.
1675
1676         [1]: https://lists.webkit.org/pipermail/webkit-dev/2016-May/028242.html
1677
1678         * wtf/CrossThreadCopier.h:
1679         Remove std::chrono support from cross thread copiers.
1680         * wtf/Forward.h:
1681         * wtf/MonotonicTime.h:
1682         (WTF::MonotonicTime::isolatedCopy const):
1683         Add isolatedCopy function.
1684         * wtf/RunLoop.h:
1685         (WTF::RunLoop::TimerBase::startRepeating):
1686         (WTF::RunLoop::TimerBase::startOneShot):
1687         Just remove these helpers.
1688         * wtf/Seconds.h:
1689         (WTF::Seconds::isolatedCopy const):
1690         Add isolatedCopy function.
1691         * wtf/WallTime.h:
1692         (WTF::WallTime::isolatedCopy const):
1693         Add isolatedCopy function.
1694         * wtf/persistence/PersistentCoders.h:
1695         (WTF::Persistence::Coder<Seconds>::encode):
1696         (WTF::Persistence::Coder<Seconds>::decode):
1697         (WTF::Persistence::Coder<WallTime>::encode):
1698         (WTF::Persistence::Coder<WallTime>::decode):
1699         Add persistent coder support for Seconds and WallTime.
1700         (WTF::Persistence::Coder<std::chrono::system_clock::time_point>::encode): Deleted.
1701         (WTF::Persistence::Coder<std::chrono::system_clock::time_point>::decode): Deleted.
1702         Remove std::chrono support from persistent coders.
1703
1704 2018-01-02  Mark Lam  <mark.lam@apple.com>
1705
1706         Refactoring: Rename DummyClass to DummyStruct because it's a struct.
1707         https://bugs.webkit.org/show_bug.cgi?id=181230
1708
1709         Reviewed by JF Bastien.
1710
1711         * wtf/WTFAssertions.cpp:
1712
1713 2018-01-02  Mark Lam  <mark.lam@apple.com>
1714
1715         Ensure that poisoned pointers do not look like double or int32 JSValues.
1716         https://bugs.webkit.org/show_bug.cgi?id=181221
1717         <rdar://problem/36248638>
1718
1719         Reviewed by JF Bastien.
1720
1721         Changed poison values to ensure that poisoned bits (i.e. pointer ^ poison)
1722         satisfies the following conditions:
1723         1. bits 48-63 are 0: this ensures that poisoned bits look like a pointer and
1724            not a double or int32 JSValue.
1725         2. bits 32-47 are not completely 0.
1726         3. bit 2 is never 0: this ensures that the poisoned value of a non-null pointer
1727            will never be null.
1728         4. bit 0-1 is always 0: this ensures that clients can still use the 2 bottom
1729            bits of the poisoned value as flag bits (just like they were able to do with
1730            pointer values).  The only difference is that bit 2 can no longer be used for
1731            flag bits because poisoned values need it to always be set.
1732
1733         * WTF.xcodeproj/project.pbxproj:
1734         * wtf/CMakeLists.txt:
1735         * wtf/PointerAsserts.cpp: Removed.
1736
1737         * wtf/Poisoned.cpp:
1738         (WTF::makePoison):
1739         - Updated to satisfy the above requirements.
1740         
1741         * wtf/Poisoned.h:
1742         (WTF::makeConstExprPoison):
1743         (WTF::makePoison): Deleted.
1744
1745         * wtf/WTFAssertions.cpp: Copied from Source/WTF/wtf/PointerAsserts.cpp.
1746         - Renamed from PointerAsserts.cpp because we assert more things than just
1747           pointers here.
1748         - Added some assertions to test makeConstExprPoison() to ensure that it satisfies
1749           the above requirements.
1750
1751 2017-12-28  Yusuke Suzuki  <utatane.tea@gmail.com>
1752
1753         Remove std::chrono if it is not used for ArgumentCoder or PersistentCoder
1754         https://bugs.webkit.org/show_bug.cgi?id=181174
1755
1756         Reviewed by Konstantin Tokarev.
1757
1758         Make WallTime more constexpr friendly. This change is already applied to MonoTonicTime.
1759
1760         We would like to move std::{isfinite,isinf,isnan} overloadings from std:: to each class scope in a separate patch[1].
1761
1762         [1]: https://bugs.webkit.org/show_bug.cgi?id=181183
1763
1764         * wtf/WallTime.h:
1765         (WTF::WallTime::WallTime):
1766         (WTF::WallTime::fromRawSeconds):
1767         (WTF::WallTime::infinity):
1768         (WTF::WallTime::secondsSinceEpoch const):
1769         (WTF::WallTime::operator bool const):
1770         (WTF::WallTime::operator+ const):
1771         (WTF::WallTime::operator- const):
1772         (WTF::WallTime::operator== const):
1773         (WTF::WallTime::operator!= const):
1774         (WTF::WallTime::operator< const):
1775         (WTF::WallTime::operator> const):
1776         (WTF::WallTime::operator<= const):
1777         (WTF::WallTime::operator>= const):
1778
1779 2017-12-28  Fujii Hironori  <Hironori.Fujii@sony.com>
1780
1781         [Win][CMake] Use add_custom_command to copy each forwarding header files
1782         https://bugs.webkit.org/show_bug.cgi?id=180921
1783
1784         Reviewed by Brent Fulgham.
1785
1786         * wtf/PlatformWin.cmake: Use WEBKIT_MAKE_FORWARDING_HEADERS.
1787
1788 2017-12-27  Yusuke Suzuki  <utatane.tea@gmail.com>
1789
1790         [WTF] Add clock_gettime based monotonicallyIncreasingTime implementation for Linux and BSDs
1791         https://bugs.webkit.org/show_bug.cgi?id=181175
1792
1793         Reviewed by Michael Catanzaro.
1794
1795         Use platform-provided POSIX APIs to get monotonic time.
1796
1797         * wtf/CurrentTime.cpp:
1798         (WTF::monotonicallyIncreasingTime):
1799
1800 2017-12-26  Carlos Alberto Lopez Perez  <clopez@igalia.com>
1801
1802         REGRESSION(r225769): Build error with constexpr std::max // std::min in libdstdc++4
1803         https://bugs.webkit.org/show_bug.cgi?id=181160
1804
1805         Reviewed by Myles C. Maxfield.
1806
1807         In libstdc++-4 std::max and std::min are not annotated with constexpr.
1808         This patch adds a WTF::min and WTF::max for using where a constexpr result is expected.
1809         Related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60271
1810
1811         * wtf/StdLibExtras.h:
1812         (WTF::min):
1813         (WTF::max):
1814
1815 2017-12-26  Yusuke Suzuki  <utatane.tea@gmail.com>
1816
1817         [JSC] Remove std::chrono completely
1818         https://bugs.webkit.org/show_bug.cgi?id=181165
1819
1820         Reviewed by Konstantin Tokarev.
1821
1822         WTF::currentCPUTime now returns WTF::Seconds.
1823         We also add the implementaiton for Linux and FreeBSD.
1824
1825         * wtf/CurrentTime.cpp:
1826         (WTF::currentCPUTime):
1827         * wtf/CurrentTime.h:
1828
1829 2017-12-22  Wenson Hsieh  <wenson_hsieh@apple.com>
1830
1831         Unreviewed, try to fix the Sierra build after r226277.
1832
1833         The macOS 10.12 SDK does not know about NSControlStateValue and some types of NSLevelIndicatorStyles, so these
1834         need to be declared in a separate section in AppKitCompatibilityDeclarations.h (rather than in the < macOS 10.12
1835         SDK #ifdef).
1836
1837         * wtf/mac/AppKitCompatibilityDeclarations.h:
1838
1839 2017-12-22  Wenson Hsieh  <wenson_hsieh@apple.com>
1840
1841         Fix build failures due to using deprecated AppKit symbols
1842         https://bugs.webkit.org/show_bug.cgi?id=181110
1843         <rdar://problem/36162865>
1844
1845         Reviewed by Dan Bernstein and Tim Horton.
1846
1847         When building with older macOS SDKs where some AppKit constants don't exist, define the modern constants to be
1848         equal to their deprecated counterparts. This allows us to just have the modern types in WebKit sources while
1849         avoiding breakage on old SDKs.
1850
1851         This, along with many other symbols in the compability header, can be removed once WebKit stops supporting macOS
1852         10.11.
1853
1854         * wtf/mac/AppKitCompatibilityDeclarations.h:
1855
1856 2017-12-21  Mark Lam  <mark.lam@apple.com>
1857
1858         Add WTF::PoisonedUniquePtr to replace std::unique_ptr when poisoning is desired.
1859         https://bugs.webkit.org/show_bug.cgi?id=181062
1860         <rdar://problem/36167040>
1861
1862         Reviewed by Chris Dumez.
1863
1864         * WTF.xcodeproj/project.pbxproj:
1865         * wtf/CMakeLists.txt:
1866         * wtf/PointerAsserts.cpp: Copied from Source/WTF/wtf/RefPtr.cpp.
1867         - renamed file because we asserts all kinds of pointers in here, not just RefPtr.
1868         
1869         * wtf/Poisoned.h:
1870         - added a missing #include.
1871         - make constexpr poison values more scrambled.
1872         (WTF::makePoison):
1873
1874         * wtf/PoisonedUniquePtr.h: Added.
1875         (WTF::PoisonedUniquePtr::PoisonedUniquePtr):
1876         (WTF::PoisonedUniquePtr::~PoisonedUniquePtr):
1877         (WTF::PoisonedUniquePtr::create):
1878         (WTF::PoisonedUniquePtr::operator=):
1879         (WTF::PoisonedUniquePtr::get const):
1880         (WTF::PoisonedUniquePtr::operator[] const):
1881         (WTF::PoisonedUniquePtr::clear):
1882         (WTF::PoisonedUniquePtr::destroy):
1883         (WTF::PoisonedUniquePtr::clearWithoutDestroy):
1884         (WTF::makePoisonedUnique):
1885         * wtf/RefPtr.cpp: Removed.
1886
1887 2017-12-21  Jeremy Jones  <jeremyj@apple.com>
1888
1889         Element fullscreen interface should display the location
1890         https://bugs.webkit.org/show_bug.cgi?id=181006
1891         rdar://problem/36143176
1892
1893         Reviewed by Simon Fraser.
1894
1895         Add SecTrustCopyInfo SPI.
1896
1897         * wtf/spi/cocoa/SecuritySPI.h:
1898
1899 2017-12-20  Fujii Hironori  <Hironori.Fujii@sony.com>
1900
1901         [CMake][WTF] Lowercase ForwardingHeaders directory name of WTF
1902         https://bugs.webkit.org/show_bug.cgi?id=181022
1903
1904         Reviewed by Konstantin Tokarev.
1905
1906         * wtf/CMakeLists.txt: Renamed ForwardingHeaders directory name WTF to wtf.
1907         * wtf/PlatformWin.cmake: Ditto.
1908
1909 2017-12-19  Brian Burg  <bburg@apple.com>
1910
1911         SLEEP_THREAD_FOR_DEBUGGER() macro should try to print out the PID of the affected process
1912         https://bugs.webkit.org/show_bug.cgi?id=180947
1913
1914         Reviewed by Joseph Pecoraro.
1915
1916         * wtf/DebugUtilities.h:
1917         - Use sleep() from CurrentTime.h as it is more cross-platform.
1918         - Print a message with the process PID to simplify attaching to sleeping thread.
1919         - Include source location in case multiple such macros are being used.
1920
1921 2017-12-18  Daniel Bates  <dabates@apple.com>
1922
1923         Conditionally forward declare NSMapTable SPI
1924         https://bugs.webkit.org/show_bug.cgi?id=180936
1925         <rdar://problem/35037796>
1926
1927         Reviewed by Dan Bernstein.
1928
1929         * wtf/spi/cocoa/NSMapTableSPI.h:
1930
1931 2017-12-16  Filip Pizlo  <fpizlo@apple.com>
1932
1933         Vector index masking
1934         https://bugs.webkit.org/show_bug.cgi?id=180909
1935
1936         Reviewed by Keith Miller.
1937         
1938         Adds index masking to StringImpl and Vector.
1939         
1940         Perf:
1941         
1942         - 0.4% slower on microbenchmarks.
1943         - Octane totally even.
1944         - Kraken may be 0.8% slower.
1945         - Speedometer is 0.8% slower with p = 0.008.
1946         - membuster is even:
1947             - snap2pre: 0.7% bigger w/ p = 0.26,
1948             - snap2post: 0.3% smaller w/ p = 0.81,
1949             - snap3pre: 1.2% bigger w/ p = 0.63,
1950             - snap3post: 0.4% smaller w/ p = 0.76.
1951
1952         * wtf/MathExtras.h:
1953         (WTF::roundUpToPowerOfTwo):
1954         (WTF::maskForSize):
1955         * wtf/SizeLimits.cpp:
1956         * wtf/Vector.h:
1957         (WTF::VectorBufferBase::allocateBuffer):
1958         (WTF::VectorBufferBase::tryAllocateBuffer):
1959         (WTF::VectorBufferBase::reallocateBuffer):
1960         (WTF::VectorBufferBase::deallocateBuffer):
1961         (WTF::VectorBufferBase::releaseBuffer):
1962         (WTF::VectorBufferBase::VectorBufferBase):
1963         (WTF::VectorBufferBase::updateMask):
1964         (WTF::VectorBuffer::allocateBuffer):
1965         (WTF::VectorBuffer::tryAllocateBuffer):
1966         (WTF::VectorBuffer::swap):
1967         (WTF::VectorBuffer::restoreInlineBufferIfNeeded):
1968         (WTF::Vector::at):
1969         (WTF::Vector::at const):
1970         * wtf/text/StringImpl.h:
1971         (WTF::StringImpl::maskOffset):
1972         (WTF::StringImpl::mask const):
1973         (WTF::StringImplShape::StringImplShape):
1974         (WTF::StringImpl::at const):
1975         (WTF::StringImpl::tailOffset):
1976         * wtf/text/StringView.h:
1977         (WTF::StringView::StringView):
1978         (WTF::StringView::operator=):
1979         (WTF::StringView::initialize):
1980         (WTF::StringView::clear):
1981         (WTF::StringView::operator[] const):
1982         * wtf/text/WTFString.h:
1983         (WTF::String::mask const):
1984
1985 2017-12-18  Claudio Saavedra  <csaavedra@igalia.com>
1986
1987         [GTK][Darwin] Do not define mach exceptions for GTK+
1988
1989         Rubber-stamped by Michael Catanzaro.
1990         * wtf/Platform.h:
1991
1992 2017-12-17  Yusuke Suzuki  <utatane.tea@gmail.com>
1993
1994         [FTL] NewArrayBuffer should be sinked if it is only used for spreading
1995         https://bugs.webkit.org/show_bug.cgi?id=179762
1996
1997         Reviewed by Saam Barati.
1998
1999         We add RecursableLambda<>. This can take a lambda and offer a way
2000         to call this lambda recursively without introducing additional allocations.
2001
2002         C++ lambda is super useful in particular when we need to capture many
2003         variables as references. Passing many arguments to a usual function is not
2004         a good way. But C++ lambda does not allow us to easily call itself recursively.
2005
2006         Our recursableLambda offers `self` function as a first argument of the
2007         given lambda. We can call this `self` recursively.
2008
2009         auto targetFunction = recursableLambda([] (auto self, ...) -> resultType {
2010             self(...);
2011         });
2012
2013         While `std::function<> func = [&func] { ... }` allows recursion, it causes
2014         heap allocation for std::function<>. `auto func = [&func] { ... }` causes
2015         a compile error since we need to deduce an actual type when capturing `func`.
2016
2017         * WTF.xcodeproj/project.pbxproj:
2018         * wtf/RecursableLambda.h: Added.
2019         (WTF::RecursableLambda::RecursableLambda):
2020         (WTF::RecursableLambda::operator() const):
2021         (WTF::recursableLambda):
2022
2023 2017-12-17  Mark Lam  <mark.lam@apple.com>
2024
2025         Enhance Ref and RefPtr to be able to work with smart pointers.
2026         https://bugs.webkit.org/show_bug.cgi?id=180762
2027         <rdar://problem/36027122>
2028
2029         Reviewed by JF Bastien and Darin Adler.
2030
2031         This is so we can use them with ConstExprPoisoned pointers to make PoisonedRef
2032         and PoisonedRefPtr.
2033
2034         * WTF.xcodeproj/project.pbxproj:
2035         * wtf/CMakeLists.txt:
2036         * wtf/DumbPtrTraits.h: Added.
2037         (WTF::DumbPtrTraits::exchange):
2038         (WTF::DumbPtrTraits::swap):
2039         (WTF::DumbPtrTraits::unwrap):
2040         * wtf/Forward.h:
2041         * wtf/Poisoned.h:
2042         (WTF::ConstExprPoisonedPtrTraits::exchange):
2043         (WTF::ConstExprPoisonedPtrTraits::swap):
2044         (WTF::ConstExprPoisonedPtrTraits::unwrap):
2045         * wtf/Ref.h:
2046         (WTF::Ref::~Ref):
2047         (WTF::Ref::Ref):
2048         (WTF::Ref::ptrAllowingHashTableEmptyValue const):
2049         (WTF::Ref::ptrAllowingHashTableEmptyValue):
2050         (WTF::Ref::operator-> const):
2051         (WTF::Ref::get const):
2052         (WTF::Ref::operator T& const):
2053         (WTF::=):
2054         (WTF::U>::swap):
2055         (WTF::swap):
2056         (WTF::U>::replace):
2057         (WTF::static_reference_cast):
2058         (WTF::adoptRef):
2059         (WTF::is):
2060         (WTF::Ref<T>::swap): Deleted.
2061         (WTF::Ref<T>::replace): Deleted.
2062         (WTF::GetPtrHelper<Ref<T>>::getPtr): Deleted.
2063         * wtf/RefPtr.cpp: Added.
2064         * wtf/RefPtr.h:
2065         (WTF::RefPtr::RefPtr):
2066         (WTF::RefPtr::~RefPtr):
2067         (WTF::RefPtr::get const):
2068         (WTF::RefPtr::operator* const):
2069         (WTF::RefPtr::operator-> const):
2070         (WTF::U>::RefPtr):
2071         (WTF::U>::leakRef):
2072         (WTF::=):
2073         (WTF::U>::swap):
2074         (WTF::swap):
2075         (WTF::operator==):
2076         (WTF::operator!=):
2077         (WTF::static_pointer_cast):
2078         (WTF::adoptRef):
2079         (WTF::is):
2080         (WTF::RefPtr<T>::RefPtr): Deleted.
2081         (WTF::RefPtr<T>::leakRef): Deleted.
2082         (WTF::RefPtr<T>::swap): Deleted.
2083
2084 2017-12-16  Yusuke Suzuki  <utatane.tea@gmail.com>
2085
2086         Remove unnecessary boolean result of start() functions
2087         https://bugs.webkit.org/show_bug.cgi?id=180856
2088
2089         Reviewed by Darin Adler.
2090
2091         CrossThreadTaskHandler's Thread is just released without calling
2092         either `waitForCompletion` or `detach`. It means that this resource
2093         of the thread is not released.
2094
2095         * benchmarks/ConditionSpeedTest.cpp:
2096         * wtf/CrossThreadTaskHandler.cpp:
2097         (WTF::CrossThreadTaskHandler::CrossThreadTaskHandler):
2098         * wtf/CrossThreadTaskHandler.h:
2099
2100 2017-12-14  David Kilzer  <ddkilzer@apple.com>
2101
2102         Enable -Wstrict-prototypes for WebKit
2103         <https://webkit.org/b/180757>
2104         <rdar://problem/36024132>
2105
2106         Rubber-stamped by Joseph Pecoraro.
2107
2108         * Configurations/Base.xcconfig:
2109         (CLANG_WARN_STRICT_PROTOTYPES): Add. Set to YES.
2110         * wtf/Assertions.h:
2111         (WTFReportBacktrace): Add 'void' to C function declaration.
2112         (WTFCrashHookFunction): Add 'void' to C function pointer declaration.
2113         (WTFInstallReportBacktraceOnCrashHook): Add 'void' to C function declaration.
2114         (WTFIsDebuggerAttached): Ditto.
2115         (WTFCrash): Ditto.
2116         (WTFCrashWithSecurityImplication): Ditto.
2117
2118 2017-12-14  Yusuke Suzuki  <utatane.tea@gmail.com>
2119
2120         Drop Thread::tryCreate
2121         https://bugs.webkit.org/show_bug.cgi?id=180808
2122
2123         Reviewed by Darin Adler.
2124
2125         We remove Thread::tryCreate. When thread creation fails, we have no way to keep WebKit working.
2126         Compared to tryMalloc, Thread::create always consumes fixed size of resource. If it fails,
2127         this is not due to arbitrary large user request. It is not reasonable that some thread creations
2128         are handled gracefully while the other thread creations are not.
2129
2130         If we would like to have the limit of number of users' thread creation (like, calling `new Worker`
2131         so many times), we should have a soft limit instead of relying on system's hard limit.
2132
2133         * wtf/ParallelJobsGeneric.cpp:
2134         (WTF::ParallelEnvironment::ThreadPrivate::tryLockFor):
2135         * wtf/Threading.cpp:
2136         (WTF::Thread::create):
2137         (WTF::Thread::tryCreate): Deleted.
2138         * wtf/Threading.h:
2139         (WTF::Thread::create): Deleted.
2140
2141 2017-12-13  Keith Miller  <keith_miller@apple.com>
2142
2143         JSObjects should have a mask for loading indexed properties
2144         https://bugs.webkit.org/show_bug.cgi?id=180768
2145
2146         Reviewed by Mark Lam.
2147
2148         Add a clz that wraps the builtin clz intrinisics provided by
2149         various compilers. The clz function by default assumes that
2150         the input may be zero. On X86 this makes a difference because not
2151         all CPUs have LZCNT and BSR has undefined behavior on zero. On ARM,
2152         the zero check gets optimized away, regardless.
2153
2154         * wtf/StdLibExtras.h:
2155         (std::clz):
2156
2157 2017-12-12  Yusuke Suzuki  <utatane.tea@gmail.com>
2158
2159         REGRESSION(r225769): Build errors with constexpr std::tie on older gcc
2160         https://bugs.webkit.org/show_bug.cgi?id=180692
2161
2162         Reviewed by Carlos Garcia Campos.
2163
2164         Due to libstdc++'s bug[1], std::tie is not annotated with constexpr in libstdc++ 5.
2165         This patch adds WTF::tie for a work around. Since we do not want to
2166         include <tuple> in StdLibExtras.h, we define this function for all
2167         the compilers.
2168
2169         [1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65978
2170
2171         * wtf/StdLibExtras.h:
2172
2173 2017-12-13  Mark Lam  <mark.lam@apple.com>
2174
2175         Fill out some Poisoned APIs, fix some bugs, and add some tests.
2176         https://bugs.webkit.org/show_bug.cgi?id=180724
2177         <rdar://problem/36006884>
2178
2179         Reviewed by JF Bastien.
2180
2181         Also rename Int32Poisoned to ConstExprPoisoned.  The key it takes is actually a
2182         uint32_t.  So, Int32 is really a misnomer.  In addition, the key needs to be a
2183         constexpr.  So, ConstExprPoisoned is a better name for it.
2184
2185         * wtf/Poisoned.cpp:
2186         (WTF::makePoison):
2187         * wtf/Poisoned.h:
2188         (WTF::PoisonedImplHelper::asReference):
2189         (WTF::PoisonedImpl::PoisonedImpl):
2190         (WTF::PoisonedImpl::clear):
2191         (WTF::PoisonedImpl::operator* const):
2192         (WTF::PoisonedImpl::operator-> const):
2193         (WTF::PoisonedImpl::operator== const):
2194         (WTF::PoisonedImpl::operator!= const):
2195         (WTF::PoisonedImpl::operator< const):
2196         (WTF::PoisonedImpl::operator<= const):
2197         (WTF::PoisonedImpl::operator> const):
2198         (WTF::PoisonedImpl::operator>= const):
2199         (WTF::PoisonedImpl::operator=):
2200         (WTF::PoisonedImpl::swap):
2201         (WTF::PoisonedImpl::exchange):
2202         (WTF::swap):
2203         (WTF::makePoison):
2204         (WTF::PoisonedImpl::operator==): Deleted.
2205
2206 2017-12-12  Yusuke Suzuki  <utatane.tea@gmail.com>
2207
2208         [JSC] Implement optimized WeakMap and WeakSet
2209         https://bugs.webkit.org/show_bug.cgi?id=179929
2210
2211         Reviewed by Saam Barati.
2212
2213         We introduce JSValueMalloc, which is specialized malloc scheme with Gigacage::JSValue.
2214         This is used for WeakMapImpl's buffer.
2215
2216         * WTF.xcodeproj/project.pbxproj:
2217         * wtf/CMakeLists.txt:
2218         * wtf/JSValueMalloc.cpp: Added.
2219         (WTF::tryJSValueMalloc):
2220         (WTF::jsValueMalloc):
2221         (WTF::jsValueRealloc):
2222         (WTF::jsValueFree):
2223         * wtf/JSValueMalloc.h: Added.
2224         (WTF::JSValueMalloc::malloc):
2225         (WTF::JSValueMalloc::tryMalloc):
2226         (WTF::JSValueMalloc::realloc):
2227         (WTF::JSValueMalloc::free):
2228         * wtf/MallocPtr.h:
2229         (WTF::MallocPtr::~MallocPtr):
2230         (WTF::MallocPtr::malloc):
2231         (WTF::MallocPtr::tryMalloc):
2232         (WTF::MallocPtr::realloc):
2233         We extend MallocPtr to adopt malloc scheme as its template parameter.
2234
2235 2017-12-11  Filip Pizlo  <fpizlo@apple.com>
2236
2237         It should be possible to flag a cell for unconditional finalization
2238         https://bugs.webkit.org/show_bug.cgi?id=180636
2239
2240         Reviewed by Saam Barati.
2241         
2242         This adds ConcurrentVector, which is like SegmentedVector, but wastes some space to allow
2243         resizing to proceed concurrently to access. It's not possible to resize concurrently to
2244         resizing, concurrent read/writes aren't protected from racing if they access the same element,
2245         and who knows what you'll get if you iterate up to size() while someone else append()s. The
2246         key insight is to stash all prior copies of the spine, so that nobody crashes trying to access
2247         a stale spine.
2248         
2249         I'm going to want to do the same thing for FastBitVector, by creating a segmented WordOwner
2250         class. That would require repeating the dance of having a spine that can resize while stashing
2251         old versions. So, the spine resizing logic is abstracted behind ConcurrentBuffer. You could
2252         use that as a kind of "concurrent vector" for immutable data. That's how ConcurrentVector uses
2253         it: it's an immutable array of segment pointers.
2254
2255         * WTF.xcodeproj/project.pbxproj:
2256         * wtf/ConcurrentBuffer.h: Added.
2257         (WTF::ConcurrentBuffer::ConcurrentBuffer):
2258         (WTF::ConcurrentBuffer::~ConcurrentBuffer):
2259         (WTF::ConcurrentBuffer::growExact):
2260         (WTF::ConcurrentBuffer::grow):
2261         (WTF::ConcurrentBuffer::array const):
2262         (WTF::ConcurrentBuffer::operator[]):
2263         (WTF::ConcurrentBuffer::operator[] const):
2264         (WTF::ConcurrentBuffer::createArray):
2265         * wtf/ConcurrentVector.h: Added.
2266         (WTF::ConcurrentVectorIterator::~ConcurrentVectorIterator):
2267         (WTF::ConcurrentVectorIterator::operator* const):
2268         (WTF::ConcurrentVectorIterator::operator-> const):
2269         (WTF::ConcurrentVectorIterator::operator++):
2270         (WTF::ConcurrentVectorIterator::operator== const):
2271         (WTF::ConcurrentVectorIterator::operator!= const):
2272         (WTF::ConcurrentVectorIterator::operator=):
2273         (WTF::ConcurrentVectorIterator::ConcurrentVectorIterator):
2274         (WTF::ConcurrentVector::~ConcurrentVector):
2275         (WTF::ConcurrentVector::size const):
2276         (WTF::ConcurrentVector::isEmpty const):
2277         (WTF::ConcurrentVector::at):
2278         (WTF::ConcurrentVector::at const):
2279         (WTF::ConcurrentVector::operator[]):
2280         (WTF::ConcurrentVector::operator[] const):
2281         (WTF::ConcurrentVector::first):
2282         (WTF::ConcurrentVector::first const):
2283         (WTF::ConcurrentVector::last):
2284         (WTF::ConcurrentVector::last const):
2285         (WTF::ConcurrentVector::takeLast):
2286         (WTF::ConcurrentVector::append):
2287         (WTF::ConcurrentVector::alloc):
2288         (WTF::ConcurrentVector::removeLast):
2289         (WTF::ConcurrentVector::grow):
2290         (WTF::ConcurrentVector::begin):
2291         (WTF::ConcurrentVector::end):
2292         (WTF::ConcurrentVector::segmentExistsFor):
2293         (WTF::ConcurrentVector::segmentFor):
2294         (WTF::ConcurrentVector::subscriptFor):
2295         (WTF::ConcurrentVector::ensureSegmentsFor):
2296         (WTF::ConcurrentVector::ensureSegment):
2297         (WTF::ConcurrentVector::allocateSegment):
2298
2299 2017-12-12  JF Bastien  <jfbastien@apple.com>
2300
2301         makeString: support more integral types
2302         https://bugs.webkit.org/show_bug.cgi?id=180720
2303
2304         Reviewed by Sam Weinig.
2305
2306         Only some integral types worked. Add more types by using template
2307         magic. While we're here, also use the same magic for
2308         floating-point types in the theoretical future where short float
2309         or long double matter.
2310
2311         The core of the magic is a second, defaulted, template
2312         parameter. It's declared in Forward.h (as void), and then in
2313         classes where we want to enable_if we use it (in C++ speak we
2314         create a partial class template specialization), otherwise we
2315         leave it as void.
2316
2317         Also clean up some constructors which were being way too verbose
2318         in stating that they were declarations for this template
2319         specialization right here, when really we already knew that.
2320
2321         * wtf/Forward.h:
2322         * wtf/text/StringConcatenate.h:
2323         (WTF::StringTypeAdapter<char>::StringTypeAdapter<char>): Deleted.
2324         (WTF::StringTypeAdapter<char>::length): Deleted.
2325         (WTF::StringTypeAdapter<char>::is8Bit): Deleted.
2326         (WTF::StringTypeAdapter<char>::writeTo const): Deleted.
2327         (WTF::StringTypeAdapter<char>::toString const): Deleted.
2328         (WTF::StringTypeAdapter<UChar>::StringTypeAdapter<UChar>): Deleted.
2329         (WTF::StringTypeAdapter<UChar>::length const): Deleted.
2330         (WTF::StringTypeAdapter<UChar>::is8Bit const): Deleted.
2331         (WTF::StringTypeAdapter<UChar>::writeTo const): Deleted.
2332         (WTF::StringTypeAdapter<UChar>::toString const): Deleted.
2333         (WTF::StringTypeAdapter<char::StringTypeAdapter): Deleted.
2334         (WTF::StringTypeAdapter<ASCIILiteral>::StringTypeAdapter): Deleted.
2335         (WTF::StringTypeAdapter<Vector<char>>::StringTypeAdapter): Deleted.
2336         (WTF::StringTypeAdapter<Vector<char>>::length const): Deleted.
2337         (WTF::StringTypeAdapter<Vector<char>>::is8Bit const): Deleted.
2338         (WTF::StringTypeAdapter<Vector<char>>::writeTo const): Deleted.
2339         (WTF::StringTypeAdapter<Vector<char>>::toString const): Deleted.
2340         (WTF::StringTypeAdapter<String>::StringTypeAdapter<String>): Deleted.
2341         (WTF::StringTypeAdapter<String>::length const): Deleted.
2342         (WTF::StringTypeAdapter<String>::is8Bit const): Deleted.
2343         (WTF::StringTypeAdapter<String>::writeTo const): Deleted.
2344         (WTF::StringTypeAdapter<String>::toString const): Deleted.
2345         (WTF::StringTypeAdapter<AtomicString>::StringTypeAdapter): Deleted.
2346         * wtf/text/StringConcatenateNumbers.h:
2347         (WTF::StringTypeAdapter<FormattedNumber>::StringTypeAdapter):
2348         (WTF::StringTypeAdapter<int>::StringTypeAdapter<int>): Deleted.
2349         (WTF::StringTypeAdapter<int>::length const): Deleted.
2350         (WTF::StringTypeAdapter<int>::is8Bit const): Deleted.
2351         (WTF::StringTypeAdapter<int>::writeTo const): Deleted.
2352         (WTF::StringTypeAdapter<int>::toString const): Deleted.
2353         (WTF::StringTypeAdapter<unsigned>::StringTypeAdapter<unsigned>): Deleted.
2354         (WTF::StringTypeAdapter<unsigned>::length const): Deleted.
2355         (WTF::StringTypeAdapter<unsigned>::is8Bit const): Deleted.
2356         (WTF::StringTypeAdapter<unsigned>::writeTo const): Deleted.
2357         (WTF::StringTypeAdapter<unsigned>::toString const): Deleted.
2358         (WTF::StringTypeAdapter<double>::StringTypeAdapter<double>): Deleted.
2359         (WTF::StringTypeAdapter<double>::length const): Deleted.
2360         (WTF::StringTypeAdapter<double>::is8Bit const): Deleted.
2361         (WTF::StringTypeAdapter<double>::writeTo const): Deleted.
2362         (WTF::StringTypeAdapter<double>::toString const): Deleted.
2363         (WTF::StringTypeAdapter<float>::StringTypeAdapter<float>): Deleted.
2364         (WTF::StringTypeAdapter<FormattedNumber>::StringTypeAdapter<FormattedNumber>): Deleted.
2365         * wtf/text/StringView.h:
2366         (WTF::StringTypeAdapter<StringView>::StringTypeAdapter<StringView>): Deleted.
2367         (WTF::StringTypeAdapter<StringView>::length): Deleted.
2368         (WTF::StringTypeAdapter<StringView>::is8Bit): Deleted.
2369         (WTF::StringTypeAdapter<StringView>::writeTo): Deleted.
2370         (WTF::StringTypeAdapter<StringView>::toString const): Deleted.
2371
2372 2017-12-12  Caio Lima  <ticaiolima@gmail.com>
2373
2374         [ESNext][BigInt] Implement BigInt literals and JSBigInt
2375         https://bugs.webkit.org/show_bug.cgi?id=179000
2376
2377         Reviewed by Darin Adler and Yusuke Suzuki.
2378
2379         * wtf/HashFunctions.h:
2380
2381 2017-12-12  Joseph Pecoraro  <pecoraro@apple.com>
2382
2383         Symbol not found: __ZN3WTF8LockBase10unlockSlowEv
2384         https://bugs.webkit.org/show_bug.cgi?id=180691
2385
2386         Reviewed by Yusuke Suzuki.
2387
2388         * wtf/mac/DeprecatedSymbolsUsedBySafari.mm:
2389         (WTF::LockBase::lockSlow):
2390         (WTF::LockBase::unlockSlow):
2391         Add back LockBase Symbols used by System Safari on 10.13.
2392
2393 2017-12-12  Yusuke Suzuki  <utatane.tea@gmail.com>
2394
2395         [WTF] Thread::create should have Thread::tryCreate
2396         https://bugs.webkit.org/show_bug.cgi?id=180333
2397
2398         Reviewed by Darin Adler.
2399
2400         Many callers of Thread::create assume that it returns non-nullptr Thread.
2401         But if the number of threads hits the limit in the system, creating Thread
2402         would fail. In that case, it is really difficult to keep WebKit working.
2403
2404         We introduce Thread::tryCreate, and change the returned value from Thread::create
2405         from RefPtr<Thread> to Ref<Thread>. In Thread::create, we ensure thread creation
2406         succeeds by RELEASE_ASSERT. And we use Thread::create intentionally if the
2407         caller assumes that thread should be created.
2408
2409         * wtf/AutomaticThread.cpp:
2410         (WTF::AutomaticThread::start):
2411         * wtf/ParallelJobsGeneric.cpp:
2412         (WTF::ParallelEnvironment::ThreadPrivate::tryLockFor):
2413         * wtf/Threading.cpp:
2414         (WTF::Thread::tryCreate):
2415         (WTF::Thread::create): Deleted.
2416         * wtf/Threading.h:
2417         (WTF::Thread::create):
2418         * wtf/WorkQueue.cpp:
2419         (WTF::WorkQueue::concurrentApply):
2420
2421 2017-12-11  Eric Carlson  <eric.carlson@apple.com>
2422
2423         Web Inspector: Optionally log WebKit log parameters as JSON
2424         https://bugs.webkit.org/show_bug.cgi?id=180529
2425         <rdar://problem/35909462>
2426
2427         Reviewed by Joseph Pecoraro.
2428
2429         * wtf/Logger.h:
2430         (WTF::Logger::log):
2431         (WTF::LogArgument<Logger::LogSiteIdentifier>::toString):
2432
2433         * wtf/MediaTime.cpp:
2434         (WTF::MediaTime::toJSONString const): Serialize to JSON string.
2435         * wtf/MediaTime.h:
2436
2437 2017-12-11  Tim Horton  <timothy_horton@apple.com>
2438
2439         Stop using deprecated target conditional for simulator builds
2440         https://bugs.webkit.org/show_bug.cgi?id=180662
2441         <rdar://problem/35136156>
2442
2443         Reviewed by Simon Fraser.
2444
2445         * wtf/Platform.h:
2446
2447 2017-12-11  Yusuke Suzuki  <utatane.tea@gmail.com>
2448
2449         [WTF] Add Converter traits to StringHasher instead of function pointer
2450         https://bugs.webkit.org/show_bug.cgi?id=180656
2451
2452         Reviewed by JF Bastien.
2453
2454         In the latest ICU, UChar is char16_t. So defining defaultConverter(UChar)
2455         and defaultConverter(char16_t) causes duplicate definitions.
2456         Instead of passing a funtion pointer, we pass a trait class DefaultConveter
2457         which has `convert` static function. And we make this `convert` function
2458         generic. This avoids defining convert function for UChar and char16_t.
2459
2460         * wtf/text/StringHash.h:
2461         (WTF::ASCIICaseInsensitiveHash::FoldCase::convert):
2462         (WTF::ASCIICaseInsensitiveHash::hash):
2463         (WTF::ASCIICaseInsensitiveHash::foldCase): Deleted.
2464         * wtf/text/StringHasher.h:
2465         (WTF::StringHasher::DefaultConverter::convert):
2466         (WTF::StringHasher::addCharactersAssumingAligned):
2467         (WTF::StringHasher::addCharacters):
2468         (WTF::StringHasher::computeHashAndMaskTop8Bits):
2469         (WTF::StringHasher::computeHash):
2470         (WTF::StringHasher::computeLiteralHash):
2471         (WTF::StringHasher::computeLiteralHashAndMaskTop8Bits):
2472         (WTF::StringHasher::computeHashImpl):
2473         (WTF::StringHasher::Converter): Deleted.
2474         (WTF::StringHasher::defaultConverter): Deleted.
2475
2476 2017-12-10  Yusuke Suzuki  <utatane.tea@gmail.com>
2477
2478         [WTF] Reduce sizeof(Thread) by adjusting alignment
2479         https://bugs.webkit.org/show_bug.cgi?id=180630
2480
2481         Reviewed by Saam Barati.
2482
2483         Reduce sizeof(Thread) slightly by adjusting alignment.
2484
2485         * wtf/Threading.h:
2486
2487 2017-12-10  Yusuke Suzuki  <utatane.tea@gmail.com>
2488
2489         Unreviewed, follow-up patch after r225726
2490         https://bugs.webkit.org/show_bug.cgi?id=180622
2491
2492         Suggested by Darin. We should take care of signed-extension of `char`.
2493
2494         * wtf/text/StringHasher.h:
2495         (WTF::StringHasher::defaultConverter):
2496
2497 2017-12-09  Yusuke Suzuki  <utatane.tea@gmail.com>
2498
2499         [WTF] Remove RELAXED_CONSTEXPR
2500         https://bugs.webkit.org/show_bug.cgi?id=180624
2501
2502         Reviewed by JF Bastien.
2503
2504         All of our required compilers support relaxed constexpr in C++14.
2505         We can drop RELAXED_CONSTEXPR macro in our tree.
2506
2507         * wtf/Compiler.h:
2508         * wtf/Expected.h:
2509         (std::experimental::fundamentals_v3::expected::operator*):
2510         (std::experimental::fundamentals_v3::expected::value):
2511         (std::experimental::fundamentals_v3::expected::error):
2512         * wtf/Unexpected.h:
2513         (std::experimental::fundamentals_v3::unexpected::value):
2514         (std::experimental::fundamentals_v3::unexpected::value const):
2515
2516 2017-12-09  Yusuke Suzuki  <utatane.tea@gmail.com>
2517
2518         Fix WTF::Hasher tuple expansion with variadic args
2519         https://bugs.webkit.org/show_bug.cgi?id=180623
2520
2521         Reviewed by JF Bastien.
2522
2523         We expand a tuple with `...`, and use this in a function's argument list.
2524         And in this argument list, we call `add()` for each value. This will be
2525         expanded as follows.
2526
2527             [] (...) { }((add(hasher, std::get<i>(values)), 0)...);
2528
2529         will become,
2530
2531             [] (...) { }((add(hasher, std::get<0>(values)), 0), (add(hasher, std::get<1>(values)), 0), ...);
2532
2533         However, the evaluation order of the C++ argument is unspecified. Actually,
2534         in GCC environment, this `add()` is not called in our expected order. As a
2535         result, currently we have test failures in TestWTF.
2536
2537         This patch just uses variadic templates to expand tuples, and call add() in
2538         our expected order. This patch fixes an existing failure of TestWTF in GCC environment.
2539
2540         * wtf/Hasher.h:
2541         (WTF::Hasher::computeHash):
2542         (WTF::addArgs):
2543         (WTF::addTupleHelper):
2544         (WTF::add):
2545
2546 2017-12-09  Yusuke Suzuki  <utatane.tea@gmail.com>
2547
2548         Use relaxed constexpr for StringHasher
2549         https://bugs.webkit.org/show_bug.cgi?id=180622
2550
2551         Reviewed by JF Bastien.
2552
2553         Now VC++ is updated and all the WebKit compilers support C++14 relaxed constexpr.
2554         This patch uses relaxed constexpr for StringHasher constexpr implementation
2555
2556         * wtf/text/StringHasher.h:
2557         (WTF::StringHasher::addCharactersAssumingAligned):
2558         (WTF::StringHasher::Converter):
2559         (WTF::StringHasher::computeHashAndMaskTop8Bits):
2560         (WTF::StringHasher::computeHash):
2561         (WTF::StringHasher::computeLiteralHash):
2562         (WTF::StringHasher::computeLiteralHashAndMaskTop8Bits):
2563         (WTF::StringHasher::defaultConverter):
2564         (WTF::StringHasher::avalancheBits):
2565         (WTF::StringHasher::finalize):
2566         (WTF::StringHasher::finalizeAndMaskTop8Bits):
2567         (WTF::StringHasher::avoidZero):
2568         (WTF::StringHasher::calculateWithRemainingLastCharacter):
2569         (WTF::StringHasher::calculateWithTwoCharacters):
2570         (WTF::StringHasher::processPendingCharacter const):
2571         (WTF::StringHasher::StringHasher): Deleted.
2572         (WTF::StringHasher::avalancheBits3): Deleted.
2573         (WTF::StringHasher::avalancheBits2): Deleted.
2574         (WTF::StringHasher::avalancheBits1): Deleted.
2575         (WTF::StringHasher::avalancheBits0): Deleted.
2576         (WTF::StringHasher::calculateWithRemainingLastCharacter1): Deleted.
2577         (WTF::StringHasher::calculateWithRemainingLastCharacter0): Deleted.
2578         (WTF::StringHasher::calculate1): Deleted.
2579         (WTF::StringHasher::calculate0): Deleted.
2580         (WTF::StringHasher::calculate): Deleted.
2581         (WTF::StringHasher::computeLiteralHashImpl): Deleted.
2582
2583 2017-12-08  Eric Carlson  <eric.carlson@apple.com>
2584
2585         Move Logger from PAL to WTF so it can be used outside of WebCore
2586         https://bugs.webkit.org/show_bug.cgi?id=180561
2587
2588         Reviewed by Alex Christensen.
2589
2590         * WTF.xcodeproj/project.pbxproj:
2591         * wtf/Logger.h: Copied from Source/WebCore/PAL/pal/Logger.h.
2592         (PAL::LogArgument::toString): Deleted.
2593         (PAL::Logger::create): Deleted.
2594         (PAL::Logger::logAlways const): Deleted.
2595         (PAL::Logger::error const): Deleted.
2596         (PAL::Logger::warning const): Deleted.
2597         (PAL::Logger::info const): Deleted.
2598         (PAL::Logger::debug const): Deleted.
2599         (PAL::Logger::willLog const): Deleted.
2600         (PAL::Logger::enabled const): Deleted.
2601         (PAL::Logger::setEnabled): Deleted.
2602         (PAL::Logger::LogSiteIdentifier::LogSiteIdentifier): Deleted.
2603         (PAL::Logger::addObserver): Deleted.
2604         (PAL::Logger::removeObserver): Deleted.
2605         (PAL::Logger::Logger): Deleted.
2606         (PAL::Logger::log): Deleted.
2607         (PAL::Logger::observers): Deleted.
2608         (PAL::LogArgument<Logger::LogSiteIdentifier>::toString): Deleted.
2609         * wtf/LoggerHelper.h: Copied from Source/WebCore/PAL/pal/LoggerHelper.h.
2610
2611 2017-12-08  Yusuke Suzuki  <utatane.tea@gmail.com>
2612
2613         Remove pthread_once in favor of dispatch_once
2614         https://bugs.webkit.org/show_bug.cgi?id=180591
2615
2616         Reviewed by Saam Barati.
2617
2618         Fix the comment.
2619
2620         * wtf/Threading.h:
2621         (WTF::Thread::current):
2622
2623 2017-12-08  Yusuke Suzuki  <utatane.tea@gmail.com>
2624
2625         [WTF][Linux][GTK] Fix a minor bug in generic/WorkQueue when WorkQueue is immediately destroyed
2626         https://bugs.webkit.org/show_bug.cgi?id=180586
2627
2628         Reviewed by Darin Adler.
2629
2630         If WorkQueue is created and destroyed immediately, RunLoop::stop can be called
2631         befire calling RunLoop::run(). At that time WorkQueue thread is not stopped.
2632
2633         This patch dispatches a task stopping its own RunLoop to ensure stop is done.
2634         We also clean up WorkQueue implementation not to include unnecessary fields,
2635         lock, condition, and thread.
2636
2637         * wtf/WorkQueue.h:
2638         * wtf/generic/WorkQueueGeneric.cpp:
2639         (WorkQueue::platformInitialize):
2640         (WorkQueue::platformInvalidate):
2641
2642 2017-12-08  Yusuke Suzuki  <utatane.tea@gmail.com>
2643
2644         [WTF] Remove remaining use of Mutex
2645         https://bugs.webkit.org/show_bug.cgi?id=180579
2646
2647         Reviewed by Alex Christensen.
2648
2649         Mutex should be only used in low-level Locking and Threading.
2650         Other ones should use WTF::Lock and WTF::Condition instead.
2651         This patch replaces WTF::Mutex with WTF::Lock in WTF if it
2652         is not related to threading or locking implementation.
2653
2654         And we also use WTF::Lock and WTF::Condition in WTF::BinarySemaphore.
2655
2656         * wtf/RunLoop.cpp:
2657         (WTF::RunLoop::performWork):
2658         (WTF::RunLoop::dispatch):
2659         * wtf/RunLoop.h:
2660         * wtf/WorkQueue.cpp:
2661         * wtf/WorkQueue.h:
2662         * wtf/threads/BinarySemaphore.cpp:
2663         (WTF::BinarySemaphore::signal):
2664         (WTF::BinarySemaphore::wait):
2665         (WTF::BinarySemaphore::BinarySemaphore): Deleted.
2666         (WTF::BinarySemaphore::~BinarySemaphore): Deleted.
2667         * wtf/threads/BinarySemaphore.h:
2668         * wtf/win/WorkQueueWin.cpp:
2669         (WTF::WorkQueue::registerHandle):
2670         (WTF::WorkQueue::unregisterAndCloseHandle):
2671         (WTF::WorkQueue::dispatch):
2672         (WTF::WorkQueue::timerCallback):
2673         (WTF::WorkQueue::dispatchAfter):
2674         (WTF::TimerContext::TimerContext): Deleted.
2675
2676 2017-12-08  Yusuke Suzuki  <utatane.tea@gmail.com>
2677
2678         Use StaticLock and Lock instead of Mutex in Windows WebKitLegacy
2679         https://bugs.webkit.org/show_bug.cgi?id=180572
2680
2681         Reviewed by Mark Lam.
2682
2683         Remove DEPRECATED_DEFINE_STATIC_LOCAL since it's no longer used.
2684
2685         * wtf/StdLibExtras.h:
2686
2687 2017-12-07  Basuke Suzuki  <Basuke.Suzuki@sony.com>
2688
2689         [Win] [64-bit] Resolve Microsoft warning C4319 on BitVector.cpp
2690         https://bugs.webkit.org/show_bug.cgi?id=180490
2691
2692         Reviewed by Alex Christensen.
2693
2694         bitsInPointer() returns unsigned which is smaller than size_t.
2695         "~"(negate) operator is applied before extending its size which result filled with zero.
2696         This may be potentially a bug if numBits is greater than max value of unsigned long
2697         (which is not practical).
2698
2699         * wtf/BitVector.cpp:
2700         (WTF::BitVector::OutOfLineBits::create):
2701
2702 2017-12-07  Yusuke Suzuki  <utatane.tea@gmail.com>
2703
2704         Use WTF Locking primitives in WebThread and drop pthread_xxx use
2705         https://bugs.webkit.org/show_bug.cgi?id=180445
2706
2707         Reviewed by Saam Barati.
2708
2709         Add initializer form to fill struct with zero if struct does not have any default initializers.
2710
2711         * wtf/ThreadSpecific.h:
2712         (WTF::ThreadSpecific::Data::Data):
2713
2714 2017-12-07  Mark Lam  <mark.lam@apple.com>
2715
2716         Apply poisoning to some native code pointers.
2717         https://bugs.webkit.org/show_bug.cgi?id=180541
2718         <rdar://problem/35916875>
2719
2720         Reviewed by Filip Pizlo.
2721
2722         Ensure that the resultant poisoned bits still looks like a pointer in that its
2723         bottom bits are 0, just like the alignment bits of a pointer.  This allows the
2724         client to use the bottom bits of the poisoned bits as flag bits just like the
2725         client was previously able to do with pointer values.
2726
2727         Note: we only ensure that the bottom alignment bits of the generated poison
2728         value is 0.  We're not masking out the poisoned bits.  This means that the bottom
2729         bits of the poisoned bits will only be null if the original pointer is aligned.
2730         Hence, if the client applies the poison to an unaligned pointer, we do not lose
2731         any information on the low bits.
2732
2733         Also removed 2 wrong assertions in PoisonedImpl's constructors.  We were
2734         asserting that Poisoned will never be used with a null value, but that's invalid.
2735         We do want to allow a null value so that we don't have to constantly do null
2736         checks in the clients.  This was uncovered by some layout tests.
2737
2738         * wtf/Poisoned.cpp:
2739         (WTF::makePoison):
2740         * wtf/Poisoned.h:
2741         (WTF::PoisonedImpl::PoisonedImpl):
2742
2743 2017-12-07  Mark Lam  <mark.lam@apple.com>
2744
2745         [Re-landing r225620] Refactoring: Rename ScrambledPtr to Poisoned.
2746         https://bugs.webkit.org/show_bug.cgi?id=180514
2747
2748         Reviewed by Saam Barati and JF Bastien.
2749
2750         Re-landing r225620 with speculative build fix for GCC 7.
2751
2752         * WTF.xcodeproj/project.pbxproj:
2753         * wtf/CMakeLists.txt:
2754         * wtf/Poisoned.cpp: Copied from Source/WTF/wtf/ScrambledPtr.cpp.
2755         (WTF::makePoison):
2756         (WTF::makeScrambledPtrKey): Deleted.
2757         * wtf/Poisoned.h: Copied from Source/WTF/wtf/ScrambledPtr.h.
2758         (WTF::PoisonedImpl::PoisonedImpl):
2759         (WTF::PoisonedImpl::assertIsPoisoned const):
2760         (WTF::PoisonedImpl::assertIsNotPoisoned const):
2761         (WTF::PoisonedImpl::unpoisoned const):
2762         (WTF::PoisonedImpl::operator-> const):
2763         (WTF::PoisonedImpl::bits const):
2764         (WTF::PoisonedImpl::operator! const):
2765         (WTF::PoisonedImpl::operator bool const):
2766         (WTF::PoisonedImpl::operator== const):
2767         (WTF::PoisonedImpl::operator==):
2768         (WTF::PoisonedImpl::operator=):
2769         (WTF::PoisonedImpl::poison):
2770         (WTF::PoisonedImpl::unpoison):
2771         (WTF::ScrambledPtr::ScrambledPtr): Deleted.
2772         (WTF::ScrambledPtr::assertIsScrambled const): Deleted.
2773         (WTF::ScrambledPtr::assertIsNotScrambled const): Deleted.
2774         (WTF::ScrambledPtr::descrambled const): Deleted.
2775         (WTF::ScrambledPtr::operator-> const): Deleted.
2776         (WTF::ScrambledPtr::bits const): Deleted.
2777         (WTF::ScrambledPtr::operator! const): Deleted.
2778         (WTF::ScrambledPtr::operator bool const): Deleted.
2779         (WTF::ScrambledPtr::operator== const): Deleted.
2780         (WTF::ScrambledPtr::operator==): Deleted.
2781         (WTF::ScrambledPtr::operator=): Deleted.
2782         (WTF::ScrambledPtr::scramble): Deleted.
2783         (WTF::ScrambledPtr::descramble): Deleted.
2784         * wtf/ScrambledPtr.cpp: Removed.
2785         * wtf/ScrambledPtr.h: Removed.
2786
2787 2017-12-07  Michael Catanzaro  <mcatanzaro@igalia.com>
2788
2789         Unreviewed, rolling out r225620
2790         https://bugs.webkit.org/show_bug.cgi?id=180514
2791         <rdar://problem/35901694>
2792
2793         It broke the build with GCC 7, and I don't know how to fix it.
2794
2795         * WTF.xcodeproj/project.pbxproj:
2796         * wtf/CMakeLists.txt:
2797         * wtf/Poisoned.h: Removed.
2798         * wtf/ScrambledPtr.cpp: Renamed from Source/WTF/wtf/Poisoned.cpp.
2799         (WTF::makeScrambledPtrKey):
2800         * wtf/ScrambledPtr.h: Added.
2801         (WTF::ScrambledPtr::ScrambledPtr):
2802         (WTF::ScrambledPtr::assertIsScrambled const):
2803         (WTF::ScrambledPtr::assertIsNotScrambled const):
2804         (WTF::ScrambledPtr::descrambled const):
2805         (WTF::ScrambledPtr::operator-> const):
2806         (WTF::ScrambledPtr::bits const):
2807         (WTF::ScrambledPtr::operator! const):
2808         (WTF::ScrambledPtr::operator bool const):
2809         (WTF::ScrambledPtr::operator== const):
2810         (WTF::ScrambledPtr::operator==):
2811         (WTF::ScrambledPtr::operator=):
2812         (WTF::ScrambledPtr::scramble):
2813         (WTF::ScrambledPtr::descramble):
2814
2815 2017-12-06  Mark Lam  <mark.lam@apple.com>
2816
2817         Refactoring: Rename ScrambledPtr to Poisoned.
2818         https://bugs.webkit.org/show_bug.cgi?id=180514
2819
2820         Reviewed by Saam Barati.
2821
2822         We're switching our nomenclature to "poisoning" instead of "scrambling" pointers.
2823         This allows us to use shorter names.
2824
2825         This patch is almost purely refactoring, except for one change: the PoisonedImpl
2826         template class (previously ScrambledPtr) has been modified to allow usage of
2827         a constexpr uint32_t poison value (see Int32Poisoned) in addition to a runtime
2828         determined uintptr_t poison value (see Poisoned).
2829
2830         * WTF.xcodeproj/project.pbxproj:
2831         * wtf/CMakeLists.txt:
2832         * wtf/Poisoned.cpp: Copied from Source/WTF/wtf/ScrambledPtr.cpp.
2833         (WTF::makePoison):
2834         (WTF::makeScrambledPtrKey): Deleted.
2835         * wtf/Poisoned.h: Copied from Source/WTF/wtf/ScrambledPtr.h.
2836         (WTF::PoisonedImpl::PoisonedImpl):
2837         (WTF::PoisonedImpl::assertIsPoisoned const):
2838         (WTF::PoisonedImpl::assertIsNotPoisoned const):
2839         (WTF::PoisonedImpl::unpoisoned const):
2840         (WTF::PoisonedImpl::operator-> const):
2841         (WTF::PoisonedImpl::bits const):
2842         (WTF::PoisonedImpl::operator! const):
2843         (WTF::PoisonedImpl::operator bool const):
2844         (WTF::PoisonedImpl::operator== const):
2845         (WTF::PoisonedImpl::operator==):
2846         (WTF::PoisonedImpl::operator=):
2847         (WTF::PoisonedImpl::poison):
2848         (WTF::PoisonedImpl::unpoison):
2849         (WTF::ScrambledPtr::ScrambledPtr): Deleted.
2850         (WTF::ScrambledPtr::assertIsScrambled const): Deleted.
2851         (WTF::ScrambledPtr::assertIsNotScrambled const): Deleted.
2852         (WTF::ScrambledPtr::descrambled const): Deleted.
2853         (WTF::ScrambledPtr::operator-> const): Deleted.
2854         (WTF::ScrambledPtr::bits const): Deleted.
2855         (WTF::ScrambledPtr::operator! const): Deleted.
2856         (WTF::ScrambledPtr::operator bool const): Deleted.
2857         (WTF::ScrambledPtr::operator== const): Deleted.
2858         (WTF::ScrambledPtr::operator==): Deleted.
2859         (WTF::ScrambledPtr::operator=): Deleted.
2860         (WTF::ScrambledPtr::scramble): Deleted.
2861         (WTF::ScrambledPtr::descramble): Deleted.
2862         * wtf/ScrambledPtr.cpp: Removed.
2863         * wtf/ScrambledPtr.h: Removed.
2864
2865 2017-12-02  Darin Adler  <darin@apple.com>
2866
2867         Modernize some aspects of text codecs, eliminate WebKit use of strcasecmp
2868         https://bugs.webkit.org/show_bug.cgi?id=180009
2869
2870         Reviewed by Alex Christensen.
2871
2872         * wtf/Assertions.cpp: Removed include of StringExtras.h.
2873         (WTFLogChannelByName): Use equalIgnoringASCIICase instead of strcasecmp.
2874         * wtf/DateMath.cpp: Removed include of StringExtras.h.
2875         * wtf/MD5.cpp: Ditto. Also removed include of CString.h.
2876         * wtf/SHA1.cpp: Ditto.
2877
2878         * wtf/StringExtras.h:
2879         (strncasecmp): Deleted.
2880         (strcasecmp): Deleted.
2881
2882         * wtf/StringPrintStream.cpp: Removed include of StringExtras.h.
2883         * wtf/text/Base64.cpp: Ditto.
2884
2885         * wtf/text/LineEnding.cpp:
2886         (WTF::normalizeLineEndingsToLF): Replaced old more general purpose function with
2887         this. Changed argument type to vector and used an rvalue reference and return value.
2888         Also fixed some small logic errors.
2889         (WTF::normalizeLineEndingsToCRLF): Ditto.
2890         (WTF::normalizeLineEndingsToNative): Updated for above changes.
2891         * wtf/text/LineEnding.h: Updated for above changes.
2892
2893         * wtf/text/StringCommon.h:
2894         (WTF::equalIgnoringASCIICase): Added overload for const char*.
2895         (WTF::equalLettersIgnoringASCIICase): Ditto.
2896
2897         * wtf/text/TextStream.cpp: Removed include of StringExtras.h.
2898         * wtf/text/WTFString.cpp: Ditto.
2899         * wtf/unicode/icu/CollatorICU.cpp: Ditto.
2900
2901 2017-12-06  Yusuke Suzuki  <utatane.tea@gmail.com>
2902
2903         [WTF] Remove XXXLockBase since constexpr constructor can initialize static variables without calling global constructors
2904         https://bugs.webkit.org/show_bug.cgi?id=180495
2905
2906         Reviewed by Mark Lam.
2907
2908         Very nice feature of C++11 is that constexpr constructor can initialize static global variables
2909         without calling global constructors. We do not need to have XXXLockBase with derived XXXLock
2910         class since StaticXXXLock can have constructors as long as it is constexpr.
2911         We remove bunch of these classes, and set `XXXLock() = default;` explicitly for readability.
2912         C++11's default constructor is constexpr as long as its member's default constructor / default
2913         initializer is constexpr.
2914
2915         * wtf/Condition.h:
2916         (WTF::ConditionBase::construct): Deleted.
2917         (WTF::ConditionBase::waitUntil): Deleted.
2918         (WTF::ConditionBase::waitFor): Deleted.
2919         (WTF::ConditionBase::wait): Deleted.
2920         (WTF::ConditionBase::notifyOne): Deleted.
2921         (WTF::ConditionBase::notifyAll): Deleted.
2922         (WTF::Condition::Condition): Deleted.
2923         * wtf/CountingLock.h:
2924         (WTF::CountingLock::CountingLock): Deleted.
2925         (WTF::CountingLock::~CountingLock): Deleted.
2926         * wtf/Lock.cpp:
2927         (WTF::Lock::lockSlow):
2928         (WTF::Lock::unlockSlow):
2929         (WTF::Lock::unlockFairlySlow):
2930         (WTF::Lock::safepointSlow):
2931         (WTF::LockBase::lockSlow): Deleted.
2932         (WTF::LockBase::unlockSlow): Deleted.
2933         (WTF::LockBase::unlockFairlySlow): Deleted.
2934         (WTF::LockBase::safepointSlow): Deleted.
2935         * wtf/Lock.h:
2936         (WTF::LockBase::construct): Deleted.
2937         (WTF::LockBase::lock): Deleted.
2938         (WTF::LockBase::tryLock): Deleted.
2939         (WTF::LockBase::try_lock): Deleted.
2940         (WTF::LockBase::unlock): Deleted.
2941         (WTF::LockBase::unlockFairly): Deleted.
2942         (WTF::LockBase::safepoint): Deleted.
2943         (WTF::LockBase::isHeld const): Deleted.
2944         (WTF::LockBase::isLocked const): Deleted.
2945         (WTF::LockBase::isFullyReset const): Deleted.
2946         (WTF::Lock::Lock): Deleted.
2947         * wtf/ReadWriteLock.cpp:
2948         (WTF::ReadWriteLock::readLock):
2949         (WTF::ReadWriteLock::readUnlock):
2950         (WTF::ReadWriteLock::writeLock):
2951         (WTF::ReadWriteLock::writeUnlock):
2952         (WTF::ReadWriteLockBase::construct): Deleted.
2953         (WTF::ReadWriteLockBase::readLock): Deleted.
2954         (WTF::ReadWriteLockBase::readUnlock): Deleted.
2955         (WTF::ReadWriteLockBase::writeLock): Deleted.
2956         (WTF::ReadWriteLockBase::writeUnlock): Deleted.
2957         * wtf/ReadWriteLock.h:
2958         (WTF::ReadWriteLock::read):
2959         (WTF::ReadWriteLock::write):
2960         (WTF::ReadWriteLockBase::ReadLock::tryLock): Deleted.
2961         (WTF::ReadWriteLockBase::ReadLock::lock): Deleted.
2962         (WTF::ReadWriteLockBase::ReadLock::unlock): Deleted.
2963         (WTF::ReadWriteLockBase::WriteLock::tryLock): Deleted.
2964         (WTF::ReadWriteLockBase::WriteLock::lock): Deleted.
2965         (WTF::ReadWriteLockBase::WriteLock::unlock): Deleted.
2966         (WTF::ReadWriteLockBase::read): Deleted.
2967         (WTF::ReadWriteLockBase::write): Deleted.
2968         (WTF::ReadWriteLock::ReadWriteLock): Deleted.
2969         * wtf/RecursiveLockAdapter.h:
2970         (WTF::RecursiveLockAdapter::RecursiveLockAdapter): Deleted.
2971         * wtf/WordLock.cpp:
2972         (WTF::WordLock::lockSlow):
2973         (WTF::WordLock::unlockSlow):
2974         (WTF::WordLockBase::lockSlow): Deleted.
2975         (WTF::WordLockBase::unlockSlow): Deleted.
2976         * wtf/WordLock.h:
2977         (WTF::WordLockBase::lock): Deleted.
2978         (WTF::WordLockBase::unlock): Deleted.
2979         (WTF::WordLockBase::isHeld const): Deleted.
2980         (WTF::WordLockBase::isLocked const): Deleted.
2981         (WTF::WordLockBase::isFullyReset const): Deleted.
2982         (WTF::WordLock::WordLock): Deleted.
2983         * wtf/WorkQueue.cpp:
2984
2985 2017-12-05  Stephan Szabo  <stephan.szabo@sony.com>
2986
2987         Switch windows build to Visual Studio 2017
2988         https://bugs.webkit.org/show_bug.cgi?id=172412
2989
2990         Reviewed by Per Arne Vollan.
2991
2992         * WTF.vcxproj/WTF.proj:
2993         * wtf/Compiler.h:
2994
2995 2017-12-05  Andy Estes  <aestes@apple.com>
2996
2997         [Darwin] Simplify use of TargetConditionals
2998         https://bugs.webkit.org/show_bug.cgi?id=180455
2999         <rdar://problem/35142971>
3000
3001         Reviewed by Tim Horton.
3002
3003         There's no need to check if TARGET_* macros are defined on Darwin platforms, since
3004         TargetConditionals.h always defines them. Also, we can simplify
3005         (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR) to TARGET_OS_IPHONE.
3006
3007         * wtf/Platform.h:
3008
3009 2017-12-05  Matt Lewis  <jlewis3@apple.com>
3010
3011         Unreviewed, rolling out r225430.
3012
3013         This caused an API failure on release.
3014
3015         Reverted changeset:
3016
3017         "Move DateComponents into WTF"
3018         https://bugs.webkit.org/show_bug.cgi?id=180211
3019         https://trac.webkit.org/changeset/225430
3020
3021 2017-12-05  Michael Saboff  <msaboff@apple.com>
3022
3023         Make WebKit build for ARM64_32
3024         https://bugs.webkit.org/show_bug.cgi?id=180447
3025
3026         Reviewed by Mark Lam.
3027
3028         Add the 'w' (32bit) pointer qualifier for ARM64_32 pointers in inline assembly.
3029
3030         * wtf/darwin/WeakLinking.h:
3031         (WTF::isNullFunctionPointer):
3032
3033 2017-12-05  Filip Pizlo  <fpizlo@apple.com>
3034
3035         bmalloc IsoHeap needs to allow a thread to deallocate some size for the first time
3036         https://bugs.webkit.org/show_bug.cgi?id=180443
3037
3038         Reviewed by Saam Barati.
3039         
3040         With this change it's possible to reenable isoheaps on iOS.
3041
3042         * wtf/IsoMalloc.h:
3043         * wtf/IsoMallocInlines.h:
3044
3045 2017-12-05  Yusuke Suzuki  <utatane.tea@gmail.com>
3046
3047         [WTF] Remove m_atomicStringTableDestructor in Thread by querying the condition at thread destruction
3048         https://bugs.webkit.org/show_bug.cgi?id=180429
3049
3050         Reviewed by Alex Christensen.
3051
3052         We now have a pointer to the AtomicStringTable::destroy in Thread.
3053         This pointer becomes nullptr only when the thread is the web thread not to destroy AtomicStringTable
3054         twice in the UI thread and the web thread.
3055
3056         Instead of having a pointer in each Thread, we query whether the current thread is the web thread at
3057         Thread destruction. And use this information to call AtomicStringTable::destroy. Then, we can drop
3058         m_atomicStringTableDestructor field in Thread.
3059
3060         * wtf/Threading.cpp:
3061         (WTF::Thread::didExit):
3062         * wtf/Threading.h:
3063         * wtf/mac/MainThreadMac.mm:
3064         * wtf/text/AtomicStringTable.cpp:
3065         (WTF::AtomicStringTable::create):
3066         (WTF::AtomicStringTable::destroy):
3067         * wtf/text/AtomicStringTable.h:
3068
3069 2017-12-01  Filip Pizlo  <fpizlo@apple.com>
3070
3071         GC constraint solving should be parallel
3072         https://bugs.webkit.org/show_bug.cgi?id=179934
3073
3074         Reviewed by JF Bastien.
3075         
3076         This does some changes to make it easier to do parallel constraint solving:
3077         
3078         - I finally removed dependencyWith. This was a silly construct whose only purpose is to confuse
3079           people about what it means to have a dependency chain. I took that as an opportunity to grealy
3080           simplify the GC's use of dependency chaining.
3081         
3082         - Added more logic to Deque<>, since I use it for part of the load balancer.
3083         
3084         - Made it possible to profile lock contention. See
3085           https://bugs.webkit.org/show_bug.cgi?id=180250#c0 for some preliminary measurements.
3086         
3087         - Introduced holdLockIf, which makes it easy to perform predicated lock acquisition. We use that
3088           to pick a lock in WebCore.
3089         
3090         - Introduced CountingLock. It's like WTF::Lock except it also enables optimistic read transactions
3091           sorta like Java's StampedLock.
3092
3093         * WTF.xcodeproj/project.pbxproj:
3094         * wtf/Atomics.h:
3095         (WTF::dependency):
3096         (WTF::DependencyWith::DependencyWith): Deleted.
3097         (WTF::dependencyWith): Deleted.
3098         * wtf/BitVector.h:
3099         (WTF::BitVector::iterator::operator++):
3100         * wtf/CMakeLists.txt:
3101         * wtf/ConcurrentPtrHashSet.cpp: Added.
3102         (WTF::ConcurrentPtrHashSet::ConcurrentPtrHashSet):
3103         (WTF::ConcurrentPtrHashSet::~ConcurrentPtrHashSet):
3104         (WTF::ConcurrentPtrHashSet::deleteOldTables):
3105         (WTF::ConcurrentPtrHashSet::clear):
3106         (WTF::ConcurrentPtrHashSet::initialize):
3107         (WTF::ConcurrentPtrHashSet::addSlow):
3108         (WTF::ConcurrentPtrHashSet::resizeIfNecessary):
3109         (WTF::ConcurrentPtrHashSet::resizeAndAdd):
3110         (WTF::ConcurrentPtrHashSet::Table::create):
3111         * wtf/ConcurrentPtrHashSet.h: Added.
3112         (WTF::ConcurrentPtrHashSet::contains):
3113         (WTF::ConcurrentPtrHashSet::add):
3114         (WTF::ConcurrentPtrHashSet::size const):
3115         (WTF::ConcurrentPtrHashSet::Table::maxLoad const):
3116         (WTF::ConcurrentPtrHashSet::hash):
3117         (WTF::ConcurrentPtrHashSet::cast):
3118         (WTF::ConcurrentPtrHashSet::containsImpl const):
3119         (WTF::ConcurrentPtrHashSet::addImpl):
3120         * wtf/Deque.h:
3121         (WTF::inlineCapacity>::takeFirst):
3122         * wtf/FastMalloc.h:
3123         * wtf/Lock.cpp:
3124         (WTF::LockBase::lockSlow):
3125         * wtf/Locker.h:
3126         (WTF::holdLockIf):
3127         * wtf/ScopedLambda.h:
3128         * wtf/SharedTask.h:
3129         (WTF::SharedTask<PassedResultType):
3130         (WTF::SharedTask<ResultType): Deleted.
3131         * wtf/StackShot.h: Added.
3132         (WTF::StackShot::StackShot):
3133         (WTF::StackShot::operator=):
3134         (WTF::StackShot::array const):
3135         (WTF::StackShot::size const):
3136         (WTF::StackShot::operator bool const):
3137         (WTF::StackShot::operator== const):
3138         (WTF::StackShot::hash const):
3139         (WTF::StackShot::isHashTableDeletedValue const):
3140         (WTF::StackShot::operator> const):
3141         (WTF::StackShot::deletedValueArray):
3142         (WTF::StackShotHash::hash):
3143         (WTF::StackShotHash::equal):
3144         * wtf/StackShotProfiler.h: Added.
3145         (WTF::StackShotProfiler::StackShotProfiler):
3146         (WTF::StackShotProfiler::profile):
3147         (WTF::StackShotProfiler::run):
3148
3149 2017-12-05  Yusuke Suzuki  <utatane.tea@gmail.com>
3150
3151         [WTF] Use m_suspendCount instead of m_suspended flag in Thread
3152         https://bugs.webkit.org/show_bug.cgi?id=180427
3153
3154         Reviewed by Carlos Garcia Campos.
3155
3156         When resuming the thread, signal handler is reinvoked once before `sigsuspend` is resumed.
3157         But this handler should not do anything since it is just a signal for `sigsuspend`.
3158         Previously, we use m_suspenedd flag to distinguish between suspending and resuming signal
3159         handler invocations.
3160
3161         But this additional m_suspended flag is not necessary since we can use m_suspendCount instead.
3162         This patch drops m_suspended and use m_suspendCount. Since semaphore operations emit full memory
3163         barrier, m_suspendCount is loaded and stored as we expect.
3164
3165         * wtf/Threading.h:
3166         * wtf/ThreadingPthreads.cpp:
3167         (WTF::Thread::signalHandlerSuspendResume):
3168         (WTF::Thread::suspend):
3169         (WTF::Thread::resume):
3170
3171 2017-12-04  Simon Fraser  <simon.fraser@apple.com>
3172
3173         Minor DisplayRefreshMonitor-related cleanup
3174         https://bugs.webkit.org/show_bug.cgi?id=179802
3175
3176         Reviewed by Sam Weinig.
3177
3178         New trace point for when the CVDisplayLink fires on its own thread.
3179
3180         * wtf/SystemTracing.h:
3181
3182 2017-12-04  JF Bastien  <jfbastien@apple.com>
3183
3184         Update std::expected to match libc++ coding style
3185         https://bugs.webkit.org/show_bug.cgi?id=180264
3186
3187         Reviewed by Alex Christensen.
3188
3189         As of https://wg21.link/p0323r4 std::expected is on its way to the
3190         Library Fundamentals v3 TS (LEWG and EWG voted for this, but LWG
3191         hasn't done wording review yet, hence "on its way"). The API is
3192         therefore pretty close to what will be in the TS, and I've gotten
3193         requests for an easily usable implementation of std::expected. I
3194         talked to our clang team and they'll help me migrate our
3195         implementation to libc++, but our implementation has to look more
3196         like libc++ than it does now. Once in libc++ I'll maintain changes
3197         on both sides to make sure neither is out-of-date for too long.
3198
3199         - Fork std::unexpected into its own header.
3200         - Add mild support for an exception-based implementation, but
3201           don't do noexcept yet.
3202         - Rename everything to follow STL style, and keep a global using
3203           or variable alias where possible to reduce WebKit code churn.
3204         - Minor API updates to remove things that aren't in the proposal
3205           anymore.
3206
3207         * wtf/Expected.h:
3208         (std::experimental::fundamentals_v3::bad_expected_access<void>::bad_expected_access):
3209         (std::experimental::fundamentals_v3::bad_expected_access::bad_expected_access):
3210         (std::experimental::fundamentals_v3::bad_expected_access::error):
3211         (std::experimental::fundamentals_v3::bad_expected_access::error const):
3212         (std::experimental::fundamentals_v3::__expected_detail::constexpr_base::constexpr_base):
3213         (std::experimental::fundamentals_v3::__expected_detail::base::base):
3214         (std::experimental::fundamentals_v3::__expected_detail::base::~base):
3215         (std::experimental::fundamentals_v3::expected::expected):
3216         (std::experimental::fundamentals_v3::expected::operator=):
3217         (std::experimental::fundamentals_v3::expected::swap):
3218         (std::experimental::fundamentals_v3::expected::operator-> const):
3219         (std::experimental::fundamentals_v3::expected::operator->):
3220         (std::experimental::fundamentals_v3::expected::operator* const):
3221         (std::experimental::fundamentals_v3::expected::operator*):
3222         (std::experimental::fundamentals_v3::expected::has_value const):
3223         (std::experimental::fundamentals_v3::expected::value const):
3224         (std::experimental::fundamentals_v3::expected::value):
3225         (std::experimental::fundamentals_v3::expected::error const):
3226         (std::experimental::fundamentals_v3::expected::error):
3227         (std::experimental::fundamentals_v3::expected::value_or const):
3228         (std::experimental::fundamentals_v3::expected::value_or):
3229         (std::experimental::fundamentals_v3::operator==):
3230         (std::experimental::fundamentals_v3::operator!=):
3231         (std::experimental::fundamentals_v3::swap):
3232         (WTF::Unexpected::Unexpected): Deleted.
3233         (WTF::Unexpected::value const): Deleted.
3234         (WTF::Unexpected::value): Deleted.
3235         (WTF::operator==): Deleted.
3236         (WTF::operator!=): Deleted.
3237         (WTF::makeUnexpected): Deleted.
3238         (WTF::ExpectedDetail::Throw): Deleted.
3239         (WTF::ExpectedDetail::destroy): Deleted.
3240         (WTF::ExpectedDetail::std::is_trivially_destructible<T>::value): Deleted.
3241         (WTF::ExpectedDetail::ConstexprBase::ConstexprBase): Deleted.
3242         (WTF::ExpectedDetail::Base::Base): Deleted.
3243         (WTF::ExpectedDetail::Base::~Base): Deleted.
3244         (WTF::Expected::Expected): Deleted.
3245         (WTF::Expected::operator=): Deleted.
3246         (WTF::Expected::swap): Deleted.
3247         (WTF::Expected::operator-> const): Deleted.
3248         (WTF::Expected::operator->): Deleted.
3249         (WTF::Expected::operator* const): Deleted.
3250         (WTF::Expected::operator*): Deleted.
3251         (WTF::Expected::operator bool const): Deleted.
3252         (WTF::Expected::hasValue const): Deleted.
3253         (WTF::Expected::value const): Deleted.
3254         (WTF::Expected::value): Deleted.
3255         (WTF::Expected::error const): Deleted.
3256         (WTF::Expected::error): Deleted.
3257         (WTF::Expected::getUnexpected const): Deleted.
3258         (WTF::Expected::valueOr const): Deleted.
3259         (WTF::Expected::valueOr): Deleted.
3260         (WTF::swap): Deleted.
3261         (WTF::makeExpected): Deleted.
3262         (WTF::makeExpectedFromError): Deleted.
3263         * wtf/Forward.h:
3264         * wtf/Optional.h:
3265         * wtf/StdLibExtras.h:
3266         * wtf/Unexpected.h: Added.
3267         (std::experimental::fundamentals_v3::unexpected::unexpected):
3268         (std::experimental::fundamentals_v3::unexpected::value const):
3269         (std::experimental::fundamentals_v3::unexpected::value):
3270         (std::experimental::fundamentals_v3::operator==):
3271         (std::experimental::fundamentals_v3::operator!=):
3272         (makeUnexpected):
3273
3274 2017-12-03  Tomas Popela  <tpopela@redhat.com>
3275
3276         Build fails on x86_64 and arm64 with BMalloc disabled
3277         https://bugs.webkit.org/show_bug.cgi?id=180188
3278
3279         Reviewed by Carlos Garcia Campos.
3280
3281         Add missing methods in WTF's Gigacage.h and fix g_gigacageBasePtr
3282         definition.
3283
3284         * wtf/Gigacage.cpp:
3285         * wtf/Gigacage.h:
3286         (Gigacage::basePtr):
3287         (Gigacage::isEnabled):
3288
3289 2017-12-03  Yusuke Suzuki  <utatane.tea@gmail.com>
3290
3291         WTF shouldn't have both Thread and ThreadIdentifier
3292         https://bugs.webkit.org/show_bug.cgi?id=180308
3293
3294         Reviewed by Darin Adler.
3295
3296         We should use a pointer of WTF::Thread instead of ThreadIdentifier.
3297
3298         One problem is that Windows support library uses WTF::createThread,
3299         which returns ThreadIdentifier. So we cannot drop ThreadIdentifier
3300         in Windows environment. This patch keeps ThreadIdentifier in Windows.
3301
3302         * wtf/MainThread.cpp:
3303         (WTF::initializeMainThread):
3304         (WTF::isMainThread):
3305         (WTF::canAccessThreadLocalDataForThread):
3306         * wtf/MainThread.h:
3307         * wtf/ParkingLot.cpp:
3308         (WTF::ParkingLot::parkConditionallyImpl):
3309         (WTF::ParkingLot::unparkOne):
3310         (WTF::ParkingLot::unparkOneImpl):
3311         (WTF::ParkingLot::unparkCount):
3312         * wtf/RecursiveLockAdapter.h:
3313         (WTF::RecursiveLockAdapter::lock):
3314         (WTF::RecursiveLockAdapter::unlock):
3315         (WTF::RecursiveLockAdapter::tryLock):
3316         * wtf/Threading.cpp:
3317         (WTF::Thread::dump const):
3318         * wtf/Threading.h:
3319         (WTF::Thread::id const):
3320         (WTF::Thread::operator==): Deleted.
3321         (WTF::Thread::operator!=): Deleted.
3322         (WTF::currentThread): Deleted.
3323         * wtf/ThreadingPrimitives.h:
3324         * wtf/ThreadingPthreads.cpp:
3325         (WTF::Thread::waitForCompletion):
3326         (WTF::Thread::detach):
3327         (WTF::Thread::initializeCurrentTLS):
3328         (WTF::Thread::suspend):
3329         (WTF::Thread::establishPlatformSpecificHandle):
3330         (WTF::Thread::currentID): Deleted.
3331         * wtf/ThreadingWin.cpp:
3332         (WTF::Thread::waitForCompletion):
3333         (WTF::Thread::suspend):
3334         (WTF::Thread::currentDying):
3335         * wtf/mac/MainThreadMac.mm:
3336         (WTF::initializeApplicationUIThread):
3337         (WTF::initializeWebThreadPlatform):
3338         (WTF::canAccessThreadLocalDataForThread):
3339         (WTF::initializeApplicationUIThreadIdentifier): Deleted.
3340         (WTF::initializeWebThreadIdentifier): Deleted.
3341
3342 2017-12-03  Darin Adler  <darin@apple.com>
3343
3344         Add WTF::Hasher, an easier to use replacement for WTF::IntegerHasher
3345         https://bugs.webkit.org/show_bug.cgi?id=180318
3346
3347         Reviewed by JF Bastien.
3348
3349         * WTF.xcodeproj/project.pbxproj: Added Hasher.h.
3350         * wtf/CMakeLists.txt: Ditto.
3351
3352         * wtf/Forward.h: Added Hasher and TextStream.
3353
3354         * wtf/Hasher.h: Moved StringHasher into a separate header. Added Hasher.
3355         Marked IntegerHasher deprecated.
3356
3357         * wtf/text/CString.cpp: Include StringHasher.h instead of Hasher.h.
3358         * wtf/text/StringHash.h: Ditto.
3359
3360         * wtf/text/StringHasher.h: Added. Moved StringHasher here from Hasher.h.
3361
3362         * wtf/text/StringImpl.h: Include StringHasher.h instead of Hasher.h.
3363
3364         * wtf/text/WTFString.h: Added a hash function. This was useful in some
3365         adoption I was doing in WebCore, not included in this patch.
3366
3367         * wtf/unicode/UTF8.cpp: Include StringHasher.h instead of Hasher.h.
3368
3369 2017-12-02  Brady Eidson  <beidson@apple.com>
3370
3371         Factor out the "databaseTaskQueue" parts of IDBServer into something reusable.
3372         https://bugs.webkit.org/show_bug.cgi?id=180298
3373
3374         Reviewed by Chris Dumez.
3375
3376         * WTF.xcodeproj/project.pbxproj:
3377         * wtf/CMakeLists.txt:
3378
3379         * wtf/CrossThreadTaskHandler.cpp: Added.
3380         (WTF::CrossThreadTaskHandler::CrossThreadTaskHandler):
3381         (WTF::CrossThreadTaskHandler::~CrossThreadTaskHandler):
3382         (WTF::CrossThreadTaskHandler::postTask):
3383         (WTF::CrossThreadTaskHandler::postTaskReply):
3384         (WTF::CrossThreadTaskHandler::taskRunLoop):
3385         (WTF::CrossThreadTaskHandler::handleTaskRepliesOnMainThread):
3386         * wtf/CrossThreadTaskHandler.h: Added.
3387
3388 2017-12-01  Mark Lam  <mark.lam@apple.com>
3389
3390         Let's scramble ClassInfo pointers in cells.
3391         https://bugs.webkit.org/show_bug.cgi?id=180291
3392         <rdar://problem/35807620>
3393
3394         Reviewed by JF Bastien.
3395
3396         * wtf/ScrambledPtr.h:
3397         (WTF::ScrambledPtr::descrambled const):
3398         (WTF::ScrambledPtr::bits const):
3399         (WTF::ScrambledPtr::operator==):
3400         (WTF::ScrambledPtr::operator=):
3401         (WTF::ScrambledPtr::scramble):
3402         (WTF::ScrambledPtr::descramble):
3403         (WTF::ScrambledPtr:: const): Deleted.
3404         (WTF::ScrambledPtr::scrambledBits const): Deleted.
3405
3406 2017-12-01  Christopher Reid  <chris.reid@sony.com>
3407
3408         Move DateComponents into WTF
3409         https://bugs.webkit.org/show_bug.cgi?id=180211
3410
3411         Reviewed by Myles C. Maxfield.
3412
3413         Moved DateComponents from WebCore/platform into WTF.
3414         Removed isLeapYear from DateComponents as DateMath already has that function.
3415
3416         * WTF.xcodeproj/project.pbxproj:
3417         * wtf/CMakeLists.txt:
3418         * wtf/DateComponents.cpp: Renamed from Source\WebCore\platform\DateComponents.cpp.
3419         * wtf/DateComponents.h: Renamed from Source\WebCore\platform\DateComponents.h.
3420
3421 2017-12-01  Youenn Fablet  <youenn@apple.com>
3422
3423         Implement https://w3c.github.io/ServiceWorker/#clients-get
3424         https://bugs.webkit.org/show_bug.cgi?id=180167
3425
3426         Reviewed by Chris Dumez.
3427
3428         * wtf/text/StringView.h:
3429         (WTF::StringView::toUInt64Strict const):
3430         * wtf/text/WTFString.h:
3431
3432 2017-12-01  Brian Burg  <bburg@apple.com>
3433
3434         Web Inspector: move Inspector::Protocol::Array<T> to JSON namespace
3435         https://bugs.webkit.org/show_bug.cgi?id=173662
3436
3437         Reviewed by Joseph Pecoraro.
3438
3439         Move Inspector::Protocol::Array<T> to JSON::ArrayOf<T>.
3440
3441         * wtf/JSONValues.h:
3442         (WTF::JSONImpl::ArrayOf::ArrayOf):
3443         (WTF::JSONImpl::ArrayOf::openAccessors):
3444         (WTF::JSONImpl::ArrayOf::addItem):
3445         (WTF::JSONImpl::ArrayOf::create):
3446
3447 2017-12-01  Brady Eidson  <beidson@apple.com>
3448
3449         Add Internals.terminateServiceWorker, and the ability to restart service workers for postMessage.
3450         https://bugs.webkit.org/show_bug.cgi?id=180170
3451
3452         Reviewed by Chris Dumez.
3453
3454         * wtf/CompletionHandler.h:
3455         (WTF::CompletionHandler<Out):
3456
3457 2017-11-30  Yusuke Suzuki  <utatane.tea@gmail.com>
3458
3459         [JSC] Remove easy toRemove & map.remove() use in OAS phase
3460         https://bugs.webkit.org/show_bug.cgi?id=180208
3461
3462         Reviewed by Mark Lam.
3463
3464         * wtf/HashMap.h:
3465         (WTF::X>::removeIf):
3466         * wtf/HashSet.h:
3467         (WTF::V>::removeIf):
3468         * wtf/HashTable.h:
3469         (WTF::KeyTraits>::removeIf):
3470
3471 2017-11-30  Commit Queue  <commit-queue@webkit.org>
3472
3473         Unreviewed, rolling out r225362.
3474         https://bugs.webkit.org/show_bug.cgi?id=180225
3475
3476         removeIf predicate function can touch remove target set
3477         (Requested by yusukesuzuki on #webkit).
3478
3479         Reverted changeset:
3480
3481         "[JSC] Remove easy toRemove & map.remove() use"
3482         https://bugs.webkit.org/show_bug.cgi?id=180208
3483         https://trac.webkit.org/changeset/225362
3484
3485 2017-11-30  Mark Lam  <mark.lam@apple.com>
3486
3487         Let's scramble MacroAssemblerCodePtr values.
3488         https://bugs.webkit.org/show_bug.cgi?id=180169
3489         <rdar://problem/35758340>
3490
3491         Reviewed by Filip Pizlo, Saam Barati, and JF Bastien.
3492
3493         Introduce a ScrambledPtr class to facilitate scrambling.
3494
3495         * WTF.xcodeproj/project.pbxproj:
3496         * wtf/CMakeLists.txt:
3497         * wtf/ScrambledPtr.cpp: Added.
3498         (WTF::makeScrambledPtrKey):
3499         * wtf/ScrambledPtr.h: Added.
3500         (WTF::ScrambledPtr::ScrambledPtr):
3501         (WTF::ScrambledPtr::paranoidAssertIsScrambled const):
3502         (WTF::ScrambledPtr::paranoidAssertIsNotScrambled const):
3503         (WTF::ScrambledPtr:: const):
3504         (WTF::ScrambledPtr::operator-> const):
3505         (WTF::ScrambledPtr::scrambledBits const):
3506         (WTF::ScrambledPtr::operator! const):
3507         (WTF::ScrambledPtr::operator bool const):
3508         (WTF::ScrambledPtr::operator== const):
3509         (WTF::ScrambledPtr::operator==):
3510         (WTF::ScrambledPtr::scramble):
3511         (WTF::ScrambledPtr::descramble):
3512
3513 2017-11-30  Yusuke Suzuki  <utatane.tea@gmail.com>
3514
3515         [JSC] Remove easy toRemove & map.remove() use
3516         https://bugs.webkit.org/show_bug.cgi?id=180208
3517
3518         Reviewed by Mark Lam.
3519
3520         Return bool from removeIf. It is true if removeIf removes at least one entry.
3521         This interface is similar to existing HashSet::remove, which returns true
3522         if it actually removes entry.
3523
3524         * wtf/HashMap.h:
3525         (WTF::X>::removeIf):
3526         * wtf/HashSet.h:
3527         (WTF::V>::removeIf):
3528         * wtf/HashTable.h:
3529         (WTF::KeyTraits>::removeIf):
3530
3531 2017-11-30  Chris Dumez  <cdumez@apple.com>
3532
3533         Populate self.registration.installing/waiting/active inside service workers
3534         https://bugs.webkit.org/show_bug.cgi?id=180168
3535
3536         Reviewed by Brady Eidson.
3537
3538         Add CrossThreadCopier support for std::optional<>.
3539
3540         * wtf/CrossThreadCopier.h:
3541
3542 2017-11-29  JF Bastien  <jfbastien@apple.com>
3543
3544         WTF / bmalloc: don't write to 0xbbadbeef when ASAN is looking
3545         https://bugs.webkit.org/show_bug.cgi?id=180175
3546
3547         Reviewed by Mark Lam.
3548
3549         ASAN knows that 0xbbadbeef is a bbad aaddress, and tells us so
3550         when we write to it, say in an assert. That creates bbad error
3551         reports where ASAN thinks we write to an invalid address, instead
3552         of thinking that we hit an assertion. In some cases, tooling that
3553         use fuzzers aggregate similar issues, and think that we just have
3554         the one bug and not a bunch of different asserts.
3555
3556         * wtf/Assertions.cpp:
3557         * wtf/Assertions.h:
3558
3559 2017-11-29  Filip Pizlo  <fpizlo@apple.com>
3560
3561         GC should support isoheaps
3562         https://bugs.webkit.org/show_bug.cgi?id=179288
3563
3564         Reviewed by Saam Barati.
3565         
3566         One of my favorite data structures in the GC is a singly-linked list that knows its tail, so that
3567         things get added to it at the end rather that at the beginning. In this patch, I use this to put
3568         the same node on multiple lists, which our existing linked list templates also don't support.
3569         
3570         This adds a new linked list that does those things:
3571