| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
| 6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
| 7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
| 8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
| 9 #include "test/unittests/test-utils.h" | 9 #include "test/unittests/test-utils.h" |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 LinkageLocation RegisterLocation(int loc) { return LinkageLocation(loc); } | 44 LinkageLocation RegisterLocation(int loc) { return LinkageLocation(loc); } |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 | 47 |
| 48 TEST_F(LinkageTailCall, EmptyToEmpty) { | 48 TEST_F(LinkageTailCall, EmptyToEmpty) { |
| 49 LocationSignature locations(0, 0, nullptr); | 49 LocationSignature locations(0, 0, nullptr); |
| 50 CallDescriptor* desc = NewStandardCallDescriptor(&locations); | 50 CallDescriptor* desc = NewStandardCallDescriptor(&locations); |
| 51 CommonOperatorBuilder common(zone()); | 51 CommonOperatorBuilder common(zone()); |
| 52 const Operator* op = common.Call(desc); | 52 const Operator* op = common.Call(desc); |
| 53 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); | 53 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); |
| 54 EXPECT_TRUE(desc->CanTailCall(node)); | 54 size_t in = 0; |
| 55 size_t out = 0; |
| 56 size_t preserved = 0; |
| 57 size_t registers = 0; |
| 58 EXPECT_TRUE(desc->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 55 } | 59 } |
| 56 | 60 |
| 57 | 61 |
| 58 TEST_F(LinkageTailCall, SameReturn) { | 62 TEST_F(LinkageTailCall, SameReturn) { |
| 59 // Caller | 63 // Caller |
| 60 LinkageLocation location_array[] = {RegisterLocation(0)}; | 64 LinkageLocation location_array[] = {RegisterLocation(0)}; |
| 61 LocationSignature locations1(1, 0, location_array); | 65 LocationSignature locations1(1, 0, location_array); |
| 62 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 66 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 63 | 67 |
| 64 // Callee | 68 // Callee |
| 65 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); | 69 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); |
| 66 | 70 |
| 67 CommonOperatorBuilder common(zone()); | 71 CommonOperatorBuilder common(zone()); |
| 68 const Operator* op = common.Call(desc2); | 72 const Operator* op = common.Call(desc2); |
| 69 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); | 73 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); |
| 70 EXPECT_TRUE(desc1->CanTailCall(node)); | 74 size_t in = 0; |
| 75 size_t out = 0; |
| 76 size_t preserved = 0; |
| 77 size_t registers = 0; |
| 78 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 71 } | 79 } |
| 72 | 80 |
| 73 | 81 |
| 74 TEST_F(LinkageTailCall, DifferingReturn) { | 82 TEST_F(LinkageTailCall, DifferingReturn) { |
| 75 // Caller | 83 // Caller |
| 76 LinkageLocation location_array1[] = {RegisterLocation(0)}; | 84 LinkageLocation location_array1[] = {RegisterLocation(0)}; |
| 77 LocationSignature locations1(1, 0, location_array1); | 85 LocationSignature locations1(1, 0, location_array1); |
| 78 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 86 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 79 | 87 |
| 80 // Callee | 88 // Callee |
| 81 LinkageLocation location_array2[] = {RegisterLocation(1)}; | 89 LinkageLocation location_array2[] = {RegisterLocation(1)}; |
| 82 LocationSignature locations2(1, 0, location_array2); | 90 LocationSignature locations2(1, 0, location_array2); |
| 83 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); | 91 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); |
| 84 | 92 |
| 85 CommonOperatorBuilder common(zone()); | 93 CommonOperatorBuilder common(zone()); |
| 86 const Operator* op = common.Call(desc2); | 94 const Operator* op = common.Call(desc2); |
| 87 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); | 95 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); |
| 88 EXPECT_FALSE(desc1->CanTailCall(node)); | 96 size_t in = 0; |
| 97 size_t out = 0; |
| 98 size_t preserved = 0; |
| 99 size_t registers = 0; |
| 100 EXPECT_FALSE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 89 } | 101 } |
| 90 | 102 |
| 91 | 103 |
| 92 TEST_F(LinkageTailCall, MoreRegisterParametersCallee) { | 104 TEST_F(LinkageTailCall, MoreRegisterParametersCallee) { |
| 93 // Caller | 105 // Caller |
| 94 LinkageLocation location_array1[] = {RegisterLocation(0)}; | 106 LinkageLocation location_array1[] = {RegisterLocation(0)}; |
| 95 LocationSignature locations1(1, 0, location_array1); | 107 LocationSignature locations1(1, 0, location_array1); |
| 96 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 108 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 97 | 109 |
| 98 // Callee | 110 // Callee |
| 99 LinkageLocation location_array2[] = {RegisterLocation(0), | 111 LinkageLocation location_array2[] = {RegisterLocation(0), |
| 100 RegisterLocation(0)}; | 112 RegisterLocation(0)}; |
| 101 LocationSignature locations2(1, 1, location_array2); | 113 LocationSignature locations2(1, 1, location_array2); |
| 102 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); | 114 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); |
| 103 | 115 |
| 104 CommonOperatorBuilder common(zone()); | 116 CommonOperatorBuilder common(zone()); |
| 105 const Operator* op = common.Call(desc2); | 117 const Operator* op = common.Call(desc2); |
| 106 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); | 118 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); |
| 107 EXPECT_TRUE(desc1->CanTailCall(node)); | 119 size_t in = 0; |
| 120 size_t out = 0; |
| 121 size_t preserved = 0; |
| 122 size_t registers = 0; |
| 123 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 108 } | 124 } |
| 109 | 125 |
| 110 | 126 |
| 111 TEST_F(LinkageTailCall, MoreRegisterParametersCaller) { | 127 TEST_F(LinkageTailCall, MoreRegisterParametersCaller) { |
| 112 // Caller | 128 // Caller |
| 113 LinkageLocation location_array1[] = {RegisterLocation(0), | 129 LinkageLocation location_array1[] = {RegisterLocation(0), |
| 114 RegisterLocation(0)}; | 130 RegisterLocation(0)}; |
| 115 LocationSignature locations1(1, 1, location_array1); | 131 LocationSignature locations1(1, 1, location_array1); |
| 116 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 132 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 117 | 133 |
| 118 // Callee | 134 // Callee |
| 119 LinkageLocation location_array2[] = {RegisterLocation(0)}; | 135 LinkageLocation location_array2[] = {RegisterLocation(0)}; |
| 120 LocationSignature locations2(1, 0, location_array2); | 136 LocationSignature locations2(1, 0, location_array2); |
| 121 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); | 137 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); |
| 122 | 138 |
| 123 CommonOperatorBuilder common(zone()); | 139 CommonOperatorBuilder common(zone()); |
| 124 const Operator* op = common.Call(desc2); | 140 const Operator* op = common.Call(desc2); |
| 125 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); | 141 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); |
| 126 EXPECT_TRUE(desc1->CanTailCall(node)); | 142 size_t in = 0; |
| 143 size_t out = 0; |
| 144 size_t preserved = 0; |
| 145 size_t registers = 0; |
| 146 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 127 } | 147 } |
| 128 | 148 |
| 129 | 149 |
| 130 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCallee) { | 150 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCallee) { |
| 131 // Caller | 151 // Caller |
| 132 LinkageLocation location_array1[] = {RegisterLocation(0)}; | 152 LinkageLocation location_array1[] = {RegisterLocation(0)}; |
| 133 LocationSignature locations1(1, 0, location_array1); | 153 LocationSignature locations1(1, 0, location_array1); |
| 134 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 154 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 135 | 155 |
| 136 // Callee | 156 // Callee |
| 137 LinkageLocation location_array2[] = {RegisterLocation(0), RegisterLocation(0), | 157 LinkageLocation location_array2[] = {RegisterLocation(0), RegisterLocation(0), |
| 138 RegisterLocation(1), StackLocation(1)}; | 158 RegisterLocation(1), StackLocation(1)}; |
| 139 LocationSignature locations2(1, 3, location_array2); | 159 LocationSignature locations2(1, 3, location_array2); |
| 140 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); | 160 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); |
| 141 | 161 |
| 142 CommonOperatorBuilder common(zone()); | 162 CommonOperatorBuilder common(zone()); |
| 143 const Operator* op = common.Call(desc2); | 163 const Operator* op = common.Call(desc2); |
| 144 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); | 164 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); |
| 145 EXPECT_FALSE(desc1->CanTailCall(node)); | 165 size_t in = 0; |
| 166 size_t out = 0; |
| 167 size_t preserved = 0; |
| 168 size_t registers = 0; |
| 169 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 146 } | 170 } |
| 147 | 171 |
| 148 | 172 |
| 149 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCaller) { | 173 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCaller) { |
| 150 // Caller | 174 // Caller |
| 151 LinkageLocation location_array[] = {RegisterLocation(0), RegisterLocation(0), | 175 LinkageLocation location_array[] = {RegisterLocation(0), RegisterLocation(0), |
| 152 RegisterLocation(1), StackLocation(1)}; | 176 RegisterLocation(1), StackLocation(1)}; |
| 153 LocationSignature locations1(1, 3, location_array); | 177 LocationSignature locations1(1, 3, location_array); |
| 154 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 178 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 155 | 179 |
| 156 // Callee | 180 // Callee |
| 157 LinkageLocation location_array2[] = {RegisterLocation(0)}; | 181 LinkageLocation location_array2[] = {RegisterLocation(0)}; |
| 158 LocationSignature locations2(1, 0, location_array2); | 182 LocationSignature locations2(1, 0, location_array2); |
| 159 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); | 183 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); |
| 160 | 184 |
| 161 CommonOperatorBuilder common(zone()); | 185 CommonOperatorBuilder common(zone()); |
| 162 const Operator* op = common.Call(desc2); | 186 const Operator* op = common.Call(desc2); |
| 163 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); | 187 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); |
| 164 EXPECT_FALSE(desc1->CanTailCall(node)); | 188 size_t in = 0; |
| 189 size_t out = 0; |
| 190 size_t preserved = 0; |
| 191 size_t registers = 0; |
| 192 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 165 } | 193 } |
| 166 | 194 |
| 167 | 195 |
| 168 TEST_F(LinkageTailCall, MatchingStackParameters) { | 196 TEST_F(LinkageTailCall, MatchingStackParameters) { |
| 169 // Caller | 197 // Caller |
| 170 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), | 198 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), |
| 171 StackLocation(2), StackLocation(1)}; | 199 StackLocation(2), StackLocation(1)}; |
| 172 LocationSignature locations1(1, 3, location_array); | 200 LocationSignature locations1(1, 3, location_array); |
| 173 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 201 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 174 | 202 |
| 175 // Caller | 203 // Caller |
| 176 LocationSignature locations2(1, 3, location_array); | 204 LocationSignature locations2(1, 3, location_array); |
| 177 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); | 205 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); |
| 178 | 206 |
| 179 CommonOperatorBuilder common(zone()); | 207 CommonOperatorBuilder common(zone()); |
| 180 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); | 208 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); |
| 181 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); | 209 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); |
| 182 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); | 210 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); |
| 183 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); | 211 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); |
| 184 Node* parameters[] = {p0, p1, p2, p3}; | 212 Node* parameters[] = {p0, p1, p2, p3}; |
| 185 const Operator* op = common.Call(desc2); | 213 const Operator* op = common.Call(desc2); |
| 186 Node* const node = | 214 Node* const node = |
| 187 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); | 215 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); |
| 188 EXPECT_TRUE(desc1->CanTailCall(node)); | 216 size_t in = 0; |
| 217 size_t out = 0; |
| 218 size_t preserved = 0; |
| 219 size_t registers = 0; |
| 220 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 189 } | 221 } |
| 190 | 222 |
| 191 | 223 |
| 192 TEST_F(LinkageTailCall, NonMatchingStackParameters) { | 224 TEST_F(LinkageTailCall, NonMatchingStackParameters) { |
| 193 // Caller | 225 // Caller |
| 194 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), | 226 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), |
| 195 StackLocation(2), StackLocation(1)}; | 227 StackLocation(2), StackLocation(1)}; |
| 196 LocationSignature locations1(1, 3, location_array); | 228 LocationSignature locations1(1, 3, location_array); |
| 197 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 229 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 198 | 230 |
| 199 // Caller | 231 // Caller |
| 200 LocationSignature locations2(1, 3, location_array); | 232 LocationSignature locations2(1, 3, location_array); |
| 201 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); | 233 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); |
| 202 | 234 |
| 203 CommonOperatorBuilder common(zone()); | 235 CommonOperatorBuilder common(zone()); |
| 204 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); | 236 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); |
| 205 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); | 237 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); |
| 206 Node* p2 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); | 238 Node* p2 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); |
| 207 Node* p3 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); | 239 Node* p3 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); |
| 208 Node* parameters[] = {p0, p1, p2, p3}; | 240 Node* parameters[] = {p0, p1, p2, p3}; |
| 209 const Operator* op = common.Call(desc2); | 241 const Operator* op = common.Call(desc2); |
| 210 Node* const node = | 242 Node* const node = |
| 211 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); | 243 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); |
| 212 EXPECT_FALSE(desc1->CanTailCall(node)); | 244 size_t in = 0; |
| 245 size_t out = 0; |
| 246 size_t preserved = 0; |
| 247 size_t registers = 0; |
| 248 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 213 } | 249 } |
| 214 | 250 |
| 215 | 251 |
| 216 TEST_F(LinkageTailCall, MatchingStackParametersExtraCallerRegisters) { | 252 TEST_F(LinkageTailCall, MatchingStackParametersExtraCallerRegisters) { |
| 217 // Caller | 253 // Caller |
| 218 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), | 254 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), |
| 219 StackLocation(2), StackLocation(1), | 255 StackLocation(2), StackLocation(1), |
| 220 RegisterLocation(0), RegisterLocation(1)}; | 256 RegisterLocation(0), RegisterLocation(1)}; |
| 221 LocationSignature locations1(1, 5, location_array); | 257 LocationSignature locations1(1, 5, location_array); |
| 222 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 258 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 223 | 259 |
| 224 // Caller | 260 // Caller |
| 225 LocationSignature locations2(1, 3, location_array); | 261 LocationSignature locations2(1, 3, location_array); |
| 226 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); | 262 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); |
| 227 | 263 |
| 228 CommonOperatorBuilder common(zone()); | 264 CommonOperatorBuilder common(zone()); |
| 229 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); | 265 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); |
| 230 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); | 266 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); |
| 231 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); | 267 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); |
| 232 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); | 268 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); |
| 233 Node* parameters[] = {p0, p1, p2, p3}; | 269 Node* parameters[] = {p0, p1, p2, p3}; |
| 234 const Operator* op = common.Call(desc2); | 270 const Operator* op = common.Call(desc2); |
| 235 Node* const node = | 271 Node* const node = |
| 236 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); | 272 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); |
| 237 EXPECT_TRUE(desc1->CanTailCall(node)); | 273 size_t in = 0; |
| 274 size_t out = 0; |
| 275 size_t preserved = 0; |
| 276 size_t registers = 0; |
| 277 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 238 } | 278 } |
| 239 | 279 |
| 240 | 280 |
| 241 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegisters) { | 281 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegisters) { |
| 242 // Caller | 282 // Caller |
| 243 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), | 283 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), |
| 244 StackLocation(2), StackLocation(1), | 284 StackLocation(2), StackLocation(1), |
| 245 RegisterLocation(0), RegisterLocation(1)}; | 285 RegisterLocation(0), RegisterLocation(1)}; |
| 246 LocationSignature locations1(1, 3, location_array); | 286 LocationSignature locations1(1, 3, location_array); |
| 247 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 287 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 248 | 288 |
| 249 // Caller | 289 // Caller |
| 250 LocationSignature locations2(1, 5, location_array); | 290 LocationSignature locations2(1, 5, location_array); |
| 251 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); | 291 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); |
| 252 | 292 |
| 253 CommonOperatorBuilder common(zone()); | 293 CommonOperatorBuilder common(zone()); |
| 254 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); | 294 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); |
| 255 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); | 295 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); |
| 256 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); | 296 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); |
| 257 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); | 297 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); |
| 258 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); | 298 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); |
| 259 Node* parameters[] = {p0, p1, p2, p3, p4}; | 299 Node* parameters[] = {p0, p1, p2, p3, p4}; |
| 260 const Operator* op = common.Call(desc2); | 300 const Operator* op = common.Call(desc2); |
| 261 Node* const node = | 301 Node* const node = |
| 262 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); | 302 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); |
| 263 EXPECT_TRUE(desc1->CanTailCall(node)); | 303 size_t in = 0; |
| 304 size_t out = 0; |
| 305 size_t preserved = 0; |
| 306 size_t registers = 0; |
| 307 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 264 } | 308 } |
| 265 | 309 |
| 266 | 310 |
| 267 TEST_F(LinkageTailCall, MatchingStackParametersExtraCallerRegistersAndStack) { | 311 TEST_F(LinkageTailCall, MatchingStackParametersExtraCallerRegistersAndStack) { |
| 268 // Caller | 312 // Caller |
| 269 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), | 313 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(4), |
| 270 StackLocation(2), StackLocation(1), | 314 StackLocation(3), StackLocation(2), |
| 271 RegisterLocation(0), StackLocation(4)}; | 315 RegisterLocation(0), StackLocation(1)}; |
| 272 LocationSignature locations1(1, 5, location_array); | 316 LocationSignature locations1(1, 5, location_array); |
| 273 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 317 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 274 | 318 |
| 275 // Caller | 319 // Caller |
| 276 LocationSignature locations2(1, 3, location_array); | 320 LocationSignature locations2(1, 3, location_array); |
| 277 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); | 321 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); |
| 278 | 322 |
| 279 CommonOperatorBuilder common(zone()); | 323 CommonOperatorBuilder common(zone()); |
| 280 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); | 324 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); |
| 281 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); | 325 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); |
| 282 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); | 326 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); |
| 283 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); | 327 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); |
| 284 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); | 328 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); |
| 285 Node* parameters[] = {p0, p1, p2, p3, p4}; | 329 Node* parameters[] = {p0, p1, p2, p3, p4}; |
| 286 const Operator* op = common.Call(desc2); | 330 const Operator* op = common.Call(desc2); |
| 287 Node* const node = | 331 Node* const node = |
| 288 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); | 332 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); |
| 289 EXPECT_FALSE(desc1->CanTailCall(node)); | 333 size_t in = 0; |
| 334 size_t out = 0; |
| 335 size_t preserved = 0; |
| 336 size_t registers = 0; |
| 337 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 290 } | 338 } |
| 291 | 339 |
| 292 | 340 |
| 293 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegistersAndStack) { | 341 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegistersAndStack) { |
| 294 // Caller | 342 // Caller |
| 295 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), | 343 LinkageLocation location_array1[] = {RegisterLocation(0), StackLocation(2), |
| 296 StackLocation(2), RegisterLocation(0), | 344 StackLocation(1), RegisterLocation(0), |
| 297 RegisterLocation(1), StackLocation(4)}; | 345 RegisterLocation(1)}; |
| 298 LocationSignature locations1(1, 3, location_array); | 346 LocationSignature locations1(1, 3, location_array1); |
| 299 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); | 347 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); |
| 300 | 348 |
| 301 // Caller | 349 // Caller |
| 302 LocationSignature locations2(1, 5, location_array); | 350 LinkageLocation location_array2[] = {RegisterLocation(0), StackLocation(3), |
| 351 StackLocation(2), RegisterLocation(0), |
| 352 RegisterLocation(1), StackLocation(1)}; |
| 353 LocationSignature locations2(1, 5, location_array2); |
| 303 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); | 354 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); |
| 304 | 355 |
| 305 CommonOperatorBuilder common(zone()); | 356 CommonOperatorBuilder common(zone()); |
| 306 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); | 357 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); |
| 307 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); | 358 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); |
| 308 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); | 359 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); |
| 309 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); | 360 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); |
| 310 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); | 361 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); |
| 311 Node* parameters[] = {p0, p1, p2, p3, p4}; | 362 Node* parameters[] = {p0, p1, p2, p3, p4}; |
| 312 const Operator* op = common.Call(desc2); | 363 const Operator* op = common.Call(desc2); |
| 313 Node* const node = | 364 Node* const node = |
| 314 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); | 365 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); |
| 315 EXPECT_FALSE(desc1->CanTailCall(node)); | 366 size_t in = 0; |
| 367 size_t out = 0; |
| 368 size_t preserved = 0; |
| 369 size_t registers = 0; |
| 370 EXPECT_TRUE(desc1->CanTailCall(node, &in, &preserved, &out, ®isters)); |
| 316 } | 371 } |
| 317 | 372 |
| 318 } // namespace compiler | 373 } // namespace compiler |
| 319 } // namespace internal | 374 } // namespace internal |
| 320 } // namespace v8 | 375 } // namespace v8 |
| OLD | NEW |