Commit c41e20fc authored by franzih's avatar franzih Committed by Commit bot

[compiler] Simplify paramerters for spread call.

The parameters for ConstructWithSpread and CallWithSpread both
contain the arity for JavaScript calls with a spread as the
last parameter and have the same functionality. Simplify them as
one parameter.

BUG=

Review-Url: https://codereview.chromium.org/2729143002
Cr-Commit-Position: refs/heads/master@{#43581}
parent 68d6b6c6
......@@ -664,7 +664,7 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
Reduction JSCallReducer::ReduceJSCallWithSpread(Node* node) {
DCHECK_EQ(IrOpcode::kJSCallWithSpread, node->opcode());
CallWithSpreadParameters const& p = CallWithSpreadParametersOf(node->op());
SpreadWithArityParameters const& p = SpreadWithArityParametersOf(node->op());
DCHECK_LE(3u, p.arity());
int arity = static_cast<int>(p.arity() - 1);
......@@ -791,8 +791,7 @@ Reduction JSCallReducer::ReduceJSConstruct(Node* node) {
Reduction JSCallReducer::ReduceJSConstructWithSpread(Node* node) {
DCHECK_EQ(IrOpcode::kJSConstructWithSpread, node->opcode());
ConstructWithSpreadParameters const& p =
ConstructWithSpreadParametersOf(node->op());
SpreadWithArityParameters const& p = SpreadWithArityParametersOf(node->op());
DCHECK_LE(3u, p.arity());
int arity = static_cast<int>(p.arity() - 2);
......
......@@ -528,8 +528,7 @@ void JSGenericLowering::LowerJSConstruct(Node* node) {
}
void JSGenericLowering::LowerJSConstructWithSpread(Node* node) {
ConstructWithSpreadParameters const& p =
ConstructWithSpreadParametersOf(node->op());
SpreadWithArityParameters const& p = SpreadWithArityParametersOf(node->op());
int const arg_count = static_cast<int>(p.arity() - 2);
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable = CodeFactory::ConstructWithSpread(isolate());
......@@ -582,7 +581,7 @@ void JSGenericLowering::LowerJSCall(Node* node) {
}
void JSGenericLowering::LowerJSCallWithSpread(Node* node) {
CallWithSpreadParameters const& p = CallWithSpreadParametersOf(node->op());
SpreadWithArityParameters const& p = SpreadWithArityParametersOf(node->op());
int const arg_count = static_cast<int>(p.arity() - 2);
Callable callable = CodeFactory::CallWithSpread(isolate());
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
......
......@@ -76,29 +76,29 @@ ConstructParameters const& ConstructParametersOf(Operator const* op) {
return OpParameter<ConstructParameters>(op);
}
bool operator==(ConstructWithSpreadParameters const& lhs,
ConstructWithSpreadParameters const& rhs) {
bool operator==(SpreadWithArityParameters const& lhs,
SpreadWithArityParameters const& rhs) {
return lhs.arity() == rhs.arity();
}
bool operator!=(ConstructWithSpreadParameters const& lhs,
ConstructWithSpreadParameters const& rhs) {
bool operator!=(SpreadWithArityParameters const& lhs,
SpreadWithArityParameters const& rhs) {
return !(lhs == rhs);
}
size_t hash_value(ConstructWithSpreadParameters const& p) {
size_t hash_value(SpreadWithArityParameters const& p) {
return base::hash_combine(p.arity());
}
std::ostream& operator<<(std::ostream& os,
ConstructWithSpreadParameters const& p) {
std::ostream& operator<<(std::ostream& os, SpreadWithArityParameters const& p) {
return os << p.arity();
}
ConstructWithSpreadParameters const& ConstructWithSpreadParametersOf(
SpreadWithArityParameters const& SpreadWithArityParametersOf(
Operator const* op) {
DCHECK_EQ(IrOpcode::kJSConstructWithSpread, op->opcode());
return OpParameter<ConstructWithSpreadParameters>(op);
DCHECK(op->opcode() == IrOpcode::kJSConstructWithSpread ||
op->opcode() == IrOpcode::kJSCallWithSpread);
return OpParameter<SpreadWithArityParameters>(op);
}
std::ostream& operator<<(std::ostream& os, CallParameters const& p) {
......@@ -123,28 +123,6 @@ CallForwardVarargsParameters const& CallForwardVarargsParametersOf(
return OpParameter<CallForwardVarargsParameters>(op);
}
bool operator==(CallWithSpreadParameters const& lhs,
CallWithSpreadParameters const& rhs) {
return lhs.arity() == rhs.arity();
}
bool operator!=(CallWithSpreadParameters const& lhs,
CallWithSpreadParameters const& rhs) {
return !(lhs == rhs);
}
size_t hash_value(CallWithSpreadParameters const& p) {
return base::hash_combine(p.arity());
}
std::ostream& operator<<(std::ostream& os, CallWithSpreadParameters const& p) {
return os << p.arity();
}
CallWithSpreadParameters const& CallWithSpreadParametersOf(Operator const* op) {
DCHECK_EQ(IrOpcode::kJSCallWithSpread, op->opcode());
return OpParameter<CallWithSpreadParameters>(op);
}
bool operator==(CallRuntimeParameters const& lhs,
CallRuntimeParameters const& rhs) {
......@@ -765,8 +743,8 @@ const Operator* JSOperatorBuilder::Call(size_t arity, float frequency,
}
const Operator* JSOperatorBuilder::CallWithSpread(uint32_t arity) {
CallWithSpreadParameters parameters(arity);
return new (zone()) Operator1<CallWithSpreadParameters>( // --
SpreadWithArityParameters parameters(arity);
return new (zone()) Operator1<SpreadWithArityParameters>( // --
IrOpcode::kJSCallWithSpread, Operator::kNoProperties, // opcode
"JSCallWithSpread", // name
parameters.arity(), 1, 1, 1, 1, 2, // counts
......@@ -808,8 +786,8 @@ const Operator* JSOperatorBuilder::Construct(uint32_t arity, float frequency,
}
const Operator* JSOperatorBuilder::ConstructWithSpread(uint32_t arity) {
ConstructWithSpreadParameters parameters(arity);
return new (zone()) Operator1<ConstructWithSpreadParameters>( // --
SpreadWithArityParameters parameters(arity);
return new (zone()) Operator1<SpreadWithArityParameters>( // --
IrOpcode::kJSConstructWithSpread, Operator::kNoProperties, // opcode
"JSConstructWithSpread", // name
parameters.arity(), 1, 1, 1, 1, 2, // counts
......
......@@ -87,12 +87,12 @@ std::ostream& operator<<(std::ostream&, ConstructParameters const&);
ConstructParameters const& ConstructParametersOf(Operator const*);
// Defines the arity for a JavaScript constructor call with a spread as the last
// parameters. This is used as a parameter by JSConstructWithSpread
// operators.
class ConstructWithSpreadParameters final {
// Defines the arity for JavaScript calls with a spread as the last
// parameter. This is used as a parameter by JSConstructWithSpread and
// JSCallWithSpread operators.
class SpreadWithArityParameters final {
public:
explicit ConstructWithSpreadParameters(uint32_t arity) : arity_(arity) {}
explicit SpreadWithArityParameters(uint32_t arity) : arity_(arity) {}
uint32_t arity() const { return arity_; }
......@@ -100,17 +100,16 @@ class ConstructWithSpreadParameters final {
uint32_t const arity_;
};
bool operator==(ConstructWithSpreadParameters const&,
ConstructWithSpreadParameters const&);
bool operator!=(ConstructWithSpreadParameters const&,
ConstructWithSpreadParameters const&);
bool operator==(SpreadWithArityParameters const&,
SpreadWithArityParameters const&);
bool operator!=(SpreadWithArityParameters const&,
SpreadWithArityParameters const&);
size_t hash_value(ConstructWithSpreadParameters const&);
size_t hash_value(SpreadWithArityParameters const&);
std::ostream& operator<<(std::ostream&, ConstructWithSpreadParameters const&);
std::ostream& operator<<(std::ostream&, SpreadWithArityParameters const&);
ConstructWithSpreadParameters const& ConstructWithSpreadParametersOf(
Operator const*);
SpreadWithArityParameters const& SpreadWithArityParametersOf(Operator const*);
// Defines the flags for a JavaScript call forwarding parameters. This
// is used as parameter by JSCallForwardVarargs operators.
......@@ -198,29 +197,6 @@ std::ostream& operator<<(std::ostream&, CallParameters const&);
const CallParameters& CallParametersOf(const Operator* op);
// Defines the arity for a JavaScript constructor call with a spread as the last
// parameters. This is used as a parameter by JSConstructWithSpread
// operators.
class CallWithSpreadParameters final {
public:
explicit CallWithSpreadParameters(uint32_t arity) : arity_(arity) {}
uint32_t arity() const { return arity_; }
private:
uint32_t const arity_;
};
bool operator==(CallWithSpreadParameters const&,
CallWithSpreadParameters const&);
bool operator!=(CallWithSpreadParameters const&,
CallWithSpreadParameters const&);
size_t hash_value(CallWithSpreadParameters const&);
std::ostream& operator<<(std::ostream&, CallWithSpreadParameters const&);
CallWithSpreadParameters const& CallWithSpreadParametersOf(Operator const*);
// Defines the arity and the ID for a runtime function call. This is used as a
// parameter by JSCallRuntime operators.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment