Revision: 25008
Author:   [email protected]
Date:     Thu Oct 30 09:00:58 2014 UTC
Log:      [turbofan] add configuration parameters for register allocator

[email protected]

BUG=
[email protected]

Review URL: https://codereview.chromium.org/688633002
https://code.google.com/p/v8/source/detail?r=25008

Modified:
 /branches/bleeding_edge/src/compiler/arm/linkage-arm.cc
 /branches/bleeding_edge/src/compiler/arm64/linkage-arm64.cc
 /branches/bleeding_edge/src/compiler/code-generator-impl.h
 /branches/bleeding_edge/src/compiler/code-generator.h
 /branches/bleeding_edge/src/compiler/common-operator.cc
 /branches/bleeding_edge/src/compiler/graph-visualizer.cc
 /branches/bleeding_edge/src/compiler/ia32/linkage-ia32.cc
 /branches/bleeding_edge/src/compiler/instruction-selector-impl.h
 /branches/bleeding_edge/src/compiler/instruction-selector.h
 /branches/bleeding_edge/src/compiler/instruction.cc
 /branches/bleeding_edge/src/compiler/instruction.h
 /branches/bleeding_edge/src/compiler/js-graph.cc
 /branches/bleeding_edge/src/compiler/linkage-impl.h
 /branches/bleeding_edge/src/compiler/linkage.cc
 /branches/bleeding_edge/src/compiler/linkage.h
 /branches/bleeding_edge/src/compiler/mips/linkage-mips.cc
 /branches/bleeding_edge/src/compiler/pipeline.cc
 /branches/bleeding_edge/src/compiler/register-allocator.cc
 /branches/bleeding_edge/src/compiler/register-allocator.h
 /branches/bleeding_edge/src/compiler/x64/linkage-x64.cc
 /branches/bleeding_edge/src/interface-descriptors.cc
 /branches/bleeding_edge/src/interface-descriptors.h
 /branches/bleeding_edge/test/cctest/compiler/test-codegen-deopt.cc
 /branches/bleeding_edge/test/cctest/compiler/test-run-machops.cc
 /branches/bleeding_edge/test/unittests/compiler/change-lowering-unittest.cc
/branches/bleeding_edge/test/unittests/compiler/instruction-selector-unittest.h

=======================================
--- /branches/bleeding_edge/src/compiler/arm/linkage-arm.cc Mon Sep 8 15:18:54 2014 UTC +++ /branches/bleeding_edge/src/compiler/arm/linkage-arm.cc Thu Oct 30 09:00:58 2014 UTC
@@ -49,7 +49,7 @@


 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CallInterfaceDescriptor descriptor, int stack_parameter_count,
