| 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" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 127 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 BaseZone zone_; | 130 BaseZone zone_; |
| 131 | 131 |
| 132 // Structure for managing handles allocation. | 132 // Structure for managing handles allocation. |
| 133 VMHandles handles_; | 133 VMHandles handles_; |
| 134 | 134 |
| 135 // Used for chaining zones in order to allow unwinding of stacks. | 135 // Used for chaining zones in order to allow unwinding of stacks. |
| 136 Zone* previous_; | 136 Zone* previous_; |
| 137 DISALLOW_COPY_AND_ASSIGN(Zone); | 137 DISALLOW_IMPLICIT_CONSTRUCTORS(Zone); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 | 140 |
| 141 inline uword BaseZone::Allocate(intptr_t size) { | 141 inline uword BaseZone::Allocate(intptr_t size) { |
| 142 ASSERT(size >= 0); | 142 ASSERT(size >= 0); |
| 143 | 143 |
| 144 // Round up the requested size to fit the alignment. | 144 // Round up the requested size to fit the alignment. |
| 145 size = Utils::RoundUp(size, kAlignment); | 145 size = Utils::RoundUp(size, kAlignment); |
| 146 | 146 |
| 147 // Check if the requested size is available without expanding. | 147 // Check if the requested size is available without expanding. |
| 148 uword result; | 148 uword result; |
| 149 intptr_t free_size = (limit_ - position_); | 149 intptr_t free_size = (limit_ - position_); |
| 150 if (free_size >= size) { | 150 if (free_size >= size) { |
| 151 result = position_; | 151 result = position_; |
| 152 position_ += size; | 152 position_ += size; |
| 153 } else { | 153 } else { |
| 154 result = AllocateExpand(size); | 154 result = AllocateExpand(size); |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Check that the result has the proper alignment and return it. | 157 // Check that the result has the proper alignment and return it. |
| 158 ASSERT(Utils::IsAligned(result, kAlignment)); | 158 ASSERT(Utils::IsAligned(result, kAlignment)); |
| 159 return result; | 159 return result; |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace dart | 162 } // namespace dart |
| 163 | 163 |
| 164 #endif // VM_ZONE_H_ | 164 #endif // VM_ZONE_H_ |
| OLD | NEW |