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 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 } | 1045 } |
1046 case kSSEFloat32ToInt64: | 1046 case kSSEFloat32ToInt64: |
1047 if (instr->InputAt(0)->IsDoubleRegister()) { | 1047 if (instr->InputAt(0)->IsDoubleRegister()) { |
1048 __ Cvttss2siq(i.OutputRegister(), i.InputDoubleRegister(0)); | 1048 __ Cvttss2siq(i.OutputRegister(), i.InputDoubleRegister(0)); |
1049 } else { | 1049 } else { |
1050 __ Cvttss2siq(i.OutputRegister(), i.InputOperand(0)); | 1050 __ Cvttss2siq(i.OutputRegister(), i.InputOperand(0)); |
1051 } | 1051 } |
1052 break; | 1052 break; |
1053 case kSSEFloat64ToInt64: | 1053 case kSSEFloat64ToInt64: |
1054 if (instr->InputAt(0)->IsDoubleRegister()) { | 1054 if (instr->InputAt(0)->IsDoubleRegister()) { |
1055 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0)); | 1055 __ Cvttsd2siq(i.OutputRegister(0), i.InputDoubleRegister(0)); |
1056 } else { | 1056 } else { |
1057 __ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0)); | 1057 __ Cvttsd2siq(i.OutputRegister(0), i.InputOperand(0)); |
| 1058 } |
| 1059 if (instr->OutputCount() > 1) { |
| 1060 __ Set(i.OutputRegister(1), 0x8000000000000000); |
| 1061 __ subq(i.OutputRegister(1), i.OutputRegister(0)); |
1058 } | 1062 } |
1059 break; | 1063 break; |
1060 case kSSEFloat32ToUint64: { | 1064 case kSSEFloat32ToUint64: { |
1061 // There does not exist a Float32ToUint64 instruction, so we have to use | 1065 // There does not exist a Float32ToUint64 instruction, so we have to use |
1062 // the Float32ToInt64 instruction. | 1066 // the Float32ToInt64 instruction. |
1063 if (instr->InputAt(0)->IsDoubleRegister()) { | 1067 if (instr->InputAt(0)->IsDoubleRegister()) { |
1064 __ Cvttss2siq(i.OutputRegister(), i.InputDoubleRegister(0)); | 1068 __ Cvttss2siq(i.OutputRegister(), i.InputDoubleRegister(0)); |
1065 } else { | 1069 } else { |
1066 __ Cvttss2siq(i.OutputRegister(), i.InputOperand(0)); | 1070 __ Cvttss2siq(i.OutputRegister(), i.InputOperand(0)); |
1067 } | 1071 } |
(...skipping 12 matching lines...) Expand all Loading... |
1080 __ addss(kScratchDoubleReg, i.InputOperand(0)); | 1084 __ addss(kScratchDoubleReg, i.InputOperand(0)); |
1081 } | 1085 } |
1082 __ Cvttss2siq(i.OutputRegister(), kScratchDoubleReg); | 1086 __ Cvttss2siq(i.OutputRegister(), kScratchDoubleReg); |
1083 __ testq(i.OutputRegister(), i.OutputRegister()); | 1087 __ testq(i.OutputRegister(), i.OutputRegister()); |
1084 // The only possible negative value here is 0x80000000000000000, which is | 1088 // The only possible negative value here is 0x80000000000000000, which is |
1085 // used on x64 to indicate an integer overflow. | 1089 // used on x64 to indicate an integer overflow. |
1086 __ j(negative, &done); | 1090 __ j(negative, &done); |
1087 // The input value is within uint64 range and the second conversion worked | 1091 // The input value is within uint64 range and the second conversion worked |
1088 // successfully, but we still have to undo the subtraction we did | 1092 // successfully, but we still have to undo the subtraction we did |
1089 // earlier. | 1093 // earlier. |
1090 __ movq(kScratchRegister, Immediate(1)); | 1094 __ Set(kScratchRegister, 0x8000000000000000); |
1091 __ shlq(kScratchRegister, Immediate(63)); | |
1092 __ orq(i.OutputRegister(), kScratchRegister); | 1095 __ orq(i.OutputRegister(), kScratchRegister); |
1093 __ bind(&done); | 1096 __ bind(&done); |
1094 break; | 1097 break; |
1095 } | 1098 } |
1096 case kSSEFloat64ToUint64: { | 1099 case kSSEFloat64ToUint64: { |
1097 // 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 |
1098 // the Float64ToInt64 instruction. | 1101 // the Float64ToInt64 instruction. |
1099 if (instr->InputAt(0)->IsDoubleRegister()) { | 1102 if (instr->InputAt(0)->IsDoubleRegister()) { |
1100 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0)); | 1103 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0)); |
1101 } else { | 1104 } else { |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2050 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2048 __ Nop(padding_size); | 2051 __ Nop(padding_size); |
2049 } | 2052 } |
2050 } | 2053 } |
2051 | 2054 |
2052 #undef __ | 2055 #undef __ |
2053 | 2056 |
2054 } // namespace compiler | 2057 } // namespace compiler |
2055 } // namespace internal | 2058 } // namespace internal |
2056 } // namespace v8 | 2059 } // namespace v8 |
OLD | NEW |