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