FTL B3 should have basic GetById support
[WebKit-https.git] / Source / WTF / ChangeLog
1 2015-12-08  Filip Pizlo  <fpizlo@apple.com>
2
3         FTL B3 should have basic GetById support
4         https://bugs.webkit.org/show_bug.cgi?id=152035
5
6         Reviewed by Saam Barati.
7
8         When dealing with shared task lambdas, you often want to force a value to be allocated so that it
9         has reference semantics, but you still want the lambda to execute OK when we pop stack. In PL we
10         usually call this a "box". This is easy to do if the value that happened to be stack-allocated
11         is also RefCounted, but that's rare, since stack-allocated values often have copy semantics. So,
12         I've added a Box type to WTF. Behind the scenes, it allocates your object with fast malloc inside
13         a ThreadSAfeRefCounted. When you pass Box<T>, you're passing the reference. This makes it a lot
14         easier to work with by-reference capture.
15
16         * WTF.xcodeproj/project.pbxproj:
17         * wtf/Box.h: Added.
18         (WTF::Box::Box):
19         (WTF::Box::create):
20         (WTF::Box::get):
21         (WTF::Box::operator*):
22         (WTF::Box::operator->):
23         (WTF::Box::operator bool):
24         (WTF::Box::Data::Data):
25
26 2015-12-09  Andreas Kling  <akling@apple.com>
27
28         [iOS] ResourceUsageOverlay should work on iOS.
29         <https://webkit.org/b/152021>
30
31         Reviewed by Antti Koivisto.
32
33         * wtf/Platform.h: Enable RESOURCE_USAGE_OVERLAY for all COCOA platforms.
34
35 2015-12-08  Joseph Pecoraro  <pecoraro@apple.com>
36
37         Create a Sandbox SPI header
38         https://bugs.webkit.org/show_bug.cgi?id=151981
39
40         Reviewed by Andy Estes.
41
42         * WTF.xcodeproj/project.pbxproj:
43         * wtf/spi/darwin/SandboxSPI.h: Added.
44
45 2015-12-07  Filip Pizlo  <fpizlo@apple.com>
46
47         FTL B3 should be able to flag the tag constants as being super important so that B3 can hoist them and Air can force them into registers
48         https://bugs.webkit.org/show_bug.cgi?id=151955
49
50         Reviewed by Geoffrey Garen.
51
52         Remove some remaining DFG-specific snippets from Dominators. This used to be a non-template
53         DFG class, and some time ago I hoisted it into WTF and made it generic. But since the only
54         user of the class was the DFG, this class still had a handful of DFG-specific snippets that
55         didn't compile when I started using it from B3.
56
57         Also renamed immediateDominatorOf() to idom(). This is the sort of abbreviation that we
58         wouldn't ordinarily want to have in WebKit. But WebKit does allow for abbreviations that are
59         "more canonical". The term "idom" is definitely more canonical than "immediateDominatorOf".
60
61         * wtf/Dominators.h:
62         (WTF::Dominators::dominates):
63         (WTF::Dominators::idom):
64         (WTF::Dominators::forAllStrictDominatorsOf):
65         (WTF::Dominators::NaiveDominators::dominates):
66         (WTF::Dominators::NaiveDominators::dump):
67         (WTF::Dominators::ValidationContext::handleErrors):
68
69 2015-12-03  Anders Carlsson  <andersca@apple.com>
70
71         Remove Objective-C GC support
72         https://bugs.webkit.org/show_bug.cgi?id=151819
73         rdar://problem/23746991
74
75         Reviewed by Dan Bernstein.
76
77         * Configurations/Base.xcconfig:
78         * wtf/ThreadingPthreads.cpp:
79         (WTF::initializeCurrentThreadInternal): Deleted.
80         * wtf/text/cf/StringImplCF.cpp:
81         (WTF::StringImpl::createCFString):
82         (garbageCollectionEnabled): Deleted.
83         (WTF::StringWrapperCFAllocator::create): Deleted.
84
85 2015-12-02  Filip Pizlo  <fpizlo@apple.com>
86
87         FTL B3 should support OSR exit
88         https://bugs.webkit.org/show_bug.cgi?id=151710
89
90         Reviewed by Saam Barati.
91
92         Make sure that this has perfect forwarding.
93
94         * wtf/SegmentedVector.h:
95         (WTF::SegmentedVector::append):
96         (WTF::SegmentedVector::alloc):
97
98 2015-12-01  Yusuke Suzuki  <utatane.tea@gmail.com>
99
100         [ES6] Implement LLInt/Baseline Support for ES6 Generators and enable this feature
101         https://bugs.webkit.org/show_bug.cgi?id=150792
102
103         Reviewed by Saam Barati.
104
105         * wtf/FastBitVector.h:
106         (WTF::FastBitVector::forEachSetBit):
107         * wtf/FeatureDefines.h:
108
109 2015-12-01  Commit Queue  <commit-queue@webkit.org>
110
111         Unreviewed, rolling out r192914.
112         https://bugs.webkit.org/show_bug.cgi?id=151734
113
114         JSC tests for this change are failing on 32 and 64-bit bots
115         (Requested by ryanhaddad on #webkit).
116
117         Reverted changeset:
118
119         "[ES6] Implement LLInt/Baseline Support for ES6 Generators and
120         enable this feature"
121         https://bugs.webkit.org/show_bug.cgi?id=150792
122         http://trac.webkit.org/changeset/192914
123
124 2015-12-01  Myles C. Maxfield  <mmaxfield@apple.com>
125
126         Give String and AtomicString an existingHash() function
127         https://bugs.webkit.org/show_bug.cgi?id=151717
128
129         Reviewed by Andreas Kling.
130
131         Test: WTF.AtomicStringExistingHash
132               WTF.StringExistingHash
133
134         * wtf/text/AtomicString.h:
135         (WTF::AtomicString::existingHash):
136         * wtf/text/WTFString.h:
137         (WTF::String::existingHash):
138
139 2015-12-01  Yusuke Suzuki  <utatane.tea@gmail.com>
140
141         [ES6] Implement LLInt/Baseline Support for ES6 Generators and enable this feature
142         https://bugs.webkit.org/show_bug.cgi?id=150792
143
144         Reviewed by Saam Barati.
145
146         * wtf/FastBitVector.h:
147         (WTF::FastBitVector::forEachSetBit):
148         * wtf/FeatureDefines.h:
149
150 2015-11-30  Geoffrey Garen  <ggaren@apple.com>
151
152         Use a better RNG for Math.random()
153         https://bugs.webkit.org/show_bug.cgi?id=151641
154
155         Reviewed by Anders Carlsson.
156
157         Use 64 bits in the random number generator instead of 32 bit. (In
158         the end, JavaScript, which uses doubles, will only see 52 bits.) This
159         prevents programs that multiply a random number by a large constant from
160         seeing non-random "banding" caused by zeroes in the low 20 bits.
161
162         I also took the opportunity to upgrade from GameRandom to Xorshift+,
163         since Xorshift+ passes more benchmarks for randomness, and is not any
164         slower or more complicated.
165
166         Now let us all remember the fateful words of Steve Weibe, who would be
167         King of Kong: "The randomness went the opposite way that it usually goes."
168
169         * wtf/WeakRandom.h:
170         (WTF::WeakRandom::WeakRandom):
171         (WTF::WeakRandom::setSeed): Use standard naming.
172
173         (WTF::WeakRandom::seed): This function is safe now. "Unsafe" in function
174         names makes me itch.
175
176         (WTF::WeakRandom::get):
177         (WTF::WeakRandom::getUint32): Update to 64bit.
178
179         (WTF::WeakRandom::advance): The Xorshift+ algorithm.
180
181         (WTF::WeakRandom::initializeSeed): Deleted.
182         (WTF::WeakRandom::seedUnsafe): Deleted.
183
184 2015-11-30  Benjamin Poulain  <bpoulain@apple.com>
185
186         [JSC] Speed up Air Liveness Analysis on Tmps
187         https://bugs.webkit.org/show_bug.cgi?id=151556
188
189         Reviewed by Filip Pizlo.
190
191         * WTF.xcodeproj/project.pbxproj:
192         * wtf/IndexSparseSet.h: Added.
193         (WTF::IndexSparseSet<OverflowHandler>::IndexSparseSet):
194         (WTF::IndexSparseSet<OverflowHandler>::add):
195         (WTF::IndexSparseSet<OverflowHandler>::remove):
196         (WTF::IndexSparseSet<OverflowHandler>::clear):
197         (WTF::IndexSparseSet<OverflowHandler>::size):
198         (WTF::IndexSparseSet<OverflowHandler>::isEmpty):
199         (WTF::IndexSparseSet<OverflowHandler>::contains):
200
201 2015-11-30  Tim Horton  <timothy_horton@apple.com>
202
203         Get rid of the !USE(ASYNC_NSTEXTINPUTCLIENT) codepath
204         https://bugs.webkit.org/show_bug.cgi?id=151673
205
206         Reviewed by Anders Carlsson.
207
208         * wtf/Platform.h:
209
210 2015-11-30  Carlos Garcia Campos  <cgarcia@igalia.com>
211
212         [GLIB] Remove GMainLoopSource and GThreadSafeMainLoopSource
213         https://bugs.webkit.org/show_bug.cgi?id=151633
214
215         Reviewed by Csaba Osztrogonác.
216
217         * WTF.vcxproj/WTF.vcxproj:
218         * WTF.vcxproj/WTF.vcxproj.filters:
219         * wtf/PlatformEfl.cmake:
220         * wtf/PlatformGTK.cmake:
221         * wtf/glib/GMainLoopSource.cpp: Removed.
222         * wtf/glib/GMainLoopSource.h: Removed.
223         * wtf/glib/GThreadSafeMainLoopSource.cpp: Removed.
224         * wtf/glib/GThreadSafeMainLoopSource.h: Removed.
225
226 2015-11-27  Csaba Osztrogonác  <ossy@webkit.org>
227
228         Fix build warning in bignum.cc
229         https://bugs.webkit.org/show_bug.cgi?id=150797
230
231         Reviewed by Geoffrey Garen.
232
233         * wtf/dtoa/bignum.cc:
234
235 2015-11-18  Daniel Bates  <dabates@apple.com>
236
237         [iOS] ASSERTION FAILED: temporaryFilePath.last() == '/' in WebCore::openTemporaryFile()
238         https://bugs.webkit.org/show_bug.cgi?id=151392
239         <rdar://problem/23595341>
240
241         Reviewed by Alexey Proskuryakov.
242
243         Workaround <rdar://problem/23579077> where confstr(_CS_DARWIN_USER_TEMP_DIR, ..., ...) retrieves
244         the path to the user temporary directory without a trailing slash in the iOS simulator.
245
246         * wtf/DataLog.cpp:
247         (WTF::initializeLogFileOnce):
248
249 2015-11-17  Filip Pizlo  <fpizlo@apple.com>
250
251         CheckAdd/Mul should have commutativity optimizations in B3->Air lowering
252         https://bugs.webkit.org/show_bug.cgi?id=151214
253
254         Reviewed by Geoffrey Garen.
255
256         Disable my failed attempts at perfect forwarding, since they were incorrect, and caused compile
257         errors if you tried to pass an argument that bound to lvalue. This shouldn't affect performance of
258         anything we care about, and performance tests seem to confirm that it's all good.
259
260         * wtf/ScopedLambda.h:
261
262 2015-11-17  Filip Pizlo  <fpizlo@apple.com>
263
264         Air should lay out code optimally
265         https://bugs.webkit.org/show_bug.cgi?id=150478
266
267         Reviewed by Geoffrey Garen.
268
269         * wtf/GraphNodeWorklist.h:
270         (WTF::GraphNodeWorklist::push):
271         (WTF::GraphNodeWorklist::isEmpty):
272         (WTF::GraphNodeWorklist::notEmpty):
273         (WTF::GraphNodeWorklist::pop):
274
275 2015-11-11  Anders Carlsson  <andersca@apple.com>
276
277         Enable cross-platform context menus by default
278         https://bugs.webkit.org/show_bug.cgi?id=151173
279
280         Reviewed by Tim Horton.
281
282         * wtf/Platform.h:
283
284 2015-11-12  Csaba Osztrogonác  <ossy@webkit.org>
285
286         Remove ENABLE(SATURATED_LAYOUT_ARITHMETIC) guards
287         https://bugs.webkit.org/show_bug.cgi?id=150972
288
289         Reviewed by Darin Adler.
290
291         * wtf/FeatureDefines.h:
292
293 2015-11-11  Filip Pizlo  <fpizlo@apple.com>
294
295         B3 should be able to compile and canonicalize Mul
296         https://bugs.webkit.org/show_bug.cgi?id=151124
297
298         Reviewed by Geoffrey Garen.
299
300         * wtf/MathExtras.h:
301         (WTF::fastLog2):
302
303 2015-11-10  Filip Pizlo  <fpizlo@apple.com>
304
305         B3 should be able to compile a program with ChillDiv
306         https://bugs.webkit.org/show_bug.cgi?id=151114
307
308         Reviewed by Benjamin Poulain.
309
310         Needed to beef up some compiler algorithms. All of the hardening was about making them
311         work with objects that have move semantics but not copy semantics. This arises in B3
312         basic block insertion sets.
313
314         * wtf/BubbleSort.h:
315         (WTF::bubbleSort):
316         * wtf/Insertion.h:
317         (WTF::Insertion::Insertion):
318         (WTF::Insertion::index):
319         (WTF::Insertion::element):
320         (WTF::Insertion::operator<):
321         (WTF::executeInsertions):
322
323 2015-11-10  Carlos Garcia Campos  <cgarcia@igalia.com>
324
325         [GTK] Use CROSS_PLATFORM_CONTEXT_MENUS
326         https://bugs.webkit.org/show_bug.cgi?id=150642
327
328         Reviewed by Martin Robinson.
329
330         Enable CROSS_PLATFORM_CONTEXT_MENUS for GTK+ port.
331
332         * wtf/Platform.h:
333
334 2015-11-09  Anders Carlsson  <andersca@apple.com>
335
336         Introspect reply block types as well
337         https://bugs.webkit.org/show_bug.cgi?id=151048
338
339         Reviewed by Tim Horton.
340
341         Fix operator-> implementation.
342
343         * wtf/Optional.h:
344         (WTF::Optional::operator->):
345
346 2015-11-05  Nikos Andronikos  <nikos.andronikos-webkit@cisra.canon.com.au>
347
348         Add runtime and compile time flags for enabling Web Animations API and model.
349         https://bugs.webkit.org/show_bug.cgi?id=150914
350
351         Reviewed by Benjamin Poulain.
352
353         Add ENABLE_WEB_ANIMATIONS compile time flag, runtime flag webAnimationsEnabled and Expose WK2 preference for runtime flag.
354
355         * wtf/FeatureDefines.h:
356
357 2015-11-05  Zan Dobersek  <zdobersek@igalia.com>
358
359         [GLib] Avoid gint64, std::chrono::microseconds overflows in RunLoop::TimerBase
360         https://bugs.webkit.org/show_bug.cgi?id=150930
361
362         Reviewed by Carlos Garcia Campos.
363
364         In RunLoop::TimerBase::start(), avoid overflowing the std::chrono::microseconds
365         value in case the passed-in fire interval (in seconds) is too large (e.g. when
366         std::chrono::microseconds::max() is used as the desired interval). This is
367         achieved by using the passed-in fire interval, converted in microseconds, only
368         if the value of this interval is smaller than std::chrono::microseconds::max().
369
370         In RunLoop::TimerBase::updateReadyTime(), the zero-delay is still considered a
371         short cut, but we use G_MAXINT64 in case the sum of the current time and the
372         desired fire interval (now in microseconds) would overflow.
373
374         * wtf/glib/RunLoopGLib.cpp:
375         (WTF::RunLoop::TimerBase::updateReadyTime):
376         (WTF::RunLoop::TimerBase::start):
377
378 2015-11-02  Filip Pizlo  <fpizlo@apple.com>
379
380         B3/Air should use bubble sort for their insertion sets, because it's faster than std::stable_sort
381         https://bugs.webkit.org/show_bug.cgi?id=150828
382
383         Reviewed by Geoffrey Garen.
384
385         Add a pretty good bubble sort implementation to WTF. This implementation has three
386         common tricks:
387
388         - Forward and backward scans. This reduces the severity of certain kinds of bubble sort
389           pathologies.
390
391         - Return if a scan finds the list to be sorted. This gives the algorithm one of its most
392           attractive properties: it's super fast when the list is already sorted.
393
394         - Each scan eliminates one element from future scans. This makes the algorithm no worse
395           than insertion sort.
396
397         Why do we want this? Because bubble sort is a really great stable sort for small lists,
398         or large lists in which only a handful of elements are out of order. Compiler insertion
399         sets tend to be one of those or somewhere in between: usually they are very small, and
400         usually they are sorted. It's rare that an element will be out of order, and when it is,
401         it's usually very close to where it's supposed to be.
402
403         This is a significant speed-up for B3 compile times.
404
405         * WTF.xcodeproj/project.pbxproj:
406         * wtf/BubbleSort.h: Added.
407         (WTF::bubbleSort):
408         * wtf/CMakeLists.txt:
409
410 2015-11-02  Andy Estes  <aestes@apple.com>
411
412         [Cocoa] Add tvOS and watchOS to SUPPORTED_PLATFORMS
413         https://bugs.webkit.org/show_bug.cgi?id=150819
414
415         Reviewed by Dan Bernstein.
416
417         This tells Xcode to include these platforms in its Devices dropdown, making it possible to build in the IDE.
418
419         * Configurations/Base.xcconfig:
420
421 2015-11-02  Carlos Garcia Campos  <cgarcia@igalia.com>
422
423         [GLIB] Remove support for GSocket main loop sources from GMainLoopSource
424         https://bugs.webkit.org/show_bug.cgi?id=150772
425
426         Reviewed by Žan Doberšek.
427
428         It complicated the code just to make generic what is only used in
429         one place.
430
431         * wtf/glib/GMainLoopSource.cpp:
432         (WTF::GMainLoopSource::cancel): Deleted.
433         (WTF::GMainLoopSource::schedule): Deleted.
434         (WTF::GMainLoopSource::scheduleTimeoutSource): Deleted.
435         (WTF::GMainLoopSource::scheduleAfterDelay): Deleted.
436         (WTF::GMainLoopSource::finishVoidCallback): Deleted.
437         (WTF::GMainLoopSource::voidCallback): Deleted.
438         (WTF::GMainLoopSource::prepareBoolCallback): Deleted.
439         * wtf/glib/GMainLoopSource.h:
440         (WTF::GMainLoopSource::Context::operator=): Deleted.
441
442 2015-11-02  Carlos Garcia Campos  <cgarcia@igalia.com>
443
444         [GLIB] Remove delete on destroy GMainLoopSources
445         https://bugs.webkit.org/show_bug.cgi?id=150771
446
447         Reviewed by Žan Doberšek.
448
449         Delete on destroy sources made the GMainLoopSource implementation
450         more complex and they are currently unused.
451
452         * wtf/glib/GMainLoopSource.cpp:
453         (WTF::GMainLoopSource::boolCallback):
454         (WTF::GMainLoopSource::create): Deleted.
455         (WTF::GMainLoopSource::GMainLoopSource): Deleted.
456         (WTF::GMainLoopSource::cancel): Deleted.
457         (WTF::GMainLoopSource::scheduleAndDeleteOnDestroy): Deleted.
458         (WTF::GMainLoopSource::scheduleAfterDelayAndDeleteOnDestroy): Deleted.
459         (WTF::GMainLoopSource::voidCallback): Deleted.
460         * wtf/glib/GMainLoopSource.h:
461
462 2015-11-01  Carlos Garcia Campos  <cgarcia@igalia.com>
463
464         [GTK] Use RunLoop in WorkQueue implementation
465         https://bugs.webkit.org/show_bug.cgi?id=150770
466
467         Reviewed by Darin Adler.
468
469         Instead of using GMainLoop directly. RunLoop already abstracts the
470         GMainLoop details and uses persistent sources making it more efficient.
471         For the dispatchAfter implementation we use a helper context class
472         and a GSource directly, since we are going to get rid of delete on
473         destroy GMainLoop soon and this is the only place where we still
474         use them.
475
476         * wtf/RunLoop.h:
477         (WTF::RunLoop::mainContext): Return the GMainContext.
478         * wtf/WorkQueue.h:
479         * wtf/glib/WorkQueueGLib.cpp:
480         (WTF::WorkQueue::platformInitialize): The RunLoop needs to be
481         created in the worker thread now, so we now use a mutex to wait
482         until the thread has started and the RunLoop has been created.
483         (WTF::WorkQueue::platformInvalidate): Stop the RunLoop and wait
484         until the thread finishes.
485         (WTF::WorkQueue::dispatch): Use RunLoop::dispatch().
486         (WTF::DispatchAfterContext::DispatchAfterContext):
487         (WTF::DispatchAfterContext::~DispatchAfterContext):
488         (WTF::DispatchAfterContext::dispatch):
489         (WTF::WorkQueue::dispatchAfter):
490
491 2015-11-01  Yusuke Suzuki  <utatane.tea@gmail.com>
492
493         [ES6] Support Generator Syntax
494         https://bugs.webkit.org/show_bug.cgi?id=150769
495
496         Reviewed by Geoffrey Garen.
497
498         Added ENABLE_ES6_GENERATORS flag.
499
500         * wtf/FeatureDefines.h:
501
502 2015-11-01  Darin Adler  <darin@apple.com>
503
504         ASCIICType refinements
505         https://bugs.webkit.org/show_bug.cgi?id=150787
506
507         Reviewed by Geoffrey Garen.
508
509         Refined ASCIICType.h by using narrower types. The most valuable part of this
510         is the part where the result of toASCIIHexValue is uint8_t instead of int;
511         that's slightly better for RGB values that the compiler needs to know fit
512         into a byte (coming in some Color work I plan to do soon).
513
514         * wtf/ASCIICType.h: Used CharacterType instead of CharType throughout, and
515         also sorted the using declarations at the bottom of the header.
516         (WTF::isASCII): Use the name "character" instead of "c".
517         (WTF::isASCIIAlpha): Ditto. Also use isASCIILower and toASCIILowerUnchecked
518         instead of writing it out.
519         (WTF::isASCIIDigit): Ditto.
520         (WTF::isASCIIAlphanumeric): Ditto.
521         (WTF::isASCIIHexDigit): Ditto. Also use toASCIILowerUnchecked instead of
522         writing it out.
523         (WTF::isASCIILower): Ditto.
524         (WTF::isASCIIBinaryDigit): Ditto. Also removed unneeded parentheses to match
525         the style of the rest of the file.
526         (WTF::isASCIIOctalDigit): Ditto.
527         (WTF::isASCIIPrintable): Ditto.
528         (WTF::isASCIISpace): Ditto.
529         (WTF::isASCIIUpper): Ditto.
530         (WTF::toASCIILower): Ditto. Also use isASCIIUpper instead of writing it out.
531         (WTF::toASCIILowerUnchecked): Tweaked comment.
532         (WTF::toASCIIUpper): Ditto. Also use isASCIILower instead of writing it out.
533         (WTF::toASCIIHexValue): Ditto. Also change return type from int to uint8_t.
534         Also broke a single assertion with && into two separate assertions and got
535         rid of unnnecessary masking with 0xF0 after shifting left. Also renamed
536         arguments for the two argument value so they are more sensible.
537         (WTF::lowerNibbleToASCIIHexDigit): Changed argument type to uint8_t, since
538         this function does not take a character. Also called it "value" instead of "c".
539         Also slightly tweaked how the expression is written.
540         (WTF::upperNibbleToASCIIHexDigit): Ditto. Using the more specific type also
541         got rid of the need to explicitly mask in this function.
542         (WTF::isASCIIAlphaCaselessEqual): Renamed the arguments for greater clarity.
543         With the new clearer argument names, the comment was superfluous.
544
545 2015-11-01  Filip Pizlo  <fpizlo@apple.com>
546
547         Dominators should be factored out of the DFG
548         https://bugs.webkit.org/show_bug.cgi?id=150764
549
550         Reviewed by Geoffrey Garen.
551
552         This takes what used to be DFGDominators.h/DFGDominators.cpp and turns it into a generic
553         algorithm that can take any abstract graph. The idea is that you create Dominators<CFG> and
554         pass it a CFG object, which defines the types of graph nodes and methods for getting
555         successors, predecessors, etc. The DFG now defines a class called CFG, which is a wrapper for
556         DFG::Graph that conforms to the thing that wtf/Dominators.h expects.
557
558         When doing things to graphs, it's common to refer to the things in the graph as "nodes".
559         Because I intend to reuse the CFG abstraction with many graph algorithms, that abstraction uses
560         the term "node" to refer to a DFG basic block. But in Dominators, the method and variable names
561         still use "block". This is because although Dominators are applicable to any kind of directed
562         graph, it's super unlikely that we will ever use them for anything but compilers. Indeed, the
563         only reason why I'm factoring them out of the DFG is so that I can use them with B3 and Air.
564
565         This has the nice side effect that a user of WTF::Dominators<JSC::DFG::CFG> will see familiar
566         terminology like "blocksStrictlyDominatedBy(...)" instead of "nodesStrictlyDominatedBy(...)",
567         which would be super confusing.
568
569         Overall, wtf/Dominators.h is a combination of what used to be in DFGDominators.h,
570         DFGDominators.cpp, DFGNaiveDominators.h, and DFGNaiveDominators.cpp. I only changed code when I
571         had to in order to make it generic.
572
573         * WTF.xcodeproj/project.pbxproj:
574         * wtf/CMakeLists.txt:
575         * wtf/Dominators.h: Added.
576         (WTF::Dominators::Dominators):
577         (WTF::Dominators::compute):
578         (WTF::Dominators::strictlyDominates):
579         (WTF::Dominators::dominates):
580         (WTF::Dominators::immediateDominatorOf):
581         (WTF::Dominators::forAllStrictDominatorsOf):
582         (WTF::Dominators::forAllDominatorsOf):
583         (WTF::Dominators::forAllBlocksStrictlyDominatedBy):
584         (WTF::Dominators::forAllBlocksDominatedBy):
585         (WTF::Dominators::strictDominatorsOf):
586         (WTF::Dominators::dominatorsOf):
587         (WTF::Dominators::blocksStrictlyDominatedBy):
588         (WTF::Dominators::blocksDominatedBy):
589         (WTF::Dominators::forAllBlocksInDominanceFrontierOf):
590         (WTF::Dominators::dominanceFrontierOf):
591         (WTF::Dominators::forAllBlocksInIteratedDominanceFrontierOf):
592         (WTF::Dominators::forAllBlocksInPrunedIteratedDominanceFrontierOf):
593         (WTF::Dominators::iteratedDominanceFrontierOf):
594         (WTF::Dominators::dump):
595         (WTF::Dominators::LengauerTarjan::LengauerTarjan):
596         (WTF::Dominators::LengauerTarjan::compute):
597         (WTF::Dominators::LengauerTarjan::immediateDominator):
598         (WTF::Dominators::LengauerTarjan::computeDepthFirstPreNumbering):
599         (WTF::Dominators::LengauerTarjan::computeSemiDominatorsAndImplicitImmediateDominators):
600         (WTF::Dominators::LengauerTarjan::computeExplicitImmediateDominators):
601         (WTF::Dominators::LengauerTarjan::link):
602         (WTF::Dominators::LengauerTarjan::eval):
603         (WTF::Dominators::LengauerTarjan::compress):
604         (WTF::Dominators::LengauerTarjan::BlockData::BlockData):
605         (WTF::Dominators::NaiveDominators::NaiveDominators):
606         (WTF::Dominators::NaiveDominators::dominates):
607         (WTF::Dominators::NaiveDominators::dump):
608         (WTF::Dominators::NaiveDominators::pruneDominators):
609         (WTF::Dominators::ValidationContext::ValidationContext):
610         (WTF::Dominators::ValidationContext::reportError):
611         (WTF::Dominators::ValidationContext::handleErrors):
612         (WTF::Dominators::naiveDominates):
613         (WTF::Dominators::forAllBlocksInDominanceFrontierOfImpl):
614         (WTF::Dominators::forAllBlocksInIteratedDominanceFrontierOfImpl):
615         (WTF::Dominators::BlockData::BlockData):
616
617 2015-11-01  Darin Adler  <darin@apple.com>
618
619         Remove some dead and unneeded code (ScrollbarThemeSafari, RenderThemeSafari, OPENCL, a little color space logic)
620         https://bugs.webkit.org/show_bug.cgi?id=150783
621
622         Reviewed by Tim Horton.
623
624         * wtf/FeatureDefines.h: Removed the OPENCL feature, no longer supported.
625
626 2015-10-31  Filip Pizlo  <fpizlo@apple.com>
627
628         B3::reduceStrength's DCE should be more agro and less wrong
629         https://bugs.webkit.org/show_bug.cgi?id=150748
630
631         Reviewed by Geoffrey Garen.
632
633         * wtf/GraphNodeWorklist.h:
634         (WTF::GraphNodeWorklist::saw): This method is super useful.
635
636 2015-11-01  Philip Chimento  <philip.chimento@gmail.com>
637
638         [GTK] Fix combinations of PLATFORM(GTK) and OS(DARWIN)
639         https://bugs.webkit.org/show_bug.cgi?id=144560
640
641         Reviewed by Darin Adler.
642
643         * wtf/Platform.h: Don't USE(ACCELERATE) on PLATFORM(GTK).
644         * wtf/WorkQueue.h: Change order of OS(DARWIN) and PLATFORM(GTK)
645         checks so that GTK facilities are used even when building the
646         GTK platform on Darwin.
647
648 2015-11-01  Carlos Garcia Campos  <cgarcia@igalia.com>
649
650         [GTK] Use RunLoop::Timer in main thread shared timer GTK+ implementation
651         https://bugs.webkit.org/show_bug.cgi?id=150754
652
653         Reviewed by Darin Adler.
654
655         Add API to set the priority of a RunLoop::Timer for GLib.
656
657         * wtf/RunLoop.h:
658         * wtf/glib/RunLoopGLib.cpp:
659         (WTF::RunLoop::TimerBase::setPriority):
660
661 2015-10-31  Andreas Kling  <akling@apple.com>
662
663         Add a debug overlay with information about web process resource usage.
664         <https://webkit.org/b/150599>
665
666         Reviewed by Darin Adler.
667
668         Add ENABLE(RESOURCE_USAGE_OVERLAY) flag, enabled on Mac by default.
669
670         * wtf/Platform.h:
671
672 2015-10-30  Chris Dumez  <cdumez@apple.com>
673
674         Regression(r191673): Crash in RunLoopTimer::schedule()
675         https://bugs.webkit.org/show_bug.cgi?id=150723
676
677         Reviewed by Anders Carlsson.
678
679         We were crashing in RunLoopTimer::schedule() when iterating over the
680         SchedulePairHashSet. The reason is that we were passing this
681         SchedulePairHashSet from the main thread to a background thread, which
682         was not safe because the SchedulePair objects inside the HashSet were
683         not ThreadSafeRefCounted. This patch makes them ThreadSafeRefCounted.
684
685         * wtf/SchedulePair.h:
686
687 2015-10-30  Carlos Garcia Campos  <cgarcia@igalia.com>
688
689         [GTK] Move the socket polling off the WorkQueue
690         https://bugs.webkit.org/show_bug.cgi?id=150593
691
692         Reviewed by Anders Carlsson.
693
694         It doesn't really belong to the WorkQueue, it's only used by the
695         WebKit2 connection, so it can be moved there.
696
697         * wtf/WorkQueue.h:
698         * wtf/glib/WorkQueueGLib.cpp:
699         (WTF::WorkQueue::registerSocketEventHandler): Deleted.
700         (WTF::WorkQueue::unregisterSocketEventHandler): Deleted.
701
702 2015-10-29  Carlos Garcia Campos  <cgarcia@igalia.com>
703
704         [GTK] Use a persistent main loop source in RunLoop glib implementation
705         https://bugs.webkit.org/show_bug.cgi?id=150590
706
707         Reviewed by Žan Doberšek.
708
709         It's more efficient than creating and destroying a new source for
710         every dispatch and it simplifies the code.
711
712         * wtf/RunLoop.h:
713         * wtf/glib/MainThreadGLib.cpp:
714         (WTF::scheduleDispatchFunctionsOnMainThread): Use
715         RunLoop::dispatch() instead of GMainLoopSource::scheduleAndDeleteOnDestroy().
716         * wtf/glib/RunLoopGLib.cpp:
717         (WTF::RunLoop::RunLoop): Create and setup the persistent source.
718         (WTF::RunLoop::~RunLoop): Destroy the persistent source.
719         (WTF::RunLoop::stop): Stop the persistent source before stopping
720         the main loop.
721         (WTF::RunLoop::wakeUp): Make the persistent source active. We
722         no longer need to explicitly wakeup the context.
723         (WTF::RunLoop::TimerBase::TimerBase): Create and setup the
724         persistent source.
725         (WTF::RunLoop::TimerBase::~TimerBase): Destroy the persistent source.
726         (WTF::RunLoop::TimerBase::updateReadyTime): Set the ready time
727         according to the fire interval.
728         (WTF::RunLoop::TimerBase::start): Make the persistent source active.
729         (WTF::RunLoop::TimerBase::stop): Stop the persistent source.
730         (WTF::RunLoop::TimerBase::isActive): Return whether the
731         persistent source is active.
732
733 2015-10-30  Philippe Normand  <pnormand@igalia.com>
734
735         [GTK][Mac] fix WTF build
736         https://bugs.webkit.org/show_bug.cgi?id=150502
737
738         Reviewed by Alex Christensen.
739
740         * wtf/CMakeLists.txt: Add CommonCryptoSPI.h in the headers.
741
742 2015-10-29  Alex Christensen  <achristensen@webkit.org>
743
744         Fix Mac CMake build
745         https://bugs.webkit.org/show_bug.cgi?id=150686
746
747         Reviewed by Filip Pizlo.
748
749         * wtf/CMakeLists.txt:
750         * wtf/Platform.h:
751         * wtf/PlatformMac.cmake:
752
753 2015-10-29  Commit Queue  <commit-queue@webkit.org>
754
755         Unreviewed, rolling out r191728.
756         https://bugs.webkit.org/show_bug.cgi?id=150668
757
758         Caused a lot of timeouts in layout tests (Requested by KaL on
759         #webkit).
760
761         Reverted changeset:
762
763         "[GTK] Use a persistent main loop source in RunLoop glib
764         implementation"
765         https://bugs.webkit.org/show_bug.cgi?id=150590
766         http://trac.webkit.org/changeset/191728
767
768 2015-10-29  Carlos Garcia Campos  <cgarcia@igalia.com>
769
770         [GTK] Use a persistent main loop source in RunLoop glib implementation
771         https://bugs.webkit.org/show_bug.cgi?id=150590
772
773         Reviewed by Žan Doberšek.
774
775         It's more efficient than creating and destroying a new source for
776         every dispatch and it simplifies the code.
777
778         * wtf/RunLoop.h:
779         * wtf/glib/MainThreadGLib.cpp:
780         (WTF::scheduleDispatchFunctionsOnMainThread): Use
781         RunLoop::dispatch() instead of GMainLoopSource::scheduleAndDeleteOnDestroy().
782         * wtf/glib/RunLoopGLib.cpp:
783         (WTF::RunLoop::RunLoop): Create and setup the persistent source.
784         (WTF::RunLoop::~RunLoop): Destroy the persistent source.
785         (WTF::RunLoop::stop): Stop the persistent source before stopping
786         the main loop.
787         (WTF::RunLoop::wakeUp): Make the persistent source active. We
788         no longer need to explicitly wakeup the context.
789         (WTF::RunLoop::TimerBase::TimerBase): Create and setup the
790         persistent source.
791         (WTF::RunLoop::TimerBase::~TimerBase): Destroy the persistent source.
792         (WTF::RunLoop::TimerBase::updateReadyTime): Set the ready time
793         according to the fire interval.
794         (WTF::RunLoop::TimerBase::start): Make the persistent source active.
795         (WTF::RunLoop::TimerBase::stop): Stop the persistent source.
796         (WTF::RunLoop::TimerBase::isActive): Return whether the
797         persistent source is active.
798
799 2015-10-28  Filip Pizlo  <fpizlo@apple.com>
800
801         Unreviewed, make sure B3 is disabled on iOS for now.
802
803         * wtf/Platform.h:
804
805 2015-10-28  Filip Pizlo  <fpizlo@apple.com>
806
807         Create a super rough prototype of B3
808         https://bugs.webkit.org/show_bug.cgi?id=150280
809
810         Reviewed by Benjamin Poulain.
811
812         * WTF.xcodeproj/project.pbxproj:
813         * wtf/CMakeLists.txt:
814         * wtf/HashSet.h:
815         (WTF::copyToVector):
816         (WTF::=):
817         * wtf/ListDump.h:
818         (WTF::PointerListDump::PointerListDump):
819         (WTF::PointerListDump::dump):
820         (WTF::MapDump::MapDump):
821         (WTF::listDump):
822         (WTF::pointerListDump):
823         (WTF::sortedListDump):
824         * wtf/MathExtras.h:
825         (WTF::leftShiftWithSaturation):
826         (WTF::rangesOverlap):
827         * wtf/Platform.h:
828         * wtf/ScopedLambda.h: Added.
829         (WTF::scopedLambda):
830         * wtf/SharedTask.h:
831         (WTF::createSharedTask):
832
833 2015-10-28  Alberto Garcia  <berto@igalia.com>
834
835         [SOUP] Cannot build the network process in glibc-based BSD systems
836         https://bugs.webkit.org/show_bug.cgi?id=150618
837
838         Reviewed by Carlos Garcia Campos.
839
840         * wtf/Platform.h: Don't enable HAVE_STAT_BIRTHTIME if the system
841         is using glibc.
842
843 2015-10-21  Filip Pizlo  <fpizlo@apple.com>
844
845         Factor out the graph node worklists from DFG into WTF
846         https://bugs.webkit.org/show_bug.cgi?id=150411
847
848         Reviewed by Geoffrey Garen.
849
850         The new GraphNodeWorklist.h file is basically just the functionality from the old
851         DFGBlockWorklist.h, but templatized to work for any graph node type and any kind of graph
852         node set.
853
854         * WTF.xcodeproj/project.pbxproj:
855         * wtf/CMakeLists.txt:
856         * wtf/GraphNodeWorklist.h: Added.
857         (WTF::GraphNodeWorklist::push):
858         (WTF::GraphNodeWorklist::notEmpty):
859         (WTF::GraphNodeWorklist::pop):
860         (WTF::GraphNodeWith::GraphNodeWith):
861         (WTF::GraphNodeWith::operator bool):
862         (WTF::ExtendedGraphNodeWorklist::ExtendedGraphNodeWorklist):
863         (WTF::ExtendedGraphNodeWorklist::forcePush):
864         (WTF::ExtendedGraphNodeWorklist::push):
865         (WTF::ExtendedGraphNodeWorklist::notEmpty):
866         (WTF::ExtendedGraphNodeWorklist::pop):
867         (WTF::GraphNodeWithOrder::GraphNodeWithOrder):
868         (WTF::GraphNodeWithOrder::operator bool):
869         (WTF::PostOrderGraphNodeWorklist::PostOrderGraphNodeWorklist):
870         (WTF::PostOrderGraphNodeWorklist::~PostOrderGraphNodeWorklist):
871         (WTF::PostOrderGraphNodeWorklist::pushPre):
872         (WTF::PostOrderGraphNodeWorklist::pushPost):
873         (WTF::PostOrderGraphNodeWorklist::push):
874         (WTF::PostOrderGraphNodeWorklist::notEmpty):
875         (WTF::PostOrderGraphNodeWorklist::pop):
876         * wtf/HashTable.h:
877         (WTF::HashTableAddResult::HashTableAddResult):
878         (WTF::HashTableAddResult::operator bool):
879
880 2015-10-20  Tim Horton  <timothy_horton@apple.com>
881
882         Try to fix the build by disabling MAC_GESTURE_EVENTS on 10.9 and 10.10
883
884         * wtf/FeatureDefines.h:
885
886 2015-10-20  Yoav Weiss  <yoav@yoav.ws>
887
888         Rename the PICTURE_SIZES flag to CURRENTSRC
889         https://bugs.webkit.org/show_bug.cgi?id=150275
890
891         Reviewed by Dean Jackson.
892
893         * wtf/FeatureDefines.h:
894
895 2015-10-19  Beth Dakin  <bdakin@apple.com>
896
897         Build fix.
898
899         * wtf/FeatureDefines.h:
900
901 2015-10-19  Tim Horton  <timothy_horton@apple.com>
902
903         Add magnify and rotate gesture event support for Mac
904         https://bugs.webkit.org/show_bug.cgi?id=150179
905         <rdar://problem/8036240>
906
907         Reviewed by Darin Adler.
908
909         * wtf/FeatureDefines.h:
910         New feature flag.
911
912 2015-10-17  Mark Lam  <mark.lam@apple.com>
913
914         Add CPU(X86) to the supported MASM_PROBE CPUs. This was accidentally left out in r191197.
915
916         Not reviewed.
917
918         * wtf/Platform.h:
919
920 2015-10-16  Mark Lam  <mark.lam@apple.com>
921
922         Always enable MASM_PROBE for debug builds.
923         https://bugs.webkit.org/show_bug.cgi?id=150190
924
925         Reviewed by Geoffrey Garen.
926
927         * wtf/Platform.h:
928
929 2015-10-14  Andreas Kling  <akling@apple.com>
930
931         REGRESSION(r190882): Concatenating a character array and an empty string is broken.
932         <https://webkit.org/b/150135>
933
934         Reviewed by Geoffrey Garen.
935
936         StringAdapter templates for raw character arrays were always using 1 as the array length
937         in toString().
938
939         * wtf/text/StringConcatenate.h:
940
941 2015-10-14  Per Arne Vollan  <peavo@outlook.com>
942
943         [Win64] Enable concurrent JIT.
944         https://bugs.webkit.org/show_bug.cgi?id=150098
945
946         Reviewed by Csaba Osztrogonác.
947
948         * wtf/Platform.h:
949
950 2015-10-13  Simon Fraser  <simon.fraser@apple.com>
951
952         Add helper funtion for checking pointer equivalency and use it
953         https://bugs.webkit.org/show_bug.cgi?id=150022
954
955         Reviewed by Darin Adler.
956         
957         Add PointerComparison.h which contains the templated pointer comparison
958         function.
959
960         * WTF.xcodeproj/project.pbxproj:
961         * wtf/PointerComparison.h: Added.
962         (WTF::arePointingToEqualData):
963
964 2015-10-12  Andreas Kling  <akling@apple.com>
965
966         "A + B" with strings shouldn't copy if A or B is empty.
967         <https://webkit.org/b/150034>
968
969         Reviewed by Anders Carlsson.
970
971         Add a fast path to WTF's operator+ magic for concatenation of two strings where
972         one of them is empty. In that case, try to avoid allocation altogether by returning
973         the non-empty string.
974
975         Spotted this while analyzing memory peaks during page load; it turns out we were
976         duplicating whole text resources (JS, CSS) at the end of decoding, below
977         TextResourceDecoder::decodeAndFlush(). That function effectively does:
978
979             return decode() + flush();
980
981         Very often, flush() returns an empty string, so due to the naive operator+,
982         we'd allocate a new StringImpl of length (decode().length() + flush().length())
983         and copy the return value from decode() into it. So silly!
984
985         Had to make the tryMakeString() machinery use String as a return type instead of
986         RefPtr<StringImpl> to make all the right overloads gel. StringTypeAdapter templates
987         are now required to provide a toString() function.
988
989         * wtf/text/StringConcatenate.h:
990         (WTF::StringTypeAdapter<char>::toString):
991         (WTF::StringTypeAdapter<UChar>::toString):
992         (WTF::StringTypeAdapter<Vector<char>>::toString):
993         (WTF::StringTypeAdapter<String>::toString):
994         (WTF::tryMakeString):
995         (WTF::makeString):
996         * wtf/text/StringOperators.h:
997         (WTF::StringAppend::operator String):
998         * wtf/text/StringView.h:
999         (WTF::StringTypeAdapter<StringView>::toString):
1000
1001 2015-10-12  Filip Pizlo  <fpizlo@apple.com>
1002
1003         Unreviewed, fix style in the hopes that it fixes Windows.
1004
1005         * wtf/ParallelHelperPool.cpp:
1006         (WTF::ParallelHelperClient::~ParallelHelperClient):
1007         (WTF::ParallelHelperClient::setTask):
1008         (WTF::ParallelHelperClient::doSomeHelping):
1009         (WTF::ParallelHelperClient::runTaskInParallel):
1010         (WTF::ParallelHelperClient::finish):
1011         (WTF::ParallelHelperClient::claimTask):
1012         (WTF::ParallelHelperClient::runTask):
1013         (WTF::ParallelHelperPool::doSomeHelping):
1014         (WTF::ParallelHelperPool::helperThreadBody):
1015         * wtf/ParallelHelperPool.h:
1016         (WTF::ParallelHelperClient::setFunction):
1017         (WTF::ParallelHelperClient::runFunctionInParallel):
1018         (WTF::ParallelHelperClient::pool):
1019
1020 2015-10-10  Filip Pizlo  <fpizlo@apple.com>
1021
1022         FTL should generate code to call slow paths lazily
1023         https://bugs.webkit.org/show_bug.cgi?id=149936
1024
1025         Reviewed by Saam Barati.
1026
1027         Enables SharedTask to handle any function type, not just void().
1028
1029         It's probably better to use SharedTask instead of std::function in performance-sensitive
1030         code. std::function uses the system malloc and has copy semantics. SharedTask uses FastMalloc
1031         and has aliasing semantics. So, you can just trust that it will have sensible performance
1032         characteristics.
1033
1034         * wtf/ParallelHelperPool.cpp:
1035         (WTF::ParallelHelperClient::~ParallelHelperClient):
1036         (WTF::ParallelHelperClient::setTask):
1037         (WTF::ParallelHelperClient::doSomeHelping):
1038         (WTF::ParallelHelperClient::runTaskInParallel):
1039         (WTF::ParallelHelperClient::finish):
1040         (WTF::ParallelHelperClient::claimTask):
1041         (WTF::ParallelHelperClient::runTask):
1042         (WTF::ParallelHelperPool::doSomeHelping):
1043         (WTF::ParallelHelperPool::helperThreadBody):
1044         * wtf/ParallelHelperPool.h:
1045         (WTF::ParallelHelperClient::setFunction):
1046         (WTF::ParallelHelperClient::runFunctionInParallel):
1047         (WTF::ParallelHelperClient::pool):
1048         * wtf/SharedTask.h:
1049         (WTF::createSharedTask):
1050         (WTF::SharedTask::SharedTask): Deleted.
1051         (WTF::SharedTask::~SharedTask): Deleted.
1052         (WTF::SharedTaskFunctor::SharedTaskFunctor): Deleted.
1053
1054 2015-10-10  Dan Bernstein  <mitz@apple.com>
1055
1056         [iOS] Remove unnecessary iOS version checks
1057         https://bugs.webkit.org/show_bug.cgi?id=150002
1058
1059         Reviewed by Alexey Proskuryakov.
1060
1061         * wtf/Platform.h:
1062
1063 2015-10-10  Dan Bernstein  <mitz@apple.com>
1064
1065         [iOS] Remove project support for iOS 8
1066         https://bugs.webkit.org/show_bug.cgi?id=149993
1067
1068         Reviewed by Alexey Proskuryakov.
1069
1070         * Configurations/Base.xcconfig:
1071         * Configurations/WTF.xcconfig:
1072         * Configurations/mbmalloc.xcconfig:
1073
1074 2015-10-08  Joseph Pecoraro  <pecoraro@apple.com>
1075
1076         Clean up Marked classes
1077         https://bugs.webkit.org/show_bug.cgi?id=149853
1078
1079         Reviewed by Darin Adler.
1080
1081         * wtf/PageBlock.h:
1082         Remove duplicate using statement.
1083
1084 2015-10-08  Joseph Pecoraro  <pecoraro@apple.com>
1085
1086         Remove PageReservation.h clang fixme that has been fixed for a while
1087         https://bugs.webkit.org/show_bug.cgi?id=149908
1088
1089         Reviewed by Csaba Osztrogonác.
1090
1091         * wtf/PageReservation.h:
1092         (WTF::PageReservation::operator bool): Deleted.
1093
1094 2015-10-06  Daniel Bates  <dbates@webkit.org>
1095
1096         Enable XSLT when building WebKit for iOS using the public iOS SDK
1097         https://bugs.webkit.org/show_bug.cgi?id=149827
1098
1099         Reviewed by Alexey Proskuryakov.
1100
1101         * wtf/FeatureDefines.h:
1102
1103 2015-10-04  Filip Pizlo  <fpizlo@apple.com>
1104
1105         Inline cache repatching should be throttled if it happens a lot
1106         https://bugs.webkit.org/show_bug.cgi?id=149796
1107         rdar://problem/22674436
1108
1109         Reviewed by Saam Barati.
1110
1111         Add some helpers for saturated math.
1112
1113         * wtf/MathExtras.h:
1114         (WTF::incrementWithSaturation):
1115         (WTF::leftShiftWithSaturation):
1116
1117 2015-10-01  Brent Fulgham  <bfulgham@apple.com>
1118
1119         [Win] Unreviewed CMake build fixes.
1120
1121         * wtf/CMakeLists.txt: Correct build flags to match
1122         the original project files.
1123
1124 2015-09-30  Commit Queue  <commit-queue@webkit.org>
1125
1126         Unreviewed, rolling out r190324.
1127         https://bugs.webkit.org/show_bug.cgi?id=149671
1128
1129         Caused flaky crashes, rdar://problem/22916304 (Requested by ap
1130         on #webkit).
1131
1132         Reverted changeset:
1133
1134         "ParallelHelperPool::runFunctionInParallel() shouldn't
1135         allocate, and ParallelHelperPool.h shouldn't be included
1136         everywhere"
1137         https://bugs.webkit.org/show_bug.cgi?id=149635
1138         http://trac.webkit.org/changeset/190324
1139
1140 2015-09-29  Filip Pizlo  <fpizlo@apple.com>
1141
1142         ParallelHelperPool::runFunctionInParallel() shouldn't allocate, and ParallelHelperPool.h shouldn't be included everywhere
1143         https://bugs.webkit.org/show_bug.cgi?id=149635
1144
1145         Reviewed by Saam Barati.
1146
1147         * wtf/ParallelHelperPool.h:
1148         (WTF::ParallelHelperClient::runFunctionInParallel): Stack-allocate the task instead of heap-allocating it.
1149
1150 2015-09-29  Filip Pizlo  <fpizlo@apple.com>
1151
1152         GC copy phase spans too many files
1153         https://bugs.webkit.org/show_bug.cgi?id=149586
1154
1155         Reviewed by Andreas Kling.
1156
1157         Extract the load balancing algorithm used by the GC's copy phase into a reusable template.
1158         The GC copy phase now uses this.
1159
1160         * WTF.vcxproj/WTF.vcxproj:
1161         * WTF.vcxproj/WTF.vcxproj.filters:
1162         * WTF.xcodeproj/project.pbxproj:
1163         * wtf/CMakeLists.txt:
1164         * wtf/ParallelVectorIterator.h: Added.
1165         (WTF::ParallelVectorIterator::ParallelVectorIterator):
1166         (WTF::ParallelVectorIterator::iterate):
1167
1168 2015-09-26  Filip Pizlo  <fpizlo@apple.com>
1169
1170         Unreviewed, fix Windows build by adding WTF_EXPORT_PRIVATE in various places.
1171
1172         * wtf/ParallelHelperPool.h:
1173         (WTF::ParallelHelperClient::setFunction):
1174         (WTF::ParallelHelperPool::numberOfThreads):
1175
1176 2015-09-24  Filip Pizlo  <fpizlo@apple.com>
1177
1178         VMs should share GC threads
1179         https://bugs.webkit.org/show_bug.cgi?id=149433
1180         rdar://problem/12859344
1181
1182         Reviewed by Geoffrey Garen.
1183
1184         This adds two major things to WTF: WeakRandom and ParallelHelperPool. WeakRandom was
1185         already in JSC; we're just hoisting it into WTF. It's just a weak random number generator
1186         that's suitable for places where you need just a tiny bit of randomness.
1187
1188         ParallelHelperPool is a new API that simplifies data-parallel algorithms like the JSC GC.
1189         In a data-parallel algorithm, we want to run one task on as many cores as possible and let
1190         the task worry about which subset of the input data to work on. In some cases, the
1191         algorithm will not need to do any load balancing - and if load balancing is required, it's
1192         up to the user. This is appropriate in contexts where the load balancing needs to be
1193         custom-tuned for performance, like the GC's marking phase.
1194
1195         This new API has three concepts: task, client, and pool. A task is a reference counted
1196         object with a run() method, which may be run in parallel. It is usually used to wrap a
1197         functor. A pool is a pool of threads that can run things. A client is a placeholder for a
1198         task. A client can have zero or one tasks. A client must be registered with a pool. When a
1199         client has a task, the pool's threads may choose to run it. If a thread starts running a
1200         task, it will run it to completion. When the task returns on any thread, the client takes
1201         it to mean that the task should be removed. That means that any currently running instances
1202         of the task will finish but no new threads will attempt to run the task. You can easily ask
1203         a client to wait until a task finishes. You can also easily ask a client to run a task on
1204         the current thread in addition to possibly some helper threads from the pool.
1205
1206         For some data-parallel algorithms, programming with ParallelHelperPool is as easy as:
1207
1208         client.runFunctionInParallel(
1209             [=] () {
1210                 do things;
1211             });
1212
1213         Note that you cannot tell ahead of time how many threads will join to help the task.
1214         Threads may become available after the task has already started running. Those threads may
1215         join after the other threads have already started. It's not advisable to make algorithmic
1216         decisions based on client.numberOfActiveThreads(), since that number may change. Usually
1217         the best way to use ParallelHelperPool is with an algorithm that has its own custom
1218         worklist. An example of a very simple custom worklist is the one in the JSC GC's copying
1219         phase - it's just a Vector and an index that indicates the next set of elements to process.
1220
1221         This new API was initially designed to simplify how GCThread works, by replacing Phase with
1222         a callback that contains the phase's workload. I then realized that with a few tweaks, I
1223         could make this somewhat general enough that it might become interesting outside GC. I also
1224         realized that I could use this to enable thread sharing. So, although the API is kinda
1225         quirky, it's grounded in the reality of how the JSC GC does parallelism.
1226
1227         * WTF.vcxproj/WTF.vcxproj:
1228         * WTF.vcxproj/WTF.vcxproj.filters:
1229         * WTF.xcodeproj/project.pbxproj:
1230         * wtf/CMakeLists.txt:
1231         * wtf/ParallelHelperPool.cpp: Added.
1232         (WTF::ParallelHelperClient::ParallelHelperClient):
1233         (WTF::ParallelHelperClient::~ParallelHelperClient):
1234         (WTF::ParallelHelperClient::setTask):
1235         (WTF::ParallelHelperClient::finish):
1236         (WTF::ParallelHelperClient::doSomeHelping):
1237         (WTF::ParallelHelperClient::runTaskInParallel):
1238         (WTF::ParallelHelperClient::claimTask):
1239         (WTF::ParallelHelperClient::runTask):
1240         (WTF::ParallelHelperPool::ParallelHelperPool):
1241         (WTF::ParallelHelperPool::~ParallelHelperPool):
1242         (WTF::ParallelHelperPool::addThreads):
1243         (WTF::ParallelHelperPool::ensureThreads):
1244         (WTF::ParallelHelperPool::doSomeHelping):
1245         (WTF::ParallelHelperPool::didMakeWorkAvailable):
1246         (WTF::ParallelHelperPool::helperThreadBody):
1247         (WTF::ParallelHelperPool::hasClientWithTask):
1248         (WTF::ParallelHelperPool::getClientWithTask):
1249         (WTF::ParallelHelperPool::waitForClientWithTask):
1250         * wtf/ParallelHelperPool.h: Added.
1251         (WTF::ParallelHelperClient::setFunction):
1252         (WTF::ParallelHelperClient::runFunctionInParallel):
1253         (WTF::ParallelHelperClient::pool):
1254         (WTF::ParallelHelperClient::numberOfActiveThreads):
1255         (WTF::ParallelHelperPool::numberOfThreads):
1256         * wtf/SharedTask.h: Added.
1257         (WTF::SharedTask::SharedTask):
1258         (WTF::SharedTask::~SharedTask):
1259         (WTF::SharedTaskFunctor::SharedTaskFunctor):
1260         (WTF::createSharedTask):
1261         * wtf/WeakRandom.h: Copied from Source/JavaScriptCore/runtime/WeakRandom.h.
1262         (WTF::WeakRandom::WeakRandom):
1263         (WTF::WeakRandom::initializeSeed):
1264         (WTF::WeakRandom::seedUnsafe):
1265         (WTF::WeakRandom::getUint32):
1266         (WTF::WeakRandom::advance):
1267         (JSC::WeakRandom::WeakRandom): Deleted.
1268         (JSC::WeakRandom::seedUnsafe): Deleted.
1269         (JSC::WeakRandom::getUint32): Deleted.
1270         (JSC::WeakRandom::advance): Deleted.
1271         (JSC::WeakRandom::initializeSeed): Deleted.
1272
1273 2015-09-25  Alex Christensen  <achristensen@webkit.org>
1274
1275         Clean up CMake build on Mac
1276         https://bugs.webkit.org/show_bug.cgi?id=149573
1277
1278         Reviewed by Chris Dumez.
1279
1280         * wtf/PlatformMac.cmake:
1281
1282 2015-09-25  Alex Christensen  <achristensen@webkit.org>
1283
1284         [Win] Switch to CMake
1285         https://bugs.webkit.org/show_bug.cgi?id=148111
1286
1287         Reviewed by Brent Fulgham.
1288
1289         * WTF.vcxproj/WTF.proj:
1290
1291 2015-09-25  Joseph Pecoraro  <pecoraro@apple.com>
1292
1293         Simplify Stopwatch::elapsedTime
1294         https://bugs.webkit.org/show_bug.cgi?id=149538
1295
1296         Reviewed by Darin Adler.
1297
1298         * wtf/Stopwatch.h:
1299         (WTF::Stopwatch::elapsedTime):
1300         Simplify by not starting/stopping but just computing without updating members.
1301
1302 2015-09-25  Brent Fulgham  <bfulgham@apple.com>
1303
1304         [Win] Unreviewed build fix.
1305
1306         * wtf/FeatureDefines.h: Don't turn STREAMS_API on by default
1307         on Windows.
1308
1309 2015-09-24  Ryosuke Niwa  <rniwa@webkit.org>
1310
1311         Ran sort-Xcode-project-file.
1312
1313         * WTF.xcodeproj/project.pbxproj:
1314
1315 2015-09-23  Andy Estes  <aestes@apple.com>
1316
1317         Disable QuickLook on watchOS
1318         https://bugs.webkit.org/show_bug.cgi?id=149508
1319         <rdar://problem/22517968>
1320
1321         Reviewed by Dan Bernstein.
1322
1323         * wtf/Platform.h:
1324
1325 2015-09-22  Andy Estes  <aestes@apple.com>
1326
1327         Disable QuickLook on tvOS
1328         https://bugs.webkit.org/show_bug.cgi?id=149492
1329         <rdar://problem/22741586>
1330
1331         Reviewed by Dan Bernstein.
1332
1333         * wtf/Platform.h: Stopped enabling QuickLook on tvOS.
1334
1335 2015-09-22  Filip Pizlo  <fpizlo@apple.com>
1336
1337         Get rid of ENABLE(PARALLEL_GC)
1338         https://bugs.webkit.org/show_bug.cgi?id=149436
1339
1340         Reviewed by Mark Lam.
1341
1342         We always enable parallel GC everywhere but Windows, and it doesn't look like it was disabled
1343         there for any good reason. So, get rid of the flag.
1344
1345         * wtf/MainThread.cpp:
1346         (WTF::canAccessThreadLocalDataForThread):
1347         (WTF::initializeGCThreads):
1348         (WTF::registerGCThread):
1349         (WTF::isMainThreadOrGCThread):
1350         * wtf/Platform.h:
1351
1352 2015-09-22  Filip Pizlo  <fpizlo@apple.com>
1353
1354         Get rid of ENABLE(GGC)
1355         https://bugs.webkit.org/show_bug.cgi?id=149472
1356
1357         Reviewed by Mark Hahnenberg and Mark Lam.
1358
1359         * wtf/Platform.h:
1360
1361 2015-09-21  Filip Pizlo  <fpizlo@apple.com>
1362
1363         Always use the compiler's CAS implementation and get rid of ENABLE(COMPARE_AND_SWAP)
1364         https://bugs.webkit.org/show_bug.cgi?id=149438
1365
1366         Reviewed by Mark Lam.
1367
1368         * wtf/Atomics.h: Make weakCompareAndSwap() just forward to the system CAS via WTF::Atomic.
1369         (WTF::weakCompareAndSwap):
1370         (WTF::weakCompareAndSwapUIntPtr): Deleted.
1371         (WTF::weakCompareAndSwapSize): Deleted.
1372         * wtf/Bitmap.h: Small changes to use the new API.
1373         (WTF::WordType>::concurrentTestAndSet):
1374         * wtf/Platform.h: Remove ENABLE(COMPARE_AND_SWAP)
1375
1376 2015-09-21  Csaba Osztrogonác  <ossy@webkit.org>
1377
1378         Remove old GCC cruft from wtf/StdLibExtras.h
1379         https://bugs.webkit.org/show_bug.cgi?id=149401
1380
1381         Reviewed by Alex Christensen.
1382
1383         * wtf/StdLibExtras.h:
1384
1385 2015-09-21  Andy Estes  <aestes@apple.com>
1386
1387         Disable Parental Controls on the Apple TV platform
1388         https://bugs.webkit.org/show_bug.cgi?id=149421
1389
1390         Reviewed by Darin Adler.
1391
1392         * wtf/Platform.h:
1393
1394 2015-09-21  Filip Pizlo  <fpizlo@apple.com>
1395
1396         JSC should infer property types
1397         https://bugs.webkit.org/show_bug.cgi?id=148610
1398
1399         Reviewed by Geoffrey Garen.
1400
1401         * wtf/HashTable.h:
1402         (WTF::HashTableAddResult::HashTableAddResult): Make it possible to say "HashMap::AddResult result" without assigning anything to it yet.
1403         * wtf/PrintStream.h:
1404         (WTF::printInternal): Beef up printing of some common WTF types, in particular RefPtr<UniquedStringImpl>.
1405
1406 2015-09-20  Youenn Fablet  <youenn.fablet@crf.canon.fr>
1407
1408         Remove XHR_TIMEOUT compilation guard
1409         https://bugs.webkit.org/show_bug.cgi?id=149260
1410
1411         Reviewed by Benjamin Poulain.
1412
1413         * wtf/FeatureDefines.h:
1414
1415 2015-09-17  Filip Pizlo  <fpizlo@apple.com>
1416
1417         Unreviewed, revert unintended change.
1418
1419         * benchmarks/LockSpeedTest.cpp:
1420         (main):
1421
1422 2015-09-15  Ryosuke Niwa  <rniwa@webkit.org>
1423
1424         Add ShadowRoot interface and Element.prototype.attachShadow
1425         https://bugs.webkit.org/show_bug.cgi?id=149187
1426
1427         Reviewed by Antti Koivisto.
1428
1429         * wtf/FeatureDefines.h:
1430
1431
1432 2015-09-11  Keith Miller  <keith_miller@apple.com>
1433
1434         cryptographicallyRandomValuesFromOS should use CCRandomCopyBytes when available.
1435         https://bugs.webkit.org/show_bug.cgi?id=148439
1436
1437         Reviewed by Alexey Proskuryakov.
1438
1439         Recently, we switched to using arc4random_buf on Darwin but further research indicates that
1440         arc4random_buf has the same behavior we had before and thus we were just pushing the problem
1441         further down the stack. CCRandomCopyBytes, however, appears to be more advanced and has much
1442         better error handling than we had before.
1443
1444         * WTF.xcodeproj/project.pbxproj:
1445         * wtf/OSRandomSource.cpp:
1446         (WTF::cryptographicallyRandomValuesFromOS):
1447         * wtf/spi/darwin/CommonCryptoSPI.h: Added.
1448
1449 2015-09-08  Filip Pizlo  <fpizlo@apple.com>
1450
1451         There should be one stub hanging off an inline cache that contains code for all of the cases, rather than forming a linked list consisting of one stub per case
1452         https://bugs.webkit.org/show_bug.cgi?id=148717
1453
1454         Reviewed by Michael Saboff.
1455
1456         Beef up dumping a bit.
1457
1458         * wtf/PrintStream.h:
1459         (WTF::pointerDump):
1460         (WTF::printInternal):
1461
1462 2015-09-08  Mark Lam  <mark.lam@apple.com>
1463
1464         GC stack scan should include ABI red zone.
1465         https://bugs.webkit.org/show_bug.cgi?id=148976
1466
1467         Reviewed by Geoffrey Garen and Benjamin Poulain.
1468
1469         * wtf/StackBounds.h:
1470         (WTF::StackBounds::origin):
1471         (WTF::StackBounds::end):
1472         (WTF::StackBounds::size):
1473
1474 2015-09-04  Csaba Osztrogonác  <ossy@webkit.org>
1475
1476         Enable reference qualified functions for GCC
1477         https://bugs.webkit.org/show_bug.cgi?id=148526
1478
1479         Reviewed by Darin Adler.
1480
1481         * wtf/Compiler.h:
1482
1483 2015-09-04  Csaba Osztrogonác  <ossy@webkit.org>
1484
1485         webkit-unassigned@lists.webkit.org
1486         https://bugs.webkit.org/show_bug.cgi?id=148525
1487
1488         Reviewed by Darin Adler.
1489
1490         * wtf/Compiler.h:
1491
1492 2015-08-29  Zan Dobersek  <zdobersek@igalia.com>
1493
1494         [WTF] Improve a ParkingLot::parkConditionally() comment for a libstdc++ workaround
1495         https://bugs.webkit.org/show_bug.cgi?id=148571
1496
1497         Reviewed by Filip Pizlo.
1498
1499         * wtf/ParkingLot.cpp:
1500         (WTF::ParkingLot::parkConditionally): Adjust the comment about the workaround for
1501         the libstdc++ std::condition_variable implementation, linking to the WebKit bug
1502         that dissected the problem and the GCC bug that originally reported the problem.
1503
1504 2015-08-28  Anders Carlsson  <andersca@apple.com>
1505
1506         Remove the #if PLATFORM(MAC) in DeprecatedSymbolsUsedBySafari.mm so we'll actually build it on iOS.
1507
1508         Reviewed by Dan Bernstein.
1509
1510         * wtf/mac/DeprecatedSymbolsUsedBySafari.mm:
1511
1512 2015-08-27  Anders Carlsson  <andersca@apple.com>
1513
1514         Define legacy main thread calling functions for iOS as well
1515         https://bugs.webkit.org/show_bug.cgi?id=148530
1516
1517         Reviewed by Tim Horton.
1518
1519         * wtf/mac/DeprecatedSymbolsUsedBySafari.mm:
1520
1521 2015-08-26  Anders Carlsson  <andersca@apple.com>
1522
1523         Fix build.
1524
1525         * wtf/WorkQueue.cpp:
1526
1527 2015-08-26  Anders Carlsson  <andersca@apple.com>
1528
1529         Add and implement WorkQueue::concurrentApply
1530         https://bugs.webkit.org/show_bug.cgi?id=148488
1531
1532         Reviewed by Geoffrey Garen.
1533
1534         WorkQueue::concurrentApply is modeled after dispatch_apply, and on Cocoa it uses dispatch_apply directly.
1535         For other ports there's a generic concurrentApply implemented using our threading primitives.
1536         
1537         * wtf/NeverDestroyed.h:
1538         (WTF::LazyNeverDestroyed::operator->):
1539         * wtf/WorkQueue.cpp:
1540         (WTF::WorkQueue::concurrentApply):
1541         * wtf/WorkQueue.h:
1542         * wtf/cocoa/WorkQueueCocoa.cpp:
1543         (WTF::WorkQueue::concurrentApply):
1544
1545 2015-08-25  Filip Pizlo  <fpizlo@apple.com>
1546
1547         Node::origin should be able to tell you if it's OK to exit
1548         https://bugs.webkit.org/show_bug.cgi?id=145204
1549
1550         Reviewed by Geoffrey Garen.
1551
1552         * wtf/Insertion.h:
1553         (WTF::executeInsertions): Add a useful assertion. This come into play because JSC will use UINT_MAX as "invalid index", and that ought to trigger this assertion.
1554
1555 2015-08-25  Csaba Osztrogonác  <ossy@webkit.org>
1556
1557         Require GCC version at least 4.9
1558         https://bugs.webkit.org/show_bug.cgi?id=148430
1559
1560         Reviewed by Darin Adler.
1561
1562         * wtf/Compiler.h:
1563
1564 2015-08-22  Anders Carlsson  <andersca@apple.com>
1565
1566         std::once_flag needs to be static.
1567
1568         * wtf/mac/DeprecatedSymbolsUsedBySafari.mm:
1569         (WTF::MainThreadFunctionTracker::singleton):
1570
1571 2015-08-21  Anders Carlsson  <andersca@apple.com>
1572
1573         Build fix.
1574
1575         * wtf/MainThread.h:
1576
1577 2015-08-21  Anders Carlsson  <andersca@apple.com>
1578
1579         Address review feedback from Darin.
1580
1581         * wtf/MainThread.h:
1582         * wtf/mac/DeprecatedSymbolsUsedBySafari.mm:
1583         (WTF::callOnMainThread):
1584         (WTF::cancelCallOnMainThread):
1585
1586 2015-08-21  Anders Carlsson  <andersca@apple.com>
1587
1588         Deprecate the old school callOnMainThread/cancelCallOnMainThread functions
1589         https://bugs.webkit.org/show_bug.cgi?id=148327
1590
1591         Reviewed by Sam Weinig.
1592
1593         * wtf/MainThread.cpp:
1594         (WTF::functionQueue):
1595         (WTF::dispatchFunctionsFromMainThread):
1596         (WTF::callOnMainThread):
1597         Change the function queue to be a queue of std::function<void ()> and get rid of dead code.
1598
1599         * wtf/MainThread.h:
1600         Conditionalize callOnMainThread and cancelCallOnMainThread because Safari on Mavericks still expects to them to be
1601         declared in MainThread.h under 10.9.
1602
1603         * wtf/mac/DeprecatedSymbolsUsedBySafari.mm:
1604         Add a MainThreadFunctionTracker singleton that keeps track of scheduled functions so we can ensure that they're not
1605         called if they're cancelled.
1606
1607         (WTF::MainThreadFunctionTracker::singleton):
1608         Return the singleton.
1609
1610         (WTF::MainThreadFunctionTracker::callOnMainThread):
1611         Add the function/context pair to our map and schedule the function to be run on the main thread.
1612         If the function has been removed, don't call it.
1613
1614         (WTF::MainThreadFunctionTracker::cancelCallOnMainThread):
1615         Remove all entries with the given function/context pair.
1616
1617         (WTF::MainThreadFunctionTracker::addFunction):
1618         Add the function/context pair to the map and return the unique identifier.
1619
1620         (WTF::MainThreadFunctionTracker::removeIdentifier):
1621         Look up the identifier and remove it if it still exists. If it exists we know that it hasn't been canceled and that we can call it.
1622
1623         (WTF::MainThreadFunctionTracker::removeFunctions):
1624         Remove all function identifiers matched by the function/context pair.
1625
1626         (WTF::callOnMainThread):
1627         Implement using MainThreadFunctionTracker.
1628
1629         (WTF::cancelCallOnMainThread):
1630         Implement using MainThreadFunctionTracker.
1631
1632 2015-08-21  Anders Carlsson  <andersca@apple.com>
1633
1634         Get rid of uses of the old callOnMainThread function that takes a function ptr + context
1635         https://bugs.webkit.org/show_bug.cgi?id=148324
1636
1637         Reviewed by Tim Horton.
1638
1639         * wtf/text/cf/StringImplCF.cpp:
1640         (WTF::StringWrapperCFAllocator::deallocate):
1641         (WTF::StringWrapperCFAllocator::deallocateOnMainThread): Deleted.
1642
1643 2015-08-20  Commit Queue  <commit-queue@webkit.org>
1644
1645         Unreviewed, rolling out r188717 and r188719.
1646         https://bugs.webkit.org/show_bug.cgi?id=148272
1647
1648         Broke the Mavericks build (Requested by andersca on #webkit).
1649
1650         Reverted changesets:
1651
1652         "Merge Lock and LockBase"
1653         https://bugs.webkit.org/show_bug.cgi?id=148266
1654         http://trac.webkit.org/changeset/188717
1655
1656         "Merge ConditionBase and Condition"
1657         https://bugs.webkit.org/show_bug.cgi?id=148270
1658         http://trac.webkit.org/changeset/188719
1659
1660 2015-08-20  Anders Carlsson  <andersca@apple.com>
1661
1662         Merge ConditionBase and Condition
1663         https://bugs.webkit.org/show_bug.cgi?id=148270
1664
1665         Reviewed by Filip Pizlo.
1666
1667         * wtf/Condition.h:
1668         Direct initialize m_hasWaiters so Condition gets a constexpr constructor.
1669
1670         * wtf/Lock.h:
1671         Remove a now outdated comment.
1672
1673 2015-08-20  Anders Carlsson  <andersca@apple.com>
1674
1675         Merge Lock and LockBase
1676         https://bugs.webkit.org/show_bug.cgi?id=148266
1677
1678         Reviewed by Filip Pizlo.
1679
1680         * wtf/Atomics.h:
1681         (WTF::Atomic::Atomic):
1682         Add a default constructor as well as a constexpr constructor that takes a value.
1683
1684         * wtf/Lock.cpp:
1685         (WTF::Lock::lockSlow):
1686         (WTF::Lock::unlockSlow):
1687         Rename LockBase to Lock.
1688
1689         * wtf/Lock.h:
1690         Rename LockBase to Lock and direct-initialize Atomic to 0. Since the Atomic constructor is constexpr,
1691         Lock also gets a constexpr constructor. Change the LockBase -> StaticLock typedef and add a fixme.
1692
1693         * wtf/WordLock.h:
1694         Direct initialize m_word to 0.
1695
1696 2015-08-19  Filip Pizlo  <fpizlo@apple.com>
1697
1698         Remove WTF::SpinLock
1699         https://bugs.webkit.org/show_bug.cgi?id=148208
1700
1701         Reviewed by Geoffrey Garen.
1702
1703         Remove the SpinLock.h file and remove references to the SpinLock class. Put the old SpinLock
1704         algorithm in LockSpeedTest.cpp - which isn't compiled as part of a WTF or WebKit build - just
1705         so we can still benchmark our locking algorithms against a spinlock baseline.
1706
1707         * WTF.vcxproj/WTF.vcxproj:
1708         * WTF.xcodeproj/project.pbxproj:
1709         * benchmarks/LockSpeedTest.cpp:
1710         * wtf/CMakeLists.txt:
1711         * wtf/Lock.h:
1712         * wtf/SpinLock.h: Removed.
1713         * wtf/WordLock.h:
1714
1715 2015-08-19  Alex Christensen  <achristensen@webkit.org>
1716
1717         CMake Windows build should not include files directly from other Source directories
1718         https://bugs.webkit.org/show_bug.cgi?id=148198
1719
1720         Reviewed by Brent Fulgham.
1721
1722         * wtf/CMakeLists.txt:
1723         * wtf/PlatformWin.cmake:
1724
1725 2015-08-18  Filip Pizlo  <fpizlo@apple.com>
1726
1727         Replace all uses of std::mutex/std::condition_variable with WTF::Lock/WTF::Condition
1728         https://bugs.webkit.org/show_bug.cgi?id=148140
1729
1730         Reviewed by Geoffrey Garen.
1731
1732         Also beef up Condition by giving it a StaticCondition variant.
1733
1734         * wtf/Condition.h:
1735         (WTF::ConditionBase::notifyAll):
1736         (WTF::ConditionBase::waitForSecondsImpl):
1737         (WTF::ConditionBase::absoluteFromRelative):
1738         (WTF::Condition::Condition):
1739         (WTF::Condition::notifyAll): Deleted.
1740         (WTF::Condition::waitForSecondsImpl): Deleted.
1741         (WTF::Condition::absoluteFromRelative): Deleted.
1742         * wtf/CryptographicallyRandomNumber.cpp:
1743         * wtf/HashTable.cpp:
1744         (WTF::HashTableStats::recordCollisionAtCount):
1745         (WTF::HashTableStats::dumpStats):
1746         (WTF::hashTableStatsMutex): Deleted.
1747         * wtf/HashTable.h:
1748         (WTF::KeyTraits>::HashTable):
1749         (WTF::KeyTraits>::invalidateIterators):
1750         (WTF::addIterator):
1751         (WTF::removeIterator):
1752         * wtf/Lock.h:
1753         * wtf/MainThread.cpp:
1754         (WTF::functionQueue):
1755         (WTF::dispatchFunctionsFromMainThread):
1756         (WTF::callOnMainThread):
1757         (WTF::cancelCallOnMainThread):
1758         (WTF::mainThreadFunctionQueueMutex): Deleted.
1759         * wtf/StackStats.cpp:
1760         (WTF::StackStats::PerThreadStats::PerThreadStats):
1761         (WTF::StackStats::CheckPoint::CheckPoint):
1762         (WTF::StackStats::CheckPoint::~CheckPoint):
1763         (WTF::StackStats::probe):
1764         (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
1765         (WTF::StackStats::LayoutCheckPoint::~LayoutCheckPoint):
1766         (WTF::StackStats::initialize): Deleted.
1767         * wtf/StackStats.h:
1768         (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
1769         (WTF::StackStats::probe):
1770         (WTF::StackStats::initialize): Deleted.
1771         * wtf/ThreadingPthreads.cpp:
1772         (WTF::initializeThreading):
1773         * wtf/mac/DeprecatedSymbolsUsedBySafari.mm:
1774         (WTF::callOnMainThread):
1775         (WTF::lockAtomicallyInitializedStaticMutex):
1776         (WTF::unlockAtomicallyInitializedStaticMutex):
1777         (WTF::atomicallyInitializedStaticMutex): Deleted.
1778         * wtf/text/StringView.cpp:
1779         (WTF::StringView::UnderlyingString::UnderlyingString):
1780         (WTF::underlyingStrings):
1781         (WTF::StringView::invalidate):
1782         (WTF::StringView::adoptUnderlyingString):
1783         (WTF::StringView::setUnderlyingString):
1784         (WTF::underlyingStringsMutex): Deleted.
1785         * wtf/unicode/icu/CollatorICU.cpp:
1786         (WTF::Collator::Collator):
1787         (WTF::Collator::~Collator):
1788         (WTF::cachedCollatorMutex): Deleted.
1789
1790 2015-08-18  Zan Dobersek  <zdobersek@igalia.com>
1791
1792         [GLib] GMainLoopSource should receive the std::function<> objects through rvalue references
1793         https://bugs.webkit.org/show_bug.cgi?id=147981
1794
1795         Reviewed by Carlos Garcia Campos.
1796
1797         Scheduling methods on GMainLoopSource and GThreadSafeMainLoopSource should
1798         have the std::function<> objects passed through rvalue references, and should
1799         move the passed-in objects forward when required.
1800
1801         * wtf/glib/GMainLoopSource.cpp:
1802         (WTF::GMainLoopSource::schedule):
1803         (WTF::GMainLoopSource::scheduleAfterDelay):
1804         (WTF::GMainLoopSource::scheduleAndDeleteOnDestroy):
1805         (WTF::GMainLoopSource::scheduleAfterDelayAndDeleteOnDestroy):
1806         * wtf/glib/GMainLoopSource.h:
1807         * wtf/glib/GThreadSafeMainLoopSource.cpp:
1808         (WTF::GThreadSafeMainLoopSource::schedule):
1809         (WTF::GThreadSafeMainLoopSource::scheduleAfterDelay):
1810         * wtf/glib/GThreadSafeMainLoopSource.h:
1811
1812 2015-08-18  Eric Carlson  <eric.carlson@apple.com>
1813
1814         Remove "platform text track menu"
1815         https://bugs.webkit.org/show_bug.cgi?id=148139
1816
1817         Reviewed by Jer Noble.
1818
1819         * wtf/Platform.h: Remove PLATFORM_TEXT_TRACK_MENU.
1820
1821 2015-08-18  Filip Pizlo  <fpizlo@apple.com>
1822
1823         WTF::Condition should have a fast path for notifyOne/notifyAll that avoids calling unparkOne/unparkAll
1824         https://bugs.webkit.org/show_bug.cgi?id=148090
1825
1826         Reviewed by Geoffrey Garen.
1827
1828         This change makes notifyOne()/notifyAll() blazing fast when nobody is waiting, by using the
1829         various hooks that ParkingLot gives us to maintain a m_hasWaiters variable. When it's false, it
1830         means that any unpark operation would simply return immediately.
1831
1832         This is a 45% speed-up for the 1-producer/1-consumer scenario with a 100-element queue when you
1833         use the notifyOne()-per-enqueue style. What's cool about this change is that you can now safely
1834         call notifyOne() (or notifyAll()) out of paranoia, just in case someone might be waiting. It's
1835         free to do so if nobody is waiting!
1836
1837         * wtf/Condition.h:
1838         (WTF::Condition::Condition):
1839         (WTF::Condition::waitUntil):
1840         (WTF::Condition::notifyOne):
1841         (WTF::Condition::notifyAll):
1842
1843 2015-08-17  Filip Pizlo  <fpizlo@apple.com>
1844
1845         Replace all remaining uses of WTF::Mutex with WTF::Lock
1846         https://bugs.webkit.org/show_bug.cgi?id=148089
1847
1848         Reviewed by Geoffrey Garen.
1849
1850         This also beefs up and rationalizes the Condition API, so that it can deal with units of time
1851         other than just steady_clock. This makes it easier to port ThreadCondition and
1852         std::condition_variable code over to Condition. This patch does not take a position on what
1853         kind of time is best; from reading a lot of the uses in WebCore, it seems like our use of
1854         double to measure seconds is often nicer than the many different classes in std::chrono.
1855
1856         Also added a Condition speed test, to make sure that all of this is a good idea. And indeed it
1857         is. The 1-producer/1-consumer scenario with a 100-element queue runs 36x faster using
1858         Lock/Condition than Mutex/ThreadCondition when you use the notifyOne()-per-enqueue style. It
1859         runs 58x faster with Lock/Condition when you use the notifyAll()-at-boundary style. Note that
1860         I have a bug open for making the notifyOne()-per-enqueue style even faster:
1861         https://bugs.webkit.org/show_bug.cgi?id=148090. Also, the 10-consumer/10-producer scenario with
1862         a 100-element queue runs 20x faster with Lock/Condition for notifyOne()-per-enqueue and 30x
1863         faster with notifyAll()-at-boundary. The only way to tweak the test to get
1864         Mutex/ThreadCondition to win is to have one producer, one consumer, a 1-element queue, and use
1865         the notifyOne()-per-enqueue style. In that case, one of the two threads is going to be waiting
1866         most of the time and the test basically measures wake-up latency and nothing else. Because
1867         Condition::wait() does a little bit more work than ThreadCondition::wait(),
1868         Mutex/ThreadCondition end up running 3% faster in this test case. But if you vary any of the
1869         parameters of the test, Mutex/ThreadCondition ends up losing - all it takes is more threads or
1870         a queue size of 5 or more. To my knowledge, we never do producer/consumer with a queue bounded
1871         to one element precisely because that approach is the least efficient regardless of locking
1872         algorithm. For example, neither WTF::MessageQueue nor DFG::Worklist have any bounds on their
1873         queue size. So, it seems that replacing all uses of system mutexes and condition variables with
1874         our own thing is a great idea.
1875
1876         * benchmarks/LockSpeedTest.cpp:
1877         * benchmarks/ConditionSpeedTest.cpp: Added.
1878         * wtf/Condition.h:
1879         (WTF::Condition::Condition):
1880         (WTF::Condition::waitUntil):
1881         (WTF::Condition::waitFor):
1882         (WTF::Condition::wait):
1883         (WTF::Condition::waitUntilWallClockSeconds):
1884         (WTF::Condition::waitUntilMonotonicClockSeconds):
1885         (WTF::Condition::notifyOne):
1886         (WTF::Condition::notifyAll):
1887         (WTF::Condition::waitForSecondsImpl):
1888         (WTF::Condition::waitForImpl):
1889         (WTF::Condition::absoluteFromRelative):
1890         * wtf/MessageQueue.h:
1891         (WTF::MessageQueue::infiniteTime):
1892         (WTF::MessageQueue<DataType>::append):
1893         (WTF::MessageQueue<DataType>::appendAndKill):
1894         (WTF::MessageQueue<DataType>::appendAndCheckEmpty):
1895         (WTF::MessageQueue<DataType>::prepend):
1896         (WTF::MessageQueue<DataType>::removeIf):
1897         (WTF::MessageQueue<DataType>::isEmpty):
1898         (WTF::MessageQueue<DataType>::kill):
1899         (WTF::MessageQueue<DataType>::killed):
1900         * wtf/ParallelJobsGeneric.cpp:
1901         (WTF::ParallelEnvironment::ThreadPrivate::execute):
1902         (WTF::ParallelEnvironment::ThreadPrivate::waitForFinish):
1903         (WTF::ParallelEnvironment::ThreadPrivate::workerThread):
1904         * wtf/ParallelJobsGeneric.h:
1905         * wtf/ParkingLot.cpp:
1906         (WTF::ParkingLot::parkConditionally):
1907         * wtf/ParkingLot.h:
1908         (WTF::ParkingLot::compareAndPark):
1909         * wtf/ThreadingPthreads.cpp:
1910         (WTF::initializeThreading):
1911         * wtf/ThreadingWin.cpp:
1912         (WTF::initializeThreading):
1913         * wtf/dtoa.cpp:
1914         (WTF::pow5mult):
1915         * wtf/dtoa.h:
1916
1917 2015-08-17  Alex Christensen  <achristensen@webkit.org>
1918
1919         Build Debug Suffix on Windows with CMake
1920         https://bugs.webkit.org/show_bug.cgi?id=148083
1921
1922         Reviewed by Brent Fulgham.
1923
1924         * wtf/PlatformWin.cmake:
1925         Add DEBUG_SUFFIX
1926
1927 2015-08-17  Myles C. Maxfield  <mmaxfield@apple.com>
1928
1929         Implement IntegerHasher
1930         https://bugs.webkit.org/show_bug.cgi?id=147866
1931
1932         Reviewed by Darin Adler and Anders Carlsson.
1933
1934         Rename StringHasher.h to Hasher.h, and include an IntegerHasher class.
1935
1936         * WTF.vcxproj/WTF.vcxproj: Update to target new file.
1937         * WTF.vcxproj/WTF.vcxproj.filters: Ditto.
1938         * WTF.xcodeproj/project.pbxproj: Ditto.
1939         * wtf/CMakeLists.txt: Ditto.
1940         * wtf/Hasher.h: Renamed from Source/WTF/wtf/StringHasher.h.
1941         * wtf/text/CString.cpp: Use new #include
1942         * wtf/text/StringHash.h: Ditto.
1943         * wtf/text/StringImpl.h: Ditto.
1944         * wtf/unicode/UTF8.cpp: Ditto.
1945
1946 2015-08-17  Alex Christensen  <achristensen@webkit.org>
1947
1948         Move some commands from ./CMakeLists.txt to Source/cmake
1949         https://bugs.webkit.org/show_bug.cgi?id=148003
1950
1951         Reviewed by Brent Fulgham.
1952
1953         * CMakeLists.txt:
1954         Added commands needed to build WTF by itself.
1955
1956 2015-08-14  Filip Pizlo  <fpizlo@apple.com>
1957
1958         Use WTF::Lock and WTF::Condition instead of WTF::Mutex, WTF::ThreadCondition, std::mutex, and std::condition_variable
1959         https://bugs.webkit.org/show_bug.cgi?id=147999
1960
1961         Reviewed by Geoffrey Garen.
1962
1963         Relanding after fixing a deadlock on Linux.
1964
1965         * wtf/Condition.h: "using WTF::Condition".
1966         * wtf/Lock.h:
1967         (WTF::LockBase::lock):
1968         (WTF::LockBase::tryLock): Add tryLock() because it turns out that we use it sometimes.
1969         (WTF::LockBase::try_lock): unique_lock needs this.
1970         (WTF::LockBase::unlock):
1971         * wtf/ParkingLot.cpp:
1972         (WTF::ParkingLot::parkConditionally): Work around a Linux C++ bug where wait_until with time_point::max() immediately returns and doesn't flash the lock.
1973
1974 2015-08-14  Keith Miller  <keith_miller@apple.com>
1975
1976         cryptographicallyRandomValuesFromOS should use arc4random_buf on Darwin.
1977         https://bugs.webkit.org/show_bug.cgi?id=148038
1978
1979         Reviewed by Geoffrey Garen.
1980
1981         Currently, we open a file descriptor to /dev/urandom, which can sometimes
1982         fail to open. Using arc4random_buf instead should get around this issue.
1983
1984         * wtf/OSRandomSource.cpp:
1985         (WTF::cryptographicallyRandomValuesFromOS):
1986
1987 2015-08-14  Commit Queue  <commit-queue@webkit.org>
1988
1989         Unreviewed, rolling out r188444.
1990         https://bugs.webkit.org/show_bug.cgi?id=148029
1991
1992         Broke GTK and EFL (see bug #148027) (Requested by philn on
1993         #webkit).
1994
1995         Reverted changeset:
1996
1997         "Use WTF::Lock and WTF::Condition instead of WTF::Mutex,
1998         WTF::ThreadCondition, std::mutex, and std::condition_variable"
1999         https://bugs.webkit.org/show_bug.cgi?id=147999
2000         http://trac.webkit.org/changeset/188444
2001
2002 2015-08-13  Filip Pizlo  <fpizlo@apple.com>
2003
2004         Use WTF::Lock and WTF::Condition instead of WTF::Mutex, WTF::ThreadCondition, std::mutex, and std::condition_variable
2005         https://bugs.webkit.org/show_bug.cgi?id=147999
2006
2007         Reviewed by Geoffrey Garen.
2008
2009         * wtf/Condition.h: "using WTF::Condition".
2010         * wtf/Lock.h:
2011         (WTF::LockBase::lock):
2012         (WTF::LockBase::tryLock): Add tryLock() because it turns out that we use it sometimes.
2013         (WTF::LockBase::try_lock): unique_lock needs this.
2014         (WTF::LockBase::unlock):
2015
2016 2015-08-13  Commit Queue  <commit-queue@webkit.org>
2017
2018         Unreviewed, rolling out r188428.
2019         https://bugs.webkit.org/show_bug.cgi?id=148015
2020
2021         broke cmake build (Requested by alexchristensen on #webkit).
2022
2023         Reverted changeset:
2024
2025         "Move some commands from ./CMakeLists.txt to Source/cmake"
2026         https://bugs.webkit.org/show_bug.cgi?id=148003
2027         http://trac.webkit.org/changeset/188428
2028
2029 2015-08-13  Alex Christensen  <achristensen@webkit.org>
2030
2031         Move some commands from ./CMakeLists.txt to Source/cmake
2032         https://bugs.webkit.org/show_bug.cgi?id=148003
2033
2034         Reviewed by Brent Fulgham.
2035
2036         * CMakeLists.txt:
2037         Added commands needed to build WTF by itself.
2038
2039 2015-08-13  Mark Lam  <mark.lam@apple.com>
2040
2041         WorkQueue::dispatchAfter() on Windows fires early.
2042         https://bugs.webkit.org/show_bug.cgi?id=147992
2043
2044         Reviewed by Brent Fulgham.
2045
2046         The Windows implementation of WorkQueue::dispatchAfter() uses CreateTimerQueueTimer().
2047         Unfortunately, CreateTimerQueueTimer() is sloppy and can fire early.  We need to compensate
2048         for this slop to ensure that the specified duration does expire before the callback function
2049         is called.  Otherwise, the JSC watchdog (which depends on this) can fail randomly.
2050
2051         * wtf/win/WorkQueueWin.cpp:
2052         (WTF::WorkQueue::dispatchAfter):
2053
2054 2015-08-13  Filip Pizlo  <fpizlo@apple.com>
2055
2056         WTF should have a compact Condition object to use with Lock
2057         https://bugs.webkit.org/show_bug.cgi?id=147986
2058
2059         Reviewed by Geoffrey Garen.
2060
2061         Adds a condition variable implementation based on ParkingLot, called simply WTF::Condition.
2062         It can be used with WTF::Lock or actually any lock implementation. It should even work with
2063         WTF::SpinLock, WTF::Mutex, or std::mutex. Best of all, Condition only requires one byte.
2064
2065         ParkingLot almost contained all of the functionality needed to implemenet wait/notify. We
2066         could have implemented Condition using a 32-bit (or even 64-bit) version that protects
2067         against a notify that happens just before we park. But, this changes the ParkingLot API to
2068         give us the ability to run some code between when ParkingLot enqueues the current thread
2069         and when it actually sleeps. This callback is called with no locks held, so it can call
2070         unlock() on any kind of lock, so long as that lock's unlock() method doesn't recurse into
2071         ParkingLot::parkConditionally(). That seems unlikely; unlock() is more likely to call
2072         ParkingLot::unparkOne() or unparkAll(). WTF::Lock will never call parkConditionally()
2073         inside unlock(), so WTF::Lock is definitely appropriate for use with Condition.
2074
2075         Condition supports most of the API that std::condition_variable supports. It does some
2076         things to try to reduce footgun potential. The preferred timeout form is waitUntil() which
2077         takes an absolute time from the steady_clock. The only relative timeout form also takes a
2078         predicate callback, so it's impossible to write the subtly incorrect
2079         "while (...) wait_for(...)" idiom.
2080
2081         This patch doesn't actually introduce any uses of WTF::Condition other than the unit tests.
2082         I'll start switching code over to using WTF::Condition in another patch.
2083
2084         * WTF.vcxproj/WTF.vcxproj:
2085         * WTF.xcodeproj/project.pbxproj:
2086         * wtf/CMakeLists.txt:
2087         * wtf/Condition.h: Added.
2088         (WTF::Condition::Condition):
2089         (WTF::Condition::waitUntil):
2090         (WTF::Condition::waitFor):
2091         (WTF::Condition::wait):
2092         (WTF::Condition::notifyOne):
2093         (WTF::Condition::notifyAll):
2094         * wtf/Lock.cpp:
2095         (WTF::LockBase::unlockSlow): Make this useful assertion be a release assertion. It catches cases where you unlock the lock even though you don't hold it.
2096         * wtf/ParkingLot.cpp:
2097         (WTF::ParkingLot::parkConditionally): Add the beforeSleep() callback.
2098         (WTF::ParkingLot::unparkOne):
2099         * wtf/ParkingLot.h:
2100         (WTF::ParkingLot::compareAndPark):
2101
2102 2015-08-12  Anders Carlsson  <andersca@apple.com>
2103
2104         Use WTF::Optional in WindowFeatures
2105         https://bugs.webkit.org/show_bug.cgi?id=147956
2106
2107         Reviewed by Sam Weinig.
2108
2109         Add new operators to WTF::Optional to make it more like std::optional.
2110
2111         * wtf/Optional.h:
2112         (WTF::Optional::operator->):
2113         (WTF::Optional::operator*):
2114
2115 2015-08-12  Filip Pizlo  <fpizlo@apple.com>
2116
2117         WTF::Lock should not suffer from the thundering herd
2118         https://bugs.webkit.org/show_bug.cgi?id=147947
2119
2120         Reviewed by Geoffrey Garen.
2121
2122         This changes Lock::unlockSlow() to use unparkOne() instead of unparkAll(). The problem with
2123         doing this is that it's not obvious after calling unparkOne() if there are any other threads
2124         that are still parked on the lock's queue. If we assume that there are and leave the
2125         hasParkedBit set, then future calls to unlock() will take the slow path. We don't want that
2126         if there aren't actually any threads parked. On the other hand, if we assume that there
2127         aren't any threads parked and clear the hasParkedBit, then if there actually were some
2128         threads parked, then they may never be awoken since future calls to unlock() won't take slow
2129         path and so won't call unparkOne(). In other words, we need a way to be very precise about
2130         when we clear the hasParkedBit and we need to do it in a race-free way: it can't be the case
2131         that we clear the bit just as some thread gets parked on the queue.
2132
2133         A similar problem arises in futexes, and one of the solutions is to have a thread that
2134         acquires a lock after parking sets the hasParkedBit. This is what Rusty Russel's usersem
2135         does. It's a subtle algorithm. Also, it means that if a thread barges in before the unparked
2136         thread runs, then that barging thread will not know that there are threads parked. This
2137         could increase the severity of barging.
2138
2139         Since ParkingLot is a user-level API, we don't have to worry about the kernel-user security
2140         issues and so we can expose callbacks while ParkingLot is holding its internal locks. This
2141         change does exactly that for unparkOne(). The new variant of unparkOne() will call a user
2142         function while the queue from which we are unparking is locked. The callback is told basic
2143         stats about the queue: did we unpark a thread this time, and could there be more threads to
2144         unpark in the future. The callback runs while it's impossible for the queue state to change,
2145         since the ParkingLot's internal locks for the queue is held. This means that
2146         Lock::unlockSlow() can either clear, or leave, the hasParkedBit while releasing the lock
2147         inside the callback from unparkOne(). This takes care of the thundering herd problem while
2148         also reducing the greed that arises from barging threads.
2149
2150         This required some careful reworking of the ParkingLot algorithm. The first thing I noticed
2151         was that the ThreadData::shouldPark flag was useless, since it's set exactly when
2152         ThreadData::address is non-null. Then I had to make sure that dequeue() could lazily create
2153         both hashtables and buckets, since the "callback is called while queue is locked" invariant
2154         requires that we didn't exit early due to the hashtable or bucket not being present. Note
2155         that all of this is done in such a way that the old unparkOne() and unparkAll() don't have
2156         to create any buckets, though they now may create the hashtable. We don't care as much about
2157         the hashtable being created by unpark since it's just such an unlikely scenario and it would
2158         only happen once.
2159
2160         This change reduces the kernel CPU usage of WTF::Lock for the long critical section test by
2161         about 8x and makes it always perform as well as WTF::WordLock and WTF::Mutex for that
2162         benchmark.
2163
2164         * benchmarks/LockSpeedTest.cpp:
2165         * wtf/Lock.cpp:
2166         (WTF::LockBase::unlockSlow):
2167         * wtf/Lock.h:
2168         (WTF::LockBase::isLocked):
2169         (WTF::LockBase::isFullyReset):
2170         * wtf/ParkingLot.cpp:
2171         (WTF::ParkingLot::parkConditionally):
2172         (WTF::ParkingLot::unparkOne):
2173         (WTF::ParkingLot::unparkAll):
2174         * wtf/ParkingLot.h:
2175         * wtf/WordLock.h:
2176         (WTF::WordLock::isLocked):
2177         (WTF::WordLock::isFullyReset):
2178
2179 2015-08-11  Filip Pizlo  <fpizlo@apple.com>
2180
2181         Always use a byte-sized lock implementation
2182         https://bugs.webkit.org/show_bug.cgi?id=147908
2183
2184         Reviewed by Geoffrey Garen.
2185
2186         At the start of my locking algorithm crusade, I implemented Lock, which is a sizeof(void*)
2187         lock implementation with some nice theoretical properties and good performance. Then I added
2188         the ParkingLot abstraction and ByteLock. ParkingLot uses Lock in its implementation.
2189         ByteLock uses ParkingLot to create a sizeof(char) lock implementation that performs like
2190         Lock.
2191
2192         It turns out that ByteLock is always at least as good as Lock, and sometimes a lot better:
2193         it requires 8x less memory on 64-bit systems. It's hard to construct a benchmark where
2194         ByteLock is significantly slower than Lock, and when you do construct such a benchmark,
2195         tweaking it a bit can also create a scenario where ByteLock is significantly faster than
2196         Lock.
2197
2198         So, the thing that we call "Lock" should really use ByteLock's algorithm, since it is more
2199         compact and just as fast. That's what this patch does.
2200
2201         But we still need to keep the old Lock algorithm, because it's used to implement ParkingLot,
2202         which in turn is used to implement ByteLock. So this patch does this transformation:
2203
2204         - Move the algorithm in Lock into files called WordLock.h|cpp. Make ParkingLot use
2205           WordLock.
2206
2207         - Move the algorithm in ByteLock into Lock.h|cpp. Make everyone who used ByteLock use Lock
2208           instead. All other users of Lock now get the byte-sized lock implementation.
2209
2210         - Remove the old ByteLock files.
2211
2212         * WTF.vcxproj/WTF.vcxproj:
2213         * WTF.xcodeproj/project.pbxproj:
2214         * benchmarks/LockSpeedTest.cpp:
2215         (main):
2216         * wtf/WordLock.cpp: Added.
2217         (WTF::WordLock::lockSlow):
2218         (WTF::WordLock::unlockSlow):
2219         * wtf/WordLock.h: Added.
2220         (WTF::WordLock::WordLock):
2221         (WTF::WordLock::lock):
2222         (WTF::WordLock::unlock):
2223         (WTF::WordLock::isHeld):
2224         (WTF::WordLock::isLocked):
2225         * wtf/ByteLock.cpp: Removed.
2226         * wtf/ByteLock.h: Removed.
2227         * wtf/CMakeLists.txt:
2228         * wtf/Lock.cpp:
2229         (WTF::LockBase::lockSlow):
2230         (WTF::LockBase::unlockSlow):
2231         * wtf/Lock.h:
2232         (WTF::LockBase::lock):
2233         (WTF::LockBase::unlock):
2234         (WTF::LockBase::isHeld):
2235         (WTF::LockBase::isLocked):
2236         (WTF::Lock::Lock):
2237         * wtf/ParkingLot.cpp:
2238
2239 2015-08-11  Filip Pizlo  <fpizlo@apple.com>
2240
2241         Remove ByteSpinLock
2242         https://bugs.webkit.org/show_bug.cgi?id=147900
2243
2244         Rubber stamped by Mark Lam.
2245
2246         * WTF.xcodeproj/project.pbxproj:
2247         * wtf/ByteSpinLock.h: Removed.
2248
2249 2015-08-11  Brent Fulgham  <bfulgham@apple.com>
2250
2251         [Win] Switch Windows build to Visual Studio 2015
2252         https://bugs.webkit.org/show_bug.cgi?id=147887
2253         <rdar://problem/22235098>
2254
2255         Reviewed by Alex Christensen.
2256
2257         Update Visual Studio project file settings to use the current Visual
2258         Studio and compiler. Continue targeting binaries to run on our minimum
2259         supported configuration of Windows 7.
2260
2261         * WTF.vcxproj/WTF.vcxproj:
2262         * WTF.vcxproj/WTFGenerated.vcxproj:
2263
2264 2015-08-10  Filip Pizlo  <fpizlo@apple.com>
2265
2266         WTF should have a ParkingLot for parking sleeping threads, so that locks can fit in 1.6 bits
2267         https://bugs.webkit.org/show_bug.cgi?id=147665
2268
2269         Reviewed by Mark Lam.
2270
2271         This change adds a major new abstraction for concurrency algorithms in WebKit. It's called a
2272         ParkingLot, and it makes available a thread parking queue for each virtual address in memory.
2273         The queues are maintained by a data-access-parallel concurrent hashtable implementation. The
2274         memory usage is bounded at around half a KB per thread.
2275
2276         The ParkingLot makes it easy to turn any spinlock-based concurrency protocol into one that
2277         parks threads after a while. Because queue state management is up to the ParkingLot and not
2278         the user's data structure, this patch uses it to implement a full adaptive mutex in one byte.
2279         In fact, only three states of that byte are used (0 = available, 1 = locked, 2 = locked and
2280         there are parked threads). Hence the joke that ParkingLot allows locks that fit in 1.6 bits.
2281
2282         ByteLock is used as a replacement for ByteSpinLock in JavaScriptCore.
2283
2284         The API tests for this also demo how to create a completely fair (FIFO) binary semamphore. The
2285         comment in Lock.h shows how we could accelerate Lock performance using ParkingLot. After we
2286         are sure that this code works, we can expand the use of ParkingLot. That's covered by
2287         https://bugs.webkit.org/show_bug.cgi?id=147841.
2288
2289         * WTF.vcxproj/WTF.vcxproj:
2290         * WTF.xcodeproj/project.pbxproj:
2291         * benchmarks/LockSpeedTest.cpp:
2292         (main):
2293         * wtf/Atomics.h:
2294         (WTF::Atomic::compareExchangeWeak):
2295         (WTF::Atomic::compareExchangeStrong):
2296         * wtf/ByteLock.cpp: Added.
2297         (WTF::ByteLock::lockSlow):
2298         (WTF::ByteLock::unlockSlow):
2299         * wtf/ByteLock.h: Added.
2300         (WTF::ByteLock::ByteLock):
2301         (WTF::ByteLock::lock):
2302         (WTF::ByteLock::unlock):
2303         (WTF::ByteLock::isHeld):
2304         (WTF::ByteLock::isLocked):
2305         * wtf/CMakeLists.txt:
2306         * wtf/Lock.h:
2307         * wtf/ParkingLot.cpp: Added.
2308         (WTF::ParkingLot::parkConditionally):
2309         (WTF::ParkingLot::unparkOne):
2310         (WTF::ParkingLot::unparkAll):
2311         (WTF::ParkingLot::forEach):
2312         * wtf/ParkingLot.h: Added.
2313         (WTF::ParkingLot::compareAndPark):
2314
2315 2015-08-11  Brent Fulgham  <bfulgham@apple.com>
2316
2317         [Win] Unreviewed gardening.
2318
2319         * WTF.vcxproj/WTF.vcxproj.filters: Place file references so that files appear in correct
2320         folders in IDE.
2321
2322 2015-08-10  Youenn Fablet  <youenn.fablet@crf.canon.fr>
2323
2324         Compile warning (-Wsign-compare) on 32-bits at WebCore/platform/FileSystem.cpp
2325         https://bugs.webkit.org/show_bug.cgi?id=146414
2326
2327         Reviewed by Darin Adler.
2328
2329         Added convertSafely routine based on isInBounds routine.
2330         Updated BoundChecker by adding a third boolean parameter to this template giving whether Target has greater or equal precision than Source.
2331         Removed BoundCheckElider, which is no longer necessary and had some issues.
2332
2333         * wtf/CheckedArithmetic.h:
2334         (WTF::isInBounds):
2335         (WTF::convertSafely):
2336
2337 2015-08-07  Filip Pizlo  <fpizlo@apple.com>
2338
2339         Lightweight locks should be adaptive
2340         https://bugs.webkit.org/show_bug.cgi?id=147545
2341
2342         Reviewed by Geoffrey Garen.
2343
2344         A common idiom in WebKit is to use spinlocks. We use them because the lock acquisition
2345         overhead is lower than system locks and because they take dramatically less space than system
2346         locks. The speed and space advantages of spinlocks can be astonishing: an uncontended spinlock
2347         acquire is up to 10x faster and under microcontention - short critical section with two or
2348         more threads taking turns - spinlocks are up to 100x faster. Spinlocks take only 1 byte or 4
2349         bytes depending on the flavor, while system locks take 64 bytes or more. Clearly, WebKit
2350         should continue to avoid system locks - they are just far too slow and far too big.
2351
2352         But there is a problem with this idiom. System lock implementations will sleep a thread when
2353         it attempts to acquire a lock that is held, while spinlocks will cause the thread to burn CPU.
2354         In WebKit spinlocks, the thread will repeatedly call sched_yield(). This is awesome for
2355         microcontention, but awful when the lock will not be released for a while. In fact, when
2356         critical sections take tens of microseconds or more, the CPU time cost of our spinlocks is
2357         almost 100x more than the CPU time cost of a system lock. This case doesn't arise too
2358         frequently in our current uses of spinlocks, but that's probably because right now there are
2359         places where we make a conscious decision to use system locks - even though they use more
2360         memory and are slower - because we don't want to waste CPU cycles when a thread has to wait a
2361         while to acquire the lock.
2362
2363         The solution is to just implement a modern adaptive mutex in WTF. Luckily, this isn't a new
2364         concept. This patch implements a mutex that is reminiscent of the kinds of low-overhead locks
2365         that JVMs use. The actual implementation here is inspired by some of the ideas from [1]. The
2366         idea is simple: the fast path is an inlined CAS to immediately acquire a lock that isn't held,
2367         the slow path tries some number of spins to acquire the lock, and if that fails, the thread is
2368         put on a queue and put to sleep. The queue is made up of statically allocated thread nodes and
2369         the lock itself is a tagged pointer: either it is just bits telling us the complete lock state
2370         (not held or held) or it is a pointer to the head of a queue of threads waiting to acquire the
2371         lock. This approach gives WTF::Lock three different levels of adaptation: an inlined fast path
2372         if the lock is not contended, a short burst of spinning for microcontention, and a full-blown
2373         queue for critical sections that are held for a long time.
2374
2375         On a locking microbenchmark, this new Lock exhibits the following performance
2376         characteristics:
2377
2378         - Lock+unlock on an uncontended no-op critical section: 2x slower than SpinLock and 3x faster
2379           than a system mutex.
2380
2381         - Lock+unlock on a contended no-op critical section: 2x slower than SpinLock and 100x faster
2382           than a system mutex.
2383
2384         - CPU time spent in lock() on a lock held for a while: same as system mutex, 90x less than a
2385           SpinLock.
2386
2387         - Memory usage: sizeof(void*), so on 64-bit it's 8x less than a system mutex but 2x worse than
2388           a SpinLock.
2389
2390         This patch replaces all uses of SpinLock with Lock, since our critical sections are not
2391         no-ops so if you do basically anything in your critical section, the Lock overhead will be
2392         invisible. Also, in all places where we used SpinLock, we could tolerate 8 bytes of overhead
2393         instead of 4. Performance benchmarking using JSC macrobenchmarks shows no difference, which is
2394         as it should be: the purpose of this change is to reduce CPU time wasted, not wallclock time.
2395         This patch doesn't replace any uses of ByteSpinLock, since we expect that the space benefits
2396         of having a lock that just uses a byte are still better than the CPU wastage benefits of
2397         Lock. But, this work will enable some future work to create locks that will fit in just 1.6
2398         bits: https://bugs.webkit.org/show_bug.cgi?id=147665.
2399         
2400         Rolling this back in after fixing Lock::unlockSlow() for architectures that have a truly weak
2401         CAS. Since the Lock::unlock() fast path can go to slow path spuriously, it may go there even if
2402         there aren't any threads on the Lock's queue. So, unlockSlow() must be able to deal with the
2403         possibility of a null queue head.
2404
2405         [1] http://www.filpizlo.com/papers/pizlo-pppj2011-fable.pdf
2406
2407         * WTF.vcxproj/WTF.vcxproj:
2408         * WTF.xcodeproj/project.pbxproj:
2409         * benchmarks: Added.
2410         * benchmarks/LockSpeedTest.cpp: Added.
2411         (main):
2412         * wtf/Atomics.h:
2413         (WTF::Atomic::compareExchangeWeak):
2414         (WTF::Atomic::compareExchangeStrong):
2415         * wtf/CMakeLists.txt:
2416         * wtf/Lock.cpp: Added.
2417         (WTF::LockBase::lockSlow):
2418         (WTF::LockBase::unlockSlow):
2419         * wtf/Lock.h: Added.
2420         (WTF::LockBase::lock):
2421         (WTF::LockBase::unlock):
2422         (WTF::LockBase::isHeld):
2423         (WTF::LockBase::isLocked):
2424         (WTF::Lock::Lock):
2425         * wtf/MetaAllocator.cpp:
2426         (WTF::MetaAllocator::release):
2427         (WTF::MetaAllocatorHandle::shrink):
2428         (WTF::MetaAllocator::allocate):
2429         (WTF::MetaAllocator::currentStatistics):
2430         (WTF::MetaAllocator::addFreshFreeSpace):
2431         (WTF::MetaAllocator::debugFreeSpaceSize):
2432         * wtf/MetaAllocator.h:
2433         * wtf/SpinLock.h:
2434         * wtf/ThreadingPthreads.cpp:
2435         * wtf/ThreadingWin.cpp:
2436         * wtf/text/AtomicString.cpp:
2437         * wtf/text/AtomicStringImpl.cpp:
2438         (WTF::AtomicStringTableLocker::AtomicStringTableLocker):
2439
2440 2015-08-05  Filip Pizlo  <fpizlo@apple.com>
2441
2442         Unreviewed, roll out http://trac.webkit.org/changeset/187972.
2443
2444         * wtf/Atomics.cpp:
2445         (WTF::getSwapLock):
2446         (WTF::atomicStep):
2447         * wtf/MessageQueue.h:
2448         (WTF::MessageQueue::infiniteTime):
2449         (WTF::MessageQueue<DataType>::append):
2450         (WTF::MessageQueue<DataType>::appendAndKill):
2451         (WTF::MessageQueue<DataType>::appendAndCheckEmpty):
2452         (WTF::MessageQueue<DataType>::prepend):
2453         (WTF::MessageQueue<DataType>::removeIf):
2454         (WTF::MessageQueue<DataType>::isEmpty):
2455         (WTF::MessageQueue<DataType>::kill):
2456         (WTF::MessageQueue<DataType>::killed):
2457         * wtf/ParallelJobsGeneric.cpp:
2458         (WTF::ParallelEnvironment::ThreadPrivate::execute):
2459         (WTF::ParallelEnvironment::ThreadPrivate::waitForFinish):
2460         (WTF::ParallelEnvironment::ThreadPrivate::workerThread):
2461         * wtf/ParallelJobsGeneric.h:
2462         * wtf/RunLoop.cpp:
2463         (WTF::RunLoop::performWork):
2464         (WTF::RunLoop::dispatch):
2465         * wtf/RunLoop.h:
2466         * wtf/ThreadSpecificWin.cpp:
2467         (WTF::destructorsList):
2468         (WTF::destructorsMutex):
2469         (WTF::threadSpecificKeyCreate):
2470         (WTF::threadSpecificKeyDelete):
2471         (WTF::ThreadSpecificThreadExit):
2472         * wtf/Threading.cpp:
2473         (WTF::threadEntryPoint):
2474         (WTF::createThread):
2475         * wtf/ThreadingPrimitives.h:
2476         * wtf/ThreadingPthreads.cpp:
2477         (WTF::threadMapMutex):
2478         (WTF::initializeThreading):
2479         (WTF::identifierByPthreadHandle):
2480         (WTF::establishIdentifierForPthreadHandle):
2481         (WTF::changeThreadPriority):
2482         (WTF::waitForThreadCompletion):
2483         (WTF::detachThread):
2484         (WTF::threadDidExit):
2485         (WTF::currentThread):
2486         (WTF::Mutex::Mutex):
2487         (WTF::Mutex::~Mutex):
2488         (WTF::Mutex::lock):
2489         (WTF::Mutex::tryLock):
2490         (WTF::Mutex::unlock):
2491         (WTF::ThreadCondition::~ThreadCondition):
2492         (WTF::ThreadCondition::wait):
2493         (WTF::ThreadCondition::timedWait):
2494         (WTF::DeprecatedMutex::DeprecatedMutex): Deleted.
2495         (WTF::DeprecatedMutex::~DeprecatedMutex): Deleted.
2496         (WTF::DeprecatedMutex::lock): Deleted.
2497         (WTF::DeprecatedMutex::tryLock): Deleted.
2498         (WTF::DeprecatedMutex::unlock): Deleted.
2499         * wtf/ThreadingWin.cpp:
2500         (WTF::initializeCurrentThreadInternal):
2501         (WTF::threadMapMutex):
2502         (WTF::initializeThreading):
2503         (WTF::storeThreadHandleByIdentifier):
2504         (WTF::threadHandleForIdentifier):
2505         (WTF::clearThreadHandleForIdentifier):
2506         (WTF::currentThread):
2507         (WTF::Mutex::Mutex):
2508         (WTF::Mutex::~Mutex):
2509         (WTF::Mutex::lock):
2510         (WTF::Mutex::tryLock):
2511         (WTF::Mutex::unlock):
2512         (WTF::ThreadCondition::~ThreadCondition):
2513         (WTF::ThreadCondition::wait):
2514         (WTF::ThreadCondition::timedWait):
2515         (WTF::DeprecatedMutex::DeprecatedMutex): Deleted.
2516         (WTF::DeprecatedMutex::~DeprecatedMutex): Deleted.
2517         (WTF::DeprecatedMutex::lock): Deleted.
2518         (WTF::DeprecatedMutex::tryLock): Deleted.
2519         (WTF::DeprecatedMutex::unlock): Deleted.
2520         * wtf/WorkQueue.h:
2521         * wtf/dtoa.cpp:
2522         * wtf/dtoa.h:
2523         * wtf/efl/DispatchQueueEfl.cpp:
2524         (DispatchQueue::dispatch):
2525         (DispatchQueue::performWork):
2526         (DispatchQueue::performTimerWork):
2527         (DispatchQueue::insertTimerWorkItem):
2528         (DispatchQueue::wakeUpThread):
2529         (DispatchQueue::getNextTimeOut):
2530         * wtf/efl/DispatchQueueEfl.h:
2531         * wtf/efl/RunLoopEfl.cpp:
2532         (WTF::RunLoop::wakeUpEvent):
2533         (WTF::RunLoop::wakeUp):
2534         * wtf/threads/BinarySemaphore.cpp:
2535         (WTF::BinarySemaphore::signal):
2536         (WTF::BinarySemaphore::wait):
2537         * wtf/threads/BinarySemaphore.h:
2538         * wtf/win/WorkQueueWin.cpp:
2539         (WTF::WorkQueue::handleCallback):
2540         (WTF::WorkQueue::platformInvalidate):
2541         (WTF::WorkQueue::dispatch):
2542         (WTF::WorkQueue::timerCallback):
2543         (WTF::WorkQueue::dispatchAfter):
2544
2545 2015-08-05  Filip Pizlo  <fpizlo@apple.com>
2546
2547         Unreviewed, fix Windows.
2548
2549         * wtf/ThreadSpecificWin.cpp:
2550         (WTF::destructorsList):
2551         (WTF::destructorsMutex):
2552         (WTF::threadSpecificKeyCreate):
2553         (WTF::threadSpecificKeyDelete):
2554         (WTF::ThreadSpecificThreadExit):
2555
2556 2015-08-04  Filip Pizlo  <fpizlo@apple.com>
2557
2558         Rename Mutex to DeprecatedMutex
2559         https://bugs.webkit.org/show_bug.cgi?id=147675
2560
2561         Reviewed by Geoffrey Garen.
2562
2563         * wtf/Atomics.cpp:
2564         (WTF::getSwapLock):
2565         (WTF::atomicStep):
2566         * wtf/MessageQueue.h:
2567         (WTF::MessageQueue::infiniteTime):
2568         (WTF::MessageQueue<DataType>::append):
2569         (WTF::MessageQueue<DataType>::appendAndKill):
2570         (WTF::MessageQueue<DataType>::appendAndCheckEmpty):
2571         (WTF::MessageQueue<DataType>::prepend):
2572         (WTF::MessageQueue<DataType>::removeIf):
2573         (WTF::MessageQueue<DataType>::isEmpty):
2574         (WTF::MessageQueue<DataType>::kill):
2575         (WTF::MessageQueue<DataType>::killed):
2576         * wtf/ParallelJobsGeneric.cpp:
2577         (WTF::ParallelEnvironment::ThreadPrivate::execute):
2578         (WTF::ParallelEnvironment::ThreadPrivate::waitForFinish):
2579         (WTF::ParallelEnvironment::ThreadPrivate::workerThread):
2580         * wtf/ParallelJobsGeneric.h:
2581         * wtf/RunLoop.cpp:
2582         (WTF::RunLoop::performWork):
2583         (WTF::RunLoop::dispatch):
2584         * wtf/RunLoop.h:
2585         * wtf/Threading.cpp:
2586         (WTF::threadEntryPoint):
2587         (WTF::createThread):
2588         * wtf/ThreadingPrimitives.h:
2589         * wtf/ThreadingPthreads.cpp:
2590         (WTF::threadMapMutex):
2591         (WTF::initializeThreading):
2592         (WTF::identifierByPthreadHandle):
2593         (WTF::establishIdentifierForPthreadHandle):
2594         (WTF::changeThreadPriority):
2595         (WTF::waitForThreadCompletion):
2596         (WTF::detachThread):
2597         (WTF::threadDidExit):
2598         (WTF::currentThread):
2599         (WTF::DeprecatedMutex::DeprecatedMutex):
2600         (WTF::DeprecatedMutex::~DeprecatedMutex):
2601         (WTF::DeprecatedMutex::lock):
2602         (WTF::DeprecatedMutex::tryLock):
2603         (WTF::DeprecatedMutex::unlock):
2604         (WTF::ThreadCondition::~ThreadCondition):
2605         (WTF::ThreadCondition::wait):
2606         (WTF::ThreadCondition::timedWait):
2607         (WTF::Mutex::Mutex): Deleted.
2608         (WTF::Mutex::~Mutex): Deleted.
2609         (WTF::Mutex::lock): Deleted.
2610         (WTF::Mutex::tryLock): Deleted.
2611         (WTF::Mutex::unlock): Deleted.
2612         * wtf/ThreadingWin.cpp:
2613         (WTF::initializeCurrentThreadInternal):
2614         (WTF::threadMapMutex):
2615         (WTF::initializeThreading):
2616         (WTF::storeThreadHandleByIdentifier):
2617         (WTF::threadHandleForIdentifier):
2618         (WTF::clearThreadHandleForIdentifier):
2619         (WTF::currentThread):
2620         (WTF::DeprecatedMutex::DeprecatedMutex):
2621         (WTF::DeprecatedMutex::~DeprecatedMutex):
2622         (WTF::DeprecatedMutex::lock):
2623         (WTF::DeprecatedMutex::tryLock):
2624         (WTF::DeprecatedMutex::unlock):
2625         (WTF::ThreadCondition::~ThreadCondition):
2626         (WTF::ThreadCondition::wait):
2627         (WTF::ThreadCondition::timedWait):
2628         (WTF::Mutex::Mutex): Deleted.
2629         (WTF::Mutex::~Mutex): Deleted.
2630         (WTF::Mutex::lock): Deleted.
2631         (WTF::Mutex::tryLock): Deleted.
2632         (WTF::Mutex::unlock): Deleted.
2633         * wtf/WorkQueue.h:
2634         * wtf/dtoa.cpp:
2635         * wtf/dtoa.h:
2636         * wtf/efl/DispatchQueueEfl.cpp:
2637         (DispatchQueue::dispatch):
2638         (DispatchQueue::performWork):
2639         (DispatchQueue::performTimerWork):
2640         (DispatchQueue::insertTimerWorkItem):
2641         (DispatchQueue::wakeUpThread):
2642         (DispatchQueue::getNextTimeOut):
2643         * wtf/efl/DispatchQueueEfl.h:
2644         * wtf/efl/RunLoopEfl.cpp:
2645         (WTF::RunLoop::wakeUpEvent):
2646         (WTF::RunLoop::wakeUp):
2647         * wtf/threads/BinarySemaphore.cpp:
2648         (WTF::BinarySemaphore::signal):
2649         (WTF::BinarySemaphore::wait):
2650         * wtf/threads/BinarySemaphore.h:
2651         * wtf/win/WorkQueueWin.cpp:
2652         (WTF::WorkQueue::handleCallback):
2653         (WTF::WorkQueue::platformInvalidate):
2654         (WTF::WorkQueue::dispatch):
2655         (WTF::WorkQueue::timerCallback):
2656         (WTF::WorkQueue::dispatchAfter):
2657
2658 2015-08-04  Alex Christensen  <achristensen@webkit.org>
2659
2660         Fix quirks with CMake and VS2015
2661         https://bugs.webkit.org/show_bug.cgi?id=147663
2662
2663         Reviewed by Brent Fulgham.
2664
2665         * wtf/Platform.h:
2666         Build fix after r187908
2667
2668 2015-08-04  Brent Fulgham  <bfulgham@apple.com>
2669
2670         [Win] Update Apple Windows build for VS2015
2671         https://bugs.webkit.org/show_bug.cgi?id=147653
2672
2673         Reviewed by Dean Jackson.
2674
2675         * WTF.vcxproj/WTF.vcxproj.filters: Drive-by-fix to place files in
2676         proper project locations in the IDE.
2677         * wtf/Platform.h: Don't define the _HAS_EXCEPTIONS macro when building with
2678         Visual Studio 2015.
2679
2680 2015-08-04  Commit Queue  <commit-queue@webkit.org>
2681
2682         Unreviewed, rolling out r187815 and r187817.
2683         https://bugs.webkit.org/show_bug.cgi?id=147644
2684
2685         Caused lots of Windows crashes (Requested by smfr on #webkit).
2686
2687         Reverted changesets:
2688
2689         "[WTF] Turn tryMakeString(), makeString() into variadic
2690         templates"
2691         https://bugs.webkit.org/show_bug.cgi?id=147142
2692         http://trac.webkit.org/changeset/187815
2693
2694         "Unreviewed build fix."
2695         http://trac.webkit.org/changeset/187817
2696
2697 2015-08-04  Alex Christensen  <achristensen@webkit.org>
2698
2699         Enable WebGL on Windows CMake build.
2700         https://bugs.webkit.org/show_bug.cgi?id=143311
2701
2702         Reviewed by Csaba Osztrogonác.
2703
2704         * wtf/FeatureDefines.h:
2705         Made the CMake feature defines the same as the non-CMake feature defines.
2706
2707 2015-08-03  Csaba Osztrogonác  <ossy@webkit.org>
2708
2709         Introduce COMPILER(GCC_OR_CLANG) guard and make COMPILER(GCC) true only for GCC
2710         https://bugs.webkit.org/show_bug.cgi?id=146833
2711
2712         Reviewed by Alexey Proskuryakov.
2713
2714         * wtf/Assertions.cpp:
2715         * wtf/Assertions.h: Removed redundant COMPILER(CLANG) guard.
2716         * wtf/Atomics.cpp:
2717         * wtf/Atomics.h:
2718         (WTF::weakCompareAndSwap):
2719         (WTF::compilerFence):
2720         * wtf/Compiler.h:
2721          - Renamed COMPILER(GCC) to COMPILER(GCC_OR_CLANG), because it is true for both compiler.
2722          - Added COMPILER(GCC) which is true only for GCC.
2723          - Moved all GCC related stuff to one block and removed redundant guards accordingly.
2724          - Removed the unused default false definition of GCC_VERSION_AT_LEAST for non GCC compilers.
2725         * wtf/ExportMacros.h:
2726         * wtf/FastMalloc.h:
2727         * wtf/Platform.h:
2728         * wtf/StdLibExtras.h:
2729         * wtf/Vector.h:
2730         * wtf/text/ASCIIFastPath.h:
2731         (WTF::copyLCharsFromUCharSource):
2732
2733 2015-08-03  Zan Dobersek  <zdobersek@igalia.com>
2734
2735         Unreviewed build fix.
2736
2737         * wtf/text/StringConcatenate.h: Include <tuple> to avoid missing
2738         std::tuple<> class definitions.
2739
2740 2015-08-03  Zan Dobersek  <zdobersek@igalia.com>
2741
2742         [WTF] Turn tryMakeString(), makeString() into variadic templates
2743         https://bugs.webkit.org/show_bug.cgi?id=147142
2744
2745         Reviewed by Sam Weinig.
2746
2747         Built upon the original work by Anders Carlsson, Mark Rowe and Sam Weinig.
2748
2749         Implement tryMakeString() and makeString() as variadic templates, replacing
2750         the argument count-based overloads.
2751
2752         tryMakeString() now constructs a stack-based tuple of necessary StringTypeAdapter
2753         objects and utilizes the StringAdapterTuple struct template to operate on that
2754         tuple, recursively calling the necessary operations on each element in the tuple.
2755         This effectively mimics the process of previous tryMakeString() implementation,
2756         but makes it scalable to a tuple of elements that are to be concatenated.
2757
2758         StringAppend class template now stores two StringTypeAdapter objects for the
2759         two passed-in string objects, packed in a tuple, calling
2760         StringAdapterTuple<>::createString() directly when concatenating the two objects
2761         into one String.
2762
2763         * wtf/text/StringConcatenate.h:
2764         (WTF::StringTypeAdapter<char>::length):
2765         (WTF::StringTypeAdapter<char>::is8Bit):
2766         (WTF::StringAdapterTuple::sumWithOverflow):
2767         (WTF::StringAdapterTuple::is8Bit):
2768         (WTF::StringAdapterTuple::writeTo):
2769         (WTF::StringAdapterTuple::createString):
2770         (WTF::tryMakeString):
2771         (WTF::makeString):
2772         (WTF::sumWithOverflow): Deleted.
2773         * wtf/text/StringOperators.h:
2774         (WTF::StringAppend::StringAppend):
2775         (WTF::StringAppend::operator String):
2776         (WTF::StringAppend::is8Bit):
2777         (WTF::StringAppend::writeTo):
2778         (WTF::StringAppend::length):
2779         (WTF::StringAppend::string1):
2780         (WTF::StringAppend::string2):
2781
2782 2015-08-03  Anders Carlsson  <andersca@apple.com>
2783
2784         Make it possible to use String::utf8() in the debugger
2785         https://bugs.webkit.org/show_bug.cgi?id=147566
2786
2787         Reviewed by Tim Horton.
2788
2789         Add a new utf8() overload that doesn't take any parameters and just calls utf8(LenientConversion), since lldb doesn't support evaluating
2790         function calls with default parameters at the moment.
2791
2792         * wtf/text/WTFString.cpp:
2793         (WTF::String::utf8):
2794         * wtf/text/WTFString.h:
2795
2796 2015-08-02  Benjamin Poulain  <bpoulain@apple.com>
2797
2798         Investigate HashTable::HashTable(const HashTable&) and HashTable::operator=(const HashTable&) performance for hash-based static analyses
2799         https://bugs.webkit.org/show_bug.cgi?id=118455
2800
2801         Reviewed by Filip Pizlo.
2802
2803         Previously, when copying a HashTable, we would start from scratch
2804         with an empty table and insert elements one by one, growing-rehashing
2805         the table as needed.
2806
2807         With this patch, we have 2 improvements to remove most of the cost.
2808
2809         First, we compute a good size from the start. This removes all the
2810         reallocations and rehashs.
2811         This is where the biggest gain comes from.
2812
2813         The second part is a simpler version of add() when we know that
2814         we cannot find a bucket with the same key and there cannot
2815         be any deleted bucket.
2816         This removes most branches from the hot loop, cutting another 25%
2817         of the time.
2818
2819         * wtf/HashTable.h:
2820         (WTF::KeyTraits>::addUniqueForInitialization):
2821         (WTF::KeyTraits>::HashTable):
2822
2823 2015-08-01  Myles C. Maxfield  <mmaxfield@apple.com>
2824
2825         HashTraits<AtomicString> can use SimpleClassHashTraits
2826         https://bugs.webkit.org/show_bug.cgi?id=147528
2827
2828         Reviewed by Andreas Kling.
2829
2830         No point in duplicating the code inside SimpleClassHashTraits.
2831
2832         * wtf/text/AtomicStringHash.h:
2833         (WTF::HashTraits<WTF::AtomicString>::constructDeletedValue): Deleted.
2834         (WTF::HashTraits<WTF::AtomicString>::isDeletedValue): Deleted.
2835
2836 2015-08-01  Alex Christensen  <achristensen@webkit.org>
2837
2838         Fix compile errors with VS2015
2839         https://bugs.webkit.org/show_bug.cgi?id=147526
2840
2841         Reviewed by Myles Maxfield.
2842
2843         * wtf/StringExtras.h:
2844         (snprintf):
2845         (wtf_vsnprintf):
2846         VS2015 has an implementation of snprintf.
2847
2848 2015-07-31  Alex Christensen  <achristensen@webkit.org>
2849
2850         Prepare for VS2015
2851         https://bugs.webkit.org/show_bug.cgi?id=146579
2852
2853         Reviewed by Jon Honeycutt.
2854
2855         * wtf/StdLibExtras.h:
2856         (std::exchange):
2857         Added preprocessor macros around functions implemented in VS2015's standard library.
2858
2859 2015-07-30  Chris Dumez  <cdumez@apple.com>
2860
2861         Mark more classes as fast allocated
2862         https://bugs.webkit.org/show_bug.cgi?id=147440
2863
2864         Reviewed by Sam Weinig.
2865
2866         Mark more classes as fast allocated for performance. We heap-allocate
2867         objects of those types throughout the code base.
2868
2869         * wtf/Bag.h:
2870         * wtf/SegmentedVector.h:
2871         * wtf/SentinelLinkedList.h:
2872
2873 2015-07-29  Basile Clement  <basile_clement@apple.com>
2874
2875         Remove native call inlining
2876         https://bugs.webkit.org/show_bug.cgi?id=147417
2877
2878         Rubber-stamped by Filip Pizlo.
2879
2880         * wtf/Platform.h:
2881
2882 2015-07-28  Yusuke Suzuki  <utatane.tea@gmail.com>
2883
2884         [ES6] Add ENABLE_ES6_MODULES compile time flag with the default value "false"
2885         https://bugs.webkit.org/show_bug.cgi?id=147350
2886
2887         Reviewed by Sam Weinig.
2888
2889         * wtf/FeatureDefines.h:
2890
2891 2015-07-28  Filip Pizlo  <fpizlo@apple.com>
2892
2893         Unreviewed, fix Windows build.
2894
2895         * wtf/MetaAllocatorHandle.h:
2896         (WTF::MetaAllocatorHandle::key):
2897
2898 2015-07-27  Filip Pizlo  <fpizlo@apple.com>
2899
2900         Add logging when executable code gets deallocated
2901         https://bugs.webkit.org/show_bug.cgi?id=147355
2902
2903         Reviewed by Mark Lam.
2904
2905         * wtf/MetaAllocator.cpp:
2906         (WTF::MetaAllocatorHandle::dump): It's useful to be able to dump these.
2907         * wtf/MetaAllocatorHandle.h:
2908
2909 2015-07-28  Benjamin Poulain  <bpoulain@apple.com>
2910
2911         Speed up StringBuilder::appendQuotedJSONString()
2912         https://bugs.webkit.org/show_bug.cgi?id=147352
2913
2914         Reviewed by Andreas Kling.
2915
2916         * wtf/text/StringBuilder.cpp:
2917         (WTF::appendQuotedJSONStringInternal):
2918         The cases '"' and '\\' are not that uncommon, and they can easily
2919         be handled in the original branch testing for them.
2920
2921         This is about 2.5% better on the JSON.stringify test.
2922
2923 2015-07-27  Alex Christensen  <achristensen@webkit.org>
2924
2925         Progress towards building AppleWin with CMake
2926         https://bugs.webkit.org/show_bug.cgi?id=147325
2927
2928         Reviewed by Martin Robinson.
2929
2930         * wtf/PlatformWin.cmake:
2931         Link with CoreFoundation.lib.
2932
2933 2015-07-25  Carlos Alberto Lopez Perez  <clopez@igalia.com>
2934
2935         REGRESSION (bmalloc): WebKit performance tests don't report memory stats.
2936         https://bugs.webkit.org/show_bug.cgi?id=141247
2937
2938         Reviewed by Geoffrey Garen.
2939
2940         Meanwhile a better way of getting memory stats with bmalloc is not found
2941         (see bug 136592), we can report as memory stats the resident set size
2942         information that the operating system provides to us.
2943
2944         This at least should be good enough to get back the memory stats on the
2945         performance tests and being able to track down memory usage regressions
2946         at https://perf.webkit.org
2947
2948         * wtf/FastMalloc.cpp:
2949         (WTF::fastMallocStatistics): Report maxrss data as committedVMBytes.
2950
2951 2015-07-24  Csaba Osztrogonác  <ossy@webkit.org>
2952
2953         Remove the unused GCC workaround - std::is_trivially_destructible
2954         https://bugs.webkit.org/show_bug.cgi?id=147226
2955
2956         Reviewed by Darin Adler.
2957
2958         * wtf/StdLibExtras.h:
2959
2960 2015-07-23  Alex Christensen  <achristensen@webkit.org>
2961
2962         Remove compile and runtime flags for promises.
2963         https://bugs.webkit.org/show_bug.cgi?id=147244
2964
2965         Reviewed by Yusuke Suzuki.
2966
2967         * wtf/FeatureDefines.h:
2968
2969 2015-07-22  Sukolsak Sakshuwong  <sukolsak@gmail.com>
2970
2971         Add ENABLE_WEBASSEMBLY feature flag for WebAssembly
2972         https://bugs.webkit.org/show_bug.cgi?id=147212
2973
2974         Reviewed by Filip Pizlo.
2975
2976         * wtf/FeatureDefines.h:
2977
2978 2015-07-22  Filip Pizlo  <fpizlo@apple.com>
2979
2980         Introduce release assert for using threads before threading is initialized
2981         https://bugs.webkit.org/show_bug.cgi?id=147200
2982
2983         Reviewed by Michael Saboff.
2984         
2985         This will help bugs where you use createThread() before calling initializeThreading().
2986
2987         * wtf/ThreadIdentifierDataPthreads.cpp:
2988         (WTF::ThreadIdentifierData::initialize):
2989
2990 2015-07-21  Daniel Bates  <dabates@apple.com>
2991
2992         WTFCrash() in WebKit::WebProcess::networkConnection()
2993         https://bugs.webkit.org/show_bug.cgi?id=147112
2994         <rdar://problem/18477459>
2995
2996         Reviewed by Gavin Barraclough.
2997
2998         Add explicit boolean conversion function and remove overload of operator! to support
2999         checking whether an activity token is valid more directly than using the overloaded operator!.
3000
3001         * wtf/RefCounter.h:
3002         (WTF::RefCounter::Token::operator bool): Added.
3003         (WTF::RefCounter::Token::operator!): Deleted.
3004
3005 2015-07-20  Mark Lam  <mark.lam@apple.com>
3006
3007         Rollout r187020 and r187021: breaks JSC API tests on debug builds.
3008         https://bugs.webkit.org/show_bug.cgi?id=147110
3009
3010         * wtf/WTFThreadData.cpp:
3011         (WTF::WTFThreadData::WTFThreadData):
3012         * wtf/WTFThreadData.h:
3013         (WTF::WTFThreadData::stack):
3014
3015 2015-07-20  Alex Christensen  <achristensen@webkit.org>
3016
3017         Resurrect CMake build on Windows.
3018         https://bugs.webkit.org/show_bug.cgi?id=147083
3019
3020         Reviewed by Gyuyoung Kim.
3021
3022         * wtf/PlatformWin.cmake:
3023
3024 2015-07-20  Per Arne Vollan  <peavo@outlook.com>
3025
3026         JavaScriptCore performance is very bad on Windows
3027         https://bugs.webkit.org/show_bug.cgi?id=146448
3028
3029         Reviewed by Mark Lam.
3030
3031         Updating the stack bounds is time consuming.
3032         Only update the stack bounds when a new fiber is running.
3033
3034         * wtf/WTFThreadData.cpp:
3035         (WTF::WTFThreadData::WTFThreadData):
3036         * wtf/WTFThreadData.h:
3037         (WTF::WTFThreadData::stack):
3038
3039 2015-07-20  Julien Brianceau  <julien.brianceau@gmail.com>
3040
3041         Use isnan from std namespace in Stopwatch.h.
3042         https://bugs.webkit.org/show_bug.cgi?id=146911
3043
3044         Reviewed by Žan Doberšek.
3045
3046         * wtf/Stopwatch.h:
3047         (WTF::Stopwatch::isActive):
3048         (WTF::Stopwatch::start):
3049         (WTF::Stopwatch::stop):
3050         (WTF::Stopwatch::elapsedTime):
3051
3052 2015-07-16  Benjamin Poulain  <bpoulain@apple.com>
3053
3054         [Content extensions] Combine suffixes when generating NFAs
3055         https://bugs.webkit.org/show_bug.cgi?id=146961
3056
3057         Reviewed by Alex Christensen.
3058
3059         * wtf/Vector.h:
3060         (WTF::minCapacity>::Vector):
3061         (WTF::=):
3062         Copying a vector with a different inline capacity was broken due to
3063         the addition of MinimumCapacity.
3064
3065         This feature was needed by this patch so I fixed WTF.
3066
3067 2015-07-15  Anders Carlsson  <andersca@apple.com>
3068
3069         Make JavaScriptCore SPI headers used by WebCore SPI headers self-contained
3070         https://bugs.webkit.org/show_bug.cgi?id=146978
3071
3072         Reviewed by Dan Bernstein.
3073
3074         * wtf/ExportMacros.h:
3075
3076 2015-07-14  Anders Carlsson  <andersca@apple.com>
3077
3078         Assertions.h should include ExportMacros.h
3079         https://bugs.webkit.org/show_bug.cgi?id=146948
3080
3081         Reviewed by Tim Horton.
3082
3083         * wtf/Assertions.h:
3084
3085 2015-07-11  Joseph Pecoraro  <pecoraro@apple.com>
3086
3087         Unreviewed build fix, restrict APP_LINKS to just iOS.
3088
3089         * wtf/Platform.h:
3090
3091 2015-07-09  Tim Horton  <timothy_horton@apple.com>
3092
3093         Use CoreAnimation fences instead of synchronous IPC to synchronize resize
3094         https://bugs.webkit.org/show_bug.cgi?id=146294
3095         <rdar://problem/21090193>
3096
3097         Reviewed by Anders Carlsson.
3098
3099         * wtf/Platform.h:
3100         Add HAVE(COREANIMATION_FENCES)
3101
3102 2015-07-04  Chris Dumez  <cdumez@apple.com>
3103
3104         Drop RefPtr::clear() method
3105         https://bugs.webkit.org/show_bug.cgi?id=146556
3106
3107         Reviewed by Brady Eidson.
3108
3109         Drop RefPtr::clear() method in favor of "= nullptr;" pattern.
3110         Also made the "= nullptr;" pattern as efficient as clear()
3111         by providing a operator=(nullptr_t) overload. Local micro-
3112         benchmarking showed that "= nullptr;" used to be ~1.7% slower
3113         than clear().
3114
3115 2015-07-03  Dan Bernstein  <mitz@apple.com>
3116
3117         [Xcode] Update some build settings as recommended by Xcode 7
3118         https://bugs.webkit.org/show_bug.cgi?id=146597
3119
3120         Reviewed by Sam Weinig.
3121
3122         * Configurations/Base.xcconfig: Enabled CLANG_WARN_UNREACHABLE_CODE and
3123         GCC_NO_COMMON_BLOCKS. Removed GCC_MODEL_TUNING.
3124
3125         * WTF.xcodeproj/project.pbxproj: Updated LastUpgradeCheck.
3126
3127 2015-07-01  Alex Christensen  <achristensen@webkit.org>
3128
3129         Re-enable WebGL on WinCairo
3130         https://bugs.webkit.org/show_bug.cgi?id=146537
3131
3132         Reviewed by Csaba Osztrogonác.
3133
3134         * wtf/FeatureDefines.h:
3135         Enable WebGL on WinCairo again.
3136
3137 2015-07-01  Alex Christensen  <achristensen@webkit.org>
3138
3139         Ignore Visual Studio warning in SegmentedVector
3140         https://bugs.webkit.org/show_bug.cgi?id=146514
3141
3142         Reviewed by Andreas Kling.
3143
3144         * wtf/SegmentedVector.h:
3145         (WTF::SegmentedVector::deleteAllSegments):
3146         Use pragmas to ignore the 0 element array warning.
3147
3148 2015-07-01  Dean Jackson  <dino@apple.com>
3149
3150         Disable the experimental WebGL2 implementation
3151         https://bugs.webkit.org/show_bug.cgi?id=146526
3152         <rdar://problem/21641235>
3153
3154         Reviewed by Myles Maxfield.
3155
3156         Add (and disable) an ENABLE_WEBGL2 flag.
3157
3158         * wtf/FeatureDefines.h:
3159
3160 2015-06-30  Alex Christensen  <achristensen@webkit.org>
3161
3162         [Win] Unreviewed build fix after r186169.
3163
3164         * wtf/FeatureDefines.h:
3165         Temporarily disable WebGL on WinCairo. It was already temporarily disabled on AppleWin.
3166
3167 2015-06-30  Andy VanWagoner  <thetalecrafter@gmail.com>
3168
3169         Implement ECMAScript Internationalization API
3170         https://bugs.webkit.org/show_bug.cgi?id=90906
3171
3172         Reviewed by Benjamin Poulain.
3173
3174         * wtf/FeatureDefines.h: add ENABLE_INTL flag
3175
3176 2015-06-30  Keith Miller  <keith_miller@apple.com>
3177
3178         Errors in read() are not handled in WTF::cryptographicallyRandomValuesFromOS.
3179         https://bugs.webkit.org/show_bug.cgi?id=146473
3180
3181         Reviewed by Filip Pizlo.
3182
3183         We were not checking if errors occurred in WTF::cryptographicallyRandomValuesFromOS.
3184         We now buffer the data until enough bits of entropy exist to fill the buffer
3185         rather than crash. Additionally, added two crash functions so we can distinguish
3186         between the two reasons why we crashed in traces.
3187
3188         * wtf/OSRandomSource.cpp:
3189         (WTF::crashUnableToOpenFD):
3190         (WTF::crashUnableToReadFromFD):
3191         (WTF::cryptographicallyRandomValuesFromOS):
3192
3193 2015-06-29  Dean Jackson  <dino@apple.com>
3194
3195         Temporarily disable PICTURE_SIZES
3196         https://bugs.webkit.org/show_bug.cgi?id=146435
3197         <rdar://problem/21087013>
3198
3199         Reviewed by Tim Horton.
3200
3201         Temporarily disable PICTURE_SIZES because it causes problems with out
3202         of date <picture> polyfills.
3203
3204         * wtf/FeatureDefines.h:
3205
3206 2015-06-26  Antti Koivisto  <antti@apple.com>
3207
3208         Network process hangs fetching disk cache entries
3209         https://bugs.webkit.org/show_bug.cgi?id=146348
3210         <rdar://problem/21528072>
3211
3212         Reviewed by Anders Carlsson.
3213
3214         RunLoop::dispatch may deadlock if invoked with std::function that captures an object that calls RunLoop::dispatch in destructor.
3215
3216         * wtf/RunLoop.cpp:
3217         (WTF::RunLoop::performWork):
3218
3219             Don't reuse std::function variable in loop. We may end up destroying previously held std::function in assignment
3220             while holding the runloop mutex. With this change std::function is always destroyed with mutex unlocked.
3221
3222 2015-06-24  Commit Queue  <commit-queue@webkit.org>
3223
3224         Unreviewed, rolling out r185906.
3225         https://bugs.webkit.org/show_bug.cgi?id=146276
3226
3227         MSVC doesn't yet provide a const-qualified std::array<T,
3228         N>::size(), failing to compile the static_assert (Requested by
3229         zdobersek on #webkit).
3230
3231         Reverted changeset:
3232
3233         "Improve the source code generated by make_names.pl"
3234         https://bugs.webkit.org/show_bug.cgi?id=146208
3235         http://trac.webkit.org/changeset/185906
3236
3237 2015-06-24  Zan Dobersek  <zdobersek@igalia.com>
3238
3239         Improve the source code generated by make_names.pl
3240         https://bugs.webkit.org/show_bug.cgi?id=146208
3241
3242         Reviewed by Darin Adler.
3243
3244         * wtf/text/StringImpl.h:
3245         (WTF::StringImpl::assertHashIsCorrect): Make this method const-qualified.
3246
3247 2015-06-22  Darin Adler  <darin@apple.com>
3248
3249         Make Array.join work directly on substrings without reifying them
3250         https://bugs.webkit.org/show_bug.cgi?id=146191
3251
3252         Reviewed by Andreas Kling.
3253
3254         * wtf/Vector.h: Added an overload of uncheckedAppend like the one we added
3255         a while back, a non-template function that forwards through to the function
3256         template. This lets us call uncheckedAppend on an argument list and have it
3257         properly convert it to the Vector's element type.
3258
3259         * wtf/text/StringView.h:
3260         (WTF::StringView::getCharactersWithUpconvert): Changed to not use memcpy;
3261         saw some indication the hand-written loop was faster when profiling. Also
3262         use m_length directly when we know we are dealing with an 8-bit string,
3263         since the masking that the index function does is not needed in that case.
3264         (WTF::StringView::UpconvertedCharacters::UpconvertedCharacters): Ditto.
3265         (WTF::StringView::toString): Ditto.
3266         (WTF::StringView::toFloat): Ditto.
3267         (WTF::StringView::toInt): Ditto.
3268         (WTF::StringView::toStringWithoutCopying): Ditto.
3269         (WTF::StringView::find): Ditto.
3270
3271 2015-06-22  YunQiang Su  <wzssyqa@gmail.com>
3272
3273         [WTF] Platform.h: use _ABI64 instead of _MIPS_SIM_ABI64 to determine MIPS N64
3274         https://bugs.webkit.org/show_bug.cgi?id=145113
3275
3276         Reviewed by Csaba Osztrogonác.
3277
3278         * wtf/Platform.h:
3279
3280 2015-06-22  Anders Carlsson  <andersca@apple.com>
3281
3282         Fix build.
3283
3284         * wtf/threads/BinarySemaphore.cpp:
3285
3286 2015-06-22  Anders Carlsson  <andersca@apple.com>
3287
3288         Get rid of the Windows specific BinarySemaphore implementation
3289         https://bugs.webkit.org/show_bug.cgi?id=146216
3290
3291         Reviewed by Andreas Kling.
3292
3293         The fact that the Windows implementation uses a HEVENT internally was only useful
3294         to the Windows port of WebKit2; we can get rid of it now.
3295
3296         * WTF.vcxproj/WTF.vcxproj:
3297         * WTF.vcxproj/WTF.vcxproj.filters:
3298         * wtf/threads/BinarySemaphore.h:
3299         (WTF::BinarySemaphore::event): Deleted.
3300         * wtf/threads/win/BinarySemaphoreWin.cpp: Removed.
3301         (WTF::BinarySemaphore::BinarySemaphore): Deleted.
3302         (WTF::BinarySemaphore::~BinarySemaphore): Deleted.
3303         (WTF::BinarySemaphore::signal): Deleted.
3304         (WTF::BinarySemaphore::wait): Deleted.
3305
3306 2015-06-21  Gavin Barraclough  <barraclough@apple.com>
3307
3308         Page load performance regression due to bugs.webkit.org/show_bug.cgi?id=145542
3309         https://bugs.webkit.org/show_bug.cgi?id=146198
3310
3311         Unreviewed rollout.
3312
3313         * wtf/glib/GUniquePtr.h:
3314
3315 2015-06-20  Michael Catanzaro  <mcatanzaro@igalia.com>
3316
3317         [EFL][GTK] Define GLIB_VERSION_MIN_REQUIRED and require glib 2.36 for GTK
3318         https://bugs.webkit.org/show_bug.cgi?id=146181
3319
3320         Reviewed by Martin Robinson.
3321
3322         Define GLIB_VERSION_MIN_REQUIRED to avoid deprecation warnings.
3323
3324         * wtf/Platform.h:
3325
3326 2015-06-19  Michael Catanzaro  <mcatanzaro@igalia.com>
3327
3328         [SOUP] Define SOUP_VERSION_MIN_REQUIRED
3329         https://bugs.webkit.org/show_bug.cgi?id=146165
3330
3331         Reviewed by Martin Robinson.
3332
3333         Define SOUP_VERSION_MIN_REQUIRED to avoid deprecation warnings.
3334
3335         * wtf/Platform.h:
3336
3337 2015-06-19  Mark Lam  <mark.lam@apple.com>
3338
3339         Gardening: build fixes for GTK and EFL for CheckedArithmetic change.
3340
3341         Not reviewed.
3342
3343         * wtf/CheckedArithmetic.h:
3344         (WTF::Checked::operator<):
3345         (WTF::Checked::operator<=):
3346         (WTF::Checked::operator>):
3347         (WTF::Checked::operator>=):
3348
3349 2015-06-19  Mark Lam  <mark.lam@apple.com>
3350
3351         CheckedArithmetic's operator bool() and operator==() is broken.
3352         https://bugs.webkit.org/show_bug.cgi?id=146129
3353
3354         Reviewed by Geoffrey Garen and Oliver Hunt.
3355
3356         The existing operator UnspecifiedBoolType*() in CheckedArithmetic is erroneously
3357         allowing the Checked value to be implicitly casted into pointer types.  This is
3358         because it is doing a reinterpret_cast<UnspecifiedBoolType*>(1) whereas the idiom
3359         relies on the address of a member e.g. &Checked::m_value.  As a result,
3360         ImageBufferData::putData() was getting an implicit cast of a Checked value to
3361         (void*)1 and doing incorrect pointer comparisons on it.
3362
3363         Also, 2 of CheckedArithmetic's operator==() will crash if used on an overflowed
3364         value, while a 3rd one does not.  The 3rd one should be consistent and also crash
3365         if used on an overflowed Checked value.
3366
3367         In this fix, we replace operator UnspecifiedBoolType*() with an explicit operator
3368         bool().  We also add the missing operators <, <=, >, and >=.  That takes care of
3369         the comparisons in ImageBufferData::putData().
3370
3371         * wtf/CheckedArithmetic.h:
3372         (WTF::CrashOnOverflow::overflowed):
3373         (WTF::CrashOnOverflow::crash):
3374         (WTF::RecordOverflow::crash):
3375
3376         (WTF::Checked::operator!):
3377         (WTF::Checked::operator bool):
3378         (WTF::Checked::unsafeGet):
3379         - Don't call CRASH() directly.  Delegate to the handler.
3380
3381         (WTF::Checked::operator==):
3382         - Should call the handler's crash() to be consistent with the other 2 versions of
3383           operator== which will crash in unsafeGet() if used on an overflowed Checked
3384           value.
3385
3386         (WTF::Checked::operator<):
3387         (WTF::Checked::operator<=):
3388         (WTF::Checked::operator>):
3389         (WTF::Checked::operator>=):
3390         - Add missing operators.
3391
3392         (WTF::Checked::operator UnspecifiedBoolType*): Deleted.
3393
3394 2015-06-19  Csaba Osztrogonác  <ossy@webkit.org>
3395
3396         [WK2] Fix unused-private-field warning in WebProcess/Plugins/PluginView.<h|cpp>
3397         https://bugs.webkit.org/show_bug.cgi?id=145252
3398
3399         Reviewed by Tim Horton.
3400
3401         * wtf/FeatureDefines.h: Moved the definition of ENABLE_PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC
3402         here from Source/WebKit2/WebProcess/WebPage/WebPage.h
3403
3404 2015-06-17  Andreas Kling  <akling@apple.com>
3405
3406         SegmentedVector should waste less memory.
3407         <https://webkit.org/b/146069>
3408
3409         Reviewed by Anders Carlsson.
3410
3411         We were wasting sizeof(Vector) on every segment in SegmentVector.
3412         The segments were using inline capacity, and would never go beyond it,
3413         so all the size/capacity/out-of-line-buffer metadata was useless.
3414
3415         Change the internal representation to Vector<T[SegmentSize]> instead.
3416         This saves 16 bytes per segment, so lower SegmentSize -> bigger savings!
3417
3418         * wtf/SegmentedVector.h:
3419         (WTF::SegmentedVectorIterator::operator*):
3420         (WTF::SegmentedVectorIterator::operator->):
3421         (WTF::SegmentedVectorIterator::operator++):
3422         (WTF::SegmentedVectorIterator::operator==):
3423         (WTF::SegmentedVectorIterator::operator!=):
3424         (WTF::SegmentedVectorIterator::SegmentedVectorIterator):
3425         (WTF::SegmentedVector::at):
3426         (WTF::SegmentedVector::append):
3427         (WTF::SegmentedVector::removeLast):
3428         (WTF::SegmentedVector::grow):
3429         (WTF::SegmentedVector::begin):
3430         (WTF::SegmentedVector::end):
3431         (WTF::SegmentedVector::deleteAllSegments):
3432         (WTF::SegmentedVector::ensureSegmentsFor):
3433         (WTF::SegmentedVector::ensureSegment):
3434         (WTF::SegmentedVector::allocateSegment):
3435         (WTF::SegmentedVectorIterator::operator=): Deleted.
3436         (WTF::SegmentedVector::SegmentedVector): Deleted.
3437
3438 2015-06-16  Andreas Kling  <akling@apple.com>
3439
3440         Remove unused template parameter InlineCapacity from SegmentedVector.
3441         <https://webkit.org/b/146044>
3442
3443         Reviewed by Anders Carlsson.
3444
3445         * wtf/SegmentedVector.h:
3446         (WTF::SegmentedVectorIterator::operator=):
3447         (WTF::SegmentedVectorIterator::SegmentedVectorIterator):
3448         (WTF::SegmentedVector::at):
3449
3450 2015-06-16  Mark Lam  <mark.lam@apple.com>
3451
3452         Use NakedPtr<Exception>& to return exception results.
3453         https://bugs.webkit.org/show_bug.cgi?id=145870
3454
3455         Reviewed by Anders Carlsson and Filip Pizlo.
3456
3457         Introducing the NakedPtr class.
3458
3459         * WTF.xcodeproj/project.pbxproj:
3460         * wtf/NakedPtr.h: Added.
3461         (WTF::NakedPtr::NakedPtr):
3462         (WTF::NakedPtr::get):
3463         (WTF::NakedPtr::clear):
3464         (WTF::NakedPtr::operator*):
3465         (WTF::NakedPtr::operator->):
3466         (WTF::NakedPtr::operator T*):
3467         (WTF::NakedPtr::operator!):
3468         (WTF::NakedPtr::operator bool):
3469         (WTF::=):
3470         (WTF::NakedPtr<T>::swap):
3471         (WTF::swap):
3472
3473 2015-06-12  Zan Dobersek  <zdobersek@igalia.com>
3474
3475         [GLib] Move files under Source/WTF/wtf/gobject to Source/WTF/wtf/glib
3476         https://bugs.webkit.org/show_bug.cgi?id=145799
3477
3478         Reviewed by Carlos Garcia Campos.
3479
3480         Move the GLib-specific files to the Source/WTF/wtf/glib/ directory.
3481         'gobject' wasn't the most appropriate name for the directory since
3482         GObject is a submodule of GLib, but a lot of the code there didn't
3483         have much to do with GObject specifically.
3484
3485         Build rules for the moved files are also updated.
3486
3487         * WTF.vcxproj/WTF.vcxproj:
3488         * WTF.vcxproj/WTF.vcxproj.filters:
3489         * wtf/Platform.h:
3490         * wtf/PlatformEfl.cmake:
3491         * wtf/PlatformGTK.cmake:
3492         * wtf/RunLoop.h:
3493         * wtf/WorkQueue.h:
3494         * wtf/glib/GLibUtilities.cpp: Renamed from Source/WTF/wtf/gobject/GlibUtilities.cpp.
3495         (getCurrentExecutablePath):
3496         * wtf/glib/GLibUtilities.h: Renamed from Source/WTF/wtf/gobject/GlibUtilities.h.
3497         * wtf/glib/GMainLoopSource.cpp: Renamed from Source/WTF/wtf/gobject/GMainLoopSource.cpp.
3498         (WTF::GMainLoopSource::create):
3499         (WTF::GMainLoopSource::GMainLoopSource):
3500         (WTF::GMainLoopSource::~GMainLoopSource):
3501         (WTF::GMainLoopSource::isScheduled):
3502         (WTF::GMainLoopSource::isActive):
3503         (WTF::GMainLoopSource::cancel):
3504         (WTF::GMainLoopSource::scheduleIdleSource):
3505         (WTF::GMainLoopSource::schedule):
3506         (WTF::GMainLoopSource::scheduleTimeoutSource):
3507         (WTF::GMainLoopSource::scheduleAfterDelay):
3508         (WTF::createMicrosecondsTimeoutSource):
3509         (WTF::GMainLoopSource::scheduleAndDeleteOnDestroy):
3510         (WTF::GMainLoopSource::scheduleAfterDelayAndDeleteOnDestroy):
3511         (WTF::GMainLoopSource::prepareVoidCallback):
3512         (WTF::GMainLoopSource::finishVoidCallback):
3513         (WTF::GMainLoopSource::voidCallback):
3514         (WTF::GMainLoopSource::prepareBoolCallback):
3515         (WTF::GMainLoopSource::finishBoolCallback):
3516         (WTF::GMainLoopSource::boolCallback):
3517         (WTF::GMainLoopSource::socketCallback):
3518         (WTF::GMainLoopSource::voidSourceCallback):
3519         (WTF::GMainLoopSource::boolSourceCallback):
3520         (WTF::GMainLoopSource::socketSourceCallback):
3521         (WTF::GMainLoopSource::Context::destroySource):
3522         * wtf/glib/GMainLoopSource.h: Renamed from Source/WTF/wtf/gobject/GMainLoopSource.h.
3523         (WTF::GMainLoopSource::Context::operator=):
3524         * wtf/glib/GMutexLocker.h: Renamed from Source/WTF/wtf/gobject/GMutexLocker.h.
3525         (WTF::MutexWrapper<GMutex>::lock):
3526         (WTF::MutexWrapper<GMutex>::unlock):
3527         (WTF::MutexWrapper<GRecMutex>::lock):
3528         (WTF::MutexWrapper<GRecMutex>::unlock):
3529         (WTF::GMutexLocker::GMutexLocker):
3530         (WTF::GMutexLocker::~GMutexLocker):
3531         (WTF::GMutexLocker::lock):
3532         (WTF::GMutexLocker::unlock):
3533         * wtf/glib/GRefPtr.cpp: Renamed from Source/WTF/wtf/gobject/GRefPtr.cpp.
3534         (WTF::refGPtr):
3535         (WTF::derefGPtr):
3536         * wtf/glib/GRefPtr.h: Renamed from Source/WTF/wtf/gobject/GRefPtr.h.
3537         (WTF::GRefPtr::GRefPtr):
3538         (WTF::GRefPtr::~GRefPtr):
3539         (WTF::GRefPtr::clear):
3540         (WTF::GRefPtr::outPtr):
3541         (WTF::GRefPtr::isHashTableDeletedValue):
3542         (WTF::GRefPtr::get):
3543         (WTF::GRefPtr::operator*):
3544         (WTF::GRefPtr::operator->):
3545         (WTF::GRefPtr::operator!):
3546         (WTF::GRefPtr::operator UnspecifiedBoolType):
3547         (WTF::GRefPtr::hashTableDeletedValue):
3548         (WTF::=):
3549         (WTF::GRefPtr<T>::swap):
3550         (WTF::swap):
3551         (WTF::operator==):
3552         (WTF::operator!=):
3553         (WTF::static_pointer_cast):
3554         (WTF::const_pointer_cast):
3555         (WTF::adoptGRef):
3556         (WTF::refGPtr):
3557         (WTF::derefGPtr):
3558         * wtf/glib/GThreadSafeMainLoopSource.cpp: Renamed from Source/WTF/wtf/gobject/GThreadSafeMainLoopSource.cpp.
3559         (WTF::GThreadSafeMainLoopSource::GThreadSafeMainLoopSource):
3560         (WTF::GThreadSafeMainLoopSource::~GThreadSafeMainLoopSource):
3561         (WTF::GThreadSafeMainLoopSource::cancel):
3562         (WTF::GThreadSafeMainLoopSource::schedule):
3563         (WTF::GThreadSafeMainLoopSource::scheduleAfterDelay):
3564         (WTF::GThreadSafeMainLoopSource::prepareVoidCallback):
3565         (WTF::GThreadSafeMainLoopSource::finishVoidCallback):
3566         (WTF::GThreadSafeMainLoopSource::voidCallback):
3567         (WTF::GThreadSafeMainLoopSource::prepareBoolCallback):
3568         (WTF::GThreadSafeMainLoopSource::finishBoolCallback):
3569         (WTF::GThreadSafeMainLoopSource::boolCallback):
3570         * wtf/glib/GThreadSafeMainLoopSource.h: Renamed from Source/WTF/wtf/gobject/GThreadSafeMainLoopSource.h.
3571         * wtf/glib/GTypedefs.h: Renamed from Source/WTF/wtf/gobject/GTypedefs.h.
3572         * wtf/glib/GUniquePtr.h: Renamed from Source/WTF/wtf/gobject/GUniquePtr.h.
3573         (WTF::GPtrDeleter::operator()):
3574         (WTF::GUniqueOutPtr::GUniqueOutPtr):
3575         (WTF::GUniqueOutPtr::~GUniqueOutPtr):
3576         (WTF::GUniqueOutPtr::outPtr):
3577         (WTF::GUniqueOutPtr::release):