| 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 "test/unittests/test-utils.h" | 9 #include "test/unittests/test-utils.h" |
| 10 | 10 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 .CompareOperation(Token::Value::INSTANCEOF, reg, Strength::WEAK) | 102 .CompareOperation(Token::Value::INSTANCEOF, reg, Strength::WEAK) |
| 103 .CompareOperation(Token::Value::IN, reg, Strength::WEAK); | 103 .CompareOperation(Token::Value::IN, reg, Strength::WEAK); |
| 104 | 104 |
| 105 // Emit cast operator invocations. | 105 // Emit cast operator invocations. |
| 106 builder.LoadNull().CastAccumulatorToBoolean(); | 106 builder.LoadNull().CastAccumulatorToBoolean(); |
| 107 | 107 |
| 108 // Emit control flow. Return must be the last instruction. | 108 // Emit control flow. Return must be the last instruction. |
| 109 BytecodeLabel start; | 109 BytecodeLabel start; |
| 110 builder.Bind(&start); | 110 builder.Bind(&start); |
| 111 // Short jumps with Imm8 operands | 111 // Short jumps with Imm8 operands |
| 112 builder.Jump(&start).JumpIfTrue(&start).JumpIfFalse(&start); | 112 builder.Jump(&start) |
| 113 .JumpIfTrue(&start) |
| 114 .JumpIfFalse(&start) |
| 115 .JumpIfToBooleanTrue(&start) |
| 116 .JumpIfToBooleanFalse(&start); |
| 113 // Insert dummy ops to force longer jumps | 117 // Insert dummy ops to force longer jumps |
| 114 for (int i = 0; i < 128; i++) { | 118 for (int i = 0; i < 128; i++) { |
| 115 builder.LoadTrue(); | 119 builder.LoadTrue(); |
| 116 } | 120 } |
| 117 // Longer jumps requiring Constant operand | 121 // Longer jumps requiring Constant operand |
| 118 builder.Jump(&start).JumpIfTrue(&start).JumpIfFalse(&start); | 122 builder.Jump(&start) |
| 123 .JumpIfTrue(&start) |
| 124 .JumpIfFalse(&start) |
| 125 .JumpIfToBooleanTrue(&start) |
| 126 .JumpIfToBooleanFalse(&start); |
| 119 builder.Return(); | 127 builder.Return(); |
| 120 | 128 |
| 121 // Generate BytecodeArray. | 129 // Generate BytecodeArray. |
| 122 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); | 130 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); |
| 123 CHECK_EQ(the_array->frame_size(), builder.locals_count() * kPointerSize); | 131 CHECK_EQ(the_array->frame_size(), builder.locals_count() * kPointerSize); |
| 124 | 132 |
| 125 // Build scorecard of bytecodes encountered in the BytecodeArray. | 133 // Build scorecard of bytecodes encountered in the BytecodeArray. |
| 126 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); | 134 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); |
| 127 Bytecode final_bytecode = Bytecode::kLdaZero; | 135 Bytecode final_bytecode = Bytecode::kLdaZero; |
| 128 int i = 0; | 136 int i = 0; |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 473 |
| 466 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 474 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
| 467 iterator.Advance(); | 475 iterator.Advance(); |
| 468 CHECK(iterator.done()); | 476 CHECK(iterator.done()); |
| 469 } | 477 } |
| 470 | 478 |
| 471 | 479 |
| 472 } // namespace interpreter | 480 } // namespace interpreter |
| 473 } // namespace internal | 481 } // namespace internal |
| 474 } // namespace v8 | 482 } // namespace v8 |
| OLD | NEW |