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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 .LoadAccumulatorWithRegister(reg_0) | 53 .LoadAccumulatorWithRegister(reg_0) |
54 .BinaryOperation(Token::Value::ADD, reg_0, 2) | 54 .BinaryOperation(Token::Value::ADD, reg_0, 2) |
55 .StoreAccumulatorInRegister(reg_1) | 55 .StoreAccumulatorInRegister(reg_1) |
56 .LoadNamedProperty(reg_1, name, feedback_slot) | 56 .LoadNamedProperty(reg_1, name, feedback_slot) |
57 .BinaryOperation(Token::Value::ADD, reg_0, 3) | 57 .BinaryOperation(Token::Value::ADD, reg_0, 3) |
58 .StoreAccumulatorInRegister(param) | 58 .StoreAccumulatorInRegister(param) |
59 .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair) | 59 .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, param, pair) |
60 .ForInPrepare(reg_0, triple) | 60 .ForInPrepare(reg_0, triple) |
61 .CallRuntime(Runtime::kLoadIC_Miss, reg_0) | 61 .CallRuntime(Runtime::kLoadIC_Miss, reg_0) |
62 .Debugger() | 62 .Debugger() |
63 .LoadGlobal(0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) | 63 .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) |
64 .Return(); | 64 .Return(); |
65 | 65 |
66 // Test iterator sees the expected output from the builder. | 66 // Test iterator sees the expected output from the builder. |
67 BytecodeArrayIterator iterator(builder.ToBytecodeArray(isolate())); | 67 BytecodeArrayIterator iterator(builder.ToBytecodeArray(isolate())); |
68 const int kPrefixByteSize = 1; | 68 const int kPrefixByteSize = 1; |
69 int offset = 0; | 69 int offset = 0; |
70 | 70 |
71 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); | 71 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); |
72 CHECK_EQ(iterator.current_offset(), offset); | 72 CHECK_EQ(iterator.current_offset(), offset); |
73 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); | 73 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 CHECK_EQ(iterator.current_bytecode(), Bytecode::kDebugger); | 261 CHECK_EQ(iterator.current_bytecode(), Bytecode::kDebugger); |
262 CHECK_EQ(iterator.current_offset(), offset); | 262 CHECK_EQ(iterator.current_offset(), offset); |
263 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); | 263 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); |
264 CHECK(!iterator.done()); | 264 CHECK(!iterator.done()); |
265 offset += Bytecodes::Size(Bytecode::kDebugger, OperandScale::kSingle); | 265 offset += Bytecodes::Size(Bytecode::kDebugger, OperandScale::kSingle); |
266 iterator.Advance(); | 266 iterator.Advance(); |
267 | 267 |
268 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaGlobal); | 268 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaGlobal); |
269 CHECK_EQ(iterator.current_offset(), offset); | 269 CHECK_EQ(iterator.current_offset(), offset); |
270 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kQuadruple); | 270 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kQuadruple); |
271 CHECK_EQ(iterator.current_bytecode_size(), 6); | 271 CHECK_EQ(iterator.current_bytecode_size(), 10); |
272 CHECK_EQ(iterator.GetIndexOperand(0), 0x10000000u); | 272 CHECK_EQ(iterator.GetIndexOperand(1), 0x10000000u); |
273 offset += Bytecodes::Size(Bytecode::kLdaGlobal, OperandScale::kQuadruple) + | 273 offset += Bytecodes::Size(Bytecode::kLdaGlobal, OperandScale::kQuadruple) + |
274 kPrefixByteSize; | 274 kPrefixByteSize; |
275 iterator.Advance(); | 275 iterator.Advance(); |
276 | 276 |
277 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 277 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
278 CHECK_EQ(iterator.current_offset(), offset); | 278 CHECK_EQ(iterator.current_offset(), offset); |
279 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); | 279 CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); |
280 CHECK(!iterator.done()); | 280 CHECK(!iterator.done()); |
281 iterator.Advance(); | 281 iterator.Advance(); |
282 CHECK(iterator.done()); | 282 CHECK(iterator.done()); |
283 } | 283 } |
284 | 284 |
285 } // namespace interpreter | 285 } // namespace interpreter |
286 } // namespace internal | 286 } // namespace internal |
287 } // namespace v8 | 287 } // namespace v8 |
OLD | NEW |