aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/unittests/compiler/instruction-selector-unittest.cc')
-rw-r--r--deps/v8/test/unittests/compiler/instruction-selector-unittest.cc110
1 files changed, 64 insertions, 46 deletions
diff --git a/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc b/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc
index dfdb4c2b1f..acab91b009 100644
--- a/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc
+++ b/deps/v8/test/unittests/compiler/instruction-selector-unittest.cc
@@ -148,6 +148,15 @@ bool InstructionSelectorTest::Stream::IsUsedAtStart(
}
+const FrameStateFunctionInfo*
+InstructionSelectorTest::StreamBuilder::GetFrameStateFunctionInfo(
+ int parameter_count, int local_count) {
+ return common()->CreateFrameStateFunctionInfo(
+ FrameStateType::kJavaScriptFunction, parameter_count, local_count,
+ Handle<SharedFunctionInfo>());
+}
+
+
// -----------------------------------------------------------------------------
// Return.
@@ -198,7 +207,8 @@ TARGET_TEST_F(InstructionSelectorTest, ReturnZero) {
TARGET_TEST_F(InstructionSelectorTest, TruncateFloat64ToInt32WithParameter) {
StreamBuilder m(this, kMachInt32, kMachFloat64);
- m.Return(m.TruncateFloat64ToInt32(m.Parameter(0)));
+ m.Return(
+ m.TruncateFloat64ToInt32(TruncationMode::kJavaScript, m.Parameter(0)));
Stream s = m.Build(kAllInstructions);
ASSERT_EQ(4U, s.size());
EXPECT_EQ(kArchNop, s[0]->arch_opcode());
@@ -363,9 +373,10 @@ TARGET_TEST_F(InstructionSelectorTest, CallJSFunctionWithDeopt) {
Node* context_dummy = m.Int32Constant(0);
Node* state_node = m.NewNode(
- m.common()->FrameState(JS_FRAME, bailout_id,
- OutputFrameStateCombine::Push()),
- parameters, locals, stack, context_dummy, m.UndefinedConstant());
+ m.common()->FrameState(bailout_id, OutputFrameStateCombine::Push(),
+ m.GetFrameStateFunctionInfo(1, 0)),
+ parameters, locals, stack, context_dummy, function_node,
+ m.UndefinedConstant());
Node* call = m.CallJS0(function_node, receiver, context, state_node);
m.Return(call);
@@ -411,9 +422,10 @@ TARGET_TEST_F(InstructionSelectorTest, CallFunctionStubWithDeopt) {
Node* context_sentinel = m.Int32Constant(0);
Node* frame_state_before = m.NewNode(
- m.common()->FrameState(JS_FRAME, bailout_id_before,
- OutputFrameStateCombine::Push()),
- parameters, locals, stack, context_sentinel, m.UndefinedConstant());
+ m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(),
+ m.GetFrameStateFunctionInfo(1, 1)),
+ parameters, locals, stack, context_sentinel, function_node,
+ m.UndefinedConstant());
// Build the call.
Node* call = m.CallFunctionStub0(function_node, receiver, context,
@@ -437,7 +449,7 @@ TARGET_TEST_F(InstructionSelectorTest, CallFunctionStubWithDeopt) {
size_t num_operands =
1 + // Code object.
1 +
- 4 + // Frame state deopt id + one input for each value in frame state.
+ 5 + // Frame state deopt id + one input for each value in frame state.
1 + // Function.
1; // Context.
ASSERT_EQ(num_operands, call_instr->InputCount());
@@ -455,21 +467,23 @@ TARGET_TEST_F(InstructionSelectorTest, CallFunctionStubWithDeopt) {
EXPECT_EQ(1u, desc_before->parameters_count());
EXPECT_EQ(1u, desc_before->locals_count());
EXPECT_EQ(1u, desc_before->stack_count());
- EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(2)));
- EXPECT_EQ(0, s.ToInt32(call_instr->InputAt(3))); // This should be a context.
+ EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(3)));
+ EXPECT_EQ(0, s.ToInt32(call_instr->InputAt(4))); // This should be a context.
// We inserted 0 here.
- EXPECT_EQ(0.5, s.ToFloat64(call_instr->InputAt(4)));
- EXPECT_TRUE(s.ToHeapObject(call_instr->InputAt(5))->IsUndefined());
- EXPECT_EQ(kMachInt32, desc_before->GetType(0));
- EXPECT_EQ(kMachAnyTagged, desc_before->GetType(1)); // context is always
+ EXPECT_EQ(0.5, s.ToFloat64(call_instr->InputAt(5)));
+ EXPECT_TRUE(s.ToHeapObject(call_instr->InputAt(6))->IsUndefined());
+ EXPECT_EQ(kMachAnyTagged, desc_before->GetType(0)); // function is always
// tagged/any.
- EXPECT_EQ(kMachFloat64, desc_before->GetType(2));
- EXPECT_EQ(kMachAnyTagged, desc_before->GetType(3));
+ EXPECT_EQ(kMachInt32, desc_before->GetType(1));
+ EXPECT_EQ(kMachAnyTagged, desc_before->GetType(2)); // context is always
+ // tagged/any.
+ EXPECT_EQ(kMachFloat64, desc_before->GetType(3));
+ EXPECT_EQ(kMachAnyTagged, desc_before->GetType(4));
// Function.
- EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(6)));
+ EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(7)));
// Context.
- EXPECT_EQ(s.ToVreg(context), s.ToVreg(call_instr->InputAt(7)));
+ EXPECT_EQ(s.ToVreg(context), s.ToVreg(call_instr->InputAt(8)));
EXPECT_EQ(kArchRet, s[index++]->arch_opcode());
@@ -501,10 +515,11 @@ TARGET_TEST_F(InstructionSelectorTest,
m.NewNode(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.common()->FrameState(JS_FRAME, bailout_id_parent,
- OutputFrameStateCombine::Ignore()),
- parameters, locals, stack, context, m.UndefinedConstant());
+ Node* frame_state_parent = m.NewNode(
+ m.common()->FrameState(bailout_id_parent,
+ OutputFrameStateCombine::Ignore(),
+ m.GetFrameStateFunctionInfo(1, 1)),
+ parameters, locals, stack, context, function_node, m.UndefinedConstant());
Node* context2 = m.Int32Constant(46);
Node* parameters2 =
@@ -513,10 +528,11 @@ TARGET_TEST_F(InstructionSelectorTest,
m.Float64Constant(0.25));
Node* stack2 = m.NewNode(m.common()->TypedStateValues(&int32x2_type),
m.Int32Constant(44), m.Int32Constant(45));
- Node* frame_state_before =
- m.NewNode(m.common()->FrameState(JS_FRAME, bailout_id_before,
- OutputFrameStateCombine::Push()),
- parameters2, locals2, stack2, context2, frame_state_parent);
+ Node* frame_state_before = m.NewNode(
+ m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(),
+ m.GetFrameStateFunctionInfo(1, 1)),
+ parameters2, locals2, stack2, context2, function_node,
+ frame_state_parent);
// Build the call.
Node* call = m.CallFunctionStub0(function_node, receiver, context2,
@@ -540,8 +556,8 @@ TARGET_TEST_F(InstructionSelectorTest,
size_t num_operands =
1 + // Code object.
1 + // Frame state deopt id
- 5 + // One input for each value in frame state + context.
- 4 + // One input for each value in the parent frame state + context.
+ 6 + // One input for each value in frame state + context.
+ 5 + // One input for each value in the parent frame state + context.
1 + // Function.
1; // Context.
EXPECT_EQ(num_operands, call_instr->InputCount());
@@ -558,34 +574,36 @@ TARGET_TEST_F(InstructionSelectorTest,
EXPECT_EQ(1u, desc_before_outer->locals_count());
EXPECT_EQ(1u, desc_before_outer->stack_count());
// Values from parent environment.
- EXPECT_EQ(63, s.ToInt32(call_instr->InputAt(2)));
- EXPECT_EQ(kMachInt32, desc_before_outer->GetType(0));
+ EXPECT_EQ(kMachAnyTagged, desc_before->GetType(0));
+ EXPECT_EQ(63, s.ToInt32(call_instr->InputAt(3)));
+ EXPECT_EQ(kMachInt32, desc_before_outer->GetType(1));
// Context:
- EXPECT_EQ(66, s.ToInt32(call_instr->InputAt(3)));
- EXPECT_EQ(kMachAnyTagged, desc_before_outer->GetType(1));
- EXPECT_EQ(64, s.ToInt32(call_instr->InputAt(4)));
- EXPECT_EQ(kMachInt32, desc_before_outer->GetType(2));
- EXPECT_EQ(65, s.ToInt32(call_instr->InputAt(5)));
+ EXPECT_EQ(66, s.ToInt32(call_instr->InputAt(4)));
+ EXPECT_EQ(kMachAnyTagged, desc_before_outer->GetType(2));
+ EXPECT_EQ(64, s.ToInt32(call_instr->InputAt(5)));
EXPECT_EQ(kMachInt32, desc_before_outer->GetType(3));
+ EXPECT_EQ(65, s.ToInt32(call_instr->InputAt(6)));
+ EXPECT_EQ(kMachInt32, desc_before_outer->GetType(4));
// Values from the nested frame.
EXPECT_EQ(1u, desc_before->parameters_count());
EXPECT_EQ(1u, desc_before->locals_count());
EXPECT_EQ(2u, desc_before->stack_count());
- EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(6)));
- EXPECT_EQ(kMachInt32, desc_before->GetType(0));
- EXPECT_EQ(46, s.ToInt32(call_instr->InputAt(7)));
- EXPECT_EQ(kMachAnyTagged, desc_before->GetType(1));
- EXPECT_EQ(0.25, s.ToFloat64(call_instr->InputAt(8)));
- EXPECT_EQ(kMachFloat64, desc_before->GetType(2));
- EXPECT_EQ(44, s.ToInt32(call_instr->InputAt(9)));
- EXPECT_EQ(kMachInt32, desc_before->GetType(3));
- EXPECT_EQ(45, s.ToInt32(call_instr->InputAt(10)));
+ EXPECT_EQ(kMachAnyTagged, desc_before->GetType(0));
+ EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(8)));
+ EXPECT_EQ(kMachInt32, desc_before->GetType(1));
+ EXPECT_EQ(46, s.ToInt32(call_instr->InputAt(9)));
+ EXPECT_EQ(kMachAnyTagged, desc_before->GetType(2));
+ EXPECT_EQ(0.25, s.ToFloat64(call_instr->InputAt(10)));
+ EXPECT_EQ(kMachFloat64, desc_before->GetType(3));
+ EXPECT_EQ(44, s.ToInt32(call_instr->InputAt(11)));
EXPECT_EQ(kMachInt32, desc_before->GetType(4));
+ EXPECT_EQ(45, s.ToInt32(call_instr->InputAt(12)));
+ EXPECT_EQ(kMachInt32, desc_before->GetType(5));
// Function.
- EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(11)));
+ EXPECT_EQ(s.ToVreg(function_node), s.ToVreg(call_instr->InputAt(13)));
// Context.
- EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(12)));
+ EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(14)));
// Continuation.
EXPECT_EQ(kArchRet, s[index++]->arch_opcode());