Fixed production builds for the iOS Simulator.
[WebKit-https.git] / Source / bmalloc / ChangeLog
1 2014-05-01  Dan Bernstein  <mitz@apple.com>
2
3         Fixed production builds for the iOS Simulator.
4
5         * Configurations/bmalloc.xcconfig: Include INSTALL_PATH_PREFIX in
6         PRIVATE_HEADERS_FOLDER_PATH when installing.
7
8 2014-04-20  Geoffrey Garen  <ggaren@apple.com>
9
10         bmalloc: Segregate pages by objects size
11         https://bugs.webkit.org/show_bug.cgi?id=131909
12
13         Reviewed by Andreas Kling.
14
15         2% reduction in memory-at-end on the Membuster memory_warning benchmarks.
16
17         * bmalloc/Allocator.cpp:
18         (bmalloc::Allocator::allocateSlowCase):
19         * bmalloc/Allocator.h:
20         (bmalloc::Allocator::allocateFastCase):
21         (bmalloc::Allocator::smallAllocatorFor): Use the new shared helper
22         function for size class calculation.
23
24         * bmalloc/Deallocator.cpp:
25         (bmalloc::Deallocator::Deallocator):
26         (bmalloc::Deallocator::scavenge):
27         (bmalloc::Deallocator::deallocateSmallLine):
28         (bmalloc::Deallocator::allocateSmallLine):
29         * bmalloc/Deallocator.h: Keep a cache for every size class, since the
30         cache can't be shared anymore.
31
32         * bmalloc/Heap.cpp:
33         (bmalloc::Heap::allocateSmallLineSlowCase):
34         * bmalloc/Heap.h:
35         (bmalloc::Heap::deallocateSmallLine): Ditto.
36
37         (bmalloc::Heap::allocateSmallLine): Check size class in addition to
38         page refcount when allocating a line because we might have deallocated
39         the page and the recycled it for another size class.
40
41         (bmalloc::Heap::deallocateMediumLine):
42         (bmalloc::Heap::allocateMediumLine):
43         * bmalloc/Line.h:
44         (bmalloc::Line::refCount):
45         * bmalloc/Page.h:
46         (bmalloc::Page::refCount):
47         (bmalloc::Page::smallSizeClass):
48         (bmalloc::Page::setSmallSizeClass):
49         (bmalloc::Page<Traits>::refCount): Deleted.
50         * bmalloc/Sizes.h:
51         (bmalloc::Sizes::smallSizeClassFor): New shared API for computing
52         an index into an array from a size.
53
54 2014-04-19  Geoffrey Garen  <ggaren@apple.com>
55
56         bmalloc: Improved alignment in LargeChunk
57         https://bugs.webkit.org/show_bug.cgi?id=131895
58
59         Reviewed by Andreas Kling.
60
61         * bmalloc/Chunk.h:
62         * bmalloc/LargeChunk.h: Align to vmPageSize just like Chunk does.
63         Technically, the previous alignment was harmless, but I would prefer,
64         dear reader, not to have to explain the interlocking set of
65         circumstances that made it so.
66
67 2014-04-19  Geoffrey Garen  <ggaren@apple.com>
68
69         Rolled out r167502 because it caused a crash on the facebook benchmark.
70
71         Unreviewed.
72
73             bmalloc: Added an XSmall line size
74             https://bugs.webkit.org/show_bug.cgi?id=131851
75
76             Reviewed by Sam Weinig.
77
78 2014-04-19  Geoffrey Garen  <ggaren@apple.com>
79
80         bmalloc: Mutex should be harder to use wrong
81         https://bugs.webkit.org/show_bug.cgi?id=131879
82
83         Reviewed by Andreas Kling.
84
85         Mutex now has a proper constructor, so you can't deadlock by forgetting
86         to initialize it.
87
88         * bmalloc.xcodeproj/project.pbxproj:
89         * bmalloc/Allocator.cpp:
90         (bmalloc::Allocator::processXSmallAllocatorLog):
91         (bmalloc::Allocator::processSmallAllocatorLog):
92         (bmalloc::Allocator::processMediumAllocatorLog):
93         (bmalloc::Allocator::allocateLarge):
94         (bmalloc::Allocator::allocateXLarge): Global replace Mutex => StaticMutex,
95         since the Heap mutex is a static.
96
97         * bmalloc/AsyncTask.h:
98         (bmalloc::Function>::AsyncTask): Use Mutex, since we're not static. No
99         need for explicit initialization anymore.
100
101         * bmalloc/Deallocator.cpp:
102         (bmalloc::Deallocator::scavenge):
103         (bmalloc::Deallocator::deallocateLarge):
104         (bmalloc::Deallocator::deallocateXLarge):
105         (bmalloc::Deallocator::processObjectLog):
106         (bmalloc::Deallocator::deallocateSmallLine):
107         (bmalloc::Deallocator::deallocateXSmallLine):
108         (bmalloc::Deallocator::allocateSmallLine):
109         (bmalloc::Deallocator::allocateXSmallLine):
110         (bmalloc::Deallocator::deallocateMediumLine):
111         (bmalloc::Deallocator::allocateMediumLine):
112         * bmalloc/Deallocator.h:
113         * bmalloc/Heap.cpp:
114         (bmalloc::sleep):
115         (bmalloc::Heap::Heap):
116         (bmalloc::Heap::concurrentScavenge):
117         (bmalloc::Heap::scavenge):
118         (bmalloc::Heap::scavengeSmallPages):
119         (bmalloc::Heap::scavengeXSmallPages):
120         (bmalloc::Heap::scavengeMediumPages):
121         (bmalloc::Heap::scavengeLargeRanges):
122         (bmalloc::Heap::allocateXSmallLineSlowCase):
123         (bmalloc::Heap::allocateSmallLineSlowCase):
124         (bmalloc::Heap::allocateMediumLineSlowCase):
125         (bmalloc::Heap::allocateXLarge):
126         (bmalloc::Heap::deallocateXLarge):
127         (bmalloc::Heap::allocateLarge):
128         (bmalloc::Heap::deallocateLarge):
129         * bmalloc/Heap.h:
130         (bmalloc::Heap::deallocateXSmallLine):
131         (bmalloc::Heap::allocateXSmallLine):
132         (bmalloc::Heap::deallocateSmallLine):
133         (bmalloc::Heap::allocateSmallLine):
134         (bmalloc::Heap::deallocateMediumLine):
135         (bmalloc::Heap::allocateMediumLine):
136         * bmalloc/Line.h:
137         (bmalloc::Line<Traits>::deref):
138         * bmalloc/Mutex.cpp: Removed.
139         * bmalloc/Mutex.h:
140         (bmalloc::Mutex::Mutex):
141         (bmalloc::Mutex::init): Deleted.
142         (bmalloc::Mutex::try_lock): Deleted.
143         (bmalloc::Mutex::lock): Deleted.
144         (bmalloc::Mutex::unlock): Deleted.
145         * bmalloc/Page.h:
146         (bmalloc::Page<Traits>::ref):
147         (bmalloc::Page<Traits>::deref):
148         (bmalloc::Page<Traits>::refCount):
149         * bmalloc/PerProcess.h:
150         (bmalloc::PerProcess::mutex):
151         (bmalloc::PerProcess<T>::getSlowCase):
152         * bmalloc/StaticMutex.cpp: Added.
153         (bmalloc::StaticMutex::lockSlowCase):
154         * bmalloc/StaticMutex.h: Added.
155         (bmalloc::StaticMutex::init):
156         (bmalloc::StaticMutex::try_lock):
157         (bmalloc::StaticMutex::lock):
158         (bmalloc::StaticMutex::unlock):
159         * bmalloc/VMHeap.h:
160         (bmalloc::VMHeap::deallocateXSmallPage):
161         (bmalloc::VMHeap::deallocateSmallPage):
162         (bmalloc::VMHeap::deallocateMediumPage):
163         (bmalloc::VMHeap::deallocateLargeRange):
164         * bmalloc/bmalloc.h:
165         (bmalloc::api::scavenge): Global replace Mutex => StaticMutex,
166         since the Heap mutex is a static.
167
168 2014-04-18  Geoffrey Garen  <ggaren@apple.com>
169
170         bmalloc: AsyncTask should use Mutex instead of std::mutex
171         https://bugs.webkit.org/show_bug.cgi?id=131865
172
173         Reviewed by Gavin Barraclough.
174
175         std::mutex is so slow that it makes parallelizing simple tasks through
176         AsyncTask a net regression. Mutex fixes this.
177
178         * bmalloc/AsyncTask.h:
179         (bmalloc::Function>::AsyncTask):
180         (bmalloc::Function>::join):
181         (bmalloc::Function>::runSlowCase):
182         (bmalloc::Function>::entryPoint):
183         * bmalloc/Mutex.h:
184         (bmalloc::Mutex::init):
185
186 2014-04-18  Geoffrey Garen  <ggaren@apple.com>
187
188         bmalloc: Added an XSmall line size
189         https://bugs.webkit.org/show_bug.cgi?id=131851
190
191         Reviewed by Sam Weinig.
192
193         Reduces malloc footprint on Membuster recordings by 10%.
194
195         This is a throughput regression, but we're still way ahead of TCMalloc.
196         I have some ideas for how to recover the regression -- but I wanted to
197         get this win in first.
198
199         Full set of benchmark results:
200
201                 bmalloc> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks --measure-heap nopatch:~/scratch/Build-nopatch/Release/ patch:~/webkit/WebKitBuild/Release/
202                                                                                                 
203                                                                nopatch                      patch                                Δ
204                 Peak Memory:
205                     reddit_memory_warning                      7,896kB                    7,532kB                  ^ 1.05x smaller
206                     flickr_memory_warning                     12,968kB                   12,324kB                  ^ 1.05x smaller
207                     theverge_memory_warning                   16,672kB                   15,200kB                   ^ 1.1x smaller
208
209                     <geometric mean>                          11,952kB                   11,216kB                  ^ 1.07x smaller
210                     <arithmetic mean>                         12,512kB                   11,685kB                  ^ 1.07x smaller
211                     <harmonic mean>                           11,375kB                   10,726kB                  ^ 1.06x smaller
212
213                 Memory at End:
214                     reddit_memory_warning                      7,320kB                    6,856kB                  ^ 1.07x smaller
215                     flickr_memory_warning                     10,848kB                    9,692kB                  ^ 1.12x smaller
216                     theverge_memory_warning                   16,380kB                   14,872kB                   ^ 1.1x smaller
217
218                     <geometric mean>                          10,916kB                    9,961kB                   ^ 1.1x smaller
219                     <arithmetic mean>                         11,516kB                   10,473kB                   ^ 1.1x smaller
220                     <harmonic mean>                           10,350kB                    9,485kB                  ^ 1.09x smaller
221
222                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks nopatch:~/scratch/Build-nopatch/Release/ patch:~/webkit/WebKitBuild/Release/
223                                                                                                 
224                                                    nopatch                patch                         Δ
225                 Execution Time:
226                     churn                            127ms                151ms            ! 1.19x slower
227                     list_allocate                    130ms                164ms            ! 1.26x slower
228                     tree_allocate                    109ms                127ms            ! 1.17x slower
229                     tree_churn                       115ms                120ms            ! 1.04x slower
230                     facebook                         240ms                259ms            ! 1.08x slower
231                     fragment                          91ms                131ms            ! 1.44x slower
232                     fragment_iterate                 105ms                106ms            ! 1.01x slower
233                     message_one                      260ms                259ms             ^ 1.0x faster
234                     message_many                     149ms                154ms            ! 1.03x slower
235                     medium                           194ms                248ms            ! 1.28x slower
236                     big                              157ms                160ms            ! 1.02x slower
237
238                     <geometric mean>                 144ms                163ms            ! 1.13x slower
239                     <arithmetic mean>                152ms                171ms            ! 1.12x slower
240                     <harmonic mean>                  137ms                156ms            ! 1.14x slower
241
242                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks nopatch:~/scratch/Build-nopatch/Release/ patch:~/webkit/WebKitBuild/Release/
243                                                                                                 
244                                                                        nopatch                          patch                                     Δ
245                 Execution Time:
246                     churn                                                126ms                          148ms                        ! 1.17x slower
247                     churn --parallel                                      62ms                           76ms                        ! 1.23x slower
248                     list_allocate                                        130ms                          164ms                        ! 1.26x slower
249                     list_allocate --parallel                             120ms                          175ms                        ! 1.46x slower
250                     tree_allocate                                        111ms                          127ms                        ! 1.14x slower
251                     tree_allocate --parallel                              95ms                          135ms                        ! 1.42x slower
252                     tree_churn                                           115ms                          124ms                        ! 1.08x slower
253                     tree_churn --parallel                                107ms                          126ms                        ! 1.18x slower
254                     facebook                                             240ms                          276ms                        ! 1.15x slower
255                     facebook --parallel                                  802ms                        1,088ms                        ! 1.36x slower
256                     fragment                                              92ms                          130ms                        ! 1.41x slower
257                     fragment --parallel                                   66ms                          124ms                        ! 1.88x slower
258                     fragment_iterate                                     109ms                          127ms                        ! 1.17x slower
259                     fragment_iterate --parallel                           55ms                           64ms                        ! 1.16x slower
260                     message_one                                          260ms                          260ms                                      
261                     message_many                                         170ms                          238ms                         ! 1.4x slower
262                     medium                                               185ms                          250ms                        ! 1.35x slower
263                     medium --parallel                                    210ms                          334ms                        ! 1.59x slower
264                     big                                                  150ms                          169ms                        ! 1.13x slower
265                     big --parallel                                       138ms                          144ms                        ! 1.04x slower
266
267                     <geometric mean>                                     135ms                          170ms                        ! 1.26x slower
268                     <arithmetic mean>                                    167ms                          214ms                        ! 1.28x slower
269                     <harmonic mean>                                      117ms                          148ms                        ! 1.26x slower
270
271                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks TC:~/scratch/Build-TCMalloc/Release/ patch:~/webkit/WebKitBuild/Release/
272
273                                                                     TC                      patch                                Δ
274                 Peak Memory:
275                     reddit_memory_warning                     13,836kB                   13,436kB                  ^ 1.03x smaller
276                     flickr_memory_warning                     24,868kB                   25,188kB                   ! 1.01x bigger
277                     theverge_memory_warning                   24,504kB                   26,636kB                   ! 1.09x bigger
278
279                     <geometric mean>                          20,353kB                   20,812kB                   ! 1.02x bigger
280                     <arithmetic mean>                         21,069kB                   21,753kB                   ! 1.03x bigger
281                     <harmonic mean>                           19,570kB                   19,780kB                   ! 1.01x bigger
282
283                 Memory at End:
284                     reddit_memory_warning                      8,656kB                   10,016kB                   ! 1.16x bigger
285                     flickr_memory_warning                     11,844kB                   13,784kB                   ! 1.16x bigger
286                     theverge_memory_warning                   18,516kB                   22,748kB                   ! 1.23x bigger
287
288                     <geometric mean>                          12,382kB                   14,644kB                   ! 1.18x bigger
289                     <arithmetic mean>                         13,005kB                   15,516kB                   ! 1.19x bigger
290                     <harmonic mean>                           11,813kB                   13,867kB                   ! 1.17x bigger
291
292                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks TC:~/scratch/Build-TCMalloc/Release/ patch:~/webkit/WebKitBuild/Release/
293                                                                                                 
294                                                         TC                patch                         Δ
295                 Execution Time:
296                     churn                            416ms                148ms            ^ 2.81x faster
297                     list_allocate                    463ms                164ms            ^ 2.82x faster
298                     tree_allocate                    292ms                127ms             ^ 2.3x faster
299                     tree_churn                       157ms                120ms            ^ 1.31x faster
300                     facebook                         327ms                276ms            ^ 1.18x faster
301                     fragment                         335ms                129ms             ^ 2.6x faster
302                     fragment_iterate                 344ms                108ms            ^ 3.19x faster
303                     message_one                      386ms                258ms             ^ 1.5x faster
304                     message_many                     410ms                154ms            ^ 2.66x faster
305                     medium                           391ms                245ms             ^ 1.6x faster
306                     big                              261ms                167ms            ^ 1.56x faster
307
308                     <geometric mean>                 332ms                164ms            ^ 2.02x faster
309                     <arithmetic mean>                344ms                172ms            ^ 1.99x faster
310                     <harmonic mean>                  317ms                157ms            ^ 2.02x faster
311
312         * bmalloc.xcodeproj/project.pbxproj:
313         * bmalloc/Allocator.cpp:
314         (bmalloc::Allocator::Allocator): Don't assume that each allocator's
315         index corresponds with its size. Instead, use the size selection function
316         explicitly. Now that we have XSmall, some small allocator entries are
317         unused.
318
319         (bmalloc::Allocator::scavenge):
320         (bmalloc::Allocator::log):
321         (bmalloc::Allocator::processXSmallAllocatorLog):
322         (bmalloc::Allocator::allocateSlowCase):
323         * bmalloc/Allocator.h:
324         (bmalloc::Allocator::xSmallAllocatorFor):
325         (bmalloc::Allocator::allocateFastCase):
326         * bmalloc/Chunk.h:
327         * bmalloc/Deallocator.cpp:
328         (bmalloc::Deallocator::scavenge):
329         (bmalloc::Deallocator::processObjectLog):
330         (bmalloc::Deallocator::deallocateSlowCase):
331         (bmalloc::Deallocator::deallocateXSmallLine):
332         (bmalloc::Deallocator::allocateXSmallLine):
333         * bmalloc/Deallocator.h:
334         (bmalloc::Deallocator::deallocateFastCase):
335         * bmalloc/Heap.cpp:
336         (bmalloc::Heap::scavenge):
337         (bmalloc::Heap::scavengeXSmallPages):
338         (bmalloc::Heap::allocateXSmallLineSlowCase):
339         * bmalloc/Heap.h:
340         (bmalloc::Heap::deallocateXSmallLine):
341         (bmalloc::Heap::allocateXSmallLine):
342         * bmalloc/LargeChunk.h:
343         (bmalloc::LargeChunk::get):
344         (bmalloc::LargeChunk::endTag):
345         * bmalloc/Line.h:
346         * bmalloc/MediumAllocator.h:
347         (bmalloc::MediumAllocator::allocate):
348         (bmalloc::MediumAllocator::refill):
349         * bmalloc/ObjectType.cpp:
350         (bmalloc::objectType):
351         * bmalloc/ObjectType.h:
352         (bmalloc::isXSmall):
353         (bmalloc::isSmall):
354         (bmalloc::isMedium):
355         (bmalloc::isLarge):
356         (bmalloc::isSmallOrMedium): Deleted.
357         * bmalloc/SegregatedFreeList.h: I boiler-plate copied existing code for
358         handling small objects. There's probably a reasonable way to share this
359         code in the future -- I'll look into that once it's stopped changing.
360
361         * bmalloc/Sizes.h: Tweaked size classes to make Membuster happy. This
362         is the main reason things got slower.
363
364         * bmalloc/SmallAllocator.h:
365         (bmalloc::SmallAllocator::allocate):
366         * bmalloc/SmallTraits.h:
367         * bmalloc/VMHeap.cpp:
368         (bmalloc::VMHeap::allocateXSmallChunk):
369         * bmalloc/VMHeap.h:
370         (bmalloc::VMHeap::allocateXSmallPage):
371         (bmalloc::VMHeap::deallocateXSmallPage):
372         * bmalloc/XSmallAllocator.h: Added.
373         (bmalloc::XSmallAllocator::isNull):
374         (bmalloc::XSmallAllocator::canAllocate):
375         (bmalloc::XSmallAllocator::XSmallAllocator):
376         (bmalloc::XSmallAllocator::line):
377         (bmalloc::XSmallAllocator::allocate):
378         (bmalloc::XSmallAllocator::objectCount):
379         (bmalloc::XSmallAllocator::derefCount):
380         (bmalloc::XSmallAllocator::refill):
381         * bmalloc/XSmallChunk.h: Added.
382         * bmalloc/XSmallLine.h: Added.
383         * bmalloc/XSmallPage.h: Added.
384         * bmalloc/XSmallTraits.h: Added.
385         * bmalloc/bmalloc.h:
386         (bmalloc::api::realloc): Boiler-plate copy, as above.
387
388 2014-04-14  Geoffrey Garen  <ggaren@apple.com>
389
390         MallocBench should scavenge explicitly instead of waiting
391         https://bugs.webkit.org/show_bug.cgi?id=131661
392
393         Reviewed by Andreas Kling.
394
395         Added explicit scavenge support to bmalloc. This isn't a memory win,
396         since bmalloc's per-thread cache is so small. But it makes testing
397         simpler.
398
399         * bmalloc/Allocator.cpp:
400         (bmalloc::Allocator::~Allocator):
401         (bmalloc::Allocator::scavenge):
402         * bmalloc/Allocator.h:
403         * bmalloc/Cache.cpp:
404         (bmalloc::Cache::operator new):
405         (bmalloc::Cache::operator delete):
406         (bmalloc::Cache::Cache):
407         (bmalloc::Cache::scavenge):
408         * bmalloc/Cache.h:
409         * bmalloc/Deallocator.cpp:
410         (bmalloc::Deallocator::~Deallocator):
411         (bmalloc::Deallocator::scavenge):
412         * bmalloc/Deallocator.h: Factored existing scavenging code into helper
413         functions, for reuse.
414
415         * bmalloc/Heap.cpp:
416         (bmalloc::sleep):
417         (bmalloc::Heap::concurrentScavenge):
418         (bmalloc::Heap::scavenge):
419         (bmalloc::Heap::scavengeSmallPages):
420         (bmalloc::Heap::scavengeMediumPages):
421         (bmalloc::Heap::scavengeLargeRanges):
422         * bmalloc/Heap.h: Made scavenge sleep duration a parameter. Forced
423         scavenging -- in response to a benchmark or a low memory warning --
424         wants to complete as soon as possible, so its sleep duration is 0.
425
426         * bmalloc/bmalloc.h:
427         (bmalloc::api::scavenge):
428         * bmalloc/mbmalloc.cpp: Exported the scavenge API for MallocBench's use.
429
430 2014-04-14  Geoffrey Garen  <ggaren@apple.com>
431
432         Use 4kB pages on Mac
433         https://bugs.webkit.org/show_bug.cgi?id=131658
434
435         Reviewed by Sam Weinig.
436
437         This reduces memory use a lot on Membuster:
438
439                                                                   base                      patch                                Δ
440                 Execution Time:
441                     reddit_memory_warning                         18ms                       17ms                   ^ 1.06x faster
442                     flickr_memory_warning                         34ms                       36ms                   ! 1.06x slower
443                     theverge_memory_warning                       39ms                       41ms                   ! 1.05x slower
444
445                     <geometric mean>                              29ms                       29ms                   ! 1.02x slower
446                     <arithmetic mean>                             30ms                       31ms                   ! 1.03x slower
447                     <harmonic mean>                               27ms                       27ms                    ^ 1.0x faster
448
449                 Peak Memory:
450                     reddit_memory_warning                     16,412kB                   16,436kB                    ! 1.0x bigger
451                     flickr_memory_warning                     30,120kB                   30,184kB                    ! 1.0x bigger
452                     theverge_memory_warning                   33,408kB                   33,420kB                    ! 1.0x bigger
453
454                     <geometric mean>                          25,466kB                   25,499kB                    ! 1.0x bigger
455                     <arithmetic mean>                         26,647kB                   26,680kB                    ! 1.0x bigger
456                     <harmonic mean>                           24,181kB                   24,214kB                    ! 1.0x bigger
457
458                 Memory at End:
459                     reddit_memory_warning                      2,404kB                    1,920kB                  ^ 1.25x smaller
460                     flickr_memory_warning                      3,764kB                    3,072kB                  ^ 1.23x smaller
461                     theverge_memory_warning                    3,648kB                    3,132kB                  ^ 1.16x smaller
462
463                     <geometric mean>                           3,208kB                    2,644kB                  ^ 1.21x smaller
464                     <arithmetic mean>                          3,272kB                    2,708kB                  ^ 1.21x smaller
465                     <harmonic mean>                            3,139kB                    2,574kB                  ^ 1.22x smaller
466
467
468         * bmalloc.xcodeproj/project.pbxproj:
469         * bmalloc/BPlatform.h: Added.
470         * bmalloc/VMAllocate.h: Only use 16kB pages on iOS because the page size
471         is 4kB on Mac.
472
473 2014-04-14  Alexey Proskuryakov  <ap@apple.com>
474
475         Fixed svn:ignore on bmalloc.xcodeproj, it had erroneous leading spaces.
476
477         * bmalloc.xcodeproj: Modified property svn:ignore.
478
479 2014-04-13  Geoffrey Garen  <ggaren@apple.com>
480
481         Fixed some mbmalloc exports
482         https://bugs.webkit.org/show_bug.cgi?id=131599
483
484         Reviewed by Ryosuke Niwa.
485
486         * bmalloc.xcodeproj/project.pbxproj: Made some headers a private part
487         of the project, so we can call them from API.
488
489         * bmalloc/mbmalloc.cpp: Marked the mbmalloc functions with default
490         visibility, so they show up as exported in the .dylib.
491
492 2014-04-09  Geoffrey Garen  <ggaren@apple.com>
493
494         Put bmalloc headers in the right place
495         https://bugs.webkit.org/show_bug.cgi?id=131464
496
497         Reviewed by Mark Rowe.
498
499         * Configurations/bmalloc.xcconfig: Set PRIVATE_HEADERS_FOLDER_PATH to
500         specify that we don't just want to dump all of our generically-named
501         headers into /usr/local/include.
502
503 2014-04-08  Geoffrey Garen  <ggaren@apple.com>
504
505         Made bmalloc more #include friendly
506         https://bugs.webkit.org/show_bug.cgi?id=131386
507
508         Reviewed by Andreas Kling.
509
510         Marked a bunch of headers private so they can be used from client code
511         that #includes bmalloc.h.
512
513         Renamed ASSERT macros to BASSERT. This matches their header, which already
514         had to be renamed, and fixes conflicts with WTF's ASSERT macros.
515
516         * bmalloc.xcodeproj/project.pbxproj:
517         * bmalloc/Allocator.cpp:
518         (bmalloc::Allocator::allocateSlowCase):
519         * bmalloc/AsyncTask.h:
520         (bmalloc::Function>::runSlowCase):
521         * bmalloc/BAssert.h:
522         * bmalloc/BoundaryTag.h:
523         (bmalloc::BoundaryTag::setSize):
524         * bmalloc/BoundaryTagInlines.h:
525         (bmalloc::validate):
526         (bmalloc::BoundaryTag::init):
527         (bmalloc::BoundaryTag::deallocate):
528         (bmalloc::BoundaryTag::splitLarge):
529         (bmalloc::BoundaryTag::allocate):
530         * bmalloc/Chunk.h:
531         * bmalloc/Deallocator.cpp:
532         (bmalloc::Deallocator::processObjectLog):
533         (bmalloc::Deallocator::deallocateSlowCase):
534         * bmalloc/Deallocator.h:
535         (bmalloc::Deallocator::deallocateFastCase):
536         * bmalloc/FixedVector.h:
537         (bmalloc::Capacity>::operator):
538         (bmalloc::Capacity>::push):
539         (bmalloc::Capacity>::pop):
540         (bmalloc::Capacity>::shrink):
541         * bmalloc/Heap.cpp:
542         (bmalloc::Heap::allocateLarge):
543         * bmalloc/LargeChunk.h:
544         (bmalloc::LargeChunk::get):
545         (bmalloc::LargeChunk::endTag):
546         * bmalloc/Line.h:
547         (bmalloc::Line<Traits>::concurrentRef):
548         (bmalloc::Line<Traits>::deref):
549         * bmalloc/MediumAllocator.h:
550         (bmalloc::MediumAllocator::allocate):
551         * bmalloc/ObjectType.h:
552         (bmalloc::isSmall):
553         * bmalloc/Page.h:
554         (bmalloc::Page<Traits>::ref):
555         (bmalloc::Page<Traits>::deref):
556         * bmalloc/PerThread.h:
557         (bmalloc::PerThread<T>::getSlowCase):
558         * bmalloc/SegregatedFreeList.cpp:
559         (bmalloc::SegregatedFreeList::SegregatedFreeList):
560         (bmalloc::SegregatedFreeList::insert):
561         * bmalloc/SmallAllocator.h:
562         (bmalloc::SmallAllocator::allocate):
563         (bmalloc::SmallAllocator::refill):
564         * bmalloc/Syscall.h:
565         * bmalloc/VMAllocate.h:
566         (bmalloc::vmValidate):
567         (bmalloc::vmAllocate):
568         (bmalloc::vmDeallocatePhysicalPagesSloppy):
569         * bmalloc/Vector.h:
570         (bmalloc::Vector<T>::operator):
571         (bmalloc::Vector<T>::pop):
572         (bmalloc::Vector<T>::shrink):
573         * bmalloc/XLargeChunk.h:
574         (bmalloc::XLargeChunk::range):
575         (bmalloc::XLargeChunk::size):
576
577 2014-04-08  Geoffrey Garen  <ggaren@apple.com>
578
579         Removed an unused file.
580
581         Unreviewed.
582
583         * bmalloc/AsyncTask.cpp: Removed.
584
585 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
586
587         Build bmalloc on Mac
588         https://bugs.webkit.org/show_bug.cgi?id=131333
589
590         Reviewed by Mark Rowe.
591
592         * Makefile: Added. For make clients.
593
594         These files are required for building any project in WebKit. I copied
595         them from WTF:
596         * Configurations: Added.
597         * Configurations/Base.xcconfig: Added.
598         * Configurations/DebugRelease.xcconfig: Added.
599         * Configurations/bmalloc.xcconfig: Added.
600         * Configurations/iOS.xcconfig: Added.
601         * Configurations/mbmalloc.xcconfig: Added.
602
603         * bmalloc.xcodeproj/project.pbxproj: I removed per-project-file stuff
604         from here because everything is in .xcconfig files now.
605
606         I had to fix a bunch of minor warnings, since they're enabled in our
607         .xcconfig files:
608
609         * bmalloc/AsyncTask.h:
610         (bmalloc::Function>::AsyncTask):
611         * bmalloc/BAssert.h:
612         * bmalloc/BoundaryTagInlines.h:
613         (bmalloc::validate):
614         * bmalloc/Heap.cpp:
615         (bmalloc::Heap::Heap):
616         (bmalloc::Heap::allocateLarge):
617         (bmalloc::Heap::deallocateLarge):
618         * bmalloc/Mutex.h:
619         (bmalloc::Mutex::Mutex): Deleted.
620         * bmalloc/VMAllocate.h:
621         (bmalloc::vmValidate):
622         * bmalloc/mbmalloc.cpp:
623
624 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
625
626         bmalloc: Fixed a leak in the per-thread cache
627         https://bugs.webkit.org/show_bug.cgi?id=131330
628
629         Reviewed by Andreas Kling.
630
631         Remember to deallocate our line caches upon thread exit.
632
633         * bmalloc/Deallocator.cpp:
634         (bmalloc::Deallocator::~Deallocator):
635
636 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
637
638         bmalloc: rolled out the tryLock experiment
639         https://bugs.webkit.org/show_bug.cgi?id=131328
640
641         Reviewed by Andreas Kling.
642
643         It wasn't a speedup.
644
645         * bmalloc.xcodeproj/project.pbxproj:
646         * bmalloc/Allocator.cpp:
647         (bmalloc::Allocator::processSmallAllocatorLog):
648         (bmalloc::Allocator::processMediumAllocatorLog):
649         * bmalloc/Deallocator.cpp:
650         (bmalloc::Deallocator::processObjectLog):
651         (bmalloc::Deallocator::deallocateSlowCase):
652         (bmalloc::Deallocator::deallocateSmallLine):
653         (bmalloc::Deallocator::deallocateMediumLine):
654         * bmalloc/Deallocator.h:
655         (bmalloc::Deallocator::deallocateFastCase):
656         * bmalloc/Heap.h:
657         (bmalloc::Heap::deallocateSmallLine):
658         (bmalloc::Heap::deallocateMediumLine):
659         * bmalloc/Line.h:
660         (bmalloc::Line<Traits>::deref):
661         * bmalloc/Page.h:
662         (bmalloc::Page<Traits>::deref):
663
664 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
665
666         bmalloc
667         https://bugs.webkit.org/show_bug.cgi?id=131170
668
669         Reviewed by Andreas Kling.
670
671         Initial commit.
672
673         * bmalloc: Added.
674         * bmalloc.xcodeproj: Added.
675         * bmalloc.xcodeproj/project.pbxproj: Added.
676         * bmalloc/Algorithm.h: Added.
677         (bmalloc::max):
678         (bmalloc::min):
679         (bmalloc::mask):
680         (bmalloc::test):
681         (bmalloc::roundUpToMultipleOf):
682         (bmalloc::roundDownToMultipleOf):
683         (bmalloc::sizeOf):
684         (bmalloc::bitCount):
685         (bmalloc::isPowerOfTwo):
686         * bmalloc/Allocator.cpp: Added.
687         (bmalloc::Allocator::Allocator):
688         (bmalloc::Allocator::~Allocator):
689         (bmalloc::Allocator::log):
690         (bmalloc::Allocator::processSmallAllocatorLog):
691         (bmalloc::Allocator::processMediumAllocatorLog):
692         (bmalloc::Allocator::allocateLarge):
693         (bmalloc::Allocator::allocateXLarge):
694         (bmalloc::Allocator::allocateMedium):
695         (bmalloc::Allocator::allocateSlowCase):
696         * bmalloc/Allocator.h: Added.
697         (bmalloc::Allocator::smallAllocatorFor):
698         (bmalloc::Allocator::allocateFastCase):
699         (bmalloc::Allocator::allocate):
700         * bmalloc/AsyncTask.cpp: Added.
701         (bmalloc::AsyncTask<Function>::runSlowCase):
702         (bmalloc::AsyncTask<Function>::pthreadEntryPoint):
703         (bmalloc::AsyncTask<Function>::entryPoint):
704         * bmalloc/AsyncTask.h: Added.
705         (bmalloc::Function>::AsyncTask):
706         (bmalloc::Function>::join):
707         (bmalloc::Function>::run):
708         (bmalloc::Function>::runSlowCase):
709         (bmalloc::Function>::pthreadEntryPoint):
710         (bmalloc::Function>::entryPoint):
711         * bmalloc/BAssert.h: Added.
712         * bmalloc/BeginTag.h: Added.
713         (bmalloc::BeginTag::isInFreeList):
714         * bmalloc/BoundaryTag.h: Added.
715         (bmalloc::BoundaryTag::isXLarge):
716         (bmalloc::BoundaryTag::setXLarge):
717         (bmalloc::BoundaryTag::isFree):
718         (bmalloc::BoundaryTag::setFree):
719         (bmalloc::BoundaryTag::isEnd):
720         (bmalloc::BoundaryTag::setEnd):
721         (bmalloc::BoundaryTag::hasPhysicalPages):
722         (bmalloc::BoundaryTag::setHasPhysicalPages):
723         (bmalloc::BoundaryTag::isNull):
724         (bmalloc::BoundaryTag::clear):
725         (bmalloc::BoundaryTag::size):
726         (bmalloc::BoundaryTag::setSize):
727         (bmalloc::BoundaryTag::prev):
728         (bmalloc::BoundaryTag::next):
729         * bmalloc/BoundaryTagInlines.h: Added.
730         (bmalloc::validate):
731         (bmalloc::validatePrev):
732         (bmalloc::validateNext):
733         (bmalloc::BoundaryTag::init):
734         (bmalloc::BoundaryTag::mergeLargeLeft):
735         (bmalloc::BoundaryTag::mergeLargeRight):
736         (bmalloc::BoundaryTag::mergeLarge):
737         (bmalloc::BoundaryTag::deallocate):
738         (bmalloc::BoundaryTag::splitLarge):
739         (bmalloc::BoundaryTag::allocate):
740         * bmalloc/Cache.cpp: Added.
741         (bmalloc::Cache::operator new):
742         (bmalloc::Cache::operator delete):
743         (bmalloc::Cache::Cache):
744         (bmalloc::Cache::allocateSlowCase):
745         (bmalloc::Cache::allocateSlowCaseNullCache):
746         (bmalloc::Cache::deallocateSlowCase):
747         (bmalloc::Cache::deallocateSlowCaseNullCache):
748         * bmalloc/Cache.h: Added.
749         (bmalloc::Cache::allocator):
750         (bmalloc::Cache::deallocator):
751         (bmalloc::Cache::allocateFastCase):
752         (bmalloc::Cache::deallocateFastCase):
753         (bmalloc::Cache::allocate):
754         (bmalloc::Cache::deallocate):
755         * bmalloc/Chunk.h: Added.
756         (bmalloc::Chunk::begin):
757         (bmalloc::Chunk::end):
758         (bmalloc::Chunk::lines):
759         (bmalloc::Chunk::pages):
760         * bmalloc/Deallocator.cpp: Added.
761         (bmalloc::Deallocator::Deallocator):
762         (bmalloc::Deallocator::~Deallocator):
763         (bmalloc::Deallocator::deallocateLarge):
764         (bmalloc::Deallocator::deallocateXLarge):
765         (bmalloc::Deallocator::processObjectLog):
766         (bmalloc::Deallocator::deallocateSlowCase):
767         (bmalloc::Deallocator::deallocateSmallLine):
768         (bmalloc::Deallocator::allocateSmallLine):
769         (bmalloc::Deallocator::deallocateMediumLine):
770         (bmalloc::Deallocator::allocateMediumLine):
771         * bmalloc/Deallocator.h: Added.
772         (bmalloc::Deallocator::deallocateFastCase):
773         (bmalloc::Deallocator::deallocate):
774         * bmalloc/EndTag.h: Added.
775         (bmalloc::EndTag::operator=):
776         * bmalloc/FixedVector.h: Added.
777         (bmalloc::FixedVector::begin):
778         (bmalloc::FixedVector::end):
779         (bmalloc::FixedVector::size):
780         (bmalloc::FixedVector::capacity):
781         (bmalloc::FixedVector::clear):
782         (bmalloc::FixedVector::isEmpty):
783         (bmalloc::Capacity>::FixedVector):
784         (bmalloc::Capacity>::operator):
785         (bmalloc::Capacity>::push):
786         (bmalloc::Capacity>::pop):
787         (bmalloc::Capacity>::shrink):
788         * bmalloc/Heap.cpp: Added.
789         (bmalloc::sleep):
790         (bmalloc::Heap::Heap):
791         (bmalloc::Heap::concurrentScavenge):
792         (bmalloc::Heap::scavengeSmallPages):
793         (bmalloc::Heap::scavengeMediumPages):
794         (bmalloc::Heap::scavengeLargeRanges):
795         (bmalloc::Heap::allocateSmallLineSlowCase):
796         (bmalloc::Heap::allocateMediumLineSlowCase):
797         (bmalloc::Heap::allocateXLarge):
798         (bmalloc::Heap::deallocateXLarge):
799         (bmalloc::Heap::allocateLarge):
800         (bmalloc::Heap::deallocateLarge):
801         * bmalloc/Heap.h: Added.
802         (bmalloc::Heap::deallocateSmallLine):
803         (bmalloc::Heap::allocateSmallLine):
804         (bmalloc::Heap::deallocateMediumLine):
805         (bmalloc::Heap::allocateMediumLine):
806         * bmalloc/Inline.h: Added.
807         * bmalloc/LargeChunk.h: Added.
808         (bmalloc::LargeChunk::begin):
809         (bmalloc::LargeChunk::end):
810         (bmalloc::LargeChunk::create):
811         (bmalloc::LargeChunk::get):
812         (bmalloc::LargeChunk::beginTag):
813         (bmalloc::LargeChunk::endTag):
814         * bmalloc/Line.h: Added.
815         (bmalloc::Line<Traits>::begin):
816         (bmalloc::Line<Traits>::end):
817         (bmalloc::Line<Traits>::concurrentRef):
818         (bmalloc::Line<Traits>::deref):
819         * bmalloc/MediumAllocator.h: Added.
820         (bmalloc::MediumAllocator::isNull):
821         (bmalloc::MediumAllocator::MediumAllocator):
822         (bmalloc::MediumAllocator::line):
823         (bmalloc::MediumAllocator::allocate):
824         (bmalloc::MediumAllocator::derefCount):
825         (bmalloc::MediumAllocator::refill):
826         * bmalloc/MediumChunk.h: Added.
827         * bmalloc/MediumLine.h: Added.
828         * bmalloc/MediumPage.h: Added.
829         * bmalloc/MediumTraits.h: Added.
830         * bmalloc/Mutex.cpp: Added.
831         (bmalloc::Mutex::lockSlowCase):
832         * bmalloc/Mutex.h: Added.
833         (bmalloc::Mutex::Mutex):
834         (bmalloc::Mutex::try_lock):
835         (bmalloc::Mutex::lock):
836         (bmalloc::Mutex::unlock):
837         * bmalloc/ObjectType.cpp: Added.
838         (bmalloc::objectType):
839         * bmalloc/ObjectType.h: Added.
840         (bmalloc::isSmallOrMedium):
841         (bmalloc::isSmall):
842         * bmalloc/Page.h: Added.
843         (bmalloc::Page<Traits>::ref):
844         (bmalloc::Page<Traits>::deref):
845         (bmalloc::Page<Traits>::refCount):
846         * bmalloc/PerProcess.h: Added.
847         (bmalloc::PerProcess::mutex):
848         (bmalloc::PerProcess<T>::getFastCase):
849         (bmalloc::PerProcess<T>::get):
850         (bmalloc::PerProcess<T>::getSlowCase):
851         * bmalloc/PerThread.h: Added.
852         (bmalloc::PerThreadStorage<Cache>::get):
853         (bmalloc::PerThreadStorage<Cache>::init):
854         (bmalloc::PerThreadStorage::get):
855         (bmalloc::PerThreadStorage::init):
856         (bmalloc::PerThread<T>::getFastCase):
857         (bmalloc::PerThread<T>::get):
858         (bmalloc::PerThread<T>::destructor):
859         (bmalloc::PerThread<T>::getSlowCase):
860         * bmalloc/Range.h: Added.
861         (bmalloc::Range::Range):
862         (bmalloc::Range::begin):
863         (bmalloc::Range::end):
864         (bmalloc::Range::size):
865         (bmalloc::Range::operator!):
866         (bmalloc::Range::operator<):
867         * bmalloc/SegregatedFreeList.cpp: Added.
868         (bmalloc::SegregatedFreeList::SegregatedFreeList):
869         (bmalloc::SegregatedFreeList::insert):
870         (bmalloc::SegregatedFreeList::takeGreedy):
871         (bmalloc::SegregatedFreeList::take):
872         * bmalloc/SegregatedFreeList.h: Added.
873         * bmalloc/Sizes.h: Added.
874         * bmalloc/SmallAllocator.h: Added.
875         (bmalloc::SmallAllocator::isNull):
876         (bmalloc::SmallAllocator::canAllocate):
877         (bmalloc::SmallAllocator::SmallAllocator):
878         (bmalloc::SmallAllocator::line):
879         (bmalloc::SmallAllocator::allocate):
880         (bmalloc::SmallAllocator::objectCount):
881         (bmalloc::SmallAllocator::derefCount):
882         (bmalloc::SmallAllocator::refill):
883         * bmalloc/SmallChunk.h: Added.
884         * bmalloc/SmallLine.h: Added.
885         * bmalloc/SmallPage.h: Added.
886         * bmalloc/SmallTraits.h: Added.
887         * bmalloc/Syscall.h: Added.
888         * bmalloc/VMAllocate.h: Added.
889         (bmalloc::vmSize):
890         (bmalloc::vmValidate):
891         (bmalloc::vmAllocate):
892         (bmalloc::vmDeallocate):
893         (bmalloc::vmDeallocatePhysicalPages):
894         (bmalloc::vmAllocatePhysicalPages):
895         (bmalloc::vmDeallocatePhysicalPagesSloppy):
896         (bmalloc::vmAllocatePhysicalPagesSloppy):
897         * bmalloc/VMHeap.cpp: Added.
898         (bmalloc::VMHeap::VMHeap):
899         (bmalloc::VMHeap::allocateSmallChunk):
900         (bmalloc::VMHeap::allocateMediumChunk):
901         (bmalloc::VMHeap::allocateLargeChunk):
902         * bmalloc/VMHeap.h: Added.
903         (bmalloc::VMHeap::allocateSmallPage):
904         (bmalloc::VMHeap::allocateMediumPage):
905         (bmalloc::VMHeap::allocateLargeRange):
906         (bmalloc::VMHeap::deallocateSmallPage):
907         (bmalloc::VMHeap::deallocateMediumPage):
908         (bmalloc::VMHeap::deallocateLargeRange):
909         * bmalloc/Vector.h: Added.
910         (bmalloc::Vector::begin):
911         (bmalloc::Vector::end):
912         (bmalloc::Vector::size):
913         (bmalloc::Vector::capacity):
914         (bmalloc::Vector::last):
915         (bmalloc::Vector::pop):
916         (bmalloc::Vector<T>::Vector):
917         (bmalloc::Vector<T>::~Vector):
918         (bmalloc::Vector<T>::operator):
919         (bmalloc::Vector<T>::push):
920         (bmalloc::Vector<T>::pop):
921         (bmalloc::Vector<T>::shrink):
922         (bmalloc::Vector<T>::reallocateBuffer):
923         (bmalloc::Vector<T>::shrinkCapacity):
924         (bmalloc::Vector<T>::growCapacity):
925         * bmalloc/XLargeChunk.h: Added.
926         (bmalloc::XLargeChunk::get):
927         (bmalloc::XLargeChunk::begin):
928         (bmalloc::XLargeChunk::XLargeChunk):
929         (bmalloc::XLargeChunk::create):
930         (bmalloc::XLargeChunk::destroy):
931         (bmalloc::XLargeChunk::range):
932         (bmalloc::XLargeChunk::size):
933         * bmalloc/bmalloc.h: Added.
934         (bmalloc::api::malloc):
935         (bmalloc::api::free):
936         (bmalloc::api::realloc):
937         * bmalloc/mbmalloc.cpp: Added.
938