| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 // Note: The implementation is inherently not thread safe. Do not use | 52 // Note: The implementation is inherently not thread safe. Do not use |
| 53 // from multi-threaded code. | 53 // from multi-threaded code. |
| 54 | 54 |
| 55 class Zone { | 55 class Zone { |
| 56 public: | 56 public: |
| 57 // Allocate 'size' bytes of memory in the Zone; expands the Zone by | 57 // Allocate 'size' bytes of memory in the Zone; expands the Zone by |
| 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 template <typename T> |
| 62 static inline T* NewArray(int length); |
| 63 |
| 61 // Delete all objects and free all memory allocated in the Zone. | 64 // Delete all objects and free all memory allocated in the Zone. |
| 62 static void DeleteAll(); | 65 static void DeleteAll(); |
| 63 | 66 |
| 64 // Returns true if more memory has been allocated in zones than | 67 // Returns true if more memory has been allocated in zones than |
| 65 // the limit allows. | 68 // the limit allows. |
| 66 static inline bool excess_allocation(); | 69 static inline bool excess_allocation(); |
| 67 | 70 |
| 68 static inline void adjust_segment_bytes_allocated(int delta); | 71 static inline void adjust_segment_bytes_allocated(int delta); |
| 69 | 72 |
| 70 private: | 73 private: |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 194 |
| 192 private: | 195 private: |
| 193 ZoneScopeMode mode_; | 196 ZoneScopeMode mode_; |
| 194 static int nesting_; | 197 static int nesting_; |
| 195 }; | 198 }; |
| 196 | 199 |
| 197 | 200 |
| 198 } } // namespace v8::internal | 201 } } // namespace v8::internal |
| 199 | 202 |
| 200 #endif // V8_ZONE_H_ | 203 #endif // V8_ZONE_H_ |
| OLD | NEW |