Reviewers: Jarin,

Message:
PTAL

Description:
[turbofan]: Fix bug in register hinting

Previously, UsePositions for Phis that are constant LiveRanges which are also
used
as hints for other USePositions would always force-allocate the first register
in
the allocatable register file to that range.

Please review this at https://codereview.chromium.org/1289313003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+29, -1 lines):
  M src/compiler/register-allocator.h
  M src/compiler/register-allocator.cc


Index: src/compiler/register-allocator.cc
diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc index 4a222a43bef66c2c22008e2a5ddbb8d2113f6a11..17985f4c9eb9dc4cf795cdfeedcaac91557754c4 100644
--- a/src/compiler/register-allocator.cc
+++ b/src/compiler/register-allocator.cc
@@ -17,6 +17,28 @@ namespace compiler {
   } while (false)


+std::ostream& operator<<(std::ostream& os, const UsePositionHintType& type) {
+  switch (type) {
+    case UsePositionHintType::kNone:
+      os << "kNone";
+      break;
+    case UsePositionHintType::kOperand:
+      os << "kOperand";
+      break;
+    case UsePositionHintType::kUsePos:
+      os << "kUsePos";
+      break;
+    case UsePositionHintType::kPhi:
+      os << "kPhi";
+      break;
+    case UsePositionHintType::kUnresolved:
+      os << "kUnresolved";
+      break;
+  }
+  return os;
+}
+
+
 namespace {

 void RemoveElement(ZoneVector<LiveRange*>* v, LiveRange* range) {
@@ -196,8 +218,11 @@ void UsePosition::ResolveHint(UsePosition* use_pos) {

void UsePosition::set_type(UsePositionType type, bool register_beneficial) { DCHECK_IMPLIES(type == UsePositionType::kRequiresSlot, !register_beneficial);
+  DCHECK_EQ(kUnassignedRegister, AssignedRegisterField::decode(flags_));
   flags_ = TypeField::encode(type) |
-           RegisterBeneficialField::encode(register_beneficial);
+           RegisterBeneficialField::encode(register_beneficial) |
+           HintTypeField::encode(HintTypeField::decode(flags_)) |
+           AssignedRegisterField::encode(kUnassignedRegister);
 }


Index: src/compiler/register-allocator.h
diff --git a/src/compiler/register-allocator.h b/src/compiler/register-allocator.h index 2e63d36e122dd11a8f5d4b9a869aef19b149a3cf..7da3093c69f7f082d698167405f501fa408de0a3 100644
--- a/src/compiler/register-allocator.h
+++ b/src/compiler/register-allocator.h
@@ -212,6 +212,9 @@ enum class UsePositionHintType : uint8_t {
 };


+std::ostream& operator<<(std::ostream& os, const UsePositionHintType& type);
+
+
 static const int32_t kUnassignedRegister =
     RegisterConfiguration::kMaxGeneralRegisters;



--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to