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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 public: | 237 public: |
234 ZoneSplayTree() | 238 ZoneSplayTree() |
235 : SplayTree<Config, ZoneListAllocationPolicy>() {} | 239 : SplayTree<Config, ZoneListAllocationPolicy>() {} |
236 ~ZoneSplayTree(); | 240 ~ZoneSplayTree(); |
237 }; | 241 }; |
238 | 242 |
239 | 243 |
240 } } // namespace v8::internal | 244 } } // namespace v8::internal |
241 | 245 |
242 #endif // V8_ZONE_H_ | 246 #endif // V8_ZONE_H_ |
OLD | NEW |