Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 | 138 |
| 139 // ZoneObject is an abstraction that helps define classes of objects | 139 // ZoneObject is an abstraction that helps define classes of objects |
| 140 // allocated in the Zone. Use it as a base class; see ast.h. | 140 // allocated in the Zone. Use it as a base class; see ast.h. |
| 141 class ZoneObject { | 141 class ZoneObject { |
| 142 public: | 142 public: |
| 143 // Allocate a new ZoneObject of 'size' bytes in the Zone. | 143 // Allocate a new ZoneObject of 'size' bytes in the Zone. |
| 144 INLINE(void* operator new(size_t size, Zone* zone)); | 144 INLINE(void* operator new(size_t size, Zone* zone)); |
| 145 | 145 |
| 146 // Ideally, the delete operator should be private instead of | 146 // Ideally, the delete operator should be private instead of |
|
tfarina
2014/01/29 17:39:15
can you update this comment while you are here?
marja
2014/01/29 17:42:18
Actually... I should've read the "MSVC requires th
tfarina
2014/01/29 17:45:00
So disregards my latest comment in src/zone.h:236
| |
| 147 // public, but unfortunately the compiler sometimes synthesizes | 147 // public, but unfortunately the compiler sometimes synthesizes |
| 148 // (unused) destructors for classes derived from ZoneObject, which | 148 // (unused) destructors for classes derived from ZoneObject, which |
| 149 // require the operator to be visible. MSVC requires the delete | 149 // require the operator to be visible. MSVC requires the delete |
| 150 // operator to be public. | 150 // operator to be public. |
| 151 | 151 |
| 152 // ZoneObjects should never be deleted individually; use | 152 // ZoneObjects should never be deleted individually; use |
| 153 // Zone::DeleteAll() to delete all zone objects in one go. | 153 // Zone::DeleteAll() to delete all zone objects in one go. |
| 154 protected: | |
| 154 void operator delete(void*, size_t) { UNREACHABLE(); } | 155 void operator delete(void*, size_t) { UNREACHABLE(); } |
| 155 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } | 156 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 | 159 |
| 159 // The ZoneScope is used to automatically call DeleteAll() on a | 160 // The ZoneScope is used to automatically call DeleteAll() on a |
| 160 // Zone when the ZoneScope is destroyed (i.e. goes out of scope) | 161 // Zone when the ZoneScope is destroyed (i.e. goes out of scope) |
| 161 struct ZoneScope { | 162 struct ZoneScope { |
| 162 public: | 163 public: |
| 163 explicit ZoneScope(Zone* zone) : zone_(zone) { } | 164 explicit ZoneScope(Zone* zone) : zone_(zone) { } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 ZoneAllocationPolicy(zone)); | 226 ZoneAllocationPolicy(zone)); |
| 226 } | 227 } |
| 227 INLINE(void Allocate(int length, Zone* zone)) { | 228 INLINE(void Allocate(int length, Zone* zone)) { |
| 228 List<T, ZoneAllocationPolicy>::Allocate(length, ZoneAllocationPolicy(zone)); | 229 List<T, ZoneAllocationPolicy>::Allocate(length, ZoneAllocationPolicy(zone)); |
| 229 } | 230 } |
| 230 INLINE(void Initialize(int capacity, Zone* zone)) { | 231 INLINE(void Initialize(int capacity, Zone* zone)) { |
| 231 List<T, ZoneAllocationPolicy>::Initialize(capacity, | 232 List<T, ZoneAllocationPolicy>::Initialize(capacity, |
| 232 ZoneAllocationPolicy(zone)); | 233 ZoneAllocationPolicy(zone)); |
| 233 } | 234 } |
| 234 | 235 |
| 235 void operator delete(void* pointer) { UNREACHABLE(); } | 236 void operator delete(void* pointer) { UNREACHABLE(); } |
|
tfarina
2014/01/29 17:43:43
do you want to make these and the ZoneSplayTree on
| |
| 236 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } | 237 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } |
| 237 }; | 238 }; |
| 238 | 239 |
| 239 | 240 |
| 240 // A zone splay tree. The config type parameter encapsulates the | 241 // A zone splay tree. The config type parameter encapsulates the |
| 241 // different configurations of a concrete splay tree (see splay-tree.h). | 242 // different configurations of a concrete splay tree (see splay-tree.h). |
| 242 // The tree itself and all its elements are allocated in the Zone. | 243 // The tree itself and all its elements are allocated in the Zone. |
| 243 template <typename Config> | 244 template <typename Config> |
| 244 class ZoneSplayTree: public SplayTree<Config, ZoneAllocationPolicy> { | 245 class ZoneSplayTree: public SplayTree<Config, ZoneAllocationPolicy> { |
| 245 public: | 246 public: |
| 246 explicit ZoneSplayTree(Zone* zone) | 247 explicit ZoneSplayTree(Zone* zone) |
| 247 : SplayTree<Config, ZoneAllocationPolicy>(ZoneAllocationPolicy(zone)) {} | 248 : SplayTree<Config, ZoneAllocationPolicy>(ZoneAllocationPolicy(zone)) {} |
| 248 ~ZoneSplayTree(); | 249 ~ZoneSplayTree(); |
| 249 | 250 |
| 250 INLINE(void* operator new(size_t size, Zone* zone)); | 251 INLINE(void* operator new(size_t size, Zone* zone)); |
| 251 | 252 |
| 252 void operator delete(void* pointer) { UNREACHABLE(); } | 253 void operator delete(void* pointer) { UNREACHABLE(); } |
| 253 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } | 254 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } |
| 254 }; | 255 }; |
| 255 | 256 |
| 256 | 257 |
| 257 typedef TemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap; | 258 typedef TemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap; |
| 258 | 259 |
| 259 } } // namespace v8::internal | 260 } } // namespace v8::internal |
| 260 | 261 |
| 261 #endif // V8_ZONE_H_ | 262 #endif // V8_ZONE_H_ |
| OLD | NEW |