Commit 205d85af authored by jarin's avatar jarin Committed by Commit bot

Reland "[turbofan] Checking of input counts on node creation"

(Original CL: https://codereview.chromium.org/1347353003/)

Unfortunately, the mips gcc gets confused by arraysize on
variadic templated arguments, so we use sizeof... instead.

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

Cr-Commit-Position: refs/heads/master@{#30880}
parent 4dd45e11
......@@ -81,11 +81,12 @@ BasicBlockProfiler::Data* BasicBlockInstrumentor::Instrument(
// Construct increment operation.
Node* base = graph->NewNode(
PointerConstant(&common, data->GetCounterAddress(block_number)));
Node* load = graph->NewNode(machine.Load(kMachUint32), base, zero);
Node* load = graph->NewNode(machine.Load(kMachUint32), base, zero,
graph->start(), graph->start());
Node* inc = graph->NewNode(machine.Int32Add(), load, one);
Node* store = graph->NewNode(
machine.Store(StoreRepresentation(kMachUint32, kNoWriteBarrier)), base,
zero, inc);
zero, inc, graph->start(), graph->start());
// Insert the new nodes.
static const int kArraySize = 6;
Node* to_insert[kArraySize] = {zero, one, base, load, inc, store};
......
......@@ -8,6 +8,7 @@
#include "src/base/bits.h"
#include "src/compiler/node.h"
#include "src/compiler/operator-properties.h"
namespace v8 {
namespace internal {
......@@ -43,7 +44,13 @@ void Graph::RemoveDecorator(GraphDecorator* decorator) {
Node* Graph::NewNode(const Operator* op, int input_count, Node** inputs,
bool incomplete) {
DCHECK_LE(op->ValueInputCount(), input_count);
DCHECK_EQ(OperatorProperties::GetTotalInputCount(op), input_count);
return NewNodeUnchecked(op, input_count, inputs, incomplete);
}
Node* Graph::NewNodeUnchecked(const Operator* op, int input_count,
Node** inputs, bool incomplete) {
Node* const node =
Node::New(zone(), NextNodeId(), op, input_count, inputs, incomplete);
Decorate(node);
......
......@@ -34,6 +34,10 @@ class Graph : public ZoneObject {
explicit Graph(Zone* zone);
// Base implementation used by all factory methods.
Node* NewNodeUnchecked(const Operator* op, int input_count, Node** inputs,
bool incomplete = false);
// Factory that checks the input count.
Node* NewNode(const Operator* op, int input_count, Node** inputs,
bool incomplete = false);
......
......@@ -32,7 +32,7 @@ RawMachineAssembler::RawMachineAssembler(Isolate* isolate, Graph* graph,
parameters_ = zone()->NewArray<Node*>(param_count);
for (size_t i = 0; i < parameter_count(); ++i) {
parameters_[i] =
NewNode(common()->Parameter(static_cast<int>(i)), graph->start());
AddNode(common()->Parameter(static_cast<int>(i)), graph->start());
}
}
......@@ -64,7 +64,7 @@ void RawMachineAssembler::Goto(Label* label) {
void RawMachineAssembler::Branch(Node* condition, Label* true_val,
Label* false_val) {
DCHECK(current_block_ != schedule()->end());
Node* branch = NewNode(common()->Branch(), condition);
Node* branch = AddNode(common()->Branch(), condition);
schedule()->AddBranch(CurrentBlock(), branch, Use(true_val), Use(false_val));
current_block_ = nullptr;
}
......@@ -75,7 +75,7 @@ void RawMachineAssembler::Switch(Node* index, Label* default_label,
size_t case_count) {
DCHECK_NE(schedule()->end(), current_block_);
size_t succ_count = case_count + 1;
Node* switch_node = NewNode(common()->Switch(succ_count), index);
Node* switch_node = AddNode(common()->Switch(succ_count), index);
BasicBlock** succ_blocks = zone()->NewArray<BasicBlock*>(succ_count);
for (size_t index = 0; index < case_count; ++index) {
int32_t case_value = case_values[index];
......@@ -95,7 +95,7 @@ void RawMachineAssembler::Switch(Node* index, Label* default_label,
void RawMachineAssembler::Return(Node* value) {
Node* ret = graph()->NewNode(common()->Return(), value);
Node* ret = MakeNode(common()->Return(), 1, &value);
schedule()->AddReturn(CurrentBlock(), ret);
current_block_ = nullptr;
}
......@@ -114,9 +114,7 @@ Node* RawMachineAssembler::CallN(CallDescriptor* desc, Node* function,
}
buffer[index++] = graph()->start();
buffer[index++] = graph()->start();
Node* call = graph()->NewNode(common()->Call(desc), input_count, buffer);
schedule()->AddNode(CurrentBlock(), call);
return call;
return AddNode(common()->Call(desc), input_count, buffer);
}
......@@ -136,9 +134,7 @@ Node* RawMachineAssembler::CallNWithFrameState(CallDescriptor* desc,
buffer[index++] = frame_state;
buffer[index++] = graph()->start();
buffer[index++] = graph()->start();
Node* call = graph()->NewNode(common()->Call(desc), input_count, buffer);
schedule()->AddNode(CurrentBlock(), call);
return call;
return AddNode(common()->Call(desc), input_count, buffer);
}
......@@ -155,8 +151,7 @@ Node* RawMachineAssembler::TailCallN(CallDescriptor* desc, Node* function,
}
buffer[index++] = graph()->start();
buffer[index++] = graph()->start();
Node* tail_call =
graph()->NewNode(common()->TailCall(desc), input_count, buffer);
Node* tail_call = MakeNode(common()->TailCall(desc), input_count, buffer);
schedule()->AddTailCall(CurrentBlock(), tail_call);
return tail_call;
}
......@@ -170,11 +165,8 @@ Node* RawMachineAssembler::CallFunctionStub0(Node* function, Node* receiver,
isolate(), zone(), callable.descriptor(), 1,
CallDescriptor::kNeedsFrameState, Operator::kNoProperties);
Node* stub_code = HeapConstant(callable.code());
Node* call = graph()->NewNode(common()->Call(desc), stub_code, function,
receiver, context, frame_state,
graph()->start(), graph()->start());
schedule()->AddNode(CurrentBlock(), call);
return call;
return AddNode(common()->Call(desc), stub_code, function, receiver, context,
frame_state, graph()->start(), graph()->start());
}
......@@ -184,15 +176,12 @@ Node* RawMachineAssembler::CallRuntime1(Runtime::FunctionId function,
zone(), function, 1, Operator::kNoProperties, false);
Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode());
Node* ref = NewNode(
Node* ref = AddNode(
common()->ExternalConstant(ExternalReference(function, isolate())));
Node* arity = Int32Constant(1);
Node* call =
graph()->NewNode(common()->Call(descriptor), centry, arg1, ref, arity,
context, graph()->start(), graph()->start());
schedule()->AddNode(CurrentBlock(), call);
return call;
return AddNode(common()->Call(descriptor), centry, arg1, ref, arity, context,
graph()->start(), graph()->start());
}
......@@ -202,15 +191,12 @@ Node* RawMachineAssembler::CallRuntime2(Runtime::FunctionId function,
zone(), function, 2, Operator::kNoProperties, false);
Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode());
Node* ref = NewNode(
Node* ref = AddNode(
common()->ExternalConstant(ExternalReference(function, isolate())));
Node* arity = Int32Constant(2);
Node* call =
graph()->NewNode(common()->Call(descriptor), centry, arg1, arg2, ref,
arity, context, graph()->start(), graph()->start());
schedule()->AddNode(CurrentBlock(), call);
return call;
return AddNode(common()->Call(descriptor), centry, arg1, arg2, ref, arity,
context, graph()->start(), graph()->start());
}
......@@ -221,10 +207,8 @@ Node* RawMachineAssembler::CallCFunction0(MachineType return_type,
const CallDescriptor* descriptor =
Linkage::GetSimplifiedCDescriptor(zone(), builder.Build());
Node* call = graph()->NewNode(common()->Call(descriptor), function,
graph()->start(), graph()->start());
schedule()->AddNode(CurrentBlock(), call);
return call;
return AddNode(common()->Call(descriptor), function, graph()->start(),
graph()->start());
}
......@@ -237,10 +221,8 @@ Node* RawMachineAssembler::CallCFunction1(MachineType return_type,
const CallDescriptor* descriptor =
Linkage::GetSimplifiedCDescriptor(zone(), builder.Build());
Node* call = graph()->NewNode(common()->Call(descriptor), function, arg0,
graph()->start(), graph()->start());
schedule()->AddNode(CurrentBlock(), call);
return call;
return AddNode(common()->Call(descriptor), function, arg0, graph()->start(),
graph()->start());
}
......@@ -255,10 +237,8 @@ Node* RawMachineAssembler::CallCFunction2(MachineType return_type,
const CallDescriptor* descriptor =
Linkage::GetSimplifiedCDescriptor(zone(), builder.Build());
Node* call = graph()->NewNode(common()->Call(descriptor), function, arg0,
arg1, graph()->start(), graph()->start());
schedule()->AddNode(CurrentBlock(), call);
return call;
return AddNode(common()->Call(descriptor), function, arg0, arg1,
graph()->start(), graph()->start());
}
......@@ -291,10 +271,7 @@ Node* RawMachineAssembler::CallCFunction8(
graph()->start()};
const CallDescriptor* descriptor =
Linkage::GetSimplifiedCDescriptor(zone(), builder.Build());
Node* call =
graph()->NewNode(common()->Call(descriptor), arraysize(args), args);
schedule()->AddNode(CurrentBlock(), call);
return call;
return AddNode(common()->Call(descriptor), arraysize(args), args);
}
......@@ -324,15 +301,23 @@ BasicBlock* RawMachineAssembler::CurrentBlock() {
}
Node* RawMachineAssembler::MakeNode(const Operator* op, int input_count,
Node** inputs) {
Node* RawMachineAssembler::AddNode(const Operator* op, int input_count,
Node** inputs) {
DCHECK_NOT_NULL(schedule_);
DCHECK(current_block_ != nullptr);
Node* node = graph()->NewNode(op, input_count, inputs);
Node* node = MakeNode(op, input_count, inputs);
schedule()->AddNode(CurrentBlock(), node);
return node;
}
Node* RawMachineAssembler::MakeNode(const Operator* op, int input_count,
Node** inputs) {
// The raw machine assembler nodes do not have effect and control inputs,
// so we disable checking input counts here.
return graph()->NewNodeUnchecked(op, input_count, inputs);
}
} // namespace compiler
} // namespace internal
} // namespace v8
This diff is collapsed.
......@@ -266,9 +266,12 @@ class RepresentationSelector {
// Helper for binops of the R x L -> O variety.
void VisitBinop(Node* node, MachineTypeUnion left_use,
MachineTypeUnion right_use, MachineTypeUnion output) {
DCHECK_EQ(2, node->InputCount());
DCHECK_EQ(2, node->op()->ValueInputCount());
ProcessInput(node, 0, left_use);
ProcessInput(node, 1, right_use);
for (int i = 2; i < node->InputCount(); i++) {
Enqueue(node->InputAt(i));
}
SetOutput(node, output);
}
......
......@@ -207,7 +207,7 @@ class CompareWrapper {
explicit CompareWrapper(IrOpcode::Value op) : opcode(op) {}
Node* MakeNode(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) {
return m->NewNode(op(m->machine()), a, b);
return m->AddNode(op(m->machine()), a, b);
}
const Operator* op(MachineOperatorBuilder* machine) {
......
......@@ -20,8 +20,10 @@
using namespace v8::internal;
using namespace v8::internal::compiler;
static Operator dummy_operator(IrOpcode::kParameter, Operator::kNoWrite,
"dummy", 0, 0, 0, 1, 0, 0);
static Operator dummy_operator1(IrOpcode::kParameter, Operator::kNoWrite,
"dummy", 1, 0, 0, 1, 0, 0);
static Operator dummy_operator6(IrOpcode::kParameter, Operator::kNoWrite,
"dummy", 6, 0, 0, 1, 0, 0);
TEST(NodeWithNullInputReachableFromEnd) {
......@@ -106,18 +108,18 @@ TEST(NodeNetworkOfDummiesReachableFromEnd) {
Node* start = graph.NewNode(common.Start(0));
graph.SetStart(start);
Node* n2 = graph.NewNode(&dummy_operator, graph.start());
Node* n3 = graph.NewNode(&dummy_operator, graph.start());
Node* n4 = graph.NewNode(&dummy_operator, n2);
Node* n5 = graph.NewNode(&dummy_operator, n2);
Node* n6 = graph.NewNode(&dummy_operator, n3);
Node* n7 = graph.NewNode(&dummy_operator, n3);
Node* n8 = graph.NewNode(&dummy_operator, n5);
Node* n9 = graph.NewNode(&dummy_operator, n5);
Node* n10 = graph.NewNode(&dummy_operator, n9);
Node* n11 = graph.NewNode(&dummy_operator, n9);
Node* n2 = graph.NewNode(&dummy_operator1, graph.start());
Node* n3 = graph.NewNode(&dummy_operator1, graph.start());
Node* n4 = graph.NewNode(&dummy_operator1, n2);
Node* n5 = graph.NewNode(&dummy_operator1, n2);
Node* n6 = graph.NewNode(&dummy_operator1, n3);
Node* n7 = graph.NewNode(&dummy_operator1, n3);
Node* n8 = graph.NewNode(&dummy_operator1, n5);
Node* n9 = graph.NewNode(&dummy_operator1, n5);
Node* n10 = graph.NewNode(&dummy_operator1, n9);
Node* n11 = graph.NewNode(&dummy_operator1, n9);
Node* end_dependencies[6] = {n4, n8, n10, n11, n6, n7};
Node* end = graph.NewNode(&dummy_operator, 6, end_dependencies);
Node* end = graph.NewNode(&dummy_operator6, 6, end_dependencies);
graph.SetEnd(end);
OFStream os(stdout);
......
......@@ -41,7 +41,8 @@ class JSConstantCacheTester : public HandleAndZoneScope,
JSGraph(main_isolate(), &main_graph_, &main_common_, &main_javascript_,
&main_machine_) {
main_graph_.SetStart(main_graph_.NewNode(common()->Start(0)));
main_graph_.SetEnd(main_graph_.NewNode(common()->End(1)));
main_graph_.SetEnd(
main_graph_.NewNode(common()->End(1), main_graph_.start()));
main_typer_.Run();
}
......
......@@ -140,24 +140,27 @@ TEST(ReduceJSStoreContext) {
{
// Mutable slot, constant context, depth = 0 => do nothing.
Node* load = t.graph()->NewNode(t.javascript()->StoreContext(0, 0),
const_context, const_context, start);
Node* load =
t.graph()->NewNode(t.javascript()->StoreContext(0, 0), const_context,
const_context, const_context, start, start);
Reduction r = t.spec()->Reduce(load);
CHECK(!r.Changed());
}
{
// Mutable slot, non-constant context, depth = 0 => do nothing.
Node* load = t.graph()->NewNode(t.javascript()->StoreContext(0, 0),
param_context, param_context, start);
Node* load =
t.graph()->NewNode(t.javascript()->StoreContext(0, 0), param_context,
param_context, const_context, start, start);
Reduction r = t.spec()->Reduce(load);
CHECK(!r.Changed());
}
{
// Immutable slot, constant context, depth = 0 => do nothing.
Node* load = t.graph()->NewNode(t.javascript()->StoreContext(0, slot),
const_context, const_context, start);
Node* load =
t.graph()->NewNode(t.javascript()->StoreContext(0, slot), const_context,
const_context, const_context, start, start);
Reduction r = t.spec()->Reduce(load);
CHECK(!r.Changed());
}
......@@ -166,7 +169,7 @@ TEST(ReduceJSStoreContext) {
// Mutable slot, constant context, depth > 0 => fold-in parent context.
Node* load = t.graph()->NewNode(
t.javascript()->StoreContext(2, Context::GLOBAL_EVAL_FUN_INDEX),
deep_const_context, deep_const_context, start);
deep_const_context, deep_const_context, const_context, start, start);
Reduction r = t.spec()->Reduce(load);
CHECK(r.Changed());
Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0);
......@@ -219,9 +222,10 @@ TEST(SpecializeToContext) {
Node* other_use =
t.graph()->NewNode(t.simplified()->ChangeTaggedToInt32(), other_load);
Node* add =
t.graph()->NewNode(t.javascript()->Add(LanguageMode::SLOPPY), value_use,
other_use, param_context, other_load, start);
Node* add = t.graph()->NewNode(
t.javascript()->Add(LanguageMode::SLOPPY), value_use, other_use,
param_context, t.jsgraph()->EmptyFrameState(),
t.jsgraph()->EmptyFrameState(), other_load, start);
Node* ret =
t.graph()->NewNode(t.common()->Return(), add, effect_use, start);
......
......@@ -41,7 +41,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
typer(main_isolate(), &graph),
context_node(NULL) {
graph.SetStart(graph.NewNode(common.Start(num_parameters)));
graph.SetEnd(graph.NewNode(common.End(1)));
graph.SetEnd(graph.NewNode(common.End(1), graph.start()));
typer.Run();
}
......@@ -79,7 +79,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
Node* state_node = graph.NewNode(
common.FrameState(BailoutId::None(), OutputFrameStateCombine::Ignore(),
nullptr),
parameters, locals, stack, context, UndefinedConstant());
parameters, locals, stack, context, UndefinedConstant(), graph.start());
return state_node;
}
......@@ -125,16 +125,23 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
Node* Binop(const Operator* op, Node* left, Node* right) {
// JS binops also require context, effect, and control
if (OperatorProperties::GetFrameStateInputCount(op) == 1) {
return graph.NewNode(op, left, right, context(),
EmptyFrameState(context()), start(), control());
} else if (OperatorProperties::GetFrameStateInputCount(op) == 2) {
return graph.NewNode(op, left, right, context(),
EmptyFrameState(context()),
EmptyFrameState(context()), start(), control());
} else {
return graph.NewNode(op, left, right, context(), start(), control());
std::vector<Node*> inputs;
inputs.push_back(left);
inputs.push_back(right);
if (OperatorProperties::HasContextInput(op)) {
inputs.push_back(context());
}
for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(op); i++) {
inputs.push_back(EmptyFrameState(context()));
}
if (op->EffectInputCount() > 0) {
inputs.push_back(start());
}
if (op->ControlInputCount() > 0) {
inputs.push_back(control());
}
return graph.NewNode(op, static_cast<int>(inputs.size()),
&(inputs.front()));
}
Node* Unop(const Operator* op, Node* input) {
......@@ -828,15 +835,18 @@ void CheckEqualityReduction(JSTypedLoweringTester* R, bool strict, Node* l,
Node* p1 = j == 1 ? l : r;
{
Node* eq = strict ? R->graph.NewNode(R->javascript.StrictEqual(), p0, p1)
: R->Binop(R->javascript.Equal(), p0, p1);
Node* eq = strict
? R->graph.NewNode(R->javascript.StrictEqual(), p0, p1,
R->context())
: R->Binop(R->javascript.Equal(), p0, p1);
Node* r = R->reduce(eq);
R->CheckPureBinop(expected, r);
}
{
Node* ne = strict
? R->graph.NewNode(R->javascript.StrictNotEqual(), p0, p1)
? R->graph.NewNode(R->javascript.StrictNotEqual(), p0, p1,
R->context())
: R->Binop(R->javascript.NotEqual(), p0, p1);
Node* n = R->reduce(ne);
CHECK_EQ(IrOpcode::kBooleanNot, n->opcode());
......
......@@ -703,7 +703,8 @@ TEST(ReduceLoadStore) {
Node* base = R.Constant<int32_t>(11);
Node* index = R.Constant<int32_t>(4);
Node* load = R.graph.NewNode(R.machine.Load(kMachInt32), base, index);
Node* load = R.graph.NewNode(R.machine.Load(kMachInt32), base, index,
R.graph.start(), R.graph.start());
{
MachineOperatorReducer reducer(&R.jsgraph);
......@@ -714,7 +715,7 @@ TEST(ReduceLoadStore) {
{
Node* store = R.graph.NewNode(
R.machine.Store(StoreRepresentation(kMachInt32, kNoWriteBarrier)), base,
index, load);
index, load, load, load);
MachineOperatorReducer reducer(&R.jsgraph);
Reduction reduction = reducer.Reduce(store);
CHECK(!reduction.Changed()); // stores should not be reduced.
......
This diff is collapsed.
......@@ -72,7 +72,7 @@ TEST(CodeGenInt32Binop) {
RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
Node* a = Int32Input(&m, j);
Node* b = Int32Input(&m, k);
m.Return(m.NewNode(kOps[i], a, b));
m.Return(m.AddNode(kOps[i], a, b));
m.GenerateCode();
}
}
......@@ -132,7 +132,7 @@ TEST(CodeGenInt64Binop) {
RawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64);
Node* a = Int64Input(&m, j);
Node* b = Int64Input(&m, k);
m.Return(m.NewNode(kOps[i], a, b));
m.Return(m.AddNode(kOps[i], a, b));
m.GenerateCode();
}
}
......@@ -626,7 +626,7 @@ TEST(RunSwitch4) {
m.Bind(&end);
const int num_results = static_cast<int>(arraysize(results));
Node* phi =
m.NewNode(m.common()->Phi(kMachInt32, num_results), num_results, results);
m.AddNode(m.common()->Phi(kMachInt32, num_results), num_results, results);
m.Return(phi);
for (size_t i = 0; i < kNumValues; ++i) {
......@@ -1053,7 +1053,7 @@ TEST(RunInt32AddInBranch) {
kMachUint32);
MLabel blocka, blockb;
m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0),
m.NewNode(shops[n], m.Parameter(1),
m.AddNode(shops[n], m.Parameter(1),
m.Parameter(2))),
m.Int32Constant(0)),
&blocka, &blockb);
......@@ -1145,7 +1145,7 @@ TEST(RunInt32AddInComparison) {
kMachUint32);
m.Return(m.Word32Equal(
m.Int32Add(m.Parameter(0),
m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))),
m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))),
m.Int32Constant(0)));
FOR_UINT32_INPUTS(i) {
FOR_INT32_INPUTS(j) {
......@@ -1390,7 +1390,7 @@ TEST(RunInt32SubInBranch) {
kMachUint32);
MLabel blocka, blockb;
m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0),
m.NewNode(shops[n], m.Parameter(1),
m.AddNode(shops[n], m.Parameter(1),
m.Parameter(2))),
m.Int32Constant(0)),
&blocka, &blockb);
......@@ -1482,7 +1482,7 @@ TEST(RunInt32SubInComparison) {
kMachUint32);
m.Return(m.Word32Equal(
m.Int32Sub(m.Parameter(0),
m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))),
m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))),
m.Int32Constant(0)));
FOR_UINT32_INPUTS(i) {
FOR_INT32_INPUTS(j) {
......@@ -2059,7 +2059,7 @@ TEST(RunWord32AndInBranch) {
kMachUint32);
MLabel blocka, blockb;
m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0),
m.NewNode(shops[n], m.Parameter(1),
m.AddNode(shops[n], m.Parameter(1),
m.Parameter(2))),
m.Int32Constant(0)),
&blocka, &blockb);
......@@ -2287,7 +2287,7 @@ TEST(RunWord32OrInBranch) {
kMachUint32);
MLabel blocka, blockb;
m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0),
m.NewNode(shops[n], m.Parameter(1),
m.AddNode(shops[n], m.Parameter(1),
m.Parameter(2))),
m.Int32Constant(0)),
&blocka, &blockb);
......@@ -2512,7 +2512,7 @@ TEST(RunWord32XorInBranch) {
kMachUint32);
MLabel blocka, blockb;
m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0),
m.NewNode(shops[n], m.Parameter(1),
m.AddNode(shops[n], m.Parameter(1),
m.Parameter(2))),
m.Int32Constant(0)),
&blocka, &blockb);
......@@ -3022,7 +3022,7 @@ TEST(RunDeadInt32Binops) {
for (size_t i = 0; i < arraysize(kOps); ++i) {
RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
int32_t constant = static_cast<int32_t>(0x55555 + i);
m.NewNode(kOps[i], m.Parameter(0), m.Parameter(1));
m.AddNode(kOps[i], m.Parameter(0), m.Parameter(1));
m.Return(m.Int32Constant(constant));
CHECK_EQ(constant, m.Call(1, 1));
......@@ -3137,9 +3137,9 @@ TEST(RunFloat32Binop) {
for (int i = 0; ops[i] != NULL; i++) {
for (int j = 0; inputs[j] != NULL; j += 2) {
RawMachineAssemblerTester<int32_t> m;
Node* a = m.NewNode(inputs[j]);
Node* b = m.NewNode(inputs[j + 1]);
Node* binop = m.NewNode(ops[i], a, b);
Node* a = m.AddNode(inputs[j]);
Node* b = m.AddNode(inputs[j + 1]);
Node* binop = m.AddNode(ops[i], a, b);
Node* base = m.PointerConstant(&result);
Node* zero = m.IntPtrConstant(0);
m.Store(kMachFloat32, base, zero, binop);
......@@ -3173,9 +3173,9 @@ TEST(RunFloat64Binop) {
for (int i = 0; ops[i] != NULL; i++) {
for (int j = 0; inputs[j] != NULL; j += 2) {
RawMachineAssemblerTester<int32_t> m;
Node* a = m.NewNode(inputs[j]);
Node* b = m.NewNode(inputs[j + 1]);
Node* binop = m.NewNode(ops[i], a, b);
Node* a = m.AddNode(inputs[j]);
Node* b = m.AddNode(inputs[j + 1]);
Node* binop = m.AddNode(ops[i], a, b);
Node* base = m.PointerConstant(&result);
Node* zero = m.Int32Constant(0);
m.Store(kMachFloat64, base, zero, binop);
......@@ -3196,7 +3196,7 @@ TEST(RunDeadFloat32Binops) {
for (int i = 0; ops[i] != NULL; i++) {
RawMachineAssemblerTester<int32_t> m;
int constant = 0x53355 + i;
m.NewNode(ops[i], m.Float32Constant(0.1f), m.Float32Constant(1.11f));
m.AddNode(ops[i], m.Float32Constant(0.1f), m.Float32Constant(1.11f));
m.Return(m.Int32Constant(constant));
CHECK_EQ(constant, m.Call());
}
......@@ -3213,7 +3213,7 @@ TEST(RunDeadFloat64Binops) {
for (int i = 0; ops[i] != NULL; i++) {
RawMachineAssemblerTester<int32_t> m;
int constant = 0x53355 + i;
m.NewNode(ops[i], m.Float64Constant(0.1), m.Float64Constant(1.11));
m.AddNode(ops[i], m.Float64Constant(0.1), m.Float64Constant(1.11));
m.Return(m.Int32Constant(constant));
CHECK_EQ(constant, m.Call());
}
......@@ -4289,7 +4289,7 @@ TEST(RunFloat64UnorderedCompare) {
Node* a = m.Float64Constant(*i);
Node* b = m.Float64Constant(nan);
if (j == 1) std::swap(a, b);
m.Return(m.NewNode(operators[o], a, b));
m.Return(m.AddNode(operators[o], a, b));
CHECK_EQ(0, m.Call());
}
}
......@@ -5287,7 +5287,7 @@ TEST(RunCheckedLoadInt64) {
Node* index = m.Parameter(0);
Node* length = m.Int32Constant(16);
Node* load =
m.NewNode(m.machine()->CheckedLoad(kMachInt64), base, index, length);
m.AddNode(m.machine()->CheckedLoad(kMachInt64), base, index, length);
m.Return(load);
CHECK_EQ(buffer[0], m.Call(0));
......@@ -5305,7 +5305,7 @@ TEST(RunCheckedStoreInt64) {
Node* index = m.Parameter(0);
Node* length = m.Int32Constant(16);
Node* value = m.Int64Constant(write);
Node* store = m.NewNode(m.machine()->CheckedStore(kMachInt64), base, index,
Node* store = m.AddNode(m.machine()->CheckedStore(kMachInt64), base, index,
length, value);
USE(store);
m.Return(m.Int32Constant(11));
......
......@@ -1219,7 +1219,10 @@ TEST(InsertBasicChanges) {
static void CheckChangesAroundBinop(TestingGraph* t, const Operator* op,
IrOpcode::Value input_change,
IrOpcode::Value output_change) {
Node* binop = t->graph()->NewNode(op, t->p0, t->p1);
Node* binop =
op->ControlInputCount() == 0
? t->graph()->NewNode(op, t->p0, t->p1)
: t->graph()->NewNode(op, t->p0, t->p1, t->graph()->start());
t->Return(binop);
t->Lower();
CHECK_EQ(input_change, binop->InputAt(0)->opcode());
......
......@@ -290,7 +290,8 @@ const IfExceptionHint kNoHint = IfExceptionHint::kLocallyCaught;
TEST_F(AdvancedReducerTest, ReplaceWithValue_ValueUse) {
CommonOperatorBuilder common(zone());
Node* node = graph()->NewNode(&kMockOperator);
Node* use_value = graph()->NewNode(common.Return(), node);
Node* start = graph()->NewNode(common.Start(1));
Node* use_value = graph()->NewNode(common.Return(), node, start, start);
Node* replacement = graph()->NewNode(&kMockOperator);
GraphReducer graph_reducer(zone(), graph(), nullptr);
ReplaceWithValueReducer r(&graph_reducer);
......@@ -306,16 +307,18 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_EffectUse) {
CommonOperatorBuilder common(zone());
Node* start = graph()->NewNode(common.Start(1));
Node* node = graph()->NewNode(&kMockOpEffect, start);
Node* use_effect = graph()->NewNode(common.EffectPhi(1), node);
Node* use_control = graph()->NewNode(common.Merge(1), start);
Node* use_effect = graph()->NewNode(common.EffectPhi(1), node, use_control);
Node* replacement = graph()->NewNode(&kMockOperator);
GraphReducer graph_reducer(zone(), graph(), nullptr);
ReplaceWithValueReducer r(&graph_reducer);
r.ReplaceWithValue(node, replacement);
EXPECT_EQ(start, use_effect->InputAt(0));
EXPECT_EQ(0, node->UseCount());
EXPECT_EQ(2, start->UseCount());
EXPECT_EQ(3, start->UseCount());
EXPECT_EQ(0, replacement->UseCount());
EXPECT_THAT(start->uses(), UnorderedElementsAre(use_effect, node));
EXPECT_THAT(start->uses(),
UnorderedElementsAre(use_effect, use_control, node));
}
......
......@@ -248,7 +248,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReferenceParameter) {
TARGET_TEST_F(InstructionSelectorTest, Finish) {
StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged);
Node* param = m.Parameter(0);
Node* finish = m.NewNode(m.common()->Finish(1), param, m.graph()->start());
Node* finish = m.AddNode(m.common()->Finish(1), param, m.graph()->start());
m.Return(finish);
Stream s = m.Build(kAllInstructions);
ASSERT_EQ(4U, s.size());
......@@ -334,8 +334,8 @@ TARGET_TEST_F(InstructionSelectorTest, ValueEffect) {
Stream s1 = m1.Build(kAllInstructions);
StreamBuilder m2(this, kMachInt32, kMachPtr);
Node* p2 = m2.Parameter(0);
m2.Return(m2.NewNode(m2.machine()->Load(kMachInt32), p2, m2.Int32Constant(0),
m2.NewNode(m2.common()->ValueEffect(1), p2)));
m2.Return(m2.AddNode(m2.machine()->Load(kMachInt32), p2, m2.Int32Constant(0),
m2.AddNode(m2.common()->ValueEffect(1), p2)));
Stream s2 = m2.Build(kAllInstructions);
EXPECT_LE(3U, s1.size());
ASSERT_EQ(s1.size(), s2.size());
......@@ -370,12 +370,12 @@ TARGET_TEST_F(InstructionSelectorTest, CallJSFunctionWithDeopt) {
zone(), false, 1, CallDescriptor::kNeedsFrameState);
Node* parameters =
m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(1));
Node* locals = m.NewNode(m.common()->TypedStateValues(&empty_types));
Node* stack = m.NewNode(m.common()->TypedStateValues(&empty_types));
m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(1));
Node* locals = m.AddNode(m.common()->TypedStateValues(&empty_types));
Node* stack = m.AddNode(m.common()->TypedStateValues(&empty_types));
Node* context_dummy = m.Int32Constant(0);
Node* state_node = m.NewNode(
Node* state_node = m.AddNode(
m.common()->FrameState(bailout_id, OutputFrameStateCombine::Push(),
m.GetFrameStateFunctionInfo(1, 0)),
parameters, locals, stack, context_dummy, function_node,
......@@ -419,14 +419,14 @@ TARGET_TEST_F(InstructionSelectorTest, CallFunctionStubWithDeopt) {
// Build frame state for the state before the call.
Node* parameters =
m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43));
Node* locals = m.NewNode(m.common()->TypedStateValues(&float64_type),
m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43));
Node* locals = m.AddNode(m.common()->TypedStateValues(&float64_type),
m.Float64Constant(0.5));
Node* stack = m.NewNode(m.common()->TypedStateValues(&tagged_type),
Node* stack = m.AddNode(m.common()->TypedStateValues(&tagged_type),
m.UndefinedConstant());
Node* context_sentinel = m.Int32Constant(0);
Node* frame_state_before = m.NewNode(
Node* frame_state_before = m.AddNode(
m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(),
m.GetFrameStateFunctionInfo(1, 1)),
parameters, locals, stack, context_sentinel, function_node,
......@@ -515,12 +515,12 @@ TARGET_TEST_F(InstructionSelectorTest,
// Build frame state for the state before the call.
Node* parameters =
m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(63));
m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(63));
Node* locals =
m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(64));
m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(64));
Node* stack =
m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(65));
Node* frame_state_parent = m.NewNode(
m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(65));
Node* frame_state_parent = m.AddNode(
m.common()->FrameState(bailout_id_parent,
OutputFrameStateCombine::Ignore(),
m.GetFrameStateFunctionInfo(1, 1)),
......@@ -528,12 +528,12 @@ TARGET_TEST_F(InstructionSelectorTest,
Node* context2 = m.Int32Constant(46);
Node* parameters2 =
m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43));
Node* locals2 = m.NewNode(m.common()->TypedStateValues(&float64_type),
m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43));
Node* locals2 = m.AddNode(m.common()->TypedStateValues(&float64_type),
m.Float64Constant(0.25));
Node* stack2 = m.NewNode(m.common()->TypedStateValues(&int32x2_type),
Node* stack2 = m.AddNode(m.common()->TypedStateValues(&int32x2_type),
m.Int32Constant(44), m.Int32Constant(45));
Node* frame_state_before = m.NewNode(
Node* frame_state_before = m.AddNode(
m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(),
m.GetFrameStateFunctionInfo(1, 1)),
parameters2, locals2, stack2, context2, function_node,
......
......@@ -153,13 +153,10 @@ TEST_F(JSContextRelaxationTest,
Node* const context = Parameter(2);
Node* const outer_context = Parameter(3);
const Operator* op = javascript()->CreateCatchContext(Handle<String>());
Node* const frame_state_1 =
ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Node* nested_context =
graph()->NewNode(op, graph()->start(), graph()->start(), outer_context,
frame_state_1, effect, control);
Node* nested_context = graph()->NewNode(
op, graph()->start(), graph()->start(), outer_context, effect, control);
Node* const frame_state_2 =
ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* node =
......@@ -205,13 +202,10 @@ TEST_F(JSContextRelaxationTest,
Node* const context = Parameter(2);
Node* const outer_context = Parameter(3);
const Operator* op = javascript()->CreateBlockContext();
Node* const frame_state_1 =
ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Node* nested_context =
graph()->NewNode(op, graph()->start(), graph()->start(), outer_context,
frame_state_1, effect, control);
Node* nested_context = graph()->NewNode(
op, graph()->start(), graph()->start(), outer_context, effect, control);
Node* const frame_state_2 =
ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* node =
......@@ -257,13 +251,10 @@ TEST_F(JSContextRelaxationTest,
Node* const context = Parameter(2);
Node* const outer_context = Parameter(3);
const Operator* op = javascript()->CreateModuleContext();
Node* const frame_state_1 =
ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Node* nested_context =
graph()->NewNode(op, graph()->start(), graph()->start(), outer_context,
frame_state_1, effect, control);
Node* nested_context = graph()->NewNode(
op, graph()->start(), graph()->start(), outer_context, effect, control);
Node* const frame_state_2 =
ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* node =
......@@ -283,13 +274,10 @@ TEST_F(JSContextRelaxationTest,
Node* const context = Parameter(2);
Node* const outer_context = Parameter(3);
const Operator* op = javascript()->CreateFunctionContext();
Node* const frame_state_1 =
ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Node* nested_context =
graph()->NewNode(op, graph()->start(), graph()->start(), outer_context,
frame_state_1, effect, control);
graph()->NewNode(op, graph()->start(), outer_context, effect, control);
Node* const frame_state_2 =
ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* node =
......
......@@ -84,15 +84,9 @@ class JSTypeFeedbackTest : public TypedGraphTest {
Handle<Name> name = isolate()->factory()->InternalizeUtf8String(string);
const Operator* op = javascript()->LoadGlobal(name, feedback);
Node* load = graph()->NewNode(op, context, global, vector, context);
if (mode == JSTypeFeedbackSpecializer::kDeoptimizationEnabled) {
for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(op);
i++) {
load->AppendInput(zone(), EmptyFrameState());
}
}
load->AppendInput(zone(), effect);
load->AppendInput(zone(), control);
Node* load =
graph()->NewNode(op, context, global, vector, context,
EmptyFrameState(), EmptyFrameState(), effect, control);
Node* if_success = graph()->NewNode(common()->IfSuccess(), load);
return graph()->NewNode(common()->Return(), load, load, if_success);
}
......
......@@ -742,13 +742,9 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) {
Node* control = graph()->start();
VectorSlotPair feedback;
const Operator* op = javascript()->StoreProperty(language_mode, feedback);
Node* node = graph()->NewNode(op, base, key, value, vector, context);
for (int i = 0;
i < OperatorProperties::GetFrameStateInputCount(node->op()); i++) {
node->AppendInput(zone(), EmptyFrameState());
}
node->AppendInput(zone(), effect);
node->AppendInput(zone(), control);
Node* node = graph()->NewNode(op, base, key, value, vector, context,
EmptyFrameState(), EmptyFrameState(),
effect, control);
Reduction r = Reduce(node);
Matcher<Node*> offset_matcher =
......@@ -790,13 +786,9 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithConversion) {
Node* control = graph()->start();
VectorSlotPair feedback;
const Operator* op = javascript()->StoreProperty(language_mode, feedback);
Node* node = graph()->NewNode(op, base, key, value, vector, context);
for (int i = 0;
i < OperatorProperties::GetFrameStateInputCount(node->op()); i++) {
node->AppendInput(zone(), EmptyFrameState());
}
node->AppendInput(zone(), effect);
node->AppendInput(zone(), control);
Node* node = graph()->NewNode(op, base, key, value, vector, context,
EmptyFrameState(), EmptyFrameState(),
effect, control);
Reduction r = Reduce(node);
Matcher<Node*> offset_matcher =
......@@ -851,13 +843,9 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithSafeKey) {
Node* control = graph()->start();
VectorSlotPair feedback;
const Operator* op = javascript()->StoreProperty(language_mode, feedback);
Node* node = graph()->NewNode(op, base, key, value, vector, context);
for (int i = 0;
i < OperatorProperties::GetFrameStateInputCount(node->op()); i++) {
node->AppendInput(zone(), EmptyFrameState());
}
node->AppendInput(zone(), effect);
node->AppendInput(zone(), control);
Node* node = graph()->NewNode(op, base, key, value, vector, context,
EmptyFrameState(), EmptyFrameState(),
effect, control);
Reduction r = Reduce(node);
ASSERT_TRUE(r.Changed());
......
......@@ -64,9 +64,10 @@ class LivenessAnalysisTest : public GraphTest {
const Operator* op = common()->FrameState(
BailoutId(ast_num), OutputFrameStateCombine::Ignore(), state_info);
Node* result = graph()->NewNode(op, empty_values_, locals, empty_values_,
jsgraph()->UndefinedConstant(),
jsgraph()->UndefinedConstant());
Node* result =
graph()->NewNode(op, empty_values_, locals, empty_values_,
jsgraph()->UndefinedConstant(),
jsgraph()->UndefinedConstant(), graph()->start());
current_block_->Checkpoint(result);
return result;
......
......@@ -479,7 +479,7 @@ TEST_F(LoopPeelingTest, TwoExitLoopWithCall_nope) {
Node* call = graph()->NewNode(&kMockCall, b1.if_true);
Node* if_success = graph()->NewNode(common()->IfSuccess(), call);
Node* if_exception = graph()->NewNode(
common()->IfException(IfExceptionHint::kLocallyUncaught), call);
common()->IfException(IfExceptionHint::kLocallyUncaught), call, call);
loop->ReplaceInput(1, if_success);
Node* merge = graph()->NewNode(common()->Merge(2), b1.if_false, if_exception);
......
......@@ -755,7 +755,7 @@ TARGET_TEST_F(SchedulerTest, NestedFloatingDiamonds) {
Node* map = graph()->NewNode(
simplified()->LoadElement(AccessBuilder::ForFixedArrayElement()), p0, p0,
p0, start, f);
start, f);
Node* br1 = graph()->NewNode(common()->Branch(), map, graph()->start());
Node* t1 = graph()->NewNode(common()->IfTrue(), br1);
Node* f1 = graph()->NewNode(common()->IfFalse(), br1);
......
......@@ -7,6 +7,7 @@
#include "src/codegen.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/operator-properties.h"
#include "test/cctest/types-fuzz.h"
#include "test/unittests/compiler/graph-unittest.h"
......@@ -60,8 +61,23 @@ class TyperTest : public TypedGraphTest {
Node* p1 = Parameter(1);
NodeProperties::SetType(p0, lhs);
NodeProperties::SetType(p1, rhs);
Node* n = graph()->NewNode(op, p0, p1, context_node_, graph()->start(),
graph()->start());
std::vector<Node*> inputs;
inputs.push_back(p0);
inputs.push_back(p1);
if (OperatorProperties::HasContextInput(op)) {
inputs.push_back(context_node_);
}
for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(op); i++) {
inputs.push_back(EmptyFrameState());
}
for (int i = 0; i < op->EffectInputCount(); i++) {
inputs.push_back(graph()->start());
}
for (int i = 0; i < op->ControlInputCount(); i++) {
inputs.push_back(graph()->start());
}
Node* n = graph()->NewNode(op, static_cast<int>(inputs.size()),
&(inputs.front()));
return NodeProperties::GetType(n);
}
......
......@@ -44,8 +44,8 @@ class ValueNumberingReducerTest : public TestWithZone {
TEST_F(ValueNumberingReducerTest, AllInputsAreChecked) {
Node* na = graph()->NewNode(&kOp0);
Node* nb = graph()->NewNode(&kOp0);
Node* n1 = graph()->NewNode(&kOp0, na);
Node* n2 = graph()->NewNode(&kOp0, nb);
Node* n1 = graph()->NewNode(&kOp1, na);
Node* n2 = graph()->NewNode(&kOp1, nb);
EXPECT_FALSE(Reduce(n1).Changed());
EXPECT_FALSE(Reduce(n2).Changed());
}
......
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