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

Side by Side Diff: test/unittests/interpreter/bytecode-array-builder-unittest.cc

Issue 1985753002: [interpreter] Introduce fused bytecodes for common sequences. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months 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
OLDNEW
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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/interpreter/bytecode-array-builder.h" 7 #include "src/interpreter/bytecode-array-builder.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "src/interpreter/bytecode-register-allocator.h" 9 #include "src/interpreter/bytecode-register-allocator.h"
10 #include "test/unittests/test-utils.h" 10 #include "test/unittests/test-utils.h"
(...skipping 29 matching lines...) Expand all
40 // Emit constant loads. 40 // Emit constant loads.
41 builder.LoadLiteral(Smi::FromInt(0)) 41 builder.LoadLiteral(Smi::FromInt(0))
42 .StoreAccumulatorInRegister(reg) 42 .StoreAccumulatorInRegister(reg)
43 .LoadLiteral(Smi::FromInt(8)) 43 .LoadLiteral(Smi::FromInt(8))
44 .StoreAccumulatorInRegister(reg) 44 .StoreAccumulatorInRegister(reg)
45 .LoadLiteral(Smi::FromInt(10000000)) 45 .LoadLiteral(Smi::FromInt(10000000))
46 .StoreAccumulatorInRegister(reg) 46 .StoreAccumulatorInRegister(reg)
47 .LoadLiteral(factory->NewStringFromStaticChars("A constant")) 47 .LoadLiteral(factory->NewStringFromStaticChars("A constant"))
48 .StoreAccumulatorInRegister(reg) 48 .StoreAccumulatorInRegister(reg)
49 .LoadUndefined() 49 .LoadUndefined()
50 .StoreAccumulatorInRegister(reg) 50 .Debugger() // Prevent peephole optimization LdaNull, Star -> LdrNull.
51 .LoadNull() 51 .LoadNull()
52 .StoreAccumulatorInRegister(reg) 52 .StoreAccumulatorInRegister(reg)
53 .LoadTheHole() 53 .LoadTheHole()
54 .StoreAccumulatorInRegister(reg) 54 .StoreAccumulatorInRegister(reg)
55 .LoadTrue() 55 .LoadTrue()
56 .StoreAccumulatorInRegister(reg) 56 .StoreAccumulatorInRegister(reg)
57 .LoadFalse() 57 .LoadFalse()
58 .StoreAccumulatorInRegister(wide); 58 .StoreAccumulatorInRegister(wide);
59 59
60 builder.StackCheck(0) 60 builder.StackCheck(0)
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 339 }
340 i += prefix_offset + Bytecodes::Size(final_bytecode, operand_scale); 340 i += prefix_offset + Bytecodes::Size(final_bytecode, operand_scale);
341 } 341 }
342 342
343 // Insert entry for illegal bytecode as this is never willingly emitted. 343 // Insert entry for illegal bytecode as this is never willingly emitted.
344 scorecard[Bytecodes::ToByte(Bytecode::kIllegal)] = 1; 344 scorecard[Bytecodes::ToByte(Bytecode::kIllegal)] = 1;
345 345
346 // Insert entry for nop bytecode as this often gets optimized out. 346 // Insert entry for nop bytecode as this often gets optimized out.
347 scorecard[Bytecodes::ToByte(Bytecode::kNop)] = 1; 347 scorecard[Bytecodes::ToByte(Bytecode::kNop)] = 1;
348 348
349 // Insert entries for bytecodes only emiited by peephole optimizer.
350 scorecard[Bytecodes::ToByte(Bytecode::kLdrNamedProperty)] = 1;
351 scorecard[Bytecodes::ToByte(Bytecode::kLdrKeyedProperty)] = 1;
352 scorecard[Bytecodes::ToByte(Bytecode::kLdrGlobal)] = 1;
353 scorecard[Bytecodes::ToByte(Bytecode::kLdrContextSlot)] = 1;
354 scorecard[Bytecodes::ToByte(Bytecode::kLdrUndefined)] = 1;
355
349 // Check return occurs at the end and only once in the BytecodeArray. 356 // Check return occurs at the end and only once in the BytecodeArray.
350 CHECK_EQ(final_bytecode, Bytecode::kReturn); 357 CHECK_EQ(final_bytecode, Bytecode::kReturn);
351 CHECK_EQ(scorecard[Bytecodes::ToByte(final_bytecode)], 1); 358 CHECK_EQ(scorecard[Bytecodes::ToByte(final_bytecode)], 1);
352 359
353 #define CHECK_BYTECODE_PRESENT(Name, ...) \ 360 #define CHECK_BYTECODE_PRESENT(Name, ...) \
354 /* Check Bytecode is marked in scorecard, unless it's a debug break */ \ 361 /* Check Bytecode is marked in scorecard, unless it's a debug break */ \
355 if (!Bytecodes::IsDebugBreak(Bytecode::k##Name)) { \ 362 if (!Bytecodes::IsDebugBreak(Bytecode::k##Name)) { \
356 CHECK_GE(scorecard[Bytecodes::ToByte(Bytecode::k##Name)], 1); \ 363 CHECK_GE(scorecard[Bytecodes::ToByte(Bytecode::k##Name)], 1); \
357 } 364 }
358 BYTECODE_LIST(CHECK_BYTECODE_PRESENT) 365 BYTECODE_LIST(CHECK_BYTECODE_PRESENT)
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 iterator.Advance(); 724 iterator.Advance();
718 } 725 }
719 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); 726 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn);
720 iterator.Advance(); 727 iterator.Advance();
721 CHECK(iterator.done()); 728 CHECK(iterator.done());
722 } 729 }
723 730
724 } // namespace interpreter 731 } // namespace interpreter
725 } // namespace internal 732 } // namespace internal
726 } // namespace v8 733 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698