| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_ZONE_H_ | 5 #ifndef VM_ZONE_H_ |
| 6 #define VM_ZONE_H_ | 6 #define VM_ZONE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/handles.h" | 9 #include "vm/handles.h" |
| 10 #include "vm/memory_region.h" | 10 #include "vm/memory_region.h" |
| 11 #include "vm/utils.h" | 11 #include "vm/utils.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 // Zones support very fast allocation of small chunks of memory. The | 15 // Zones support very fast allocation of small chunks of memory. The |
| 16 // chunks cannot be deallocated individually, but instead zones | 16 // chunks cannot be deallocated individually, but instead zones |
| 17 // support deallocating all chunks in one fast operation. | 17 // support deallocating all chunks in one fast operation. |
| 18 | 18 |
| 19 class BaseZone { | 19 class BaseZone { |
| 20 public: | |
| 21 | |
| 22 private: | 20 private: |
| 23 BaseZone(); | 21 BaseZone(); |
| 24 ~BaseZone(); // Delete all memory associated with the zone. | 22 ~BaseZone(); // Delete all memory associated with the zone. |
| 25 | 23 |
| 26 // Allocate 'size' bytes of memory in the zone; expands the zone by | 24 // Allocate 'size' bytes of memory in the zone; expands the zone by |
| 27 // allocating new segments of memory on demand using 'new'. | 25 // allocating new segments of memory on demand using 'new'. |
| 28 inline uword Allocate(intptr_t size); | 26 inline uword Allocate(intptr_t size); |
| 29 | 27 |
| 30 // Allocate 'new_size' bytes of memory and copies 'old_size' bytes from | 28 // Allocate 'new_size' bytes of memory and copies 'old_size' bytes from |
| 31 // 'data' into new allocated memory. Uses current zone. | 29 // 'data' into new allocated memory. Uses current zone. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 91 |
| 94 friend class Zone; | 92 friend class Zone; |
| 95 friend class ApiZone; | 93 friend class ApiZone; |
| 96 DISALLOW_COPY_AND_ASSIGN(BaseZone); | 94 DISALLOW_COPY_AND_ASSIGN(BaseZone); |
| 97 }; | 95 }; |
| 98 | 96 |
| 99 | 97 |
| 100 class Zone : public StackResource { | 98 class Zone : public StackResource { |
| 101 public: | 99 public: |
| 102 // Create an empty zone and set is at the current zone for the Isolate. | 100 // Create an empty zone and set is at the current zone for the Isolate. |
| 103 Zone(); | 101 explicit Zone(Isolate* isolate); |
| 104 | 102 |
| 105 // Delete all memory associated with the zone. | 103 // Delete all memory associated with the zone. |
| 106 ~Zone(); | 104 ~Zone(); |
| 107 | 105 |
| 108 // Allocate 'size' bytes of memory in the zone; expands the zone by | 106 // Allocate 'size' bytes of memory in the zone; expands the zone by |
| 109 // allocating new segments of memory on demand using 'new'. | 107 // allocating new segments of memory on demand using 'new'. |
| 110 uword Allocate(intptr_t size) { return zone_.Allocate(size); } | 108 uword Allocate(intptr_t size) { return zone_.Allocate(size); } |
| 111 | 109 |
| 112 // Allocate 'new_size' bytes of memory and copies 'old_size' bytes from | 110 // Allocate 'new_size' bytes of memory and copies 'old_size' bytes from |
| 113 // 'data' into new allocated memory. Uses current zone. | 111 // 'data' into new allocated memory. Uses current zone. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 155 } |
| 158 | 156 |
| 159 // Check that the result has the proper alignment and return it. | 157 // Check that the result has the proper alignment and return it. |
| 160 ASSERT(Utils::IsAligned(result, kAlignment)); | 158 ASSERT(Utils::IsAligned(result, kAlignment)); |
| 161 return result; | 159 return result; |
| 162 } | 160 } |
| 163 | 161 |
| 164 } // namespace dart | 162 } // namespace dart |
| 165 | 163 |
| 166 #endif // VM_ZONE_H_ | 164 #endif // VM_ZONE_H_ |
| OLD | NEW |