OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 private: | 380 private: |
381 explicit Location(uword value) : value_(value) { } | 381 explicit Location(uword value) : value_(value) { } |
382 | 382 |
383 Location(Kind kind, uword payload) | 383 Location(Kind kind, uword payload) |
384 : value_(KindField::encode(kind) | PayloadField::encode(payload)) { } | 384 : value_(KindField::encode(kind) | PayloadField::encode(payload)) { } |
385 | 385 |
386 uword payload() const { | 386 uword payload() const { |
387 return PayloadField::decode(value_); | 387 return PayloadField::decode(value_); |
388 } | 388 } |
389 | 389 |
390 typedef BitField<Kind, 0, kBitsForKind> KindField; | 390 class KindField : public BitField<uword, Kind, 0, kBitsForKind> {}; |
391 typedef BitField<uword, kBitsForKind, kBitsForPayload> PayloadField; | 391 class PayloadField : |
| 392 public BitField<uword, uword, kBitsForKind, kBitsForPayload> {}; |
392 | 393 |
393 // Layout for kUnallocated locations payload. | 394 // Layout for kUnallocated locations payload. |
394 typedef BitField<Policy, 0, 3> PolicyField; | 395 typedef BitField<uword, Policy, 0, 3> PolicyField; |
395 | 396 |
396 // Layout for stack slots. | 397 // Layout for stack slots. |
397 static const intptr_t kBitsForBaseReg = 5; | 398 static const intptr_t kBitsForBaseReg = 5; |
398 static const intptr_t kBitsForStackIndex = kBitsForPayload - kBitsForBaseReg; | 399 static const intptr_t kBitsForStackIndex = kBitsForPayload - kBitsForBaseReg; |
399 typedef BitField<Register, 0, kBitsForBaseReg> StackSlotBaseField; | 400 class StackSlotBaseField : |
400 typedef BitField<intptr_t, | 401 public BitField<uword, Register, 0, kBitsForBaseReg> {}; |
401 kBitsForBaseReg, | 402 class StackIndexField : |
402 kBitsForStackIndex> StackIndexField; | 403 public BitField<uword, intptr_t, kBitsForBaseReg, kBitsForStackIndex> {}; |
403 COMPILE_ASSERT(1 << kBitsForBaseReg >= kNumberOfCpuRegisters); | 404 COMPILE_ASSERT(1 << kBitsForBaseReg >= kNumberOfCpuRegisters); |
404 | 405 |
405 static const intptr_t kStackIndexBias = | 406 static const intptr_t kStackIndexBias = |
406 static_cast<intptr_t>(1) << (kBitsForStackIndex - 1); | 407 static_cast<intptr_t>(1) << (kBitsForStackIndex - 1); |
407 | 408 |
408 // Location either contains kind and payload fields or a tagged handle for | 409 // Location either contains kind and payload fields or a tagged handle for |
409 // a constant locations. Values of enumeration Kind are selected in such a | 410 // a constant locations. Values of enumeration Kind are selected in such a |
410 // way that none of them can be interpreted as a kConstant tag. | 411 // way that none of them can be interpreted as a kConstant tag. |
411 uword value_; | 412 uword value_; |
412 }; | 413 }; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 | 710 |
710 #if defined(DEBUG) | 711 #if defined(DEBUG) |
711 intptr_t writable_inputs_; | 712 intptr_t writable_inputs_; |
712 #endif | 713 #endif |
713 }; | 714 }; |
714 | 715 |
715 | 716 |
716 } // namespace dart | 717 } // namespace dart |
717 | 718 |
718 #endif // VM_LOCATIONS_H_ | 719 #endif // VM_LOCATIONS_H_ |
OLD | NEW |