| 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 #ifndef V8_ZONE_ZONE_H_ | 5 #ifndef V8_ZONE_ZONE_H_ |
| 6 #define V8_ZONE_ZONE_H_ | 6 #define V8_ZONE_ZONE_H_ |
| 7 | 7 |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "src/base/hashmap.h" | 10 #include "src/base/hashmap.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // the Zone supports deallocating all chunks in one fast | 22 // the Zone supports deallocating all chunks in one fast |
| 23 // operation. The Zone is used to hold temporary data structures like | 23 // operation. The Zone is used to hold temporary data structures like |
| 24 // the abstract syntax tree, which is deallocated after compilation. | 24 // the abstract syntax tree, which is deallocated after compilation. |
| 25 // | 25 // |
| 26 // Note: There is no need to initialize the Zone; the first time an | 26 // Note: There is no need to initialize the Zone; the first time an |
| 27 // allocation is attempted, a segment of memory will be requested | 27 // allocation is attempted, a segment of memory will be requested |
| 28 // through a call to malloc(). | 28 // through a call to malloc(). |
| 29 // | 29 // |
| 30 // Note: The implementation is inherently not thread safe. Do not use | 30 // Note: The implementation is inherently not thread safe. Do not use |
| 31 // from multi-threaded code. | 31 // from multi-threaded code. |
| 32 class Zone final { | 32 class V8_EXPORT_PRIVATE Zone final { |
| 33 public: | 33 public: |
| 34 explicit Zone(AccountingAllocator* allocator); | 34 explicit Zone(AccountingAllocator* allocator); |
| 35 ~Zone(); | 35 ~Zone(); |
| 36 | 36 |
| 37 // Allocate 'size' bytes of memory in the Zone; expands the Zone by | 37 // Allocate 'size' bytes of memory in the Zone; expands the Zone by |
| 38 // allocating new segments of memory on demand using malloc(). | 38 // allocating new segments of memory on demand using malloc(). |
| 39 void* New(size_t size); | 39 void* New(size_t size); |
| 40 | 40 |
| 41 template <typename T> | 41 template <typename T> |
| 42 T* NewArray(size_t length) { | 42 T* NewArray(size_t length) { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } | 232 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 typedef base::TemplateHashMapImpl<void*, void*, ZoneAllocationPolicy> | 235 typedef base::TemplateHashMapImpl<void*, void*, ZoneAllocationPolicy> |
| 236 ZoneHashMap; | 236 ZoneHashMap; |
| 237 | 237 |
| 238 } // namespace internal | 238 } // namespace internal |
| 239 } // namespace v8 | 239 } // namespace v8 |
| 240 | 240 |
| 241 #endif // V8_ZONE_ZONE_H_ | 241 #endif // V8_ZONE_ZONE_H_ |
| OLD | NEW |