| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // elements. The list itself and all its elements are allocated in the | 170 // elements. The list itself and all its elements are allocated in the |
| 171 // Zone. ZoneLists cannot be deleted individually; you can delete all | 171 // Zone. ZoneLists cannot be deleted individually; you can delete all |
| 172 // objects in the Zone by calling Zone::DeleteAll(). | 172 // objects in the Zone by calling Zone::DeleteAll(). |
| 173 template<typename T> | 173 template<typename T> |
| 174 class ZoneList: public List<T, ZoneListAllocationPolicy> { | 174 class ZoneList: public List<T, ZoneListAllocationPolicy> { |
| 175 public: | 175 public: |
| 176 // Construct a new ZoneList with the given capacity; the length is | 176 // Construct a new ZoneList with the given capacity; the length is |
| 177 // always zero. The capacity must be non-negative. | 177 // always zero. The capacity must be non-negative. |
| 178 explicit ZoneList(int capacity) | 178 explicit ZoneList(int capacity) |
| 179 : List<T, ZoneListAllocationPolicy>(capacity) { } | 179 : List<T, ZoneListAllocationPolicy>(capacity) { } |
| 180 |
| 181 // Construct a new ZoneList by copying the elements of the given ZoneList. |
| 182 explicit ZoneList(const ZoneList<T>& other) |
| 183 : List<T, ZoneListAllocationPolicy>(other.length()) { |
| 184 AddAll(other); |
| 185 } |
| 180 }; | 186 }; |
| 181 | 187 |
| 182 | 188 |
| 183 // A zone splay tree. The config type parameter encapsulates the | 189 // Introduce a convenience type for zone lists of map handles. |
| 184 // different configurations of a concrete splay tree (see splay-tree.h). | 190 typedef ZoneList<Handle<Map> > ZoneMapList; |
| 185 // The tree itself and all its elements are allocated in the Zone. | |
| 186 template <typename Config> | |
| 187 class ZoneSplayTree: public SplayTree<Config, ZoneListAllocationPolicy> { | |
| 188 public: | |
| 189 ZoneSplayTree() | |
| 190 : SplayTree<Config, ZoneListAllocationPolicy>() {} | |
| 191 ~ZoneSplayTree(); | |
| 192 }; | |
| 193 | 191 |
| 194 | 192 |
| 195 // ZoneScopes keep track of the current parsing and compilation | 193 // ZoneScopes keep track of the current parsing and compilation |
| 196 // nesting and cleans up generated ASTs in the Zone when exiting the | 194 // nesting and cleans up generated ASTs in the Zone when exiting the |
| 197 // outer-most scope. | 195 // outer-most scope. |
| 198 class ZoneScope BASE_EMBEDDED { | 196 class ZoneScope BASE_EMBEDDED { |
| 199 public: | 197 public: |
| 198 // TODO(isolates): pass isolate pointer here. |
| 200 inline explicit ZoneScope(ZoneScopeMode mode); | 199 inline explicit ZoneScope(ZoneScopeMode mode); |
| 201 | 200 |
| 202 virtual ~ZoneScope(); | 201 virtual ~ZoneScope(); |
| 203 | 202 |
| 204 inline bool ShouldDeleteOnExit(); | 203 inline bool ShouldDeleteOnExit(); |
| 205 | 204 |
| 206 // For ZoneScopes that do not delete on exit by default, call this | 205 // For ZoneScopes that do not delete on exit by default, call this |
| 207 // method to request deletion on exit. | 206 // method to request deletion on exit. |
| 208 void DeleteOnExit() { | 207 void DeleteOnExit() { |
| 209 mode_ = DELETE_ON_EXIT; | 208 mode_ = DELETE_ON_EXIT; |
| 210 } | 209 } |
| 211 | 210 |
| 212 inline static int nesting(); | 211 inline static int nesting(); |
| 213 | 212 |
| 214 private: | 213 private: |
| 215 Isolate* isolate_; | 214 Isolate* isolate_; |
| 216 ZoneScopeMode mode_; | 215 ZoneScopeMode mode_; |
| 217 }; | 216 }; |
| 218 | 217 |
| 219 | 218 |
| 219 // A zone splay tree. The config type parameter encapsulates the |
| 220 // different configurations of a concrete splay tree (see splay-tree.h). |
| 221 // The tree itself and all its elements are allocated in the Zone. |
| 222 template <typename Config> |
| 223 class ZoneSplayTree: public SplayTree<Config, ZoneListAllocationPolicy> { |
| 224 public: |
| 225 ZoneSplayTree() |
| 226 : SplayTree<Config, ZoneListAllocationPolicy>() {} |
| 227 ~ZoneSplayTree(); |
| 228 }; |
| 229 |
| 230 |
| 220 } } // namespace v8::internal | 231 } } // namespace v8::internal |
| 221 | 232 |
| 222 #endif // V8_ZONE_H_ | 233 #endif // V8_ZONE_H_ |
| OLD | NEW |