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 |