2015-01-27 07:47:56 +00:00
|
|
|
// Copyright 2015 the V8 project authors. All rights reserved.
|
2015-01-26 11:21:14 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
This CL enables precise source positions for all V8 compilers. It merges compiler::SourcePosition and internal::SourcePosition to a single class used throughout the codebase. The new internal::SourcePosition instances store an id identifying an inlined function in addition to a script offset.
SourcePosition::InliningId() refers to a the new table DeoptimizationInputData::InliningPositions(), which provides the following data for every inlining id:
- The inlined SharedFunctionInfo as an offset into DeoptimizationInfo::LiteralArray
- The SourcePosition of the inlining. Recursively, this yields the full inlining stack.
Before the Code object is created, the same information can be found in CompilationInfo::inlined_functions().
If SourcePosition::InliningId() is SourcePosition::kNotInlined, it refers to the outer (non-inlined) function.
So every SourcePosition has full information about its inlining stack, as long as the corresponding Code object is known. The internal represenation of a source position is a positive 64bit integer.
All compilers create now appropriate source positions for inlined functions. In the case of Turbofan, this required using AstGraphBuilderWithPositions for inlined functions too. So this class is now moved to a header file.
At the moment, the additional information in source positions is only used in --trace-deopt and --code-comments. The profiler needs to be updated, at the moment it gets the correct script offsets from the deopt info, but the wrong script id from the reconstructed deopt stack, which can lead to wrong outputs. This should be resolved by making the profiler use the new inlining information for deopts.
I activated the inlined deoptimization tests in test-cpu-profiler.cc for Turbofan, changing them to a case where the deopt stack and the inlining position agree. It is currently still broken for other cases.
The following additional changes were necessary:
- The source position table (internal::SourcePositionTableBuilder etc.) supports now 64bit source positions. Encoding source positions in a single 64bit int together with the difference encoding in the source position table results in very little overhead for the inlining id, since only 12% of the source positions in Octane have a changed inlining id.
- The class HPositionInfo was effectively dead code and is now removed.
- SourcePosition has new printing and information facilities, including computing a full inlining stack.
- I had to rename compiler/source-position.{h,cc} to compiler/compiler-source-position-table.{h,cc} to avoid clashes with the new src/source-position.cc file.
- I wrote the new wrapper PodArray for ByteArray. It is a template working with any POD-type. This is used in DeoptimizationInputData::InliningPositions().
- I removed HInlinedFunctionInfo and HGraph::inlined_function_infos, because they were only used for the now obsolete Crankshaft inlining ids.
- Crankshaft managed a list of inlined functions in Lithium: LChunk::inlined_functions. This is an analog structure to CompilationInfo::inlined_functions. So I removed LChunk::inlined_functions and made Crankshaft use CompilationInfo::inlined_functions instead, because this was necessary to register the offsets into the literal array in a uniform way. This is a safe change because LChunk::inlined_functions has no other uses and the functions in CompilationInfo::inlined_functions have a strictly longer lifespan, being created earlier (in Hydrogen already).
BUG=v8:5432
Review-Url: https://codereview.chromium.org/2451853002
Cr-Commit-Position: refs/heads/master@{#40975}
2016-11-14 17:21:37 +00:00
|
|
|
#include "src/compiler/scheduler.h"
|
2015-01-26 11:21:14 +00:00
|
|
|
#include "src/compiler/access-builder.h"
|
|
|
|
#include "src/compiler/common-operator.h"
|
This CL enables precise source positions for all V8 compilers. It merges compiler::SourcePosition and internal::SourcePosition to a single class used throughout the codebase. The new internal::SourcePosition instances store an id identifying an inlined function in addition to a script offset.
SourcePosition::InliningId() refers to a the new table DeoptimizationInputData::InliningPositions(), which provides the following data for every inlining id:
- The inlined SharedFunctionInfo as an offset into DeoptimizationInfo::LiteralArray
- The SourcePosition of the inlining. Recursively, this yields the full inlining stack.
Before the Code object is created, the same information can be found in CompilationInfo::inlined_functions().
If SourcePosition::InliningId() is SourcePosition::kNotInlined, it refers to the outer (non-inlined) function.
So every SourcePosition has full information about its inlining stack, as long as the corresponding Code object is known. The internal represenation of a source position is a positive 64bit integer.
All compilers create now appropriate source positions for inlined functions. In the case of Turbofan, this required using AstGraphBuilderWithPositions for inlined functions too. So this class is now moved to a header file.
At the moment, the additional information in source positions is only used in --trace-deopt and --code-comments. The profiler needs to be updated, at the moment it gets the correct script offsets from the deopt info, but the wrong script id from the reconstructed deopt stack, which can lead to wrong outputs. This should be resolved by making the profiler use the new inlining information for deopts.
I activated the inlined deoptimization tests in test-cpu-profiler.cc for Turbofan, changing them to a case where the deopt stack and the inlining position agree. It is currently still broken for other cases.
The following additional changes were necessary:
- The source position table (internal::SourcePositionTableBuilder etc.) supports now 64bit source positions. Encoding source positions in a single 64bit int together with the difference encoding in the source position table results in very little overhead for the inlining id, since only 12% of the source positions in Octane have a changed inlining id.
- The class HPositionInfo was effectively dead code and is now removed.
- SourcePosition has new printing and information facilities, including computing a full inlining stack.
- I had to rename compiler/source-position.{h,cc} to compiler/compiler-source-position-table.{h,cc} to avoid clashes with the new src/source-position.cc file.
- I wrote the new wrapper PodArray for ByteArray. It is a template working with any POD-type. This is used in DeoptimizationInputData::InliningPositions().
- I removed HInlinedFunctionInfo and HGraph::inlined_function_infos, because they were only used for the now obsolete Crankshaft inlining ids.
- Crankshaft managed a list of inlined functions in Lithium: LChunk::inlined_functions. This is an analog structure to CompilationInfo::inlined_functions. So I removed LChunk::inlined_functions and made Crankshaft use CompilationInfo::inlined_functions instead, because this was necessary to register the offsets into the literal array in a uniform way. This is a safe change because LChunk::inlined_functions has no other uses and the functions in CompilationInfo::inlined_functions have a strictly longer lifespan, being created earlier (in Hydrogen already).
BUG=v8:5432
Review-Url: https://codereview.chromium.org/2451853002
Cr-Commit-Position: refs/heads/master@{#40975}
2016-11-14 17:21:37 +00:00
|
|
|
#include "src/compiler/compiler-source-position-table.h"
|
2015-01-26 11:21:14 +00:00
|
|
|
#include "src/compiler/graph-visualizer.h"
|
2016-04-04 17:44:29 +00:00
|
|
|
#include "src/compiler/graph.h"
|
2015-01-26 11:21:14 +00:00
|
|
|
#include "src/compiler/js-operator.h"
|
2018-05-18 14:04:36 +00:00
|
|
|
#include "src/compiler/node-origin-table.h"
|
2015-01-26 11:21:14 +00:00
|
|
|
#include "src/compiler/node.h"
|
|
|
|
#include "src/compiler/opcodes.h"
|
|
|
|
#include "src/compiler/operator.h"
|
This CL enables precise source positions for all V8 compilers. It merges compiler::SourcePosition and internal::SourcePosition to a single class used throughout the codebase. The new internal::SourcePosition instances store an id identifying an inlined function in addition to a script offset.
SourcePosition::InliningId() refers to a the new table DeoptimizationInputData::InliningPositions(), which provides the following data for every inlining id:
- The inlined SharedFunctionInfo as an offset into DeoptimizationInfo::LiteralArray
- The SourcePosition of the inlining. Recursively, this yields the full inlining stack.
Before the Code object is created, the same information can be found in CompilationInfo::inlined_functions().
If SourcePosition::InliningId() is SourcePosition::kNotInlined, it refers to the outer (non-inlined) function.
So every SourcePosition has full information about its inlining stack, as long as the corresponding Code object is known. The internal represenation of a source position is a positive 64bit integer.
All compilers create now appropriate source positions for inlined functions. In the case of Turbofan, this required using AstGraphBuilderWithPositions for inlined functions too. So this class is now moved to a header file.
At the moment, the additional information in source positions is only used in --trace-deopt and --code-comments. The profiler needs to be updated, at the moment it gets the correct script offsets from the deopt info, but the wrong script id from the reconstructed deopt stack, which can lead to wrong outputs. This should be resolved by making the profiler use the new inlining information for deopts.
I activated the inlined deoptimization tests in test-cpu-profiler.cc for Turbofan, changing them to a case where the deopt stack and the inlining position agree. It is currently still broken for other cases.
The following additional changes were necessary:
- The source position table (internal::SourcePositionTableBuilder etc.) supports now 64bit source positions. Encoding source positions in a single 64bit int together with the difference encoding in the source position table results in very little overhead for the inlining id, since only 12% of the source positions in Octane have a changed inlining id.
- The class HPositionInfo was effectively dead code and is now removed.
- SourcePosition has new printing and information facilities, including computing a full inlining stack.
- I had to rename compiler/source-position.{h,cc} to compiler/compiler-source-position-table.{h,cc} to avoid clashes with the new src/source-position.cc file.
- I wrote the new wrapper PodArray for ByteArray. It is a template working with any POD-type. This is used in DeoptimizationInputData::InliningPositions().
- I removed HInlinedFunctionInfo and HGraph::inlined_function_infos, because they were only used for the now obsolete Crankshaft inlining ids.
- Crankshaft managed a list of inlined functions in Lithium: LChunk::inlined_functions. This is an analog structure to CompilationInfo::inlined_functions. So I removed LChunk::inlined_functions and made Crankshaft use CompilationInfo::inlined_functions instead, because this was necessary to register the offsets into the literal array in a uniform way. This is a safe change because LChunk::inlined_functions has no other uses and the functions in CompilationInfo::inlined_functions have a strictly longer lifespan, being created earlier (in Hydrogen already).
BUG=v8:5432
Review-Url: https://codereview.chromium.org/2451853002
Cr-Commit-Position: refs/heads/master@{#40975}
2016-11-14 17:21:37 +00:00
|
|
|
#include "src/compiler/schedule.h"
|
2015-01-26 11:21:14 +00:00
|
|
|
#include "src/compiler/simplified-operator.h"
|
|
|
|
#include "src/compiler/verifier.h"
|
2015-01-27 07:47:56 +00:00
|
|
|
#include "test/unittests/compiler/compiler-test-utils.h"
|
2015-01-26 11:21:14 +00:00
|
|
|
#include "test/unittests/test-utils.h"
|
2015-02-20 14:20:09 +00:00
|
|
|
#include "testing/gmock/include/gmock/gmock.h"
|
|
|
|
|
|
|
|
using testing::AnyOf;
|
2015-01-26 11:21:14 +00:00
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
2015-01-26 11:21:14 +00:00
|
|
|
|
2015-04-23 09:04:37 +00:00
|
|
|
class SchedulerTest : public TestWithIsolateAndZone {
|
2015-01-26 11:21:14 +00:00
|
|
|
public:
|
|
|
|
SchedulerTest()
|
2015-01-27 07:47:56 +00:00
|
|
|
: graph_(zone()), common_(zone()), simplified_(zone()), js_(zone()) {}
|
2015-01-26 11:21:14 +00:00
|
|
|
|
2015-02-20 14:20:09 +00:00
|
|
|
Schedule* ComputeAndVerifySchedule(size_t expected) {
|
2015-01-26 11:21:14 +00:00
|
|
|
if (FLAG_trace_turbo) {
|
|
|
|
OFStream os(stdout);
|
2015-12-11 16:58:03 +00:00
|
|
|
SourcePositionTable table(graph());
|
2018-05-18 14:04:36 +00:00
|
|
|
NodeOriginTable table2(graph());
|
|
|
|
os << AsJSON(*graph(), &table, &table2);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 14:20:09 +00:00
|
|
|
Schedule* schedule =
|
|
|
|
Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kSplitNodes);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
if (FLAG_trace_turbo_scheduler) {
|
|
|
|
OFStream os(stdout);
|
|
|
|
os << *schedule << std::endl;
|
|
|
|
}
|
|
|
|
ScheduleVerifier::Run(schedule);
|
2015-02-20 14:20:09 +00:00
|
|
|
EXPECT_EQ(expected, GetScheduledNodeCount(schedule));
|
2015-01-26 11:21:14 +00:00
|
|
|
return schedule;
|
|
|
|
}
|
|
|
|
|
2015-02-20 14:20:09 +00:00
|
|
|
size_t GetScheduledNodeCount(const Schedule* schedule) {
|
2015-01-26 11:21:14 +00:00
|
|
|
size_t node_count = 0;
|
|
|
|
for (auto block : *schedule->rpo_order()) {
|
|
|
|
node_count += block->NodeCount();
|
|
|
|
if (block->control() != BasicBlock::kNone) ++node_count;
|
|
|
|
}
|
2015-02-20 14:20:09 +00:00
|
|
|
return node_count;
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Graph* graph() { return &graph_; }
|
|
|
|
CommonOperatorBuilder* common() { return &common_; }
|
|
|
|
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
|
|
|
|
JSOperatorBuilder* js() { return &js_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Graph graph_;
|
|
|
|
CommonOperatorBuilder common_;
|
|
|
|
SimplifiedOperatorBuilder simplified_;
|
|
|
|
JSOperatorBuilder js_;
|
|
|
|
};
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2015-02-20 14:20:09 +00:00
|
|
|
const Operator kHeapConstant(IrOpcode::kHeapConstant, Operator::kPure,
|
|
|
|
"HeapConstant", 0, 0, 0, 1, 0, 0);
|
2015-01-27 07:47:56 +00:00
|
|
|
const Operator kIntAdd(IrOpcode::kInt32Add, Operator::kPure, "Int32Add", 2, 0,
|
|
|
|
0, 1, 0, 0);
|
2015-02-24 11:44:45 +00:00
|
|
|
const Operator kMockCall(IrOpcode::kCall, Operator::kNoProperties, "MockCall",
|
2015-09-25 08:42:51 +00:00
|
|
|
0, 0, 1, 1, 1, 2);
|
2015-05-05 09:42:59 +00:00
|
|
|
const Operator kMockTailCall(IrOpcode::kTailCall, Operator::kNoProperties,
|
|
|
|
"MockTailCall", 1, 1, 1, 0, 0, 1);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
2015-02-20 14:20:09 +00:00
|
|
|
TEST_F(SchedulerTest, BuildScheduleEmpty) {
|
|
|
|
graph()->SetStart(graph()->NewNode(common()->Start(0)));
|
2015-05-26 10:31:55 +00:00
|
|
|
graph()->SetEnd(graph()->NewNode(common()->End(1), graph()->start()));
|
2015-02-20 14:20:09 +00:00
|
|
|
USE(Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kNoFlags));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(SchedulerTest, BuildScheduleOneParameter) {
|
|
|
|
graph()->SetStart(graph()->NewNode(common()->Start(0)));
|
|
|
|
|
|
|
|
Node* p1 = graph()->NewNode(common()->Parameter(0), graph()->start());
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, p1, graph()->start(),
|
2015-02-20 14:20:09 +00:00
|
|
|
graph()->start());
|
|
|
|
|
2015-05-26 10:31:55 +00:00
|
|
|
graph()->SetEnd(graph()->NewNode(common()->End(1), ret));
|
2015-02-20 14:20:09 +00:00
|
|
|
|
|
|
|
USE(Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kNoFlags));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
namespace {
|
2015-01-26 11:21:14 +00:00
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
Node* CreateDiamond(Graph* graph, CommonOperatorBuilder* common, Node* cond) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* tv = graph->NewNode(common->Int32Constant(6));
|
|
|
|
Node* fv = graph->NewNode(common->Int32Constant(7));
|
|
|
|
Node* br = graph->NewNode(common->Branch(), cond, graph->start());
|
|
|
|
Node* t = graph->NewNode(common->IfTrue(), br);
|
|
|
|
Node* f = graph->NewNode(common->IfFalse(), br);
|
|
|
|
Node* m = graph->NewNode(common->Merge(2), t, f);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi =
|
|
|
|
graph->NewNode(common->Phi(MachineRepresentation::kTagged, 2), tv, fv, m);
|
2015-01-26 11:21:14 +00:00
|
|
|
return phi;
|
|
|
|
}
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
} // namespace
|
|
|
|
|
2015-01-26 11:21:14 +00:00
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, FloatingDiamond1) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(1));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
Node* d1 = CreateDiamond(graph(), common(), p0);
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, d1, start, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(14);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
2016-04-04 17:44:29 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, FloatingDeadDiamond1) {
|
|
|
|
Node* start = graph()->NewNode(common()->Start(1));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
Node* d1 = CreateDiamond(graph(), common(), p0);
|
|
|
|
USE(d1);
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, p0, start, start);
|
2016-04-04 17:44:29 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(5);
|
2016-04-04 17:44:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TARGET_TEST_F(SchedulerTest, FloatingDeadDiamond2) {
|
|
|
|
Graph* g = graph();
|
|
|
|
Node* start = g->NewNode(common()->Start(1));
|
|
|
|
g->SetStart(start);
|
|
|
|
|
|
|
|
Node* n1 = g->NewNode(common()->Parameter(1), start);
|
|
|
|
|
|
|
|
Node* n2 = g->NewNode(common()->Branch(), n1, start);
|
|
|
|
Node* n3 = g->NewNode(common()->IfTrue(), n2);
|
|
|
|
Node* n4 = g->NewNode(common()->IfFalse(), n2);
|
|
|
|
Node* n5 = g->NewNode(common()->Int32Constant(-100));
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* n6 = g->NewNode(common()->Return(), zero, n5, start, n4);
|
2016-04-04 17:44:29 +00:00
|
|
|
Node* n7 = g->NewNode(common()->Int32Constant(0));
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* n8 = g->NewNode(common()->Return(), zero, n7, start, n3);
|
2016-04-04 17:44:29 +00:00
|
|
|
Node* n9 = g->NewNode(common()->End(2), n6, n8);
|
|
|
|
|
|
|
|
// Dead nodes
|
|
|
|
Node* n10 = g->NewNode(common()->Branch(), n1, n3);
|
|
|
|
Node* n11 = g->NewNode(common()->IfTrue(), n10);
|
|
|
|
Node* n12 = g->NewNode(common()->IfFalse(), n10);
|
|
|
|
Node* n13 = g->NewNode(common()->Merge(2), n11, n12);
|
|
|
|
Node* n14 =
|
|
|
|
g->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), n1, n7, n13);
|
|
|
|
|
|
|
|
USE(n14);
|
|
|
|
|
|
|
|
g->SetEnd(n9);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(11);
|
2016-04-04 17:44:29 +00:00
|
|
|
}
|
2015-01-26 11:21:14 +00:00
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, FloatingDiamond2) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(2));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
Node* p1 = graph()->NewNode(common()->Parameter(1), start);
|
|
|
|
Node* d1 = CreateDiamond(graph(), common(), p0);
|
|
|
|
Node* d2 = CreateDiamond(graph(), common(), p1);
|
|
|
|
Node* add = graph()->NewNode(&kIntAdd, d1, d2);
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, add, start, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(25);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, FloatingDiamond3) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(2));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
Node* p1 = graph()->NewNode(common()->Parameter(1), start);
|
|
|
|
Node* d1 = CreateDiamond(graph(), common(), p0);
|
|
|
|
Node* d2 = CreateDiamond(graph(), common(), p1);
|
|
|
|
Node* add = graph()->NewNode(&kIntAdd, d1, d2);
|
|
|
|
Node* d3 = CreateDiamond(graph(), common(), add);
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, d3, start, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(34);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, NestedFloatingDiamonds) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(2));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
|
|
|
|
Node* fv = graph()->NewNode(common()->Int32Constant(7));
|
|
|
|
Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start());
|
|
|
|
Node* t = graph()->NewNode(common()->IfTrue(), br);
|
|
|
|
Node* f = graph()->NewNode(common()->IfFalse(), br);
|
|
|
|
|
|
|
|
Node* map = graph()->NewNode(
|
|
|
|
simplified()->LoadElement(AccessBuilder::ForFixedArrayElement()), p0, p0,
|
2015-09-23 09:08:15 +00:00
|
|
|
start, f);
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* br1 = graph()->NewNode(common()->Branch(), map, graph()->start());
|
|
|
|
Node* t1 = graph()->NewNode(common()->IfTrue(), br1);
|
|
|
|
Node* f1 = graph()->NewNode(common()->IfFalse(), br1);
|
|
|
|
Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1);
|
|
|
|
Node* ttrue = graph()->NewNode(common()->Int32Constant(1));
|
|
|
|
Node* ffalse = graph()->NewNode(common()->Int32Constant(0));
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi1 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), ttrue, ffalse, m1);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
Node* m = graph()->NewNode(common()->Merge(2), t, f);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
|
|
|
fv, phi1, m);
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), start, map, m);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, phi, ephi1, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(24);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(2));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
Node* p1 = graph()->NewNode(common()->Parameter(1), start);
|
|
|
|
Node* c = graph()->NewNode(common()->Int32Constant(7));
|
|
|
|
|
|
|
|
Node* brA1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
|
|
|
|
Node* tA1 = graph()->NewNode(common()->IfTrue(), brA1);
|
|
|
|
Node* fA1 = graph()->NewNode(common()->IfFalse(), brA1);
|
|
|
|
Node* mA1 = graph()->NewNode(common()->Merge(2), tA1, fA1);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phiA1 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), p0, p1, mA1);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* brB1 = graph()->NewNode(common()->Branch(), p1, graph()->start());
|
|
|
|
Node* tB1 = graph()->NewNode(common()->IfTrue(), brB1);
|
|
|
|
Node* fB1 = graph()->NewNode(common()->IfFalse(), brB1);
|
|
|
|
Node* mB1 = graph()->NewNode(common()->Merge(2), tB1, fB1);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phiB1 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), p0, p1, mB1);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* brA2 = graph()->NewNode(common()->Branch(), phiB1, mA1);
|
|
|
|
Node* tA2 = graph()->NewNode(common()->IfTrue(), brA2);
|
|
|
|
Node* fA2 = graph()->NewNode(common()->IfFalse(), brA2);
|
|
|
|
Node* mA2 = graph()->NewNode(common()->Merge(2), tA2, fA2);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phiA2 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), phiB1, c, mA2);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* brB2 = graph()->NewNode(common()->Branch(), phiA1, mB1);
|
|
|
|
Node* tB2 = graph()->NewNode(common()->IfTrue(), brB2);
|
|
|
|
Node* fB2 = graph()->NewNode(common()->IfFalse(), brB2);
|
|
|
|
Node* mB2 = graph()->NewNode(common()->Merge(2), tB2, fB2);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phiB2 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), phiA1, c, mB2);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* add = graph()->NewNode(&kIntAdd, phiA2, phiB2);
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, add, start, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(37);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(2));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
|
|
|
|
Node* fv = graph()->NewNode(common()->Int32Constant(7));
|
|
|
|
Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start());
|
|
|
|
Node* t = graph()->NewNode(common()->IfTrue(), br);
|
|
|
|
Node* f = graph()->NewNode(common()->IfFalse(), br);
|
|
|
|
|
|
|
|
Node* loop = graph()->NewNode(common()->Loop(2), f, start);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
|
|
|
p0, p0, loop);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* add = graph()->NewNode(&kIntAdd, ind, fv);
|
|
|
|
Node* br1 = graph()->NewNode(common()->Branch(), add, loop);
|
|
|
|
Node* t1 = graph()->NewNode(common()->IfTrue(), br1);
|
|
|
|
Node* f1 = graph()->NewNode(common()->IfFalse(), br1);
|
|
|
|
|
|
|
|
loop->ReplaceInput(1, t1); // close loop.
|
|
|
|
ind->ReplaceInput(1, ind); // close induction variable.
|
|
|
|
|
|
|
|
Node* m = graph()->NewNode(common()->Merge(2), t, f1);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
|
|
|
fv, ind, m);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(21);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond1) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(2));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
|
|
|
|
Node* c = graph()->NewNode(common()->Int32Constant(7));
|
|
|
|
Node* loop = graph()->NewNode(common()->Loop(2), start, start);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
|
|
|
p0, p0, loop);
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* add = graph()->NewNode(&kIntAdd, ind, c);
|
|
|
|
|
|
|
|
Node* br = graph()->NewNode(common()->Branch(), add, loop);
|
|
|
|
Node* t = graph()->NewNode(common()->IfTrue(), br);
|
|
|
|
Node* f = graph()->NewNode(common()->IfFalse(), br);
|
|
|
|
|
|
|
|
Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
|
|
|
|
Node* t1 = graph()->NewNode(common()->IfTrue(), br1);
|
|
|
|
Node* f1 = graph()->NewNode(common()->IfFalse(), br1);
|
|
|
|
Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi1 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), add, p0, m1);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
loop->ReplaceInput(1, t); // close loop.
|
|
|
|
ind->ReplaceInput(1, phi1); // close induction variable.
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, ind, start, f);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(2), ret, f);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(21);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond2) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(2));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
|
|
|
|
Node* c = graph()->NewNode(common()->Int32Constant(7));
|
|
|
|
Node* loop = graph()->NewNode(common()->Loop(2), start, start);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
|
|
|
p0, p0, loop);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
|
|
|
|
Node* t1 = graph()->NewNode(common()->IfTrue(), br1);
|
|
|
|
Node* f1 = graph()->NewNode(common()->IfFalse(), br1);
|
|
|
|
Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi1 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), c, ind, m1);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* add = graph()->NewNode(&kIntAdd, ind, phi1);
|
|
|
|
|
|
|
|
Node* br = graph()->NewNode(common()->Branch(), add, loop);
|
|
|
|
Node* t = graph()->NewNode(common()->IfTrue(), br);
|
|
|
|
Node* f = graph()->NewNode(common()->IfFalse(), br);
|
|
|
|
|
|
|
|
loop->ReplaceInput(1, t); // close loop.
|
|
|
|
ind->ReplaceInput(1, add); // close induction variable.
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, ind, start, f);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(2), ret, f);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(21);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond3) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(2));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
|
|
|
|
Node* c = graph()->NewNode(common()->Int32Constant(7));
|
|
|
|
Node* loop = graph()->NewNode(common()->Loop(2), start, start);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
|
|
|
p0, p0, loop);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
|
|
|
|
Node* t1 = graph()->NewNode(common()->IfTrue(), br1);
|
|
|
|
Node* f1 = graph()->NewNode(common()->IfFalse(), br1);
|
|
|
|
|
|
|
|
Node* loop1 = graph()->NewNode(common()->Loop(2), t1, start);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* ind1 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), p0, p0, loop);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* add1 = graph()->NewNode(&kIntAdd, ind1, c);
|
|
|
|
Node* br2 = graph()->NewNode(common()->Branch(), add1, loop1);
|
|
|
|
Node* t2 = graph()->NewNode(common()->IfTrue(), br2);
|
|
|
|
Node* f2 = graph()->NewNode(common()->IfFalse(), br2);
|
|
|
|
|
|
|
|
loop1->ReplaceInput(1, t2); // close inner loop.
|
|
|
|
ind1->ReplaceInput(1, ind1); // close inner induction variable.
|
|
|
|
|
|
|
|
Node* m1 = graph()->NewNode(common()->Merge(2), f1, f2);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi1 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), c, ind1, m1);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* add = graph()->NewNode(&kIntAdd, ind, phi1);
|
|
|
|
|
|
|
|
Node* br = graph()->NewNode(common()->Branch(), add, loop);
|
|
|
|
Node* t = graph()->NewNode(common()->IfTrue(), br);
|
|
|
|
Node* f = graph()->NewNode(common()->IfFalse(), br);
|
|
|
|
|
|
|
|
loop->ReplaceInput(1, t); // close loop.
|
|
|
|
ind->ReplaceInput(1, add); // close induction variable.
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, ind, start, f);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(2), ret, f);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(29);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, PhisPushedDownToDifferentBranches) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(2));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
Node* p1 = graph()->NewNode(common()->Parameter(1), start);
|
|
|
|
|
|
|
|
Node* v1 = graph()->NewNode(common()->Int32Constant(1));
|
|
|
|
Node* v2 = graph()->NewNode(common()->Int32Constant(2));
|
|
|
|
Node* v3 = graph()->NewNode(common()->Int32Constant(3));
|
|
|
|
Node* v4 = graph()->NewNode(common()->Int32Constant(4));
|
|
|
|
Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start());
|
|
|
|
Node* t = graph()->NewNode(common()->IfTrue(), br);
|
|
|
|
Node* f = graph()->NewNode(common()->IfFalse(), br);
|
|
|
|
Node* m = graph()->NewNode(common()->Merge(2), t, f);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
|
|
|
v1, v2, m);
|
|
|
|
Node* phi2 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), v3, v4, m);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
Node* br2 = graph()->NewNode(common()->Branch(), p1, graph()->start());
|
|
|
|
Node* t2 = graph()->NewNode(common()->IfTrue(), br2);
|
|
|
|
Node* f2 = graph()->NewNode(common()->IfFalse(), br2);
|
|
|
|
Node* m2 = graph()->NewNode(common()->Merge(2), t2, f2);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi3 = graph()->NewNode(
|
|
|
|
common()->Phi(MachineRepresentation::kTagged, 2), phi, phi2, m2);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, phi3, start, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(25);
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, BranchHintTrue) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(1));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
Node* tv = graph()->NewNode(common()->Int32Constant(6));
|
|
|
|
Node* fv = graph()->NewNode(common()->Int32Constant(7));
|
|
|
|
Node* br = graph()->NewNode(common()->Branch(BranchHint::kTrue), p0, start);
|
|
|
|
Node* t = graph()->NewNode(common()->IfTrue(), br);
|
|
|
|
Node* f = graph()->NewNode(common()->IfFalse(), br);
|
|
|
|
Node* m = graph()->NewNode(common()->Merge(2), t, f);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
|
|
|
tv, fv, m);
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
Schedule* schedule = ComputeAndVerifySchedule(14);
|
2015-01-26 11:21:14 +00:00
|
|
|
// Make sure the false block is marked as deferred.
|
2015-02-20 14:20:09 +00:00
|
|
|
EXPECT_FALSE(schedule->block(t)->deferred());
|
|
|
|
EXPECT_TRUE(schedule->block(f)->deferred());
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, BranchHintFalse) {
|
2015-01-26 11:21:14 +00:00
|
|
|
Node* start = graph()->NewNode(common()->Start(1));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
Node* tv = graph()->NewNode(common()->Int32Constant(6));
|
|
|
|
Node* fv = graph()->NewNode(common()->Int32Constant(7));
|
|
|
|
Node* br = graph()->NewNode(common()->Branch(BranchHint::kFalse), p0, start);
|
|
|
|
Node* t = graph()->NewNode(common()->IfTrue(), br);
|
|
|
|
Node* f = graph()->NewNode(common()->IfFalse(), br);
|
|
|
|
Node* m = graph()->NewNode(common()->Merge(2), t, f);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
|
|
|
tv, fv, m);
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-01-26 11:21:14 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
Schedule* schedule = ComputeAndVerifySchedule(14);
|
2015-01-26 11:21:14 +00:00
|
|
|
// Make sure the true block is marked as deferred.
|
2015-02-20 14:20:09 +00:00
|
|
|
EXPECT_TRUE(schedule->block(t)->deferred());
|
|
|
|
EXPECT_FALSE(schedule->block(f)->deferred());
|
2015-01-26 11:21:14 +00:00
|
|
|
}
|
|
|
|
|
2015-02-09 08:56:01 +00:00
|
|
|
|
2015-02-24 11:44:45 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, CallException) {
|
|
|
|
Node* start = graph()->NewNode(common()->Start(1));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
Node* c1 = graph()->NewNode(&kMockCall, start);
|
|
|
|
Node* ok1 = graph()->NewNode(common()->IfSuccess(), c1);
|
2016-08-02 14:48:21 +00:00
|
|
|
Node* ex1 = graph()->NewNode(common()->IfException(), c1, c1);
|
2015-02-24 11:44:45 +00:00
|
|
|
Node* c2 = graph()->NewNode(&kMockCall, ok1);
|
|
|
|
Node* ok2 = graph()->NewNode(common()->IfSuccess(), c2);
|
2016-08-02 14:48:21 +00:00
|
|
|
Node* ex2 = graph()->NewNode(common()->IfException(), c2, c2);
|
2015-02-24 11:44:45 +00:00
|
|
|
Node* hdl = graph()->NewNode(common()->Merge(2), ex1, ex2);
|
|
|
|
Node* m = graph()->NewNode(common()->Merge(2), ok2, hdl);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
|
|
|
|
c2, p0, m);
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, m);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-02-24 11:44:45 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
Schedule* schedule = ComputeAndVerifySchedule(18);
|
2015-02-24 11:44:45 +00:00
|
|
|
// Make sure the exception blocks as well as the handler are deferred.
|
|
|
|
EXPECT_TRUE(schedule->block(ex1)->deferred());
|
|
|
|
EXPECT_TRUE(schedule->block(ex2)->deferred());
|
|
|
|
EXPECT_TRUE(schedule->block(hdl)->deferred());
|
|
|
|
EXPECT_FALSE(schedule->block(m)->deferred());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-05 09:42:59 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, TailCall) {
|
|
|
|
Node* start = graph()->NewNode(common()->Start(1));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
|
|
|
Node* call = graph()->NewNode(&kMockTailCall, p0, start, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), call);
|
2015-05-05 09:42:59 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
|
|
|
ComputeAndVerifySchedule(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-09 08:56:01 +00:00
|
|
|
TARGET_TEST_F(SchedulerTest, Switch) {
|
|
|
|
Node* start = graph()->NewNode(common()->Start(1));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
2015-02-17 13:29:31 +00:00
|
|
|
Node* sw = graph()->NewNode(common()->Switch(3), p0, start);
|
|
|
|
Node* c0 = graph()->NewNode(common()->IfValue(0), sw);
|
2015-02-09 08:56:01 +00:00
|
|
|
Node* v0 = graph()->NewNode(common()->Int32Constant(11));
|
2015-02-17 13:29:31 +00:00
|
|
|
Node* c1 = graph()->NewNode(common()->IfValue(1), sw);
|
2015-02-09 08:56:01 +00:00
|
|
|
Node* v1 = graph()->NewNode(common()->Int32Constant(22));
|
2015-02-17 13:29:31 +00:00
|
|
|
Node* d = graph()->NewNode(common()->IfDefault(), sw);
|
|
|
|
Node* vd = graph()->NewNode(common()->Int32Constant(33));
|
|
|
|
Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 3),
|
|
|
|
v0, v1, vd, m);
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, m);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-02-09 08:56:01 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(17);
|
2015-02-09 08:56:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TARGET_TEST_F(SchedulerTest, FloatingSwitch) {
|
|
|
|
Node* start = graph()->NewNode(common()->Start(1));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
|
2015-02-17 13:29:31 +00:00
|
|
|
Node* sw = graph()->NewNode(common()->Switch(3), p0, start);
|
|
|
|
Node* c0 = graph()->NewNode(common()->IfValue(0), sw);
|
2015-02-09 08:56:01 +00:00
|
|
|
Node* v0 = graph()->NewNode(common()->Int32Constant(11));
|
2015-02-17 13:29:31 +00:00
|
|
|
Node* c1 = graph()->NewNode(common()->IfValue(1), sw);
|
2015-02-09 08:56:01 +00:00
|
|
|
Node* v1 = graph()->NewNode(common()->Int32Constant(22));
|
2015-02-17 13:29:31 +00:00
|
|
|
Node* d = graph()->NewNode(common()->IfDefault(), sw);
|
|
|
|
Node* vd = graph()->NewNode(common()->Int32Constant(33));
|
|
|
|
Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d);
|
2015-12-10 09:03:30 +00:00
|
|
|
Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 3),
|
|
|
|
v0, v1, vd, m);
|
2016-11-02 13:15:39 +00:00
|
|
|
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
|
|
|
Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, start);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), ret);
|
2015-02-09 08:56:01 +00:00
|
|
|
|
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
2016-11-02 13:15:39 +00:00
|
|
|
ComputeAndVerifySchedule(17);
|
2015-02-09 08:56:01 +00:00
|
|
|
}
|
|
|
|
|
2015-05-06 12:51:41 +00:00
|
|
|
|
|
|
|
TARGET_TEST_F(SchedulerTest, Terminate) {
|
|
|
|
Node* start = graph()->NewNode(common()->Start(1));
|
|
|
|
graph()->SetStart(start);
|
|
|
|
|
|
|
|
Node* loop = graph()->NewNode(common()->Loop(2), start, start);
|
|
|
|
loop->ReplaceInput(1, loop); // self loop, NTL.
|
|
|
|
|
2015-10-09 10:52:41 +00:00
|
|
|
Node* effect = graph()->NewNode(common()->EffectPhi(2), start, start, loop);
|
|
|
|
effect->ReplaceInput(1, effect); // self loop.
|
2015-05-06 12:51:41 +00:00
|
|
|
|
|
|
|
Node* terminate = graph()->NewNode(common()->Terminate(), effect, loop);
|
2015-05-26 10:31:55 +00:00
|
|
|
Node* end = graph()->NewNode(common()->End(1), terminate);
|
2015-05-06 12:51:41 +00:00
|
|
|
graph()->SetEnd(end);
|
|
|
|
|
|
|
|
Schedule* schedule = ComputeAndVerifySchedule(6);
|
|
|
|
BasicBlock* block = schedule->block(loop);
|
|
|
|
EXPECT_EQ(block, schedule->block(effect));
|
|
|
|
EXPECT_GE(block->rpo_number(), 0);
|
|
|
|
}
|
|
|
|
|
2015-01-27 07:47:56 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|