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/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 break; | 1097 break; |
1098 } | 1098 } |
1099 case kSSEFloat64ToUint64: { | 1099 case kSSEFloat64ToUint64: { |
1100 // There does not exist a Float64ToUint64 instruction, so we have to use | 1100 // There does not exist a Float64ToUint64 instruction, so we have to use |
1101 // the Float64ToInt64 instruction. | 1101 // the Float64ToInt64 instruction. |
1102 if (instr->InputAt(0)->IsDoubleRegister()) { | 1102 if (instr->InputAt(0)->IsDoubleRegister()) { |
1103 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0)); | 1103 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0)); |
1104 } else { | 1104 } else { |
1105 __ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0)); | 1105 __ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0)); |
1106 } | 1106 } |
| 1107 if (instr->OutputCount() > 1) { |
| 1108 __ Set(i.OutputRegister(1), 0); |
| 1109 } |
1107 // Check if the result of the Float64ToInt64 conversion is positive, we | 1110 // Check if the result of the Float64ToInt64 conversion is positive, we |
1108 // are already done. | 1111 // are already done. |
1109 __ testq(i.OutputRegister(), i.OutputRegister()); | 1112 __ testq(i.OutputRegister(), i.OutputRegister()); |
1110 Label done; | 1113 Label done; |
1111 __ j(positive, &done); | 1114 Label success; |
| 1115 __ j(positive, &success); |
1112 // The result of the first conversion was negative, which means that the | 1116 // The result of the first conversion was negative, which means that the |
1113 // input value was not within the positive int64 range. We subtract 2^64 | 1117 // input value was not within the positive int64 range. We subtract 2^64 |
1114 // and convert it again to see if it is within the uint64 range. | 1118 // and convert it again to see if it is within the uint64 range. |
1115 __ Move(kScratchDoubleReg, -9223372036854775808.0); | 1119 __ Move(kScratchDoubleReg, -9223372036854775808.0); |
1116 if (instr->InputAt(0)->IsDoubleRegister()) { | 1120 if (instr->InputAt(0)->IsDoubleRegister()) { |
1117 __ addsd(kScratchDoubleReg, i.InputDoubleRegister(0)); | 1121 __ addsd(kScratchDoubleReg, i.InputDoubleRegister(0)); |
1118 } else { | 1122 } else { |
1119 __ addsd(kScratchDoubleReg, i.InputOperand(0)); | 1123 __ addsd(kScratchDoubleReg, i.InputOperand(0)); |
1120 } | 1124 } |
1121 __ Cvttsd2siq(i.OutputRegister(), kScratchDoubleReg); | 1125 __ Cvttsd2siq(i.OutputRegister(), kScratchDoubleReg); |
1122 __ testq(i.OutputRegister(), i.OutputRegister()); | 1126 __ testq(i.OutputRegister(), i.OutputRegister()); |
1123 // The only possible negative value here is 0x80000000000000000, which is | 1127 // The only possible negative value here is 0x80000000000000000, which is |
1124 // used on x64 to indicate an integer overflow. | 1128 // used on x64 to indicate an integer overflow. |
1125 __ j(negative, &done); | 1129 __ j(negative, &done); |
1126 // The input value is within uint64 range and the second conversion worked | 1130 // The input value is within uint64 range and the second conversion worked |
1127 // successfully, but we still have to undo the subtraction we did | 1131 // successfully, but we still have to undo the subtraction we did |
1128 // earlier. | 1132 // earlier. |
1129 __ movq(kScratchRegister, Immediate(1)); | 1133 __ Set(kScratchRegister, 0x8000000000000000); |
1130 __ shlq(kScratchRegister, Immediate(63)); | |
1131 __ orq(i.OutputRegister(), kScratchRegister); | 1134 __ orq(i.OutputRegister(), kScratchRegister); |
| 1135 __ bind(&success); |
| 1136 if (instr->OutputCount() > 1) { |
| 1137 __ Set(i.OutputRegister(1), 1); |
| 1138 } |
1132 __ bind(&done); | 1139 __ bind(&done); |
1133 break; | 1140 break; |
1134 } | 1141 } |
1135 case kSSEInt32ToFloat64: | 1142 case kSSEInt32ToFloat64: |
1136 if (instr->InputAt(0)->IsRegister()) { | 1143 if (instr->InputAt(0)->IsRegister()) { |
1137 __ Cvtlsi2sd(i.OutputDoubleRegister(), i.InputRegister(0)); | 1144 __ Cvtlsi2sd(i.OutputDoubleRegister(), i.InputRegister(0)); |
1138 } else { | 1145 } else { |
1139 __ Cvtlsi2sd(i.OutputDoubleRegister(), i.InputOperand(0)); | 1146 __ Cvtlsi2sd(i.OutputDoubleRegister(), i.InputOperand(0)); |
1140 } | 1147 } |
1141 break; | 1148 break; |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2057 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2051 __ Nop(padding_size); | 2058 __ Nop(padding_size); |
2052 } | 2059 } |
2053 } | 2060 } |
2054 | 2061 |
2055 #undef __ | 2062 #undef __ |
2056 | 2063 |
2057 } // namespace compiler | 2064 } // namespace compiler |
2058 } // namespace internal | 2065 } // namespace internal |
2059 } // namespace v8 | 2066 } // namespace v8 |
OLD | NEW |