OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "wtf/PartitionAlloc.h" | 34 #include "wtf/PartitionAlloc.h" |
35 | 35 |
36 #ifndef NDEBUG | 36 #ifndef NDEBUG |
37 #include "wtf/MainThread.h" | 37 #include "wtf/MainThread.h" |
38 #endif | 38 #endif |
39 | 39 |
40 namespace WTF { | 40 namespace WTF { |
41 | 41 |
42 extern void initializeThreading(); | 42 extern void initializeThreading(); |
43 | 43 |
| 44 PartitionAllocator<4096> Partitions::m_bufferAllocator; |
| 45 unsigned short QuantizedAllocation::table[QuantizedAllocation::kTableSize]; |
| 46 |
44 void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncr
easingTimeFunction) | 47 void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncr
easingTimeFunction) |
45 { | 48 { |
| 49 QuantizedAllocation::init(); |
46 Partitions::initialize(); | 50 Partitions::initialize(); |
47 setCurrentTimeFunction(currentTimeFunction); | 51 setCurrentTimeFunction(currentTimeFunction); |
48 setMonotonicallyIncreasingTimeFunction(monotonicallyIncreasingTimeFunction); | 52 setMonotonicallyIncreasingTimeFunction(monotonicallyIncreasingTimeFunction); |
49 initializeThreading(); | 53 initializeThreading(); |
50 } | 54 } |
51 | 55 |
52 void shutdown() | 56 void shutdown() |
53 { | 57 { |
54 Partitions::shutdown(); | 58 Partitions::shutdown(); |
55 } | 59 } |
56 | 60 |
57 void Partitions::initialize() | 61 void Partitions::initialize() |
58 { | 62 { |
59 m_bufferAllocator.init(); | 63 m_bufferAllocator.init(); |
60 } | 64 } |
61 | 65 |
62 void Partitions::shutdown() | 66 void Partitions::shutdown() |
63 { | 67 { |
64 m_bufferAllocator.shutdown(); | 68 m_bufferAllocator.shutdown(); |
65 } | 69 } |
66 | 70 |
67 PartitionAllocator<4096> Partitions::m_bufferAllocator; | 71 void QuantizedAllocation::init() |
| 72 { |
| 73 size_t currAllocation = 0; |
| 74 size_t currRounding = kMinRounding; |
| 75 size_t currRoundingLimit = kMinRoundingLimit / 2; |
| 76 size_t numCurrRounding = 0; |
| 77 for (size_t i = 0; i < kTableSize; ++i) { |
| 78 table[i] = currRounding - 1; |
| 79 currAllocation += kMinRoundingLimit; |
| 80 if (currAllocation == currRoundingLimit * 2) { |
| 81 currRoundingLimit *= 2; |
| 82 currRounding *= 2; |
| 83 } |
| 84 } |
| 85 } |
68 | 86 |
69 } // namespace WTF | 87 } // namespace WTF |
OLD | NEW |