Commit 6bb08db2 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

[turbofan] Next step towards shared operators.

TEST=compiler-unittests,cctest
R=svenpanne@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23837 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8d35f227
This diff is collapsed.
...@@ -140,7 +140,7 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor { ...@@ -140,7 +140,7 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
// Process arguments to a call by popping {arity} elements off the operand // Process arguments to a call by popping {arity} elements off the operand
// stack and build a call node using the given call operator. // stack and build a call node using the given call operator.
Node* ProcessArguments(Operator* op, int arity); Node* ProcessArguments(const Operator* op, int arity);
// Visit statements. // Visit statements.
void VisitIfNotNull(Statement* stmt); void VisitIfNotNull(Statement* stmt);
......
...@@ -168,8 +168,9 @@ Reduction ChangeLowering::ChangeTaggedToUI32(Node* val, Node* control, ...@@ -168,8 +168,9 @@ Reduction ChangeLowering::ChangeTaggedToUI32(Node* val, Node* control,
Node* branch = graph()->NewNode(common()->Branch(), tag, control); Node* branch = graph()->NewNode(common()->Branch(), tag, control);
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Operator* op = (signedness == kSigned) ? machine()->ChangeFloat64ToInt32() const Operator* op = (signedness == kSigned)
: machine()->ChangeFloat64ToUint32(); ? machine()->ChangeFloat64ToInt32()
: machine()->ChangeFloat64ToUint32();
Node* change = graph()->NewNode(op, LoadHeapNumberValue(val, if_true)); Node* change = graph()->NewNode(op, LoadHeapNumberValue(val, if_true));
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
......
...@@ -30,7 +30,7 @@ const int kArguments[] = {1, 5, 6, 42, 100, 10000, kMaxInt}; ...@@ -30,7 +30,7 @@ const int kArguments[] = {1, 5, 6, 42, 100, 10000, kMaxInt};
TEST_F(CommonOperatorTest, ControlEffect) { TEST_F(CommonOperatorTest, ControlEffect) {
Operator* op = common()->ControlEffect(); const Operator* op = common()->ControlEffect();
EXPECT_EQ(1, OperatorProperties::GetControlInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetControlInputCount(op));
EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op));
EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
...@@ -41,7 +41,7 @@ TEST_F(CommonOperatorTest, ControlEffect) { ...@@ -41,7 +41,7 @@ TEST_F(CommonOperatorTest, ControlEffect) {
TEST_F(CommonOperatorTest, ValueEffect) { TEST_F(CommonOperatorTest, ValueEffect) {
TRACED_FOREACH(int, arguments, kArguments) { TRACED_FOREACH(int, arguments, kArguments) {
Operator* op = common()->ValueEffect(arguments); const Operator* op = common()->ValueEffect(arguments);
EXPECT_EQ(arguments, OperatorProperties::GetValueInputCount(op)); EXPECT_EQ(arguments, OperatorProperties::GetValueInputCount(op));
EXPECT_EQ(arguments, OperatorProperties::GetTotalInputCount(op)); EXPECT_EQ(arguments, OperatorProperties::GetTotalInputCount(op));
EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
...@@ -53,7 +53,7 @@ TEST_F(CommonOperatorTest, ValueEffect) { ...@@ -53,7 +53,7 @@ TEST_F(CommonOperatorTest, ValueEffect) {
TEST_F(CommonOperatorTest, Finish) { TEST_F(CommonOperatorTest, Finish) {
TRACED_FOREACH(int, arguments, kArguments) { TRACED_FOREACH(int, arguments, kArguments) {
Operator* op = common()->Finish(arguments); const Operator* op = common()->Finish(arguments);
EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op));
EXPECT_EQ(arguments, OperatorProperties::GetEffectInputCount(op)); EXPECT_EQ(arguments, OperatorProperties::GetEffectInputCount(op));
EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op)); EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op));
......
...@@ -81,104 +81,105 @@ class CommonOperatorBuilder { ...@@ -81,104 +81,105 @@ class CommonOperatorBuilder {
return new (zone_) ControlOperator(IrOpcode::k##name, Operator::kFoldable, \ return new (zone_) ControlOperator(IrOpcode::k##name, Operator::kFoldable, \
inputs, 0, controls, #name); inputs, 0, controls, #name);
Operator* Start(int num_formal_parameters) { const Operator* Start(int num_formal_parameters) {
// Outputs are formal parameters, plus context, receiver, and JSFunction. // Outputs are formal parameters, plus context, receiver, and JSFunction.
int outputs = num_formal_parameters + 3; int outputs = num_formal_parameters + 3;
return new (zone_) ControlOperator(IrOpcode::kStart, Operator::kFoldable, 0, return new (zone_) ControlOperator(IrOpcode::kStart, Operator::kFoldable, 0,
outputs, 0, "Start"); outputs, 0, "Start");
} }
Operator* Dead() { CONTROL_OP(Dead, 0, 0); } const Operator* Dead() { CONTROL_OP(Dead, 0, 0); }
Operator* End() { CONTROL_OP(End, 0, 1); } const Operator* End() { CONTROL_OP(End, 0, 1); }
Operator* Branch() { CONTROL_OP(Branch, 1, 1); } const Operator* Branch() { CONTROL_OP(Branch, 1, 1); }
Operator* IfTrue() { CONTROL_OP(IfTrue, 0, 1); } const Operator* IfTrue() { CONTROL_OP(IfTrue, 0, 1); }
Operator* IfFalse() { CONTROL_OP(IfFalse, 0, 1); } const Operator* IfFalse() { CONTROL_OP(IfFalse, 0, 1); }
Operator* Throw() { CONTROL_OP(Throw, 1, 1); } const Operator* Throw() { CONTROL_OP(Throw, 1, 1); }
Operator* Return() { const Operator* Return() {
return new (zone_) ControlOperator( return new (zone_) ControlOperator(
IrOpcode::kReturn, Operator::kNoProperties, 1, 0, 1, "Return"); IrOpcode::kReturn, Operator::kNoProperties, 1, 0, 1, "Return");
} }
Operator* Merge(int controls) { const Operator* Merge(int controls) {
return new (zone_) ControlOperator(IrOpcode::kMerge, Operator::kFoldable, 0, return new (zone_) ControlOperator(IrOpcode::kMerge, Operator::kFoldable, 0,
0, controls, "Merge"); 0, controls, "Merge");
} }
Operator* Loop(int controls) { const Operator* Loop(int controls) {
return new (zone_) ControlOperator(IrOpcode::kLoop, Operator::kFoldable, 0, return new (zone_) ControlOperator(IrOpcode::kLoop, Operator::kFoldable, 0,
0, controls, "Loop"); 0, controls, "Loop");
} }
Operator* Parameter(int index) { const Operator* Parameter(int index) {
return new (zone_) Operator1<int>(IrOpcode::kParameter, Operator::kPure, 1, return new (zone_) Operator1<int>(IrOpcode::kParameter, Operator::kPure, 1,
1, "Parameter", index); 1, "Parameter", index);
} }
Operator* Int32Constant(int32_t value) { const Operator* Int32Constant(int32_t value) {
return new (zone_) return new (zone_)
Operator1<int32_t>(IrOpcode::kInt32Constant, Operator::kPure, 0, 1, Operator1<int32_t>(IrOpcode::kInt32Constant, Operator::kPure, 0, 1,
"Int32Constant", value); "Int32Constant", value);
} }
Operator* Int64Constant(int64_t value) { const Operator* Int64Constant(int64_t value) {
return new (zone_) return new (zone_)
Operator1<int64_t>(IrOpcode::kInt64Constant, Operator::kPure, 0, 1, Operator1<int64_t>(IrOpcode::kInt64Constant, Operator::kPure, 0, 1,
"Int64Constant", value); "Int64Constant", value);
} }
Operator* Float64Constant(double value) { const Operator* Float64Constant(double value) {
return new (zone_) return new (zone_)
Operator1<double>(IrOpcode::kFloat64Constant, Operator::kPure, 0, 1, Operator1<double>(IrOpcode::kFloat64Constant, Operator::kPure, 0, 1,
"Float64Constant", value); "Float64Constant", value);
} }
Operator* ExternalConstant(ExternalReference value) { const Operator* ExternalConstant(ExternalReference value) {
return new (zone_) Operator1<ExternalReference>(IrOpcode::kExternalConstant, return new (zone_) Operator1<ExternalReference>(IrOpcode::kExternalConstant,
Operator::kPure, 0, 1, Operator::kPure, 0, 1,
"ExternalConstant", value); "ExternalConstant", value);
} }
Operator* NumberConstant(double value) { const Operator* NumberConstant(double value) {
return new (zone_) return new (zone_)
Operator1<double>(IrOpcode::kNumberConstant, Operator::kPure, 0, 1, Operator1<double>(IrOpcode::kNumberConstant, Operator::kPure, 0, 1,
"NumberConstant", value); "NumberConstant", value);
} }
Operator* HeapConstant(Unique<Object> value) { const Operator* HeapConstant(Unique<Object> value) {
return new (zone_) Operator1<Unique<Object> >( return new (zone_) Operator1<Unique<Object> >(
IrOpcode::kHeapConstant, Operator::kPure, 0, 1, "HeapConstant", value); IrOpcode::kHeapConstant, Operator::kPure, 0, 1, "HeapConstant", value);
} }
Operator* Phi(MachineType type, int arguments) { const Operator* Phi(MachineType type, int arguments) {
DCHECK(arguments > 0); // Disallow empty phis. DCHECK(arguments > 0); // Disallow empty phis.
return new (zone_) Operator1<MachineType>(IrOpcode::kPhi, Operator::kPure, return new (zone_) Operator1<MachineType>(IrOpcode::kPhi, Operator::kPure,
arguments, 1, "Phi", type); arguments, 1, "Phi", type);
} }
Operator* EffectPhi(int arguments) { const Operator* EffectPhi(int arguments) {
DCHECK(arguments > 0); // Disallow empty phis. DCHECK(arguments > 0); // Disallow empty phis.
return new (zone_) Operator1<int>(IrOpcode::kEffectPhi, Operator::kPure, 0, return new (zone_) Operator1<int>(IrOpcode::kEffectPhi, Operator::kPure, 0,
0, "EffectPhi", arguments); 0, "EffectPhi", arguments);
} }
Operator* ControlEffect() { const Operator* ControlEffect() {
return new (zone_) SimpleOperator(IrOpcode::kControlEffect, Operator::kPure, return new (zone_) SimpleOperator(IrOpcode::kControlEffect, Operator::kPure,
0, 0, "ControlEffect"); 0, 0, "ControlEffect");
} }
Operator* ValueEffect(int arguments) { const Operator* ValueEffect(int arguments) {
DCHECK(arguments > 0); // Disallow empty value effects. DCHECK(arguments > 0); // Disallow empty value effects.
return new (zone_) SimpleOperator(IrOpcode::kValueEffect, Operator::kPure, return new (zone_) SimpleOperator(IrOpcode::kValueEffect, Operator::kPure,
arguments, 0, "ValueEffect"); arguments, 0, "ValueEffect");
} }
Operator* Finish(int arguments) { const Operator* Finish(int arguments) {
DCHECK(arguments > 0); // Disallow empty finishes. DCHECK(arguments > 0); // Disallow empty finishes.
return new (zone_) Operator1<int>(IrOpcode::kFinish, Operator::kPure, 1, 1, return new (zone_) Operator1<int>(IrOpcode::kFinish, Operator::kPure, 1, 1,
"Finish", arguments); "Finish", arguments);
} }
Operator* StateValues(int arguments) { const Operator* StateValues(int arguments) {
return new (zone_) Operator1<int>(IrOpcode::kStateValues, Operator::kPure, return new (zone_) Operator1<int>(IrOpcode::kStateValues, Operator::kPure,
arguments, 1, "StateValues", arguments); arguments, 1, "StateValues", arguments);
} }
Operator* FrameState(BailoutId bailout_id, OutputFrameStateCombine combine) { const Operator* FrameState(BailoutId bailout_id,
OutputFrameStateCombine combine) {
return new (zone_) Operator1<FrameStateCallInfo>( return new (zone_) Operator1<FrameStateCallInfo>(
IrOpcode::kFrameState, Operator::kPure, 4, 1, "FrameState", IrOpcode::kFrameState, Operator::kPure, 4, 1, "FrameState",
FrameStateCallInfo(bailout_id, combine)); FrameStateCallInfo(bailout_id, combine));
} }
Operator* Call(CallDescriptor* descriptor) { const Operator* Call(CallDescriptor* descriptor) {
return new (zone_) CallOperator(descriptor, "Call"); return new (zone_) CallOperator(descriptor, "Call");
} }
Operator* Projection(size_t index) { const Operator* Projection(size_t index) {
return new (zone_) Operator1<size_t>(IrOpcode::kProjection, Operator::kPure, return new (zone_) Operator1<size_t>(IrOpcode::kProjection, Operator::kPure,
1, 1, "Projection", index); 1, 1, "Projection", index);
} }
......
...@@ -28,7 +28,8 @@ StructuredGraphBuilder::StructuredGraphBuilder(Graph* graph, ...@@ -28,7 +28,8 @@ StructuredGraphBuilder::StructuredGraphBuilder(Graph* graph,
exit_control_(NULL) {} exit_control_(NULL) {}
Node* StructuredGraphBuilder::MakeNode(Operator* op, int value_input_count, Node* StructuredGraphBuilder::MakeNode(const Operator* op,
int value_input_count,
Node** value_inputs) { Node** value_inputs) {
DCHECK(op->InputCount() == value_input_count); DCHECK(op->InputCount() == value_input_count);
...@@ -161,7 +162,7 @@ void StructuredGraphBuilder::Environment::PrepareForLoop() { ...@@ -161,7 +162,7 @@ void StructuredGraphBuilder::Environment::PrepareForLoop() {
Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
Operator* phi_op = common()->Phi(kMachAnyTagged, count); const Operator* phi_op = common()->Phi(kMachAnyTagged, count);
Node** buffer = zone()->NewArray<Node*>(count + 1); Node** buffer = zone()->NewArray<Node*>(count + 1);
MemsetPointer(buffer, input, count); MemsetPointer(buffer, input, count);
buffer[count] = control; buffer[count] = control;
...@@ -172,7 +173,7 @@ Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { ...@@ -172,7 +173,7 @@ Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
// TODO(mstarzinger): Revisit this once we have proper effect states. // TODO(mstarzinger): Revisit this once we have proper effect states.
Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input, Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input,
Node* control) { Node* control) {
Operator* phi_op = common()->EffectPhi(count); const Operator* phi_op = common()->EffectPhi(count);
Node** buffer = zone()->NewArray<Node*>(count + 1); Node** buffer = zone()->NewArray<Node*>(count + 1);
MemsetPointer(buffer, input, count); MemsetPointer(buffer, input, count);
buffer[count] = control; buffer[count] = control;
...@@ -184,17 +185,17 @@ Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) { ...@@ -184,17 +185,17 @@ Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) {
int inputs = OperatorProperties::GetControlInputCount(control->op()) + 1; int inputs = OperatorProperties::GetControlInputCount(control->op()) + 1;
if (control->opcode() == IrOpcode::kLoop) { if (control->opcode() == IrOpcode::kLoop) {
// Control node for loop exists, add input. // Control node for loop exists, add input.
Operator* op = common()->Loop(inputs); const Operator* op = common()->Loop(inputs);
control->AppendInput(zone(), other); control->AppendInput(zone(), other);
control->set_op(op); control->set_op(op);
} else if (control->opcode() == IrOpcode::kMerge) { } else if (control->opcode() == IrOpcode::kMerge) {
// Control node for merge exists, add input. // Control node for merge exists, add input.
Operator* op = common()->Merge(inputs); const Operator* op = common()->Merge(inputs);
control->AppendInput(zone(), other); control->AppendInput(zone(), other);
control->set_op(op); control->set_op(op);
} else { } else {
// Control node is a singleton, introduce a merge. // Control node is a singleton, introduce a merge.
Operator* op = common()->Merge(inputs); const Operator* op = common()->Merge(inputs);
control = graph()->NewNode(op, control, other); control = graph()->NewNode(op, control, other);
} }
return control; return control;
......
...@@ -24,40 +24,41 @@ class GraphBuilder { ...@@ -24,40 +24,41 @@ class GraphBuilder {
explicit GraphBuilder(Graph* graph) : graph_(graph) {} explicit GraphBuilder(Graph* graph) : graph_(graph) {}
virtual ~GraphBuilder() {} virtual ~GraphBuilder() {}
Node* NewNode(Operator* op) { Node* NewNode(const Operator* op) {
return MakeNode(op, 0, static_cast<Node**>(NULL)); return MakeNode(op, 0, static_cast<Node**>(NULL));
} }
Node* NewNode(Operator* op, Node* n1) { return MakeNode(op, 1, &n1); } Node* NewNode(const Operator* op, Node* n1) { return MakeNode(op, 1, &n1); }
Node* NewNode(Operator* op, Node* n1, Node* n2) { Node* NewNode(const Operator* op, Node* n1, Node* n2) {
Node* buffer[] = {n1, n2}; Node* buffer[] = {n1, n2};
return MakeNode(op, arraysize(buffer), buffer); return MakeNode(op, arraysize(buffer), buffer);
} }
Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3) { Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) {
Node* buffer[] = {n1, n2, n3}; Node* buffer[] = {n1, n2, n3};
return MakeNode(op, arraysize(buffer), buffer); return MakeNode(op, arraysize(buffer), buffer);
} }
Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) { Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) {
Node* buffer[] = {n1, n2, n3, n4}; Node* buffer[] = {n1, n2, n3, n4};
return MakeNode(op, arraysize(buffer), buffer); return MakeNode(op, arraysize(buffer), buffer);
} }
Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5) { Node* n5) {
Node* buffer[] = {n1, n2, n3, n4, n5}; Node* buffer[] = {n1, n2, n3, n4, n5};
return MakeNode(op, arraysize(buffer), buffer); return MakeNode(op, arraysize(buffer), buffer);
} }
Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n6) { Node* n5, Node* n6) {
Node* nodes[] = {n1, n2, n3, n4, n5, n6}; Node* nodes[] = {n1, n2, n3, n4, n5, n6};
return MakeNode(op, arraysize(nodes), nodes); return MakeNode(op, arraysize(nodes), nodes);
} }
Node* NewNode(Operator* op, int value_input_count, Node** value_inputs) { Node* NewNode(const Operator* op, int value_input_count,
Node** value_inputs) {
return MakeNode(op, value_input_count, value_inputs); return MakeNode(op, value_input_count, value_inputs);
} }
...@@ -65,7 +66,7 @@ class GraphBuilder { ...@@ -65,7 +66,7 @@ class GraphBuilder {
protected: protected:
// Base implementation used by all factory methods. // Base implementation used by all factory methods.
virtual Node* MakeNode(Operator* op, int value_input_count, virtual Node* MakeNode(const Operator* op, int value_input_count,
Node** value_inputs) = 0; Node** value_inputs) = 0;
private: private:
...@@ -107,8 +108,8 @@ class StructuredGraphBuilder : public GraphBuilder { ...@@ -107,8 +108,8 @@ class StructuredGraphBuilder : public GraphBuilder {
// The following method creates a new node having the specified operator and // The following method creates a new node having the specified operator and
// ensures effect and control dependencies are wired up. The dependencies // ensures effect and control dependencies are wired up. The dependencies
// tracked by the environment might be mutated. // tracked by the environment might be mutated.
virtual Node* MakeNode(Operator* op, int value_input_count, virtual Node* MakeNode(const Operator* op, int value_input_count,
Node** value_inputs); Node** value_inputs) FINAL;
Environment* environment() const { return environment_; } Environment* environment() const { return environment_; }
void set_environment(Environment* env) { environment_ = env; } void set_environment(Environment* env) { environment_ = env; }
......
...@@ -81,8 +81,8 @@ Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) { ...@@ -81,8 +81,8 @@ Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) {
if (access.depth() == 0) { if (access.depth() == 0) {
return Reducer::NoChange(); return Reducer::NoChange();
} }
Operator* op = jsgraph_->javascript()->LoadContext(0, access.index(), const Operator* op = jsgraph_->javascript()->LoadContext(
access.immutable()); 0, access.index(), access.immutable());
node->set_op(op); node->set_op(op);
Handle<Object> context_handle = Handle<Object>(context, info_->isolate()); Handle<Object> context_handle = Handle<Object>(context, info_->isolate());
node->ReplaceInput(0, jsgraph_->Constant(context_handle)); node->ReplaceInput(0, jsgraph_->Constant(context_handle));
...@@ -128,13 +128,14 @@ Reduction JSContextSpecializer::ReduceJSStoreContext(Node* node) { ...@@ -128,13 +128,14 @@ Reduction JSContextSpecializer::ReduceJSStoreContext(Node* node) {
context = context->previous(); context = context->previous();
} }
Operator* op = jsgraph_->javascript()->StoreContext(0, access.index()); const Operator* op = jsgraph_->javascript()->StoreContext(0, access.index());
node->set_op(op); node->set_op(op);
Handle<Object> new_context_handle = Handle<Object>(context, info_->isolate()); Handle<Object> new_context_handle = Handle<Object>(context, info_->isolate());
node->ReplaceInput(0, jsgraph_->Constant(new_context_handle)); node->ReplaceInput(0, jsgraph_->Constant(new_context_handle));
return Reducer::Changed(node); return Reducer::Changed(node);
} }
}
} } // namespace compiler
} // namespace v8::internal::compiler } // namespace internal
} // namespace v8
...@@ -120,7 +120,7 @@ JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph, ...@@ -120,7 +120,7 @@ JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph,
machine_(machine) {} machine_(machine) {}
void JSGenericLowering::PatchOperator(Node* node, Operator* op) { void JSGenericLowering::PatchOperator(Node* node, const Operator* op) {
node->set_op(op); node->set_op(op);
} }
......
...@@ -50,7 +50,7 @@ class JSGenericLowering : public Reducer { ...@@ -50,7 +50,7 @@ class JSGenericLowering : public Reducer {
Node* ExternalConstant(ExternalReference ref); Node* ExternalConstant(ExternalReference ref);
// Helpers to patch existing nodes in the graph. // Helpers to patch existing nodes in the graph.
void PatchOperator(Node* node, Operator* new_op); void PatchOperator(Node* node, const Operator* new_op);
void PatchInsertInput(Node* node, int index, Node* input); void PatchInsertInput(Node* node, int index, Node* input);
// Helpers to replace existing nodes with a generic call. // Helpers to replace existing nodes with a generic call.
......
...@@ -16,7 +16,7 @@ Node* JSGraph::ImmovableHeapConstant(Handle<Object> object) { ...@@ -16,7 +16,7 @@ Node* JSGraph::ImmovableHeapConstant(Handle<Object> object) {
} }
Node* JSGraph::NewNode(Operator* op) { Node* JSGraph::NewNode(const Operator* op) {
Node* node = graph()->NewNode(op); Node* node = graph()->NewNode(op);
typer_->Init(node); typer_->Init(node);
return node; return node;
......
...@@ -99,7 +99,7 @@ class JSGraph : public ZoneObject { ...@@ -99,7 +99,7 @@ class JSGraph : public ZoneObject {
Node* ImmovableHeapConstant(Handle<Object> value); Node* ImmovableHeapConstant(Handle<Object> value);
Node* NumberConstant(double value); Node* NumberConstant(double value);
Node* NewNode(Operator* op); Node* NewNode(const Operator* op);
Factory* factory() { return isolate()->factory(); } Factory* factory() { return isolate()->factory(); }
}; };
......
...@@ -121,8 +121,9 @@ void Inlinee::UnifyReturn() { ...@@ -121,8 +121,9 @@ void Inlinee::UnifyReturn() {
int predecessors = int predecessors =
OperatorProperties::GetControlInputCount(final_merge->op()); OperatorProperties::GetControlInputCount(final_merge->op());
Operator* op_phi = jsgraph_->common()->Phi(kMachAnyTagged, predecessors); const Operator* op_phi =
Operator* op_ephi = jsgraph_->common()->EffectPhi(predecessors); jsgraph_->common()->Phi(kMachAnyTagged, predecessors);
const Operator* op_ephi = jsgraph_->common()->EffectPhi(predecessors);
NodeVector values(jsgraph_->zone()); NodeVector values(jsgraph_->zone());
NodeVector effects(jsgraph_->zone()); NodeVector effects(jsgraph_->zone());
......
...@@ -81,100 +81,106 @@ class JSOperatorBuilder { ...@@ -81,100 +81,106 @@ class JSOperatorBuilder {
#define PURE_BINOP(name) SIMPLE(name, Operator::kPure, 2, 1) #define PURE_BINOP(name) SIMPLE(name, Operator::kPure, 2, 1)
Operator* Equal() { BINOP(JSEqual); } const Operator* Equal() { BINOP(JSEqual); }
Operator* NotEqual() { BINOP(JSNotEqual); } const Operator* NotEqual() { BINOP(JSNotEqual); }
Operator* StrictEqual() { PURE_BINOP(JSStrictEqual); } const Operator* StrictEqual() { PURE_BINOP(JSStrictEqual); }
Operator* StrictNotEqual() { PURE_BINOP(JSStrictNotEqual); } const Operator* StrictNotEqual() { PURE_BINOP(JSStrictNotEqual); }
Operator* LessThan() { BINOP(JSLessThan); } const Operator* LessThan() { BINOP(JSLessThan); }
Operator* GreaterThan() { BINOP(JSGreaterThan); } const Operator* GreaterThan() { BINOP(JSGreaterThan); }
Operator* LessThanOrEqual() { BINOP(JSLessThanOrEqual); } const Operator* LessThanOrEqual() { BINOP(JSLessThanOrEqual); }
Operator* GreaterThanOrEqual() { BINOP(JSGreaterThanOrEqual); } const Operator* GreaterThanOrEqual() { BINOP(JSGreaterThanOrEqual); }
Operator* BitwiseOr() { BINOP(JSBitwiseOr); } const Operator* BitwiseOr() { BINOP(JSBitwiseOr); }
Operator* BitwiseXor() { BINOP(JSBitwiseXor); } const Operator* BitwiseXor() { BINOP(JSBitwiseXor); }
Operator* BitwiseAnd() { BINOP(JSBitwiseAnd); } const Operator* BitwiseAnd() { BINOP(JSBitwiseAnd); }
Operator* ShiftLeft() { BINOP(JSShiftLeft); } const Operator* ShiftLeft() { BINOP(JSShiftLeft); }
Operator* ShiftRight() { BINOP(JSShiftRight); } const Operator* ShiftRight() { BINOP(JSShiftRight); }
Operator* ShiftRightLogical() { BINOP(JSShiftRightLogical); } const Operator* ShiftRightLogical() { BINOP(JSShiftRightLogical); }
Operator* Add() { BINOP(JSAdd); } const Operator* Add() { BINOP(JSAdd); }
Operator* Subtract() { BINOP(JSSubtract); } const Operator* Subtract() { BINOP(JSSubtract); }
Operator* Multiply() { BINOP(JSMultiply); } const Operator* Multiply() { BINOP(JSMultiply); }
Operator* Divide() { BINOP(JSDivide); } const Operator* Divide() { BINOP(JSDivide); }
Operator* Modulus() { BINOP(JSModulus); } const Operator* Modulus() { BINOP(JSModulus); }
Operator* UnaryNot() { UNOP(JSUnaryNot); } const Operator* UnaryNot() { UNOP(JSUnaryNot); }
Operator* ToBoolean() { UNOP(JSToBoolean); } const Operator* ToBoolean() { UNOP(JSToBoolean); }
Operator* ToNumber() { UNOP(JSToNumber); } const Operator* ToNumber() { UNOP(JSToNumber); }
Operator* ToString() { UNOP(JSToString); } const Operator* ToString() { UNOP(JSToString); }
Operator* ToName() { UNOP(JSToName); } const Operator* ToName() { UNOP(JSToName); }
Operator* ToObject() { UNOP(JSToObject); } const Operator* ToObject() { UNOP(JSToObject); }
Operator* Yield() { UNOP(JSYield); } const Operator* Yield() { UNOP(JSYield); }
Operator* Create() { SIMPLE(JSCreate, Operator::kEliminatable, 0, 1); } const Operator* Create() { SIMPLE(JSCreate, Operator::kEliminatable, 0, 1); }
Operator* Call(int arguments, CallFunctionFlags flags) { const Operator* Call(int arguments, CallFunctionFlags flags) {
CallParameters parameters = {arguments, flags}; CallParameters parameters = {arguments, flags};
OP1(JSCallFunction, CallParameters, parameters, Operator::kNoProperties, OP1(JSCallFunction, CallParameters, parameters, Operator::kNoProperties,
arguments, 1); arguments, 1);
} }
Operator* CallNew(int arguments) { const Operator* CallNew(int arguments) {
return new (zone_) return new (zone_)
Operator1<int>(IrOpcode::kJSCallConstruct, Operator::kNoProperties, Operator1<int>(IrOpcode::kJSCallConstruct, Operator::kNoProperties,
arguments, 1, "JSCallConstruct", arguments); arguments, 1, "JSCallConstruct", arguments);
} }
Operator* LoadProperty() { BINOP(JSLoadProperty); } const Operator* LoadProperty() { BINOP(JSLoadProperty); }
Operator* LoadNamed(Unique<Name> name, const Operator* LoadNamed(Unique<Name> name,
ContextualMode contextual_mode = NOT_CONTEXTUAL) { ContextualMode contextual_mode = NOT_CONTEXTUAL) {
LoadNamedParameters parameters = {name, contextual_mode}; LoadNamedParameters parameters = {name, contextual_mode};
OP1(JSLoadNamed, LoadNamedParameters, parameters, Operator::kNoProperties, OP1(JSLoadNamed, LoadNamedParameters, parameters, Operator::kNoProperties,
1, 1); 1, 1);
} }
Operator* StoreProperty(StrictMode strict_mode) { const Operator* StoreProperty(StrictMode strict_mode) {
OP1(JSStoreProperty, StrictMode, strict_mode, Operator::kNoProperties, 3, OP1(JSStoreProperty, StrictMode, strict_mode, Operator::kNoProperties, 3,
0); 0);
} }
Operator* StoreNamed(StrictMode strict_mode, Unique<Name> name) { const Operator* StoreNamed(StrictMode strict_mode, Unique<Name> name) {
StoreNamedParameters parameters = {strict_mode, name}; StoreNamedParameters parameters = {strict_mode, name};
OP1(JSStoreNamed, StoreNamedParameters, parameters, Operator::kNoProperties, OP1(JSStoreNamed, StoreNamedParameters, parameters, Operator::kNoProperties,
2, 0); 2, 0);
} }
Operator* DeleteProperty(StrictMode strict_mode) { const Operator* DeleteProperty(StrictMode strict_mode) {
OP1(JSDeleteProperty, StrictMode, strict_mode, Operator::kNoProperties, 2, OP1(JSDeleteProperty, StrictMode, strict_mode, Operator::kNoProperties, 2,
1); 1);
} }
Operator* HasProperty() { NOPROPS(JSHasProperty, 2, 1); } const Operator* HasProperty() { NOPROPS(JSHasProperty, 2, 1); }
Operator* LoadContext(uint16_t depth, uint32_t index, bool immutable) { const Operator* LoadContext(uint16_t depth, uint32_t index, bool immutable) {
ContextAccess access(depth, index, immutable); ContextAccess access(depth, index, immutable);
OP1(JSLoadContext, ContextAccess, access, OP1(JSLoadContext, ContextAccess, access,
Operator::kEliminatable | Operator::kNoWrite, 1, 1); Operator::kEliminatable | Operator::kNoWrite, 1, 1);
} }
Operator* StoreContext(uint16_t depth, uint32_t index) { const Operator* StoreContext(uint16_t depth, uint32_t index) {
ContextAccess access(depth, index, false); ContextAccess access(depth, index, false);
OP1(JSStoreContext, ContextAccess, access, Operator::kNoProperties, 2, 0); OP1(JSStoreContext, ContextAccess, access, Operator::kNoProperties, 2, 0);
} }
Operator* TypeOf() { SIMPLE(JSTypeOf, Operator::kPure, 1, 1); } const Operator* TypeOf() { SIMPLE(JSTypeOf, Operator::kPure, 1, 1); }
Operator* InstanceOf() { NOPROPS(JSInstanceOf, 2, 1); } const Operator* InstanceOf() { NOPROPS(JSInstanceOf, 2, 1); }
Operator* Debugger() { NOPROPS(JSDebugger, 0, 0); } const Operator* Debugger() { NOPROPS(JSDebugger, 0, 0); }
// TODO(titzer): nail down the static parts of each of these context flavors. // TODO(titzer): nail down the static parts of each of these context flavors.
Operator* CreateFunctionContext() { NOPROPS(JSCreateFunctionContext, 1, 1); } const Operator* CreateFunctionContext() {
Operator* CreateCatchContext(Unique<String> name) { NOPROPS(JSCreateFunctionContext, 1, 1);
}
const Operator* CreateCatchContext(Unique<String> name) {
OP1(JSCreateCatchContext, Unique<String>, name, Operator::kNoProperties, 1, OP1(JSCreateCatchContext, Unique<String>, name, Operator::kNoProperties, 1,
1); 1);
} }
Operator* CreateWithContext() { NOPROPS(JSCreateWithContext, 2, 1); } const Operator* CreateWithContext() { NOPROPS(JSCreateWithContext, 2, 1); }
Operator* CreateBlockContext() { NOPROPS(JSCreateBlockContext, 2, 1); } const Operator* CreateBlockContext() { NOPROPS(JSCreateBlockContext, 2, 1); }
Operator* CreateModuleContext() { NOPROPS(JSCreateModuleContext, 2, 1); } const Operator* CreateModuleContext() {
Operator* CreateGlobalContext() { NOPROPS(JSCreateGlobalContext, 2, 1); } NOPROPS(JSCreateModuleContext, 2, 1);
}
const Operator* CreateGlobalContext() {
NOPROPS(JSCreateGlobalContext, 2, 1);
}
Operator* Runtime(Runtime::FunctionId function, int arguments) { const Operator* Runtime(Runtime::FunctionId function, int arguments) {
const Runtime::Function* f = Runtime::FunctionForId(function); const Runtime::Function* f = Runtime::FunctionForId(function);
DCHECK(f->nargs == -1 || f->nargs == arguments); DCHECK(f->nargs == -1 || f->nargs == arguments);
OP1(JSCallRuntime, Runtime::FunctionId, function, Operator::kNoProperties, OP1(JSCallRuntime, Runtime::FunctionId, function, Operator::kNoProperties,
...@@ -219,8 +225,9 @@ struct StaticParameterTraits<Runtime::FunctionId> { ...@@ -219,8 +225,9 @@ struct StaticParameterTraits<Runtime::FunctionId> {
return a == b; return a == b;
} }
}; };
}
} } // namespace compiler
} // namespace v8::internal::compiler } // namespace internal
} // namespace v8
#endif // V8_COMPILER_JS_OPERATOR_H_ #endif // V8_COMPILER_JS_OPERATOR_H_
...@@ -79,7 +79,7 @@ class JSBinopReduction { ...@@ -79,7 +79,7 @@ class JSBinopReduction {
// Remove all effect and control inputs and outputs to this node and change // Remove all effect and control inputs and outputs to this node and change
// to the pure operator {op}, possibly inserting a boolean inversion. // to the pure operator {op}, possibly inserting a boolean inversion.
Reduction ChangeToPureOperator(Operator* op, bool invert = false) { Reduction ChangeToPureOperator(const Operator* op, bool invert = false) {
DCHECK_EQ(0, OperatorProperties::GetEffectInputCount(op)); DCHECK_EQ(0, OperatorProperties::GetEffectInputCount(op));
DCHECK_EQ(false, OperatorProperties::HasContextInput(op)); DCHECK_EQ(false, OperatorProperties::HasContextInput(op));
DCHECK_EQ(0, OperatorProperties::GetControlInputCount(op)); DCHECK_EQ(0, OperatorProperties::GetControlInputCount(op));
...@@ -205,8 +205,8 @@ class JSBinopReduction { ...@@ -205,8 +205,8 @@ class JSBinopReduction {
if (input_type->Is(type)) return node; // already in the value range. if (input_type->Is(type)) return node; // already in the value range.
Operator* op = is_signed ? simplified()->NumberToInt32() const Operator* op = is_signed ? simplified()->NumberToInt32()
: simplified()->NumberToUint32(); : simplified()->NumberToUint32();
Node* n = graph()->NewNode(op, node); Node* n = graph()->NewNode(op, node);
return n; return n;
} }
...@@ -231,7 +231,8 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) { ...@@ -231,7 +231,8 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
} }
Reduction JSTypedLowering::ReduceNumberBinop(Node* node, Operator* numberOp) { Reduction JSTypedLowering::ReduceNumberBinop(Node* node,
const Operator* numberOp) {
JSBinopReduction r(this, node); JSBinopReduction r(this, node);
if (r.OneInputIs(Type::Primitive())) { if (r.OneInputIs(Type::Primitive())) {
// If at least one input is a primitive, then insert appropriate conversions // If at least one input is a primitive, then insert appropriate conversions
...@@ -246,7 +247,8 @@ Reduction JSTypedLowering::ReduceNumberBinop(Node* node, Operator* numberOp) { ...@@ -246,7 +247,8 @@ Reduction JSTypedLowering::ReduceNumberBinop(Node* node, Operator* numberOp) {
Reduction JSTypedLowering::ReduceI32Binop(Node* node, bool left_signed, Reduction JSTypedLowering::ReduceI32Binop(Node* node, bool left_signed,
bool right_signed, Operator* intOp) { bool right_signed,
const Operator* intOp) {
JSBinopReduction r(this, node); JSBinopReduction r(this, node);
// TODO(titzer): some Smi bitwise operations don't really require going // TODO(titzer): some Smi bitwise operations don't really require going
// all the way to int32, which can save tagging/untagging for some operations // all the way to int32, which can save tagging/untagging for some operations
...@@ -258,7 +260,7 @@ Reduction JSTypedLowering::ReduceI32Binop(Node* node, bool left_signed, ...@@ -258,7 +260,7 @@ Reduction JSTypedLowering::ReduceI32Binop(Node* node, bool left_signed,
Reduction JSTypedLowering::ReduceI32Shift(Node* node, bool left_signed, Reduction JSTypedLowering::ReduceI32Shift(Node* node, bool left_signed,
Operator* shift_op) { const Operator* shift_op) {
JSBinopReduction r(this, node); JSBinopReduction r(this, node);
r.ConvertInputsForShift(left_signed); r.ConvertInputsForShift(left_signed);
return r.ChangeToPureOperator(shift_op); return r.ChangeToPureOperator(shift_op);
...@@ -269,7 +271,7 @@ Reduction JSTypedLowering::ReduceJSComparison(Node* node) { ...@@ -269,7 +271,7 @@ Reduction JSTypedLowering::ReduceJSComparison(Node* node) {
JSBinopReduction r(this, node); JSBinopReduction r(this, node);
if (r.BothInputsAre(Type::String())) { if (r.BothInputsAre(Type::String())) {
// If both inputs are definitely strings, perform a string comparison. // If both inputs are definitely strings, perform a string comparison.
Operator* stringOp; const Operator* stringOp;
switch (node->opcode()) { switch (node->opcode()) {
case IrOpcode::kJSLessThan: case IrOpcode::kJSLessThan:
stringOp = simplified()->StringLessThan(); stringOp = simplified()->StringLessThan();
...@@ -291,8 +293,8 @@ Reduction JSTypedLowering::ReduceJSComparison(Node* node) { ...@@ -291,8 +293,8 @@ Reduction JSTypedLowering::ReduceJSComparison(Node* node) {
return r.ChangeToPureOperator(stringOp); return r.ChangeToPureOperator(stringOp);
} else if (r.OneInputCannotBe(Type::String())) { } else if (r.OneInputCannotBe(Type::String())) {
// If one input cannot be a string, then emit a number comparison. // If one input cannot be a string, then emit a number comparison.
Operator* less_than; const Operator* less_than;
Operator* less_than_or_equal; const Operator* less_than_or_equal;
if (r.BothInputsAre(Type::Unsigned32())) { if (r.BothInputsAre(Type::Unsigned32())) {
less_than = machine()->Uint32LessThan(); less_than = machine()->Uint32LessThan();
less_than_or_equal = machine()->Uint32LessThanOrEqual(); less_than_or_equal = machine()->Uint32LessThanOrEqual();
...@@ -305,7 +307,7 @@ Reduction JSTypedLowering::ReduceJSComparison(Node* node) { ...@@ -305,7 +307,7 @@ Reduction JSTypedLowering::ReduceJSComparison(Node* node) {
less_than = simplified()->NumberLessThan(); less_than = simplified()->NumberLessThan();
less_than_or_equal = simplified()->NumberLessThanOrEqual(); less_than_or_equal = simplified()->NumberLessThanOrEqual();
} }
Operator* comparison; const Operator* comparison;
switch (node->opcode()) { switch (node->opcode()) {
case IrOpcode::kJSLessThan: case IrOpcode::kJSLessThan:
comparison = less_than; comparison = less_than;
......
...@@ -45,10 +45,11 @@ class JSTypedLowering : public Reducer { ...@@ -45,10 +45,11 @@ class JSTypedLowering : public Reducer {
Reduction ReduceJSToNumberInput(Node* input); Reduction ReduceJSToNumberInput(Node* input);
Reduction ReduceJSToStringInput(Node* input); Reduction ReduceJSToStringInput(Node* input);
Reduction ReduceJSToBooleanInput(Node* input); Reduction ReduceJSToBooleanInput(Node* input);
Reduction ReduceNumberBinop(Node* node, Operator* numberOp); Reduction ReduceNumberBinop(Node* node, const Operator* numberOp);
Reduction ReduceI32Binop(Node* node, bool left_signed, bool right_signed, Reduction ReduceI32Binop(Node* node, bool left_signed, bool right_signed,
Operator* intOp); const Operator* intOp);
Reduction ReduceI32Shift(Node* node, bool left_signed, Operator* shift_op); Reduction ReduceI32Shift(Node* node, bool left_signed,
const Operator* shift_op);
JSOperatorBuilder* javascript() { return jsgraph_->javascript(); } JSOperatorBuilder* javascript() { return jsgraph_->javascript(); }
CommonOperatorBuilder* common() { return jsgraph_->common(); } CommonOperatorBuilder* common() { return jsgraph_->common(); }
......
...@@ -164,7 +164,7 @@ static const uint32_t kUint32Values[] = { ...@@ -164,7 +164,7 @@ static const uint32_t kUint32Values[] = {
namespace { namespace {
struct UnaryOperator { struct UnaryOperator {
Operator* (MachineOperatorBuilder::*constructor)(); const Operator* (MachineOperatorBuilder::*constructor)();
const char* constructor_name; const char* constructor_name;
}; };
......
...@@ -39,7 +39,7 @@ class MachineOperatorCommonTest ...@@ -39,7 +39,7 @@ class MachineOperatorCommonTest
TEST_P(MachineOperatorCommonTest, ChangeInt32ToInt64) { TEST_P(MachineOperatorCommonTest, ChangeInt32ToInt64) {
Operator* op = machine()->ChangeInt32ToInt64(); const Operator* op = machine()->ChangeInt32ToInt64();
EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op));
EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op));
EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
...@@ -49,7 +49,7 @@ TEST_P(MachineOperatorCommonTest, ChangeInt32ToInt64) { ...@@ -49,7 +49,7 @@ TEST_P(MachineOperatorCommonTest, ChangeInt32ToInt64) {
TEST_P(MachineOperatorCommonTest, ChangeUint32ToUint64) { TEST_P(MachineOperatorCommonTest, ChangeUint32ToUint64) {
Operator* op = machine()->ChangeUint32ToUint64(); const Operator* op = machine()->ChangeUint32ToUint64();
EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op));
EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op));
EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
...@@ -59,7 +59,7 @@ TEST_P(MachineOperatorCommonTest, ChangeUint32ToUint64) { ...@@ -59,7 +59,7 @@ TEST_P(MachineOperatorCommonTest, ChangeUint32ToUint64) {
TEST_P(MachineOperatorCommonTest, TruncateFloat64ToInt32) { TEST_P(MachineOperatorCommonTest, TruncateFloat64ToInt32) {
Operator* op = machine()->TruncateFloat64ToInt32(); const Operator* op = machine()->TruncateFloat64ToInt32();
EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op));
EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op));
EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
...@@ -69,7 +69,7 @@ TEST_P(MachineOperatorCommonTest, TruncateFloat64ToInt32) { ...@@ -69,7 +69,7 @@ TEST_P(MachineOperatorCommonTest, TruncateFloat64ToInt32) {
TEST_P(MachineOperatorCommonTest, TruncateInt64ToInt32) { TEST_P(MachineOperatorCommonTest, TruncateInt64ToInt32) {
Operator* op = machine()->TruncateInt64ToInt32(); const Operator* op = machine()->TruncateInt64ToInt32();
EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op));
EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op)); EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op));
EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op)); EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
......
...@@ -73,101 +73,101 @@ class MachineOperatorBuilder { ...@@ -73,101 +73,101 @@ class MachineOperatorBuilder {
#define WORD_SIZE(x) return is64() ? Word64##x() : Word32##x() #define WORD_SIZE(x) return is64() ? Word64##x() : Word32##x()
#define INT_SIZE(x) return is64() ? Int64##x() : Int32##x() #define INT_SIZE(x) return is64() ? Int64##x() : Int32##x()
Operator* Load(MachineType rep) { // load [base + index] const Operator* Load(MachineType rep) { // load [base + index]
OP1(Load, MachineType, rep, Operator::kNoWrite, 2, 1); OP1(Load, MachineType, rep, Operator::kNoWrite, 2, 1);
} }
// store [base + index], value // store [base + index], value
Operator* Store(MachineType rep, WriteBarrierKind kind) { const Operator* Store(MachineType rep, WriteBarrierKind kind) {
StoreRepresentation store_rep = {rep, kind}; StoreRepresentation store_rep = {rep, kind};
OP1(Store, StoreRepresentation, store_rep, Operator::kNoRead, 3, 0); OP1(Store, StoreRepresentation, store_rep, Operator::kNoRead, 3, 0);
} }
Operator* WordAnd() { WORD_SIZE(And); } const Operator* WordAnd() { WORD_SIZE(And); }
Operator* WordOr() { WORD_SIZE(Or); } const Operator* WordOr() { WORD_SIZE(Or); }
Operator* WordXor() { WORD_SIZE(Xor); } const Operator* WordXor() { WORD_SIZE(Xor); }
Operator* WordShl() { WORD_SIZE(Shl); } const Operator* WordShl() { WORD_SIZE(Shl); }
Operator* WordShr() { WORD_SIZE(Shr); } const Operator* WordShr() { WORD_SIZE(Shr); }
Operator* WordSar() { WORD_SIZE(Sar); } const Operator* WordSar() { WORD_SIZE(Sar); }
Operator* WordRor() { WORD_SIZE(Ror); } const Operator* WordRor() { WORD_SIZE(Ror); }
Operator* WordEqual() { WORD_SIZE(Equal); } const Operator* WordEqual() { WORD_SIZE(Equal); }
Operator* Word32And() { BINOP_AC(Word32And); } const Operator* Word32And() { BINOP_AC(Word32And); }
Operator* Word32Or() { BINOP_AC(Word32Or); } const Operator* Word32Or() { BINOP_AC(Word32Or); }
Operator* Word32Xor() { BINOP_AC(Word32Xor); } const Operator* Word32Xor() { BINOP_AC(Word32Xor); }
Operator* Word32Shl() { BINOP(Word32Shl); } const Operator* Word32Shl() { BINOP(Word32Shl); }
Operator* Word32Shr() { BINOP(Word32Shr); } const Operator* Word32Shr() { BINOP(Word32Shr); }
Operator* Word32Sar() { BINOP(Word32Sar); } const Operator* Word32Sar() { BINOP(Word32Sar); }
Operator* Word32Ror() { BINOP(Word32Ror); } const Operator* Word32Ror() { BINOP(Word32Ror); }
Operator* Word32Equal() { BINOP_C(Word32Equal); } const Operator* Word32Equal() { BINOP_C(Word32Equal); }
Operator* Word64And() { BINOP_AC(Word64And); } const Operator* Word64And() { BINOP_AC(Word64And); }
Operator* Word64Or() { BINOP_AC(Word64Or); } const Operator* Word64Or() { BINOP_AC(Word64Or); }
Operator* Word64Xor() { BINOP_AC(Word64Xor); } const Operator* Word64Xor() { BINOP_AC(Word64Xor); }
Operator* Word64Shl() { BINOP(Word64Shl); } const Operator* Word64Shl() { BINOP(Word64Shl); }
Operator* Word64Shr() { BINOP(Word64Shr); } const Operator* Word64Shr() { BINOP(Word64Shr); }
Operator* Word64Sar() { BINOP(Word64Sar); } const Operator* Word64Sar() { BINOP(Word64Sar); }
Operator* Word64Ror() { BINOP(Word64Ror); } const Operator* Word64Ror() { BINOP(Word64Ror); }
Operator* Word64Equal() { BINOP_C(Word64Equal); } const Operator* Word64Equal() { BINOP_C(Word64Equal); }
Operator* Int32Add() { BINOP_AC(Int32Add); } const Operator* Int32Add() { BINOP_AC(Int32Add); }
Operator* Int32AddWithOverflow() { BINOP_ACO(Int32AddWithOverflow); } const Operator* Int32AddWithOverflow() { BINOP_ACO(Int32AddWithOverflow); }
Operator* Int32Sub() { BINOP(Int32Sub); } const Operator* Int32Sub() { BINOP(Int32Sub); }
Operator* Int32SubWithOverflow() { BINOP_O(Int32SubWithOverflow); } const Operator* Int32SubWithOverflow() { BINOP_O(Int32SubWithOverflow); }
Operator* Int32Mul() { BINOP_AC(Int32Mul); } const Operator* Int32Mul() { BINOP_AC(Int32Mul); }
Operator* Int32Div() { BINOP(Int32Div); } const Operator* Int32Div() { BINOP(Int32Div); }
Operator* Int32UDiv() { BINOP(Int32UDiv); } const Operator* Int32UDiv() { BINOP(Int32UDiv); }
Operator* Int32Mod() { BINOP(Int32Mod); } const Operator* Int32Mod() { BINOP(Int32Mod); }
Operator* Int32UMod() { BINOP(Int32UMod); } const Operator* Int32UMod() { BINOP(Int32UMod); }
Operator* Int32LessThan() { BINOP(Int32LessThan); } const Operator* Int32LessThan() { BINOP(Int32LessThan); }
Operator* Int32LessThanOrEqual() { BINOP(Int32LessThanOrEqual); } const Operator* Int32LessThanOrEqual() { BINOP(Int32LessThanOrEqual); }
Operator* Uint32LessThan() { BINOP(Uint32LessThan); } const Operator* Uint32LessThan() { BINOP(Uint32LessThan); }
Operator* Uint32LessThanOrEqual() { BINOP(Uint32LessThanOrEqual); } const Operator* Uint32LessThanOrEqual() { BINOP(Uint32LessThanOrEqual); }
Operator* Int64Add() { BINOP_AC(Int64Add); } const Operator* Int64Add() { BINOP_AC(Int64Add); }
Operator* Int64Sub() { BINOP(Int64Sub); } const Operator* Int64Sub() { BINOP(Int64Sub); }
Operator* Int64Mul() { BINOP_AC(Int64Mul); } const Operator* Int64Mul() { BINOP_AC(Int64Mul); }
Operator* Int64Div() { BINOP(Int64Div); } const Operator* Int64Div() { BINOP(Int64Div); }
Operator* Int64UDiv() { BINOP(Int64UDiv); } const Operator* Int64UDiv() { BINOP(Int64UDiv); }
Operator* Int64Mod() { BINOP(Int64Mod); } const Operator* Int64Mod() { BINOP(Int64Mod); }
Operator* Int64UMod() { BINOP(Int64UMod); } const Operator* Int64UMod() { BINOP(Int64UMod); }
Operator* Int64LessThan() { BINOP(Int64LessThan); } const Operator* Int64LessThan() { BINOP(Int64LessThan); }
Operator* Int64LessThanOrEqual() { BINOP(Int64LessThanOrEqual); } const Operator* Int64LessThanOrEqual() { BINOP(Int64LessThanOrEqual); }
// Signed comparison of word-sized integer values, translates to int32/int64 // Signed comparison of word-sized integer values, translates to int32/int64
// comparisons depending on the word-size of the machine. // comparisons depending on the word-size of the machine.
Operator* IntLessThan() { INT_SIZE(LessThan); } const Operator* IntLessThan() { INT_SIZE(LessThan); }
Operator* IntLessThanOrEqual() { INT_SIZE(LessThanOrEqual); } const Operator* IntLessThanOrEqual() { INT_SIZE(LessThanOrEqual); }
// Convert representation of integers between float64 and int32/uint32. // Convert representation of integers between float64 and int32/uint32.
// The precise rounding mode and handling of out of range inputs are *not* // The precise rounding mode and handling of out of range inputs are *not*
// defined for these operators, since they are intended only for use with // defined for these operators, since they are intended only for use with
// integers. // integers.
Operator* ChangeInt32ToFloat64() { UNOP(ChangeInt32ToFloat64); } const Operator* ChangeInt32ToFloat64() { UNOP(ChangeInt32ToFloat64); }
Operator* ChangeUint32ToFloat64() { UNOP(ChangeUint32ToFloat64); } const Operator* ChangeUint32ToFloat64() { UNOP(ChangeUint32ToFloat64); }
Operator* ChangeFloat64ToInt32() { UNOP(ChangeFloat64ToInt32); } const Operator* ChangeFloat64ToInt32() { UNOP(ChangeFloat64ToInt32); }
Operator* ChangeFloat64ToUint32() { UNOP(ChangeFloat64ToUint32); } const Operator* ChangeFloat64ToUint32() { UNOP(ChangeFloat64ToUint32); }
// Sign/zero extend int32/uint32 to int64/uint64. // Sign/zero extend int32/uint32 to int64/uint64.
Operator* ChangeInt32ToInt64() { UNOP(ChangeInt32ToInt64); } const Operator* ChangeInt32ToInt64() { UNOP(ChangeInt32ToInt64); }
Operator* ChangeUint32ToUint64() { UNOP(ChangeUint32ToUint64); } const Operator* ChangeUint32ToUint64() { UNOP(ChangeUint32ToUint64); }
// Truncate double to int32 using JavaScript semantics. // Truncate double to int32 using JavaScript semantics.
Operator* TruncateFloat64ToInt32() { UNOP(TruncateFloat64ToInt32); } const Operator* TruncateFloat64ToInt32() { UNOP(TruncateFloat64ToInt32); }
// Truncate the high order bits and convert the remaining bits to int32. // Truncate the high order bits and convert the remaining bits to int32.
Operator* TruncateInt64ToInt32() { UNOP(TruncateInt64ToInt32); } const Operator* TruncateInt64ToInt32() { UNOP(TruncateInt64ToInt32); }
// Floating point operators always operate with IEEE 754 round-to-nearest. // Floating point operators always operate with IEEE 754 round-to-nearest.
Operator* Float64Add() { BINOP_C(Float64Add); } const Operator* Float64Add() { BINOP_C(Float64Add); }
Operator* Float64Sub() { BINOP(Float64Sub); } const Operator* Float64Sub() { BINOP(Float64Sub); }
Operator* Float64Mul() { BINOP_C(Float64Mul); } const Operator* Float64Mul() { BINOP_C(Float64Mul); }
Operator* Float64Div() { BINOP(Float64Div); } const Operator* Float64Div() { BINOP(Float64Div); }
Operator* Float64Mod() { BINOP(Float64Mod); } const Operator* Float64Mod() { BINOP(Float64Mod); }
// Floating point comparisons complying to IEEE 754. // Floating point comparisons complying to IEEE 754.
Operator* Float64Equal() { BINOP_C(Float64Equal); } const Operator* Float64Equal() { BINOP_C(Float64Equal); }
Operator* Float64LessThan() { BINOP(Float64LessThan); } const Operator* Float64LessThan() { BINOP(Float64LessThan); }
Operator* Float64LessThanOrEqual() { BINOP(Float64LessThanOrEqual); } const Operator* Float64LessThanOrEqual() { BINOP(Float64LessThanOrEqual); }
inline bool is32() const { return word_ == kRepWord32; } inline bool is32() const { return word_ == kRepWord32; }
inline bool is64() const { return word_ == kRepWord64; } inline bool is64() const { return word_ == kRepWord64; }
...@@ -184,8 +184,9 @@ class MachineOperatorBuilder { ...@@ -184,8 +184,9 @@ class MachineOperatorBuilder {
Zone* zone_; Zone* zone_;
MachineType word_; MachineType word_;
}; };
}
} } // namespace compiler
} // namespace v8::internal::compiler } // namespace internal
} // namespace v8
#endif // V8_COMPILER_MACHINE_OPERATOR_H_ #endif // V8_COMPILER_MACHINE_OPERATOR_H_
...@@ -149,7 +149,7 @@ BasicBlock* RawMachineAssembler::CurrentBlock() { ...@@ -149,7 +149,7 @@ BasicBlock* RawMachineAssembler::CurrentBlock() {
} }
Node* RawMachineAssembler::MakeNode(Operator* op, int input_count, Node* RawMachineAssembler::MakeNode(const Operator* op, int input_count,
Node** inputs) { Node** inputs) {
DCHECK(ScheduleValid()); DCHECK(ScheduleValid());
DCHECK(current_block_ != NULL); DCHECK(current_block_ != NULL);
......
...@@ -423,7 +423,8 @@ class RawMachineAssembler : public GraphBuilder { ...@@ -423,7 +423,8 @@ class RawMachineAssembler : public GraphBuilder {
Schedule* Export(); Schedule* Export();
protected: protected:
virtual Node* MakeNode(Operator* op, int input_count, Node** inputs); virtual Node* MakeNode(const Operator* op, int input_count,
Node** inputs) FINAL;
bool ScheduleValid() { return schedule_ != NULL; } bool ScheduleValid() { return schedule_ != NULL; }
......
...@@ -91,7 +91,7 @@ class RepresentationChanger { ...@@ -91,7 +91,7 @@ class RepresentationChanger {
break; break;
} }
// Select the correct X -> Tagged operator. // Select the correct X -> Tagged operator.
Operator* op; const Operator* op;
if (output_type & kRepBit) { if (output_type & kRepBit) {
op = simplified()->ChangeBitToBool(); op = simplified()->ChangeBitToBool();
} else if (output_type & rWord) { } else if (output_type & rWord) {
...@@ -129,7 +129,7 @@ class RepresentationChanger { ...@@ -129,7 +129,7 @@ class RepresentationChanger {
break; break;
} }
// Select the correct X -> Float64 operator. // Select the correct X -> Float64 operator.
Operator* op; const Operator* op;
if (output_type & kRepBit) { if (output_type & kRepBit) {
return TypeError(node, output_type, kRepFloat64); return TypeError(node, output_type, kRepFloat64);
} else if (output_type & rWord) { } else if (output_type & rWord) {
...@@ -169,7 +169,7 @@ class RepresentationChanger { ...@@ -169,7 +169,7 @@ class RepresentationChanger {
break; break;
} }
// Select the correct X -> Word32 operator. // Select the correct X -> Word32 operator.
Operator* op = NULL; const Operator* op = NULL;
if (output_type & kRepFloat64) { if (output_type & kRepFloat64) {
if (output_type & kTypeUint32 || use_unsigned) { if (output_type & kTypeUint32 || use_unsigned) {
op = machine()->ChangeFloat64ToUint32(); op = machine()->ChangeFloat64ToUint32();
...@@ -207,7 +207,7 @@ class RepresentationChanger { ...@@ -207,7 +207,7 @@ class RepresentationChanger {
break; break;
} }
// Select the correct X -> Bit operator. // Select the correct X -> Bit operator.
Operator* op; const Operator* op;
if (output_type & rWord) { if (output_type & rWord) {
return node; // No change necessary. return node; // No change necessary.
} else if (output_type & kRepWord64) { } else if (output_type & kRepWord64) {
...@@ -228,7 +228,7 @@ class RepresentationChanger { ...@@ -228,7 +228,7 @@ class RepresentationChanger {
return TypeError(node, output_type, kRepWord64); return TypeError(node, output_type, kRepWord64);
} }
Operator* Int32OperatorFor(IrOpcode::Value opcode) { const Operator* Int32OperatorFor(IrOpcode::Value opcode) {
switch (opcode) { switch (opcode) {
case IrOpcode::kNumberAdd: case IrOpcode::kNumberAdd:
return machine()->Int32Add(); return machine()->Int32Add();
...@@ -246,7 +246,7 @@ class RepresentationChanger { ...@@ -246,7 +246,7 @@ class RepresentationChanger {
} }
} }
Operator* Uint32OperatorFor(IrOpcode::Value opcode) { const Operator* Uint32OperatorFor(IrOpcode::Value opcode) {
switch (opcode) { switch (opcode) {
case IrOpcode::kNumberAdd: case IrOpcode::kNumberAdd:
return machine()->Int32Add(); return machine()->Int32Add();
...@@ -264,7 +264,7 @@ class RepresentationChanger { ...@@ -264,7 +264,7 @@ class RepresentationChanger {
} }
} }
Operator* Float64OperatorFor(IrOpcode::Value opcode) { const Operator* Float64OperatorFor(IrOpcode::Value opcode) {
switch (opcode) { switch (opcode) {
case IrOpcode::kNumberAdd: case IrOpcode::kNumberAdd:
return machine()->Float64Add(); return machine()->Float64Add();
......
...@@ -336,15 +336,15 @@ class RepresentationSelector { ...@@ -336,15 +336,15 @@ class RepresentationSelector {
} }
} }
Operator* Int32Op(Node* node) { const Operator* Int32Op(Node* node) {
return changer_->Int32OperatorFor(node->opcode()); return changer_->Int32OperatorFor(node->opcode());
} }
Operator* Uint32Op(Node* node) { const Operator* Uint32Op(Node* node) {
return changer_->Uint32OperatorFor(node->opcode()); return changer_->Uint32OperatorFor(node->opcode());
} }
Operator* Float64Op(Node* node) { const Operator* Float64Op(Node* node) {
return changer_->Float64OperatorFor(node->opcode()); return changer_->Float64OperatorFor(node->opcode());
} }
......
...@@ -128,7 +128,7 @@ MATCHER(IsNaN, std::string(negation ? "isn't" : "is") + " NaN") { ...@@ -128,7 +128,7 @@ MATCHER(IsNaN, std::string(negation ? "isn't" : "is") + " NaN") {
namespace { namespace {
struct UnaryOperator { struct UnaryOperator {
Operator* (SimplifiedOperatorBuilder::*constructor)() const; const Operator* (SimplifiedOperatorBuilder::*constructor)() const;
const char* constructor_name; const char* constructor_name;
}; };
......
...@@ -102,7 +102,8 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) { ...@@ -102,7 +102,8 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
} }
Reduction SimplifiedOperatorReducer::Change(Node* node, Operator* op, Node* a) { Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op,
Node* a) {
node->set_op(op); node->set_op(op);
node->ReplaceInput(0, a); node->ReplaceInput(0, a);
return Changed(node); return Changed(node);
......
...@@ -28,7 +28,7 @@ class SimplifiedOperatorReducer FINAL : public Reducer { ...@@ -28,7 +28,7 @@ class SimplifiedOperatorReducer FINAL : public Reducer {
virtual Reduction Reduce(Node* node) OVERRIDE; virtual Reduction Reduce(Node* node) OVERRIDE;
private: private:
Reduction Change(Node* node, Operator* op, Node* a); Reduction Change(Node* node, const Operator* op, Node* a);
Reduction ReplaceFloat64(double value); Reduction ReplaceFloat64(double value);
Reduction ReplaceInt32(int32_t value); Reduction ReplaceInt32(int32_t value);
Reduction ReplaceUint32(uint32_t value) { Reduction ReplaceUint32(uint32_t value) {
......
...@@ -133,45 +133,49 @@ class SimplifiedOperatorBuilder { ...@@ -133,45 +133,49 @@ class SimplifiedOperatorBuilder {
#define UNOP(name) SIMPLE(name, Operator::kPure, 1, 1) #define UNOP(name) SIMPLE(name, Operator::kPure, 1, 1)
#define BINOP(name) SIMPLE(name, Operator::kPure, 2, 1) #define BINOP(name) SIMPLE(name, Operator::kPure, 2, 1)
Operator* BooleanNot() const { UNOP(BooleanNot); } const Operator* BooleanNot() const { UNOP(BooleanNot); }
Operator* NumberEqual() const { BINOP(NumberEqual); } const Operator* NumberEqual() const { BINOP(NumberEqual); }
Operator* NumberLessThan() const { BINOP(NumberLessThan); } const Operator* NumberLessThan() const { BINOP(NumberLessThan); }
Operator* NumberLessThanOrEqual() const { BINOP(NumberLessThanOrEqual); } const Operator* NumberLessThanOrEqual() const {
Operator* NumberAdd() const { BINOP(NumberAdd); } BINOP(NumberLessThanOrEqual);
Operator* NumberSubtract() const { BINOP(NumberSubtract); } }
Operator* NumberMultiply() const { BINOP(NumberMultiply); } const Operator* NumberAdd() const { BINOP(NumberAdd); }
Operator* NumberDivide() const { BINOP(NumberDivide); } const Operator* NumberSubtract() const { BINOP(NumberSubtract); }
Operator* NumberModulus() const { BINOP(NumberModulus); } const Operator* NumberMultiply() const { BINOP(NumberMultiply); }
Operator* NumberToInt32() const { UNOP(NumberToInt32); } const Operator* NumberDivide() const { BINOP(NumberDivide); }
Operator* NumberToUint32() const { UNOP(NumberToUint32); } const Operator* NumberModulus() const { BINOP(NumberModulus); }
const Operator* NumberToInt32() const { UNOP(NumberToInt32); }
Operator* ReferenceEqual(Type* type) const { BINOP(ReferenceEqual); } const Operator* NumberToUint32() const { UNOP(NumberToUint32); }
Operator* StringEqual() const { BINOP(StringEqual); } const Operator* ReferenceEqual(Type* type) const { BINOP(ReferenceEqual); }
Operator* StringLessThan() const { BINOP(StringLessThan); }
Operator* StringLessThanOrEqual() const { BINOP(StringLessThanOrEqual); } const Operator* StringEqual() const { BINOP(StringEqual); }
Operator* StringAdd() const { BINOP(StringAdd); } const Operator* StringLessThan() const { BINOP(StringLessThan); }
const Operator* StringLessThanOrEqual() const {
Operator* ChangeTaggedToInt32() const { UNOP(ChangeTaggedToInt32); } BINOP(StringLessThanOrEqual);
Operator* ChangeTaggedToUint32() const { UNOP(ChangeTaggedToUint32); } }
Operator* ChangeTaggedToFloat64() const { UNOP(ChangeTaggedToFloat64); } const Operator* StringAdd() const { BINOP(StringAdd); }
Operator* ChangeInt32ToTagged() const { UNOP(ChangeInt32ToTagged); }
Operator* ChangeUint32ToTagged() const { UNOP(ChangeUint32ToTagged); } const Operator* ChangeTaggedToInt32() const { UNOP(ChangeTaggedToInt32); }
Operator* ChangeFloat64ToTagged() const { UNOP(ChangeFloat64ToTagged); } const Operator* ChangeTaggedToUint32() const { UNOP(ChangeTaggedToUint32); }
Operator* ChangeBoolToBit() const { UNOP(ChangeBoolToBit); } const Operator* ChangeTaggedToFloat64() const { UNOP(ChangeTaggedToFloat64); }
Operator* ChangeBitToBool() const { UNOP(ChangeBitToBool); } const Operator* ChangeInt32ToTagged() const { UNOP(ChangeInt32ToTagged); }
const Operator* ChangeUint32ToTagged() const { UNOP(ChangeUint32ToTagged); }
Operator* LoadField(const FieldAccess& access) const { const Operator* ChangeFloat64ToTagged() const { UNOP(ChangeFloat64ToTagged); }
const Operator* ChangeBoolToBit() const { UNOP(ChangeBoolToBit); }
const Operator* ChangeBitToBool() const { UNOP(ChangeBitToBool); }
const Operator* LoadField(const FieldAccess& access) const {
OP1(LoadField, FieldAccess, access, Operator::kNoWrite, 1, 1); OP1(LoadField, FieldAccess, access, Operator::kNoWrite, 1, 1);
} }
Operator* StoreField(const FieldAccess& access) const { const Operator* StoreField(const FieldAccess& access) const {
OP1(StoreField, FieldAccess, access, Operator::kNoRead, 2, 0); OP1(StoreField, FieldAccess, access, Operator::kNoRead, 2, 0);
} }
Operator* LoadElement(const ElementAccess& access) const { const Operator* LoadElement(const ElementAccess& access) const {
OP1(LoadElement, ElementAccess, access, Operator::kNoWrite, 2, 1); OP1(LoadElement, ElementAccess, access, Operator::kNoWrite, 2, 1);
} }
Operator* StoreElement(const ElementAccess& access) const { const Operator* StoreElement(const ElementAccess& access) const {
OP1(StoreElement, ElementAccess, access, Operator::kNoRead, 3, 0); OP1(StoreElement, ElementAccess, access, Operator::kNoRead, 3, 0);
} }
......
...@@ -242,7 +242,7 @@ class CompareWrapper { ...@@ -242,7 +242,7 @@ class CompareWrapper {
return m->NewNode(op(m->machine()), a, b); return m->NewNode(op(m->machine()), a, b);
} }
Operator* op(MachineOperatorBuilder* machine) { const Operator* op(MachineOperatorBuilder* machine) {
switch (opcode) { switch (opcode) {
case IrOpcode::kWord32Equal: case IrOpcode::kWord32Equal:
return machine->Word32Equal(); return machine->Word32Equal();
......
...@@ -26,8 +26,8 @@ class DirectGraphBuilder : public GraphBuilder { ...@@ -26,8 +26,8 @@ class DirectGraphBuilder : public GraphBuilder {
virtual ~DirectGraphBuilder() {} virtual ~DirectGraphBuilder() {}
protected: protected:
virtual Node* MakeNode(Operator* op, int value_input_count, virtual Node* MakeNode(const Operator* op, int value_input_count,
Node** value_inputs) { Node** value_inputs) FINAL {
return graph()->NewNode(op, value_input_count, value_inputs); return graph()->NewNode(op, value_input_count, value_inputs);
} }
}; };
......
...@@ -43,7 +43,8 @@ void SimplifiedGraphBuilder::End() { ...@@ -43,7 +43,8 @@ void SimplifiedGraphBuilder::End() {
} }
Node* SimplifiedGraphBuilder::MakeNode(Operator* op, int value_input_count, Node* SimplifiedGraphBuilder::MakeNode(const Operator* op,
int value_input_count,
Node** value_inputs) { Node** value_inputs) {
DCHECK(op->InputCount() == value_input_count); DCHECK(op->InputCount() == value_input_count);
......
...@@ -136,8 +136,8 @@ class SimplifiedGraphBuilder : public GraphBuilder { ...@@ -136,8 +136,8 @@ class SimplifiedGraphBuilder : public GraphBuilder {
} }
protected: protected:
virtual Node* MakeNode(Operator* op, int value_input_count, virtual Node* MakeNode(const Operator* op, int value_input_count,
Node** value_inputs); Node** value_inputs) FINAL;
private: private:
Node* effect_; Node* effect_;
......
...@@ -99,7 +99,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -99,7 +99,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number)); CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number));
} }
void BuildAndLower(Operator* op) { void BuildAndLower(const Operator* op) {
// We build a graph by hand here, because the raw machine assembler // We build a graph by hand here, because the raw machine assembler
// does not add the correct control and effect nodes. // does not add the correct control and effect nodes.
Node* p0 = this->Parameter(0); Node* p0 = this->Parameter(0);
...@@ -111,7 +111,8 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -111,7 +111,8 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
LowerChange(change); LowerChange(change);
} }
void BuildStoreAndLower(Operator* op, Operator* store_op, void* location) { void BuildStoreAndLower(const Operator* op, const Operator* store_op,
void* location) {
// We build a graph by hand here, because the raw machine assembler // We build a graph by hand here, because the raw machine assembler
// does not add the correct control and effect nodes. // does not add the correct control and effect nodes.
Node* p0 = this->Parameter(0); Node* p0 = this->Parameter(0);
...@@ -126,7 +127,8 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -126,7 +127,8 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
LowerChange(change); LowerChange(change);
} }
void BuildLoadAndLower(Operator* op, Operator* load_op, void* location) { void BuildLoadAndLower(const Operator* op, const Operator* load_op,
void* location) {
// We build a graph by hand here, because the raw machine assembler // We build a graph by hand here, because the raw machine assembler
// does not add the correct control and effect nodes. // does not add the correct control and effect nodes.
Node* load = Node* load =
......
...@@ -33,8 +33,8 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -33,8 +33,8 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
} }
Isolate* isolate; Isolate* isolate;
Operator* binop; const Operator* binop;
Operator* unop; const Operator* unop;
JSOperatorBuilder javascript; JSOperatorBuilder javascript;
MachineOperatorBuilder machine; MachineOperatorBuilder machine;
SimplifiedOperatorBuilder simplified; SimplifiedOperatorBuilder simplified;
...@@ -73,25 +73,25 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -73,25 +73,25 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
CHECK_EQ(2, node->InputCount()); // should not have context, effect, etc. CHECK_EQ(2, node->InputCount()); // should not have context, effect, etc.
} }
void CheckPureBinop(Operator* expected, Node* node) { void CheckPureBinop(const Operator* expected, Node* node) {
CHECK_EQ(expected->opcode(), node->op()->opcode()); CHECK_EQ(expected->opcode(), node->op()->opcode());
CHECK_EQ(2, node->InputCount()); // should not have context, effect, etc. CHECK_EQ(2, node->InputCount()); // should not have context, effect, etc.
} }
Node* ReduceUnop(Operator* op, Type* input_type) { Node* ReduceUnop(const Operator* op, Type* input_type) {
return reduce(Unop(op, Parameter(input_type))); return reduce(Unop(op, Parameter(input_type)));
} }
Node* ReduceBinop(Operator* op, Type* left_type, Type* right_type) { Node* ReduceBinop(const Operator* op, Type* left_type, Type* right_type) {
return reduce(Binop(op, Parameter(left_type, 0), Parameter(right_type, 1))); return reduce(Binop(op, Parameter(left_type, 0), Parameter(right_type, 1)));
} }
Node* Binop(Operator* op, Node* left, Node* right) { Node* Binop(const Operator* op, Node* left, Node* right) {
// JS binops also require context, effect, and control // JS binops also require context, effect, and control
return graph.NewNode(op, left, right, context(), start(), control()); return graph.NewNode(op, left, right, context(), start(), control());
} }
Node* Unop(Operator* op, Node* input) { Node* Unop(const Operator* op, Node* input) {
// JS unops also require context, effect, and control // JS unops also require context, effect, and control
return graph.NewNode(op, input, context(), start(), control()); return graph.NewNode(op, input, context(), start(), control());
} }
...@@ -206,7 +206,7 @@ TEST(AddNumber1) { ...@@ -206,7 +206,7 @@ TEST(AddNumber1) {
TEST(NumberBinops) { TEST(NumberBinops) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* ops[] = { const Operator* ops[] = {
R.javascript.Add(), R.simplified.NumberAdd(), R.javascript.Add(), R.simplified.NumberAdd(),
R.javascript.Subtract(), R.simplified.NumberSubtract(), R.javascript.Subtract(), R.simplified.NumberSubtract(),
R.javascript.Multiply(), R.simplified.NumberMultiply(), R.javascript.Multiply(), R.simplified.NumberMultiply(),
...@@ -253,7 +253,7 @@ static void CheckToI32(Node* old_input, Node* new_input, bool is_signed) { ...@@ -253,7 +253,7 @@ static void CheckToI32(Node* old_input, Node* new_input, bool is_signed) {
class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester { class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester {
public: public:
static const int kNumberOps = 6; static const int kNumberOps = 6;
Operator* ops[kNumberOps]; const Operator* ops[kNumberOps];
bool signedness[kNumberOps]; bool signedness[kNumberOps];
JSBitwiseShiftTypedLoweringTester() { JSBitwiseShiftTypedLoweringTester() {
...@@ -267,7 +267,7 @@ class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester { ...@@ -267,7 +267,7 @@ class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester {
} }
private: private:
void set(int idx, Operator* op, bool s) { void set(int idx, const Operator* op, bool s) {
ops[idx] = op; ops[idx] = op;
signedness[idx] = s; signedness[idx] = s;
} }
...@@ -313,7 +313,7 @@ TEST(Int32BitwiseShifts) { ...@@ -313,7 +313,7 @@ TEST(Int32BitwiseShifts) {
class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester { class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester {
public: public:
static const int kNumberOps = 6; static const int kNumberOps = 6;
Operator* ops[kNumberOps]; const Operator* ops[kNumberOps];
bool signedness[kNumberOps]; bool signedness[kNumberOps];
JSBitwiseTypedLoweringTester() { JSBitwiseTypedLoweringTester() {
...@@ -327,7 +327,7 @@ class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester { ...@@ -327,7 +327,7 @@ class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester {
} }
private: private:
void set(int idx, Operator* op, bool s) { void set(int idx, const Operator* op, bool s) {
ops[idx] = op; ops[idx] = op;
signedness[idx] = s; signedness[idx] = s;
} }
...@@ -366,7 +366,7 @@ TEST(Int32BitwiseBinops) { ...@@ -366,7 +366,7 @@ TEST(Int32BitwiseBinops) {
TEST(JSToNumber1) { TEST(JSToNumber1) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* ton = R.javascript.ToNumber(); const Operator* ton = R.javascript.ToNumber();
for (size_t i = 0; i < arraysize(kNumberTypes); i++) { // ToNumber(number) for (size_t i = 0; i < arraysize(kNumberTypes); i++) { // ToNumber(number)
Node* r = R.ReduceUnop(ton, kNumberTypes[i]); Node* r = R.ReduceUnop(ton, kNumberTypes[i]);
...@@ -416,9 +416,10 @@ TEST(JSToNumber_replacement) { ...@@ -416,9 +416,10 @@ TEST(JSToNumber_replacement) {
TEST(JSToNumberOfConstant) { TEST(JSToNumberOfConstant) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* ops[] = {R.common.NumberConstant(0), R.common.NumberConstant(-1), const Operator* ops[] = {
R.common.NumberConstant(0.1), R.common.Int32Constant(1177), R.common.NumberConstant(0), R.common.NumberConstant(-1),
R.common.Float64Constant(0.99)}; R.common.NumberConstant(0.1), R.common.Int32Constant(1177),
R.common.Float64Constant(0.99)};
for (size_t i = 0; i < arraysize(ops); i++) { for (size_t i = 0; i < arraysize(ops); i++) {
Node* n = R.graph.NewNode(ops[i]); Node* n = R.graph.NewNode(ops[i]);
...@@ -455,7 +456,7 @@ TEST(JSToNumberOfNumberOrOtherPrimitive) { ...@@ -455,7 +456,7 @@ TEST(JSToNumberOfNumberOrOtherPrimitive) {
TEST(JSToBoolean) { TEST(JSToBoolean) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* op = R.javascript.ToBoolean(); const Operator* op = R.javascript.ToBoolean();
{ // ToBoolean(undefined) { // ToBoolean(undefined)
Node* r = R.ReduceUnop(op, Type::Undefined()); Node* r = R.ReduceUnop(op, Type::Undefined());
...@@ -543,7 +544,7 @@ TEST(JSToString1) { ...@@ -543,7 +544,7 @@ TEST(JSToString1) {
CHECK_EQ(IrOpcode::kParameter, r->opcode()); CHECK_EQ(IrOpcode::kParameter, r->opcode());
} }
Operator* op = R.javascript.ToString(); const Operator* op = R.javascript.ToString();
{ // ToString(undefined) => "undefined" { // ToString(undefined) => "undefined"
Node* r = R.ReduceUnop(op, Type::Undefined()); Node* r = R.ReduceUnop(op, Type::Undefined());
...@@ -610,7 +611,7 @@ TEST(JSToString_replacement) { ...@@ -610,7 +611,7 @@ TEST(JSToString_replacement) {
TEST(StringComparison) { TEST(StringComparison) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* ops[] = { const Operator* ops[] = {
R.javascript.LessThan(), R.simplified.StringLessThan(), R.javascript.LessThan(), R.simplified.StringLessThan(),
R.javascript.LessThanOrEqual(), R.simplified.StringLessThanOrEqual(), R.javascript.LessThanOrEqual(), R.simplified.StringLessThanOrEqual(),
R.javascript.GreaterThan(), R.simplified.StringLessThan(), R.javascript.GreaterThan(), R.simplified.StringLessThan(),
...@@ -655,7 +656,7 @@ static void CheckIsConvertedToNumber(Node* val, Node* converted) { ...@@ -655,7 +656,7 @@ static void CheckIsConvertedToNumber(Node* val, Node* converted) {
TEST(NumberComparison) { TEST(NumberComparison) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* ops[] = { const Operator* ops[] = {
R.javascript.LessThan(), R.simplified.NumberLessThan(), R.javascript.LessThan(), R.simplified.NumberLessThan(),
R.javascript.LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(), R.javascript.LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(),
R.javascript.GreaterThan(), R.simplified.NumberLessThan(), R.javascript.GreaterThan(), R.simplified.NumberLessThan(),
...@@ -755,7 +756,7 @@ TEST(ObjectComparison) { ...@@ -755,7 +756,7 @@ TEST(ObjectComparison) {
TEST(UnaryNot) { TEST(UnaryNot) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* opnot = R.javascript.UnaryNot(); const Operator* opnot = R.javascript.UnaryNot();
for (size_t i = 0; i < arraysize(kJSTypes); i++) { for (size_t i = 0; i < arraysize(kJSTypes); i++) {
Node* orig = R.Unop(opnot, R.Parameter(kJSTypes[i])); Node* orig = R.Unop(opnot, R.Parameter(kJSTypes[i]));
...@@ -832,7 +833,7 @@ TEST(RemoveToNumberEffects) { ...@@ -832,7 +833,7 @@ TEST(RemoveToNumberEffects) {
// Helper class for testing the reduction of a single binop. // Helper class for testing the reduction of a single binop.
class BinopEffectsTester { class BinopEffectsTester {
public: public:
explicit BinopEffectsTester(Operator* op, Type* t0, Type* t1) explicit BinopEffectsTester(const Operator* op, Type* t0, Type* t1)
: R(), : R(),
p0(R.Parameter(t0, 0)), p0(R.Parameter(t0, 0)),
p1(R.Parameter(t1, 1)), p1(R.Parameter(t1, 1)),
...@@ -961,7 +962,7 @@ TEST(StringEquality) { ...@@ -961,7 +962,7 @@ TEST(StringEquality) {
TEST(RemovePureNumberBinopEffects) { TEST(RemovePureNumberBinopEffects) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* ops[] = { const Operator* ops[] = {
R.javascript.Equal(), R.simplified.NumberEqual(), R.javascript.Equal(), R.simplified.NumberEqual(),
R.javascript.Add(), R.simplified.NumberAdd(), R.javascript.Add(), R.simplified.NumberAdd(),
R.javascript.Subtract(), R.simplified.NumberSubtract(), R.javascript.Subtract(), R.simplified.NumberSubtract(),
...@@ -989,7 +990,7 @@ TEST(RemovePureNumberBinopEffects) { ...@@ -989,7 +990,7 @@ TEST(RemovePureNumberBinopEffects) {
TEST(OrderNumberBinopEffects1) { TEST(OrderNumberBinopEffects1) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* ops[] = { const Operator* ops[] = {
R.javascript.Subtract(), R.simplified.NumberSubtract(), R.javascript.Subtract(), R.simplified.NumberSubtract(),
R.javascript.Multiply(), R.simplified.NumberMultiply(), R.javascript.Multiply(), R.simplified.NumberMultiply(),
R.javascript.Divide(), R.simplified.NumberDivide(), R.javascript.Divide(), R.simplified.NumberDivide(),
...@@ -1015,7 +1016,7 @@ TEST(OrderNumberBinopEffects1) { ...@@ -1015,7 +1016,7 @@ TEST(OrderNumberBinopEffects1) {
TEST(OrderNumberBinopEffects2) { TEST(OrderNumberBinopEffects2) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* ops[] = { const Operator* ops[] = {
R.javascript.Add(), R.simplified.NumberAdd(), R.javascript.Add(), R.simplified.NumberAdd(),
R.javascript.Subtract(), R.simplified.NumberSubtract(), R.javascript.Subtract(), R.simplified.NumberSubtract(),
R.javascript.Multiply(), R.simplified.NumberMultiply(), R.javascript.Multiply(), R.simplified.NumberMultiply(),
...@@ -1054,7 +1055,7 @@ TEST(OrderNumberBinopEffects2) { ...@@ -1054,7 +1055,7 @@ TEST(OrderNumberBinopEffects2) {
TEST(OrderCompareEffects) { TEST(OrderCompareEffects) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* ops[] = { const Operator* ops[] = {
R.javascript.GreaterThan(), R.simplified.NumberLessThan(), R.javascript.GreaterThan(), R.simplified.NumberLessThan(),
R.javascript.GreaterThanOrEqual(), R.simplified.NumberLessThanOrEqual(), R.javascript.GreaterThanOrEqual(), R.simplified.NumberLessThanOrEqual(),
}; };
...@@ -1187,7 +1188,7 @@ TEST(Int32BinopEffects) { ...@@ -1187,7 +1188,7 @@ TEST(Int32BinopEffects) {
TEST(UnaryNotEffects) { TEST(UnaryNotEffects) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
Operator* opnot = R.javascript.UnaryNot(); const Operator* opnot = R.javascript.UnaryNot();
for (size_t i = 0; i < arraysize(kJSTypes); i++) { for (size_t i = 0; i < arraysize(kJSTypes); i++) {
Node* p0 = R.Parameter(kJSTypes[i], 0); Node* p0 = R.Parameter(kJSTypes[i], 0);
...@@ -1299,10 +1300,10 @@ TEST(Int32Comparisons) { ...@@ -1299,10 +1300,10 @@ TEST(Int32Comparisons) {
JSTypedLoweringTester R; JSTypedLoweringTester R;
struct Entry { struct Entry {
Operator* js_op; const Operator* js_op;
Operator* uint_op; const Operator* uint_op;
Operator* int_op; const Operator* int_op;
Operator* num_op; const Operator* num_op;
bool commute; bool commute;
}; };
...@@ -1330,7 +1331,7 @@ TEST(Int32Comparisons) { ...@@ -1330,7 +1331,7 @@ TEST(Int32Comparisons) {
Node* cmp = R.Binop(ops[o].js_op, p0, p1); Node* cmp = R.Binop(ops[o].js_op, p0, p1);
Node* r = R.reduce(cmp); Node* r = R.reduce(cmp);
Operator* expected; const Operator* expected;
if (t0->Is(Type::Unsigned32()) && t1->Is(Type::Unsigned32())) { if (t0->Is(Type::Unsigned32()) && t1->Is(Type::Unsigned32())) {
expected = ops[o].uint_op; expected = ops[o].uint_op;
} else if (t0->Is(Type::Signed32()) && t1->Is(Type::Signed32())) { } else if (t0->Is(Type::Signed32()) && t1->Is(Type::Signed32())) {
......
...@@ -15,17 +15,18 @@ using namespace v8::internal; ...@@ -15,17 +15,18 @@ using namespace v8::internal;
using namespace v8::internal::compiler; using namespace v8::internal::compiler;
template <typename T> template <typename T>
Operator* NewConstantOperator(CommonOperatorBuilder* common, volatile T value); const Operator* NewConstantOperator(CommonOperatorBuilder* common,
volatile T value);
template <> template <>
Operator* NewConstantOperator<int32_t>(CommonOperatorBuilder* common, const Operator* NewConstantOperator<int32_t>(CommonOperatorBuilder* common,
volatile int32_t value) { volatile int32_t value) {
return common->Int32Constant(value); return common->Int32Constant(value);
} }
template <> template <>
Operator* NewConstantOperator<double>(CommonOperatorBuilder* common, const Operator* NewConstantOperator<double>(CommonOperatorBuilder* common,
volatile double value) { volatile double value) {
return common->Float64Constant(value); return common->Float64Constant(value);
} }
...@@ -63,8 +64,8 @@ class ReducerTester : public HandleAndZoneScope { ...@@ -63,8 +64,8 @@ class ReducerTester : public HandleAndZoneScope {
} }
Isolate* isolate; Isolate* isolate;
Operator* binop; const Operator* binop;
Operator* unop; const Operator* unop;
MachineOperatorBuilder machine; MachineOperatorBuilder machine;
CommonOperatorBuilder common; CommonOperatorBuilder common;
Graph graph; Graph graph;
...@@ -130,7 +131,7 @@ class ReducerTester : public HandleAndZoneScope { ...@@ -130,7 +131,7 @@ class ReducerTester : public HandleAndZoneScope {
// Check that the reduction of this binop applied to {left} and {right} yields // Check that the reduction of this binop applied to {left} and {right} yields
// the {op_expect} applied to {left_expect} and {right_expect}. // the {op_expect} applied to {left_expect} and {right_expect}.
template <typename T> template <typename T>
void CheckFoldBinop(volatile T left_expect, Operator* op_expect, void CheckFoldBinop(volatile T left_expect, const Operator* op_expect,
Node* right_expect, Node* left, Node* right) { Node* right_expect, Node* left, Node* right) {
CHECK_NE(NULL, binop); CHECK_NE(NULL, binop);
Node* n = graph.NewNode(binop, left, right); Node* n = graph.NewNode(binop, left, right);
...@@ -145,7 +146,7 @@ class ReducerTester : public HandleAndZoneScope { ...@@ -145,7 +146,7 @@ class ReducerTester : public HandleAndZoneScope {
// Check that the reduction of this binop applied to {left} and {right} yields // Check that the reduction of this binop applied to {left} and {right} yields
// the {op_expect} applied to {left_expect} and {right_expect}. // the {op_expect} applied to {left_expect} and {right_expect}.
template <typename T> template <typename T>
void CheckFoldBinop(Node* left_expect, Operator* op_expect, void CheckFoldBinop(Node* left_expect, const Operator* op_expect,
volatile T right_expect, Node* left, Node* right) { volatile T right_expect, Node* left, Node* right) {
CHECK_NE(NULL, binop); CHECK_NE(NULL, binop);
Node* n = graph.NewNode(binop, left, right); Node* n = graph.NewNode(binop, left, right);
......
...@@ -58,7 +58,7 @@ static Node* Int32Input(RawMachineAssemblerTester<int32_t>* m, int index) { ...@@ -58,7 +58,7 @@ static Node* Int32Input(RawMachineAssemblerTester<int32_t>* m, int index) {
TEST(CodeGenInt32Binop) { TEST(CodeGenInt32Binop) {
RawMachineAssemblerTester<void> m; RawMachineAssemblerTester<void> m;
Operator* ops[] = { const Operator* ops[] = {
m.machine()->Word32And(), m.machine()->Word32Or(), m.machine()->Word32And(), m.machine()->Word32Or(),
m.machine()->Word32Xor(), m.machine()->Word32Shl(), m.machine()->Word32Xor(), m.machine()->Word32Shl(),
m.machine()->Word32Shr(), m.machine()->Word32Sar(), m.machine()->Word32Shr(), m.machine()->Word32Sar(),
...@@ -741,8 +741,9 @@ TEST(RunInt32AddInBranch) { ...@@ -741,8 +741,9 @@ TEST(RunInt32AddInBranch) {
} }
{ {
RawMachineAssemblerTester<void> m; RawMachineAssemblerTester<void> m;
Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), const Operator* shops[] = {m.machine()->Word32Sar(),
m.machine()->Word32Shr()}; m.machine()->Word32Shl(),
m.machine()->Word32Shr()};
for (size_t n = 0; n < arraysize(shops); n++) { for (size_t n = 0; n < arraysize(shops); n++) {
RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
kMachUint32); kMachUint32);
...@@ -832,8 +833,9 @@ TEST(RunInt32AddInComparison) { ...@@ -832,8 +833,9 @@ TEST(RunInt32AddInComparison) {
} }
{ {
RawMachineAssemblerTester<void> m; RawMachineAssemblerTester<void> m;
Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), const Operator* shops[] = {m.machine()->Word32Sar(),
m.machine()->Word32Shr()}; m.machine()->Word32Shl(),
m.machine()->Word32Shr()};
for (size_t n = 0; n < arraysize(shops); n++) { for (size_t n = 0; n < arraysize(shops); n++) {
RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
kMachUint32); kMachUint32);
...@@ -1076,8 +1078,9 @@ TEST(RunInt32SubInBranch) { ...@@ -1076,8 +1078,9 @@ TEST(RunInt32SubInBranch) {
} }
{ {
RawMachineAssemblerTester<void> m; RawMachineAssemblerTester<void> m;
Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), const Operator* shops[] = {m.machine()->Word32Sar(),
m.machine()->Word32Shr()}; m.machine()->Word32Shl(),
m.machine()->Word32Shr()};
for (size_t n = 0; n < arraysize(shops); n++) { for (size_t n = 0; n < arraysize(shops); n++) {
RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
kMachUint32); kMachUint32);
...@@ -1167,8 +1170,9 @@ TEST(RunInt32SubInComparison) { ...@@ -1167,8 +1170,9 @@ TEST(RunInt32SubInComparison) {
} }
{ {
RawMachineAssemblerTester<void> m; RawMachineAssemblerTester<void> m;
Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), const Operator* shops[] = {m.machine()->Word32Sar(),
m.machine()->Word32Shr()}; m.machine()->Word32Shl(),
m.machine()->Word32Shr()};
for (size_t n = 0; n < arraysize(shops); n++) { for (size_t n = 0; n < arraysize(shops); n++) {
RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
kMachUint32); kMachUint32);
...@@ -1699,8 +1703,9 @@ TEST(RunWord32AndInBranch) { ...@@ -1699,8 +1703,9 @@ TEST(RunWord32AndInBranch) {
} }
{ {
RawMachineAssemblerTester<void> m; RawMachineAssemblerTester<void> m;
Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), const Operator* shops[] = {m.machine()->Word32Sar(),
m.machine()->Word32Shr()}; m.machine()->Word32Shl(),
m.machine()->Word32Shr()};
for (size_t n = 0; n < arraysize(shops); n++) { for (size_t n = 0; n < arraysize(shops); n++) {
RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
kMachUint32); kMachUint32);
...@@ -1926,8 +1931,9 @@ TEST(RunWord32OrInBranch) { ...@@ -1926,8 +1931,9 @@ TEST(RunWord32OrInBranch) {
} }
{ {
RawMachineAssemblerTester<void> m; RawMachineAssemblerTester<void> m;
Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), const Operator* shops[] = {m.machine()->Word32Sar(),
m.machine()->Word32Shr()}; m.machine()->Word32Shl(),
m.machine()->Word32Shr()};
for (size_t n = 0; n < arraysize(shops); n++) { for (size_t n = 0; n < arraysize(shops); n++) {
RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
kMachUint32); kMachUint32);
...@@ -2150,8 +2156,9 @@ TEST(RunWord32XorInBranch) { ...@@ -2150,8 +2156,9 @@ TEST(RunWord32XorInBranch) {
} }
{ {
RawMachineAssemblerTester<void> m; RawMachineAssemblerTester<void> m;
Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), const Operator* shops[] = {m.machine()->Word32Sar(),
m.machine()->Word32Shr()}; m.machine()->Word32Shl(),
m.machine()->Word32Shr()};
for (size_t n = 0; n < arraysize(shops); n++) { for (size_t n = 0; n < arraysize(shops); n++) {
RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
kMachUint32); kMachUint32);
...@@ -2651,7 +2658,7 @@ TEST(RunDeadNodes) { ...@@ -2651,7 +2658,7 @@ TEST(RunDeadNodes) {
TEST(RunDeadInt32Binops) { TEST(RunDeadInt32Binops) {
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
Operator* ops[] = { const Operator* ops[] = {
m.machine()->Word32And(), m.machine()->Word32Or(), m.machine()->Word32And(), m.machine()->Word32Or(),
m.machine()->Word32Xor(), m.machine()->Word32Shl(), m.machine()->Word32Xor(), m.machine()->Word32Shl(),
m.machine()->Word32Shr(), m.machine()->Word32Sar(), m.machine()->Word32Shr(), m.machine()->Word32Sar(),
...@@ -2762,12 +2769,12 @@ TEST(RunFloat64Binop) { ...@@ -2762,12 +2769,12 @@ TEST(RunFloat64Binop) {
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
double result; double result;
Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(),
m.machine()->Float64Mul(), m.machine()->Float64Div(), m.machine()->Float64Mul(), m.machine()->Float64Div(),
m.machine()->Float64Mod(), NULL}; m.machine()->Float64Mod(), NULL};
double inf = V8_INFINITY; double inf = V8_INFINITY;
Operator* inputs[] = { const Operator* inputs[] = {
m.common()->Float64Constant(0), m.common()->Float64Constant(1), m.common()->Float64Constant(0), m.common()->Float64Constant(1),
m.common()->Float64Constant(1), m.common()->Float64Constant(0), m.common()->Float64Constant(1), m.common()->Float64Constant(0),
m.common()->Float64Constant(0), m.common()->Float64Constant(-1), m.common()->Float64Constant(0), m.common()->Float64Constant(-1),
...@@ -2797,9 +2804,9 @@ TEST(RunFloat64Binop) { ...@@ -2797,9 +2804,9 @@ TEST(RunFloat64Binop) {
TEST(RunDeadFloat64Binops) { TEST(RunDeadFloat64Binops) {
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(),
m.machine()->Float64Mul(), m.machine()->Float64Div(), m.machine()->Float64Mul(), m.machine()->Float64Div(),
m.machine()->Float64Mod(), NULL}; m.machine()->Float64Mod(), NULL};
for (int i = 0; ops[i] != NULL; i++) { for (int i = 0; ops[i] != NULL; i++) {
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
...@@ -3714,9 +3721,9 @@ TEST(RunFloat64Compare) { ...@@ -3714,9 +3721,9 @@ TEST(RunFloat64Compare) {
TEST(RunFloat64UnorderedCompare) { TEST(RunFloat64UnorderedCompare) {
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
Operator* operators[] = {m.machine()->Float64Equal(), const Operator* operators[] = {m.machine()->Float64Equal(),
m.machine()->Float64LessThan(), m.machine()->Float64LessThan(),
m.machine()->Float64LessThanOrEqual()}; m.machine()->Float64LessThanOrEqual()};
double nan = v8::base::OS::nan_value(); double nan = v8::base::OS::nan_value();
......
...@@ -676,7 +676,7 @@ TEST(BuildScheduleIfSplitWithEffects) { ...@@ -676,7 +676,7 @@ TEST(BuildScheduleIfSplitWithEffects) {
Graph graph(scope.main_zone()); Graph graph(scope.main_zone());
CommonOperatorBuilder common_builder(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone());
JSOperatorBuilder js_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone());
Operator* op; const Operator* op;
Handle<Object> object = Handle<Object> object =
Handle<Object>(isolate->heap()->undefined_value(), isolate); Handle<Object>(isolate->heap()->undefined_value(), isolate);
...@@ -821,7 +821,7 @@ TEST(BuildScheduleSimpleLoop) { ...@@ -821,7 +821,7 @@ TEST(BuildScheduleSimpleLoop) {
Graph graph(scope.main_zone()); Graph graph(scope.main_zone());
CommonOperatorBuilder common_builder(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone());
JSOperatorBuilder js_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone());
Operator* op; const Operator* op;
Handle<Object> object = Handle<Object> object =
Handle<Object>(isolate->heap()->undefined_value(), isolate); Handle<Object>(isolate->heap()->undefined_value(), isolate);
...@@ -933,7 +933,7 @@ TEST(BuildScheduleComplexLoops) { ...@@ -933,7 +933,7 @@ TEST(BuildScheduleComplexLoops) {
Graph graph(scope.main_zone()); Graph graph(scope.main_zone());
CommonOperatorBuilder common_builder(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone());
JSOperatorBuilder js_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone());
Operator* op; const Operator* op;
Handle<Object> object = Handle<Object> object =
Handle<Object>(isolate->heap()->undefined_value(), isolate); Handle<Object>(isolate->heap()->undefined_value(), isolate);
...@@ -1180,7 +1180,7 @@ TEST(BuildScheduleBreakAndContinue) { ...@@ -1180,7 +1180,7 @@ TEST(BuildScheduleBreakAndContinue) {
Graph graph(scope.main_zone()); Graph graph(scope.main_zone());
CommonOperatorBuilder common_builder(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone());
JSOperatorBuilder js_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone());
Operator* op; const Operator* op;
Handle<Object> object = Handle<Object> object =
Handle<Object>(isolate->heap()->undefined_value(), isolate); Handle<Object>(isolate->heap()->undefined_value(), isolate);
...@@ -1510,7 +1510,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { ...@@ -1510,7 +1510,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) {
CommonOperatorBuilder common_builder(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone());
JSOperatorBuilder js_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone());
MachineOperatorBuilder machine_builder(scope.main_zone()); MachineOperatorBuilder machine_builder(scope.main_zone());
Operator* op; const Operator* op;
Handle<Object> object = Handle<Object> object =
Handle<Object>(isolate->heap()->undefined_value(), isolate); Handle<Object>(isolate->heap()->undefined_value(), isolate);
......
...@@ -649,14 +649,14 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { ...@@ -649,14 +649,14 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
NodeProperties::SetBounds(p1, Bounds(p1_type)); NodeProperties::SetBounds(p1, Bounds(p1_type));
} }
void CheckLoweringBinop(IrOpcode::Value expected, Operator* op) { void CheckLoweringBinop(IrOpcode::Value expected, const Operator* op) {
Node* node = Return(graph()->NewNode(op, p0, p1)); Node* node = Return(graph()->NewNode(op, p0, p1));
Lower(); Lower();
CHECK_EQ(expected, node->opcode()); CHECK_EQ(expected, node->opcode());
} }
void CheckLoweringTruncatedBinop(IrOpcode::Value expected, Operator* op, void CheckLoweringTruncatedBinop(IrOpcode::Value expected, const Operator* op,
Operator* trunc) { const Operator* trunc) {
Node* node = graph()->NewNode(op, p0, p1); Node* node = graph()->NewNode(op, p0, p1);
Return(graph()->NewNode(trunc, node)); Return(graph()->NewNode(trunc, node));
Lower(); Lower();
...@@ -1108,7 +1108,7 @@ TEST(InsertBasicChanges) { ...@@ -1108,7 +1108,7 @@ TEST(InsertBasicChanges) {
} }
static void CheckChangesAroundBinop(TestingGraph* t, Operator* op, static void CheckChangesAroundBinop(TestingGraph* t, const Operator* op,
IrOpcode::Value input_change, IrOpcode::Value input_change,
IrOpcode::Value output_change) { IrOpcode::Value output_change) {
Node* binop = t->graph()->NewNode(op, t->p0, t->p1); Node* binop = t->graph()->NewNode(op, t->p0, t->p1);
...@@ -1126,11 +1126,11 @@ static void CheckChangesAroundBinop(TestingGraph* t, Operator* op, ...@@ -1126,11 +1126,11 @@ static void CheckChangesAroundBinop(TestingGraph* t, Operator* op,
TEST(InsertChangesAroundInt32Binops) { TEST(InsertChangesAroundInt32Binops) {
TestingGraph t(Type::Signed32(), Type::Signed32()); TestingGraph t(Type::Signed32(), Type::Signed32());
Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(), const Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(),
t.machine()->Int32Mul(), t.machine()->Int32Div(), t.machine()->Int32Mul(), t.machine()->Int32Div(),
t.machine()->Int32Mod(), t.machine()->Word32And(), t.machine()->Int32Mod(), t.machine()->Word32And(),
t.machine()->Word32Or(), t.machine()->Word32Xor(), t.machine()->Word32Or(), t.machine()->Word32Xor(),
t.machine()->Word32Shl(), t.machine()->Word32Sar()}; t.machine()->Word32Shl(), t.machine()->Word32Sar()};
for (size_t i = 0; i < arraysize(ops); i++) { for (size_t i = 0; i < arraysize(ops); i++) {
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
...@@ -1142,8 +1142,8 @@ TEST(InsertChangesAroundInt32Binops) { ...@@ -1142,8 +1142,8 @@ TEST(InsertChangesAroundInt32Binops) {
TEST(InsertChangesAroundInt32Cmp) { TEST(InsertChangesAroundInt32Cmp) {
TestingGraph t(Type::Signed32(), Type::Signed32()); TestingGraph t(Type::Signed32(), Type::Signed32());
Operator* ops[] = {t.machine()->Int32LessThan(), const Operator* ops[] = {t.machine()->Int32LessThan(),
t.machine()->Int32LessThanOrEqual()}; t.machine()->Int32LessThanOrEqual()};
for (size_t i = 0; i < arraysize(ops); i++) { for (size_t i = 0; i < arraysize(ops); i++) {
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
...@@ -1155,8 +1155,8 @@ TEST(InsertChangesAroundInt32Cmp) { ...@@ -1155,8 +1155,8 @@ TEST(InsertChangesAroundInt32Cmp) {
TEST(InsertChangesAroundUint32Cmp) { TEST(InsertChangesAroundUint32Cmp) {
TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); TestingGraph t(Type::Unsigned32(), Type::Unsigned32());
Operator* ops[] = {t.machine()->Uint32LessThan(), const Operator* ops[] = {t.machine()->Uint32LessThan(),
t.machine()->Uint32LessThanOrEqual()}; t.machine()->Uint32LessThanOrEqual()};
for (size_t i = 0; i < arraysize(ops); i++) { for (size_t i = 0; i < arraysize(ops); i++) {
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32, CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32,
...@@ -1168,7 +1168,7 @@ TEST(InsertChangesAroundUint32Cmp) { ...@@ -1168,7 +1168,7 @@ TEST(InsertChangesAroundUint32Cmp) {
TEST(InsertChangesAroundFloat64Binops) { TEST(InsertChangesAroundFloat64Binops) {
TestingGraph t(Type::Number(), Type::Number()); TestingGraph t(Type::Number(), Type::Number());
Operator* ops[] = { const Operator* ops[] = {
t.machine()->Float64Add(), t.machine()->Float64Sub(), t.machine()->Float64Add(), t.machine()->Float64Sub(),
t.machine()->Float64Mul(), t.machine()->Float64Div(), t.machine()->Float64Mul(), t.machine()->Float64Div(),
t.machine()->Float64Mod(), t.machine()->Float64Mod(),
...@@ -1184,9 +1184,9 @@ TEST(InsertChangesAroundFloat64Binops) { ...@@ -1184,9 +1184,9 @@ TEST(InsertChangesAroundFloat64Binops) {
TEST(InsertChangesAroundFloat64Cmp) { TEST(InsertChangesAroundFloat64Cmp) {
TestingGraph t(Type::Number(), Type::Number()); TestingGraph t(Type::Number(), Type::Number());
Operator* ops[] = {t.machine()->Float64Equal(), const Operator* ops[] = {t.machine()->Float64Equal(),
t.machine()->Float64LessThan(), t.machine()->Float64LessThan(),
t.machine()->Float64LessThanOrEqual()}; t.machine()->Float64LessThanOrEqual()};
for (size_t i = 0; i < arraysize(ops); i++) { for (size_t i = 0; i < arraysize(ops); i++) {
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64,
......
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