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