| 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 "src/interpreter/bytecode-label.h" | 9 #include "src/interpreter/bytecode-label.h" |
| 10 #include "src/interpreter/bytecode-register-allocator.h" | 10 #include "src/interpreter/bytecode-register-allocator.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 Register wide(128); | 35 Register wide(128); |
| 36 RegisterList reg_list; | 36 RegisterList reg_list; |
| 37 RegisterList pair(0, 2), triple(0, 3); | 37 RegisterList pair(0, 2), triple(0, 3); |
| 38 | 38 |
| 39 // Emit argument creation operations. | 39 // Emit argument creation operations. |
| 40 builder.CreateArguments(CreateArgumentsType::kMappedArguments) | 40 builder.CreateArguments(CreateArgumentsType::kMappedArguments) |
| 41 .CreateArguments(CreateArgumentsType::kUnmappedArguments) | 41 .CreateArguments(CreateArgumentsType::kUnmappedArguments) |
| 42 .CreateArguments(CreateArgumentsType::kRestParameter); | 42 .CreateArguments(CreateArgumentsType::kRestParameter); |
| 43 | 43 |
| 44 // Emit constant loads. | 44 // Emit constant loads. |
| 45 builder.LoadLiteral(Smi::FromInt(0)) | 45 builder.LoadLiteral(Smi::kZero) |
| 46 .StoreAccumulatorInRegister(reg) | 46 .StoreAccumulatorInRegister(reg) |
| 47 .LoadLiteral(Smi::FromInt(8)) | 47 .LoadLiteral(Smi::FromInt(8)) |
| 48 .CompareOperation(Token::Value::NE, reg, | 48 .CompareOperation(Token::Value::NE, reg, |
| 49 1) // Prevent peephole optimization | 49 1) // Prevent peephole optimization |
| 50 // LdaSmi, Star -> LdrSmi. | 50 // LdaSmi, Star -> LdrSmi. |
| 51 .StoreAccumulatorInRegister(reg) | 51 .StoreAccumulatorInRegister(reg) |
| 52 .LoadLiteral(Smi::FromInt(10000000)) | 52 .LoadLiteral(Smi::FromInt(10000000)) |
| 53 .StoreAccumulatorInRegister(reg) | 53 .StoreAccumulatorInRegister(reg) |
| 54 .LoadLiteral(factory->NewStringFromStaticChars("A constant")) | 54 .LoadLiteral(factory->NewStringFromStaticChars("A constant")) |
| 55 .StoreAccumulatorInRegister(reg) | 55 .StoreAccumulatorInRegister(reg) |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // Longer jumps with constant operands | 212 // Longer jumps with constant operands |
| 213 BytecodeLabel end[8]; | 213 BytecodeLabel end[8]; |
| 214 { | 214 { |
| 215 BytecodeLabel after_jump; | 215 BytecodeLabel after_jump; |
| 216 builder.Jump(&end[0]) | 216 builder.Jump(&end[0]) |
| 217 .Bind(&after_jump) | 217 .Bind(&after_jump) |
| 218 .LoadTrue() | 218 .LoadTrue() |
| 219 .JumpIfTrue(&end[1]) | 219 .JumpIfTrue(&end[1]) |
| 220 .LoadTrue() | 220 .LoadTrue() |
| 221 .JumpIfFalse(&end[2]) | 221 .JumpIfFalse(&end[2]) |
| 222 .LoadLiteral(Smi::FromInt(0)) | 222 .LoadLiteral(Smi::kZero) |
| 223 .JumpIfTrue(&end[3]) | 223 .JumpIfTrue(&end[3]) |
| 224 .LoadLiteral(Smi::FromInt(0)) | 224 .LoadLiteral(Smi::kZero) |
| 225 .JumpIfFalse(&end[4]) | 225 .JumpIfFalse(&end[4]) |
| 226 .JumpIfNull(&end[5]) | 226 .JumpIfNull(&end[5]) |
| 227 .JumpIfUndefined(&end[6]) | 227 .JumpIfUndefined(&end[6]) |
| 228 .JumpIfNotHole(&end[7]); | 228 .JumpIfNotHole(&end[7]); |
| 229 } | 229 } |
| 230 | 230 |
| 231 // Perform an operation that returns boolean value to | 231 // Perform an operation that returns boolean value to |
| 232 // generate JumpIfTrue/False | 232 // generate JumpIfTrue/False |
| 233 { | 233 { |
| 234 BytecodeLabel after_jump1, after_jump2; | 234 BytecodeLabel after_jump1, after_jump2; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 414 |
| 415 | 415 |
| 416 TEST_F(BytecodeArrayBuilderTest, FrameSizesLookGood) { | 416 TEST_F(BytecodeArrayBuilderTest, FrameSizesLookGood) { |
| 417 CanonicalHandleScope canonical(isolate()); | 417 CanonicalHandleScope canonical(isolate()); |
| 418 for (int locals = 0; locals < 5; locals++) { | 418 for (int locals = 0; locals < 5; locals++) { |
| 419 for (int contexts = 0; contexts < 4; contexts++) { | 419 for (int contexts = 0; contexts < 4; contexts++) { |
| 420 for (int temps = 0; temps < 3; temps++) { | 420 for (int temps = 0; temps < 3; temps++) { |
| 421 BytecodeArrayBuilder builder(isolate(), zone(), 0, contexts, locals); | 421 BytecodeArrayBuilder builder(isolate(), zone(), 0, contexts, locals); |
| 422 BytecodeRegisterAllocator* allocator(builder.register_allocator()); | 422 BytecodeRegisterAllocator* allocator(builder.register_allocator()); |
| 423 for (int i = 0; i < locals + contexts; i++) { | 423 for (int i = 0; i < locals + contexts; i++) { |
| 424 builder.LoadLiteral(Smi::FromInt(0)); | 424 builder.LoadLiteral(Smi::kZero); |
| 425 builder.StoreAccumulatorInRegister(Register(i)); | 425 builder.StoreAccumulatorInRegister(Register(i)); |
| 426 } | 426 } |
| 427 for (int i = 0; i < temps; i++) { | 427 for (int i = 0; i < temps; i++) { |
| 428 Register temp = allocator->NewRegister(); | 428 Register temp = allocator->NewRegister(); |
| 429 builder.LoadLiteral(Smi::FromInt(0)); | 429 builder.LoadLiteral(Smi::kZero); |
| 430 builder.StoreAccumulatorInRegister(temp); | 430 builder.StoreAccumulatorInRegister(temp); |
| 431 // Ensure temporaries are used so not optimized away by the | 431 // Ensure temporaries are used so not optimized away by the |
| 432 // register optimizer. | 432 // register optimizer. |
| 433 builder.ConvertAccumulatorToName(temp); | 433 builder.ConvertAccumulatorToName(temp); |
| 434 } | 434 } |
| 435 builder.Return(); | 435 builder.Return(); |
| 436 | 436 |
| 437 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(isolate()); | 437 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(isolate()); |
| 438 int total_registers = locals + contexts + temps; | 438 int total_registers = locals + contexts + temps; |
| 439 CHECK_EQ(the_array->frame_size(), total_registers * kPointerSize); | 439 CHECK_EQ(the_array->frame_size(), total_registers * kPointerSize); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 iterator.Advance(); | 729 iterator.Advance(); |
| 730 } | 730 } |
| 731 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 731 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
| 732 iterator.Advance(); | 732 iterator.Advance(); |
| 733 CHECK(iterator.done()); | 733 CHECK(iterator.done()); |
| 734 } | 734 } |
| 735 | 735 |
| 736 } // namespace interpreter | 736 } // namespace interpreter |
| 737 } // namespace internal | 737 } // namespace internal |
| 738 } // namespace v8 | 738 } // namespace v8 |
| OLD | NEW |