Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: src/zone/zone.h

Issue 2394213003: Named all zones in the project (Closed)
Patch Set: Merge branch 'master' into zonenames Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "src/base/logging.h" 11 #include "src/base/logging.h"
12 #include "src/globals.h" 12 #include "src/globals.h"
13 #include "src/list.h" 13 #include "src/list.h"
14 #include "src/splay-tree.h" 14 #include "src/splay-tree.h"
15 #include "src/zone/accounting-allocator.h" 15 #include "src/zone/accounting-allocator.h"
16 16
17 #ifndef ZONE_NAME
18 #define STRINGIFY(x) #x
19 #define TOSTRING(x) STRINGIFY(x)
20 #define ZONE_NAME __FILE__ ":" TOSTRING(__LINE__)
21 #endif
22
17 namespace v8 { 23 namespace v8 {
18 namespace internal { 24 namespace internal {
19 25
20 // The Zone supports very fast allocation of small chunks of 26 // The Zone supports very fast allocation of small chunks of
21 // memory. The chunks cannot be deallocated individually, but instead 27 // memory. The chunks cannot be deallocated individually, but instead
22 // the Zone supports deallocating all chunks in one fast 28 // the Zone supports deallocating all chunks in one fast
23 // operation. The Zone is used to hold temporary data structures like 29 // operation. The Zone is used to hold temporary data structures like
24 // the abstract syntax tree, which is deallocated after compilation. 30 // the abstract syntax tree, which is deallocated after compilation.
25 // 31 //
26 // Note: There is no need to initialize the Zone; the first time an 32 // Note: There is no need to initialize the Zone; the first time an
27 // allocation is attempted, a segment of memory will be requested 33 // allocation is attempted, a segment of memory will be requested
28 // through the allocator. 34 // through the allocator.
29 // 35 //
30 // Note: The implementation is inherently not thread safe. Do not use 36 // Note: The implementation is inherently not thread safe. Do not use
31 // from multi-threaded code. 37 // from multi-threaded code.
32 class V8_EXPORT_PRIVATE Zone final { 38 class V8_EXPORT_PRIVATE Zone final {
33 public: 39 public:
34 explicit Zone(AccountingAllocator* allocator, const char* name = "unnamed"); 40 Zone(AccountingAllocator* allocator, const char* name);
35 ~Zone(); 41 ~Zone();
36 42
37 // Allocate 'size' bytes of memory in the Zone; expands the Zone by 43 // Allocate 'size' bytes of memory in the Zone; expands the Zone by
38 // allocating new segments of memory on demand using malloc(). 44 // allocating new segments of memory on demand using malloc().
39 void* New(size_t size); 45 void* New(size_t size);
40 46
41 template <typename T> 47 template <typename T>
42 T* NewArray(size_t length) { 48 T* NewArray(size_t length) {
43 DCHECK_LT(length, std::numeric_limits<size_t>::max() / sizeof(T)); 49 DCHECK_LT(length, std::numeric_limits<size_t>::max() / sizeof(T));
44 return static_cast<T*>(New(length * sizeof(T))); 50 return static_cast<T*>(New(length * sizeof(T)));
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 223
218 typedef base::PointerTemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap; 224 typedef base::PointerTemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap;
219 225
220 typedef base::CustomMatcherTemplateHashMapImpl<ZoneAllocationPolicy> 226 typedef base::CustomMatcherTemplateHashMapImpl<ZoneAllocationPolicy>
221 CustomMatcherZoneHashMap; 227 CustomMatcherZoneHashMap;
222 228
223 } // namespace internal 229 } // namespace internal
224 } // namespace v8 230 } // namespace v8
225 231
226 #endif // V8_ZONE_ZONE_H_ 232 #endif // V8_ZONE_ZONE_H_
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698