+    const CallInterfaceDescriptor& descriptor, int stack_parameter_count,
     CallDescriptor::Flags flags, Zone* zone) {
   return LH::GetStubCallDescriptor(zone, descriptor, stack_parameter_count,
                                    flags);
=======================================
--- /branches/bleeding_edge/src/compiler/arm64/linkage-arm64.cc Mon Sep 8 15:18:54 2014 UTC +++ /branches/bleeding_edge/src/compiler/arm64/linkage-arm64.cc Thu Oct 30 09:00:58 2014 UTC
@@ -49,7 +49,7 @@


 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CallInterfaceDescriptor descriptor, int stack_parameter_count,
+    const CallInterfaceDescriptor& descriptor, int stack_parameter_count,
     CallDescriptor::Flags flags, Zone* zone) {
   return LH::GetStubCallDescriptor(zone, descriptor, stack_parameter_count,
                                    flags);
=======================================
--- /branches/bleeding_edge/src/compiler/code-generator-impl.h Tue Oct 14 08:51:22 2014 UTC +++ /branches/bleeding_edge/src/compiler/code-generator-impl.h Thu Oct 30 09:00:58 2014 UTC
@@ -5,10 +5,12 @@
 #ifndef V8_COMPILER_CODE_GENERATOR_IMPL_H_
 #define V8_COMPILER_CODE_GENERATOR_IMPL_H_

+#include "src/code-stubs.h"
 #include "src/compiler/code-generator.h"
 #include "src/compiler/instruction.h"
 #include "src/compiler/linkage.h"
 #include "src/compiler/opcodes.h"
+#include "src/macro-assembler.h"

 namespace v8 {
 namespace internal {
=======================================
--- /branches/bleeding_edge/src/compiler/code-generator.h Mon Oct 27 12:39:20 2014 UTC +++ /branches/bleeding_edge/src/compiler/code-generator.h Thu Oct 30 09:00:58 2014 UTC
@@ -17,6 +17,8 @@
 namespace internal {
 namespace compiler {

+class Linkage;
+
 // Generates native code for a sequence of instructions.
 class CodeGenerator FINAL : public GapResolver::Assembler {
  public:
=======================================
--- /branches/bleeding_edge/src/compiler/common-operator.cc Wed Oct 29 14:40:47 2014 UTC +++ /branches/bleeding_edge/src/compiler/common-operator.cc Thu Oct 30 09:00:58 2014 UTC
@@ -7,6 +7,8 @@
 #include "src/assembler.h"
 #include "src/base/lazy-instance.h"
 #include "src/compiler/linkage.h"
+#include "src/compiler/opcodes.h"
+#include "src/compiler/operator.h"
 #include "src/unique.h"
 #include "src/zone.h"

=======================================
--- /branches/bleeding_edge/src/compiler/graph-visualizer.cc Wed Oct 29 18:46:44 2014 UTC +++ /branches/bleeding_edge/src/compiler/graph-visualizer.cc Thu Oct 30 09:00:58 2014 UTC
@@ -7,6 +7,7 @@
 #include <sstream>
 #include <string>

+#include "src/code-stubs.h"
 #include "src/compiler/generic-algorithm.h"
 #include "src/compiler/generic-node.h"
 #include "src/compiler/generic-node-inl.h"
@@ -673,19 +674,16 @@
   Tag tag(this, "intervals");
   PrintStringProperty("name", phase);

- const Vector<LiveRange*>* fixed_d = allocator->fixed_double_live_ranges();
-  for (int i = 0; i < fixed_d->length(); ++i) {
-    PrintLiveRange(fixed_d->at(i), "fixed");
+  for (auto range : allocator->fixed_double_live_ranges()) {
+    PrintLiveRange(range, "fixed");
   }

-  const Vector<LiveRange*>* fixed = allocator->fixed_live_ranges();
-  for (int i = 0; i < fixed->length(); ++i) {
-    PrintLiveRange(fixed->at(i), "fixed");
+  for (auto range : allocator->fixed_live_ranges()) {
+    PrintLiveRange(range, "fixed");
   }

-  const ZoneList<LiveRange*>* live_ranges = allocator->live_ranges();
-  for (int i = 0; i < live_ranges->length(); ++i) {
-    PrintLiveRange(live_ranges->at(i), "object");
+  for (auto range : allocator->live_ranges()) {
+    PrintLiveRange(range, "object");
   }
 }

=======================================
--- /branches/bleeding_edge/src/compiler/ia32/linkage-ia32.cc Mon Sep 8 15:18:54 2014 UTC +++ /branches/bleeding_edge/src/compiler/ia32/linkage-ia32.cc Thu Oct 30 09:00:58 2014 UTC
@@ -44,7 +44,7 @@


 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CallInterfaceDescriptor descriptor, int stack_parameter_count,
+    const CallInterfaceDescriptor& descriptor, int stack_parameter_count,
     CallDescriptor::Flags flags, Zone* zone) {
   return LH::GetStubCallDescriptor(zone, descriptor, stack_parameter_count,
                                    flags);
=======================================
--- /branches/bleeding_edge/src/compiler/instruction-selector-impl.h Mon Oct 27 22:33:52 2014 UTC +++ /branches/bleeding_edge/src/compiler/instruction-selector-impl.h Thu Oct 30 09:00:58 2014 UTC
@@ -9,6 +9,7 @@
 #include "src/compiler/instruction.h"
 #include "src/compiler/instruction-selector.h"
 #include "src/compiler/linkage.h"
+#include "src/macro-assembler.h"

 namespace v8 {
 namespace internal {
=======================================
--- /branches/bleeding_edge/src/compiler/instruction-selector.h Sun Oct 26 10:24:49 2014 UTC +++ /branches/bleeding_edge/src/compiler/instruction-selector.h Thu Oct 30 09:00:58 2014 UTC
@@ -19,6 +19,7 @@
 // Forward declarations.
 struct CallBuffer;  // TODO(bmeurer): Remove this.
 class FlagsContinuation;
+class Linkage;

 class InstructionSelector FINAL {
  public:
=======================================
--- /branches/bleeding_edge/src/compiler/instruction.cc Mon Oct 27 22:33:52 2014 UTC +++ /branches/bleeding_edge/src/compiler/instruction.cc Thu Oct 30 09:00:58 2014 UTC
@@ -2,16 +2,20 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

-#include "src/compiler/instruction.h"
-
 #include "src/compiler/common-operator.h"
 #include "src/compiler/generic-node-inl.h"
 #include "src/compiler/graph.h"
+#include "src/compiler/instruction.h"
+#include "src/macro-assembler.h"

 namespace v8 {
 namespace internal {
 namespace compiler {

+STATIC_ASSERT(kMaxGeneralRegisters >= Register::kNumRegisters);
+STATIC_ASSERT(kMaxDoubleRegisters >= DoubleRegister::kMaxNumRegisters);
+
+
 std::ostream& operator<<(std::ostream& os, const InstructionOperand& op) {
   switch (op.kind()) {
     case InstructionOperand::INVALID:
=======================================
--- /branches/bleeding_edge/src/compiler/instruction.h Fri Oct 24 09:36:40 2014 UTC +++ /branches/bleeding_edge/src/compiler/instruction.h Thu Oct 30 09:00:58 2014 UTC
@@ -16,30 +16,29 @@
 #include "src/compiler/opcodes.h"
 #include "src/compiler/schedule.h"
 #include "src/compiler/source-position.h"
-// TODO(titzer): don't include the macro-assembler?
-#include "src/macro-assembler.h"
 #include "src/zone-allocator.h"

 namespace v8 {
 namespace internal {
 namespace compiler {

-// Forward declarations.
-class Linkage;
-
 // A couple of reserved opcodes are used for internal use.
 const InstructionCode kGapInstruction = -1;
 const InstructionCode kBlockStartInstruction = -2;
 const InstructionCode kSourcePositionInstruction = -3;

+// Platform independent maxes.
+static const int kMaxGeneralRegisters = 32;
+static const int kMaxDoubleRegisters = 32;

-#define INSTRUCTION_OPERAND_LIST(V)              \
-  V(Constant, CONSTANT, 0)                       \
-  V(Immediate, IMMEDIATE, 0)                     \
-  V(StackSlot, STACK_SLOT, 128)                  \
-  V(DoubleStackSlot, DOUBLE_STACK_SLOT, 128)     \
-  V(Register, REGISTER, Register::kNumRegisters) \
-  V(DoubleRegister, DOUBLE_REGISTER, DoubleRegister::kMaxNumRegisters)
+
+#define INSTRUCTION_OPERAND_LIST(V)           \
+  V(Constant, CONSTANT, 0)                    \
+  V(Immediate, IMMEDIATE, 0)                  \
+  V(StackSlot, STACK_SLOT, 128)               \
+  V(DoubleStackSlot, DOUBLE_STACK_SLOT, 128)  \
+  V(Register, REGISTER, kMaxGeneralRegisters) \
+  V(DoubleRegister, DOUBLE_REGISTER, kMaxDoubleRegisters)

 class InstructionOperand : public ZoneObject {
  public:
=======================================
--- /branches/bleeding_edge/src/compiler/js-graph.cc Wed Oct 15 12:29:39 2014 UTC +++ /branches/bleeding_edge/src/compiler/js-graph.cc Thu Oct 30 09:00:58 2014 UTC
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

+#include "src/code-stubs.h"
 #include "src/compiler/js-graph.h"
 #include "src/compiler/node-properties-inl.h"
 #include "src/compiler/typer.h"
=======================================
--- /branches/bleeding_edge/src/compiler/linkage-impl.h Mon Sep 8 15:18:54 2014 UTC +++ /branches/bleeding_edge/src/compiler/linkage-impl.h Thu Oct 30 09:00:58 2014 UTC
@@ -5,6 +5,8 @@
 #ifndef V8_COMPILER_LINKAGE_IMPL_H_
 #define V8_COMPILER_LINKAGE_IMPL_H_

+#include "src/code-stubs.h"
+
 namespace v8 {
 namespace internal {
 namespace compiler {
@@ -129,8 +131,8 @@

   // TODO(turbofan): cache call descriptors for code stub calls.
   static CallDescriptor* GetStubCallDescriptor(
- Zone* zone, CallInterfaceDescriptor descriptor, int stack_parameter_count,
-      CallDescriptor::Flags flags) {
+      Zone* zone, const CallInterfaceDescriptor& descriptor,
+      int stack_parameter_count, CallDescriptor::Flags flags) {
     const int register_parameter_count =
         descriptor.GetEnvironmentParameterCount();
     const int js_parameter_count =
=======================================
--- /branches/bleeding_edge/src/compiler/linkage.cc Wed Oct 29 18:16:15 2014 UTC +++ /branches/bleeding_edge/src/compiler/linkage.cc Thu Oct 30 09:00:58 2014 UTC
@@ -2,10 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

-#include "src/compiler/linkage.h"
-
 #include "src/code-stubs.h"
 #include "src/compiler.h"
+#include "src/compiler/linkage.h"
 #include "src/compiler/node.h"
 #include "src/compiler/pipeline.h"
 #include "src/scopes.h"
@@ -102,7 +101,7 @@


 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CallInterfaceDescriptor descriptor, int stack_parameter_count,
+    const CallInterfaceDescriptor& descriptor, int stack_parameter_count,
     CallDescriptor::Flags flags) const {
return GetStubCallDescriptor(descriptor, stack_parameter_count, flags, zone_);
 }
@@ -233,7 +232,7 @@


 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CallInterfaceDescriptor descriptor, int stack_parameter_count,
+    const CallInterfaceDescriptor& descriptor, int stack_parameter_count,
     CallDescriptor::Flags flags, Zone* zone) {
   UNIMPLEMENTED();
   return NULL;
=======================================
--- /branches/bleeding_edge/src/compiler/linkage.h Mon Oct 27 12:39:20 2014 UTC +++ /branches/bleeding_edge/src/compiler/linkage.h Thu Oct 30 09:00:58 2014 UTC
@@ -6,15 +6,16 @@
 #define V8_COMPILER_LINKAGE_H_

 #include "src/base/flags.h"
-#include "src/code-stubs.h"
 #include "src/compiler/frame.h"
 #include "src/compiler/machine-type.h"
-#include "src/compiler/node.h"
 #include "src/compiler/operator.h"
 #include "src/zone.h"

 namespace v8 {
 namespace internal {
+
+class CallInterfaceDescriptor;
+
 namespace compiler {

 // Describes the location for a parameter or a return value to a call.
@@ -183,10 +184,10 @@
       Operator::Properties properties, Zone* zone);

   CallDescriptor* GetStubCallDescriptor(
-      CallInterfaceDescriptor descriptor, int stack_parameter_count = 0,
+ const CallInterfaceDescriptor& descriptor, int stack_parameter_count = 0,
       CallDescriptor::Flags flags = CallDescriptor::kNoFlags) const;
   static CallDescriptor* GetStubCallDescriptor(
-      CallInterfaceDescriptor descriptor, int stack_parameter_count,
+      const CallInterfaceDescriptor& descriptor, int stack_parameter_count,
       CallDescriptor::Flags flags, Zone* zone);

   // Creates a call descriptor for simplified C calls that is appropriate
=======================================
--- /branches/bleeding_edge/src/compiler/mips/linkage-mips.cc Thu Oct 2 15:48:48 2014 UTC +++ /branches/bleeding_edge/src/compiler/mips/linkage-mips.cc Thu Oct 30 09:00:58 2014 UTC
@@ -49,7 +49,7 @@


 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CallInterfaceDescriptor descriptor, int stack_parameter_count,
+    const CallInterfaceDescriptor& descriptor, int stack_parameter_count,
     CallDescriptor::Flags flags, Zone* zone) {
   return LH::GetStubCallDescriptor(zone, descriptor, stack_parameter_count,
                                    flags);
=======================================
--- /branches/bleeding_edge/src/compiler/pipeline.cc Wed Oct 29 15:27:27 2014 UTC +++ /branches/bleeding_edge/src/compiler/pipeline.cc Thu Oct 30 09:00:58 2014 UTC
@@ -580,7 +580,9 @@
     debug_name = GetDebugName(info());
 #endif

-    RegisterAllocator allocator(zone_scope.zone(), &frame, &sequence,
+
+    RegisterAllocator allocator(RegisterAllocator::PlatformConfig(),
+                                zone_scope.zone(), &frame, &sequence,
                                 debug_name.get());
     if (!allocator.Allocate(data->pipeline_statistics())) {
       info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc);
=======================================
--- /branches/bleeding_edge/src/compiler/register-allocator.cc Wed Oct 29 12:34:51 2014 UTC +++ /branches/bleeding_edge/src/compiler/register-allocator.cc Thu Oct 30 09:00:58 2014 UTC
@@ -5,6 +5,7 @@
 #include "src/compiler/linkage.h"
 #include "src/compiler/pipeline-statistics.h"
 #include "src/compiler/register-allocator.h"
+#include "src/macro-assembler.h"  // TODO(dcarney): remove this.
 #include "src/string-stream.h"

 namespace v8 {
@@ -506,24 +507,47 @@
 }


-RegisterAllocator::RegisterAllocator(Zone* local_zone, Frame* frame,
-                                     InstructionSequence* code,
+RegisterAllocator::Config RegisterAllocator::PlatformConfig() {
+  DCHECK_EQ(Register::kMaxNumAllocatableRegisters,
+            Register::NumAllocatableRegisters());
+  Config config;
+  config.num_general_registers_ = Register::kMaxNumAllocatableRegisters;
+ config.num_double_registers_ = DoubleRegister::kMaxNumAllocatableRegisters;
+  config.num_aliased_double_registers_ =
+      DoubleRegister::NumAllocatableAliasedRegisters();
+  config.GeneralRegisterName = Register::AllocationIndexToString;
+  config.DoubleRegisterName = DoubleRegister::AllocationIndexToString;
+  return config;
+}
+
+
+RegisterAllocator::RegisterAllocator(const Config& config, Zone* local_zone, + Frame* frame, InstructionSequence* code,
                                      const char* debug_name)
     : zone_(local_zone),
       frame_(frame),
       code_(code),
       debug_name_(debug_name),
+      config_(config),
       live_in_sets_(code->InstructionBlockCount(), zone()),
       live_ranges_(code->VirtualRegisterCount() * 2, zone()),
-      fixed_live_ranges_(NULL),
-      fixed_double_live_ranges_(NULL),
+ fixed_live_ranges_(this->config().num_general_registers_, NULL, zone()),
+      fixed_double_live_ranges_(this->config().num_double_registers_, NULL,
+                                zone()),
       unhandled_live_ranges_(code->VirtualRegisterCount() * 2, zone()),
       active_live_ranges_(8, zone()),
       inactive_live_ranges_(8, zone()),
       reusable_slots_(8, zone()),
       mode_(UNALLOCATED_REGISTERS),
       num_registers_(-1),
-      allocation_ok_(true) {}
+      allocation_ok_(true) {
+  DCHECK(this->config().num_general_registers_ <= kMaxGeneralRegisters);
+  DCHECK(this->config().num_double_registers_ <= kMaxDoubleRegisters);
+  // TryAllocateFreeReg and AllocateBlockedReg assume this
+  // when allocating local arrays.
+  DCHECK(this->config().num_double_registers_ >=
+         this->config().num_general_registers_);
+}


 void RegisterAllocator::InitializeLivenessAnalysis() {
@@ -579,7 +603,7 @@


 int RegisterAllocator::FixedDoubleLiveRangeID(int index) {
-  return -index - 1 - Register::kMaxNumAllocatableRegisters;
+  return -index - 1 - config().num_general_registers_;
 }


@@ -611,7 +635,7 @@


 LiveRange* RegisterAllocator::FixedLiveRangeFor(int index) {
-  DCHECK(index < Register::kMaxNumAllocatableRegisters);
+  DCHECK(index < config().num_general_registers_);
   LiveRange* result = fixed_live_ranges_[index];
   if (result == NULL) {
     // TODO(titzer): add a utility method to allocate a new LiveRange:
@@ -629,7 +653,7 @@


 LiveRange* RegisterAllocator::FixedDoubleLiveRangeFor(int index) {
-  DCHECK(index < DoubleRegister::NumAllocatableAliasedRegisters());
+  DCHECK(index < config().num_aliased_double_registers_);
   LiveRange* result = fixed_double_live_ranges_[index];
   if (result == NULL) {
result = new (zone()) LiveRange(FixedDoubleLiveRangeID(index), code_zone());
@@ -1007,7 +1031,7 @@
       }

       if (instr->ClobbersRegisters()) {
-        for (int i = 0; i < Register::kMaxNumAllocatableRegisters; ++i) {
+        for (int i = 0; i < config().num_general_registers_; ++i) {
           if (!IsOutputRegisterOf(instr, i)) {
             LiveRange* range = FixedLiveRangeFor(i);
range->AddUseInterval(curr_position, curr_position.InstructionEnd(),
@@ -1017,8 +1041,7 @@
       }

       if (instr->ClobbersDoubleRegisters()) {
- for (int i = 0; i < DoubleRegister::NumAllocatableAliasedRegisters();
-             ++i) {
+        for (int i = 0; i < config().num_aliased_double_registers_; ++i) {
           if (!IsOutputDoubleRegisterOf(instr, i)) {
             LiveRange* range = FixedDoubleLiveRangeFor(i);
range->AddUseInterval(curr_position, curr_position.InstructionEnd(),
@@ -1103,10 +1126,10 @@


 bool RegisterAllocator::Allocate(PipelineStatistics* stats) {
-  assigned_registers_ = new (code_zone())
-      BitVector(Register::NumAllocatableRegisters(), code_zone());
+  assigned_registers_ =
+ new (code_zone()) BitVector(config().num_general_registers_, code_zone());
   assigned_double_registers_ = new (code_zone())
- BitVector(DoubleRegister::NumAllocatableAliasedRegisters(), code_zone());
+      BitVector(config().num_aliased_double_registers_, code_zone());
   {
     PhaseScope phase_scope(stats, "meet register constraints");
     MeetRegisterConstraints();
@@ -1235,8 +1258,8 @@


 void RegisterAllocator::ConnectRanges() {
-  for (int i = 0; i < live_ranges()->length(); ++i) {
-    LiveRange* first_range = live_ranges()->at(i);
+  for (int i = 0; i < live_ranges().length(); ++i) {
+    LiveRange* first_range = live_ranges().at(i);
     if (first_range == NULL || first_range->parent() != NULL) continue;

     LiveRange* second_range = first_range->next();
@@ -1437,8 +1460,8 @@
   int last_range_start = 0;
   const PointerMapDeque* pointer_maps = code()->pointer_maps();
   PointerMapDeque::const_iterator first_it = pointer_maps->begin();
- for (int range_idx = 0; range_idx < live_ranges()->length(); ++range_idx) {
-    LiveRange* range = live_ranges()->at(range_idx);
+ for (int range_idx = 0; range_idx < live_ranges().length(); ++range_idx) {
+    LiveRange* range = live_ranges().at(range_idx);
     if (range == NULL) continue;
     // Iterate over the first parts of multi-part live ranges.
     if (range->parent() != NULL) continue;
@@ -1512,14 +1535,14 @@


 void RegisterAllocator::AllocateGeneralRegisters() {
-  num_registers_ = Register::NumAllocatableRegisters();
+  num_registers_ = config().num_general_registers_;
   mode_ = GENERAL_REGISTERS;
   AllocateRegisters();
 }


 void RegisterAllocator::AllocateDoubleRegisters() {
-  num_registers_ = DoubleRegister::NumAllocatableAliasedRegisters();
+  num_registers_ = config().num_aliased_double_registers_;
   mode_ = DOUBLE_REGISTERS;
   AllocateRegisters();
 }
@@ -1543,7 +1566,7 @@
   DCHECK(inactive_live_ranges_.is_empty());

   if (mode_ == DOUBLE_REGISTERS) {
- for (int i = 0; i < DoubleRegister::NumAllocatableAliasedRegisters(); ++i) {
+    for (int i = 0; i < config().num_aliased_double_registers_; ++i) {
       LiveRange* current = fixed_double_live_ranges_.at(i);
       if (current != NULL) {
         AddToInactive(current);
@@ -1551,8 +1574,7 @@
     }
   } else {
     DCHECK(mode_ == GENERAL_REGISTERS);
-    for (int i = 0; i < fixed_live_ranges_.length(); ++i) {
-      LiveRange* current = fixed_live_ranges_.at(i);
+    for (auto current : fixed_live_ranges()) {
       if (current != NULL) {
         AddToInactive(current);
       }
@@ -1636,9 +1658,9 @@

 const char* RegisterAllocator::RegisterName(int allocation_index) {
   if (mode_ == GENERAL_REGISTERS) {
-    return Register::AllocationIndexToString(allocation_index);
+    return config().GeneralRegisterName(allocation_index);
   } else {
-    return DoubleRegister::AllocationIndexToString(allocation_index);
+    return config().DoubleRegisterName(allocation_index);
   }
 }

@@ -1782,14 +1804,8 @@
 }


-// TryAllocateFreeReg and AllocateBlockedReg assume this
-// when allocating local arrays.
-STATIC_ASSERT(DoubleRegister::kMaxNumAllocatableRegisters >=
-              Register::kMaxNumAllocatableRegisters);
-
-
 bool RegisterAllocator::TryAllocateFreeReg(LiveRange* current) {
- LifetimePosition free_until_pos[DoubleRegister::kMaxNumAllocatableRegisters];
+  LifetimePosition free_until_pos[kMaxDoubleRegisters];

   for (int i = 0; i < num_registers_; i++) {
     free_until_pos[i] = LifetimePosition::MaxPosition();
@@ -1872,9 +1888,8 @@
     return;
   }

-
-  LifetimePosition use_pos[DoubleRegister::kMaxNumAllocatableRegisters];
-  LifetimePosition block_pos[DoubleRegister::kMaxNumAllocatableRegisters];
+  LifetimePosition use_pos[kMaxGeneralRegisters];
+  LifetimePosition block_pos[kMaxDoubleRegisters];

   for (int i = 0; i < num_registers_; i++) {
     use_pos[i] = block_pos[i] = LifetimePosition::MaxPosition();
@@ -2187,8 +2202,7 @@


 void RegisterAllocator::Verify() const {
-  for (int i = 0; i < live_ranges()->length(); ++i) {
-    LiveRange* current = live_ranges()->at(i);
+  for (auto current : live_ranges()) {
     if (current != NULL) current->Verify();
   }
 }
=======================================
--- /branches/bleeding_edge/src/compiler/register-allocator.h Wed Oct 29 12:34:51 2014 UTC +++ /branches/bleeding_edge/src/compiler/register-allocator.h Thu Oct 30 09:00:58 2014 UTC
@@ -5,10 +5,8 @@
 #ifndef V8_REGISTER_ALLOCATOR_H_
 #define V8_REGISTER_ALLOCATOR_H_

-#include "src/allocation.h"
 #include "src/compiler/instruction.h"
-#include "src/macro-assembler.h"
-#include "src/zone.h"
+#include "src/zone-containers.h"

 namespace v8 {
 namespace internal {
@@ -321,8 +319,19 @@

 class RegisterAllocator BASE_EMBEDDED {
  public:
-  explicit RegisterAllocator(Zone* local_zone, Frame* frame,
-                             InstructionSequence* code,
+  class Config {
+   public:
+    int num_general_registers_;
+    int num_double_registers_;
+    int num_aliased_double_registers_;
+    const char* (*GeneralRegisterName)(int allocation_index);
+    const char* (*DoubleRegisterName)(int allocation_index);
+  };
+
+  static Config PlatformConfig();
+
+  explicit RegisterAllocator(const Config& config, Zone* local_zone,
+                             Frame* frame, InstructionSequence* code,
                              const char* debug_name = nullptr);

   bool Allocate(PipelineStatistics* stats = NULL);
@@ -330,12 +339,12 @@
   BitVector* assigned_registers() { return assigned_registers_; }
BitVector* assigned_double_registers() { return assigned_double_registers_; }

-  const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; }
-  const Vector<LiveRange*>* fixed_live_ranges() const {
-    return &fixed_live_ranges_;
+  const ZoneList<LiveRange*>& live_ranges() const { return live_ranges_; }
+  const ZoneVector<LiveRange*>& fixed_live_ranges() const {
+    return fixed_live_ranges_;
   }
-  const Vector<LiveRange*>* fixed_double_live_ranges() const {
-    return &fixed_double_live_ranges_;
+  const ZoneVector<LiveRange*>& fixed_double_live_ranges() const {
+    return fixed_double_live_ranges_;
   }
   InstructionSequence* code() const { return code_; }

@@ -481,7 +490,7 @@
   // Helper methods for the fixed registers.
   int RegisterCount() const;
   static int FixedLiveRangeID(int index) { return -index - 1; }
-  static int FixedDoubleLiveRangeID(int index);
+  int FixedDoubleLiveRangeID(int index);
   LiveRange* FixedLiveRangeFor(int index);
   LiveRange* FixedDoubleLiveRangeFor(int index);
   LiveRange* LiveRangeFor(int index);
@@ -493,12 +502,15 @@

   Frame* frame() const { return frame_; }
   const char* debug_name() const { return debug_name_; }
+  const Config& config() const { return config_; }

   Zone* const zone_;
   Frame* const frame_;
   InstructionSequence* const code_;
   const char* const debug_name_;

+  const Config config_;
+
   // During liveness analysis keep a mapping from block id to live_in sets
   // for blocks already analyzed.
   ZoneList<BitVector*> live_in_sets_;
@@ -507,10 +519,8 @@
   ZoneList<LiveRange*> live_ranges_;

   // Lists of live ranges
-  EmbeddedVector<LiveRange*, Register::kMaxNumAllocatableRegisters>
-      fixed_live_ranges_;
-  EmbeddedVector<LiveRange*, DoubleRegister::kMaxNumAllocatableRegisters>
-      fixed_double_live_ranges_;
+  ZoneVector<LiveRange*> fixed_live_ranges_;
+  ZoneVector<LiveRange*> fixed_double_live_ranges_;
   ZoneList<LiveRange*> unhandled_live_ranges_;
   ZoneList<LiveRange*> active_live_ranges_;
   ZoneList<LiveRange*> inactive_live_ranges_;
=======================================
--- /branches/bleeding_edge/src/compiler/x64/linkage-x64.cc Mon Sep 8 15:18:54 2014 UTC +++ /branches/bleeding_edge/src/compiler/x64/linkage-x64.cc Thu Oct 30 09:00:58 2014 UTC
@@ -63,7 +63,7 @@


 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CallInterfaceDescriptor descriptor, int stack_parameter_count,
+    const CallInterfaceDescriptor& descriptor, int stack_parameter_count,
     CallDescriptor::Flags flags, Zone* zone) {
   return LH::GetStubCallDescriptor(zone, descriptor, stack_parameter_count,
                                    flags);
=======================================
--- /branches/bleeding_edge/src/interface-descriptors.cc Tue Sep 30 14:54:14 2014 UTC +++ /branches/bleeding_edge/src/interface-descriptors.cc Thu Oct 30 09:00:58 2014 UTC
@@ -42,7 +42,7 @@
 }


-const char* CallInterfaceDescriptor::DebugName(Isolate* isolate) {
+const char* CallInterfaceDescriptor::DebugName(Isolate* isolate) const {
   CallInterfaceDescriptorData* start = isolate->call_descriptor_data(0);
   size_t index = data_ - start;
   DCHECK(index < CallDescriptors::NUMBER_OF_DESCRIPTORS);
=======================================
--- /branches/bleeding_edge/src/interface-descriptors.h Tue Sep 30 14:54:14 2014 UTC +++ /branches/bleeding_edge/src/interface-descriptors.h Thu Oct 30 09:00:58 2014 UTC
@@ -163,7 +163,7 @@

   static const Register ContextRegister();

-  const char* DebugName(Isolate* isolate);
+  const char* DebugName(Isolate* isolate) const;

  protected:
   const CallInterfaceDescriptorData* data() const { return data_; }
=======================================
--- /branches/bleeding_edge/test/cctest/compiler/test-codegen-deopt.cc Wed Oct 29 12:34:51 2014 UTC +++ /branches/bleeding_edge/test/cctest/compiler/test-codegen-deopt.cc Thu Oct 30 09:00:58 2014 UTC
@@ -78,7 +78,8 @@
     }

     Frame frame;
-    RegisterAllocator allocator(scope_->main_zone(), &frame, code);
+    RegisterAllocator allocator(RegisterAllocator::PlatformConfig(),
+                                scope_->main_zone(), &frame, code);
     CHECK(allocator.Allocate());

     if (FLAG_trace_turbo) {
=======================================
--- /branches/bleeding_edge/test/cctest/compiler/test-run-machops.cc Mon Oct 27 22:33:52 2014 UTC +++ /branches/bleeding_edge/test/cctest/compiler/test-run-machops.cc Thu Oct 30 09:00:58 2014 UTC
@@ -6,6 +6,7 @@
 #include <limits>

 #include "src/base/bits.h"
+#include "src/codegen.h"
 #include "src/compiler/generic-node-inl.h"
 #include "test/cctest/cctest.h"
 #include "test/cctest/compiler/codegen-tester.h"
=======================================
--- /branches/bleeding_edge/test/unittests/compiler/change-lowering-unittest.cc Mon Oct 27 12:39:20 2014 UTC +++ /branches/bleeding_edge/test/unittests/compiler/change-lowering-unittest.cc Thu Oct 30 09:00:58 2014 UTC
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

+#include "src/code-stubs.h"
 #include "src/compiler/change-lowering.h"
 #include "src/compiler/js-graph.h"
 #include "src/compiler/node-properties-inl.h"
=======================================
--- /branches/bleeding_edge/test/unittests/compiler/instruction-selector-unittest.h Fri Oct 24 09:36:40 2014 UTC +++ /branches/bleeding_edge/test/unittests/compiler/instruction-selector-unittest.h Thu Oct 30 09:00:58 2014 UTC
@@ -11,6 +11,7 @@
 #include "src/base/utils/random-number-generator.h"
 #include "src/compiler/instruction-selector.h"
 #include "src/compiler/raw-machine-assembler.h"
+#include "src/macro-assembler.h"
 #include "test/unittests/test-utils.h"

 namespace v8 {

--
--
v8-dev mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to