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/interpreter/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace interpreter { | 9 namespace interpreter { |
10 | 10 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 // TODO(rmcilroy): Consider passing the type as a bytecode operand rather | 522 // TODO(rmcilroy): Consider passing the type as a bytecode operand rather |
523 // than having two different bytecodes once we have better support for | 523 // than having two different bytecodes once we have better support for |
524 // branches in the InterpreterAssembler. | 524 // branches in the InterpreterAssembler. |
525 Bytecode bytecode = BytecodeForCreateArguments(type); | 525 Bytecode bytecode = BytecodeForCreateArguments(type); |
526 Output(bytecode); | 526 Output(bytecode); |
527 return *this; | 527 return *this; |
528 } | 528 } |
529 | 529 |
530 | 530 |
531 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateRegExpLiteral( | 531 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateRegExpLiteral( |
532 int literal_index, int flags) { | 532 Handle<String> pattern, int literal_index, int flags) { |
533 DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits. | 533 DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits. |
534 if (FitsInIdx8Operand(literal_index)) { | 534 size_t pattern_entry = GetConstantPoolEntry(pattern); |
535 Output(Bytecode::kCreateRegExpLiteral, static_cast<uint8_t>(literal_index), | 535 if (FitsInIdx8Operand(literal_index) && FitsInIdx8Operand(pattern_entry)) { |
536 static_cast<uint8_t>(flags)); | 536 Output(Bytecode::kCreateRegExpLiteral, static_cast<uint8_t>(pattern_entry), |
| 537 static_cast<uint8_t>(literal_index), static_cast<uint8_t>(flags)); |
| 538 } else if (FitsInIdx16Operand(literal_index) && |
| 539 FitsInIdx16Operand(pattern_entry)) { |
| 540 Output(Bytecode::kCreateRegExpLiteralWide, |
| 541 static_cast<uint16_t>(pattern_entry), |
| 542 static_cast<uint16_t>(literal_index), static_cast<uint8_t>(flags)); |
537 } else { | 543 } else { |
538 UNIMPLEMENTED(); | 544 UNIMPLEMENTED(); |
539 } | 545 } |
540 return *this; | 546 return *this; |
541 } | 547 } |
542 | 548 |
543 | 549 |
544 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateArrayLiteral( | 550 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateArrayLiteral( |
545 int literal_index, int flags) { | 551 Handle<FixedArray> constant_elements, int literal_index, int flags) { |
546 DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits. | 552 DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits. |
547 if (FitsInIdx8Operand(literal_index)) { | 553 size_t constant_elements_entry = GetConstantPoolEntry(constant_elements); |
548 Output(Bytecode::kCreateArrayLiteral, static_cast<uint8_t>(literal_index), | 554 if (FitsInIdx8Operand(literal_index) && |
549 static_cast<uint8_t>(flags)); | 555 FitsInIdx8Operand(constant_elements_entry)) { |
| 556 Output(Bytecode::kCreateArrayLiteral, |
| 557 static_cast<uint8_t>(constant_elements_entry), |
| 558 static_cast<uint8_t>(literal_index), static_cast<uint8_t>(flags)); |
| 559 } else if (FitsInIdx16Operand(literal_index) && |
| 560 FitsInIdx16Operand(constant_elements_entry)) { |
| 561 Output(Bytecode::kCreateArrayLiteralWide, |
| 562 static_cast<uint16_t>(constant_elements_entry), |
| 563 static_cast<uint16_t>(literal_index), static_cast<uint8_t>(flags)); |
550 } else { | 564 } else { |
551 UNIMPLEMENTED(); | 565 UNIMPLEMENTED(); |
552 } | 566 } |
553 return *this; | 567 return *this; |
554 } | 568 } |
555 | 569 |
556 | 570 |
557 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateObjectLiteral( | 571 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateObjectLiteral( |
558 int literal_index, int flags) { | 572 Handle<FixedArray> constant_properties, int literal_index, int flags) { |
559 DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits. | 573 DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits. |
560 if (FitsInIdx8Operand(literal_index)) { | 574 size_t constant_properties_entry = GetConstantPoolEntry(constant_properties); |
561 Output(Bytecode::kCreateObjectLiteral, static_cast<uint8_t>(literal_index), | 575 if (FitsInIdx8Operand(literal_index) && |
562 static_cast<uint8_t>(flags)); | 576 FitsInIdx8Operand(constant_properties_entry)) { |
| 577 Output(Bytecode::kCreateObjectLiteral, |
| 578 static_cast<uint8_t>(constant_properties_entry), |
| 579 static_cast<uint8_t>(literal_index), static_cast<uint8_t>(flags)); |
| 580 } else if (FitsInIdx16Operand(literal_index) && |
| 581 FitsInIdx16Operand(constant_properties_entry)) { |
| 582 Output(Bytecode::kCreateObjectLiteralWide, |
| 583 static_cast<uint16_t>(constant_properties_entry), |
| 584 static_cast<uint16_t>(literal_index), static_cast<uint8_t>(flags)); |
563 } else { | 585 } else { |
564 UNIMPLEMENTED(); | 586 UNIMPLEMENTED(); |
565 } | 587 } |
566 return *this; | 588 return *this; |
567 } | 589 } |
568 | 590 |
569 | 591 |
570 BytecodeArrayBuilder& BytecodeArrayBuilder::PushContext(Register context) { | 592 BytecodeArrayBuilder& BytecodeArrayBuilder::PushContext(Register context) { |
571 Output(Bytecode::kPushContext, context.ToOperand()); | 593 Output(Bytecode::kPushContext, context.ToOperand()); |
572 return *this; | 594 return *this; |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 DCHECK_GT(next_consecutive_count_, 0); | 1446 DCHECK_GT(next_consecutive_count_, 0); |
1425 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); | 1447 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); |
1426 allocated_.push_back(next_consecutive_register_); | 1448 allocated_.push_back(next_consecutive_register_); |
1427 next_consecutive_count_--; | 1449 next_consecutive_count_--; |
1428 return Register(next_consecutive_register_++); | 1450 return Register(next_consecutive_register_++); |
1429 } | 1451 } |
1430 | 1452 |
1431 } // namespace interpreter | 1453 } // namespace interpreter |
1432 } // namespace internal | 1454 } // namespace internal |
1433 } // namespace v8 | 1455 } // namespace v8 |
OLD | NEW |