From 263a96b227ef771c80d52129e9e3d588ef7b09e1 Mon Sep 17 00:00:00 2001 From: "bmeurer@chromium.org" Date: Mon, 8 Sep 2014 06:49:17 +0000 Subject: [PATCH] [turbofan] Fix Projection operator parameter type. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/549063002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23764 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/compiler/common-operator.h | 11 ++++++----- src/compiler/graph-unittest.cc | 8 ++++---- src/compiler/graph-unittest.h | 2 +- src/compiler/instruction-selector.cc | 6 +++--- src/compiler/node.cc | 9 ++++----- src/compiler/node.h | 2 +- src/compiler/verifier.cc | 5 +++-- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/compiler/common-operator.h b/src/compiler/common-operator.h index d871fb781e..ebd4478e3b 100644 --- a/src/compiler/common-operator.h +++ b/src/compiler/common-operator.h @@ -114,8 +114,9 @@ class CommonOperatorBuilder { 1, "Parameter", index); } Operator* Int32Constant(int32_t value) { - return new (zone_) Operator1(IrOpcode::kInt32Constant, Operator::kPure, - 0, 1, "Int32Constant", value); + return new (zone_) + Operator1(IrOpcode::kInt32Constant, Operator::kPure, 0, 1, + "Int32Constant", value); } Operator* Int64Constant(int64_t value) { return new (zone_) @@ -177,9 +178,9 @@ class CommonOperatorBuilder { Operator* Call(CallDescriptor* descriptor) { return new (zone_) CallOperator(descriptor, "Call"); } - Operator* Projection(int index) { - return new (zone_) Operator1(IrOpcode::kProjection, Operator::kPure, 1, - 1, "Projection", index); + Operator* Projection(size_t index) { + return new (zone_) Operator1(IrOpcode::kProjection, Operator::kPure, + 1, 1, "Projection", index); } private: diff --git a/src/compiler/graph-unittest.cc b/src/compiler/graph-unittest.cc index 5be2ec5408..85ab3dcf62 100644 --- a/src/compiler/graph-unittest.cc +++ b/src/compiler/graph-unittest.cc @@ -331,7 +331,7 @@ class IsPhiMatcher FINAL : public NodeMatcher { class IsProjectionMatcher FINAL : public NodeMatcher { public: - IsProjectionMatcher(const Matcher& index_matcher, + IsProjectionMatcher(const Matcher& index_matcher, const Matcher& base_matcher) : NodeMatcher(IrOpcode::kProjection), index_matcher_(index_matcher), @@ -349,14 +349,14 @@ class IsProjectionMatcher FINAL : public NodeMatcher { virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const OVERRIDE { return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter(node), "index", + PrintMatchAndExplain(OpParameter(node), "index", index_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", base_matcher_, listener)); } private: - const Matcher index_matcher_; + const Matcher index_matcher_; const Matcher base_matcher_; }; @@ -685,7 +685,7 @@ Matcher IsPhi(const Matcher& type_matcher, } -Matcher IsProjection(const Matcher& index_matcher, +Matcher IsProjection(const Matcher& index_matcher, const Matcher& base_matcher) { return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher)); } diff --git a/src/compiler/graph-unittest.h b/src/compiler/graph-unittest.h index 90266f642b..761343c0f1 100644 --- a/src/compiler/graph-unittest.h +++ b/src/compiler/graph-unittest.h @@ -73,7 +73,7 @@ Matcher IsPhi(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& merge_matcher); -Matcher IsProjection(const Matcher& index_matcher, +Matcher IsProjection(const Matcher& index_matcher, const Matcher& base_matcher); Matcher IsCall(const Matcher& descriptor_matcher, const Matcher& value0_matcher, diff --git a/src/compiler/instruction-selector.cc b/src/compiler/instruction-selector.cc index 2e0b29c05b..9d9d932bcf 100644 --- a/src/compiler/instruction-selector.cc +++ b/src/compiler/instruction-selector.cc @@ -822,10 +822,10 @@ void InstructionSelector::VisitProjection(Node* node) { switch (value->opcode()) { case IrOpcode::kInt32AddWithOverflow: case IrOpcode::kInt32SubWithOverflow: - if (OpParameter(node) == 0) { + if (OpParameter(node) == 0) { Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value)); } else { - DCHECK_EQ(1, OpParameter(node)); + DCHECK(OpParameter(node) == 1u); MarkAsUsed(value); } break; @@ -933,7 +933,7 @@ void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, case IrOpcode::kProjection: // Check if this is the overflow output projection of an // WithOverflow node. - if (OpParameter(value) == 1) { + if (OpParameter(value) == 1u) { // We cannot combine the WithOverflow with this branch // unless the 0th projection (the use of the actual value of the // is either NULL, which means there's no use of the diff --git a/src/compiler/node.cc b/src/compiler/node.cc index 66294bd180..7df736ee12 100644 --- a/src/compiler/node.cc +++ b/src/compiler/node.cc @@ -23,19 +23,18 @@ void Node::CollectProjections(NodeVector* projections) { } for (UseIter i = uses().begin(); i != uses().end(); ++i) { if ((*i)->opcode() != IrOpcode::kProjection) continue; - int32_t index = OpParameter(*i); - DCHECK_GE(index, 0); - DCHECK_LT(index, static_cast(projections->size())); + size_t index = OpParameter(*i); + DCHECK_LT(index, projections->size()); DCHECK_EQ(NULL, (*projections)[index]); (*projections)[index] = *i; } } -Node* Node::FindProjection(int32_t projection_index) { +Node* Node::FindProjection(size_t projection_index) { for (UseIter i = uses().begin(); i != uses().end(); ++i) { if ((*i)->opcode() == IrOpcode::kProjection && - OpParameter(*i) == projection_index) { + OpParameter(*i) == projection_index) { return *i; } } diff --git a/src/compiler/node.h b/src/compiler/node.h index ac2f332210..2c4c5d31d2 100644 --- a/src/compiler/node.h +++ b/src/compiler/node.h @@ -58,7 +58,7 @@ class Node FINAL : public GenericNode { void Kill(); void CollectProjections(ZoneVector* projections); - Node* FindProjection(int32_t projection_index); + Node* FindProjection(size_t projection_index); }; OStream& operator<<(OStream& os, const Node& n); diff --git a/src/compiler/verifier.cc b/src/compiler/verifier.cc index bd06c84fba..23cec7a809 100644 --- a/src/compiler/verifier.cc +++ b/src/compiler/verifier.cc @@ -213,9 +213,10 @@ GenericGraphVisit::Control Verifier::Visitor::Pre(Node* node) { break; case IrOpcode::kProjection: { // Projection has an input that produces enough values. - int index = OpParameter(node); + size_t index = OpParameter(node); Node* input = NodeProperties::GetValueInput(node, 0); - CHECK_GT(OperatorProperties::GetValueOutputCount(input->op()), index); + CHECK_GT(OperatorProperties::GetValueOutputCount(input->op()), + static_cast(index)); break; } default: