OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/zone/zone.h" | 5 #include "src/zone/zone.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 USE(start); \ | 34 USE(start); \ |
35 USE(size); \ | 35 USE(size); \ |
36 } while (false) | 36 } while (false) |
37 | 37 |
38 const size_t kASanRedzoneBytes = 0; | 38 const size_t kASanRedzoneBytes = 0; |
39 | 39 |
40 #endif // V8_USE_ADDRESS_SANITIZER | 40 #endif // V8_USE_ADDRESS_SANITIZER |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 Zone::Zone(AccountingAllocator* allocator) | 44 Zone::Zone(AccountingAllocator* allocator, const char* name) |
45 : allocation_size_(0), | 45 : allocation_size_(0), |
46 segment_bytes_allocated_(0), | 46 segment_bytes_allocated_(0), |
47 position_(0), | 47 position_(0), |
48 limit_(0), | 48 limit_(0), |
49 allocator_(allocator), | 49 allocator_(allocator), |
50 segment_head_(nullptr) {} | 50 segment_head_(nullptr), |
| 51 name_(name) { |
| 52 allocator_->ZoneCreation(this); |
| 53 } |
51 | 54 |
52 Zone::~Zone() { | 55 Zone::~Zone() { |
| 56 allocator_->ZoneDestruction(this); |
| 57 |
53 DeleteAll(); | 58 DeleteAll(); |
54 | 59 |
55 DCHECK(segment_bytes_allocated_ == 0); | 60 DCHECK(segment_bytes_allocated_ == 0); |
56 } | 61 } |
57 | 62 |
58 void* Zone::New(size_t size) { | 63 void* Zone::New(size_t size) { |
59 // Round up the requested size to fit the alignment. | 64 // Round up the requested size to fit the alignment. |
60 size = RoundUp(size, kAlignment); | 65 size = RoundUp(size, kAlignment); |
61 | 66 |
62 // If the allocation size is divisible by 8 then we return an 8-byte aligned | 67 // If the allocation size is divisible by 8 then we return an 8-byte aligned |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // size bytes + header and alignment padding) | 179 // size bytes + header and alignment padding) |
175 DCHECK(reinterpret_cast<uintptr_t>(position_) >= | 180 DCHECK(reinterpret_cast<uintptr_t>(position_) >= |
176 reinterpret_cast<uintptr_t>(result)); | 181 reinterpret_cast<uintptr_t>(result)); |
177 limit_ = segment->end(); | 182 limit_ = segment->end(); |
178 DCHECK(position_ <= limit_); | 183 DCHECK(position_ <= limit_); |
179 return result; | 184 return result; |
180 } | 185 } |
181 | 186 |
182 } // namespace internal | 187 } // namespace internal |
183 } // namespace v8 | 188 } // namespace v8 |
OLD | NEW |