v8/test/unittests/compiler/simplified-lowering-unittest.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

95 lines
3.2 KiB
C++
Raw Normal View History

// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compiler/simplified-lowering.h"
#include "src/codegen/tick-counter.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/simplified-operator.h"
#include "test/unittests/compiler/graph-unittest.h"
#include "test/unittests/compiler/node-test-utils.h"
namespace v8 {
namespace internal {
namespace compiler {
class SimplifiedLoweringTest : public GraphTest {
public:
explicit SimplifiedLoweringTest(int num_parameters = 1)
: GraphTest(num_parameters),
num_parameters_(num_parameters),
machine_(zone()),
javascript_(zone()),
simplified_(zone()),
jsgraph_(isolate(), graph(), common(), &javascript_, &simplified_,
&machine_) {}
~SimplifiedLoweringTest() override = default;
void LowerGraph(Node* node) {
// Make sure we always start with an empty graph.
graph()->SetStart(graph()->NewNode(common()->Start(num_parameters())));
graph()->SetEnd(graph()->NewNode(common()->End(1), graph()->start()));
// Return {node} directly, so that we can match it with
// "IsReturn(expected)".
Node* zero = graph()->NewNode(common()->NumberConstant(0));
Node* ret = graph()->NewNode(common()->Return(), zero, node,
graph()->start(), graph()->start());
NodeProperties::MergeControlToEnd(graph(), common(), ret);
{
// Simplified lowering needs to run w/o the typer decorator so make sure
// the object is not live at the same time.
Typer typer(broker(), Typer::kNoFlags, graph(), tick_counter());
typer.Run();
}
Reland "[turboprop] Pass required parameters as value inputs to TierUpCheck node" This is a reland of 44f46defcf0884dcfefb7f67d2d550c2ae6d32cf with a fix for failures with --turbonci_as_mid_tier Original change's description: > [turboprop] Pass required parameters as value inputs to TierUpCheck node > > TierUpCheck node tail calls interpreter entry trampoline when additional > processing is needed for tiering up. Calling IET requires target, > new_target, input count and context as parameters. Earlier these were > created as parameter nodes in effect-control-linearizer. This causes > problems with Turboprop since TurboProp doesn't use the second scheduler > and cannot reschedule these nodes to the start block. We should instead > create these parameter nodes in bytecode-graph-builder and pass them > as value inputs to TierUpCheck node. > > Bug: v8:9684 > Change-Id: Icfe5a33b4e628d5a3ba9a3121b2b0746be6aed5c > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2498695 > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> > Commit-Queue: Mythri Alle <mythria@chromium.org> > Cr-Commit-Position: refs/heads/master@{#70790} Bug: v8:9684 Change-Id: Ic1a7d39aab0a599d0dd421f237e7bc640fcd6eb1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2504258 Commit-Queue: Mythri Alle <mythria@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Cr-Commit-Position: refs/heads/master@{#70856}
2020-10-28 14:20:22 +00:00
Linkage* linkage = zone()->New<Linkage>(Linkage::GetJSCallDescriptor(
zone(), false, num_parameters_ + 1, CallDescriptor::kCanUseRoots));
SimplifiedLowering lowering(
jsgraph(), broker(), zone(), source_positions(), node_origins(),
Reland "[turboprop] Pass required parameters as value inputs to TierUpCheck node" This is a reland of 44f46defcf0884dcfefb7f67d2d550c2ae6d32cf with a fix for failures with --turbonci_as_mid_tier Original change's description: > [turboprop] Pass required parameters as value inputs to TierUpCheck node > > TierUpCheck node tail calls interpreter entry trampoline when additional > processing is needed for tiering up. Calling IET requires target, > new_target, input count and context as parameters. Earlier these were > created as parameter nodes in effect-control-linearizer. This causes > problems with Turboprop since TurboProp doesn't use the second scheduler > and cannot reschedule these nodes to the start block. We should instead > create these parameter nodes in bytecode-graph-builder and pass them > as value inputs to TierUpCheck node. > > Bug: v8:9684 > Change-Id: Icfe5a33b4e628d5a3ba9a3121b2b0746be6aed5c > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2498695 > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> > Commit-Queue: Mythri Alle <mythria@chromium.org> > Cr-Commit-Position: refs/heads/master@{#70790} Bug: v8:9684 Change-Id: Ic1a7d39aab0a599d0dd421f237e7bc640fcd6eb1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2504258 Commit-Queue: Mythri Alle <mythria@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Cr-Commit-Position: refs/heads/master@{#70856}
2020-10-28 14:20:22 +00:00
PoisoningMitigationLevel::kDontPoison, tick_counter(), linkage);
lowering.LowerAllNodes();
}
int num_parameters() const { return num_parameters_; }
JSGraph* jsgraph() { return &jsgraph_; }
private:
const int num_parameters_;
MachineOperatorBuilder machine_;
JSOperatorBuilder javascript_;
SimplifiedOperatorBuilder simplified_;
JSGraph jsgraph_;
};
const int kSmiValues[] = {Smi::kMinValue,
Smi::kMinValue + 1,
Smi::kMinValue + 2,
3,
2,
1,
0,
-1,
-2,
-3,
Smi::kMaxValue - 2,
Smi::kMaxValue - 1,
Smi::kMaxValue};
TEST_F(SimplifiedLoweringTest, SmiConstantToIntPtrConstant) {
TRACED_FOREACH(int, x, kSmiValues) {
LowerGraph(jsgraph()->Constant(x));
intptr_t smi = bit_cast<intptr_t>(Smi::FromInt(x));
EXPECT_THAT(graph()->end()->InputAt(1),
IsReturn(IsIntPtrConstant(smi), start(), start()));
}
}
} // namespace compiler
} // namespace internal
} // namespace v8