OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 3147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3158 const bool needs_writable_input = (value()->Type()->ToCid() != kDoubleCid); | 3158 const bool needs_writable_input = (value()->Type()->ToCid() != kDoubleCid); |
3159 summary->set_in(0, needs_writable_input | 3159 summary->set_in(0, needs_writable_input |
3160 ? Location::WritableRegister() | 3160 ? Location::WritableRegister() |
3161 : Location::RequiresRegister()); | 3161 : Location::RequiresRegister()); |
3162 summary->set_out(0, Location::RequiresFpuRegister()); | 3162 summary->set_out(0, Location::RequiresFpuRegister()); |
3163 return summary; | 3163 return summary; |
3164 } | 3164 } |
3165 | 3165 |
3166 | 3166 |
3167 void UnboxDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3167 void UnboxDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
3168 const intptr_t value_cid = value()->Type()->ToCid(); | 3168 CompileType* value_type = value()->Type(); |
| 3169 const intptr_t value_cid = value_type->ToCid(); |
3169 const Register value = locs()->in(0).reg(); | 3170 const Register value = locs()->in(0).reg(); |
3170 const XmmRegister result = locs()->out(0).fpu_reg(); | 3171 const XmmRegister result = locs()->out(0).fpu_reg(); |
3171 | 3172 |
3172 if (value_cid == kDoubleCid) { | 3173 if (value_cid == kDoubleCid) { |
3173 __ movsd(result, FieldAddress(value, Double::value_offset())); | 3174 __ movsd(result, FieldAddress(value, Double::value_offset())); |
3174 } else if (value_cid == kSmiCid) { | 3175 } else if (value_cid == kSmiCid) { |
3175 __ SmiUntag(value); // Untag input before conversion. | 3176 __ SmiUntag(value); // Untag input before conversion. |
3176 __ cvtsi2sd(result, value); | 3177 __ cvtsi2sd(result, value); |
3177 } else { | 3178 } else { |
3178 Label* deopt = compiler->AddDeoptStub(deopt_id_, | 3179 Label* deopt = compiler->AddDeoptStub(deopt_id_, |
3179 ICData::kDeoptBinaryDoubleOp); | 3180 ICData::kDeoptBinaryDoubleOp); |
3180 Label is_smi, done; | 3181 if (value_type->is_nullable() && |
3181 __ testq(value, Immediate(kSmiTagMask)); | 3182 (value_type->ToNullableCid() == kDoubleCid)) { |
3182 __ j(ZERO, &is_smi); | 3183 const Immediate& raw_null = |
3183 __ CompareClassId(value, kDoubleCid); | 3184 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
3184 __ j(NOT_EQUAL, deopt); | 3185 __ cmpq(value, raw_null); |
3185 __ movsd(result, FieldAddress(value, Double::value_offset())); | 3186 __ j(EQUAL, deopt); |
3186 __ jmp(&done); | 3187 // It must be double now. |
3187 __ Bind(&is_smi); | 3188 __ movsd(result, FieldAddress(value, Double::value_offset())); |
3188 __ SmiUntag(value); | 3189 } else { |
3189 __ cvtsi2sd(result, value); | 3190 Label is_smi, done; |
3190 __ Bind(&done); | 3191 __ testq(value, Immediate(kSmiTagMask)); |
| 3192 __ j(ZERO, &is_smi); |
| 3193 __ CompareClassId(value, kDoubleCid); |
| 3194 __ j(NOT_EQUAL, deopt); |
| 3195 __ movsd(result, FieldAddress(value, Double::value_offset())); |
| 3196 __ jmp(&done); |
| 3197 __ Bind(&is_smi); |
| 3198 __ SmiUntag(value); |
| 3199 __ cvtsi2sd(result, value); |
| 3200 __ Bind(&done); |
| 3201 } |
3191 } | 3202 } |
3192 } | 3203 } |
3193 | 3204 |
3194 | 3205 |
3195 LocationSummary* BoxFloat32x4Instr::MakeLocationSummary(bool opt) const { | 3206 LocationSummary* BoxFloat32x4Instr::MakeLocationSummary(bool opt) const { |
3196 const intptr_t kNumInputs = 1; | 3207 const intptr_t kNumInputs = 1; |
3197 const intptr_t kNumTemps = 0; | 3208 const intptr_t kNumTemps = 0; |
3198 LocationSummary* summary = | 3209 LocationSummary* summary = |
3199 new LocationSummary(kNumInputs, | 3210 new LocationSummary(kNumInputs, |
3200 kNumTemps, | 3211 kNumTemps, |
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5589 PcDescriptors::kOther, | 5600 PcDescriptors::kOther, |
5590 locs()); | 5601 locs()); |
5591 __ Drop(ArgumentCount()); // Discard arguments. | 5602 __ Drop(ArgumentCount()); // Discard arguments. |
5592 } | 5603 } |
5593 | 5604 |
5594 } // namespace dart | 5605 } // namespace dart |
5595 | 5606 |
5596 #undef __ | 5607 #undef __ |
5597 | 5608 |
5598 #endif // defined TARGET_ARCH_X64 | 5609 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |