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 "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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 | 172 |
173 TEST_F(BytecodeArrayBuilderTest, FrameSizesLookGood) { | 173 TEST_F(BytecodeArrayBuilderTest, FrameSizesLookGood) { |
174 for (int locals = 0; locals < 5; locals++) { | 174 for (int locals = 0; locals < 5; locals++) { |
175 for (int contexts = 0; contexts < 4; contexts++) { | 175 for (int contexts = 0; contexts < 4; contexts++) { |
176 for (int temps = 0; temps < 3; temps++) { | 176 for (int temps = 0; temps < 3; temps++) { |
177 BytecodeArrayBuilder builder(isolate(), zone()); | 177 BytecodeArrayBuilder builder(isolate(), zone()); |
178 builder.set_parameter_count(0); | 178 builder.set_parameter_count(0); |
179 builder.set_locals_count(locals); | 179 builder.set_locals_count(locals); |
180 builder.set_context_count(contexts); | 180 builder.set_context_count(contexts); |
181 builder.Return(); | |
182 | 181 |
183 TemporaryRegisterScope temporaries(&builder); | 182 TemporaryRegisterScope temporaries(&builder); |
184 for (int i = 0; i < temps; i++) { | 183 for (int i = 0; i < temps; i++) { |
185 temporaries.NewRegister(); | 184 builder.StoreAccumulatorInRegister(temporaries.NewRegister()); |
186 } | 185 } |
| 186 builder.Return(); |
187 | 187 |
188 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); | 188 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); |
189 int total_registers = locals + contexts + temps; | 189 int total_registers = locals + contexts + temps; |
190 CHECK_EQ(the_array->frame_size(), total_registers * kPointerSize); | 190 CHECK_EQ(the_array->frame_size(), total_registers * kPointerSize); |
191 } | 191 } |
192 } | 192 } |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 | 196 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 builder.set_parameter_count(10); | 240 builder.set_parameter_count(10); |
241 builder.set_locals_count(0); | 241 builder.set_locals_count(0); |
242 builder.set_context_count(0); | 242 builder.set_context_count(0); |
243 | 243 |
244 Register param0(builder.Parameter(0)); | 244 Register param0(builder.Parameter(0)); |
245 Register param9(builder.Parameter(9)); | 245 Register param9(builder.Parameter(9)); |
246 CHECK_EQ(param9.index() - param0.index(), 9); | 246 CHECK_EQ(param9.index() - param0.index(), 9); |
247 } | 247 } |
248 | 248 |
249 | 249 |
| 250 TEST_F(BytecodeArrayBuilderTest, RegisterType) { |
| 251 BytecodeArrayBuilder builder(isolate(), zone()); |
| 252 builder.set_parameter_count(10); |
| 253 builder.set_locals_count(3); |
| 254 builder.set_context_count(0); |
| 255 |
| 256 TemporaryRegisterScope temporary_register_scope(&builder); |
| 257 Register temp0 = temporary_register_scope.NewRegister(); |
| 258 Register param0(builder.Parameter(0)); |
| 259 Register param9(builder.Parameter(9)); |
| 260 Register temp1 = temporary_register_scope.NewRegister(); |
| 261 Register reg0(0); |
| 262 Register reg1(1); |
| 263 Register reg2(2); |
| 264 Register temp2 = temporary_register_scope.NewRegister(); |
| 265 CHECK_EQ(builder.RegisterIsParameterOrLocal(temp0), false); |
| 266 CHECK_EQ(builder.RegisterIsParameterOrLocal(temp1), false); |
| 267 CHECK_EQ(builder.RegisterIsParameterOrLocal(temp2), false); |
| 268 CHECK_EQ(builder.RegisterIsParameterOrLocal(param0), true); |
| 269 CHECK_EQ(builder.RegisterIsParameterOrLocal(param9), true); |
| 270 CHECK_EQ(builder.RegisterIsParameterOrLocal(reg0), true); |
| 271 CHECK_EQ(builder.RegisterIsParameterOrLocal(reg1), true); |
| 272 CHECK_EQ(builder.RegisterIsParameterOrLocal(reg2), true); |
| 273 } |
| 274 |
| 275 |
250 TEST_F(BytecodeArrayBuilderTest, Constants) { | 276 TEST_F(BytecodeArrayBuilderTest, Constants) { |
251 BytecodeArrayBuilder builder(isolate(), zone()); | 277 BytecodeArrayBuilder builder(isolate(), zone()); |
252 builder.set_parameter_count(0); | 278 builder.set_parameter_count(0); |
253 builder.set_locals_count(0); | 279 builder.set_locals_count(0); |
254 builder.set_context_count(0); | 280 builder.set_context_count(0); |
255 | 281 |
256 Factory* factory = isolate()->factory(); | 282 Factory* factory = isolate()->factory(); |
257 Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(3.14); | 283 Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(3.14); |
258 Handle<HeapObject> heap_num_2 = factory->NewHeapNumber(5.2); | 284 Handle<HeapObject> heap_num_2 = factory->NewHeapNumber(5.2); |
259 Handle<Object> large_smi(Smi::FromInt(0x12345678), isolate()); | 285 Handle<Object> large_smi(Smi::FromInt(0x12345678), isolate()); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 527 |
502 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 528 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
503 iterator.Advance(); | 529 iterator.Advance(); |
504 CHECK(iterator.done()); | 530 CHECK(iterator.done()); |
505 } | 531 } |
506 | 532 |
507 | 533 |
508 } // namespace interpreter | 534 } // namespace interpreter |
509 } // namespace internal | 535 } // namespace internal |
510 } // namespace v8 | 536 } // namespace v8 |
OLD | NEW |