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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 int second; | 111 int second; |
112 { | 112 { |
113 TemporaryRegisterScope temporaries(&builder); | 113 TemporaryRegisterScope temporaries(&builder); |
114 second = temporaries.NewRegister().index(); | 114 second = temporaries.NewRegister().index(); |
115 } | 115 } |
116 | 116 |
117 CHECK_EQ(first, second); | 117 CHECK_EQ(first, second); |
118 } | 118 } |
119 | 119 |
| 120 |
| 121 TEST_F(BytecodeArrayBuilderTest, RegisterValues) { |
| 122 int index = 1; |
| 123 uint8_t operand = static_cast<uint8_t>(-index); |
| 124 |
| 125 Register the_register(index); |
| 126 CHECK_EQ(the_register.index(), index); |
| 127 |
| 128 int actual_operand = the_register.ToOperand(); |
| 129 CHECK_EQ(actual_operand, operand); |
| 130 |
| 131 int actual_index = Register::FromOperand(actual_operand).index(); |
| 132 CHECK_EQ(actual_index, index); |
| 133 } |
| 134 |
120 } // namespace interpreter | 135 } // namespace interpreter |
121 } // namespace internal | 136 } // namespace internal |
122 } // namespace v8 | 137 } // namespace v8 |
OLD | NEW |