[turbofan] add configuration parameters for register allocator
authordcarney@chromium.org <dcarney@chromium.org>
Thu, 30 Oct 2014 09:00:58 +0000 (09:00 +0000)
committerdcarney@chromium.org <dcarney@chromium.org>
Thu, 30 Oct 2014 09:01:47 +0000 (09:01 +0000)
T=jarin@chromium.org

BUG=
R=jarin@chromium.org

Review URL: https://codereview.chromium.org/688633002

Cr-Commit-Position: refs/heads/master@{#25008}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25008 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

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

index 6673a47..9a65ccc 100644 (file)
@@ -49,7 +49,7 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 
 
 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);
index 2be2cb1..c50736c 100644 (file)
@@ -49,7 +49,7 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 
 
 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);
index 92d3b05..0be2626 100644 (file)
@@ -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 {
index 494f91e..2184a84 100644 (file)
@@ -17,6 +17,8 @@ namespace v8 {
 namespace internal {
 namespace compiler {
 
+class Linkage;
+
 // Generates native code for a sequence of instructions.
 class CodeGenerator FINAL : public GapResolver::Assembler {
  public:
index 571a7f5..b0af2fd 100644 (file)
@@ -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"
 
index 67b933f..19f533b 100644 (file)
@@ -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 @@ void GraphC1Visualizer::PrintAllocator(const char* phase,
   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");
   }
 }
 
index f2c5fab..8d85a9d 100644 (file)
@@ -44,7 +44,7 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 
 
 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);
index 53d508a..bc2ada7 100644 (file)
@@ -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 {
index 5af2c9d..59f8073 100644 (file)
@@ -19,6 +19,7 @@ namespace compiler {
 // Forward declarations.
 struct CallBuffer;  // TODO(bmeurer): Remove this.
 class FlagsContinuation;
+class Linkage;
 
 class InstructionSelector FINAL {
  public:
index 15a01f2..8ba4b0c 100644 (file)
@@ -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:
index 3a82c11..72453ed 100644 (file)
 #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:
index 22e6760..da6d66d 100644 (file)
@@ -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"
index c32c706..807d626 100644 (file)
@@ -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 @@ class LinkageHelper {
 
   // 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 =
index dcfc78a..b586301 100644 (file)
@@ -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::GetRuntimeCallDescriptor(
 
 
 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::GetRuntimeCallDescriptor(
 
 
 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CallInterfaceDescriptor descriptor, int stack_parameter_count,
+    const CallInterfaceDescriptor& descriptor, int stack_parameter_count,
     CallDescriptor::Flags flags, Zone* zone) {
   UNIMPLEMENTED();
   return NULL;
index cc5be9b..d11fa12 100644 (file)
@@ -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 @@ class Linkage : public ZoneObject {
       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
index b9f3fa2..91fe9c3 100644 (file)
@@ -49,7 +49,7 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 
 
 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);
index fc0a432..0c79c08 100644 (file)
@@ -580,7 +580,9 @@ Handle<Code> Pipeline::GenerateCode(Linkage* linkage, PipelineData* data) {
     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);
index e65b9ff..ced88a8 100644 (file)
@@ -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 @@ LifetimePosition LiveRange::FirstIntersection(LiveRange* other) {
 }
 
 
-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 @@ void RegisterAllocator::AddInitialIntervals(const InstructionBlock* block,
 
 
 int RegisterAllocator::FixedDoubleLiveRangeID(int index) {
-  return -index - 1 - Register::kMaxNumAllocatableRegisters;
+  return -index - 1 - config().num_general_registers_;
 }
 
 
@@ -611,7 +635,7 @@ InstructionOperand* RegisterAllocator::AllocateFixed(
 
 
 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::FixedLiveRangeFor(int index) {
 
 
 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 @@ void RegisterAllocator::ProcessInstructions(const InstructionBlock* block,
       }
 
       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 @@ void RegisterAllocator::ProcessInstructions(const InstructionBlock* block,
       }
 
       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 @@ void RegisterAllocator::ResolvePhis(const InstructionBlock* block) {
 
 
 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 @@ const InstructionBlock* RegisterAllocator::GetInstructionBlock(
 
 
 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 @@ void RegisterAllocator::PopulatePointerMaps() {
   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::PopulatePointerMaps() {
 
 
 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 @@ void RegisterAllocator::AllocateRegisters() {
   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 @@ void RegisterAllocator::AllocateRegisters() {
     }
   } 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 @@ void RegisterAllocator::AllocateRegisters() {
 
 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 @@ void RegisterAllocator::InactiveToActive(LiveRange* range) {
 }
 
 
-// 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 @@ void RegisterAllocator::AllocateBlockedReg(LiveRange* current) {
     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 @@ int RegisterAllocator::RegisterCount() const { return num_registers_; }
 
 
 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();
   }
 }
index 55abd5f..40fafb1 100644 (file)
@@ -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 LiveRange FINAL : public ZoneObject {
 
 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 @@ class RegisterAllocator BASE_EMBEDDED {
   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 @@ class RegisterAllocator BASE_EMBEDDED {
   // 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 @@ class RegisterAllocator BASE_EMBEDDED {
 
   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 @@ class RegisterAllocator BASE_EMBEDDED {
   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_;
index 8175bc6..0638591 100644 (file)
@@ -63,7 +63,7 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 
 
 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);
index d41d53b..b1ebc3f 100644 (file)
@@ -42,7 +42,7 @@ void CallInterfaceDescriptorData::Initialize(
 }
 
 
-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);
index c1f374c..3e4f3e7 100644 (file)
@@ -163,7 +163,7 @@ class CallInterfaceDescriptor {
 
   static const Register ContextRegister();
 
-  const char* DebugName(Isolate* isolate);
+  const char* DebugName(Isolate* isolate) const;
 
  protected:
   const CallInterfaceDescriptorData* data() const { return data_; }
index 8ee4429..a11ac05 100644 (file)
@@ -78,7 +78,8 @@ class DeoptCodegenTester {
     }
 
     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) {
index 6935771..18a8bd8 100644 (file)
@@ -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"
index ed57513..f70ee95 100644 (file)
@@ -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"
index 4e49862..b0df9a4 100644 (file)
@@ -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 {