| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 class Zone { | 59 class Zone { |
| 60 public: | 60 public: |
| 61 // Allocate 'size' bytes of memory in the Zone; expands the Zone by | 61 // Allocate 'size' bytes of memory in the Zone; expands the Zone by |
| 62 // allocating new segments of memory on demand using malloc(). | 62 // allocating new segments of memory on demand using malloc(). |
| 63 inline void* New(int size); | 63 inline void* New(int size); |
| 64 | 64 |
| 65 template <typename T> | 65 template <typename T> |
| 66 inline T* NewArray(int length); | 66 inline T* NewArray(int length); |
| 67 | 67 |
| 68 // Delete all objects and free all memory allocated in the Zone. | 68 // Deletes all objects and free all memory allocated in the Zone. Keeps one |
| 69 // small (size <= kMaximumKeptSegmentSize) segment around if it finds one. |
| 69 void DeleteAll(); | 70 void DeleteAll(); |
| 70 | 71 |
| 72 // Deletes the last small segment kept around by DeleteAll(). |
| 73 void DeleteKeptSegment(); |
| 74 |
| 71 // Returns true if more memory has been allocated in zones than | 75 // Returns true if more memory has been allocated in zones than |
| 72 // the limit allows. | 76 // the limit allows. |
| 73 inline bool excess_allocation(); | 77 inline bool excess_allocation(); |
| 74 | 78 |
| 75 inline void adjust_segment_bytes_allocated(int delta); | 79 inline void adjust_segment_bytes_allocated(int delta); |
| 76 | 80 |
| 77 inline Isolate* isolate() { return isolate_; } | 81 inline Isolate* isolate() { return isolate_; } |
| 78 | 82 |
| 79 static unsigned allocation_size_; | 83 static unsigned allocation_size_; |
| 80 | 84 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 : List<T, ZoneListAllocationPolicy>(capacity) { } | 193 : List<T, ZoneListAllocationPolicy>(capacity) { } |
| 190 | 194 |
| 191 // Construct a new ZoneList by copying the elements of the given ZoneList. | 195 // Construct a new ZoneList by copying the elements of the given ZoneList. |
| 192 explicit ZoneList(const ZoneList<T>& other) | 196 explicit ZoneList(const ZoneList<T>& other) |
| 193 : List<T, ZoneListAllocationPolicy>(other.length()) { | 197 : List<T, ZoneListAllocationPolicy>(other.length()) { |
| 194 AddAll(other); | 198 AddAll(other); |
| 195 } | 199 } |
| 196 }; | 200 }; |
| 197 | 201 |
| 198 | 202 |
| 199 // Introduce a convenience type for zone lists of map handles. | |
| 200 typedef ZoneList<Handle<Map> > ZoneMapList; | |
| 201 | |
| 202 | |
| 203 // ZoneScopes keep track of the current parsing and compilation | 203 // ZoneScopes keep track of the current parsing and compilation |
| 204 // nesting and cleans up generated ASTs in the Zone when exiting the | 204 // nesting and cleans up generated ASTs in the Zone when exiting the |
| 205 // outer-most scope. | 205 // outer-most scope. |
| 206 class ZoneScope BASE_EMBEDDED { | 206 class ZoneScope BASE_EMBEDDED { |
| 207 public: | 207 public: |
| 208 INLINE(ZoneScope(Isolate* isolate, ZoneScopeMode mode)); | 208 INLINE(ZoneScope(Isolate* isolate, ZoneScopeMode mode)); |
| 209 | 209 |
| 210 virtual ~ZoneScope(); | 210 virtual ~ZoneScope(); |
| 211 | 211 |
| 212 inline bool ShouldDeleteOnExit(); | 212 inline bool ShouldDeleteOnExit(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 233 public: | 233 public: |
| 234 ZoneSplayTree() | 234 ZoneSplayTree() |
| 235 : SplayTree<Config, ZoneListAllocationPolicy>() {} | 235 : SplayTree<Config, ZoneListAllocationPolicy>() {} |
| 236 ~ZoneSplayTree(); | 236 ~ZoneSplayTree(); |
| 237 }; | 237 }; |
| 238 | 238 |
| 239 | 239 |
| 240 } } // namespace v8::internal | 240 } } // namespace v8::internal |
| 241 | 241 |
| 242 #endif // V8_ZONE_H_ | 242 #endif // V8_ZONE_H_ |
| OLD | NEW |