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