Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1997)

Unified Diff: Source/wtf/WTF.cpp

Issue 23604048: Get rid of fastMallocGoodSize() and replace it with something generic. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix compile error. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Source/wtf/WTF.h ('K') | « Source/wtf/WTF.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/WTF.cpp
diff --git a/Source/wtf/WTF.cpp b/Source/wtf/WTF.cpp
index bddb3c0902f685c6f19360fe3748933df7e59b69..ac31ca2d7741dc76959c24e117c25b1665cee18b 100644
--- a/Source/wtf/WTF.cpp
+++ b/Source/wtf/WTF.cpp
@@ -41,8 +41,12 @@ namespace WTF {
extern void initializeThreading();
+PartitionAllocator<4096> Partitions::m_bufferAllocator;
+unsigned short QuantizedAllocation::table[QuantizedAllocation::kTableSize];
+
void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncreasingTimeFunction)
{
+ QuantizedAllocation::init();
Partitions::initialize();
setCurrentTimeFunction(currentTimeFunction);
setMonotonicallyIncreasingTimeFunction(monotonicallyIncreasingTimeFunction);
@@ -64,6 +68,20 @@ void Partitions::shutdown()
m_bufferAllocator.shutdown();
}
-PartitionAllocator<4096> Partitions::m_bufferAllocator;
+void QuantizedAllocation::init()
+{
+ size_t currAllocation = 0;
+ size_t currRounding = kMinRounding;
+ size_t currRoundingLimit = kMinRoundingLimit / 2;
+ size_t numCurrRounding = 0;
+ for (size_t i = 0; i < kTableSize; ++i) {
+ table[i] = currRounding - 1;
+ currAllocation += kMinRoundingLimit;
+ if (currAllocation == currRoundingLimit * 2) {
+ currRoundingLimit *= 2;
+ currRounding *= 2;
+ }
+ }
+}
} // namespace WTF
« Source/wtf/WTF.h ('K') | « Source/wtf/WTF.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698