bmalloc should support system memory analysis tools (part 1)
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Dec 2014 22:17:06 +0000 (22:17 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Dec 2014 22:17:06 +0000 (22:17 +0000)
commit435f1914da1c2a1e864adb9f83f43d6534f01f63
tree50e685b85e4be08daa60f2045fb726fb28619eb8
parentea81e8ce5ba907c2eff40a266abfdc4791d0f35c
bmalloc should support system memory analysis tools (part 1)
https://bugs.webkit.org/show_bug.cgi?id=139559

Reviewed by Mark Lam.

This patch adds the hooks to disable bmalloc at runtime if certain
environment variables are set, but doesn't actually read from the
environment yet.

No performance change.

* bmalloc.xcodeproj/project.pbxproj: Added the Environment class, which
we'll use to read environment variables and see if memory analysis tools
have been enabled.

* bmalloc/Allocator.cpp:
(bmalloc::Allocator::Allocator):
(bmalloc::Allocator::allocateSlowCase): Added a hook to disable bmalloc
on the allocation path. We cache the setting to make the check fast.

* bmalloc/Allocator.h: Interface changes.

* bmalloc/Cache.cpp:
(bmalloc::Cache::Cache): Pass a heap pointer through to our allocator
and deallocator. This main purpose is to enable them to query the
environment for whether bmalloc is enabled; but this is also a slightly
cleaner way to guarantee to them that the Heap has been pre-initialized.

* bmalloc/Deallocator.cpp:
(bmalloc::Deallocator::Deallocator): If bmalloc is disable, artificially
fill the object log to force us to take the slow path on all deallocations.

(bmalloc::Deallocator::deallocateSlowCase): Do the disabled check.

* bmalloc/Deallocator.h: Interface changes.

* bmalloc/Environment.cpp: Added.
(bmalloc::Environment::Environment):
(bmalloc::Environment::computeIsBmallocEnabled):
* bmalloc/Environment.h: Added.
(bmalloc::Environment::isBmallocEnabled): This is the class that will
encapsulate looking for environment variables that turn on heap
analysis tools.

* bmalloc/Heap.h:
(bmalloc::Heap::environment):

* bmalloc/Mutex.h:
(bmalloc::Mutex::Mutex):
* bmalloc/StaticMutex.h: A little refactoring to clarify these comments,
since I got super confused about them while writing this patch.

* bmalloc/VMHeap.cpp: Fixed an #include.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
Source/bmalloc/bmalloc/Allocator.cpp
Source/bmalloc/bmalloc/Allocator.h
Source/bmalloc/bmalloc/Cache.cpp
Source/bmalloc/bmalloc/Deallocator.cpp
Source/bmalloc/bmalloc/Deallocator.h
Source/bmalloc/bmalloc/Environment.cpp [new file with mode: 0644]
Source/bmalloc/bmalloc/Environment.h [new file with mode: 0644]
Source/bmalloc/bmalloc/Heap.h
Source/bmalloc/bmalloc/Mutex.h
Source/bmalloc/bmalloc/StaticMutex.h
Source/bmalloc/bmalloc/VMHeap.cpp