Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Side by Side Diff: test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc

Issue 2485383002: [Interpreter] Remove Ldr[Named/Keyed]Property bytecodes and use Star Lookahead instead. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/unittests/interpreter/bytecode-array-builder-unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 optimizer()->Write(&second); 314 optimizer()->Write(&second);
315 CHECK_EQ(write_count(), 0); 315 CHECK_EQ(write_count(), 0);
316 Flush(); 316 Flush();
317 CHECK_EQ(write_count(), 1); 317 CHECK_EQ(write_count(), 1);
318 BytecodeNode expected(Bytecode::kStackCheck, source_info); 318 BytecodeNode expected(Bytecode::kStackCheck, 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) {
325 const uint32_t operands[] = {
326 static_cast<uint32_t>(Register(31).ToOperand()), 32, 33,
327 static_cast<uint32_t>(Register(256).ToOperand())};
328 const int expected_operand_count = static_cast<int>(arraysize(operands));
329
330 BytecodeNode first(Bytecode::kLdaNamedProperty, operands[0], operands[1],
331 operands[2]);
332 BytecodeNode second(Bytecode::kStar, operands[3]);
333 BytecodeNode third(Bytecode::kReturn);
334 optimizer()->Write(&first);
335 optimizer()->Write(&second);
336 CHECK_EQ(write_count(), 1);
337 CHECK_EQ(last_written().bytecode(), Bytecode::kLdrNamedProperty);
338 CHECK_EQ(last_written().operand_count(), expected_operand_count);
339 for (int i = 0; i < expected_operand_count; ++i) {
340 CHECK_EQ(last_written().operand(i), operands[i]);
341 }
342 optimizer()->Write(&third);
343 CHECK_EQ(write_count(), 2);
344 CHECK_EQ(last_written().bytecode(), Bytecode::kLdar);
345 CHECK_EQ(last_written().operand(0), operands[expected_operand_count - 1]);
346 Flush();
347 CHECK_EQ(last_written().bytecode(), third.bytecode());
348 }
349
350 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaKeyedPropertyStar) {
351 const uint32_t operands[] = {static_cast<uint32_t>(Register(31).ToOperand()),
352 9999997,
353 static_cast<uint32_t>(Register(1).ToOperand())};
354 const int expected_operand_count = static_cast<int>(arraysize(operands));
355
356 BytecodeNode first(Bytecode::kLdaKeyedProperty, operands[0], operands[1]);
357 BytecodeNode second(Bytecode::kStar, operands[2]);
358 BytecodeNode third(Bytecode::kReturn);
359 optimizer()->Write(&first);
360 optimizer()->Write(&second);
361 CHECK_EQ(write_count(), 1);
362 CHECK_EQ(last_written().bytecode(), Bytecode::kLdrKeyedProperty);
363 CHECK_EQ(last_written().operand_count(), expected_operand_count);
364 for (int i = 0; i < expected_operand_count; ++i) {
365 CHECK_EQ(last_written().operand(i), operands[i]);
366 }
367 optimizer()->Write(&third);
368 CHECK_EQ(write_count(), 2);
369 CHECK_EQ(last_written().bytecode(), Bytecode::kLdar);
370 CHECK_EQ(last_written().operand(0), operands[expected_operand_count - 1]);
371 Flush();
372 CHECK_EQ(last_written().bytecode(), third.bytecode());
373 }
374
375 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaGlobalStar) { 324 TEST_F(BytecodePeepholeOptimizerTest, MergeLdaGlobalStar) {
376 const uint32_t operands[] = {19191, 325 const uint32_t operands[] = {19191,
377 static_cast<uint32_t>(Register(1).ToOperand())}; 326 static_cast<uint32_t>(Register(1).ToOperand())};
378 const int expected_operand_count = static_cast<int>(arraysize(operands)); 327 const int expected_operand_count = static_cast<int>(arraysize(operands));
379 328
380 BytecodeNode first(Bytecode::kLdaGlobal, operands[0]); 329 BytecodeNode first(Bytecode::kLdaGlobal, operands[0]);
381 BytecodeNode second(Bytecode::kStar, operands[1]); 330 BytecodeNode second(Bytecode::kStar, operands[1]);
382 BytecodeNode third(Bytecode::kReturn); 331 BytecodeNode third(Bytecode::kReturn);
383 optimizer()->Write(&first); 332 optimizer()->Write(&first);
384 optimizer()->Write(&second); 333 optimizer()->Write(&second);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 CHECK_EQ(last_written().operand(0), 0); 474 CHECK_EQ(last_written().operand(0), 0);
526 CHECK_EQ(last_written().operand(1), reg_operand); 475 CHECK_EQ(last_written().operand(1), reg_operand);
527 CHECK_EQ(last_written().operand(2), idx_operand); 476 CHECK_EQ(last_written().operand(2), idx_operand);
528 Reset(); 477 Reset();
529 } 478 }
530 } 479 }
531 480
532 } // namespace interpreter 481 } // namespace interpreter
533 } // namespace internal 482 } // namespace internal
534 } // namespace v8 483 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/interpreter/bytecode-array-builder-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698