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

Unified Diff: Source/wtf/QuantizedAllocation.cpp

Issue 23604048: Get rid of fastMallocGoodSize() and replace it with something generic. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missed WTF_EXPORT. 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
« no previous file with comments | « Source/wtf/QuantizedAllocation.h ('k') | Source/wtf/Vector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/QuantizedAllocation.cpp
diff --git a/Source/wtf/SpinLock.h b/Source/wtf/QuantizedAllocation.cpp
similarity index 73%
copy from Source/wtf/SpinLock.h
copy to Source/wtf/QuantizedAllocation.cpp
index ae2f11675f7e006b22994b0de6695d700f2e4dda..d918e6bae9d24a88aafc168eb584717ad534aa09 100644
--- a/Source/wtf/SpinLock.h
+++ b/Source/wtf/QuantizedAllocation.cpp
@@ -28,32 +28,27 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WTF_SpinLock_h
-#define WTF_SpinLock_h
-
-// DESCRIPTION
-// spinLockLock() and spinLockUnlock() are simple spinlock primitives based on
-// the standard CPU primitive of atomic increment and decrement of an int at
-// a given memory address.
-
-#include "wtf/Atomics.h"
+#include "config.h"
+#include "wtf/QuantizedAllocation.h"
namespace WTF {
-ALWAYS_INLINE void spinLockLock(int volatile* lock)
-{
- while (atomicIncrement(lock) != 1)
- atomicDecrement(lock);
-}
+unsigned short QuantizedAllocation::table[QuantizedAllocation::kTableSize];
-ALWAYS_INLINE void spinLockUnlock(int volatile* lock)
+void QuantizedAllocation::init()
{
- atomicDecrement(lock);
+ 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
-
-using WTF::spinLockLock;
-using WTF::spinLockUnlock;
-
-#endif // WTF_PartitionAlloc_h
« no previous file with comments | « Source/wtf/QuantizedAllocation.h ('k') | Source/wtf/Vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698