From: rmcilroy Date: Tue, 21 Jul 2015 15:54:16 +0000 (-0700) Subject: [turbofan] Change RawMachineAssembler to take a CallDescriptor instead of a MachineSi... X-Git-Tag: upstream/4.7.83~1263 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fbe085fd754845d281c5f9adcae15beda8155fef;p=platform%2Fupstream%2Fv8.git [turbofan] Change RawMachineAssembler to take a CallDescriptor instead of a MachineSignature. The InterpreterAssembler needs to specify a specific CallDescriptor type instead of using the SimplifiedCDescriptor type. This CL makes it possible to specify the CallDescriptor used by the RawMachineAssembler instead of specifying a MachineSignature. Also removes instruction-selector-tester.h which was erroneously resurrected at some point. BUG=v8:4280 LOG=N Review URL: https://codereview.chromium.org/1235313002 Cr-Commit-Position: refs/heads/master@{#29777} --- diff --git a/src/compiler/raw-machine-assembler.cc b/src/compiler/raw-machine-assembler.cc index 3e87ef5..1a3d649 100644 --- a/src/compiler/raw-machine-assembler.cc +++ b/src/compiler/raw-machine-assembler.cc @@ -12,16 +12,14 @@ namespace internal { namespace compiler { RawMachineAssembler::RawMachineAssembler(Isolate* isolate, Graph* graph, - const MachineSignature* machine_sig, + CallDescriptor* call_descriptor, MachineType word, MachineOperatorBuilder::Flags flags) : GraphBuilder(isolate, graph), schedule_(new (zone()) Schedule(zone())), machine_(zone(), word, flags), common_(zone()), - machine_sig_(machine_sig), - call_descriptor_( - Linkage::GetSimplifiedCDescriptor(graph->zone(), machine_sig)), + call_descriptor_(call_descriptor), parameters_(NULL), current_block_(schedule()->start()) { int param_count = static_cast(parameter_count()); diff --git a/src/compiler/raw-machine-assembler.h b/src/compiler/raw-machine-assembler.h index bc28e6c..3629944 100644 --- a/src/compiler/raw-machine-assembler.h +++ b/src/compiler/raw-machine-assembler.h @@ -43,7 +43,7 @@ class RawMachineAssembler : public GraphBuilder { }; RawMachineAssembler(Isolate* isolate, Graph* graph, - const MachineSignature* machine_sig, + CallDescriptor* call_descriptor, MachineType word = kMachPtr, MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::Flag::kNoFlags); @@ -53,8 +53,10 @@ class RawMachineAssembler : public GraphBuilder { MachineOperatorBuilder* machine() { return &machine_; } CommonOperatorBuilder* common() { return &common_; } CallDescriptor* call_descriptor() const { return call_descriptor_; } - size_t parameter_count() const { return machine_sig_->parameter_count(); } - const MachineSignature* machine_sig() const { return machine_sig_; } + size_t parameter_count() const { return machine_sig()->parameter_count(); } + const MachineSignature* machine_sig() const { + return call_descriptor_->GetMachineSignature(); + } Node* UndefinedConstant() { Unique unique = Unique::CreateImmovable( @@ -528,7 +530,6 @@ class RawMachineAssembler : public GraphBuilder { Schedule* schedule_; MachineOperatorBuilder machine_; CommonOperatorBuilder common_; - const MachineSignature* machine_sig_; CallDescriptor* call_descriptor_; Node** parameters_; BasicBlock* current_block_; diff --git a/test/cctest/compiler/codegen-tester.h b/test/cctest/compiler/codegen-tester.h index bc6d938..d8ecc02 100644 --- a/test/cctest/compiler/codegen-tester.h +++ b/test/cctest/compiler/codegen-tester.h @@ -34,8 +34,10 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, p2, p3, p4)), RawMachineAssembler( main_isolate(), new (main_zone()) Graph(main_zone()), - CSignature::New(main_zone(), MachineTypeForC(), p0, p1, - p2, p3, p4), + Linkage::GetSimplifiedCDescriptor( + main_zone(), + CSignature::New(main_zone(), MachineTypeForC(), p0, + p1, p2, p3, p4)), kMachPtr, InstructionSelector::SupportedMachineOperatorFlags()) {} void CheckNumber(double expected, Object* number) { diff --git a/test/cctest/compiler/instruction-selector-tester.h b/test/cctest/compiler/instruction-selector-tester.h deleted file mode 100644 index 3a28b2e..0000000 --- a/test/cctest/compiler/instruction-selector-tester.h +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_CCTEST_COMPILER_INSTRUCTION_SELECTOR_TEST_H_ -#define V8_CCTEST_COMPILER_INSTRUCTION_SELECTOR_TEST_H_ - -#include -#include - -#include "src/compiler/instruction-selector.h" -#include "src/compiler/raw-machine-assembler.h" -#include "src/ostreams.h" -#include "test/cctest/cctest.h" - -namespace v8 { -namespace internal { -namespace compiler { - -typedef std::set VirtualRegisterSet; - -enum InstructionSelectorTesterMode { kTargetMode, kInternalMode }; - -class InstructionSelectorTester : public HandleAndZoneScope, - public RawMachineAssembler { - public: - enum Mode { kTargetMode, kInternalMode }; - - static const int kParameterCount = 3; - static MachineType* BuildParameterArray(Zone* zone) { - MachineType* array = zone->NewArray(kParameterCount); - for (int i = 0; i < kParameterCount; ++i) { - array[i] = kMachInt32; - } - return array; - } - - InstructionSelectorTester() - : RawMachineAssembler( - new (main_zone()) Graph(main_zone()), - new (main_zone()) MachineCallDescriptorBuilder( - kMachInt32, kParameterCount, BuildParameterArray(main_zone())), - kMachPtr) {} - - void SelectInstructions(CpuFeature feature) { - SelectInstructions(InstructionSelector::Features(feature)); - } - - void SelectInstructions(CpuFeature feature1, CpuFeature feature2) { - SelectInstructions(InstructionSelector::Features(feature1, feature2)); - } - - void SelectInstructions(Mode mode = kTargetMode) { - SelectInstructions(InstructionSelector::Features(), mode); - } - - void SelectInstructions(InstructionSelector::Features features, - Mode mode = kTargetMode) { - OFStream out(stdout); - Schedule* schedule = Export(); - CHECK_NE(0, graph()->NodeCount()); - CompilationInfo info(main_isolate(), main_zone()); - Linkage linkage(&info, call_descriptor()); - InstructionSequence sequence(&linkage, graph(), schedule); - SourcePositionTable source_positions(graph()); - InstructionSelector selector(&sequence, &source_positions, features); - selector.SelectInstructions(); - out << "--- Code sequence after instruction selection --- " << endl - << sequence; - for (InstructionSequence::const_iterator i = sequence.begin(); - i != sequence.end(); ++i) { - Instruction* instr = *i; - if (instr->opcode() < 0) continue; - if (mode == kTargetMode) { - switch (ArchOpcodeField::decode(instr->opcode())) { -#define CASE(Name) \ - case k##Name: \ - break; - TARGET_ARCH_OPCODE_LIST(CASE) -#undef CASE - default: - continue; - } - } - code.push_back(instr); - } - for (int vreg = 0; vreg < sequence.VirtualRegisterCount(); ++vreg) { - if (sequence.IsDouble(vreg)) { - CHECK(!sequence.IsReference(vreg)); - doubles.insert(vreg); - } - if (sequence.IsReference(vreg)) { - CHECK(!sequence.IsDouble(vreg)); - references.insert(vreg); - } - } - immediates.assign(sequence.immediates().begin(), - sequence.immediates().end()); - } - - int32_t ToInt32(const InstructionOperand* operand) const { - size_t i = operand->index(); - CHECK(i < immediates.size()); - CHECK_EQ(InstructionOperand::IMMEDIATE, operand->kind()); - return immediates[i].ToInt32(); - } - - std::deque code; - VirtualRegisterSet doubles; - VirtualRegisterSet references; - std::deque immediates; -}; - - -static inline void CheckSameVreg(InstructionOperand* exp, - InstructionOperand* val) { - CHECK_EQ(InstructionOperand::UNALLOCATED, exp->kind()); - CHECK_EQ(InstructionOperand::UNALLOCATED, val->kind()); - CHECK_EQ(UnallocatedOperand::cast(exp)->virtual_register(), - UnallocatedOperand::cast(val)->virtual_register()); -} - -} // namespace compiler -} // namespace internal -} // namespace v8 - -#endif // V8_CCTEST_COMPILER_INSTRUCTION_SELECTOR_TEST_H_ diff --git a/test/unittests/compiler/instruction-selector-unittest.h b/test/unittests/compiler/instruction-selector-unittest.h index 15d3b20..574864e 100644 --- a/test/unittests/compiler/instruction-selector-unittest.h +++ b/test/unittests/compiler/instruction-selector-unittest.h @@ -39,22 +39,22 @@ class InstructionSelectorTest : public TestWithContext, StreamBuilder(InstructionSelectorTest* test, MachineType return_type) : RawMachineAssembler( test->isolate(), new (test->zone()) Graph(test->zone()), - MakeMachineSignature(test->zone(), return_type), kMachPtr, + MakeCallDescriptor(test->zone(), return_type), kMachPtr, MachineOperatorBuilder::kAllOptionalOps), test_(test) {} StreamBuilder(InstructionSelectorTest* test, MachineType return_type, MachineType parameter0_type) : RawMachineAssembler( test->isolate(), new (test->zone()) Graph(test->zone()), - MakeMachineSignature(test->zone(), return_type, parameter0_type), + MakeCallDescriptor(test->zone(), return_type, parameter0_type), kMachPtr, MachineOperatorBuilder::kAllOptionalOps), test_(test) {} StreamBuilder(InstructionSelectorTest* test, MachineType return_type, MachineType parameter0_type, MachineType parameter1_type) : RawMachineAssembler( test->isolate(), new (test->zone()) Graph(test->zone()), - MakeMachineSignature(test->zone(), return_type, parameter0_type, - parameter1_type), + MakeCallDescriptor(test->zone(), return_type, parameter0_type, + parameter1_type), kMachPtr, MachineOperatorBuilder::kAllOptionalOps), test_(test) {} StreamBuilder(InstructionSelectorTest* test, MachineType return_type, @@ -62,8 +62,8 @@ class InstructionSelectorTest : public TestWithContext, MachineType parameter2_type) : RawMachineAssembler( test->isolate(), new (test->zone()) Graph(test->zone()), - MakeMachineSignature(test->zone(), return_type, parameter0_type, - parameter1_type, parameter2_type), + MakeCallDescriptor(test->zone(), return_type, parameter0_type, + parameter1_type, parameter2_type), kMachPtr, MachineOperatorBuilder::kAllOptionalOps), test_(test) {} @@ -85,41 +85,40 @@ class InstructionSelectorTest : public TestWithContext, int local_count); private: - MachineSignature* MakeMachineSignature(Zone* zone, - MachineType return_type) { + CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type) { MachineSignature::Builder builder(zone, 1, 0); builder.AddReturn(return_type); - return builder.Build(); + return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); } - MachineSignature* MakeMachineSignature(Zone* zone, MachineType return_type, - MachineType parameter0_type) { + CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, + MachineType parameter0_type) { MachineSignature::Builder builder(zone, 1, 1); builder.AddReturn(return_type); builder.AddParam(parameter0_type); - return builder.Build(); + return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); } - MachineSignature* MakeMachineSignature(Zone* zone, MachineType return_type, - MachineType parameter0_type, - MachineType parameter1_type) { + CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, + MachineType parameter0_type, + MachineType parameter1_type) { MachineSignature::Builder builder(zone, 1, 2); builder.AddReturn(return_type); builder.AddParam(parameter0_type); builder.AddParam(parameter1_type); - return builder.Build(); + return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); } - MachineSignature* MakeMachineSignature(Zone* zone, MachineType return_type, - MachineType parameter0_type, - MachineType parameter1_type, - MachineType parameter2_type) { + CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, + MachineType parameter0_type, + MachineType parameter1_type, + MachineType parameter2_type) { MachineSignature::Builder builder(zone, 1, 3); builder.AddReturn(return_type); builder.AddParam(parameter0_type); builder.AddParam(parameter1_type); builder.AddParam(parameter2_type); - return builder.Build(); + return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); } private: