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