bmalloc: Use a separate zone when using system malloc
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jan 2017 23:39:09 +0000 (23:39 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jan 2017 23:39:09 +0000 (23:39 +0000)
commit9f14501f7d6a56bc68a61166baaffb34dc04839b
tree4ebcf4e1a1e334c344649ea70d90446fb297a9f4
parentcad0406c8a2d14f38d77664e913479f945c03500
bmalloc: Use a separate zone when using system malloc
https://bugs.webkit.org/show_bug.cgi?id=167014

Reviewed by Filip Pizlo.

Harris asked for this so he could separate Safari and WebKit memory use
when doing memory analysis.

This patch adds an explicit DebugHeap class that contains all our
code for specialized allocation with debugging.

* bmalloc.xcodeproj/project.pbxproj:

* bmalloc/Allocator.cpp:
(bmalloc::Allocator::Allocator):
(bmalloc::Allocator::tryAllocate):
(bmalloc::Allocator::allocateImpl):
(bmalloc::Allocator::reallocate):
(bmalloc::Allocator::allocateSlowCase):
* bmalloc/Allocator.h: Forward to DebugHeap instead of inlining all the
code. This is required for our new interface, and it is also a nice
simplification that moves some not-very-important code out of the way.

* bmalloc/Deallocator.cpp:
(bmalloc::Deallocator::Deallocator):
(bmalloc::Deallocator::scavenge):
(bmalloc::Deallocator::deallocateSlowCase):
* bmalloc/Deallocator.h: Ditto.

* bmalloc/DebugHeap.cpp: Added.
(bmalloc::DebugHeap::DebugHeap):
(bmalloc::DebugHeap::malloc):
(bmalloc::DebugHeap::memalign):
(bmalloc::DebugHeap::realloc):
(bmalloc::DebugHeap::free):
* bmalloc/DebugHeap.h: Added. New class for overriding normal heap
behavior. Right now, it just adds a malloc zone and then forwards to
system malloc -- but we can add lots more kinds of debug heaps in the
future if we find them useful.

* bmalloc/Environment.cpp:
(bmalloc::Environment::Environment):
(bmalloc::Environment::computeIsDebugHeapEnabled):
(bmalloc::Environment::computeIsBmallocEnabled): Deleted.
* bmalloc/Environment.h:
(bmalloc::Environment::isDebugHeapEnabled):
(bmalloc::Environment::isBmallocEnabled): Deleted. Renamed everything to
reflect our new use of DebugHeap.

* bmalloc/Heap.cpp:
(bmalloc::Heap::Heap):
* bmalloc/Heap.h:
(bmalloc::Heap::debugHeap): Updated to use DebugHeap.
(bmalloc::Heap::environment): Deleted.

* bmalloc/bmalloc.h:
(bmalloc::api::isEnabled): Updated to use DebugHeap.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210746 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/bmalloc/CMakeLists.txt
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
Source/bmalloc/bmalloc/Allocator.cpp
Source/bmalloc/bmalloc/Allocator.h
Source/bmalloc/bmalloc/Deallocator.cpp
Source/bmalloc/bmalloc/Deallocator.h
Source/bmalloc/bmalloc/DebugHeap.cpp [new file with mode: 0644]
Source/bmalloc/bmalloc/DebugHeap.h [new file with mode: 0644]
Source/bmalloc/bmalloc/Environment.cpp
Source/bmalloc/bmalloc/Environment.h
Source/bmalloc/bmalloc/Heap.cpp
Source/bmalloc/bmalloc/Heap.h
Source/bmalloc/bmalloc/bmalloc.h