OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/factory.h" | 7 #include "src/factory.h" |
8 #include "src/interpreter/bytecode-label.h" | 8 #include "src/interpreter/bytecode-label.h" |
9 #include "src/interpreter/bytecode-peephole-optimizer.h" | 9 #include "src/interpreter/bytecode-peephole-optimizer.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
11 #include "src/objects.h" | 11 #include "src/objects.h" |
12 #include "test/unittests/test-utils.h" | 12 #include "test/unittests/test-utils.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 namespace interpreter { | 16 namespace interpreter { |
17 | 17 |
18 class BytecodePeepholeOptimizerTest : public BytecodePipelineStage, | 18 class BytecodePeepholeOptimizerTest : public BytecodePipelineStage, |
19 public TestWithIsolateAndZone { | 19 public TestWithIsolateAndZone { |
20 public: | 20 public: |
21 BytecodePeepholeOptimizerTest() : peephole_optimizer_(this) {} | 21 BytecodePeepholeOptimizerTest() |
| 22 : peephole_optimizer_(this), last_written_(Bytecode::kIllegal) {} |
22 ~BytecodePeepholeOptimizerTest() override {} | 23 ~BytecodePeepholeOptimizerTest() override {} |
23 | 24 |
24 void Reset() { | 25 void Reset() { |
25 last_written_.set_bytecode(Bytecode::kIllegal); | 26 last_written_.set_bytecode(Bytecode::kIllegal); |
26 write_count_ = 0; | 27 write_count_ = 0; |
27 } | 28 } |
28 | 29 |
29 void Write(BytecodeNode* node) override { | 30 void Write(BytecodeNode* node) override { |
30 write_count_++; | 31 write_count_++; |
31 last_written_.Clone(node); | 32 last_written_.Clone(node); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Sanity tests. | 65 // Sanity tests. |
65 | 66 |
66 TEST_F(BytecodePeepholeOptimizerTest, FlushOnJump) { | 67 TEST_F(BytecodePeepholeOptimizerTest, FlushOnJump) { |
67 CHECK_EQ(write_count(), 0); | 68 CHECK_EQ(write_count(), 0); |
68 | 69 |
69 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1); | 70 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1); |
70 optimizer()->Write(&add); | 71 optimizer()->Write(&add); |
71 CHECK_EQ(write_count(), 0); | 72 CHECK_EQ(write_count(), 0); |
72 | 73 |
73 BytecodeLabel target; | 74 BytecodeLabel target; |
74 BytecodeNode jump(Bytecode::kJump, 0); | 75 BytecodeNode jump(Bytecode::kJump, 0, nullptr); |
75 optimizer()->WriteJump(&jump, &target); | 76 optimizer()->WriteJump(&jump, &target); |
76 CHECK_EQ(write_count(), 2); | 77 CHECK_EQ(write_count(), 2); |
77 CHECK_EQ(jump, last_written()); | 78 CHECK_EQ(jump, last_written()); |
78 } | 79 } |
79 | 80 |
80 TEST_F(BytecodePeepholeOptimizerTest, FlushOnBind) { | 81 TEST_F(BytecodePeepholeOptimizerTest, FlushOnBind) { |
81 CHECK_EQ(write_count(), 0); | 82 CHECK_EQ(write_count(), 0); |
82 | 83 |
83 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1); | 84 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1); |
84 optimizer()->Write(&add); | 85 optimizer()->Write(&add); |
(...skipping 11 matching lines...) Expand all Loading... |
96 BytecodeNode nop(Bytecode::kNop); | 97 BytecodeNode nop(Bytecode::kNop); |
97 optimizer()->Write(&nop); | 98 optimizer()->Write(&nop); |
98 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1); | 99 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1); |
99 optimizer()->Write(&add); | 100 optimizer()->Write(&add); |
100 Flush(); | 101 Flush(); |
101 CHECK_EQ(write_count(), 1); | 102 CHECK_EQ(write_count(), 1); |
102 CHECK_EQ(add, last_written()); | 103 CHECK_EQ(add, last_written()); |
103 } | 104 } |
104 | 105 |
105 TEST_F(BytecodePeepholeOptimizerTest, ElideExpressionNop) { | 106 TEST_F(BytecodePeepholeOptimizerTest, ElideExpressionNop) { |
106 BytecodeNode nop(Bytecode::kNop); | 107 BytecodeSourceInfo source_info(3, false); |
107 nop.source_info().MakeExpressionPosition(3); | 108 BytecodeNode nop(Bytecode::kNop, &source_info); |
108 optimizer()->Write(&nop); | 109 optimizer()->Write(&nop); |
109 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1); | 110 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1); |
110 optimizer()->Write(&add); | 111 optimizer()->Write(&add); |
111 Flush(); | 112 Flush(); |
112 CHECK_EQ(write_count(), 1); | 113 CHECK_EQ(write_count(), 1); |
113 CHECK_EQ(add, last_written()); | 114 CHECK_EQ(add, last_written()); |
114 } | 115 } |
115 | 116 |
116 TEST_F(BytecodePeepholeOptimizerTest, KeepStatementNop) { | 117 TEST_F(BytecodePeepholeOptimizerTest, KeepStatementNop) { |
117 BytecodeNode nop(Bytecode::kNop); | 118 BytecodeSourceInfo source_info(3, true); |
118 nop.source_info().MakeStatementPosition(3); | 119 BytecodeNode nop(Bytecode::kNop, &source_info); |
119 optimizer()->Write(&nop); | 120 optimizer()->Write(&nop); |
120 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1); | 121 source_info.MakeExpressionPosition(3); |
121 add.source_info().MakeExpressionPosition(3); | 122 BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1, &source_info); |
122 optimizer()->Write(&add); | 123 optimizer()->Write(&add); |
123 Flush(); | 124 Flush(); |
124 CHECK_EQ(write_count(), 2); | 125 CHECK_EQ(write_count(), 2); |
125 CHECK_EQ(add, last_written()); | 126 CHECK_EQ(add, last_written()); |
126 } | 127 } |
127 | 128 |
128 // Tests covering BytecodePeepholeOptimizer::UpdateCurrentBytecode(). | 129 // Tests covering BytecodePeepholeOptimizer::UpdateCurrentBytecode(). |
129 | 130 |
130 TEST_F(BytecodePeepholeOptimizerTest, KeepJumpIfToBooleanTrue) { | 131 TEST_F(BytecodePeepholeOptimizerTest, KeepJumpIfToBooleanTrue) { |
131 BytecodeNode first(Bytecode::kLdaNull); | 132 BytecodeNode first(Bytecode::kLdaNull); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 optimizer()->Write(&first); | 198 optimizer()->Write(&first); |
198 optimizer()->Write(&second); | 199 optimizer()->Write(&second); |
199 CHECK_EQ(write_count(), 0); | 200 CHECK_EQ(write_count(), 0); |
200 Flush(); | 201 Flush(); |
201 CHECK_EQ(write_count(), 1); | 202 CHECK_EQ(write_count(), 1); |
202 CHECK_EQ(last_written(), first); | 203 CHECK_EQ(last_written(), first); |
203 } | 204 } |
204 | 205 |
205 TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRxStatement) { | 206 TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRxStatement) { |
206 BytecodeNode first(Bytecode::kStar, Register(0).ToOperand()); | 207 BytecodeNode first(Bytecode::kStar, Register(0).ToOperand()); |
207 BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand()); | 208 BytecodeSourceInfo source_info(3, true); |
208 second.source_info().MakeStatementPosition(0); | 209 BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand(), &source_info); |
209 optimizer()->Write(&first); | 210 optimizer()->Write(&first); |
210 CHECK_EQ(write_count(), 0); | 211 CHECK_EQ(write_count(), 0); |
211 optimizer()->Write(&second); | 212 optimizer()->Write(&second); |
212 CHECK_EQ(write_count(), 1); | 213 CHECK_EQ(write_count(), 1); |
213 CHECK_EQ(last_written(), first); | 214 CHECK_EQ(last_written(), first); |
214 Flush(); | 215 Flush(); |
215 CHECK_EQ(write_count(), 2); | 216 CHECK_EQ(write_count(), 2); |
216 CHECK_EQ(last_written().bytecode(), Bytecode::kNop); | 217 CHECK_EQ(last_written().bytecode(), Bytecode::kNop); |
217 CHECK_EQ(last_written().source_info(), second.source_info()); | 218 CHECK_EQ(last_written().source_info(), second.source_info()); |
218 } | 219 } |
219 | 220 |
220 TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRxStatementStarRy) { | 221 TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRxStatementStarRy) { |
221 BytecodeLabel label; | 222 BytecodeLabel label; |
222 BytecodeNode first(Bytecode::kStar, Register(0).ToOperand()); | 223 BytecodeNode first(Bytecode::kStar, Register(0).ToOperand()); |
223 BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand()); | 224 BytecodeSourceInfo source_info(0, true); |
| 225 BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand(), &source_info); |
224 BytecodeNode third(Bytecode::kStar, Register(3).ToOperand()); | 226 BytecodeNode third(Bytecode::kStar, Register(3).ToOperand()); |
225 second.source_info().MakeStatementPosition(0); | |
226 optimizer()->Write(&first); | 227 optimizer()->Write(&first); |
227 CHECK_EQ(write_count(), 0); | 228 CHECK_EQ(write_count(), 0); |
228 optimizer()->Write(&second); | 229 optimizer()->Write(&second); |
229 CHECK_EQ(write_count(), 1); | 230 CHECK_EQ(write_count(), 1); |
230 CHECK_EQ(last_written(), first); | 231 CHECK_EQ(last_written(), first); |
231 optimizer()->Write(&third); | 232 optimizer()->Write(&third); |
232 CHECK_EQ(write_count(), 1); | 233 CHECK_EQ(write_count(), 1); |
233 Flush(); | 234 Flush(); |
234 CHECK_EQ(write_count(), 2); | 235 CHECK_EQ(write_count(), 2); |
235 CHECK_EQ(last_written(), third); | 236 CHECK_EQ(last_written(), third); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 optimizer()->Write(&first); | 271 optimizer()->Write(&first); |
271 CHECK_EQ(write_count(), 0); | 272 CHECK_EQ(write_count(), 0); |
272 optimizer()->Write(&second); | 273 optimizer()->Write(&second); |
273 CHECK_EQ(write_count(), 0); | 274 CHECK_EQ(write_count(), 0); |
274 Flush(); | 275 Flush(); |
275 CHECK_EQ(write_count(), 1); | 276 CHECK_EQ(write_count(), 1); |
276 CHECK_EQ(last_written(), second); | 277 CHECK_EQ(last_written(), second); |
277 } | 278 } |
278 | 279 |
279 TEST_F(BytecodePeepholeOptimizerTest, LdaTrueStatementLdaFalse) { | 280 TEST_F(BytecodePeepholeOptimizerTest, LdaTrueStatementLdaFalse) { |
280 BytecodeNode first(Bytecode::kLdaTrue); | 281 BytecodeSourceInfo source_info(3, true); |
281 first.source_info().MakeExpressionPosition(3); | 282 BytecodeNode first(Bytecode::kLdaTrue, &source_info); |
282 BytecodeNode second(Bytecode::kLdaFalse); | 283 BytecodeNode second(Bytecode::kLdaFalse); |
283 optimizer()->Write(&first); | 284 optimizer()->Write(&first); |
284 CHECK_EQ(write_count(), 0); | 285 CHECK_EQ(write_count(), 0); |
285 optimizer()->Write(&second); | 286 optimizer()->Write(&second); |
286 CHECK_EQ(write_count(), 0); | 287 CHECK_EQ(write_count(), 0); |
287 Flush(); | 288 Flush(); |
288 CHECK_EQ(write_count(), 1); | 289 CHECK_EQ(write_count(), 1); |
289 CHECK_EQ(last_written(), second); | 290 CHECK_EQ(last_written(), second); |
290 CHECK(second.source_info().is_expression()); | 291 CHECK(second.source_info().is_statement()); |
291 CHECK_EQ(second.source_info().source_position(), 3); | 292 CHECK_EQ(second.source_info().source_position(), 3); |
292 } | 293 } |
293 | 294 |
294 TEST_F(BytecodePeepholeOptimizerTest, NopStackCheck) { | 295 TEST_F(BytecodePeepholeOptimizerTest, NopStackCheck) { |
295 BytecodeNode first(Bytecode::kNop); | 296 BytecodeNode first(Bytecode::kNop); |
296 BytecodeNode second(Bytecode::kStackCheck); | 297 BytecodeNode second(Bytecode::kStackCheck, nullptr); |
297 optimizer()->Write(&first); | 298 optimizer()->Write(&first); |
298 CHECK_EQ(write_count(), 0); | 299 CHECK_EQ(write_count(), 0); |
299 optimizer()->Write(&second); | 300 optimizer()->Write(&second); |
300 CHECK_EQ(write_count(), 0); | 301 CHECK_EQ(write_count(), 0); |
301 Flush(); | 302 Flush(); |
302 CHECK_EQ(write_count(), 1); | 303 CHECK_EQ(write_count(), 1); |
303 CHECK_EQ(last_written(), second); | 304 CHECK_EQ(last_written(), second); |
304 } | 305 } |
305 | 306 |
306 TEST_F(BytecodePeepholeOptimizerTest, NopStatementStackCheck) { | 307 TEST_F(BytecodePeepholeOptimizerTest, NopStatementStackCheck) { |
307 BytecodeNode first(Bytecode::kNop); | 308 BytecodeSourceInfo source_info(3, true); |
308 first.source_info().MakeExpressionPosition(3); | 309 BytecodeNode first(Bytecode::kNop, &source_info); |
309 BytecodeNode second(Bytecode::kStackCheck); | 310 BytecodeNode second(Bytecode::kStackCheck); |
310 optimizer()->Write(&first); | 311 optimizer()->Write(&first); |
311 CHECK_EQ(write_count(), 0); | 312 CHECK_EQ(write_count(), 0); |
312 optimizer()->Write(&second); | 313 optimizer()->Write(&second); |
313 CHECK_EQ(write_count(), 0); | 314 CHECK_EQ(write_count(), 0); |
314 Flush(); | 315 Flush(); |
315 CHECK_EQ(write_count(), 1); | 316 CHECK_EQ(write_count(), 1); |
316 second.source_info().MakeExpressionPosition( | 317 BytecodeSourceInfo expected_source_info(3, true); |
317 first.source_info().source_position()); | 318 BytecodeNode expected(Bytecode::kStackCheck, &expected_source_info); |
318 CHECK_EQ(last_written(), second); | 319 CHECK_EQ(last_written(), expected); |
319 } | 320 } |
320 | 321 |
321 // Tests covering BytecodePeepholeOptimizer::UpdateLastAndCurrentBytecodes(). | 322 // Tests covering BytecodePeepholeOptimizer::UpdateLastAndCurrentBytecodes(). |
322 | 323 |
323 TEST_F(BytecodePeepholeOptimizerTest, MergeLoadICStar) { | 324 TEST_F(BytecodePeepholeOptimizerTest, MergeLoadICStar) { |
324 const uint32_t operands[] = { | 325 const uint32_t operands[] = { |
325 static_cast<uint32_t>(Register(31).ToOperand()), 32, 33, | 326 static_cast<uint32_t>(Register(31).ToOperand()), 32, 33, |
326 static_cast<uint32_t>(Register(256).ToOperand())}; | 327 static_cast<uint32_t>(Register(256).ToOperand())}; |
327 const int expected_operand_count = static_cast<int>(arraysize(operands)); | 328 const int expected_operand_count = static_cast<int>(arraysize(operands)); |
328 | 329 |
(...skipping 16 matching lines...) Expand all Loading... |
345 Flush(); | 346 Flush(); |
346 CHECK_EQ(last_written().bytecode(), third.bytecode()); | 347 CHECK_EQ(last_written().bytecode(), third.bytecode()); |
347 } | 348 } |
348 | 349 |
349 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaKeyedPropertyStar) { | 350 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaKeyedPropertyStar) { |
350 const uint32_t operands[] = {static_cast<uint32_t>(Register(31).ToOperand()), | 351 const uint32_t operands[] = {static_cast<uint32_t>(Register(31).ToOperand()), |
351 9999997, | 352 9999997, |
352 static_cast<uint32_t>(Register(1).ToOperand())}; | 353 static_cast<uint32_t>(Register(1).ToOperand())}; |
353 const int expected_operand_count = static_cast<int>(arraysize(operands)); | 354 const int expected_operand_count = static_cast<int>(arraysize(operands)); |
354 | 355 |
355 BytecodeNode first(Bytecode::kLdaKeyedProperty, operands[0], operands[1]); | 356 BytecodeNode first(Bytecode::kLdaKeyedProperty, operands[0], operands[1], |
| 357 nullptr); |
356 BytecodeNode second(Bytecode::kStar, operands[2]); | 358 BytecodeNode second(Bytecode::kStar, operands[2]); |
357 BytecodeNode third(Bytecode::kReturn); | 359 BytecodeNode third(Bytecode::kReturn); |
358 optimizer()->Write(&first); | 360 optimizer()->Write(&first); |
359 optimizer()->Write(&second); | 361 optimizer()->Write(&second); |
360 CHECK_EQ(write_count(), 1); | 362 CHECK_EQ(write_count(), 1); |
361 CHECK_EQ(last_written().bytecode(), Bytecode::kLdrKeyedProperty); | 363 CHECK_EQ(last_written().bytecode(), Bytecode::kLdrKeyedProperty); |
362 CHECK_EQ(last_written().operand_count(), expected_operand_count); | 364 CHECK_EQ(last_written().operand_count(), expected_operand_count); |
363 for (int i = 0; i < expected_operand_count; ++i) { | 365 for (int i = 0; i < expected_operand_count; ++i) { |
364 CHECK_EQ(last_written().operand(i), operands[i]); | 366 CHECK_EQ(last_written().operand(i), operands[i]); |
365 } | 367 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 Bytecode operator_replacement_pairs[][2] = { | 452 Bytecode operator_replacement_pairs[][2] = { |
451 {Bytecode::kAdd, Bytecode::kAddSmi}, | 453 {Bytecode::kAdd, Bytecode::kAddSmi}, |
452 {Bytecode::kSub, Bytecode::kSubSmi}, | 454 {Bytecode::kSub, Bytecode::kSubSmi}, |
453 {Bytecode::kBitwiseAnd, Bytecode::kBitwiseAndSmi}, | 455 {Bytecode::kBitwiseAnd, Bytecode::kBitwiseAndSmi}, |
454 {Bytecode::kBitwiseOr, Bytecode::kBitwiseOrSmi}, | 456 {Bytecode::kBitwiseOr, Bytecode::kBitwiseOrSmi}, |
455 {Bytecode::kShiftLeft, Bytecode::kShiftLeftSmi}, | 457 {Bytecode::kShiftLeft, Bytecode::kShiftLeftSmi}, |
456 {Bytecode::kShiftRight, Bytecode::kShiftRightSmi}}; | 458 {Bytecode::kShiftRight, Bytecode::kShiftRightSmi}}; |
457 | 459 |
458 for (auto operator_replacement : operator_replacement_pairs) { | 460 for (auto operator_replacement : operator_replacement_pairs) { |
459 uint32_t imm_operand = 17; | 461 uint32_t imm_operand = 17; |
460 BytecodeNode first(Bytecode::kLdaSmi, imm_operand); | 462 BytecodeSourceInfo source_info(3, true); |
461 first.source_info().Clone({3, true}); | 463 BytecodeNode first(Bytecode::kLdaSmi, imm_operand, &source_info); |
462 uint32_t reg_operand = Register(0).ToOperand(); | 464 uint32_t reg_operand = Register(0).ToOperand(); |
463 uint32_t idx_operand = 1; | 465 uint32_t idx_operand = 1; |
464 BytecodeNode second(operator_replacement[0], reg_operand, idx_operand); | 466 BytecodeNode second(operator_replacement[0], reg_operand, idx_operand); |
465 optimizer()->Write(&first); | 467 optimizer()->Write(&first); |
466 optimizer()->Write(&second); | 468 optimizer()->Write(&second); |
467 Flush(); | 469 Flush(); |
468 CHECK_EQ(write_count(), 1); | 470 CHECK_EQ(write_count(), 1); |
469 CHECK_EQ(last_written().bytecode(), operator_replacement[1]); | 471 CHECK_EQ(last_written().bytecode(), operator_replacement[1]); |
470 CHECK_EQ(last_written().operand_count(), 3); | 472 CHECK_EQ(last_written().operand_count(), 3); |
471 CHECK_EQ(last_written().operand(0), imm_operand); | 473 CHECK_EQ(last_written().operand(0), imm_operand); |
472 CHECK_EQ(last_written().operand(1), reg_operand); | 474 CHECK_EQ(last_written().operand(1), reg_operand); |
473 CHECK_EQ(last_written().operand(2), idx_operand); | 475 CHECK_EQ(last_written().operand(2), idx_operand); |
474 CHECK_EQ(last_written().source_info(), first.source_info()); | 476 CHECK_EQ(last_written().source_info(), first.source_info()); |
475 Reset(); | 477 Reset(); |
476 } | 478 } |
477 } | 479 } |
478 | 480 |
479 TEST_F(BytecodePeepholeOptimizerTest, NotMergingLdaSmiWithBinaryOp) { | 481 TEST_F(BytecodePeepholeOptimizerTest, NotMergingLdaSmiWithBinaryOp) { |
480 Bytecode operator_replacement_pairs[][2] = { | 482 Bytecode operator_replacement_pairs[][2] = { |
481 {Bytecode::kAdd, Bytecode::kAddSmi}, | 483 {Bytecode::kAdd, Bytecode::kAddSmi}, |
482 {Bytecode::kSub, Bytecode::kSubSmi}, | 484 {Bytecode::kSub, Bytecode::kSubSmi}, |
483 {Bytecode::kBitwiseAnd, Bytecode::kBitwiseAndSmi}, | 485 {Bytecode::kBitwiseAnd, Bytecode::kBitwiseAndSmi}, |
484 {Bytecode::kBitwiseOr, Bytecode::kBitwiseOrSmi}, | 486 {Bytecode::kBitwiseOr, Bytecode::kBitwiseOrSmi}, |
485 {Bytecode::kShiftLeft, Bytecode::kShiftLeftSmi}, | 487 {Bytecode::kShiftLeft, Bytecode::kShiftLeftSmi}, |
486 {Bytecode::kShiftRight, Bytecode::kShiftRightSmi}}; | 488 {Bytecode::kShiftRight, Bytecode::kShiftRightSmi}}; |
487 | 489 |
488 for (auto operator_replacement : operator_replacement_pairs) { | 490 for (auto operator_replacement : operator_replacement_pairs) { |
489 uint32_t imm_operand = 17; | 491 uint32_t imm_operand = 17; |
490 BytecodeNode first(Bytecode::kLdaSmi, imm_operand); | 492 BytecodeSourceInfo source_info(3, true); |
491 first.source_info().Clone({3, true}); | 493 BytecodeNode first(Bytecode::kLdaSmi, imm_operand, &source_info); |
492 uint32_t reg_operand = Register(0).ToOperand(); | 494 uint32_t reg_operand = Register(0).ToOperand(); |
493 BytecodeNode second(operator_replacement[0], reg_operand, 1); | 495 source_info.MakeStatementPosition(4); |
494 second.source_info().Clone({4, true}); | 496 BytecodeNode second(operator_replacement[0], reg_operand, 1, &source_info); |
495 optimizer()->Write(&first); | 497 optimizer()->Write(&first); |
496 optimizer()->Write(&second); | 498 optimizer()->Write(&second); |
497 CHECK_EQ(last_written(), first); | 499 CHECK_EQ(last_written(), first); |
498 Flush(); | 500 Flush(); |
499 CHECK_EQ(last_written(), second); | 501 CHECK_EQ(last_written(), second); |
500 Reset(); | 502 Reset(); |
501 } | 503 } |
502 } | 504 } |
503 | 505 |
504 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaZeroWithBinaryOp) { | 506 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaZeroWithBinaryOp) { |
(...skipping 19 matching lines...) Expand all Loading... |
524 CHECK_EQ(last_written().operand(0), 0); | 526 CHECK_EQ(last_written().operand(0), 0); |
525 CHECK_EQ(last_written().operand(1), reg_operand); | 527 CHECK_EQ(last_written().operand(1), reg_operand); |
526 CHECK_EQ(last_written().operand(2), idx_operand); | 528 CHECK_EQ(last_written().operand(2), idx_operand); |
527 Reset(); | 529 Reset(); |
528 } | 530 } |
529 } | 531 } |
530 | 532 |
531 } // namespace interpreter | 533 } // namespace interpreter |
532 } // namespace internal | 534 } // namespace internal |
533 } // namespace v8 | 535 } // namespace v8 |
OLD | NEW |