OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 .LoadAccumulatorWithRegister(reg_0) | 49 .LoadAccumulatorWithRegister(reg_0) |
50 .BinaryOperation(Token::Value::ADD, reg_0) | 50 .BinaryOperation(Token::Value::ADD, reg_0) |
51 .StoreAccumulatorInRegister(reg_1) | 51 .StoreAccumulatorInRegister(reg_1) |
52 .LoadNamedProperty(reg_1, name, feedback_slot) | 52 .LoadNamedProperty(reg_1, name, feedback_slot) |
53 .BinaryOperation(Token::Value::ADD, reg_0) | 53 .BinaryOperation(Token::Value::ADD, reg_0) |
54 .StoreAccumulatorInRegister(param) | 54 .StoreAccumulatorInRegister(param) |
55 .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, 1, reg_0) | 55 .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, 1, reg_0) |
56 .ForInPrepare(reg_0) | 56 .ForInPrepare(reg_0) |
57 .CallRuntime(Runtime::kLoadIC_Miss, reg_0, 1) | 57 .CallRuntime(Runtime::kLoadIC_Miss, reg_0, 1) |
58 .Debugger() | 58 .Debugger() |
59 .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) | 59 .LoadGlobal(0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) |
60 .Return(); | 60 .Return(); |
61 | 61 |
62 // Test iterator sees the expected output from the builder. | 62 // Test iterator sees the expected output from the builder. |
63 BytecodeArrayIterator iterator(builder.ToBytecodeArray()); | 63 BytecodeArrayIterator iterator(builder.ToBytecodeArray()); |
64 const int kPrefixByteSize = 1; | 64 const int kPrefixByteSize = 1; |
65 int offset = 0; | 65 int offset = 0; |
66 | 66 |
67 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); | 67 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); |
68 CHECK_EQ(iterator.current_offset(), offset); | 68 CHECK_EQ(iterator.current_offset(), offset); |
69 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); | 69 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 CHECK_EQ(iterator.current_bytecode(), Bytecode::kDebugger); | 239 CHECK_EQ(iterator.current_bytecode(), Bytecode::kDebugger); |
240 CHECK_EQ(iterator.current_offset(), offset); | 240 CHECK_EQ(iterator.current_offset(), offset); |
241 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); | 241 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); |
242 CHECK(!iterator.done()); | 242 CHECK(!iterator.done()); |
243 offset += Bytecodes::Size(Bytecode::kDebugger, OperandScale::kSingle); | 243 offset += Bytecodes::Size(Bytecode::kDebugger, OperandScale::kSingle); |
244 iterator.Advance(); | 244 iterator.Advance(); |
245 | 245 |
246 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaGlobal); | 246 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaGlobal); |
247 CHECK_EQ(iterator.current_offset(), offset); | 247 CHECK_EQ(iterator.current_offset(), offset); |
248 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kQuadruple); | 248 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kQuadruple); |
249 CHECK_EQ(iterator.current_bytecode_size(), 10); | 249 CHECK_EQ(iterator.current_bytecode_size(), 6); |
250 CHECK_EQ(iterator.GetIndexOperand(1), 0x10000000); | 250 CHECK_EQ(iterator.GetIndexOperand(0), 0x10000000); |
251 offset += Bytecodes::Size(Bytecode::kLdaGlobal, OperandScale::kQuadruple) + | 251 offset += Bytecodes::Size(Bytecode::kLdaGlobal, OperandScale::kQuadruple) + |
252 kPrefixByteSize; | 252 kPrefixByteSize; |
253 iterator.Advance(); | 253 iterator.Advance(); |
254 | 254 |
255 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 255 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
256 CHECK_EQ(iterator.current_offset(), offset); | 256 CHECK_EQ(iterator.current_offset(), offset); |
257 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); | 257 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); |
258 CHECK(!iterator.done()); | 258 CHECK(!iterator.done()); |
259 iterator.Advance(); | 259 iterator.Advance(); |
260 CHECK(iterator.done()); | 260 CHECK(iterator.done()); |
261 } | 261 } |
262 | 262 |
263 } // namespace interpreter | 263 } // namespace interpreter |
264 } // namespace internal | 264 } // namespace internal |
265 } // namespace v8 | 265 } // namespace v8 |
OLD | NEW |