OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/compiler/zone-pool.h" | 6 #include "src/compiler/zone-pool.h" |
7 #include "test/unittests/test-utils.h" | 7 #include "test/unittests/test-utils.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 size_t Allocate(Zone* zone) { | 33 size_t Allocate(Zone* zone) { |
34 size_t bytes = rng.NextInt(25) + 7; | 34 size_t bytes = rng.NextInt(25) + 7; |
35 size_t size_before = zone->allocation_size(); | 35 size_t size_before = zone->allocation_size(); |
36 zone->New(bytes); | 36 zone->New(bytes); |
37 return zone->allocation_size() - size_before; | 37 return zone->allocation_size() - size_before; |
38 } | 38 } |
39 | 39 |
40 private: | 40 private: |
41 base::AccountingAllocator allocator_; | 41 v8::internal::AccountingAllocator allocator_; |
42 ZonePool zone_pool_; | 42 ZonePool zone_pool_; |
43 base::RandomNumberGenerator rng; | 43 base::RandomNumberGenerator rng; |
44 }; | 44 }; |
45 | 45 |
46 | 46 |
47 TEST_F(ZonePoolTest, Empty) { | 47 TEST_F(ZonePoolTest, Empty) { |
48 ExpectForPool(0, 0, 0); | 48 ExpectForPool(0, 0, 0); |
49 { | 49 { |
50 ZonePool::StatsScope stats(zone_pool()); | 50 ZonePool::StatsScope stats(zone_pool()); |
51 Expect(&stats, 0, 0, 0); | 51 Expect(&stats, 0, 0, 0); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 ExpectForPool(outer_allocated, max_loop_allocation, total_allocated); | 154 ExpectForPool(outer_allocated, max_loop_allocation, total_allocated); |
155 } | 155 } |
156 } | 156 } |
157 Expect(&outer_stats, 0, max_loop_allocation, total_allocated); | 157 Expect(&outer_stats, 0, max_loop_allocation, total_allocated); |
158 ExpectForPool(0, max_loop_allocation, total_allocated); | 158 ExpectForPool(0, max_loop_allocation, total_allocated); |
159 } | 159 } |
160 | 160 |
161 } // namespace compiler | 161 } // namespace compiler |
162 } // namespace internal | 162 } // namespace internal |
163 } // namespace v8 | 163 } // namespace v8 |
OLD | NEW |