Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/compiler/code-generator.cc

Issue 2258073002: [Turbofan]: Use new MachineTypes in access-builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Code comments addressed. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 (type.representation() == MachineRepresentation::kTagged ||
824 type.representation() == MachineRepresentation::kTaggedSigned ||
825 type.representation() == MachineRepresentation::kTaggedPointer) {
mvstanton 2016/08/29 12:02:10 Introduced helper function for these cases, IsAnyT
824 translation->StoreStackSlot(LocationOperand::cast(op)->index()); 826 translation->StoreStackSlot(LocationOperand::cast(op)->index());
825 } else { 827 } else {
826 CHECK(false); 828 CHECK(false);
827 } 829 }
828 } else if (op->IsFPStackSlot()) { 830 } else if (op->IsFPStackSlot()) {
829 if (type.representation() == MachineRepresentation::kFloat64) { 831 if (type.representation() == MachineRepresentation::kFloat64) {
830 translation->StoreDoubleStackSlot(LocationOperand::cast(op)->index()); 832 translation->StoreDoubleStackSlot(LocationOperand::cast(op)->index());
831 } else { 833 } else {
832 DCHECK_EQ(MachineRepresentation::kFloat32, type.representation()); 834 DCHECK_EQ(MachineRepresentation::kFloat32, type.representation());
833 translation->StoreFloatStackSlot(LocationOperand::cast(op)->index()); 835 translation->StoreFloatStackSlot(LocationOperand::cast(op)->index());
834 } 836 }
835 } else if (op->IsRegister()) { 837 } else if (op->IsRegister()) {
836 InstructionOperandConverter converter(this, instr); 838 InstructionOperandConverter converter(this, instr);
837 if (type.representation() == MachineRepresentation::kBit) { 839 if (type.representation() == MachineRepresentation::kBit) {
838 translation->StoreBoolRegister(converter.ToRegister(op)); 840 translation->StoreBoolRegister(converter.ToRegister(op));
839 } else if (type == MachineType::Int8() || type == MachineType::Int16() || 841 } else if (type == MachineType::Int8() || type == MachineType::Int16() ||
840 type == MachineType::Int32()) { 842 type == MachineType::Int32()) {
841 translation->StoreInt32Register(converter.ToRegister(op)); 843 translation->StoreInt32Register(converter.ToRegister(op));
842 } else if (type == MachineType::Uint8() || type == MachineType::Uint16() || 844 } else if (type == MachineType::Uint8() || type == MachineType::Uint16() ||
843 type == MachineType::Uint32()) { 845 type == MachineType::Uint32()) {
844 translation->StoreUint32Register(converter.ToRegister(op)); 846 translation->StoreUint32Register(converter.ToRegister(op));
845 } else if (type.representation() == MachineRepresentation::kTagged) { 847 } else if (type.representation() == MachineRepresentation::kTagged ||
848 type.representation() == MachineRepresentation::kTaggedSigned ||
849 type.representation() == MachineRepresentation::kTaggedPointer) {
846 translation->StoreRegister(converter.ToRegister(op)); 850 translation->StoreRegister(converter.ToRegister(op));
847 } else { 851 } else {
848 CHECK(false); 852 CHECK(false);
849 } 853 }
850 } else if (op->IsFPRegister()) { 854 } else if (op->IsFPRegister()) {
851 InstructionOperandConverter converter(this, instr); 855 InstructionOperandConverter converter(this, instr);
852 if (type.representation() == MachineRepresentation::kFloat64) { 856 if (type.representation() == MachineRepresentation::kFloat64) {
853 translation->StoreDoubleRegister(converter.ToDoubleRegister(op)); 857 translation->StoreDoubleRegister(converter.ToDoubleRegister(op));
854 } else { 858 } else {
855 DCHECK_EQ(MachineRepresentation::kFloat32, type.representation()); 859 DCHECK_EQ(MachineRepresentation::kFloat32, type.representation());
856 translation->StoreFloatRegister(converter.ToFloatRegister(op)); 860 translation->StoreFloatRegister(converter.ToFloatRegister(op));
857 } 861 }
858 } else if (op->IsImmediate()) { 862 } else if (op->IsImmediate()) {
859 InstructionOperandConverter converter(this, instr); 863 InstructionOperandConverter converter(this, instr);
860 Constant constant = converter.ToConstant(op); 864 Constant constant = converter.ToConstant(op);
861 Handle<Object> constant_object; 865 Handle<Object> constant_object;
862 switch (constant.type()) { 866 switch (constant.type()) {
863 case Constant::kInt32: 867 case Constant::kInt32:
864 if (type.representation() == MachineRepresentation::kTagged) { 868 if (type.representation() == MachineRepresentation::kTagged ||
869 type.representation() == MachineRepresentation::kTaggedSigned) {
865 // When pointers are 4 bytes, we can use int32 constants to represent 870 // When pointers are 4 bytes, we can use int32 constants to represent
866 // Smis. 871 // Smis.
867 DCHECK_EQ(4, kPointerSize); 872 DCHECK_EQ(4, kPointerSize);
868 constant_object = 873 constant_object =
869 handle(reinterpret_cast<Smi*>(constant.ToInt32()), isolate()); 874 handle(reinterpret_cast<Smi*>(constant.ToInt32()), isolate());
870 DCHECK(constant_object->IsSmi()); 875 DCHECK(constant_object->IsSmi());
871 } else { 876 } else {
872 DCHECK(type == MachineType::Int32() || 877 DCHECK(type == MachineType::Int32() ||
873 type == MachineType::Uint32() || 878 type == MachineType::Uint32() ||
874 type.representation() == MachineRepresentation::kBit || 879 type.representation() == MachineRepresentation::kBit ||
875 type.representation() == MachineRepresentation::kNone); 880 type.representation() == MachineRepresentation::kNone);
876 DCHECK(type.representation() != MachineRepresentation::kNone || 881 DCHECK(type.representation() != MachineRepresentation::kNone ||
877 constant.ToInt32() == FrameStateDescriptor::kImpossibleValue); 882 constant.ToInt32() == FrameStateDescriptor::kImpossibleValue);
878 883
879 constant_object = 884 constant_object =
880 isolate()->factory()->NewNumberFromInt(constant.ToInt32()); 885 isolate()->factory()->NewNumberFromInt(constant.ToInt32());
881 } 886 }
882 break; 887 break;
883 case Constant::kInt64: 888 case Constant::kInt64:
884 // When pointers are 8 bytes, we can use int64 constants to represent 889 // When pointers are 8 bytes, we can use int64 constants to represent
885 // Smis. 890 // Smis.
886 DCHECK_EQ(type.representation(), MachineRepresentation::kTagged); 891 DCHECK(type.representation() == MachineRepresentation::kTagged ||
892 type.representation() == MachineRepresentation::kTaggedSigned);
887 DCHECK_EQ(8, kPointerSize); 893 DCHECK_EQ(8, kPointerSize);
888 constant_object = 894 constant_object =
889 handle(reinterpret_cast<Smi*>(constant.ToInt64()), isolate()); 895 handle(reinterpret_cast<Smi*>(constant.ToInt64()), isolate());
890 DCHECK(constant_object->IsSmi()); 896 DCHECK(constant_object->IsSmi());
891 break; 897 break;
892 case Constant::kFloat32: 898 case Constant::kFloat32:
893 DCHECK(type.representation() == MachineRepresentation::kFloat32 || 899 DCHECK(type.representation() == MachineRepresentation::kFloat32 ||
894 type.representation() == MachineRepresentation::kTagged); 900 type.representation() == MachineRepresentation::kTagged ||
901 type.representation() == MachineRepresentation::kTaggedPointer);
895 constant_object = isolate()->factory()->NewNumber(constant.ToFloat32()); 902 constant_object = isolate()->factory()->NewNumber(constant.ToFloat32());
896 break; 903 break;
897 case Constant::kFloat64: 904 case Constant::kFloat64:
898 DCHECK(type.representation() == MachineRepresentation::kFloat64 || 905 DCHECK(type.representation() == MachineRepresentation::kFloat64 ||
899 type.representation() == MachineRepresentation::kTagged); 906 type.representation() == MachineRepresentation::kTagged ||
907 type.representation() == MachineRepresentation::kTaggedPointer);
900 constant_object = isolate()->factory()->NewNumber(constant.ToFloat64()); 908 constant_object = isolate()->factory()->NewNumber(constant.ToFloat64());
901 break; 909 break;
902 case Constant::kHeapObject: 910 case Constant::kHeapObject:
903 DCHECK(type.representation() == MachineRepresentation::kTagged); 911 DCHECK(type.representation() == MachineRepresentation::kTagged ||
912 type.representation() == MachineRepresentation::kTaggedPointer);
904 constant_object = constant.ToHeapObject(); 913 constant_object = constant.ToHeapObject();
905 break; 914 break;
906 default: 915 default:
907 CHECK(false); 916 CHECK(false);
908 } 917 }
909 if (constant_object.is_identical_to(info()->closure())) { 918 if (constant_object.is_identical_to(info()->closure())) {
910 translation->StoreJSFrameFunction(); 919 translation->StoreJSFrameFunction();
911 } else { 920 } else {
912 int literal_id = DefineDeoptimizationLiteral(constant_object); 921 int literal_id = DefineDeoptimizationLiteral(constant_object);
913 translation->StoreLiteral(literal_id); 922 translation->StoreLiteral(literal_id);
(...skipping 22 matching lines...) Expand all
936 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { 945 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) {
937 gen->ools_ = this; 946 gen->ools_ = this;
938 } 947 }
939 948
940 949
941 OutOfLineCode::~OutOfLineCode() {} 950 OutOfLineCode::~OutOfLineCode() {}
942 951
943 } // namespace compiler 952 } // namespace compiler
944 } // namespace internal 953 } // namespace internal
945 } // namespace v8 954 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.cc ('k') | src/compiler/ia32/instruction-selector-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698