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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 CallDescriptor::kCallCodeObject, kMachAnyTagged, LinkageLocation(0), | 53 CallDescriptor::kCallCodeObject, kMachAnyTagged, LinkageLocation(0), |
54 new (zone()) MachineSignature(1, 1, kMachineSignature), | 54 new (zone()) MachineSignature(1, 1, kMachineSignature), |
55 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, | 55 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, |
56 Operator::kNoProperties, 0, CallDescriptor::kSupportsTailCalls); | 56 Operator::kNoProperties, 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( |
63 common()->IfException(IfExceptionHint::kLocallyUncaught), call); | 63 common()->IfException(IfExceptionHint::kLocallyUncaught), call, call); |
64 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); | 64 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); |
65 Node* end = graph()->NewNode(common()->End(1), if_exception); | 65 Node* end = graph()->NewNode(common()->End(1), if_exception); |
66 graph()->SetEnd(end); | 66 graph()->SetEnd(end); |
67 Reduction r = Reduce(ret); | 67 Reduction r = Reduce(ret); |
68 ASSERT_FALSE(r.Changed()); | 68 ASSERT_FALSE(r.Changed()); |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 TEST_F(TailCallOptimizationTest, CallCodeObject2) { | 72 TEST_F(TailCallOptimizationTest, CallCodeObject2) { |
73 MachineType kMachineSignature[] = {kMachAnyTagged, kMachAnyTagged}; | 73 MachineType kMachineSignature[] = {kMachAnyTagged, kMachAnyTagged}; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 CallDescriptor::kCallJSFunction, kMachAnyTagged, LinkageLocation(0), | 119 CallDescriptor::kCallJSFunction, kMachAnyTagged, LinkageLocation(0), |
120 new (zone()) MachineSignature(1, 1, kMachineSignature), | 120 new (zone()) MachineSignature(1, 1, kMachineSignature), |
121 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, | 121 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, |
122 Operator::kNoProperties, 0, CallDescriptor::kSupportsTailCalls); | 122 Operator::kNoProperties, 0, CallDescriptor::kSupportsTailCalls); |
123 Node* p0 = Parameter(0); | 123 Node* p0 = Parameter(0); |
124 Node* p1 = Parameter(1); | 124 Node* p1 = Parameter(1); |
125 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, | 125 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, |
126 graph()->start(), graph()->start()); | 126 graph()->start(), graph()->start()); |
127 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); | 127 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); |
128 Node* if_exception = graph()->NewNode( | 128 Node* if_exception = graph()->NewNode( |
129 common()->IfException(IfExceptionHint::kLocallyUncaught), call); | 129 common()->IfException(IfExceptionHint::kLocallyUncaught), call, call); |
130 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); | 130 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); |
131 Node* end = graph()->NewNode(common()->End(1), if_exception); | 131 Node* end = graph()->NewNode(common()->End(1), if_exception); |
132 graph()->SetEnd(end); | 132 graph()->SetEnd(end); |
133 Reduction r = Reduce(ret); | 133 Reduction r = Reduce(ret); |
134 ASSERT_FALSE(r.Changed()); | 134 ASSERT_FALSE(r.Changed()); |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 TEST_F(TailCallOptimizationTest, CallJSFunction2) { | 138 TEST_F(TailCallOptimizationTest, CallJSFunction2) { |
139 MachineType kMachineSignature[] = {kMachAnyTagged, kMachAnyTagged}; | 139 MachineType kMachineSignature[] = {kMachAnyTagged, kMachAnyTagged}; |
(...skipping 13 matching lines...) Expand all Loading... |
153 Reduction r = Reduce(ret); | 153 Reduction r = Reduce(ret); |
154 ASSERT_TRUE(r.Changed()); | 154 ASSERT_TRUE(r.Changed()); |
155 EXPECT_THAT(r.replacement(), IsTailCall(kCallDescriptor, p0, p1, | 155 EXPECT_THAT(r.replacement(), IsTailCall(kCallDescriptor, p0, p1, |
156 graph()->start(), graph()->start())); | 156 graph()->start(), graph()->start())); |
157 } | 157 } |
158 | 158 |
159 | 159 |
160 } // namespace compiler | 160 } // namespace compiler |
161 } // namespace internal | 161 } // namespace internal |
162 } // namespace v8 | 162 } // namespace v8 |
OLD | NEW |