| 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/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
| 8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 Immediate64 ToImmediate64(InstructionOperand* operand) { | 68 Immediate64 ToImmediate64(InstructionOperand* operand) { |
| 69 Constant constant = ToConstant(operand); | 69 Constant constant = ToConstant(operand); |
| 70 Immediate64 immediate; | 70 Immediate64 immediate; |
| 71 immediate.value = 0xbeefdeaddeefbeed; | 71 immediate.value = 0xbeefdeaddeefbeed; |
| 72 immediate.type = kImm64Value; | 72 immediate.type = kImm64Value; |
| 73 switch (constant.type()) { | 73 switch (constant.type()) { |
| 74 case Constant::kInt32: | 74 case Constant::kInt32: |
| 75 case Constant::kInt64: | 75 case Constant::kInt64: |
| 76 immediate.value = constant.ToInt64(); | 76 immediate.value = constant.ToInt64(); |
| 77 return immediate; | 77 return immediate; |
| 78 case Constant::kFloat32: |
| 79 immediate.type = kImm64Handle; |
| 80 immediate.handle = |
| 81 isolate()->factory()->NewNumber(constant.ToFloat32(), TENURED); |
| 82 return immediate; |
| 78 case Constant::kFloat64: | 83 case Constant::kFloat64: |
| 79 immediate.type = kImm64Handle; | 84 immediate.type = kImm64Handle; |
| 80 immediate.handle = | 85 immediate.handle = |
| 81 isolate()->factory()->NewNumber(constant.ToFloat64(), TENURED); | 86 isolate()->factory()->NewNumber(constant.ToFloat64(), TENURED); |
| 82 return immediate; | 87 return immediate; |
| 83 case Constant::kExternalReference: | 88 case Constant::kExternalReference: |
| 84 immediate.type = kImm64Reference; | 89 immediate.type = kImm64Reference; |
| 85 immediate.reference = constant.ToExternalReference(); | 90 immediate.reference = constant.ToExternalReference(); |
| 86 return immediate; | 91 return immediate; |
| 87 case Constant::kHeapObject: | 92 case Constant::kHeapObject: |
| 88 immediate.type = kImm64Handle; | 93 immediate.type = kImm64Handle; |
| 89 immediate.handle = constant.ToHeapObject(); | 94 immediate.handle = constant.ToHeapObject(); |
| 90 return immediate; | 95 return immediate; |
| 91 } | 96 } |
| 92 UNREACHABLE(); | 97 UNREACHABLE(); |
| 93 return immediate; | 98 return immediate; |
| 94 } | 99 } |
| 95 | 100 |
| 96 Immediate ToImmediate(InstructionOperand* operand) { | 101 Immediate ToImmediate(InstructionOperand* operand) { |
| 97 Constant constant = ToConstant(operand); | 102 Constant constant = ToConstant(operand); |
| 98 switch (constant.type()) { | 103 switch (constant.type()) { |
| 99 case Constant::kInt32: | 104 case Constant::kInt32: |
| 100 return Immediate(constant.ToInt32()); | 105 return Immediate(constant.ToInt32()); |
| 101 case Constant::kInt64: | 106 case Constant::kInt64: |
| 107 case Constant::kFloat32: |
| 102 case Constant::kFloat64: | 108 case Constant::kFloat64: |
| 103 case Constant::kExternalReference: | 109 case Constant::kExternalReference: |
| 104 case Constant::kHeapObject: | 110 case Constant::kHeapObject: |
| 105 break; | 111 break; |
| 106 } | 112 } |
| 107 UNREACHABLE(); | 113 UNREACHABLE(); |
| 108 return Immediate(-1); | 114 return Immediate(-1); |
| 109 } | 115 } |
| 110 | 116 |
| 111 Operand ToOperand(InstructionOperand* op, int extra = 0) { | 117 Operand ToOperand(InstructionOperand* op, int extra = 0) { |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 } else { | 900 } else { |
| 895 // Spill on demand to use a temporary register for memory-to-memory | 901 // Spill on demand to use a temporary register for memory-to-memory |
| 896 // moves. | 902 // moves. |
| 897 Register tmp = kScratchRegister; | 903 Register tmp = kScratchRegister; |
| 898 Operand dst = g.ToOperand(destination); | 904 Operand dst = g.ToOperand(destination); |
| 899 __ movq(tmp, src); | 905 __ movq(tmp, src); |
| 900 __ movq(dst, tmp); | 906 __ movq(dst, tmp); |
| 901 } | 907 } |
| 902 } else if (source->IsConstant()) { | 908 } else if (source->IsConstant()) { |
| 903 ConstantOperand* constant_source = ConstantOperand::cast(source); | 909 ConstantOperand* constant_source = ConstantOperand::cast(source); |
| 910 Constant src = g.ToConstant(constant_source); |
| 904 if (destination->IsRegister() || destination->IsStackSlot()) { | 911 if (destination->IsRegister() || destination->IsStackSlot()) { |
| 905 Register dst = destination->IsRegister() ? g.ToRegister(destination) | 912 Register dst = destination->IsRegister() ? g.ToRegister(destination) |
| 906 : kScratchRegister; | 913 : kScratchRegister; |
| 907 Immediate64 imm = g.ToImmediate64(constant_source); | 914 Immediate64 imm = g.ToImmediate64(constant_source); |
| 908 switch (imm.type) { | 915 switch (imm.type) { |
| 909 case kImm64Value: | 916 case kImm64Value: |
| 910 __ Set(dst, imm.value); | 917 __ Set(dst, imm.value); |
| 911 break; | 918 break; |
| 912 case kImm64Reference: | 919 case kImm64Reference: |
| 913 __ Move(dst, imm.reference); | 920 __ Move(dst, imm.reference); |
| 914 break; | 921 break; |
| 915 case kImm64Handle: | 922 case kImm64Handle: |
| 916 __ Move(dst, imm.handle); | 923 __ Move(dst, imm.handle); |
| 917 break; | 924 break; |
| 918 } | 925 } |
| 919 if (destination->IsStackSlot()) { | 926 if (destination->IsStackSlot()) { |
| 920 __ movq(g.ToOperand(destination), kScratchRegister); | 927 __ movq(g.ToOperand(destination), kScratchRegister); |
| 921 } | 928 } |
| 929 } else if (src.type() == Constant::kFloat32) { |
| 930 // TODO(turbofan): Can we do better here? |
| 931 __ movl(kScratchRegister, Immediate(bit_cast<int32_t>(src.ToFloat32()))); |
| 932 if (destination->IsDoubleRegister()) { |
| 933 XMMRegister dst = g.ToDoubleRegister(destination); |
| 934 __ movq(dst, kScratchRegister); |
| 935 } else { |
| 936 DCHECK(destination->IsDoubleStackSlot()); |
| 937 Operand dst = g.ToOperand(destination); |
| 938 __ movl(dst, kScratchRegister); |
| 939 } |
| 922 } else { | 940 } else { |
| 923 __ movq(kScratchRegister, | 941 DCHECK_EQ(Constant::kFloat64, src.type()); |
| 924 bit_cast<uint64_t, double>(g.ToDouble(constant_source))); | 942 __ movq(kScratchRegister, bit_cast<int64_t>(src.ToFloat64())); |
| 925 if (destination->IsDoubleRegister()) { | 943 if (destination->IsDoubleRegister()) { |
| 926 __ movq(g.ToDoubleRegister(destination), kScratchRegister); | 944 __ movq(g.ToDoubleRegister(destination), kScratchRegister); |
| 927 } else { | 945 } else { |
| 928 DCHECK(destination->IsDoubleStackSlot()); | 946 DCHECK(destination->IsDoubleStackSlot()); |
| 929 __ movq(g.ToOperand(destination), kScratchRegister); | 947 __ movq(g.ToOperand(destination), kScratchRegister); |
| 930 } | 948 } |
| 931 } | 949 } |
| 932 } else if (source->IsDoubleRegister()) { | 950 } else if (source->IsDoubleRegister()) { |
| 933 XMMRegister src = g.ToDoubleRegister(source); | 951 XMMRegister src = g.ToDoubleRegister(source); |
| 934 if (destination->IsDoubleRegister()) { | 952 if (destination->IsDoubleRegister()) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 } | 1035 } |
| 1018 } | 1036 } |
| 1019 MarkLazyDeoptSite(); | 1037 MarkLazyDeoptSite(); |
| 1020 } | 1038 } |
| 1021 | 1039 |
| 1022 #undef __ | 1040 #undef __ |
| 1023 | 1041 |
| 1024 } // namespace internal | 1042 } // namespace internal |
| 1025 } // namespace compiler | 1043 } // namespace compiler |
| 1026 } // namespace v8 | 1044 } // namespace v8 |
| OLD | NEW |