OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/linkage.h" | 5 #include "src/compiler/linkage.h" |
6 #include "src/compiler/tail-call-optimization.h" | 6 #include "src/compiler/tail-call-optimization.h" |
7 #include "test/unittests/compiler/graph-unittest.h" | 7 #include "test/unittests/compiler/graph-unittest.h" |
8 #include "test/unittests/compiler/node-test-utils.h" | 8 #include "test/unittests/compiler/node-test-utils.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( | 52 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( |
53 CallDescriptor::kCallCodeObject, MachineType::AnyTagged(), | 53 CallDescriptor::kCallCodeObject, MachineType::AnyTagged(), |
54 LinkageLocation::ForRegister(0, MachineType::Pointer()), | 54 LinkageLocation::ForRegister(0, MachineType::Pointer()), |
55 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, | 55 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, |
56 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls); | 56 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls); |
57 Node* p0 = Parameter(0); | 57 Node* p0 = Parameter(0); |
58 Node* p1 = Parameter(1); | 58 Node* p1 = Parameter(1); |
59 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, | 59 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, |
60 graph()->start(), graph()->start()); | 60 graph()->start(), graph()->start()); |
61 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); | 61 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); |
62 Node* if_exception = graph()->NewNode( | 62 Node* if_exception = graph()->NewNode(common()->IfException(), call, call); |
63 common()->IfException(IfExceptionHint::kLocallyUncaught), call, call); | |
64 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); | 63 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); |
65 Node* end = graph()->NewNode(common()->End(1), if_exception); | 64 Node* end = graph()->NewNode(common()->End(1), if_exception); |
66 graph()->SetEnd(end); | 65 graph()->SetEnd(end); |
67 Reduction r = Reduce(ret); | 66 Reduction r = Reduce(ret); |
68 ASSERT_FALSE(r.Changed()); | 67 ASSERT_FALSE(r.Changed()); |
69 } | 68 } |
70 | 69 |
71 | 70 |
72 TEST_F(TailCallOptimizationTest, CallCodeObject2) { | 71 TEST_F(TailCallOptimizationTest, CallCodeObject2) { |
73 LinkageLocation kLocationSignature[] = { | 72 LinkageLocation kLocationSignature[] = { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( | 117 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( |
119 CallDescriptor::kCallJSFunction, MachineType::AnyTagged(), | 118 CallDescriptor::kCallJSFunction, MachineType::AnyTagged(), |
120 LinkageLocation::ForRegister(0), | 119 LinkageLocation::ForRegister(0), |
121 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, | 120 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, |
122 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls); | 121 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls); |
123 Node* p0 = Parameter(0); | 122 Node* p0 = Parameter(0); |
124 Node* p1 = Parameter(1); | 123 Node* p1 = Parameter(1); |
125 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, | 124 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, |
126 graph()->start(), graph()->start()); | 125 graph()->start(), graph()->start()); |
127 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); | 126 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); |
128 Node* if_exception = graph()->NewNode( | 127 Node* if_exception = graph()->NewNode(common()->IfException(), call, call); |
129 common()->IfException(IfExceptionHint::kLocallyUncaught), call, call); | |
130 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); | 128 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); |
131 Node* end = graph()->NewNode(common()->End(1), if_exception); | 129 Node* end = graph()->NewNode(common()->End(1), if_exception); |
132 graph()->SetEnd(end); | 130 graph()->SetEnd(end); |
133 Reduction r = Reduce(ret); | 131 Reduction r = Reduce(ret); |
134 ASSERT_FALSE(r.Changed()); | 132 ASSERT_FALSE(r.Changed()); |
135 } | 133 } |
136 | 134 |
137 | 135 |
138 TEST_F(TailCallOptimizationTest, CallJSFunction2) { | 136 TEST_F(TailCallOptimizationTest, CallJSFunction2) { |
139 LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0), | 137 LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0), |
(...skipping 12 matching lines...) Expand all Loading... |
152 Reduction r = Reduce(ret); | 150 Reduction r = Reduce(ret); |
153 ASSERT_TRUE(r.Changed()); | 151 ASSERT_TRUE(r.Changed()); |
154 EXPECT_THAT(r.replacement(), IsTailCall(kCallDescriptor, p0, p1, | 152 EXPECT_THAT(r.replacement(), IsTailCall(kCallDescriptor, p0, p1, |
155 graph()->start(), graph()->start())); | 153 graph()->start(), graph()->start())); |
156 } | 154 } |
157 | 155 |
158 | 156 |
159 } // namespace compiler | 157 } // namespace compiler |
160 } // namespace internal | 158 } // namespace internal |
161 } // namespace v8 | 159 } // namespace v8 |
OLD | NEW |