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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 Factory* factory = isolate()->factory(); | 30 Factory* factory = isolate()->factory(); |
31 Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); | 31 Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); |
32 Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); | 32 Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); |
33 Smi* zero = Smi::FromInt(0); | 33 Smi* zero = Smi::FromInt(0); |
34 Smi* smi_0 = Smi::FromInt(64); | 34 Smi* smi_0 = Smi::FromInt(64); |
35 Smi* smi_1 = Smi::FromInt(-65536); | 35 Smi* smi_1 = Smi::FromInt(-65536); |
36 Register reg_0(0); | 36 Register reg_0(0); |
37 Register reg_1(1); | 37 Register reg_1(1); |
38 Register reg_2 = Register::FromParameterIndex(2, builder.parameter_count()); | 38 Register reg_2 = Register::FromParameterIndex(2, builder.parameter_count()); |
39 int name_index = 21; | 39 Handle<String> name = factory->NewStringFromStaticChars("abc"); |
| 40 int name_index = 3; |
40 int feedback_slot = 97; | 41 int feedback_slot = 97; |
41 | 42 |
42 builder.LoadLiteral(heap_num_0) | 43 builder.LoadLiteral(heap_num_0) |
43 .LoadLiteral(heap_num_1) | 44 .LoadLiteral(heap_num_1) |
44 .LoadLiteral(zero) | 45 .LoadLiteral(zero) |
45 .LoadLiteral(smi_0) | 46 .LoadLiteral(smi_0) |
46 .LoadLiteral(smi_1) | 47 .LoadLiteral(smi_1) |
47 .LoadAccumulatorWithRegister(reg_0) | 48 .LoadAccumulatorWithRegister(reg_0) |
48 .LoadNamedProperty(reg_1, name_index, feedback_slot, LanguageMode::SLOPPY) | 49 .LoadNamedProperty(reg_1, name, feedback_slot, LanguageMode::SLOPPY) |
49 .StoreAccumulatorInRegister(reg_2) | 50 .StoreAccumulatorInRegister(reg_2) |
50 .CallRuntime(Runtime::kLoadIC_Miss, reg_0, 1) | 51 .CallRuntime(Runtime::kLoadIC_Miss, reg_0, 1) |
51 .Return(); | 52 .Return(); |
52 | 53 |
53 // Test iterator sees the expected output from the builder. | 54 // Test iterator sees the expected output from the builder. |
54 BytecodeArrayIterator iterator(builder.ToBytecodeArray()); | 55 BytecodeArrayIterator iterator(builder.ToBytecodeArray()); |
55 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); | 56 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); |
56 CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_0)); | 57 CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_0)); |
57 CHECK(!iterator.done()); | 58 CHECK(!iterator.done()); |
58 iterator.Advance(); | 59 iterator.Advance(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 104 |
104 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 105 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
105 CHECK(!iterator.done()); | 106 CHECK(!iterator.done()); |
106 iterator.Advance(); | 107 iterator.Advance(); |
107 CHECK(iterator.done()); | 108 CHECK(iterator.done()); |
108 } | 109 } |
109 | 110 |
110 } // namespace interpreter | 111 } // namespace interpreter |
111 } // namespace internal | 112 } // namespace internal |
112 } // namespace v8 | 113 } // namespace v8 |
OLD | NEW |