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/base/adapters.h" | 8 #include "src/base/adapters.h" |
9 #include "src/compiler/code-generator-impl.h" | 9 #include "src/compiler/code-generator-impl.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 MachineType type) { | 813 MachineType type) { |
814 if (op->IsStackSlot()) { | 814 if (op->IsStackSlot()) { |
815 if (type.representation() == MachineRepresentation::kBit) { | 815 if (type.representation() == MachineRepresentation::kBit) { |
816 translation->StoreBoolStackSlot(LocationOperand::cast(op)->index()); | 816 translation->StoreBoolStackSlot(LocationOperand::cast(op)->index()); |
817 } else if (type == MachineType::Int8() || type == MachineType::Int16() || | 817 } else if (type == MachineType::Int8() || type == MachineType::Int16() || |
818 type == MachineType::Int32()) { | 818 type == MachineType::Int32()) { |
819 translation->StoreInt32StackSlot(LocationOperand::cast(op)->index()); | 819 translation->StoreInt32StackSlot(LocationOperand::cast(op)->index()); |
820 } else if (type == MachineType::Uint8() || type == MachineType::Uint16() || | 820 } else if (type == MachineType::Uint8() || type == MachineType::Uint16() || |
821 type == MachineType::Uint32()) { | 821 type == MachineType::Uint32()) { |
822 translation->StoreUint32StackSlot(LocationOperand::cast(op)->index()); | 822 translation->StoreUint32StackSlot(LocationOperand::cast(op)->index()); |
823 } else if (type.representation() == MachineRepresentation::kTagged) { | 823 } else if (IsAnyTagged(type.representation())) { |
824 translation->StoreStackSlot(LocationOperand::cast(op)->index()); | 824 translation->StoreStackSlot(LocationOperand::cast(op)->index()); |
825 } else { | 825 } else { |
826 CHECK(false); | 826 CHECK(false); |
827 } | 827 } |
828 } else if (op->IsFPStackSlot()) { | 828 } else if (op->IsFPStackSlot()) { |
829 if (type.representation() == MachineRepresentation::kFloat64) { | 829 if (type.representation() == MachineRepresentation::kFloat64) { |
830 translation->StoreDoubleStackSlot(LocationOperand::cast(op)->index()); | 830 translation->StoreDoubleStackSlot(LocationOperand::cast(op)->index()); |
831 } else { | 831 } else { |
832 DCHECK_EQ(MachineRepresentation::kFloat32, type.representation()); | 832 DCHECK_EQ(MachineRepresentation::kFloat32, type.representation()); |
833 translation->StoreFloatStackSlot(LocationOperand::cast(op)->index()); | 833 translation->StoreFloatStackSlot(LocationOperand::cast(op)->index()); |
834 } | 834 } |
835 } else if (op->IsRegister()) { | 835 } else if (op->IsRegister()) { |
836 InstructionOperandConverter converter(this, instr); | 836 InstructionOperandConverter converter(this, instr); |
837 if (type.representation() == MachineRepresentation::kBit) { | 837 if (type.representation() == MachineRepresentation::kBit) { |
838 translation->StoreBoolRegister(converter.ToRegister(op)); | 838 translation->StoreBoolRegister(converter.ToRegister(op)); |
839 } else if (type == MachineType::Int8() || type == MachineType::Int16() || | 839 } else if (type == MachineType::Int8() || type == MachineType::Int16() || |
840 type == MachineType::Int32()) { | 840 type == MachineType::Int32()) { |
841 translation->StoreInt32Register(converter.ToRegister(op)); | 841 translation->StoreInt32Register(converter.ToRegister(op)); |
842 } else if (type == MachineType::Uint8() || type == MachineType::Uint16() || | 842 } else if (type == MachineType::Uint8() || type == MachineType::Uint16() || |
843 type == MachineType::Uint32()) { | 843 type == MachineType::Uint32()) { |
844 translation->StoreUint32Register(converter.ToRegister(op)); | 844 translation->StoreUint32Register(converter.ToRegister(op)); |
845 } else if (type.representation() == MachineRepresentation::kTagged) { | 845 } else if (IsAnyTagged(type.representation())) { |
846 translation->StoreRegister(converter.ToRegister(op)); | 846 translation->StoreRegister(converter.ToRegister(op)); |
847 } else { | 847 } else { |
848 CHECK(false); | 848 CHECK(false); |
849 } | 849 } |
850 } else if (op->IsFPRegister()) { | 850 } else if (op->IsFPRegister()) { |
851 InstructionOperandConverter converter(this, instr); | 851 InstructionOperandConverter converter(this, instr); |
852 if (type.representation() == MachineRepresentation::kFloat64) { | 852 if (type.representation() == MachineRepresentation::kFloat64) { |
853 translation->StoreDoubleRegister(converter.ToDoubleRegister(op)); | 853 translation->StoreDoubleRegister(converter.ToDoubleRegister(op)); |
854 } else { | 854 } else { |
855 DCHECK_EQ(MachineRepresentation::kFloat32, type.representation()); | 855 DCHECK_EQ(MachineRepresentation::kFloat32, type.representation()); |
856 translation->StoreFloatRegister(converter.ToFloatRegister(op)); | 856 translation->StoreFloatRegister(converter.ToFloatRegister(op)); |
857 } | 857 } |
858 } else if (op->IsImmediate()) { | 858 } else if (op->IsImmediate()) { |
859 InstructionOperandConverter converter(this, instr); | 859 InstructionOperandConverter converter(this, instr); |
860 Constant constant = converter.ToConstant(op); | 860 Constant constant = converter.ToConstant(op); |
861 Handle<Object> constant_object; | 861 Handle<Object> constant_object; |
862 switch (constant.type()) { | 862 switch (constant.type()) { |
863 case Constant::kInt32: | 863 case Constant::kInt32: |
864 if (type.representation() == MachineRepresentation::kTagged) { | 864 if (type.representation() == MachineRepresentation::kTagged || |
| 865 type.representation() == MachineRepresentation::kTaggedSigned) { |
865 // When pointers are 4 bytes, we can use int32 constants to represent | 866 // When pointers are 4 bytes, we can use int32 constants to represent |
866 // Smis. | 867 // Smis. |
867 DCHECK_EQ(4, kPointerSize); | 868 DCHECK_EQ(4, kPointerSize); |
868 constant_object = | 869 constant_object = |
869 handle(reinterpret_cast<Smi*>(constant.ToInt32()), isolate()); | 870 handle(reinterpret_cast<Smi*>(constant.ToInt32()), isolate()); |
870 DCHECK(constant_object->IsSmi()); | 871 DCHECK(constant_object->IsSmi()); |
871 } else { | 872 } else { |
872 DCHECK(type == MachineType::Int32() || | 873 DCHECK(type == MachineType::Int32() || |
873 type == MachineType::Uint32() || | 874 type == MachineType::Uint32() || |
874 type.representation() == MachineRepresentation::kBit || | 875 type.representation() == MachineRepresentation::kBit || |
875 type.representation() == MachineRepresentation::kNone); | 876 type.representation() == MachineRepresentation::kNone); |
876 DCHECK(type.representation() != MachineRepresentation::kNone || | 877 DCHECK(type.representation() != MachineRepresentation::kNone || |
877 constant.ToInt32() == FrameStateDescriptor::kImpossibleValue); | 878 constant.ToInt32() == FrameStateDescriptor::kImpossibleValue); |
878 | 879 |
879 constant_object = | 880 constant_object = |
880 isolate()->factory()->NewNumberFromInt(constant.ToInt32()); | 881 isolate()->factory()->NewNumberFromInt(constant.ToInt32()); |
881 } | 882 } |
882 break; | 883 break; |
883 case Constant::kInt64: | 884 case Constant::kInt64: |
884 // When pointers are 8 bytes, we can use int64 constants to represent | 885 // When pointers are 8 bytes, we can use int64 constants to represent |
885 // Smis. | 886 // Smis. |
886 DCHECK_EQ(type.representation(), MachineRepresentation::kTagged); | 887 DCHECK(type.representation() == MachineRepresentation::kTagged || |
| 888 type.representation() == MachineRepresentation::kTaggedSigned); |
887 DCHECK_EQ(8, kPointerSize); | 889 DCHECK_EQ(8, kPointerSize); |
888 constant_object = | 890 constant_object = |
889 handle(reinterpret_cast<Smi*>(constant.ToInt64()), isolate()); | 891 handle(reinterpret_cast<Smi*>(constant.ToInt64()), isolate()); |
890 DCHECK(constant_object->IsSmi()); | 892 DCHECK(constant_object->IsSmi()); |
891 break; | 893 break; |
892 case Constant::kFloat32: | 894 case Constant::kFloat32: |
893 DCHECK(type.representation() == MachineRepresentation::kFloat32 || | 895 DCHECK(type.representation() == MachineRepresentation::kFloat32 || |
894 type.representation() == MachineRepresentation::kTagged); | 896 CanBeTaggedPointer(type.representation())); |
895 constant_object = isolate()->factory()->NewNumber(constant.ToFloat32()); | 897 constant_object = isolate()->factory()->NewNumber(constant.ToFloat32()); |
896 break; | 898 break; |
897 case Constant::kFloat64: | 899 case Constant::kFloat64: |
898 DCHECK(type.representation() == MachineRepresentation::kFloat64 || | 900 DCHECK(type.representation() == MachineRepresentation::kFloat64 || |
899 type.representation() == MachineRepresentation::kTagged); | 901 CanBeTaggedPointer(type.representation())); |
900 constant_object = isolate()->factory()->NewNumber(constant.ToFloat64()); | 902 constant_object = isolate()->factory()->NewNumber(constant.ToFloat64()); |
901 break; | 903 break; |
902 case Constant::kHeapObject: | 904 case Constant::kHeapObject: |
903 DCHECK(type.representation() == MachineRepresentation::kTagged); | 905 DCHECK(CanBeTaggedPointer(type.representation())); |
904 constant_object = constant.ToHeapObject(); | 906 constant_object = constant.ToHeapObject(); |
905 break; | 907 break; |
906 default: | 908 default: |
907 CHECK(false); | 909 CHECK(false); |
908 } | 910 } |
909 if (constant_object.is_identical_to(info()->closure())) { | 911 if (constant_object.is_identical_to(info()->closure())) { |
910 translation->StoreJSFrameFunction(); | 912 translation->StoreJSFrameFunction(); |
911 } else { | 913 } else { |
912 int literal_id = DefineDeoptimizationLiteral(constant_object); | 914 int literal_id = DefineDeoptimizationLiteral(constant_object); |
913 translation->StoreLiteral(literal_id); | 915 translation->StoreLiteral(literal_id); |
(...skipping 22 matching lines...) Expand all Loading... |
936 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { | 938 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { |
937 gen->ools_ = this; | 939 gen->ools_ = this; |
938 } | 940 } |
939 | 941 |
940 | 942 |
941 OutOfLineCode::~OutOfLineCode() {} | 943 OutOfLineCode::~OutOfLineCode() {} |
942 | 944 |
943 } // namespace compiler | 945 } // namespace compiler |
944 } // namespace internal | 946 } // namespace internal |
945 } // namespace v8 | 947 } // namespace v8 |
OLD | NEW |