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 "test/unittests/test-utils.h" | 8 #include "test/unittests/test-utils.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 23 matching lines...) Expand all Loading... |
34 .LoadFalse(); | 34 .LoadFalse(); |
35 | 35 |
36 // Emit accumulator transfers. | 36 // Emit accumulator transfers. |
37 Register reg(0); | 37 Register reg(0); |
38 builder.LoadAccumulatorWithRegister(reg).StoreAccumulatorInRegister(reg); | 38 builder.LoadAccumulatorWithRegister(reg).StoreAccumulatorInRegister(reg); |
39 | 39 |
40 // Emit binary operators invocations. | 40 // Emit binary operators invocations. |
41 builder.BinaryOperation(Token::Value::ADD, reg) | 41 builder.BinaryOperation(Token::Value::ADD, reg) |
42 .BinaryOperation(Token::Value::SUB, reg) | 42 .BinaryOperation(Token::Value::SUB, reg) |
43 .BinaryOperation(Token::Value::MUL, reg) | 43 .BinaryOperation(Token::Value::MUL, reg) |
44 .BinaryOperation(Token::Value::DIV, reg); | 44 .BinaryOperation(Token::Value::DIV, reg) |
| 45 .BinaryOperation(Token::Value::MOD, reg); |
45 | 46 |
46 // Emit control flow. Return must be the last instruction. | 47 // Emit control flow. Return must be the last instruction. |
47 builder.Return(); | 48 builder.Return(); |
48 | 49 |
49 // Generate BytecodeArray. | 50 // Generate BytecodeArray. |
50 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); | 51 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); |
51 CHECK_EQ(the_array->frame_size(), builder.locals_count() * kPointerSize); | 52 CHECK_EQ(the_array->frame_size(), builder.locals_count() * kPointerSize); |
52 | 53 |
53 // Build scorecard of bytecodes encountered in the BytecodeArray. | 54 // Build scorecard of bytecodes encountered in the BytecodeArray. |
54 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); | 55 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 int actual_operand = the_register.ToOperand(); | 129 int actual_operand = the_register.ToOperand(); |
129 CHECK_EQ(actual_operand, operand); | 130 CHECK_EQ(actual_operand, operand); |
130 | 131 |
131 int actual_index = Register::FromOperand(actual_operand).index(); | 132 int actual_index = Register::FromOperand(actual_operand).index(); |
132 CHECK_EQ(actual_index, index); | 133 CHECK_EQ(actual_index, index); |
133 } | 134 } |
134 | 135 |
135 } // namespace interpreter | 136 } // namespace interpreter |
136 } // namespace internal | 137 } // namespace internal |
137 } // namespace v8 | 138 } // namespace v8 |
OLD | NEW |