Commit c16b91e8 authored by Benedikt Meurer's avatar Benedikt Meurer

[turbofan] Fix unit test coverage for JSIntrinsicLowering.

R=dcarney@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#27328}
parent c594995d
......@@ -27,8 +27,9 @@ class JSIntrinsicLoweringTest : public GraphTest {
~JSIntrinsicLoweringTest() OVERRIDE {}
protected:
Reduction Reduce(Node* node) {
MachineOperatorBuilder machine(zone());
Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags =
MachineOperatorBuilder::kNoFlags) {
MachineOperatorBuilder machine(zone(), kMachPtr, flags);
JSGraph jsgraph(isolate(), graph(), common(), javascript(), &machine);
JSIntrinsicLowering reducer(&jsgraph);
return reducer.Reduce(node);
......@@ -223,6 +224,77 @@ TEST_F(JSIntrinsicLoweringTest, InlineIsRegExp) {
}
// -----------------------------------------------------------------------------
// %_JSValueGetValue
TEST_F(JSIntrinsicLoweringTest, InlineJSValueGetValue) {
Node* const input = Parameter(0);
Node* const context = Parameter(1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Reduction const r = Reduce(graph()->NewNode(
javascript()->CallRuntime(Runtime::kInlineJSValueGetValue, 1), input,
context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsLoadField(AccessBuilder::ForValue(), input, effect, control));
}
// -----------------------------------------------------------------------------
// %_MathFloor
TEST_F(JSIntrinsicLoweringTest, InlineMathFloor) {
Node* const input = Parameter(0);
Node* const context = Parameter(1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Reduction const r = Reduce(
graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineMathFloor, 1),
input, context, effect, control),
MachineOperatorBuilder::kFloat64RoundDown);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat64RoundDown(input));
}
// -----------------------------------------------------------------------------
// %_MathSqrt
TEST_F(JSIntrinsicLoweringTest, InlineMathSqrt) {
Node* const input = Parameter(0);
Node* const context = Parameter(1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Reduction const r = Reduce(
graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineMathSqrt, 1),
input, context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat64Sqrt(input));
}
// -----------------------------------------------------------------------------
// %_StringGetLength
TEST_F(JSIntrinsicLoweringTest, InlineStringGetLength) {
Node* const input = Parameter(0);
Node* const context = Parameter(1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Reduction const r = Reduce(graph()->NewNode(
javascript()->CallRuntime(Runtime::kInlineStringGetLength, 1), input,
context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(),
input, effect, control));
}
// -----------------------------------------------------------------------------
// %_ValueOf
......
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