Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Unified Diff: runtime/vm/locations.h

Issue 10800037: New linear scan allocator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/locations.h
diff --git a/runtime/vm/locations.h b/runtime/vm/locations.h
index 27e4ee783d07467171059648a2aa09e9f66b0328..ff6a4f070b585ea1ef5d4b92f710b5422886aca2 100644
--- a/runtime/vm/locations.h
+++ b/runtime/vm/locations.h
@@ -36,7 +36,9 @@ class Location : public ValueObject {
kUnallocated = 2,
// Register location represents a fixed register.
- kRegister = 3
+ kRegister = 3,
+
+ kSpillSlot = 4
};
static const uword kInvalidLocation = 0;
@@ -69,6 +71,8 @@ class Location : public ValueObject {
// Unallocated locations.
enum Policy {
+ kAny,
+ kPrefersRegister,
kRequiresRegister,
kSameAsFirstInput,
};
@@ -77,11 +81,23 @@ class Location : public ValueObject {
return kind() == kUnallocated;
}
+ bool IsRegisterBeneficial() {
+ return !Equals(Any());
+ }
+
static Location UnallocatedLocation(Policy policy) {
return Location(kUnallocated, PolicyField::encode(policy));
}
// Any free register is suitable to replace this unallocated location.
+ static Location Any() {
+ return UnallocatedLocation(kAny);
+ }
+
+ static Location PrefersRegister() {
+ return UnallocatedLocation(kPrefersRegister);
+ }
+
static Location RequiresRegister() {
return UnallocatedLocation(kRequiresRegister);
}
@@ -116,7 +132,22 @@ class Location : public ValueObject {
return static_cast<Register>(payload());
}
+ // Spill slots.
+ static Location SpillSlot(intptr_t spill_index) {
+ return Location(kSpillSlot, static_cast<uword>(spill_index));
+ }
+
+ bool IsSpillSlot() const {
+ return kind() == kSpillSlot;
+ }
+
+ intptr_t spill_index() const {
+ ASSERT(IsSpillSlot());
+ return static_cast<uword>(payload());
+ }
+
const char* Name() const;
+ void PrintTo(BufferFormatter* f) const;
// Compare two non-constant locations.
bool Equals(Location other) const {
@@ -140,11 +171,11 @@ class Location : public ValueObject {
return KindField::decode(value_);
}
- typedef BitField<Kind, 0, 2> KindField;
- typedef BitField<uword, 2, kWordSize * kBitsPerByte - 2> PayloadField;
+ typedef BitField<Kind, 0, 3> KindField;
+ typedef BitField<uword, 3, kWordSize * kBitsPerByte - 2> PayloadField;
// Layout for kUnallocated locations payload.
- typedef BitField<Policy, 0, 1> PolicyField;
+ typedef BitField<Policy, 0, 2> PolicyField;
// Location either contains kind and payload fields or a tagged handle for
// a constant locations. Values of enumeration Kind are selected in such a

Powered by Google App Engine
This is Rietveld 408576698