Fixed a typo in the previous commit.
[WebKit-https.git] / Source / bmalloc / ChangeLog
1 2015-02-27  Ryosuke Niwa  <rniwa@webkit.org>
2
3         Fixed a typo in the previous commit.
4
5         * bmalloc/BoundaryTag.h:
6         (bmalloc::BoundaryTag::setOwner):
7
8 2015-02-27  Ryosuke Niwa  <rniwa@webkit.org>
9
10         EFL build fix after r180797.
11
12         * bmalloc/BoundaryTag.h:
13         (bmalloc::BoundaryTag::owner):
14         (bmalloc::BoundaryTag::setOwner):
15
16 2015-02-27  Geoffrey Garen  <ggaren@apple.com>
17
18         bmalloc: Pathological madvise churn on the free(malloc(x)) benchmark
19         https://bugs.webkit.org/show_bug.cgi?id=142058
20
21         Reviewed by Andreas Kling.
22
23         The churn was caused by repeatedly splitting an object with physical
24         pages from an object without, and then merging them back together again.
25         The merge would conservatively forget that we had physical pages, forcing
26         a new call to madvise on the next allocation.
27
28         This patch more strictly segregates objects in the heap from objects in
29         the VM heap, with these changes:
30
31         (1) Objects in the heap are not allowed to merge with objects in the VM
32         heap, and vice versa -- since that would erase our precise knowledge of
33         which physical pages had been allocated.
34
35         (2) The VM heap is exclusively responsible for allocating and deallocating
36         physical pages.
37
38         (3) The heap free list must consider entries for objects that are in the
39         VM heap to be invalid, and vice versa. (This condition can arise
40         because the free list does not eagerly remove items.)
41
42         With these changes, we can know that any valid object in the heap's free
43         list already has physical pages, and does not need to call madvise.
44
45         Note that the VM heap -- as before -- might sometimes contain ranges
46         or pieces of ranges that have physical pages, since we allow splitting
47         of ranges at granularities smaller than the VM page size. These ranges
48         can eventually merge with ranges in the heap during scavenging.
49
50         * bmalloc.xcodeproj/project.pbxproj:
51
52         * bmalloc/BoundaryTag.h:
53         (bmalloc::BoundaryTag::owner):
54         (bmalloc::BoundaryTag::setOwner):
55         (bmalloc::BoundaryTag::initSentinel):
56         (bmalloc::BoundaryTag::hasPhysicalPages): Deleted.
57         (bmalloc::BoundaryTag::setHasPhysicalPages): Deleted. Replaced the concept
58         of "has physical pages" with a bit indicating which heap owns the large
59         object. This is a more precise concept, since the old bit was really a
60         Yes / Maybe bit.
61
62         * bmalloc/Deallocator.cpp:
63
64         * bmalloc/FreeList.cpp: Adopt
65         (bmalloc::FreeList::takeGreedy):
66         (bmalloc::FreeList::take):
67         (bmalloc::FreeList::removeInvalidAndDuplicateEntries):
68         * bmalloc/FreeList.h:
69         (bmalloc::FreeList::push): Added API for considering the owner when
70         deciding if a free list entry is valid.
71
72         * bmalloc/Heap.cpp:
73         (bmalloc::Heap::Heap): Adopt new API.
74
75         (bmalloc::Heap::scavengeLargeRanges): Scavenge all ranges with no minimum,
76         since some ranges might be able to merge with ranges in the VM heap, and
77         they won't be allowed to until we scavenge them.
78
79         (bmalloc::Heap::allocateSmallPage):
80         (bmalloc::Heap::allocateMediumPage):
81         (bmalloc::Heap::allocateLarge): New VM heap API makes this function
82         simpler, since we always get back physical pages now.
83
84         * bmalloc/Heap.h:
85         * bmalloc/LargeObject.h:
86         (bmalloc::LargeObject::end):
87         (bmalloc::LargeObject::owner):
88         (bmalloc::LargeObject::setOwner):
89         (bmalloc::LargeObject::isValidAndFree):
90         (bmalloc::LargeObject::merge): Do not merge objects across heaps since
91         that causes madvise churn.
92         (bmalloc::LargeObject::validateSelf):
93         (bmalloc::LargeObject::init):
94         (bmalloc::LargeObject::hasPhysicalPages): Deleted.
95         (bmalloc::LargeObject::setHasPhysicalPages): Deleted. Propogate the Owner API.
96
97         * bmalloc/Owner.h: Added.
98
99         * bmalloc/SegregatedFreeList.cpp:
100         (bmalloc::SegregatedFreeList::SegregatedFreeList):
101         (bmalloc::SegregatedFreeList::insert):
102         (bmalloc::SegregatedFreeList::takeGreedy):
103         (bmalloc::SegregatedFreeList::take):
104         * bmalloc/SegregatedFreeList.h: Propogate the owner API.
105
106         * bmalloc/VMAllocate.h:
107         (bmalloc::vmDeallocatePhysicalPagesSloppy):
108         (bmalloc::vmAllocatePhysicalPagesSloppy): Clarified these functions and
109         removed an edge case.
110
111         * bmalloc/VMHeap.cpp:
112         (bmalloc::VMHeap::VMHeap):
113         * bmalloc/VMHeap.h:
114         (bmalloc::VMHeap::allocateSmallPage):
115         (bmalloc::VMHeap::allocateMediumPage):
116         (bmalloc::VMHeap::allocateLargeObject):
117         (bmalloc::VMHeap::deallocateLargeObject): Be sure to give each object
118         a new chance to merge, since it might have been prohibited from merging
119         before by virtue of not being in the VM heap.
120
121         (bmalloc::VMHeap::allocateLargeRange): Deleted.
122         (bmalloc::VMHeap::deallocateLargeRange): Deleted.
123
124 2015-02-26  Geoffrey Garen  <ggaren@apple.com>
125
126         bmalloc: Large object free list can grow infinitely
127         https://bugs.webkit.org/show_bug.cgi?id=142055
128
129         Reviewed by Andreas Kling.
130
131         By design, we don't eagerly remove large objects from the free list.
132         This creates two simple pathologies:
133
134             (1) If you free and then allocate the same object repeatedly, it will
135             duplicate itself in the free list repeatedly. Since it is never
136             invalid at the time of allocation, it will never be removed.
137
138             (2) If you split and then merge the same object repeatedly, it will
139             duplicate its split sibling in the free list repeatedly. If its
140             sibling is in a separate free list size class, it will never be
141             consulted at the time of allocation, so it will never be removed.
142
143         So, a simple "while (1) { free(malloc(x)); }" causes infinite memory
144         use in the free list.
145
146         The solution in this patch is a simple helper to remove garbage from the
147         free list if it grows too large. This pathology is not common, so the
148         cost is OK.
149
150         Long-term, perhaps we should rethink the laziness of these free lists.
151
152         * bmalloc/BoundaryTag.h:
153         (bmalloc::BoundaryTag::isMarked):
154         (bmalloc::BoundaryTag::setMarked): New bit, used by free list GC.
155
156         * bmalloc/FreeList.cpp:
157         (bmalloc::FreeList::removeInvalidAndDuplicateEntries): The GC algorithm.
158
159         * bmalloc/FreeList.h:
160         (bmalloc::FreeList::FreeList):
161         (bmalloc::FreeList::push): Invoke the GC if we're getting huge.
162
163         * bmalloc/LargeObject.h:
164         (bmalloc::LargeObject::isMarked):
165         (bmalloc::LargeObject::setMarked):
166         (bmalloc::LargeObject::validateSelf): Expose the new bit.
167
168         * bmalloc/Sizes.h: New constant to control GC frequency.
169
170 2015-02-26  Csaba Osztrogonác  <ossy@webkit.org>
171
172         URTBF after r180693.
173
174         * CMakeLists.txt:
175
176 2015-02-26  Geoffrey Garen  <ggaren@apple.com>
177
178         Try to fix the Mac build.
179
180         Unreviewed.
181
182         * bmalloc.xcodeproj/project.pbxproj: Make FreeList.h available.
183
184 2015-02-26  Geoffrey Garen  <ggaren@apple.com>
185
186         bmalloc: Refactored SegregatedFreeList and BoundaryTag::init
187         https://bugs.webkit.org/show_bug.cgi?id=142049
188
189         Reviewed by Anders Carlsson.
190
191         Split out a FreeList class from SegregatedFreeList. This will make it
192         easier to add behaviors on free list insertion and removal -- and it's
193         probably how I should have designed things at the start.
194
195         Moved BoundaryTag::init into LargeObject, since all the related logic
196         lives in LargeObject now too, and this allows us to remove BoundaryTagInlines.h.
197
198         * bmalloc.xcodeproj/project.pbxproj:
199         * bmalloc/BoundaryTagInlines.h: Removed.
200         * bmalloc/FreeList.cpp: Copied from Source/bmalloc/bmalloc/SegregatedFreeList.cpp.
201         (bmalloc::FreeList::takeGreedy):
202         (bmalloc::FreeList::take):
203         (bmalloc::SegregatedFreeList::SegregatedFreeList): Deleted.
204         (bmalloc::SegregatedFreeList::insert): Deleted.
205         (bmalloc::SegregatedFreeList::takeGreedy): Deleted.
206         (bmalloc::SegregatedFreeList::take): Deleted.
207         * bmalloc/FreeList.h: Copied from Source/bmalloc/bmalloc/SegregatedFreeList.h.
208         (bmalloc::FreeList::push):
209         * bmalloc/LargeObject.h:
210         (bmalloc::LargeObject::init):
211         * bmalloc/SegregatedFreeList.cpp:
212         (bmalloc::SegregatedFreeList::SegregatedFreeList):
213         (bmalloc::SegregatedFreeList::insert):
214         (bmalloc::SegregatedFreeList::takeGreedy):
215         (bmalloc::SegregatedFreeList::take):
216         * bmalloc/SegregatedFreeList.h:
217         * bmalloc/Sizes.h:
218         * bmalloc/VMHeap.cpp:
219         (bmalloc::VMHeap::grow):
220
221 2015-02-26  Geoffrey Garen  <ggaren@apple.com>
222
223         bmalloc: free up a bit in BoundaryTag
224         https://bugs.webkit.org/show_bug.cgi?id=142048
225
226         Reviewed by Brady Eidson.
227
228         We were wasting a bit by accident, and I need one now.
229
230         * bmalloc/Algorithm.h:
231         (bmalloc::rightShift): Deleted. Not needed, now that I've simplified
232         the math.
233
234         * bmalloc/BoundaryTag.h: Since each boundary tag bucket is 1024 bytes
235         long, the maximum offset into a bucket is 1023.
236
237         You need 5 bits to count up to 1024, but only 4 to count up to 1023.
238         
239         Math is hard.
240
241         (bmalloc::BoundaryTag::compactBegin): Switched to division because it
242         is simpler, and easier to match up with our ASSERT. The compiler will
243         turn division by constant power of two into a shift for us.
244
245         (bmalloc::BoundaryTag::setRange): Added an ASSERT for compactBegin
246         because we do encode it, so we should ASSERT that encoding did not
247         lose information.
248
249         * bmalloc/Sizes.h: Shifting is no longer used since we use division
250         instead.
251
252 2015-02-24  Stephanie Lewis  <slewis@apple.com>
253
254         Rolling out http://trac.webkit.org/changeset/180430 as it causes the PLT to crash.
255         <rdar://problem/19948015>
256
257         Unreviewed.
258
259         * bmalloc/VMHeap.cpp:
260         (bmalloc::VMHeap::grow):
261         * bmalloc/VMHeap.h:
262         * bmalloc/Zone.cpp:
263         (bmalloc::Zone::Zone):
264         (bmalloc::Zone::size): Deleted.
265         * bmalloc/Zone.h:
266
267 2015-02-24  Geoffrey Garen  <ggaren@apple.com>
268
269         bmalloc: Added a little more abstraction for large objects
270         https://bugs.webkit.org/show_bug.cgi?id=141978
271
272         Reviewed by Sam Weinig.
273
274         Previously, each client needed to manage the boundary tags of
275         a large object using free functions. This patch introduces a LargeObject
276         class that does things a little more automatically.
277
278         * bmalloc.xcodeproj/project.pbxproj:
279
280         * bmalloc/Allocator.cpp:
281         (bmalloc::Allocator::reallocate): Use the new LargeObject class.
282
283         * bmalloc/BeginTag.h:
284         (bmalloc::BeginTag::isInFreeList): Deleted. Moved this logic into the
285         LargeObject class.
286
287         * bmalloc/BoundaryTag.h:
288         (bmalloc::BoundaryTag::isSentinel):
289         (bmalloc::BoundaryTag::compactBegin):
290         (bmalloc::BoundaryTag::setRange):
291         (bmalloc::BoundaryTag::initSentinel): Added an explicit API for sentinels,
292         which we used to create and test for implicitly.
293
294         * bmalloc/BoundaryTagInlines.h:
295         (bmalloc::BoundaryTag::init):
296         (bmalloc::validate): Deleted.
297         (bmalloc::validatePrev): Deleted.
298         (bmalloc::validateNext): Deleted.
299         (bmalloc::BoundaryTag::mergeLeft): Deleted.
300         (bmalloc::BoundaryTag::mergeRight): Deleted.
301         (bmalloc::BoundaryTag::merge): Deleted.
302         (bmalloc::BoundaryTag::deallocate): Deleted.
303         (bmalloc::BoundaryTag::split): Deleted.
304         (bmalloc::BoundaryTag::allocate): Deleted. Moved this logic into the
305         LargeObject class.
306
307         * bmalloc/EndTag.h:
308         (bmalloc::EndTag::init):
309         (bmalloc::EndTag::operator=): Deleted. Re-reading this code, I found
310         special behavior in the assignment operator to be a surprising API.
311         So, I replaced the assignment operation with an explicit initializing
312         function.
313
314         * bmalloc/Heap.cpp:
315         (bmalloc::Heap::scavengeLargeRanges):
316         (bmalloc::Heap::allocateXLarge):
317         (bmalloc::Heap::findXLarge):
318         (bmalloc::Heap::deallocateXLarge):
319         (bmalloc::Heap::allocateLarge):
320         (bmalloc::Heap::deallocateLarge):
321         * bmalloc/Heap.h: No behavior changes here -- just adopting the
322         LargeObject interface.
323
324         * bmalloc/LargeObject.h: Added.
325         (bmalloc::LargeObject::operator!):
326         (bmalloc::LargeObject::begin):
327         (bmalloc::LargeObject::size):
328         (bmalloc::LargeObject::range):
329         (bmalloc::LargeObject::LargeObject):
330         (bmalloc::LargeObject::setFree):
331         (bmalloc::LargeObject::isFree):
332         (bmalloc::LargeObject::hasPhysicalPages):
333         (bmalloc::LargeObject::setHasPhysicalPages):
334         (bmalloc::LargeObject::isValidAndFree):
335         (bmalloc::LargeObject::merge):
336         (bmalloc::LargeObject::split):
337         (bmalloc::LargeObject::validateSelf):
338         (bmalloc::LargeObject::validate): Moved this code into a class, out of
339         BoundaryTag free functions.
340
341         New to the class are these features:
342
343             (1) Every reference to an object is validated upon creation and use.
344
345             (2) There's an explicit API for "This is a reference to an object
346             that might be stale (the DoNotValidate API)".
347
348             (3) The begin and end tags are kept in sync automatically.
349
350         * bmalloc/SegregatedFreeList.cpp:
351         (bmalloc::SegregatedFreeList::insert):
352         (bmalloc::SegregatedFreeList::takeGreedy):
353         (bmalloc::SegregatedFreeList::take):
354         * bmalloc/SegregatedFreeList.h: Adopt the LargeObject interface.
355
356         * bmalloc/VMHeap.cpp:
357         (bmalloc::VMHeap::grow):
358         * bmalloc/VMHeap.h:
359         (bmalloc::VMHeap::allocateLargeRange):
360         (bmalloc::VMHeap::deallocateLargeRange): Adopt the LargeObject interface.
361
362 2015-02-20  Geoffrey Garen  <ggaren@apple.com>
363
364         bmalloc should implement malloc introspection (to stop false-positive leaks when MallocStackLogging is off)
365         https://bugs.webkit.org/show_bug.cgi?id=141802
366
367         Reviewed by Andreas Kling.
368
369         Rolling back in with a fix for a crash seen while using GuardMalloc.
370
371         * bmalloc/VMHeap.cpp:
372         (bmalloc::VMHeap::grow):
373         * bmalloc/VMHeap.h:
374         * bmalloc/Zone.cpp: Re-land the old patch.
375
376         (bmalloc::Zone::size): Be sure to implement the size() function since
377         it's accessible indirectly via the malloc_zone_from_ptr public API --
378         and GuardMalloc calls it all the time.
379
380         (bmalloc::Zone::Zone):
381         * bmalloc/Zone.h: Re-land the old patch.
382
383 2015-02-19  Commit Queue  <commit-queue@webkit.org>
384
385         Unreviewed, rolling out r180363.
386         https://bugs.webkit.org/show_bug.cgi?id=141814
387
388         Caused >50 crashes when running LayoutTests in GuardMalloc or
389         ASAN modes. (Requested by jernoble on #webkit).
390
391         Reverted changeset:
392
393         "bmalloc should implement malloc introspection (to stop false-
394         positive leaks when MallocStackLogging is off)"
395         https://bugs.webkit.org/show_bug.cgi?id=141802
396         http://trac.webkit.org/changeset/180363
397
398 2015-02-19  Geoffrey Garen  <ggaren@apple.com>
399
400         bmalloc should implement malloc introspection (to stop false-positive leaks when MallocStackLogging is off)
401         https://bugs.webkit.org/show_bug.cgi?id=141802
402
403         Reviewed by Andreas Kling.
404
405         Fixed a last-minute type.
406
407         The macro is OS, not PLATFORM.
408
409         * bmalloc/VMHeap.cpp:
410         (bmalloc::VMHeap::grow):
411         * bmalloc/VMHeap.h:
412         * bmalloc/Zone.h:
413
414 2015-02-19  Geoffrey Garen  <ggaren@apple.com>
415
416         bmalloc should implement malloc introspection (to stop false-positive leaks when MallocStackLogging is off)
417         https://bugs.webkit.org/show_bug.cgi?id=141802
418
419         Reviewed by Andreas Kling.
420
421         This patch does the bare minimum to stop false positive leaks from
422         being reported by the Darwin leaks tool. We register each super chunk
423         as a single object, and then request that the leaks tool scan it.
424
425         * bmalloc.xcodeproj/project.pbxproj: Added an abstraction for the malloc
426         zone introspection API.
427
428         * bmalloc/Algorithm.h: Missing #include.
429
430         * bmalloc/VMHeap.cpp:
431         (bmalloc::VMHeap::grow):
432         * bmalloc/VMHeap.h: Adopt the new abstraction.
433
434         * bmalloc/Zone.cpp: Added.
435         (bmalloc::remoteRead): Helper for reading an object out of another process.
436         (bmalloc::Zone::enumerator):
437         (bmalloc::Zone::Zone): Register a malloc zone so that we will participate
438         in introspection.
439
440         * bmalloc/Zone.h: Added.
441         (bmalloc::Zone::superChunks):
442         (bmalloc::Zone::addSuperChunk): Use a non-dynamically-allocated vector
443         since our dynamic allocations will not be scanned by leaks since they
444         will have the malloc VM tag.
445
446 2015-02-18  Geoffrey Garen  <ggaren@apple.com>
447
448         bmalloc: VMHeap should keep a record of all of its VM ranges (for malloc introspection)
449         https://bugs.webkit.org/show_bug.cgi?id=141759
450
451         Reviewed by Andreas Kling.
452
453         * bmalloc.xcodeproj/project.pbxproj:
454         * bmalloc/SuperChunk.h: Added.
455         (bmalloc::SuperChunk::create):
456         (bmalloc::SuperChunk::SuperChunk):
457         (bmalloc::SuperChunk::smallChunk):
458         (bmalloc::SuperChunk::mediumChunk):
459         (bmalloc::SuperChunk::largeChunk): Factored out super chunk creation
460         into a separate class, for clarity and type safety.
461
462         * bmalloc/VMHeap.cpp:
463         (bmalloc::VMHeap::grow):
464         (bmalloc::VMHeap::allocateSuperChunk): Renamed "allocateSuperChunk" to
465         "grow" because Andreas found "allocateSuperChunk" to be unclear.
466
467         * bmalloc/VMHeap.h: Track all our VM ranges. We will use this information
468         for malloc introspection.
469
470         (bmalloc::VMHeap::allocateSmallPage):
471         (bmalloc::VMHeap::allocateMediumPage):
472         (bmalloc::VMHeap::allocateLargeRange): Updated for renames.
473
474 2015-02-18  Zan Dobersek  <zdobersek@igalia.com>
475
476         Build bmalloc through CMake as a static library. It's then linked either
477         into the WTF library (if built as a shared library) or into the JSC and
478         WebKit2 libraries. There's no need to build it as a standalone shared library.
479
480         Rubber-stamped by Carlos Garcia Campos.
481
482         * CMakeLists.txt:
483
484 2015-02-13  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
485
486         [BMalloc] Add a FIXME comment for memory alignas
487         https://bugs.webkit.org/show_bug.cgi?id=141556
488
489         Reviewed by Csaba Osztrogonác.
490
491         * bmalloc/Chunk.h: Add a FIXME comment.
492         * bmalloc/LargeChunk.h: ditto.
493
494 2015-02-11  Csaba Osztrogonác  <ossy@webkit.org>
495
496         bmalloc buildfix on 32 bit Linux (x86/ARM)
497         https://bugs.webkit.org/show_bug.cgi?id=141472
498
499         Reviewed by Gyuyoung Kim.
500
501         * bmalloc/Algorithm.h:
502         (bmalloc::roundUpToMultipleOf):
503         * bmalloc/FixedVector.h:
504         (bmalloc::FixedVector::clear):
505         * bmalloc/Sizes.h:
506         (bmalloc::Sizes::sizeClass):
507
508 2015-02-11  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
509
510         [EFL][GTK] Use bmalloc instead of tcmalloc
511         https://bugs.webkit.org/show_bug.cgi?id=140162
512
513         Reviewed by Carlos Garcia Campos.
514
515         Support to use bmalloc on EFL and GTK ports.
516
517         * CMakeLists.txt: Added.
518         * bmalloc/Allocator.cpp:
519         (bmalloc::Allocator::allocate):
520             Fix unused return value caused by posix_memalign().
521         * bmalloc/AsyncTask.h:
522         * bmalloc/BoundaryTag.h:
523         (bmalloc::BoundaryTag::clear):
524         * bmalloc/Chunk.h:
525             Change Traits::Page with Traits::PageType in order to fix
526             -fpermitive build error on EFL and GTK port. 
527         * bmalloc/EndTag.h:
528         (bmalloc::EndTag::operator=):
529         * bmalloc/Line.h: ditto.
530         * bmalloc/MediumTraits.h:
531         * bmalloc/Page.h: ditto.
532         * bmalloc/PerThread.h:
533             EFL port doesn't support __has_include definition yet.
534             Define HAVE_PTHREAD_MACHDEP_H according to check if __has_include is supported.
535         * bmalloc/SmallTraits.h: ditto.
536         * bmalloc/VMAllocate.h:
537         (bmalloc::vmDeallocatePhysicalPages):
538         (bmalloc::vmAllocatePhysicalPages):
539         * bmalloc/Vector.h:
540         (bmalloc::Vector<T>::push):
541         (bmalloc::Vector<T>::reallocateBuffer):
542
543 2015-01-31  Sam Weinig  <sam@webkit.org>
544
545         Remove even more Mountain Lion support
546         https://bugs.webkit.org/show_bug.cgi?id=141124
547
548         Reviewed by Alexey Proskuryakov.
549
550         * Configurations/Base.xcconfig:
551         * Configurations/DebugRelease.xcconfig:
552
553 2015-01-30  Geoffrey Garen  <ggaren@apple.com>
554
555         GC marking threads should clear malloc caches
556         https://bugs.webkit.org/show_bug.cgi?id=141097
557
558         Reviewed by Andreas Kling.
559
560         Split the scavenging API into per-thread vs global, so that you can
561         request to scavenge your own thread without scavenging the whole heap.
562
563         * bmalloc/Cache.cpp:
564         (bmalloc::Cache::scavenge):
565         * bmalloc/bmalloc.h:
566         (bmalloc::api::scavengeThisThread):
567         (bmalloc::api::scavenge):
568
569 2015-01-28  Dana Burkart  <dburkart@apple.com>
570
571         Move ASan flag settings from DebugRelease.xcconfig to Base.xcconfig
572         https://bugs.webkit.org/show_bug.cgi?id=136765
573
574         Reviewed by Alexey Proskuryakov.
575
576         * Configurations/Base.xcconfig:
577         * Configurations/DebugRelease.xcconfig:
578
579 2015-01-21  Geoffrey Garen  <ggaren@apple.com>
580
581         bmalloc: support aligned allocation
582         https://bugs.webkit.org/show_bug.cgi?id=140732
583
584         Reviewed by Andreas Kling.
585
586         * bmalloc/Allocator.cpp:
587         (bmalloc::Allocator::allocate): New function for aligned allocation.
588
589         Small and medium requests just allocate and free until they find an
590         aligned pointer. This is slightly inefficient in the worst case, but
591         still constant-time with little-to-no space overhead.
592
593         Large requests use a new API that requires the client to specify both
594         its ideal size and alignment, and the worst-case size you would have to
595         allocate in order to produce some interior pointer of the requested size
596         and alignment. We put the burden of this calculation on the client
597         because it simplifies things if we guarantee that allocation won't fail.
598
599         XLarge requests are easy: we just forward them to vmAllocate, which
600         already supported aligned requests.
601
602         * bmalloc/BoundaryTag.h:
603         * bmalloc/BoundaryTagInlines.h:
604         (bmalloc::BoundaryTag::mergeLeft):
605         (bmalloc::BoundaryTag::mergeRight):
606         (bmalloc::BoundaryTag::merge):
607         (bmalloc::BoundaryTag::deallocate):
608         (bmalloc::BoundaryTag::split):
609         (bmalloc::BoundaryTag::allocate): No behavior change here. I just
610         refactored the interface to remove some reference out parameters in
611         order to clarify what changes and what doesn't.
612
613         * bmalloc/Heap.cpp:
614         (bmalloc::Heap::allocateXLarge): Added an alignment API.
615
616         (bmalloc::Heap::allocateLarge):
617         * bmalloc/Heap.h: Added an alignment API. I split out allocateLarge into
618         a few variants, so aligned and unaligned allocation could share some code.
619
620         * bmalloc/SegregatedFreeList.cpp:
621         (bmalloc::SegregatedFreeList::take):
622         * bmalloc/SegregatedFreeList.h: Changed to use a separate, explicit API
623         for aligned allocation. It turns out that the aligned path is pretty
624         different, since it ends up searching for two potential ways to satisfy
625         an allocation: either large enough and aligned, or large enough to split
626         into something not aligned and something large enough and aligned.
627
628         * bmalloc/VMAllocate.h:
629         (bmalloc::vmAllocate): Switched alignment to come before size because
630         that's how the memalign API specifies it.
631
632         * bmalloc/VMHeap.h:
633         (bmalloc::VMHeap::allocateLargeRange): Added an alignment API.
634
635 2015-01-20  Geoffrey Garen  <ggaren@apple.com>
636
637         bmalloc: a little bit of cleanup
638         https://bugs.webkit.org/show_bug.cgi?id=140687
639
640         Reviewed by Anders Carlsson.
641
642         * bmalloc/Algorithm.h:
643         (bmalloc::isPowerOfTwo): Added a check for 0, since 0 would break a lot
644         of code.
645
646         * bmalloc/BoundaryTag.h:
647         * bmalloc/BoundaryTagInlines.h:
648         (bmalloc::BoundaryTag::mergeLeft):
649         (bmalloc::BoundaryTag::mergeRight):
650         (bmalloc::BoundaryTag::merge):
651         (bmalloc::BoundaryTag::deallocate):
652         (bmalloc::BoundaryTag::split):
653         (bmalloc::BoundaryTag::allocate):
654         (bmalloc::BoundaryTag::mergeLargeLeft): Deleted.
655         (bmalloc::BoundaryTag::mergeLargeRight): Deleted.
656         (bmalloc::BoundaryTag::mergeLarge): Deleted.
657         (bmalloc::BoundaryTag::splitLarge): Deleted. Removed the word "Large"
658         from all these functions, since boundary tags always pertain to large
659         objects, and putting the word "Large" everywhere wasn't helping to
660         explain that.
661
662         * bmalloc/Heap.cpp:
663         (bmalloc::Heap::allocateXLarge):
664         (bmalloc::Heap::findXLarge):
665         (bmalloc::Heap::deallocateXLarge):
666         * bmalloc/Heap.h:
667         * bmalloc/VMHeap.h:
668         (bmalloc::VMHeap::allocateXLarge): Deleted.
669         (bmalloc::VMHeap::findXLarge): Deleted.
670         (bmalloc::VMHeap::deallocateXLarge): Deleted. Moved XLarge allocation
671         from VMHeap to Heap. Since the purpose of the VMHeap is to cache VM
672         ranges, and the VMHeap never caches any XLarge ranges, it doesn't
673         really make sense for the VMHeap to be involved.
674
675 2015-01-16  Geoffrey Garen  <ggaren@apple.com>
676
677         bmalloc: refactored XLarge allocation for better alignment
678         https://bugs.webkit.org/show_bug.cgi?id=140582
679
680         Reviewed by Andreas Kling.
681
682         XLarge objects used to be Large objects with an extra bit of metadata
683         that said "actually, I'm not large -- I'm extra large".
684
685         The metadata header in an XLarge allocation made it impossible for the
686         XLarge object to honor a very large alignment request.
687
688         The solution is to stop using a metadata header for XLarge objects, and
689         instead to store explicit metadata on the side.
690
691         This is a bit less astonishing, which is also nice.
692
693         Finding XLarge metadata is now a linear search. That's probably OK, since
694         it was always so in TCMalloc, and the usual number of XLarge allocations
695         in a process is 0.
696
697         This design makes it possible for the heap to cache XLarge allocations
698         with and/or without physical pages. I haven't actually done that yet
699         because the tradeoffs are subtle, so I don't want to do anything without
700         a motivating test case.
701
702         * bmalloc.xcodeproj/project.pbxproj:
703         * bmalloc/Allocator.cpp:
704         (bmalloc::Allocator::reallocate): Removed the concept of an XLargeChunk,
705         since an XLarge allocation is now just a naked buffer without a header.
706
707         (bmalloc::Allocator::allocateXLarge): Added an explicit qualifier for
708         XLarge alignment, since XLargeChunk won't give this to us implicitly
709         anymore.
710
711         * bmalloc/BoundaryTag.h:
712         (bmalloc::BoundaryTag::setRange):
713         (bmalloc::BoundaryTag::isXLarge): Deleted.
714         (bmalloc::BoundaryTag::setXLarge): Deleted.
715         * bmalloc/BoundaryTagInlines.h:
716         (bmalloc::validate):
717         (bmalloc::BoundaryTag::deallocate): Removed the XLarge hacks from Large allocations.
718
719         * bmalloc/Deallocator.cpp:
720         (bmalloc::Deallocator::deallocateXLarge):
721         (bmalloc::Deallocator::deallocateSlowCase):
722         * bmalloc/Heap.cpp:
723         (bmalloc::Heap::findXLarge):
724         (bmalloc::Heap::allocateXLarge):
725         (bmalloc::Heap::deallocateXLarge):
726         * bmalloc/Heap.h: Updated for interface changes.
727
728         * bmalloc/ObjectType.cpp:
729         (bmalloc::objectType):
730         * bmalloc/ObjectType.h:
731         (bmalloc::isXLarge): We can now tell if a pointer is XLarge just by
732         examining its bit pattern -- just like we do for other kinds of
733         allocations -- which is nice.
734
735         * bmalloc/Sizes.h:
736         * bmalloc/VMHeap.h:
737         (bmalloc::VMHeap::allocateXLarge):
738         (bmalloc::VMHeap::findXLarge):
739         (bmalloc::VMHeap::deallocateXLarge): Keep an explicit vector of metadata
740         for XLarge allocations.
741
742         * bmalloc/XLargeChunk.h: Removed.
743
744 2015-01-16  Geoffrey Garen  <ggaren@apple.com>
745
746         bmalloc: added some infrastructure for aligned allocation
747         https://bugs.webkit.org/show_bug.cgi?id=140572
748
749         Reviewed by Andreas Kling.
750
751         * bmalloc/Algorithm.h:
752         (bmalloc::isPowerOfTwo):
753         (bmalloc::roundUpToMultipleOf):
754         (bmalloc::roundDownToMultipleOf): Refactored some duplicate code to use our
755         isPowerOfTwo helper function.
756
757         * bmalloc/Allocator.cpp:
758         (bmalloc::Allocator::allocate):
759         * bmalloc/Allocator.h: Stubbed out an implementation of aligned allocation.
760         Doesn't do anything yet, but does correctly forward to system malloc
761         when bmalloc is disabled.
762
763         * bmalloc/Cache.cpp:
764         (bmalloc::Cache::allocateSlowCaseNullCache):
765         * bmalloc/Cache.h:
766         (bmalloc::Cache::allocate):
767         * bmalloc/bmalloc.h:
768         (bmalloc::api::memalign):
769         * bmalloc/mbmalloc.cpp: Stubbed out an API for aligned allocation.
770
771 2015-01-13  Geoffrey Garen  <ggaren@apple.com>
772
773         Consider alignment when allocating from a SegregatedFreeList
774         https://bugs.webkit.org/show_bug.cgi?id=140408
775
776         Reviewed by Sam Weinig.
777
778         In preparation for supporting aligned allocation.
779
780         No performance change.
781
782         Since this is just one extra branch in an already expensive function,
783         I decided not to duplicate the function just to avoid the branch in
784         the un-aligned case.
785
786         * bmalloc/SegregatedFreeList.cpp:
787         (bmalloc::SegregatedFreeList::take):
788         * bmalloc/SegregatedFreeList.h:
789
790 2015-01-13  Geoffrey Garen  <ggaren@apple.com>
791
792         Renamed minimum to size in SegregatedFreeList
793         https://bugs.webkit.org/show_bug.cgi?id=140406
794
795         Reviewed by Sam Weinig.
796
797         In preparation for supporting aligned allocation.
798
799         * bmalloc/SegregatedFreeList.cpp:
800         (bmalloc::SegregatedFreeList::takeGreedy):
801         (bmalloc::SegregatedFreeList::take): Every size passed to malloc is
802         really just a minimum. Let's not imply that this value is special.
803
804 2015-01-11  Dan Bernstein  <mitz@apple.com>
805
806         Geoff is organized, but he is not an organization.
807
808         Rubber-stamped by Anders Carlsson.
809
810         * bmalloc.xcodeproj/project.pbxproj: Removed the ORGANIZATIONNAME project attribute.
811
812 2015-01-07  Geoffrey Garen  <ggaren@apple.com>
813
814         Make bmalloc work with ASan
815         https://bugs.webkit.org/show_bug.cgi?id=140194
816
817         Reviewed by Mark Lam.
818
819         * bmalloc/BPlatform.h: Added a way to detect Darwin OSes, since we need
820         an OS-specific API to test for loaded runtime libraries.
821
822         * bmalloc/Environment.cpp:
823         (bmalloc::isASanEnabled):
824         (bmalloc::Environment::computeIsBmallocEnabled): Disabled bmalloc if
825         ASan is enabled, since system malloc has the Asan hooks we need.
826
827         You could check for the ASan compile-time flag instead, but doing this
828         check at runtime prepares bmalloc for a world where it is a dynamic
829         library that might be loaded into projects it did not compile with.
830
831 2015-01-05  Geoffrey Garen  <ggaren@apple.com>
832
833         Fix up bmalloc's PerThread for use on Linux
834         https://bugs.webkit.org/show_bug.cgi?id=139804
835
836         Reviewed by Anders Carlsson.
837
838         The previous implementation was a bit slow.
839
840         * bmalloc/PerThread.h:
841         (bmalloc::PerThreadStorage<Cache>::get):
842         (bmalloc::PerThreadStorage::get):
843         (bmalloc::PerThreadStorage::init): Added a catch-all cross-platform Unix
844         way to do fast per-thread access without taking a lock every time. This
845         probably works on all the platforms we care about, and it matches other
846         techniques we use elsewhere in WebKit.
847
848         (bmalloc::PerThread<T>::getFastCase): Removed the conditional from
849         this class because PerThreadStorage now encapsulates everything that
850         needs to be conditional.
851
852         (bmalloc::PerThreadStorage::initSharedKeyIfNeeded): Deleted.
853
854 2014-12-26  Dan Bernstein  <mitz@apple.com>
855
856         <rdar://problem/19348208> REGRESSION (r177027): iOS builds use the wrong toolchain
857         https://bugs.webkit.org/show_bug.cgi?id=139950
858
859         Reviewed by David Kilzer.
860
861         * Configurations/Base.xcconfig: Only define TOOLCHAINS when building for OS X, doing so
862         in a manner that works with Xcode 5.1.1.
863
864 2014-12-15  Geoffrey Garen  <ggaren@apple.com>
865
866         Safari crashes when you set Malloc environment variables
867         https://bugs.webkit.org/show_bug.cgi?id=139656
868
869         Reviewed by Michael Saboff.
870
871         I forgot to cover the realloc() case. Whoops. (OoPS?)
872
873         This time around, I ran the full MallocBench test suite in Malloc=1
874         mode, and it passed.
875
876         * bmalloc/Allocator.cpp:
877         (bmalloc::Allocator::reallocate):
878         * bmalloc/Allocator.h: Pushed realloc() logic down into the allocator.
879         It needs to be down there so that we can do the short-circuiting check
880         for whether bmalloc is enabled first.
881
882         Also added the check.
883
884         * bmalloc/Cache.cpp:
885         (bmalloc::Cache::scavenge):
886         (bmalloc::Cache::Cache):
887         (bmalloc::Cache::reallocateSlowCaseNullCache):
888         * bmalloc/Cache.h:
889         (bmalloc::Cache::deallocator):
890         (bmalloc::Cache::reallocate): Ditto.
891
892         * bmalloc/bmalloc.h:
893         (bmalloc::api::free):
894         (bmalloc::api::realloc): Ditto.
895
896         (bmalloc::api::scavenge): Pushed this down into Cache to match the
897         surrounding functions.
898
899 2014-12-11  Geoffrey Garen  <ggaren@apple.com>
900
901         bmalloc should support system memory analysis tools (part 2)
902         https://bugs.webkit.org/show_bug.cgi?id=139565
903
904         Reviewed by Mark Lam.
905
906         This patch actually queries the environment to see if memory analysis
907         tools have been enabled.
908
909         * bmalloc/Deallocator.cpp:
910         (bmalloc::Deallocator::scavenge): Don't process the object log if
911         we've disabled bmalloc because it will be full of invalid nullptrs.
912
913         * bmalloc/Environment.cpp:
914         (bmalloc::isMallocEnvironmentVariableSet): Test for the list of known
915         Malloc debugging flags. I also added a plain "Malloc" catch-all for
916         when you want to disable bmalloc without enabling any kind of funny
917         business.
918
919         It would be slightly nicer just to iterate the list of environment
920         variables and strstr them, but getenv is the more portable option,
921         and performance here doesn't really matter.
922
923         (bmalloc::isLibgmallocEnabled): Test for the libgmalloc insertion
924         environment variable.
925
926         (bmalloc::Environment::computeIsBmallocEnabled):
927
928 2014-12-11  Geoffrey Garen  <ggaren@apple.com>
929
930         Try to fix the iOS simulator build.
931
932         #include the declaration of malloc / free.
933
934         * bmalloc/Allocator.cpp:
935         * bmalloc/Deallocator.cpp:
936
937 2014-12-11  Geoffrey Garen  <ggaren@apple.com>
938
939         Try to fix the build.
940
941         * bmalloc.xcodeproj/project.pbxproj: Marked a header exported.
942
943 2014-12-11  Geoffrey Garen  <ggaren@apple.com>
944
945         bmalloc should support system memory analysis tools (part 1)
946         https://bugs.webkit.org/show_bug.cgi?id=139559
947
948         Reviewed by Mark Lam.
949
950         This patch adds the hooks to disable bmalloc at runtime if certain
951         environment variables are set, but doesn't actually read from the
952         environment yet.
953
954         No performance change.
955
956         * bmalloc.xcodeproj/project.pbxproj: Added the Environment class, which
957         we'll use to read environment variables and see if memory analysis tools
958         have been enabled.
959
960         * bmalloc/Allocator.cpp:
961         (bmalloc::Allocator::Allocator):
962         (bmalloc::Allocator::allocateSlowCase): Added a hook to disable bmalloc
963         on the allocation path. We cache the setting to make the check fast.
964
965         * bmalloc/Allocator.h: Interface changes.
966
967         * bmalloc/Cache.cpp:
968         (bmalloc::Cache::Cache): Pass a heap pointer through to our allocator
969         and deallocator. This main purpose is to enable them to query the
970         environment for whether bmalloc is enabled; but this is also a slightly
971         cleaner way to guarantee to them that the Heap has been pre-initialized.
972
973         * bmalloc/Deallocator.cpp:
974         (bmalloc::Deallocator::Deallocator): If bmalloc is disable, artificially
975         fill the object log to force us to take the slow path on all deallocations.
976
977         (bmalloc::Deallocator::deallocateSlowCase): Do the disabled check.
978
979         * bmalloc/Deallocator.h: Interface changes.
980
981         * bmalloc/Environment.cpp: Added.
982         (bmalloc::Environment::Environment):
983         (bmalloc::Environment::computeIsBmallocEnabled):
984         * bmalloc/Environment.h: Added.
985         (bmalloc::Environment::isBmallocEnabled): This is the class that will
986         encapsulate looking for environment variables that turn on heap
987         analysis tools.
988
989         * bmalloc/Heap.h:
990         (bmalloc::Heap::environment):
991
992         * bmalloc/Mutex.h:
993         (bmalloc::Mutex::Mutex):
994         * bmalloc/StaticMutex.h: A little refactoring to clarify these comments,
995         since I got super confused about them while writing this patch.
996
997         * bmalloc/VMHeap.cpp: Fixed an #include.
998
999 2014-12-09  David Kilzer  <ddkilzer@apple.com>
1000
1001         Switch from using PLATFORM_NAME to SDK selectors in ANGLE, bmalloc, gtest, JavaScriptCore, WTF
1002         <http://webkit.org/b/139212>
1003
1004         Reviewed by Joseph Pecoraro.
1005
1006         * Configurations/Base.xcconfig:
1007         - Only set GCC_ENABLE_OBJC_GC, GCC_MODEL_TUNING and TOOLCHAINS
1008           on OS X.
1009         * Configurations/DebugRelease.xcconfig:
1010         - Only set MACOSX_DEPLOYMENT_TARGET and SDKROOT on OS X.
1011
1012 2014-11-07  Geoffrey Garen  <ggaren@apple.com>
1013
1014         bmalloc uses 8X more virtual memory than necessary
1015         https://bugs.webkit.org/show_bug.cgi?id=138495
1016
1017         Reviewed by Mark Lam.
1018
1019         iOS has a per-process virtual memory cap around 1GB, so there's some
1020         value to not going totally ham with virtual memory.
1021
1022         We currently use about 8X the necessary amount:
1023             - 2X to align our VM allocation
1024             - 4X to reserve small / medium / (2) large chunk VM ranges per superchunk
1025
1026         We can cut that down:
1027             - Return the unaligned portion of our VM allocation (-2X)
1028             - Use all the chunks in a superchunk, instead of allocating one
1029               chunk per superchunk (-4X)
1030
1031         * bmalloc/Algorithm.h:
1032         (bmalloc::roundUpToMultipleOf): Added a non-constant version of this
1033         function so we can call it with getpagesize() at runtime.
1034
1035         * bmalloc/Chunk.h:
1036         * bmalloc/LargeChunk.h:
1037         (bmalloc::LargeChunk::create): Deleted. Instead of each chunk allocating
1038         its own VM, VMHeap allocates the superchunk and all the chunks in it at a time.
1039
1040         * bmalloc/VMAllocate.h:
1041         (bmalloc::vmValidate):
1042         (bmalloc::vmAllocate): ASSERT that mmap succeeds to make crashes clearer
1043         if it does not succeed. Allocate precisely, and give back the extra.
1044
1045         * bmalloc/VMHeap.cpp:
1046         (bmalloc::VMHeap::allocateSuperChunk):
1047         (bmalloc::VMHeap::allocateSmallChunk): Deleted.
1048         (bmalloc::VMHeap::allocateMediumChunk): Deleted.
1049         (bmalloc::VMHeap::allocateLargeChunk): Deleted. Use all the chunks
1050         in a superchunk, instead of just one.
1051
1052         * bmalloc/VMHeap.h:
1053         (bmalloc::VMHeap::allocateSmallPage):
1054         (bmalloc::VMHeap::allocateMediumPage):
1055         (bmalloc::VMHeap::allocateLargeRange):
1056         * bmalloc/XLargeChunk.h:
1057         (bmalloc::XLargeChunk::create): Updated to match changes above.
1058
1059 2014-11-01  David Kilzer  <ddkilzer@apple.com>
1060
1061         JavaScriptCore is missing debug info for bmalloc because libbmalloc.a is stripped
1062         <https://webkit.org/b/138286>
1063         <rdar://problem/18847087>
1064
1065         Reviewed by Dan Bernstein.
1066
1067         * Configurations/bmalloc.xcconfig: Set STRIP_INSTALLED_PRODUCT
1068         to NO for the target that produces libbmalloc.a so that the
1069         debug symbols will be linked into JavaScriptCore and end up in
1070         its dSYM file.
1071
1072 2014-10-30  Dana Burkart  <dburkart@apple.com>
1073
1074         <rdar://problem/18821260> Prepare for the mysterious future
1075
1076         Reviewed by Lucas Forschler.
1077
1078         * Configurations/Base.xcconfig:
1079         * Configurations/DebugRelease.xcconfig:
1080
1081 2014-09-24  Geoffrey Garen  <ggaren@apple.com>
1082
1083         bmalloc: cleaned up fast path vs slow path
1084         https://bugs.webkit.org/show_bug.cgi?id=137081
1085
1086         Reviewed by Sam Weinig.
1087
1088         Might be a 1% speedup on MallocBench. Also cleans up the code a bit.
1089
1090         * bmalloc/Allocator.cpp:
1091         (bmalloc::Allocator::Allocator): Merged the small and medium range
1092         caches, just like the small and medium allocators. Ranges are abstract
1093         objects that don't really care whether they hold small or medium objects,
1094         so they don't need to be segregated.
1095
1096         (bmalloc::Allocator::scavenge): Ditto.
1097
1098         (bmalloc::Allocator::allocateBumpRangeSlowCase):
1099         (bmalloc::Allocator::allocateBumpRange): Same thing here, except that
1100         we do care a tiny bit, because we need to specify small vs medium when
1101         allocating new ranges from the heap, to ensure that the heap allocates
1102         from the right segment of VM.
1103
1104         (bmalloc::Allocator::allocateLarge):
1105         (bmalloc::Allocator::allocateXLarge): NO_INLINE because this was clouding
1106         up the fast path. Large allocation performance is dominated by allocation
1107         logic and initialization, so inlining it doesn't help.
1108
1109         (bmalloc::Allocator::allocateSlowCase): Slow path got a bit cleaner since
1110         it doesn't need to distinguish small vs medium objects.
1111
1112         (bmalloc::Allocator::allocateSmallBumpRange): Deleted.
1113         (bmalloc::Allocator::allocateMediumBumpRange): Deleted.
1114
1115         * bmalloc/Allocator.h:
1116         * bmalloc/BumpRange.h:
1117
1118         * bmalloc/Cache.cpp:
1119         (bmalloc::Cache::allocateSlowCase): Deleted.
1120         (bmalloc::Cache::deallocateSlowCase): Deleted.
1121         * bmalloc/Cache.h:
1122         (bmalloc::Cache::allocate):
1123         (bmalloc::Cache::deallocate):
1124         (bmalloc::Cache::allocateFastCase): Deleted.
1125         (bmalloc::Cache::deallocateFastCase): Deleted. Removed the Cache slow
1126         paths. The downside to this change is that the fast path branches to two
1127         distinct failure cases instead of one. The upside is that the slow path
1128         doesn't need to re-read the segment register, which is not as cheap as a
1129         normal register, and it doesn't need to do an extra level of function 
1130         call. Seems to be worth it.
1131
1132         * bmalloc/Deallocator.h:
1133         * bmalloc/Heap.cpp:
1134         (bmalloc::Heap::refillSmallBumpRangeCache):
1135         (bmalloc::Heap::refillMediumBumpRangeCache):
1136         * bmalloc/Heap.h: Updated for interface changes.
1137
1138         * bmalloc/Sizes.h: The most ranges a cache will hold is the number of
1139         small lines in a page / 2, since any other free lines will coalesce
1140         with their neighbors.
1141
1142 2014-09-23  Geoffrey Garen  <ggaren@apple.com>
1143
1144         Rolled out r173346.
1145
1146             bmalloc should honor the FastMalloc statistics API
1147             https://bugs.webkit.org/show_bug.cgi?id=136592
1148
1149         This didn't really work. Because we allow ranges with and without
1150         physical pages to merge, and we allow double-committing and
1151         double-decommitting, we can't rely on commit actions to track memory
1152         footprint.
1153
1154         * bmalloc/Heap.cpp:
1155         (bmalloc::Heap::size): Deleted.
1156         (bmalloc::Heap::capacity): Deleted.
1157         * bmalloc/Heap.h:
1158         * bmalloc/VMHeap.cpp:
1159         (bmalloc::VMHeap::VMHeap):
1160         (bmalloc::VMHeap::allocateSmallChunk):
1161         (bmalloc::VMHeap::allocateMediumChunk):
1162         (bmalloc::VMHeap::allocateLargeChunk):
1163         * bmalloc/VMHeap.h:
1164         (bmalloc::VMHeap::allocateSmallPage):
1165         (bmalloc::VMHeap::allocateMediumPage):
1166         (bmalloc::VMHeap::allocateLargeRange):
1167         (bmalloc::VMHeap::deallocateSmallPage):
1168         (bmalloc::VMHeap::deallocateMediumPage):
1169         (bmalloc::VMHeap::deallocateLargeRange):
1170         (bmalloc::VMHeap::size): Deleted.
1171         (bmalloc::VMHeap::capacity): Deleted.
1172         * bmalloc/bmalloc.h:
1173         (bmalloc::api::heapSize): Deleted.
1174         (bmalloc::api::heapCapacity): Deleted.
1175
1176 2014-09-23  Geoffrey Garen  <ggaren@apple.com>
1177
1178         bmalloc: Allocation should be more precise
1179         https://bugs.webkit.org/show_bug.cgi?id=136993
1180
1181         Reviewed by Gavin Barraclough.
1182
1183         13% reduction in heap size on the MallocBench *_memory_warning benchmarks.
1184
1185         This patch teaches the allocator to merge adjacent free lines into a
1186         single allocatable range. This allows us to shrink the size of an
1187         individual line without increasing fragmentation or the rate of allocator
1188         slow paths.
1189
1190         We'll only take more slow paths when available memory is sparse, which
1191         is exactly when it's worth it. When available memory is dense, we'll
1192         take fewer slow paths.
1193
1194         * bmalloc.xcodeproj/project.pbxproj:
1195         * bmalloc/Algorithm.h:
1196         (bmalloc::divideRoundingUp):
1197
1198         * bmalloc/Allocator.cpp:
1199         (bmalloc::Allocator::Allocator): Updated for interface changes.
1200
1201         (bmalloc::Allocator::scavenge): Scavenge by object instead of by line.
1202         Now that we merge lines, it's not convenient to scavenge by line.
1203
1204         (bmalloc::Allocator::allocateSmallBumpRange):
1205         (bmalloc::Allocator::allocateMediumBumpRange): Allocate whole ranges
1206         instead of individual lines.
1207
1208         (bmalloc::Allocator::allocateSlowCase):
1209         (bmalloc::Allocator::allocateSmallLine): Deleted.
1210         (bmalloc::Allocator::allocateMediumLine): Deleted.
1211         (bmalloc::Allocator::allocateMedium): Deleted.
1212         * bmalloc/Allocator.h:
1213         (bmalloc::Allocator::allocateFastCase): Folded medium allocations
1214         into the standard fast path with small allocations. Since a BumpAllocator
1215         just allocates out of an arbitrary range, it doesn't need to distinguish
1216         between small and medium lines.
1217
1218         * bmalloc/BumpAllocator.h:
1219         (bmalloc::BumpAllocator::size):
1220         (bmalloc::BumpAllocator::BumpAllocator):
1221         (bmalloc::BumpAllocator::init):
1222         (bmalloc::BumpAllocator::refill):
1223         (bmalloc::BumpAllocator::line): Deleted. No need to track line information
1224         anymore: the heap just gives us a pointer and a pre-computed number of
1225         objects, and we allocate them.
1226
1227         * bmalloc/Deallocator.cpp:
1228         (bmalloc::Deallocator::processObjectLog): Updated for interface changes.
1229
1230         * bmalloc/Heap.cpp:
1231         (bmalloc::Heap::Heap):
1232         (bmalloc::Heap::initializeLineMetadata): Pre-compute precise metadata
1233         detailing where all objects will lie in memory. After we merge two lines,
1234         we might allocate an object that spans from one line to the next. This
1235         metadata details which bits of memory overlap in that way, and how they
1236         overlap.
1237
1238         (bmalloc::Heap::refillSmallBumpRangeCache):
1239         (bmalloc::Heap::refillMediumBumpRangeCache): Scan a whole page at a time,
1240         and merge adjacent free lines into BumpRanges.
1241
1242         (bmalloc::Heap::allocateSmallPage):
1243         (bmalloc::Heap::allocateMediumPage):
1244         (bmalloc::Heap::deallocateSmallLine):
1245         (bmalloc::Heap::deallocateMediumLine): Track pages rather than lines,
1246         since we scan for free memory a page at a time.
1247
1248         (bmalloc::Heap::allocateSmallLineSlowCase): Deleted.
1249         (bmalloc::Heap::allocateMediumLineSlowCase): Deleted. Folded into the
1250         fast path.
1251
1252         * bmalloc/Heap.h:
1253         (bmalloc::Heap::derefSmallLine):
1254         (bmalloc::Heap::derefMediumLine):
1255         (bmalloc::Heap::deallocateSmallLine): Deleted.
1256         (bmalloc::Heap::allocateSmallLine): Deleted.
1257         (bmalloc::Heap::deallocateMediumLine): Deleted.
1258         (bmalloc::Heap::allocateMediumLine): Deleted. Updated for interface changes.
1259
1260         * bmalloc/Line.h:
1261         (bmalloc::Line<Traits>::ref):
1262         (bmalloc::Line<Traits>::deref):
1263         (bmalloc::Line<Traits>::concurrentRef): Deleted. We don't pass a derefCount
1264         anymore, since we only ever deref by 1 now.
1265
1266         * bmalloc/MediumAllocator.h:
1267         (bmalloc::MediumAllocator::isNull): Deleted.
1268         (bmalloc::MediumAllocator::MediumAllocator): Deleted.
1269         (bmalloc::MediumAllocator::line): Deleted.
1270         (bmalloc::MediumAllocator::allocate): Deleted.
1271         (bmalloc::MediumAllocator::derefCount): Deleted.
1272         (bmalloc::MediumAllocator::refill): Deleted.
1273         (bmalloc::MediumAllocator::clear): Deleted. Deleted some code that's
1274         been dead for a while, since it doesn't build anymore with this patch.
1275
1276         * bmalloc/Page.h:
1277         (bmalloc::Page::sizeClass):
1278         (bmalloc::Page::setSizeClass):
1279         (bmalloc::Page::smallSizeClass): Deleted.
1280         (bmalloc::Page::setSmallSizeClass): Deleted. Renamed setSmallSizeClass
1281         to sizeClass, since we use it for medium sizes too.
1282
1283         * bmalloc/Sizes.h:
1284         (bmalloc::Sizes::sizeClass):
1285         (bmalloc::Sizes::objectSize): Shrank line sizes to save memory.
1286
1287         (bmalloc::Sizes::smallSizeClassFor): Deleted.
1288         (bmalloc::Sizes::mediumSizeClassFor): Deleted.
1289
1290         * bmalloc/bmalloc.h:
1291         (bmalloc::api::realloc): Now that we have precise objects sizes, realloc
1292         can be a bit more precise. It also has to be, since we can't guarantee
1293         that an object ends at the end of a line anymore.
1294
1295 2014-09-19  Daniel Bates  <dabates@apple.com>
1296
1297         Always assume internal SDK when building configuration Production
1298         https://bugs.webkit.org/show_bug.cgi?id=136925
1299         <rdar://problem/18362399>
1300
1301         Reviewed by Dan Bernstein.
1302
1303         * Configurations/Base.xcconfig:
1304
1305 2014-09-16  Geoffrey Garen  <ggaren@apple.com>
1306
1307         bmalloc: moved line caches from the deallocator to the allocator
1308         https://bugs.webkit.org/show_bug.cgi?id=136868
1309
1310         Reviewed by Gavin Barraclough.
1311
1312         I did this mostly as a simplification, to make it easier to change the
1313         allocation strategy.
1314
1315         No throughput change on MallocBench. Saves about 50kB.
1316
1317         Since the deallocator needs to lock the heap when freeing lines anyway,
1318         there isn't much benefit to giving the deallocator a local cache of
1319         deallocated lines.
1320
1321         We still give the allocator a local cache of lines because that does
1322         reduce the frequency at which it needs to lock the heap in order to
1323         acquire more lines.
1324
1325         * bmalloc/Allocator.cpp:
1326         (bmalloc::Allocator::scavenge):
1327         (bmalloc::Allocator::allocateSmallLine):
1328         (bmalloc::Allocator::allocateMediumLine):
1329         (bmalloc::Allocator::allocateMedium):
1330         (bmalloc::Allocator::allocateSlowCase):
1331         * bmalloc/Allocator.h:
1332         * bmalloc/Deallocator.cpp:
1333         (bmalloc::Deallocator::Deallocator):
1334         (bmalloc::Deallocator::scavenge):
1335         (bmalloc::Deallocator::processObjectLog):
1336         (bmalloc::Deallocator::deallocateSmallLine): Deleted.
1337         (bmalloc::Deallocator::allocateSmallLine): Deleted.
1338         (bmalloc::Deallocator::deallocateMediumLine): Deleted.
1339         (bmalloc::Deallocator::allocateMediumLine): Deleted.
1340         * bmalloc/Deallocator.h:
1341
1342         * bmalloc/Sizes.h:
1343         * bmalloc/VMAllocate.h: Took the opportunity to make the line cache size
1344         exactly one page in size. That's about what we were shooting for anyway,
1345         and it may make it easier to switch to per-page allocation in future.
1346
1347 2014-09-15  Geoffrey Garen  <ggaren@apple.com>
1348
1349         bmalloc: allocate small and medium objects using the same bump pointer class
1350         https://bugs.webkit.org/show_bug.cgi?id=136843
1351
1352         Reviewed by Gavin Barraclough.
1353
1354         4% speedup on MallocBench.
1355
1356         Now that medium-sized objects have dedicated per-size allocators, they
1357         don't need to use an arbitrary bump pointer allocator. This means that
1358         every allocator knows how many objects it will allocate from the start,
1359         and we don't need a post-processing step to adjust refcounts based on
1360         real allocation count.
1361
1362         * bmalloc.xcodeproj/project.pbxproj: Renamed SmallAllocator to BumpAllocator
1363         since it's used for small and medium objects now.
1364
1365         * bmalloc/Allocator.cpp:
1366         (bmalloc::Allocator::Allocator): Updated to use new interface.
1367         (bmalloc::Allocator::scavenge): To "retire" an allocator, we just need
1368         to make sure that we finish allocating all the objects in it.
1369
1370         (bmalloc::Allocator::allocateMedium):
1371         (bmalloc::Allocator::allocateSlowCase):
1372         (bmalloc::Allocator::retire): Deleted.
1373         (bmalloc::Allocator::processSmallAllocatorLog): Deleted.
1374         (bmalloc::Allocator::processMediumAllocatorLog): Deleted.
1375         * bmalloc/Allocator.h:
1376         (bmalloc::Allocator::allocateFastCase): Removed abstractions and data
1377         used to post-process an allocator based on how many objects it allocated.
1378
1379         * bmalloc/BumpAllocator.h: Copied from Source/bmalloc/bmalloc/SmallAllocator.h.
1380         (bmalloc::BumpAllocator::BumpAllocator):
1381         (bmalloc::BumpAllocator::init):
1382         (bmalloc::BumpAllocator::line):
1383         (bmalloc::BumpAllocator::validate):
1384         (bmalloc::BumpAllocator::allocate):
1385         (bmalloc::BumpAllocator::refill):
1386         (bmalloc::BumpAllocator::clear): Updated these functions to be agnostic
1387         about the kinds of lines they allocate into. In some cases, the line
1388         type must be provided as a template parameter by the caller.
1389
1390         (bmalloc::SmallAllocator::SmallAllocator): Deleted.
1391         (bmalloc::SmallAllocator::line): Deleted.
1392         (bmalloc::SmallAllocator::allocate): Deleted.
1393         (bmalloc::SmallAllocator::objectCount): Deleted.
1394         (bmalloc::SmallAllocator::derefCount): Deleted.
1395         (bmalloc::SmallAllocator::refill): Deleted.
1396         (bmalloc::SmallAllocator::clear): Deleted.
1397
1398         * bmalloc/ObjectType.h:
1399         (bmalloc::isMedium):
1400
1401         * bmalloc/SmallAllocator.h:
1402         (bmalloc::SmallAllocator::isNull): Deleted.
1403         (bmalloc::SmallAllocator::canAllocate): Deleted.
1404         (bmalloc::SmallAllocator::SmallAllocator): Deleted.
1405         (bmalloc::SmallAllocator::line): Deleted.
1406         (bmalloc::SmallAllocator::allocate): Deleted.
1407         (bmalloc::SmallAllocator::objectCount): Deleted.
1408         (bmalloc::SmallAllocator::derefCount): Deleted.
1409         (bmalloc::SmallAllocator::refill): Deleted.
1410         (bmalloc::SmallAllocator::clear): Deleted.
1411
1412 2014-09-12  Geoffrey Garen  <ggaren@apple.com>
1413
1414         Fixed a goof in bmalloc Vector sizing
1415         https://bugs.webkit.org/show_bug.cgi?id=136795
1416
1417         Reviewed by Gavin Barraclough and Sam Weinig.
1418
1419         We want our minimum vector to be page-sized since the OS will give us
1420         a page no matter what -- but we want that many bytes, and not enough
1421         bytes to store that many elements.
1422
1423         * bmalloc/Vector.h: Math is hard.
1424
1425 2014-09-11  Geoffrey Garen  <ggaren@apple.com>
1426
1427         bmalloc should segregate medium-sized objects by line like it does for small-sized objects
1428         https://bugs.webkit.org/show_bug.cgi?id=136693
1429
1430         Reviewed by Gavin Barraclough.
1431
1432         4% reduction in heap size on the MallocBench *_memory_warning benchmarks.
1433
1434         No throughput change.
1435
1436         We keep an array of medium allocators, just like our array of small
1437         allocators.
1438
1439         In future, we can simplify the allocation fast path by merging the small
1440         and medium allocator arrays. For now, this is the simplest change that
1441         gets the win.
1442
1443         * bmalloc/Allocator.cpp:
1444         (bmalloc::Allocator::Allocator):
1445         (bmalloc::Allocator::scavenge):
1446         (bmalloc::Allocator::allocateMedium):
1447         * bmalloc/Allocator.h:
1448         * bmalloc/Sizes.h:
1449         (bmalloc::Sizes::mediumSizeClassFor):
1450
1451 2014-09-11  Geoffrey Garen  <ggaren@apple.com>
1452
1453         Reviewed by Sam Weinig.
1454
1455         Renamed log => retire for clarity.
1456
1457         * bmalloc/Allocator.cpp:
1458         (bmalloc::Allocator::scavenge):
1459         (bmalloc::Allocator::retire):
1460         (bmalloc::Allocator::allocateMedium):
1461         (bmalloc::Allocator::allocateSlowCase):
1462         (bmalloc::Allocator::log): Deleted.
1463         * bmalloc/Allocator.h:
1464
1465 2014-09-11  Geoffrey Garen  <ggaren@apple.com>
1466
1467         bmalloc: eager scavenge leaves behind a bogus allocator
1468         https://bugs.webkit.org/show_bug.cgi?id=136743
1469
1470         Reviewed by Sam Weinig.
1471
1472         Be sure to clear the allocator after logging it in the eager scavenge
1473         case, so that we don't later try to allocate out of the lines that we
1474         have thrown away.
1475
1476         We didn't need to do this previously because scavenge would only happen
1477         at thread exit time, after which no further allocation from the per-thread
1478         cache would take place.
1479
1480         * bmalloc/Allocator.cpp:
1481         (bmalloc::Allocator::scavenge):
1482         * bmalloc/MediumAllocator.h:
1483         (bmalloc::MediumAllocator::clear):
1484         * bmalloc/SmallAllocator.h:
1485         (bmalloc::SmallAllocator::clear):
1486
1487 2014-09-05  Geoffrey Garen  <ggaren@apple.com>
1488
1489         bmalloc should honor the FastMalloc statistics API
1490         https://bugs.webkit.org/show_bug.cgi?id=136592
1491
1492         Reviewed by Gavin Barraclough.
1493
1494         We do this by tracking "size" and "capacity" in the VM heap.
1495
1496         The VM heap's "capacity" is all the VM we ever allocated.
1497
1498         The VM heap's "size" the subset of VM currently held onto by the
1499         VM heap (and therefore not in use by the regular heap).
1500
1501         Somewhat ironically, reducing the process's memory footprint, increases
1502         the size of the VM heap, since the VM heap holds the pages that are
1503         purely virtual and not physical.
1504
1505         * bmalloc/Heap.cpp:
1506         (bmalloc::Heap::size):
1507         (bmalloc::Heap::capacity):
1508         * bmalloc/Heap.h:
1509         * bmalloc/VMHeap.cpp:
1510         (bmalloc::VMHeap::VMHeap):
1511         (bmalloc::VMHeap::allocateSmallChunk):
1512         (bmalloc::VMHeap::allocateMediumChunk):
1513         (bmalloc::VMHeap::allocateLargeChunk):
1514         * bmalloc/VMHeap.h:
1515         (bmalloc::VMHeap::size):
1516         (bmalloc::VMHeap::capacity):
1517         (bmalloc::VMHeap::allocateSmallPage):
1518         (bmalloc::VMHeap::allocateMediumPage):
1519         (bmalloc::VMHeap::allocateLargeRange):
1520         (bmalloc::VMHeap::deallocateSmallPage):
1521         (bmalloc::VMHeap::deallocateMediumPage):
1522         (bmalloc::VMHeap::deallocateLargeRange):
1523         * bmalloc/bmalloc.h:
1524         (bmalloc::api::heapSize):
1525         (bmalloc::api::heapCapacity):
1526
1527 2014-09-02  Geoffrey Garen  <ggaren@apple.com>
1528
1529         bmalloc crashes on the EWS bots (due to bad large object allocation)
1530         https://bugs.webkit.org/show_bug.cgi?id=136469
1531
1532         Reviewed by Andreas Kling.
1533
1534         It's possible to convince bmalloc to perform a bad large object allocation,
1535         through these steps:
1536
1537         (1) Insert object A into freelist F0.
1538
1539         (2) Split, merge and split again A's neighbors such that object B is
1540         inserted into freelist F0, with boundary tag and size equal to object A,
1541         but pointer not completely equal to object A. Put object B at the head of F0.
1542
1543         (3) Allocate some other object from F0, swapping its position in the
1544         freelist with object B, such that object A is now ahead of object B.
1545
1546         --> Now, the next allocation for size A/B will allocate object A, which
1547         has a slightly wrong idea about where the object actually begins.
1548         Immediately, you'll corrupt a little memory, and over time, you'll also
1549         corrupt boundary tag metadata.
1550
1551         The solution is to store the begin pointer in the boundary tag. Luckily,
1552         this doesn't make the tag any bigger, and it's not a noticeable slowdown
1553         on MallocBench.
1554
1555         * bmalloc/Algorithm.h:
1556         (bmalloc::rightShift):
1557         * bmalloc/BeginTag.h:
1558         (bmalloc::BeginTag::isInFreeList): This is the bug fix. Make sure to
1559         validate the start pointer when popping off the free list. Through a
1560         very uncommon set of steps, it is possible to have an item in the free
1561         list that is valid by all accounts except for its start pointer.
1562
1563         * bmalloc/BoundaryTag.h:
1564         (bmalloc::BoundaryTag::compactBegin):
1565         (bmalloc::BoundaryTag::setRange):
1566         (bmalloc::BoundaryTag::setSize): Deleted. Record a compact version of the
1567         start pointer. We don't need the whole pointer -- just the offset, in
1568         largeAlignment increments, into the relevant boundary tag bucket.
1569
1570         * bmalloc/BoundaryTagInlines.h:
1571         (bmalloc::validateNext):
1572         (bmalloc::BoundaryTag::init):
1573         (bmalloc::BoundaryTag::mergeLarge):
1574         (bmalloc::BoundaryTag::splitLarge):
1575         * bmalloc/SegregatedFreeList.cpp:
1576         (bmalloc::SegregatedFreeList::insert):
1577         (bmalloc::SegregatedFreeList::takeGreedy):
1578         (bmalloc::SegregatedFreeList::take): Provide the whole range instead of
1579         the size when establishing a boundary tag, as required by the new
1580         interface.
1581
1582         * bmalloc/Sizes.h:
1583
1584 2014-08-14  Geoffrey Garen  <ggaren@apple.com>
1585
1586         Fixed a bmalloc crash seen on the EWS bot
1587         https://bugs.webkit.org/show_bug.cgi?id=135955
1588
1589         Reviewed by Andreas Kling.
1590
1591         * bmalloc/Syscall.h: Some CG APIs vm_copy their input buffers. If the
1592         input buffer is a malloc region, that region will get marked Copy-On-Write
1593         by the kernel. Calls to madvise() for COW regions fail and return EINVAL
1594         on older OS X's. In 10.10, they still fail, but they do not return
1595         EINVAL.
1596
1597         So, we can only ASSERT that our syscalls succeed starting with 10.10.
1598
1599 2014-08-14  Geoffrey Garen  <ggaren@apple.com>
1600
1601         Fixed the bmalloc build
1602         https://bugs.webkit.org/show_bug.cgi?id=135953
1603
1604         Reviewed by Andreas Kling.
1605
1606         * bmalloc.xcodeproj/project.pbxproj: Marked a few headers as private.
1607         These headers are used, so they must be available outside the project.
1608
1609 2014-08-13  Daniel Bates  <dabates@apple.com>
1610
1611         Attempt to fix the build following <http://trac.webkit.org/changeset/172576>
1612         (https://bugs.webkit.org/show_bug.cgi?id=135895)
1613
1614         Substitute PerThreadStorage<T>::initSharedKeyIfNeeded() for initSharedKeyIfNeeded() in
1615         implementation of PerThread<T>::getFastCase().
1616
1617         * bmalloc/PerThread.h:
1618         (bmalloc::PerThread<T>::getFastCase):
1619
1620 2014-08-13  Daniel Bates  <dabates@apple.com>
1621
1622         Make bmalloc::PerThread work without C++ thread local storage
1623         https://bugs.webkit.org/show_bug.cgi?id=135895
1624
1625         Reviewed by Geoffrey Garen.
1626
1627         Implement support for building bmalloc without C++ thread local storage.
1628
1629         * bmalloc/BPlatform.h: Remove macro define BPLATFORM_IOS_SIMULATOR. Added macro function
1630         BCOMPILER_SUPPORTS() and macro define BCOMPILER_SUPPORTS_CXX_THREAD_LOCAL that can be used
1631         to determine whether the compiler supports C++ thread local storage.
1632         * bmalloc/PerThread.h:
1633         (bmalloc::PerThreadStorage::get): Modified to call pthread_getspecific() when building
1634         without C++ thread local storage.
1635         (bmalloc::PerThreadStorage::initSharedKeyIfNeeded): Added.
1636         (bmalloc::PerThreadStorage::init): Moved logic to initialize shared Pthread key from here to
1637         PerThreadStorage::initSharedKeyIfNeeded().
1638         (bmalloc::PerThread<T>::getFastCase): Modified to call PerThreadStorage::initSharedKeyIfNeeded()
1639         before querying PerThreadStorage::get() when building without C++ thread local storage so as to
1640         ensure that the shared key has been initialized.
1641         (_pthread_setspecific_direct): Deleted.
1642         (_pthread_getspecific_direct): Deleted.
1643
1644 2014-08-13  Daniel Bates  <dabates@apple.com>
1645
1646         [iOS] Make JavaScriptCore and bmalloc build with the public SDK
1647         https://bugs.webkit.org/show_bug.cgi?id=135848
1648
1649         Reviewed by Geoffrey Garen.
1650
1651         * bmalloc/BPlatform.h: Added macro BPLATFORM_IOS_SIMULATOR, which evaluates to true
1652         when building for the iOS Simulator.
1653         * bmalloc/PerThread.h: Use pthread_machdep.h code path when building for iOS Simulator
1654         using the public SDK.
1655         (_pthread_setspecific_direct): Added; only defined when building for the iOS Simulator
1656         using the public SDK.
1657         (_pthread_getspecific_direct): Added; only defined when building for the iOS Simulator
1658         using the public SDK.
1659
1660 2014-08-12  Daniel Bates  <dabates@apple.com>
1661
1662         BPLATFORM(IOS) always evaluates to false
1663         https://bugs.webkit.org/show_bug.cgi?id=135843
1664
1665         Reviewed by Geoffrey Garen.
1666
1667         Fix typo in definition of BPLATFORM() and include system header TargetConditionals.h
1668         (when building on an Apple platform) so that BPLATFORM(X) evaluates to true when
1669         building for platform X. In particular, so that BPLATFORM(IOS) evaluates to true when
1670         building for iOS.
1671
1672         As a side effect of this change, the change made in <http://trac.webkit.org/changeset/167289>
1673         will be honored and iOS will assume a VM page size of 16kB (again) instead of 4kB.
1674
1675         * bmalloc/BPlatform.h:
1676
1677 2014-08-11  Andy Estes  <aestes@apple.com>
1678
1679         [iOS] Get rid of iOS.xcconfig
1680         https://bugs.webkit.org/show_bug.cgi?id=135809
1681
1682         Reviewed by Joseph Pecoraro.
1683
1684         All iOS.xcconfig did was include AspenFamily.xcconfig, so there's no need for the indirection.
1685
1686         * Configurations/Base.xcconfig:
1687         * Configurations/iOS.xcconfig: Removed.
1688         * bmalloc.xcodeproj/project.pbxproj:
1689
1690 2014-05-01  Dan Bernstein  <mitz@apple.com>
1691
1692         Fixed production builds for the iOS Simulator.
1693         <rdar://problem/16792221>
1694
1695         * Configurations/bmalloc.xcconfig: Include INSTALL_PATH_PREFIX in
1696         PRIVATE_HEADERS_FOLDER_PATH when installing.
1697
1698 2014-04-20  Geoffrey Garen  <ggaren@apple.com>
1699
1700         bmalloc: Segregate pages by objects size
1701         https://bugs.webkit.org/show_bug.cgi?id=131909
1702
1703         Reviewed by Andreas Kling.
1704
1705         2% reduction in memory-at-end on the Membuster memory_warning benchmarks.
1706
1707         * bmalloc/Allocator.cpp:
1708         (bmalloc::Allocator::allocateSlowCase):
1709         * bmalloc/Allocator.h:
1710         (bmalloc::Allocator::allocateFastCase):
1711         (bmalloc::Allocator::smallAllocatorFor): Use the new shared helper
1712         function for size class calculation.
1713
1714         * bmalloc/Deallocator.cpp:
1715         (bmalloc::Deallocator::Deallocator):
1716         (bmalloc::Deallocator::scavenge):
1717         (bmalloc::Deallocator::deallocateSmallLine):
1718         (bmalloc::Deallocator::allocateSmallLine):
1719         * bmalloc/Deallocator.h: Keep a cache for every size class, since the
1720         cache can't be shared anymore.
1721
1722         * bmalloc/Heap.cpp:
1723         (bmalloc::Heap::allocateSmallLineSlowCase):
1724         * bmalloc/Heap.h:
1725         (bmalloc::Heap::deallocateSmallLine): Ditto.
1726
1727         (bmalloc::Heap::allocateSmallLine): Check size class in addition to
1728         page refcount when allocating a line because we might have deallocated
1729         the page and the recycled it for another size class.
1730
1731         (bmalloc::Heap::deallocateMediumLine):
1732         (bmalloc::Heap::allocateMediumLine):
1733         * bmalloc/Line.h:
1734         (bmalloc::Line::refCount):
1735         * bmalloc/Page.h:
1736         (bmalloc::Page::refCount):
1737         (bmalloc::Page::smallSizeClass):
1738         (bmalloc::Page::setSmallSizeClass):
1739         (bmalloc::Page<Traits>::refCount): Deleted.
1740         * bmalloc/Sizes.h:
1741         (bmalloc::Sizes::smallSizeClassFor): New shared API for computing
1742         an index into an array from a size.
1743
1744 2014-04-19  Geoffrey Garen  <ggaren@apple.com>
1745
1746         bmalloc: Improved alignment in LargeChunk
1747         https://bugs.webkit.org/show_bug.cgi?id=131895
1748
1749         Reviewed by Andreas Kling.
1750
1751         * bmalloc/Chunk.h:
1752         * bmalloc/LargeChunk.h: Align to vmPageSize just like Chunk does.
1753         Technically, the previous alignment was harmless, but I would prefer,
1754         dear reader, not to have to explain the interlocking set of
1755         circumstances that made it so.
1756
1757 2014-04-19  Geoffrey Garen  <ggaren@apple.com>
1758
1759         Rolled out r167502 because it caused a crash on the facebook benchmark.
1760
1761         Unreviewed.
1762
1763             bmalloc: Added an XSmall line size
1764             https://bugs.webkit.org/show_bug.cgi?id=131851
1765
1766             Reviewed by Sam Weinig.
1767
1768 2014-04-19  Geoffrey Garen  <ggaren@apple.com>
1769
1770         bmalloc: Mutex should be harder to use wrong
1771         https://bugs.webkit.org/show_bug.cgi?id=131879
1772
1773         Reviewed by Andreas Kling.
1774
1775         Mutex now has a proper constructor, so you can't deadlock by forgetting
1776         to initialize it.
1777
1778         * bmalloc.xcodeproj/project.pbxproj:
1779         * bmalloc/Allocator.cpp:
1780         (bmalloc::Allocator::processXSmallAllocatorLog):
1781         (bmalloc::Allocator::processSmallAllocatorLog):
1782         (bmalloc::Allocator::processMediumAllocatorLog):
1783         (bmalloc::Allocator::allocateLarge):
1784         (bmalloc::Allocator::allocateXLarge): Global replace Mutex => StaticMutex,
1785         since the Heap mutex is a static.
1786
1787         * bmalloc/AsyncTask.h:
1788         (bmalloc::Function>::AsyncTask): Use Mutex, since we're not static. No
1789         need for explicit initialization anymore.
1790
1791         * bmalloc/Deallocator.cpp:
1792         (bmalloc::Deallocator::scavenge):
1793         (bmalloc::Deallocator::deallocateLarge):
1794         (bmalloc::Deallocator::deallocateXLarge):
1795         (bmalloc::Deallocator::processObjectLog):
1796         (bmalloc::Deallocator::deallocateSmallLine):
1797         (bmalloc::Deallocator::deallocateXSmallLine):
1798         (bmalloc::Deallocator::allocateSmallLine):
1799         (bmalloc::Deallocator::allocateXSmallLine):
1800         (bmalloc::Deallocator::deallocateMediumLine):
1801         (bmalloc::Deallocator::allocateMediumLine):
1802         * bmalloc/Deallocator.h:
1803         * bmalloc/Heap.cpp:
1804         (bmalloc::sleep):
1805         (bmalloc::Heap::Heap):
1806         (bmalloc::Heap::concurrentScavenge):
1807         (bmalloc::Heap::scavenge):
1808         (bmalloc::Heap::scavengeSmallPages):
1809         (bmalloc::Heap::scavengeXSmallPages):
1810         (bmalloc::Heap::scavengeMediumPages):
1811         (bmalloc::Heap::scavengeLargeRanges):
1812         (bmalloc::Heap::allocateXSmallLineSlowCase):
1813         (bmalloc::Heap::allocateSmallLineSlowCase):
1814         (bmalloc::Heap::allocateMediumLineSlowCase):
1815         (bmalloc::Heap::allocateXLarge):
1816         (bmalloc::Heap::deallocateXLarge):
1817         (bmalloc::Heap::allocateLarge):
1818         (bmalloc::Heap::deallocateLarge):
1819         * bmalloc/Heap.h:
1820         (bmalloc::Heap::deallocateXSmallLine):
1821         (bmalloc::Heap::allocateXSmallLine):
1822         (bmalloc::Heap::deallocateSmallLine):
1823         (bmalloc::Heap::allocateSmallLine):
1824         (bmalloc::Heap::deallocateMediumLine):
1825         (bmalloc::Heap::allocateMediumLine):
1826         * bmalloc/Line.h:
1827         (bmalloc::Line<Traits>::deref):
1828         * bmalloc/Mutex.cpp: Removed.
1829         * bmalloc/Mutex.h:
1830         (bmalloc::Mutex::Mutex):
1831         (bmalloc::Mutex::init): Deleted.
1832         (bmalloc::Mutex::try_lock): Deleted.
1833         (bmalloc::Mutex::lock): Deleted.
1834         (bmalloc::Mutex::unlock): Deleted.
1835         * bmalloc/Page.h:
1836         (bmalloc::Page<Traits>::ref):
1837         (bmalloc::Page<Traits>::deref):
1838         (bmalloc::Page<Traits>::refCount):
1839         * bmalloc/PerProcess.h:
1840         (bmalloc::PerProcess::mutex):
1841         (bmalloc::PerProcess<T>::getSlowCase):
1842         * bmalloc/StaticMutex.cpp: Added.
1843         (bmalloc::StaticMutex::lockSlowCase):
1844         * bmalloc/StaticMutex.h: Added.
1845         (bmalloc::StaticMutex::init):
1846         (bmalloc::StaticMutex::try_lock):
1847         (bmalloc::StaticMutex::lock):
1848         (bmalloc::StaticMutex::unlock):
1849         * bmalloc/VMHeap.h:
1850         (bmalloc::VMHeap::deallocateXSmallPage):
1851         (bmalloc::VMHeap::deallocateSmallPage):
1852         (bmalloc::VMHeap::deallocateMediumPage):
1853         (bmalloc::VMHeap::deallocateLargeRange):
1854         * bmalloc/bmalloc.h:
1855         (bmalloc::api::scavenge): Global replace Mutex => StaticMutex,
1856         since the Heap mutex is a static.
1857
1858 2014-04-18  Geoffrey Garen  <ggaren@apple.com>
1859
1860         bmalloc: AsyncTask should use Mutex instead of std::mutex
1861         https://bugs.webkit.org/show_bug.cgi?id=131865
1862
1863         Reviewed by Gavin Barraclough.
1864
1865         std::mutex is so slow that it makes parallelizing simple tasks through
1866         AsyncTask a net regression. Mutex fixes this.
1867
1868         * bmalloc/AsyncTask.h:
1869         (bmalloc::Function>::AsyncTask):
1870         (bmalloc::Function>::join):
1871         (bmalloc::Function>::runSlowCase):
1872         (bmalloc::Function>::entryPoint):
1873         * bmalloc/Mutex.h:
1874         (bmalloc::Mutex::init):
1875
1876 2014-04-18  Geoffrey Garen  <ggaren@apple.com>
1877
1878         bmalloc: Added an XSmall line size
1879         https://bugs.webkit.org/show_bug.cgi?id=131851
1880
1881         Reviewed by Sam Weinig.
1882
1883         Reduces malloc footprint on Membuster recordings by 10%.
1884
1885         This is a throughput regression, but we're still way ahead of TCMalloc.
1886         I have some ideas for how to recover the regression -- but I wanted to
1887         get this win in first.
1888
1889         Full set of benchmark results:
1890
1891                 bmalloc> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks --measure-heap nopatch:~/scratch/Build-nopatch/Release/ patch:~/webkit/WebKitBuild/Release/
1892                                                                                                 
1893                                                                nopatch                      patch                                Δ
1894                 Peak Memory:
1895                     reddit_memory_warning                      7,896kB                    7,532kB                  ^ 1.05x smaller
1896                     flickr_memory_warning                     12,968kB                   12,324kB                  ^ 1.05x smaller
1897                     theverge_memory_warning                   16,672kB                   15,200kB                   ^ 1.1x smaller
1898
1899                     <geometric mean>                          11,952kB                   11,216kB                  ^ 1.07x smaller
1900                     <arithmetic mean>                         12,512kB                   11,685kB                  ^ 1.07x smaller
1901                     <harmonic mean>                           11,375kB                   10,726kB                  ^ 1.06x smaller
1902
1903                 Memory at End:
1904                     reddit_memory_warning                      7,320kB                    6,856kB                  ^ 1.07x smaller
1905                     flickr_memory_warning                     10,848kB                    9,692kB                  ^ 1.12x smaller
1906                     theverge_memory_warning                   16,380kB                   14,872kB                   ^ 1.1x smaller
1907
1908                     <geometric mean>                          10,916kB                    9,961kB                   ^ 1.1x smaller
1909                     <arithmetic mean>                         11,516kB                   10,473kB                   ^ 1.1x smaller
1910                     <harmonic mean>                           10,350kB                    9,485kB                  ^ 1.09x smaller
1911
1912                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks nopatch:~/scratch/Build-nopatch/Release/ patch:~/webkit/WebKitBuild/Release/
1913                                                                                                 
1914                                                    nopatch                patch                         Δ
1915                 Execution Time:
1916                     churn                            127ms                151ms            ! 1.19x slower
1917                     list_allocate                    130ms                164ms            ! 1.26x slower
1918                     tree_allocate                    109ms                127ms            ! 1.17x slower
1919                     tree_churn                       115ms                120ms            ! 1.04x slower
1920                     facebook                         240ms                259ms            ! 1.08x slower
1921                     fragment                          91ms                131ms            ! 1.44x slower
1922                     fragment_iterate                 105ms                106ms            ! 1.01x slower
1923                     message_one                      260ms                259ms             ^ 1.0x faster
1924                     message_many                     149ms                154ms            ! 1.03x slower
1925                     medium                           194ms                248ms            ! 1.28x slower
1926                     big                              157ms                160ms            ! 1.02x slower
1927
1928                     <geometric mean>                 144ms                163ms            ! 1.13x slower
1929                     <arithmetic mean>                152ms                171ms            ! 1.12x slower
1930                     <harmonic mean>                  137ms                156ms            ! 1.14x slower
1931
1932                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks nopatch:~/scratch/Build-nopatch/Release/ patch:~/webkit/WebKitBuild/Release/
1933                                                                                                 
1934                                                                        nopatch                          patch                                     Δ
1935                 Execution Time:
1936                     churn                                                126ms                          148ms                        ! 1.17x slower
1937                     churn --parallel                                      62ms                           76ms                        ! 1.23x slower
1938                     list_allocate                                        130ms                          164ms                        ! 1.26x slower
1939                     list_allocate --parallel                             120ms                          175ms                        ! 1.46x slower
1940                     tree_allocate                                        111ms                          127ms                        ! 1.14x slower
1941                     tree_allocate --parallel                              95ms                          135ms                        ! 1.42x slower
1942                     tree_churn                                           115ms                          124ms                        ! 1.08x slower
1943                     tree_churn --parallel                                107ms                          126ms                        ! 1.18x slower
1944                     facebook                                             240ms                          276ms                        ! 1.15x slower
1945                     facebook --parallel                                  802ms                        1,088ms                        ! 1.36x slower
1946                     fragment                                              92ms                          130ms                        ! 1.41x slower
1947                     fragment --parallel                                   66ms                          124ms                        ! 1.88x slower
1948                     fragment_iterate                                     109ms                          127ms                        ! 1.17x slower
1949                     fragment_iterate --parallel                           55ms                           64ms                        ! 1.16x slower
1950                     message_one                                          260ms                          260ms                                      
1951                     message_many                                         170ms                          238ms                         ! 1.4x slower
1952                     medium                                               185ms                          250ms                        ! 1.35x slower
1953                     medium --parallel                                    210ms                          334ms                        ! 1.59x slower
1954                     big                                                  150ms                          169ms                        ! 1.13x slower
1955                     big --parallel                                       138ms                          144ms                        ! 1.04x slower
1956
1957                     <geometric mean>                                     135ms                          170ms                        ! 1.26x slower
1958                     <arithmetic mean>                                    167ms                          214ms                        ! 1.28x slower
1959                     <harmonic mean>                                      117ms                          148ms                        ! 1.26x slower
1960
1961                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks TC:~/scratch/Build-TCMalloc/Release/ patch:~/webkit/WebKitBuild/Release/
1962
1963                                                                     TC                      patch                                Δ
1964                 Peak Memory:
1965                     reddit_memory_warning                     13,836kB                   13,436kB                  ^ 1.03x smaller
1966                     flickr_memory_warning                     24,868kB                   25,188kB                   ! 1.01x bigger
1967                     theverge_memory_warning                   24,504kB                   26,636kB                   ! 1.09x bigger
1968
1969                     <geometric mean>                          20,353kB                   20,812kB                   ! 1.02x bigger
1970                     <arithmetic mean>                         21,069kB                   21,753kB                   ! 1.03x bigger
1971                     <harmonic mean>                           19,570kB                   19,780kB                   ! 1.01x bigger
1972
1973                 Memory at End:
1974                     reddit_memory_warning                      8,656kB                   10,016kB                   ! 1.16x bigger
1975                     flickr_memory_warning                     11,844kB                   13,784kB                   ! 1.16x bigger
1976                     theverge_memory_warning                   18,516kB                   22,748kB                   ! 1.23x bigger
1977
1978                     <geometric mean>                          12,382kB                   14,644kB                   ! 1.18x bigger
1979                     <arithmetic mean>                         13,005kB                   15,516kB                   ! 1.19x bigger
1980                     <harmonic mean>                           11,813kB                   13,867kB                   ! 1.17x bigger
1981
1982                 MallocBench> ~/webkit/PerformanceTests/MallocBench/run-malloc-benchmarks TC:~/scratch/Build-TCMalloc/Release/ patch:~/webkit/WebKitBuild/Release/
1983                                                                                                 
1984                                                         TC                patch                         Δ
1985                 Execution Time:
1986                     churn                            416ms                148ms            ^ 2.81x faster
1987                     list_allocate                    463ms                164ms            ^ 2.82x faster
1988                     tree_allocate                    292ms                127ms             ^ 2.3x faster
1989                     tree_churn                       157ms                120ms            ^ 1.31x faster
1990                     facebook                         327ms                276ms            ^ 1.18x faster
1991                     fragment                         335ms                129ms             ^ 2.6x faster
1992                     fragment_iterate                 344ms                108ms            ^ 3.19x faster
1993                     message_one                      386ms                258ms             ^ 1.5x faster
1994                     message_many                     410ms                154ms            ^ 2.66x faster
1995                     medium                           391ms                245ms             ^ 1.6x faster
1996                     big                              261ms                167ms            ^ 1.56x faster
1997
1998                     <geometric mean>                 332ms                164ms            ^ 2.02x faster
1999                     <arithmetic mean>                344ms                172ms            ^ 1.99x faster
2000                     <harmonic mean>                  317ms                157ms            ^ 2.02x faster
2001
2002         * bmalloc.xcodeproj/project.pbxproj:
2003         * bmalloc/Allocator.cpp:
2004         (bmalloc::Allocator::Allocator): Don't assume that each allocator's
2005         index corresponds with its size. Instead, use the size selection function
2006         explicitly. Now that we have XSmall, some small allocator entries are
2007         unused.
2008
2009         (bmalloc::Allocator::scavenge):
2010         (bmalloc::Allocator::log):
2011         (bmalloc::Allocator::processXSmallAllocatorLog):
2012         (bmalloc::Allocator::allocateSlowCase):
2013         * bmalloc/Allocator.h:
2014         (bmalloc::Allocator::xSmallAllocatorFor):
2015         (bmalloc::Allocator::allocateFastCase):
2016         * bmalloc/Chunk.h:
2017         * bmalloc/Deallocator.cpp:
2018         (bmalloc::Deallocator::scavenge):
2019         (bmalloc::Deallocator::processObjectLog):
2020         (bmalloc::Deallocator::deallocateSlowCase):
2021         (bmalloc::Deallocator::deallocateXSmallLine):
2022         (bmalloc::Deallocator::allocateXSmallLine):
2023         * bmalloc/Deallocator.h:
2024         (bmalloc::Deallocator::deallocateFastCase):
2025         * bmalloc/Heap.cpp:
2026         (bmalloc::Heap::scavenge):
2027         (bmalloc::Heap::scavengeXSmallPages):
2028         (bmalloc::Heap::allocateXSmallLineSlowCase):
2029         * bmalloc/Heap.h:
2030         (bmalloc::Heap::deallocateXSmallLine):
2031         (bmalloc::Heap::allocateXSmallLine):
2032         * bmalloc/LargeChunk.h:
2033         (bmalloc::LargeChunk::get):
2034         (bmalloc::LargeChunk::endTag):
2035         * bmalloc/Line.h:
2036         * bmalloc/MediumAllocator.h:
2037         (bmalloc::MediumAllocator::allocate):
2038         (bmalloc::MediumAllocator::refill):
2039         * bmalloc/ObjectType.cpp:
2040         (bmalloc::objectType):
2041         * bmalloc/ObjectType.h:
2042         (bmalloc::isXSmall):
2043         (bmalloc::isSmall):
2044         (bmalloc::isMedium):
2045         (bmalloc::isLarge):
2046         (bmalloc::isSmallOrMedium): Deleted.
2047         * bmalloc/SegregatedFreeList.h: I boiler-plate copied existing code for
2048         handling small objects. There's probably a reasonable way to share this
2049         code in the future -- I'll look into that once it's stopped changing.
2050
2051         * bmalloc/Sizes.h: Tweaked size classes to make Membuster happy. This
2052         is the main reason things got slower.
2053
2054         * bmalloc/SmallAllocator.h:
2055         (bmalloc::SmallAllocator::allocate):
2056         * bmalloc/SmallTraits.h:
2057         * bmalloc/VMHeap.cpp:
2058         (bmalloc::VMHeap::allocateXSmallChunk):
2059         * bmalloc/VMHeap.h:
2060         (bmalloc::VMHeap::allocateXSmallPage):
2061         (bmalloc::VMHeap::deallocateXSmallPage):
2062         * bmalloc/XSmallAllocator.h: Added.
2063         (bmalloc::XSmallAllocator::isNull):
2064         (bmalloc::XSmallAllocator::canAllocate):
2065         (bmalloc::XSmallAllocator::XSmallAllocator):
2066         (bmalloc::XSmallAllocator::line):
2067         (bmalloc::XSmallAllocator::allocate):
2068         (bmalloc::XSmallAllocator::objectCount):
2069         (bmalloc::XSmallAllocator::derefCount):
2070         (bmalloc::XSmallAllocator::refill):
2071         * bmalloc/XSmallChunk.h: Added.
2072         * bmalloc/XSmallLine.h: Added.
2073         * bmalloc/XSmallPage.h: Added.
2074         * bmalloc/XSmallTraits.h: Added.
2075         * bmalloc/bmalloc.h:
2076         (bmalloc::api::realloc): Boiler-plate copy, as above.
2077
2078 2014-04-14  Geoffrey Garen  <ggaren@apple.com>
2079
2080         MallocBench should scavenge explicitly instead of waiting
2081         https://bugs.webkit.org/show_bug.cgi?id=131661
2082
2083         Reviewed by Andreas Kling.
2084
2085         Added explicit scavenge support to bmalloc. This isn't a memory win,
2086         since bmalloc's per-thread cache is so small. But it makes testing
2087         simpler.
2088
2089         * bmalloc/Allocator.cpp:
2090         (bmalloc::Allocator::~Allocator):
2091         (bmalloc::Allocator::scavenge):
2092         * bmalloc/Allocator.h:
2093         * bmalloc/Cache.cpp:
2094         (bmalloc::Cache::operator new):
2095         (bmalloc::Cache::operator delete):
2096         (bmalloc::Cache::Cache):
2097         (bmalloc::Cache::scavenge):
2098         * bmalloc/Cache.h:
2099         * bmalloc/Deallocator.cpp:
2100         (bmalloc::Deallocator::~Deallocator):
2101         (bmalloc::Deallocator::scavenge):
2102         * bmalloc/Deallocator.h: Factored existing scavenging code into helper
2103         functions, for reuse.
2104
2105         * bmalloc/Heap.cpp:
2106         (bmalloc::sleep):
2107         (bmalloc::Heap::concurrentScavenge):
2108         (bmalloc::Heap::scavenge):
2109         (bmalloc::Heap::scavengeSmallPages):
2110         (bmalloc::Heap::scavengeMediumPages):
2111         (bmalloc::Heap::scavengeLargeRanges):
2112         * bmalloc/Heap.h: Made scavenge sleep duration a parameter. Forced
2113         scavenging -- in response to a benchmark or a low memory warning --
2114         wants to complete as soon as possible, so its sleep duration is 0.
2115
2116         * bmalloc/bmalloc.h:
2117         (bmalloc::api::scavenge):
2118         * bmalloc/mbmalloc.cpp: Exported the scavenge API for MallocBench's use.
2119
2120 2014-04-14  Geoffrey Garen  <ggaren@apple.com>
2121
2122         Use 4kB pages on Mac
2123         https://bugs.webkit.org/show_bug.cgi?id=131658
2124
2125         Reviewed by Sam Weinig.
2126
2127         This reduces memory use a lot on Membuster:
2128
2129                                                                   base                      patch                                Δ
2130                 Execution Time:
2131                     reddit_memory_warning                         18ms                       17ms                   ^ 1.06x faster
2132                     flickr_memory_warning                         34ms                       36ms                   ! 1.06x slower
2133                     theverge_memory_warning                       39ms                       41ms                   ! 1.05x slower
2134
2135                     <geometric mean>                              29ms                       29ms                   ! 1.02x slower
2136                     <arithmetic mean>                             30ms                       31ms                   ! 1.03x slower
2137                     <harmonic mean>                               27ms                       27ms                    ^ 1.0x faster
2138
2139                 Peak Memory:
2140                     reddit_memory_warning                     16,412kB                   16,436kB                    ! 1.0x bigger
2141                     flickr_memory_warning                     30,120kB                   30,184kB                    ! 1.0x bigger
2142                     theverge_memory_warning                   33,408kB                   33,420kB                    ! 1.0x bigger
2143
2144                     <geometric mean>                          25,466kB                   25,499kB                    ! 1.0x bigger
2145                     <arithmetic mean>                         26,647kB                   26,680kB                    ! 1.0x bigger
2146                     <harmonic mean>                           24,181kB                   24,214kB                    ! 1.0x bigger
2147
2148                 Memory at End:
2149                     reddit_memory_warning                      2,404kB                    1,920kB                  ^ 1.25x smaller
2150                     flickr_memory_warning                      3,764kB                    3,072kB                  ^ 1.23x smaller
2151                     theverge_memory_warning                    3,648kB                    3,132kB                  ^ 1.16x smaller
2152
2153                     <geometric mean>                           3,208kB                    2,644kB                  ^ 1.21x smaller
2154                     <arithmetic mean>                          3,272kB                    2,708kB                  ^ 1.21x smaller
2155                     <harmonic mean>                            3,139kB                    2,574kB                  ^ 1.22x smaller
2156
2157
2158         * bmalloc.xcodeproj/project.pbxproj:
2159         * bmalloc/BPlatform.h: Added.
2160         * bmalloc/VMAllocate.h: Only use 16kB pages on iOS because the page size
2161         is 4kB on Mac.
2162
2163 2014-04-14  Alexey Proskuryakov  <ap@apple.com>
2164
2165         Fixed svn:ignore on bmalloc.xcodeproj, it had erroneous leading spaces.
2166
2167         * bmalloc.xcodeproj: Modified property svn:ignore.
2168
2169 2014-04-13  Geoffrey Garen  <ggaren@apple.com>
2170
2171         Fixed some mbmalloc exports
2172         https://bugs.webkit.org/show_bug.cgi?id=131599
2173
2174         Reviewed by Ryosuke Niwa.
2175
2176         * bmalloc.xcodeproj/project.pbxproj: Made some headers a private part
2177         of the project, so we can call them from API.
2178
2179         * bmalloc/mbmalloc.cpp: Marked the mbmalloc functions with default
2180         visibility, so they show up as exported in the .dylib.
2181
2182 2014-04-09  Geoffrey Garen  <ggaren@apple.com>
2183
2184         Put bmalloc headers in the right place
2185         https://bugs.webkit.org/show_bug.cgi?id=131464
2186
2187         Reviewed by Mark Rowe.
2188
2189         * Configurations/bmalloc.xcconfig: Set PRIVATE_HEADERS_FOLDER_PATH to
2190         specify that we don't just want to dump all of our generically-named
2191         headers into /usr/local/include.
2192
2193 2014-04-08  Geoffrey Garen  <ggaren@apple.com>
2194
2195         Made bmalloc more #include friendly
2196         https://bugs.webkit.org/show_bug.cgi?id=131386
2197
2198         Reviewed by Andreas Kling.
2199
2200         Marked a bunch of headers private so they can be used from client code
2201         that #includes bmalloc.h.
2202
2203         Renamed ASSERT macros to BASSERT. This matches their header, which already
2204         had to be renamed, and fixes conflicts with WTF's ASSERT macros.
2205
2206         * bmalloc.xcodeproj/project.pbxproj:
2207         * bmalloc/Allocator.cpp:
2208         (bmalloc::Allocator::allocateSlowCase):
2209         * bmalloc/AsyncTask.h:
2210         (bmalloc::Function>::runSlowCase):
2211         * bmalloc/BAssert.h:
2212         * bmalloc/BoundaryTag.h:
2213         (bmalloc::BoundaryTag::setSize):
2214         * bmalloc/BoundaryTagInlines.h:
2215         (bmalloc::validate):
2216         (bmalloc::BoundaryTag::init):
2217         (bmalloc::BoundaryTag::deallocate):
2218         (bmalloc::BoundaryTag::splitLarge):
2219         (bmalloc::BoundaryTag::allocate):
2220         * bmalloc/Chunk.h:
2221         * bmalloc/Deallocator.cpp:
2222         (bmalloc::Deallocator::processObjectLog):
2223         (bmalloc::Deallocator::deallocateSlowCase):
2224         * bmalloc/Deallocator.h:
2225         (bmalloc::Deallocator::deallocateFastCase):
2226         * bmalloc/FixedVector.h:
2227         (bmalloc::Capacity>::operator):
2228         (bmalloc::Capacity>::push):
2229         (bmalloc::Capacity>::pop):
2230         (bmalloc::Capacity>::shrink):
2231         * bmalloc/Heap.cpp:
2232         (bmalloc::Heap::allocateLarge):
2233         * bmalloc/LargeChunk.h:
2234         (bmalloc::LargeChunk::get):
2235         (bmalloc::LargeChunk::endTag):
2236         * bmalloc/Line.h:
2237         (bmalloc::Line<Traits>::concurrentRef):
2238         (bmalloc::Line<Traits>::deref):
2239         * bmalloc/MediumAllocator.h:
2240         (bmalloc::MediumAllocator::allocate):
2241         * bmalloc/ObjectType.h:
2242         (bmalloc::isSmall):
2243         * bmalloc/Page.h:
2244         (bmalloc::Page<Traits>::ref):
2245         (bmalloc::Page<Traits>::deref):
2246         * bmalloc/PerThread.h:
2247         (bmalloc::PerThread<T>::getSlowCase):
2248         * bmalloc/SegregatedFreeList.cpp:
2249         (bmalloc::SegregatedFreeList::SegregatedFreeList):
2250         (bmalloc::SegregatedFreeList::insert):
2251         * bmalloc/SmallAllocator.h:
2252         (bmalloc::SmallAllocator::allocate):
2253         (bmalloc::SmallAllocator::refill):
2254         * bmalloc/Syscall.h:
2255         * bmalloc/VMAllocate.h:
2256         (bmalloc::vmValidate):
2257         (bmalloc::vmAllocate):
2258         (bmalloc::vmDeallocatePhysicalPagesSloppy):
2259         * bmalloc/Vector.h:
2260         (bmalloc::Vector<T>::operator):
2261         (bmalloc::Vector<T>::pop):
2262         (bmalloc::Vector<T>::shrink):
2263         * bmalloc/XLargeChunk.h:
2264         (bmalloc::XLargeChunk::range):
2265         (bmalloc::XLargeChunk::size):
2266
2267 2014-04-08  Geoffrey Garen  <ggaren@apple.com>
2268
2269         Removed an unused file.
2270
2271         Unreviewed.
2272
2273         * bmalloc/AsyncTask.cpp: Removed.
2274
2275 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
2276
2277         Build bmalloc on Mac
2278         https://bugs.webkit.org/show_bug.cgi?id=131333
2279
2280         Reviewed by Mark Rowe.
2281
2282         * Makefile: Added. For make clients.
2283
2284         These files are required for building any project in WebKit. I copied
2285         them from WTF:
2286         * Configurations: Added.
2287         * Configurations/Base.xcconfig: Added.
2288         * Configurations/DebugRelease.xcconfig: Added.
2289         * Configurations/bmalloc.xcconfig: Added.
2290         * Configurations/iOS.xcconfig: Added.
2291         * Configurations/mbmalloc.xcconfig: Added.
2292
2293         * bmalloc.xcodeproj/project.pbxproj: I removed per-project-file stuff
2294         from here because everything is in .xcconfig files now.
2295
2296         I had to fix a bunch of minor warnings, since they're enabled in our
2297         .xcconfig files:
2298
2299         * bmalloc/AsyncTask.h:
2300         (bmalloc::Function>::AsyncTask):
2301         * bmalloc/BAssert.h:
2302         * bmalloc/BoundaryTagInlines.h:
2303         (bmalloc::validate):
2304         * bmalloc/Heap.cpp:
2305         (bmalloc::Heap::Heap):
2306         (bmalloc::Heap::allocateLarge):
2307         (bmalloc::Heap::deallocateLarge):
2308         * bmalloc/Mutex.h:
2309         (bmalloc::Mutex::Mutex): Deleted.
2310         * bmalloc/VMAllocate.h:
2311         (bmalloc::vmValidate):
2312         * bmalloc/mbmalloc.cpp:
2313
2314 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
2315
2316         bmalloc: Fixed a leak in the per-thread cache
2317         https://bugs.webkit.org/show_bug.cgi?id=131330
2318
2319         Reviewed by Andreas Kling.
2320
2321         Remember to deallocate our line caches upon thread exit.
2322
2323         * bmalloc/Deallocator.cpp:
2324         (bmalloc::Deallocator::~Deallocator):
2325
2326 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
2327
2328         bmalloc: rolled out the tryLock experiment
2329         https://bugs.webkit.org/show_bug.cgi?id=131328
2330
2331         Reviewed by Andreas Kling.
2332
2333         It wasn't a speedup.
2334
2335         * bmalloc.xcodeproj/project.pbxproj:
2336         * bmalloc/Allocator.cpp:
2337         (bmalloc::Allocator::processSmallAllocatorLog):
2338         (bmalloc::Allocator::processMediumAllocatorLog):
2339         * bmalloc/Deallocator.cpp:
2340         (bmalloc::Deallocator::processObjectLog):
2341         (bmalloc::Deallocator::deallocateSlowCase):
2342         (bmalloc::Deallocator::deallocateSmallLine):
2343         (bmalloc::Deallocator::deallocateMediumLine):
2344         * bmalloc/Deallocator.h:
2345         (bmalloc::Deallocator::deallocateFastCase):
2346         * bmalloc/Heap.h:
2347         (bmalloc::Heap::deallocateSmallLine):
2348         (bmalloc::Heap::deallocateMediumLine):
2349         * bmalloc/Line.h:
2350         (bmalloc::Line<Traits>::deref):
2351         * bmalloc/Page.h:
2352         (bmalloc::Page<Traits>::deref):
2353
2354 2014-04-07  Geoffrey Garen  <ggaren@apple.com>
2355
2356         bmalloc
2357         https://bugs.webkit.org/show_bug.cgi?id=131170
2358
2359         Reviewed by Andreas Kling.
2360
2361         Initial commit.
2362
2363         * bmalloc: Added.
2364         * bmalloc.xcodeproj: Added.
2365         * bmalloc.xcodeproj/project.pbxproj: Added.
2366         * bmalloc/Algorithm.h: Added.
2367         (bmalloc::max):
2368         (bmalloc::min):
2369         (bmalloc::mask):
2370         (bmalloc::test):
2371         (bmalloc::roundUpToMultipleOf):
2372         (bmalloc::roundDownToMultipleOf):
2373         (bmalloc::sizeOf):
2374         (bmalloc::bitCount):
2375         (bmalloc::isPowerOfTwo):
2376         * bmalloc/Allocator.cpp: Added.
2377         (bmalloc::Allocator::Allocator):
2378         (bmalloc::Allocator::~Allocator):
2379         (bmalloc::Allocator::log):
2380         (bmalloc::Allocator::processSmallAllocatorLog):
2381         (bmalloc::Allocator::processMediumAllocatorLog):
2382         (bmalloc::Allocator::allocateLarge):
2383         (bmalloc::Allocator::allocateXLarge):
2384         (bmalloc::Allocator::allocateMedium):
2385         (bmalloc::Allocator::allocateSlowCase):
2386         * bmalloc/Allocator.h: Added.
2387         (bmalloc::Allocator::smallAllocatorFor):
2388         (bmalloc::Allocator::allocateFastCase):
2389         (bmalloc::Allocator::allocate):
2390         * bmalloc/AsyncTask.cpp: Added.
2391         (bmalloc::AsyncTask<Function>::runSlowCase):
2392         (bmalloc::AsyncTask<Function>::pthreadEntryPoint):
2393         (bmalloc::AsyncTask<Function>::entryPoint):
2394         * bmalloc/AsyncTask.h: Added.
2395         (bmalloc::Function>::AsyncTask):
2396         (bmalloc::Function>::join):
2397         (bmalloc::Function>::run):
2398         (bmalloc::Function>::runSlowCase):
2399         (bmalloc::Function>::pthreadEntryPoint):
2400         (bmalloc::Function>::entryPoint):
2401         * bmalloc/BAssert.h: Added.
2402         * bmalloc/BeginTag.h: Added.
2403         (bmalloc::BeginTag::isInFreeList):
2404         * bmalloc/BoundaryTag.h: Added.
2405         (bmalloc::BoundaryTag::isXLarge):
2406         (bmalloc::BoundaryTag::setXLarge):
2407         (bmalloc::BoundaryTag::isFree):
2408         (bmalloc::BoundaryTag::setFree):
2409         (bmalloc::BoundaryTag::isEnd):
2410         (bmalloc::BoundaryTag::setEnd):
2411         (bmalloc::BoundaryTag::hasPhysicalPages):
2412         (bmalloc::BoundaryTag::setHasPhysicalPages):
2413         (bmalloc::BoundaryTag::isNull):
2414         (bmalloc::BoundaryTag::clear):
2415         (bmalloc::BoundaryTag::size):
2416         (bmalloc::BoundaryTag::setSize):
2417         (bmalloc::BoundaryTag::prev):
2418         (bmalloc::BoundaryTag::next):
2419         * bmalloc/BoundaryTagInlines.h: Added.
2420         (bmalloc::validate):
2421         (bmalloc::validatePrev):
2422         (bmalloc::validateNext):
2423         (bmalloc::BoundaryTag::init):
2424         (bmalloc::BoundaryTag::mergeLargeLeft):
2425         (bmalloc::BoundaryTag::mergeLargeRight):
2426         (bmalloc::BoundaryTag::mergeLarge):
2427         (bmalloc::BoundaryTag::deallocate):
2428         (bmalloc::BoundaryTag::splitLarge):
2429         (bmalloc::BoundaryTag::allocate):
2430         * bmalloc/Cache.cpp: Added.
2431         (bmalloc::Cache::operator new):
2432         (bmalloc::Cache::operator delete):
2433         (bmalloc::Cache::Cache):
2434         (bmalloc::Cache::allocateSlowCase):
2435         (bmalloc::Cache::allocateSlowCaseNullCache):
2436         (bmalloc::Cache::deallocateSlowCase):
2437         (bmalloc::Cache::deallocateSlowCaseNullCache):
2438         * bmalloc/Cache.h: Added.
2439         (bmalloc::Cache::allocator):
2440         (bmalloc::Cache::deallocator):
2441         (bmalloc::Cache::allocateFastCase):
2442         (bmalloc::Cache::deallocateFastCase):
2443         (bmalloc::Cache::allocate):
2444         (bmalloc::Cache::deallocate):
2445         * bmalloc/Chunk.h: Added.
2446         (bmalloc::Chunk::begin):
2447         (bmalloc::Chunk::end):
2448         (bmalloc::Chunk::lines):
2449         (bmalloc::Chunk::pages):
2450         * bmalloc/Deallocator.cpp: Added.
2451         (bmalloc::Deallocator::Deallocator):
2452         (bmalloc::Deallocator::~Deallocator):
2453         (bmalloc::Deallocator::deallocateLarge):
2454         (bmalloc::Deallocator::deallocateXLarge):
2455         (bmalloc::Deallocator::processObjectLog):
2456         (bmalloc::Deallocator::deallocateSlowCase):
2457         (bmalloc::Deallocator::deallocateSmallLine):
2458         (bmalloc::Deallocator::allocateSmallLine):
2459         (bmalloc::Deallocator::deallocateMediumLine):
2460         (bmalloc::Deallocator::allocateMediumLine):
2461         * bmalloc/Deallocator.h: Added.
2462         (bmalloc::Deallocator::deallocateFastCase):
2463         (bmalloc::Deallocator::deallocate):
2464         * bmalloc/EndTag.h: Added.
2465         (bmalloc::EndTag::operator=):
2466         * bmalloc/FixedVector.h: Added.
2467         (bmalloc::FixedVector::begin):
2468         (bmalloc::FixedVector::end):
2469         (bmalloc::FixedVector::size):
2470         (bmalloc::FixedVector::capacity):
2471         (bmalloc::FixedVector::clear):
2472         (bmalloc::FixedVector::isEmpty):
2473         (bmalloc::Capacity>::FixedVector):
2474         (bmalloc::Capacity>::operator):
2475         (bmalloc::Capacity>::push):
2476         (bmalloc::Capacity>::pop):
2477         (bmalloc::Capacity>::shrink):
2478         * bmalloc/Heap.cpp: Added.
2479         (bmalloc::sleep):
2480         (bmalloc::Heap::Heap):
2481         (bmalloc::Heap::concurrentScavenge):
2482         (bmalloc::Heap::scavengeSmallPages):
2483         (bmalloc::Heap::scavengeMediumPages):
2484         (bmalloc::Heap::scavengeLargeRanges):
2485         (bmalloc::Heap::allocateSmallLineSlowCase):
2486         (bmalloc::Heap::allocateMediumLineSlowCase):
2487         (bmalloc::Heap::allocateXLarge):
2488         (bmalloc::Heap::deallocateXLarge):
2489         (bmalloc::Heap::allocateLarge):
2490         (bmalloc::Heap::deallocateLarge):
2491         * bmalloc/Heap.h: Added.
2492         (bmalloc::Heap::deallocateSmallLine):
2493         (bmalloc::Heap::allocateSmallLine):
2494         (bmalloc::Heap::deallocateMediumLine):
2495         (bmalloc::Heap::allocateMediumLine):
2496         * bmalloc/Inline.h: Added.
2497         * bmalloc/LargeChunk.h: Added.
2498         (bmalloc::LargeChunk::begin):
2499         (bmalloc::LargeChunk::end):
2500         (bmalloc::LargeChunk::create):
2501         (bmalloc::LargeChunk::get):
2502         (bmalloc::LargeChunk::beginTag):
2503         (bmalloc::LargeChunk::endTag):
2504         * bmalloc/Line.h: Added.
2505         (bmalloc::Line<Traits>::begin):
2506         (bmalloc::Line<Traits>::end):
2507         (bmalloc::Line<Traits>::concurrentRef):
2508         (bmalloc::Line<Traits>::deref):
2509         * bmalloc/MediumAllocator.h: Added.
2510         (bmalloc::MediumAllocator::isNull):
2511         (bmalloc::MediumAllocator::MediumAllocator):
2512         (bmalloc::MediumAllocator::line):
2513         (bmalloc::MediumAllocator::allocate):
2514         (bmalloc::MediumAllocator::derefCount):
2515         (bmalloc::MediumAllocator::refill):
2516         * bmalloc/MediumChunk.h: Added.
2517         * bmalloc/MediumLine.h: Added.
2518         * bmalloc/MediumPage.h: Added.
2519         * bmalloc/MediumTraits.h: Added.
2520         * bmalloc/Mutex.cpp: Added.
2521         (bmalloc::Mutex::lockSlowCase):
2522         * bmalloc/Mutex.h: Added.
2523         (bmalloc::Mutex::Mutex):
2524         (bmalloc::Mutex::try_lock):
2525         (bmalloc::Mutex::lock):
2526         (bmalloc::Mutex::unlock):
2527         * bmalloc/ObjectType.cpp: Added.
2528         (bmalloc::objectType):
2529         * bmalloc/ObjectType.h: Added.
2530         (bmalloc::isSmallOrMedium):
2531         (bmalloc::isSmall):
2532         * bmalloc/Page.h: Added.
2533         (bmalloc::Page<Traits>::ref):
2534         (bmalloc::Page<Traits>::deref):
2535         (bmalloc::Page<Traits>::refCount):
2536         * bmalloc/PerProcess.h: Added.
2537         (bmalloc::PerProcess::mutex):
2538         (bmalloc::PerProcess<T>::getFastCase):
2539         (bmalloc::PerProcess<T>::get):
2540         (bmalloc::PerProcess<T>::getSlowCase):
2541         * bmalloc/PerThread.h: Added.
2542         (bmalloc::PerThreadStorage<Cache>::get):
2543         (bmalloc::PerThreadStorage<Cache>::init):
2544         (bmalloc::PerThreadStorage::get):
2545         (bmalloc::PerThreadStorage::init):
2546         (bmalloc::PerThread<T>::getFastCase):
2547         (bmalloc::PerThread<T>::get):
2548         (bmalloc::PerThread<T>::destructor):
2549         (bmalloc::PerThread<T>::getSlowCase):
2550         * bmalloc/Range.h: Added.
2551         (bmalloc::Range::Range):
2552         (bmalloc::Range::begin):
2553         (bmalloc::Range::end):
2554         (bmalloc::Range::size):
2555         (bmalloc::Range::operator!):
2556         (bmalloc::Range::operator<):
2557         * bmalloc/SegregatedFreeList.cpp: Added.
2558         (bmalloc::SegregatedFreeList::SegregatedFreeList):
2559         (bmalloc::SegregatedFreeList::insert):
2560         (bmalloc::SegregatedFreeList::takeGreedy):
2561         (bmalloc::SegregatedFreeList::take):
2562         * bmalloc/SegregatedFreeList.h: Added.
2563         * bmalloc/Sizes.h: Added.
2564         * bmalloc/SmallAllocator.h: Added.
2565         (bmalloc::SmallAllocator::isNull):
2566         (bmalloc::SmallAllocator::canAllocate):
2567         (bmalloc::SmallAllocator::SmallAllocator):
2568         (bmalloc::SmallAllocator::line):
2569         (bmalloc::SmallAllocator::allocate):
2570         (bmalloc::SmallAllocator::objectCount):
2571         (bmalloc::SmallAllocator::derefCount):
2572         (bmalloc::SmallAllocator::refill):
2573         * bmalloc/SmallChunk.h: Added.
2574         * bmalloc/SmallLine.h: Added.
2575         * bmalloc/SmallPage.h: Added.
2576         * bmalloc/SmallTraits.h: Added.
2577         * bmalloc/Syscall.h: Added.
2578         * bmalloc/VMAllocate.h: Added.
2579         (bmalloc::vmSize):
2580         (bmalloc::vmValidate):
2581         (bmalloc::vmAllocate):
2582         (bmalloc::vmDeallocate):
2583         (bmalloc::vmDeallocatePhysicalPages):
2584         (bmalloc::vmAllocatePhysicalPages):
2585         (bmalloc::vmDeallocatePhysicalPagesSloppy):
2586         (bmalloc::vmAllocatePhysicalPagesSloppy):
2587         * bmalloc/VMHeap.cpp: Added.
2588         (bmalloc::VMHeap::VMHeap):
2589         (bmalloc::VMHeap::allocateSmallChunk):
2590         (bmalloc::VMHeap::allocateMediumChunk):
2591         (bmalloc::VMHeap::allocateLargeChunk):
2592         * bmalloc/VMHeap.h: Added.
2593         (bmalloc::VMHeap::allocateSmallPage):
2594         (bmalloc::VMHeap::allocateMediumPage):
2595         (bmalloc::VMHeap::allocateLargeRange):
2596         (bmalloc::VMHeap::deallocateSmallPage):
2597         (bmalloc::VMHeap::deallocateMediumPage):
2598         (bmalloc::VMHeap::deallocateLargeRange):
2599         * bmalloc/Vector.h: Added.
2600         (bmalloc::Vector::begin):
2601         (bmalloc::Vector::end):
2602         (bmalloc::Vector::size):
2603         (bmalloc::Vector::capacity):
2604         (bmalloc::Vector::last):
2605         (bmalloc::Vector::pop):
2606         (bmalloc::Vector<T>::Vector):
2607         (bmalloc::Vector<T>::~Vector):
2608         (bmalloc::Vector<T>::operator):
2609         (bmalloc::Vector<T>::push):
2610         (bmalloc::Vector<T>::pop):
2611         (bmalloc::Vector<T>::shrink):
2612         (bmalloc::Vector<T>::reallocateBuffer):
2613         (bmalloc::Vector<T>::shrinkCapacity):
2614         (bmalloc::Vector<T>::growCapacity):
2615         * bmalloc/XLargeChunk.h: Added.
2616         (bmalloc::XLargeChunk::get):
2617         (bmalloc::XLargeChunk::begin):
2618         (bmalloc::XLargeChunk::XLargeChunk):
2619         (bmalloc::XLargeChunk::create):
2620         (bmalloc::XLargeChunk::destroy):
2621         (bmalloc::XLargeChunk::range):
2622         (bmalloc::XLargeChunk::size):
2623         * bmalloc/bmalloc.h: Added.
2624         (bmalloc::api::malloc):
2625         (bmalloc::api::free):
2626         (bmalloc::api::realloc):
2627         * bmalloc/mbmalloc.cpp: Added.
2628