| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // allocating new segments of memory on demand using malloc(). | 58 // allocating new segments of memory on demand using malloc(). |
| 59 static inline void* New(int size); | 59 static inline void* New(int size); |
| 60 | 60 |
| 61 // Delete all objects and free all memory allocated in the Zone. | 61 // Delete all objects and free all memory allocated in the Zone. |
| 62 static void DeleteAll(); | 62 static void DeleteAll(); |
| 63 | 63 |
| 64 // Returns true if more memory has been allocated in zones than | 64 // Returns true if more memory has been allocated in zones than |
| 65 // the limit allows. | 65 // the limit allows. |
| 66 static inline bool excess_allocation(); | 66 static inline bool excess_allocation(); |
| 67 | 67 |
| 68 static inline void adjust_segment_bytes_allocated(int delta); |
| 69 |
| 68 private: | 70 private: |
| 69 friend class Segment; | |
| 70 | 71 |
| 71 // All pointers returned from New() have this alignment. | 72 // All pointers returned from New() have this alignment. |
| 72 static const int kAlignment = kPointerSize; | 73 static const int kAlignment = kPointerSize; |
| 73 | 74 |
| 74 // Never allocate segments smaller than this size in bytes. | 75 // Never allocate segments smaller than this size in bytes. |
| 75 static const int kMinimumSegmentSize = 8 * KB; | 76 static const int kMinimumSegmentSize = 8 * KB; |
| 76 | 77 |
| 77 // Never keep segments larger than this size in bytes around. | 78 // Never keep segments larger than this size in bytes around. |
| 78 static const int kMaximumKeptSegmentSize = 64 * KB; | 79 static const int kMaximumKeptSegmentSize = 64 * KB; |
| 79 | 80 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 ~ZoneScope() { | 177 ~ZoneScope() { |
| 177 if (--nesting_ == 0 && mode_ == DELETE_ON_EXIT) Zone::DeleteAll(); | 178 if (--nesting_ == 0 && mode_ == DELETE_ON_EXIT) Zone::DeleteAll(); |
| 178 } | 179 } |
| 179 | 180 |
| 180 // For ZoneScopes that do not delete on exit by default, call this | 181 // For ZoneScopes that do not delete on exit by default, call this |
| 181 // method to request deletion on exit. | 182 // method to request deletion on exit. |
| 182 void DeleteOnExit() { | 183 void DeleteOnExit() { |
| 183 mode_ = DELETE_ON_EXIT; | 184 mode_ = DELETE_ON_EXIT; |
| 184 } | 185 } |
| 185 | 186 |
| 187 static int nesting() { return nesting_; } |
| 188 |
| 186 private: | 189 private: |
| 187 ZoneScopeMode mode_; | 190 ZoneScopeMode mode_; |
| 188 static int nesting_; | 191 static int nesting_; |
| 189 }; | 192 }; |
| 190 | 193 |
| 191 | 194 |
| 192 } } // namespace v8::internal | 195 } } // namespace v8::internal |
| 193 | 196 |
| 194 #endif // V8_ZONE_H_ | 197 #endif // V8_ZONE_H_ |
| OLD | NEW |