OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/address-map.h" | 7 #include "src/address-map.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 size_t index, | 503 size_t index, |
504 OutputFrameStateCombine combine) { | 504 OutputFrameStateCombine combine) { |
505 DCHECK(index < descriptor->GetSize(combine)); | 505 DCHECK(index < descriptor->GetSize(combine)); |
506 switch (combine.kind()) { | 506 switch (combine.kind()) { |
507 case OutputFrameStateCombine::kPushOutput: { | 507 case OutputFrameStateCombine::kPushOutput: { |
508 DCHECK(combine.GetPushCount() <= instr->OutputCount()); | 508 DCHECK(combine.GetPushCount() <= instr->OutputCount()); |
509 size_t size_without_output = | 509 size_t size_without_output = |
510 descriptor->GetSize(OutputFrameStateCombine::Ignore()); | 510 descriptor->GetSize(OutputFrameStateCombine::Ignore()); |
511 // If the index is past the existing stack items, return the output. | 511 // If the index is past the existing stack items, return the output. |
512 if (index >= size_without_output) { | 512 if (index >= size_without_output) { |
513 return {instr->OutputAt(index - size_without_output), kMachAnyTagged}; | 513 return {instr->OutputAt(index - size_without_output), |
| 514 MachineType::AnyTagged()}; |
514 } | 515 } |
515 break; | 516 break; |
516 } | 517 } |
517 case OutputFrameStateCombine::kPokeAt: | 518 case OutputFrameStateCombine::kPokeAt: |
518 size_t index_from_top = | 519 size_t index_from_top = |
519 descriptor->GetSize(combine) - 1 - combine.GetOffsetToPokeAt(); | 520 descriptor->GetSize(combine) - 1 - combine.GetOffsetToPokeAt(); |
520 if (index >= index_from_top && | 521 if (index >= index_from_top && |
521 index < index_from_top + instr->OutputCount()) { | 522 index < index_from_top + instr->OutputCount()) { |
522 return {instr->OutputAt(index - index_from_top), kMachAnyTagged}; | 523 return {instr->OutputAt(index - index_from_top), |
| 524 MachineType::AnyTagged()}; |
523 } | 525 } |
524 break; | 526 break; |
525 } | 527 } |
526 return {instr->InputAt(frame_state_offset + index), | 528 return {instr->InputAt(frame_state_offset + index), |
527 descriptor->GetType(index)}; | 529 descriptor->GetType(index)}; |
528 } | 530 } |
529 | 531 |
530 } // namespace | 532 } // namespace |
531 | 533 |
532 | 534 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 | 598 |
597 return deoptimization_id; | 599 return deoptimization_id; |
598 } | 600 } |
599 | 601 |
600 | 602 |
601 void CodeGenerator::AddTranslationForOperand(Translation* translation, | 603 void CodeGenerator::AddTranslationForOperand(Translation* translation, |
602 Instruction* instr, | 604 Instruction* instr, |
603 InstructionOperand* op, | 605 InstructionOperand* op, |
604 MachineType type) { | 606 MachineType type) { |
605 if (op->IsStackSlot()) { | 607 if (op->IsStackSlot()) { |
606 if (type == kMachBool || type == kRepBit) { | 608 if (type.representation() == MachineRepresentation::kBit) { |
607 translation->StoreBoolStackSlot(LocationOperand::cast(op)->index()); | 609 translation->StoreBoolStackSlot(LocationOperand::cast(op)->index()); |
608 } else if (type == kMachInt32 || type == kMachInt8 || type == kMachInt16) { | 610 } else if (type == MachineType::Int8() || type == MachineType::Int16() || |
| 611 type == MachineType::Int32()) { |
609 translation->StoreInt32StackSlot(LocationOperand::cast(op)->index()); | 612 translation->StoreInt32StackSlot(LocationOperand::cast(op)->index()); |
610 } else if (type == kMachUint32 || type == kMachUint16 || | 613 } else if (type == MachineType::Uint8() || type == MachineType::Uint16() || |
611 type == kMachUint8) { | 614 type == MachineType::Uint32()) { |
612 translation->StoreUint32StackSlot(LocationOperand::cast(op)->index()); | 615 translation->StoreUint32StackSlot(LocationOperand::cast(op)->index()); |
613 } else if ((type & kRepMask) == kRepTagged) { | 616 } else if (type.representation() == MachineRepresentation::kTagged) { |
614 translation->StoreStackSlot(LocationOperand::cast(op)->index()); | 617 translation->StoreStackSlot(LocationOperand::cast(op)->index()); |
615 } else { | 618 } else { |
616 CHECK(false); | 619 CHECK(false); |
617 } | 620 } |
618 } else if (op->IsDoubleStackSlot()) { | 621 } else if (op->IsDoubleStackSlot()) { |
619 DCHECK((type & (kRepFloat32 | kRepFloat64)) != 0); | 622 DCHECK(IsFloatingPoint(type.representation())); |
620 translation->StoreDoubleStackSlot(LocationOperand::cast(op)->index()); | 623 translation->StoreDoubleStackSlot(LocationOperand::cast(op)->index()); |
621 } else if (op->IsRegister()) { | 624 } else if (op->IsRegister()) { |
622 InstructionOperandConverter converter(this, instr); | 625 InstructionOperandConverter converter(this, instr); |
623 if (type == kMachBool || type == kRepBit) { | 626 if (type.representation() == MachineRepresentation::kBit) { |
624 translation->StoreBoolRegister(converter.ToRegister(op)); | 627 translation->StoreBoolRegister(converter.ToRegister(op)); |
625 } else if (type == kMachInt32 || type == kMachInt8 || type == kMachInt16) { | 628 } else if (type == MachineType::Int8() || type == MachineType::Int16() || |
| 629 type == MachineType::Int32()) { |
626 translation->StoreInt32Register(converter.ToRegister(op)); | 630 translation->StoreInt32Register(converter.ToRegister(op)); |
627 } else if (type == kMachUint32 || type == kMachUint16 || | 631 } else if (type == MachineType::Uint8() || type == MachineType::Uint16() || |
628 type == kMachUint8) { | 632 type == MachineType::Uint32()) { |
629 translation->StoreUint32Register(converter.ToRegister(op)); | 633 translation->StoreUint32Register(converter.ToRegister(op)); |
630 } else if ((type & kRepMask) == kRepTagged) { | 634 } else if (type.representation() == MachineRepresentation::kTagged) { |
631 translation->StoreRegister(converter.ToRegister(op)); | 635 translation->StoreRegister(converter.ToRegister(op)); |
632 } else { | 636 } else { |
633 CHECK(false); | 637 CHECK(false); |
634 } | 638 } |
635 } else if (op->IsDoubleRegister()) { | 639 } else if (op->IsDoubleRegister()) { |
636 DCHECK((type & (kRepFloat32 | kRepFloat64)) != 0); | 640 DCHECK(IsFloatingPoint(type.representation())); |
637 InstructionOperandConverter converter(this, instr); | 641 InstructionOperandConverter converter(this, instr); |
638 translation->StoreDoubleRegister(converter.ToDoubleRegister(op)); | 642 translation->StoreDoubleRegister(converter.ToDoubleRegister(op)); |
639 } else if (op->IsImmediate()) { | 643 } else if (op->IsImmediate()) { |
640 InstructionOperandConverter converter(this, instr); | 644 InstructionOperandConverter converter(this, instr); |
641 Constant constant = converter.ToConstant(op); | 645 Constant constant = converter.ToConstant(op); |
642 Handle<Object> constant_object; | 646 Handle<Object> constant_object; |
643 switch (constant.type()) { | 647 switch (constant.type()) { |
644 case Constant::kInt32: | 648 case Constant::kInt32: |
645 DCHECK(type == kMachInt32 || type == kMachUint32 || type == kMachBool || | 649 DCHECK(type == MachineType::Int32() || type == MachineType::Uint32() || |
646 type == kRepBit); | 650 type.representation() == MachineRepresentation::kBit); |
647 constant_object = | 651 constant_object = |
648 isolate()->factory()->NewNumberFromInt(constant.ToInt32()); | 652 isolate()->factory()->NewNumberFromInt(constant.ToInt32()); |
649 break; | 653 break; |
650 case Constant::kFloat32: | 654 case Constant::kFloat32: |
651 DCHECK((type & (kRepFloat32 | kRepTagged)) != 0); | 655 DCHECK(type.representation() == MachineRepresentation::kFloat32 || |
| 656 type.representation() == MachineRepresentation::kTagged); |
652 constant_object = isolate()->factory()->NewNumber(constant.ToFloat32()); | 657 constant_object = isolate()->factory()->NewNumber(constant.ToFloat32()); |
653 break; | 658 break; |
654 case Constant::kFloat64: | 659 case Constant::kFloat64: |
655 DCHECK((type & (kRepFloat64 | kRepTagged)) != 0); | 660 DCHECK(type.representation() == MachineRepresentation::kFloat64 || |
| 661 type.representation() == MachineRepresentation::kTagged); |
656 constant_object = isolate()->factory()->NewNumber(constant.ToFloat64()); | 662 constant_object = isolate()->factory()->NewNumber(constant.ToFloat64()); |
657 break; | 663 break; |
658 case Constant::kHeapObject: | 664 case Constant::kHeapObject: |
659 DCHECK((type & kRepMask) == kRepTagged); | 665 DCHECK(type.representation() == MachineRepresentation::kTagged); |
660 constant_object = constant.ToHeapObject(); | 666 constant_object = constant.ToHeapObject(); |
661 break; | 667 break; |
662 default: | 668 default: |
663 CHECK(false); | 669 CHECK(false); |
664 } | 670 } |
665 if (constant_object.is_identical_to(info()->closure())) { | 671 if (constant_object.is_identical_to(info()->closure())) { |
666 translation->StoreJSFrameFunction(); | 672 translation->StoreJSFrameFunction(); |
667 } else { | 673 } else { |
668 int literal_id = DefineDeoptimizationLiteral(constant_object); | 674 int literal_id = DefineDeoptimizationLiteral(constant_object); |
669 translation->StoreLiteral(literal_id); | 675 translation->StoreLiteral(literal_id); |
(...skipping 27 matching lines...) Expand all Loading... |
697 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { | 703 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { |
698 gen->ools_ = this; | 704 gen->ools_ = this; |
699 } | 705 } |
700 | 706 |
701 | 707 |
702 OutOfLineCode::~OutOfLineCode() {} | 708 OutOfLineCode::~OutOfLineCode() {} |
703 | 709 |
704 } // namespace compiler | 710 } // namespace compiler |
705 } // namespace internal | 711 } // namespace internal |
706 } // namespace v8 | 712 } // namespace v8 |
OLD | NEW |