OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_LOCATIONS_H_ | 5 #ifndef VM_LOCATIONS_H_ |
6 #define VM_LOCATIONS_H_ | 6 #define VM_LOCATIONS_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/bitfield.h" | 10 #include "vm/bitfield.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 // Layout for kUnallocated locations payload. | 201 // Layout for kUnallocated locations payload. |
202 typedef BitField<Policy, 0, 2> PolicyField; | 202 typedef BitField<Policy, 0, 2> PolicyField; |
203 | 203 |
204 // Location either contains kind and payload fields or a tagged handle for | 204 // Location either contains kind and payload fields or a tagged handle for |
205 // a constant locations. Values of enumeration Kind are selected in such a | 205 // a constant locations. Values of enumeration Kind are selected in such a |
206 // way that none of them can be interpreted as a kConstant tag. | 206 // way that none of them can be interpreted as a kConstant tag. |
207 uword value_; | 207 uword value_; |
208 }; | 208 }; |
209 | 209 |
210 | 210 |
211 class RegisterSet : public ValueObject { | |
212 public: | |
213 RegisterSet() : registers_(0) { | |
214 ASSERT(kNumberOfCpuRegisters < (kWordSize * kBitsPerByte)); | |
215 } | |
216 | |
217 void Add(Register reg) { | |
218 registers_ |= (1 << reg); | |
219 } | |
220 | |
221 bool Contains(Register reg) { | |
222 return (registers_ & (1 << reg)) != 0; | |
223 } | |
224 | |
225 private: | |
226 intptr_t registers_; | |
227 | |
228 DISALLOW_COPY_AND_ASSIGN(RegisterSet); | |
229 }; | |
230 | |
231 | |
211 // Specification of locations for inputs and output. | 232 // Specification of locations for inputs and output. |
212 class LocationSummary : public ZoneAllocated { | 233 class LocationSummary : public ZoneAllocated { |
213 public: | 234 public: |
214 enum ContainsCall { | 235 enum ContainsCall { |
215 kNoCall, | 236 kNoCall, |
216 kCall, | 237 kCall, |
238 kCallOnSlowPath | |
217 }; | 239 }; |
218 | 240 |
219 LocationSummary(intptr_t input_count, | 241 LocationSummary(intptr_t input_count, |
220 intptr_t temp_count, | 242 intptr_t temp_count, |
221 LocationSummary::ContainsCall contains_call); | 243 LocationSummary::ContainsCall contains_call); |
222 | 244 |
223 intptr_t input_count() const { | 245 intptr_t input_count() const { |
224 return input_locations_.length(); | 246 return input_locations_.length(); |
225 } | 247 } |
226 | 248 |
(...skipping 28 matching lines...) Expand all Loading... | |
255 } | 277 } |
256 | 278 |
257 Location out() const { | 279 Location out() const { |
258 return output_location_; | 280 return output_location_; |
259 } | 281 } |
260 | 282 |
261 Location* out_slot() { | 283 Location* out_slot() { |
262 return &output_location_; | 284 return &output_location_; |
263 } | 285 } |
264 | 286 |
265 | |
266 void set_out(Location loc) { | 287 void set_out(Location loc) { |
267 ASSERT(!is_call() || loc.IsRegister()); | 288 ASSERT(!is_call() || loc.IsRegister()); |
268 output_location_ = loc; | 289 output_location_ = loc; |
269 } | 290 } |
270 | 291 |
271 BitmapBuilder* stack_bitmap() const { return stack_bitmap_; } | 292 BitmapBuilder* stack_bitmap() const { return stack_bitmap_; } |
272 | 293 |
273 bool is_call() const { | 294 bool is_call() const { |
274 return is_call_; | 295 return contains_call_ == kCall; |
296 } | |
297 | |
298 bool contains_call() const { | |
srdjan
2012/08/15 00:12:03
I find is_call vs contains_call too similar/confus
Vyacheslav Egorov (Google)
2012/08/15 13:08:07
I rename contains_call() into can_call(), is_call
| |
299 return contains_call_ != kNoCall; | |
275 } | 300 } |
276 | 301 |
277 void PrintTo(BufferFormatter* f) const; | 302 void PrintTo(BufferFormatter* f) const; |
278 | 303 |
279 static LocationSummary* Make(intptr_t input_count, | 304 static LocationSummary* Make(intptr_t input_count, |
280 Location out, | 305 Location out, |
281 LocationSummary::ContainsCall contains_call); | 306 ContainsCall contains_call); |
307 | |
308 RegisterSet* live_registers() { | |
309 return &live_registers_; | |
310 } | |
282 | 311 |
283 private: | 312 private: |
284 // TODO(vegorov): replace with ZoneArray. | 313 // TODO(vegorov): replace with ZoneArray. |
285 GrowableArray<Location> input_locations_; | 314 GrowableArray<Location> input_locations_; |
286 GrowableArray<Location> temp_locations_; | 315 GrowableArray<Location> temp_locations_; |
287 Location output_location_; | 316 Location output_location_; |
288 BitmapBuilder* stack_bitmap_; | 317 BitmapBuilder* stack_bitmap_; |
289 const bool is_call_; | 318 |
319 const ContainsCall contains_call_; | |
320 RegisterSet live_registers_; | |
290 }; | 321 }; |
291 | 322 |
292 | 323 |
293 } // namespace dart | 324 } // namespace dart |
294 | 325 |
295 #endif // VM_LOCATIONS_H_ | 326 #endif // VM_LOCATIONS_H_ |
OLD | NEW |