| 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/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 Loading... |
| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 342 } |
| 343 i += prefix_offset + Bytecodes::Size(final_bytecode, operand_scale); | 343 i += prefix_offset + Bytecodes::Size(final_bytecode, operand_scale); |
| 344 } | 344 } |
| 345 | 345 |
| 346 // Insert entry for illegal bytecode as this is never willingly emitted. | 346 // Insert entry for illegal bytecode as this is never willingly emitted. |
| 347 scorecard[Bytecodes::ToByte(Bytecode::kIllegal)] = 1; | 347 scorecard[Bytecodes::ToByte(Bytecode::kIllegal)] = 1; |
| 348 | 348 |
| 349 // Insert entry for nop bytecode as this often gets optimized out. | 349 // Insert entry for nop bytecode as this often gets optimized out. |
| 350 scorecard[Bytecodes::ToByte(Bytecode::kNop)] = 1; | 350 scorecard[Bytecodes::ToByte(Bytecode::kNop)] = 1; |
| 351 | 351 |
| 352 // Insert entries for bytecodes only emiited by peephole optimizer. |
| 353 scorecard[Bytecodes::ToByte(Bytecode::kLdrNamedProperty)] = 1; |
| 354 scorecard[Bytecodes::ToByte(Bytecode::kLdrKeyedProperty)] = 1; |
| 355 scorecard[Bytecodes::ToByte(Bytecode::kLdrGlobal)] = 1; |
| 356 scorecard[Bytecodes::ToByte(Bytecode::kLdrContextSlot)] = 1; |
| 357 scorecard[Bytecodes::ToByte(Bytecode::kLdrUndefined)] = 1; |
| 358 |
| 352 // Check return occurs at the end and only once in the BytecodeArray. | 359 // Check return occurs at the end and only once in the BytecodeArray. |
| 353 CHECK_EQ(final_bytecode, Bytecode::kReturn); | 360 CHECK_EQ(final_bytecode, Bytecode::kReturn); |
| 354 CHECK_EQ(scorecard[Bytecodes::ToByte(final_bytecode)], 1); | 361 CHECK_EQ(scorecard[Bytecodes::ToByte(final_bytecode)], 1); |
| 355 | 362 |
| 356 #define CHECK_BYTECODE_PRESENT(Name, ...) \ | 363 #define CHECK_BYTECODE_PRESENT(Name, ...) \ |
| 357 /* Check Bytecode is marked in scorecard, unless it's a debug break */ \ | 364 /* Check Bytecode is marked in scorecard, unless it's a debug break */ \ |
| 358 if (!Bytecodes::IsDebugBreak(Bytecode::k##Name)) { \ | 365 if (!Bytecodes::IsDebugBreak(Bytecode::k##Name)) { \ |
| 359 CHECK_GE(scorecard[Bytecodes::ToByte(Bytecode::k##Name)], 1); \ | 366 CHECK_GE(scorecard[Bytecodes::ToByte(Bytecode::k##Name)], 1); \ |
| 360 } | 367 } |
| 361 BYTECODE_LIST(CHECK_BYTECODE_PRESENT) | 368 BYTECODE_LIST(CHECK_BYTECODE_PRESENT) |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 iterator.Advance(); | 727 iterator.Advance(); |
| 721 } | 728 } |
| 722 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 729 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
| 723 iterator.Advance(); | 730 iterator.Advance(); |
| 724 CHECK(iterator.done()); | 731 CHECK(iterator.done()); |
| 725 } | 732 } |
| 726 | 733 |
| 727 } // namespace interpreter | 734 } // namespace interpreter |
| 728 } // namespace internal | 735 } // namespace internal |
| 729 } // namespace v8 | 736 } // namespace v8 |
| OLD | NEW |