| 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/osr.h" | 10 #include "src/compiler/osr.h" |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 __ AssertZeroExtended(i.OutputRegister()); | 1020 __ AssertZeroExtended(i.OutputRegister()); |
| 1021 break; | 1021 break; |
| 1022 } | 1022 } |
| 1023 case kSSEFloat64ToInt64: | 1023 case kSSEFloat64ToInt64: |
| 1024 if (instr->InputAt(0)->IsDoubleRegister()) { | 1024 if (instr->InputAt(0)->IsDoubleRegister()) { |
| 1025 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0)); | 1025 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0)); |
| 1026 } else { | 1026 } else { |
| 1027 __ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0)); | 1027 __ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0)); |
| 1028 } | 1028 } |
| 1029 break; | 1029 break; |
| 1030 case kSSEFloat64ToUint64: { |
| 1031 // There does not exist a Float64ToUint64 instruction, so we have to use |
| 1032 // the Float64ToInt64 instruction. |
| 1033 if (instr->InputAt(0)->IsDoubleRegister()) { |
| 1034 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0)); |
| 1035 } else { |
| 1036 __ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0)); |
| 1037 } |
| 1038 // Check if the result of the Float64ToInt64 conversion is positive, we |
| 1039 // are already done. |
| 1040 __ testq(i.OutputRegister(), i.OutputRegister()); |
| 1041 Label done; |
| 1042 __ j(positive, &done); |
| 1043 // The result of the first conversion was negative, which means that the |
| 1044 // input value was not within the positive int64 range. We subtract 2^64 |
| 1045 // and convert it again to see if it is within the uint64 range. |
| 1046 __ Move(kScratchDoubleReg, -9223372036854775808.0); |
| 1047 if (instr->InputAt(0)->IsDoubleRegister()) { |
| 1048 __ addsd(kScratchDoubleReg, i.InputDoubleRegister(0)); |
| 1049 } else { |
| 1050 __ addsd(kScratchDoubleReg, i.InputOperand(0)); |
| 1051 } |
| 1052 __ Cvttsd2siq(i.OutputRegister(), kScratchDoubleReg); |
| 1053 __ testq(i.OutputRegister(), i.OutputRegister()); |
| 1054 // The only possible negative value here is 0x80000000000000000, which is |
| 1055 // used on x64 to indicate an integer overflow. |
| 1056 __ j(negative, &done); |
| 1057 // The input value is within uint64 range and the second conversion worked |
| 1058 // successfully, but we still have to undo the subtraction we did |
| 1059 // earlier. |
| 1060 __ movq(kScratchRegister, Immediate(1)); |
| 1061 __ shlq(kScratchRegister, Immediate(63)); |
| 1062 __ orq(i.OutputRegister(), kScratchRegister); |
| 1063 __ bind(&done); |
| 1064 break; |
| 1065 } |
| 1030 case kSSEInt32ToFloat64: | 1066 case kSSEInt32ToFloat64: |
| 1031 if (instr->InputAt(0)->IsRegister()) { | 1067 if (instr->InputAt(0)->IsRegister()) { |
| 1032 __ Cvtlsi2sd(i.OutputDoubleRegister(), i.InputRegister(0)); | 1068 __ Cvtlsi2sd(i.OutputDoubleRegister(), i.InputRegister(0)); |
| 1033 } else { | 1069 } else { |
| 1034 __ Cvtlsi2sd(i.OutputDoubleRegister(), i.InputOperand(0)); | 1070 __ Cvtlsi2sd(i.OutputDoubleRegister(), i.InputOperand(0)); |
| 1035 } | 1071 } |
| 1036 break; | 1072 break; |
| 1037 case kSSEInt64ToFloat32: | 1073 case kSSEInt64ToFloat32: |
| 1038 if (instr->InputAt(0)->IsRegister()) { | 1074 if (instr->InputAt(0)->IsRegister()) { |
| 1039 __ Cvtqsi2ss(i.OutputDoubleRegister(), i.InputRegister(0)); | 1075 __ Cvtqsi2ss(i.OutputDoubleRegister(), i.InputRegister(0)); |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 1976 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 1941 __ Nop(padding_size); | 1977 __ Nop(padding_size); |
| 1942 } | 1978 } |
| 1943 } | 1979 } |
| 1944 | 1980 |
| 1945 #undef __ | 1981 #undef __ |
| 1946 | 1982 |
| 1947 } // namespace compiler | 1983 } // namespace compiler |
| 1948 } // namespace internal | 1984 } // namespace internal |
| 1949 } // namespace v8 | 1985 } // namespace v8 |
| OLD | NEW |