| 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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 | 1125 |
| 1126 CompileType LoadIndexedInstr::ComputeType() const { | 1126 CompileType LoadIndexedInstr::ComputeType() const { |
| 1127 switch (class_id_) { | 1127 switch (class_id_) { |
| 1128 case kArrayCid: | 1128 case kArrayCid: |
| 1129 case kImmutableArrayCid: | 1129 case kImmutableArrayCid: |
| 1130 return CompileType::Dynamic(); | 1130 return CompileType::Dynamic(); |
| 1131 | 1131 |
| 1132 case kTypedDataFloat32ArrayCid: | 1132 case kTypedDataFloat32ArrayCid: |
| 1133 case kTypedDataFloat64ArrayCid: | 1133 case kTypedDataFloat64ArrayCid: |
| 1134 return CompileType::FromCid(kDoubleCid); | 1134 return CompileType::FromCid(kDoubleCid); |
| 1135 case kTypedDataFloat32x4ArrayCid: |
| 1136 return CompileType::FromCid(kFloat32x4Cid); |
| 1135 | 1137 |
| 1136 case kTypedDataInt8ArrayCid: | 1138 case kTypedDataInt8ArrayCid: |
| 1137 case kTypedDataUint8ArrayCid: | 1139 case kTypedDataUint8ArrayCid: |
| 1138 case kTypedDataUint8ClampedArrayCid: | 1140 case kTypedDataUint8ClampedArrayCid: |
| 1139 case kExternalTypedDataUint8ArrayCid: | 1141 case kExternalTypedDataUint8ArrayCid: |
| 1140 case kExternalTypedDataUint8ClampedArrayCid: | 1142 case kExternalTypedDataUint8ClampedArrayCid: |
| 1141 case kTypedDataInt16ArrayCid: | 1143 case kTypedDataInt16ArrayCid: |
| 1142 case kTypedDataUint16ArrayCid: | 1144 case kTypedDataUint16ArrayCid: |
| 1143 case kOneByteStringCid: | 1145 case kOneByteStringCid: |
| 1144 case kTwoByteStringCid: | 1146 case kTwoByteStringCid: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1165 case kTypedDataInt16ArrayCid: | 1167 case kTypedDataInt16ArrayCid: |
| 1166 case kTypedDataUint16ArrayCid: | 1168 case kTypedDataUint16ArrayCid: |
| 1167 case kOneByteStringCid: | 1169 case kOneByteStringCid: |
| 1168 case kTwoByteStringCid: | 1170 case kTwoByteStringCid: |
| 1169 case kTypedDataInt32ArrayCid: | 1171 case kTypedDataInt32ArrayCid: |
| 1170 case kTypedDataUint32ArrayCid: | 1172 case kTypedDataUint32ArrayCid: |
| 1171 return kTagged; | 1173 return kTagged; |
| 1172 case kTypedDataFloat32ArrayCid: | 1174 case kTypedDataFloat32ArrayCid: |
| 1173 case kTypedDataFloat64ArrayCid: | 1175 case kTypedDataFloat64ArrayCid: |
| 1174 return kUnboxedDouble; | 1176 return kUnboxedDouble; |
| 1177 case kTypedDataFloat32x4ArrayCid: |
| 1178 return kUnboxedFloat32x4; |
| 1175 default: | 1179 default: |
| 1176 UNIMPLEMENTED(); | 1180 UNIMPLEMENTED(); |
| 1177 return kTagged; | 1181 return kTagged; |
| 1178 } | 1182 } |
| 1179 } | 1183 } |
| 1180 | 1184 |
| 1181 | 1185 |
| 1182 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const { | 1186 LocationSummary* LoadIndexedInstr::MakeLocationSummary() const { |
| 1183 const intptr_t kNumInputs = 2; | 1187 const intptr_t kNumInputs = 2; |
| 1184 const intptr_t kNumTemps = 0; | 1188 const intptr_t kNumTemps = 0; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 } else { | 1228 } else { |
| 1225 ASSERT(this->array()->definition()->representation() == kTagged); | 1229 ASSERT(this->array()->definition()->representation() == kTagged); |
| 1226 element_address = index.IsRegister() | 1230 element_address = index.IsRegister() |
| 1227 ? FlowGraphCompiler::ElementAddressForRegIndex( | 1231 ? FlowGraphCompiler::ElementAddressForRegIndex( |
| 1228 class_id(), index_scale(), array, index.reg()) | 1232 class_id(), index_scale(), array, index.reg()) |
| 1229 : FlowGraphCompiler::ElementAddressForIntIndex( | 1233 : FlowGraphCompiler::ElementAddressForIntIndex( |
| 1230 class_id(), index_scale(), array, | 1234 class_id(), index_scale(), array, |
| 1231 Smi::Cast(index.constant()).Value()); | 1235 Smi::Cast(index.constant()).Value()); |
| 1232 } | 1236 } |
| 1233 | 1237 |
| 1234 if (representation() == kUnboxedDouble) { | 1238 if ((representation() == kUnboxedDouble) || |
| 1239 (representation() == kUnboxedFloat32x4)) { |
| 1235 if ((index_scale() == 1) && index.IsRegister()) { | 1240 if ((index_scale() == 1) && index.IsRegister()) { |
| 1236 __ SmiUntag(index.reg()); | 1241 __ SmiUntag(index.reg()); |
| 1237 } | 1242 } |
| 1238 | 1243 |
| 1239 XmmRegister result = locs()->out().fpu_reg(); | 1244 XmmRegister result = locs()->out().fpu_reg(); |
| 1240 if (class_id() == kTypedDataFloat32ArrayCid) { | 1245 if (class_id() == kTypedDataFloat32ArrayCid) { |
| 1241 // Load single precision float. | 1246 // Load single precision float. |
| 1242 __ movss(result, element_address); | 1247 __ movss(result, element_address); |
| 1243 // Promote to double. | 1248 // Promote to double. |
| 1244 __ cvtss2sd(result, locs()->out().fpu_reg()); | 1249 __ cvtss2sd(result, locs()->out().fpu_reg()); |
| 1250 } else if (class_id() == kTypedDataFloat64ArrayCid) { |
| 1251 __ movsd(result, element_address); |
| 1245 } else { | 1252 } else { |
| 1246 ASSERT(class_id() == kTypedDataFloat64ArrayCid); | 1253 ASSERT(class_id() == kTypedDataFloat32x4ArrayCid); |
| 1247 __ movsd(result, element_address); | 1254 __ movups(result, element_address); |
| 1248 } | 1255 } |
| 1249 return; | 1256 return; |
| 1250 } | 1257 } |
| 1251 | 1258 |
| 1252 if ((index_scale() == 1) && index.IsRegister()) { | 1259 if ((index_scale() == 1) && index.IsRegister()) { |
| 1253 __ SmiUntag(index.reg()); | 1260 __ SmiUntag(index.reg()); |
| 1254 } | 1261 } |
| 1255 Register result = locs()->out().reg(); | 1262 Register result = locs()->out().reg(); |
| 1256 switch (class_id()) { | 1263 switch (class_id()) { |
| 1257 case kTypedDataInt8ArrayCid: | 1264 case kTypedDataInt8ArrayCid: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 case kTypedDataUint8ClampedArrayCid: | 1311 case kTypedDataUint8ClampedArrayCid: |
| 1305 case kExternalTypedDataUint8ClampedArrayCid: | 1312 case kExternalTypedDataUint8ClampedArrayCid: |
| 1306 case kTypedDataInt16ArrayCid: | 1313 case kTypedDataInt16ArrayCid: |
| 1307 case kTypedDataUint16ArrayCid: | 1314 case kTypedDataUint16ArrayCid: |
| 1308 case kTypedDataInt32ArrayCid: | 1315 case kTypedDataInt32ArrayCid: |
| 1309 case kTypedDataUint32ArrayCid: | 1316 case kTypedDataUint32ArrayCid: |
| 1310 return kTagged; | 1317 return kTagged; |
| 1311 case kTypedDataFloat32ArrayCid: | 1318 case kTypedDataFloat32ArrayCid: |
| 1312 case kTypedDataFloat64ArrayCid: | 1319 case kTypedDataFloat64ArrayCid: |
| 1313 return kUnboxedDouble; | 1320 return kUnboxedDouble; |
| 1321 case kTypedDataFloat32x4ArrayCid: |
| 1322 return kUnboxedFloat32x4; |
| 1314 default: | 1323 default: |
| 1315 UNIMPLEMENTED(); | 1324 UNIMPLEMENTED(); |
| 1316 return kTagged; | 1325 return kTagged; |
| 1317 } | 1326 } |
| 1318 } | 1327 } |
| 1319 | 1328 |
| 1320 | 1329 |
| 1321 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { | 1330 LocationSummary* StoreIndexedInstr::MakeLocationSummary() const { |
| 1322 const intptr_t kNumInputs = 3; | 1331 const intptr_t kNumInputs = 3; |
| 1323 const intptr_t kNumTemps = 0; | 1332 const intptr_t kNumTemps = 0; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 locs->set_in(2, Location::WritableRegister()); | 1369 locs->set_in(2, Location::WritableRegister()); |
| 1361 break; | 1370 break; |
| 1362 case kTypedDataFloat32ArrayCid: | 1371 case kTypedDataFloat32ArrayCid: |
| 1363 // Need temp register for float-to-double conversion. | 1372 // Need temp register for float-to-double conversion. |
| 1364 locs->AddTemp(Location::RequiresFpuRegister()); | 1373 locs->AddTemp(Location::RequiresFpuRegister()); |
| 1365 // Fall through. | 1374 // Fall through. |
| 1366 case kTypedDataFloat64ArrayCid: | 1375 case kTypedDataFloat64ArrayCid: |
| 1367 // TODO(srdjan): Support Float64 constants. | 1376 // TODO(srdjan): Support Float64 constants. |
| 1368 locs->set_in(2, Location::RequiresFpuRegister()); | 1377 locs->set_in(2, Location::RequiresFpuRegister()); |
| 1369 break; | 1378 break; |
| 1379 case kTypedDataFloat32x4ArrayCid: |
| 1380 locs->set_in(2, Location::RequiresFpuRegister()); |
| 1381 break; |
| 1370 default: | 1382 default: |
| 1371 UNREACHABLE(); | 1383 UNREACHABLE(); |
| 1372 return NULL; | 1384 return NULL; |
| 1373 } | 1385 } |
| 1374 return locs; | 1386 return locs; |
| 1375 } | 1387 } |
| 1376 | 1388 |
| 1377 | 1389 |
| 1378 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1390 void StoreIndexedInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1379 Register array = locs()->in(0).reg(); | 1391 Register array = locs()->in(0).reg(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 } | 1485 } |
| 1474 case kTypedDataFloat32ArrayCid: | 1486 case kTypedDataFloat32ArrayCid: |
| 1475 // Convert to single precision. | 1487 // Convert to single precision. |
| 1476 __ cvtsd2ss(locs()->temp(0).fpu_reg(), locs()->in(2).fpu_reg()); | 1488 __ cvtsd2ss(locs()->temp(0).fpu_reg(), locs()->in(2).fpu_reg()); |
| 1477 // Store. | 1489 // Store. |
| 1478 __ movss(element_address, locs()->temp(0).fpu_reg()); | 1490 __ movss(element_address, locs()->temp(0).fpu_reg()); |
| 1479 break; | 1491 break; |
| 1480 case kTypedDataFloat64ArrayCid: | 1492 case kTypedDataFloat64ArrayCid: |
| 1481 __ movsd(element_address, locs()->in(2).fpu_reg()); | 1493 __ movsd(element_address, locs()->in(2).fpu_reg()); |
| 1482 break; | 1494 break; |
| 1495 case kTypedDataFloat32x4ArrayCid: |
| 1496 __ movups(element_address, locs()->in(2).fpu_reg()); |
| 1497 break; |
| 1483 default: | 1498 default: |
| 1484 UNREACHABLE(); | 1499 UNREACHABLE(); |
| 1485 } | 1500 } |
| 1486 } | 1501 } |
| 1487 | 1502 |
| 1488 | 1503 |
| 1489 LocationSummary* GuardFieldInstr::MakeLocationSummary() const { | 1504 LocationSummary* GuardFieldInstr::MakeLocationSummary() const { |
| 1490 const intptr_t kNumInputs = 1; | 1505 const intptr_t kNumInputs = 1; |
| 1491 LocationSummary* summary = | 1506 LocationSummary* summary = |
| 1492 new LocationSummary(kNumInputs, 0, LocationSummary::kNoCall); | 1507 new LocationSummary(kNumInputs, 0, LocationSummary::kNoCall); |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 __ Bind(entry_label()); | 2636 __ Bind(entry_label()); |
| 2622 const Class& double_class = compiler->double_class(); | 2637 const Class& double_class = compiler->double_class(); |
| 2623 const Code& stub = | 2638 const Code& stub = |
| 2624 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); | 2639 Code::Handle(StubCode::GetAllocationStubForClass(double_class)); |
| 2625 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); | 2640 const ExternalLabel label(double_class.ToCString(), stub.EntryPoint()); |
| 2626 | 2641 |
| 2627 LocationSummary* locs = instruction_->locs(); | 2642 LocationSummary* locs = instruction_->locs(); |
| 2628 locs->live_registers()->Remove(locs->out()); | 2643 locs->live_registers()->Remove(locs->out()); |
| 2629 | 2644 |
| 2630 compiler->SaveLiveRegisters(locs); | 2645 compiler->SaveLiveRegisters(locs); |
| 2631 compiler->GenerateCall(instruction_->token_pos(), | 2646 compiler->GenerateCall(Scanner::kDummyTokenIndex, // No token position. |
| 2632 &label, | 2647 &label, |
| 2633 PcDescriptors::kOther, | 2648 PcDescriptors::kOther, |
| 2634 locs); | 2649 locs); |
| 2635 if (RAX != locs->out().reg()) __ movq(locs->out().reg(), RAX); | 2650 __ MoveRegister(locs->out().reg(), RAX); |
| 2636 compiler->RestoreLiveRegisters(locs); | 2651 compiler->RestoreLiveRegisters(locs); |
| 2637 | 2652 |
| 2638 __ jmp(exit_label()); | 2653 __ jmp(exit_label()); |
| 2639 } | 2654 } |
| 2640 | 2655 |
| 2641 private: | 2656 private: |
| 2642 BoxDoubleInstr* instruction_; | 2657 BoxDoubleInstr* instruction_; |
| 2643 }; | 2658 }; |
| 2644 | 2659 |
| 2645 | 2660 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2693 __ movsd(result, FieldAddress(value, Double::value_offset())); | 2708 __ movsd(result, FieldAddress(value, Double::value_offset())); |
| 2694 __ jmp(&done); | 2709 __ jmp(&done); |
| 2695 __ Bind(&is_smi); | 2710 __ Bind(&is_smi); |
| 2696 __ SmiUntag(value); | 2711 __ SmiUntag(value); |
| 2697 __ cvtsi2sd(result, value); | 2712 __ cvtsi2sd(result, value); |
| 2698 __ Bind(&done); | 2713 __ Bind(&done); |
| 2699 } | 2714 } |
| 2700 } | 2715 } |
| 2701 | 2716 |
| 2702 | 2717 |
| 2718 LocationSummary* BoxFloat32x4Instr::MakeLocationSummary() const { |
| 2719 const intptr_t kNumInputs = 1; |
| 2720 const intptr_t kNumTemps = 0; |
| 2721 LocationSummary* summary = |
| 2722 new LocationSummary(kNumInputs, |
| 2723 kNumTemps, |
| 2724 LocationSummary::kCallOnSlowPath); |
| 2725 summary->set_in(0, Location::RequiresFpuRegister()); |
| 2726 summary->set_out(Location::RequiresRegister()); |
| 2727 return summary; |
| 2728 } |
| 2729 |
| 2730 |
| 2731 class BoxFloat32x4SlowPath : public SlowPathCode { |
| 2732 public: |
| 2733 explicit BoxFloat32x4SlowPath(BoxFloat32x4Instr* instruction) |
| 2734 : instruction_(instruction) { } |
| 2735 |
| 2736 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2737 __ Comment("BoxFloat32x4SlowPath"); |
| 2738 __ Bind(entry_label()); |
| 2739 const Class& float32x4_class = compiler->float32x4_class(); |
| 2740 const Code& stub = |
| 2741 Code::Handle(StubCode::GetAllocationStubForClass(float32x4_class)); |
| 2742 const ExternalLabel label(float32x4_class.ToCString(), stub.EntryPoint()); |
| 2743 |
| 2744 LocationSummary* locs = instruction_->locs(); |
| 2745 locs->live_registers()->Remove(locs->out()); |
| 2746 |
| 2747 compiler->SaveLiveRegisters(locs); |
| 2748 compiler->GenerateCall(Scanner::kDummyTokenIndex, // No token position. |
| 2749 &label, |
| 2750 PcDescriptors::kOther, |
| 2751 locs); |
| 2752 __ MoveRegister(locs->out().reg(), RAX); |
| 2753 compiler->RestoreLiveRegisters(locs); |
| 2754 |
| 2755 __ jmp(exit_label()); |
| 2756 } |
| 2757 |
| 2758 private: |
| 2759 BoxFloat32x4Instr* instruction_; |
| 2760 }; |
| 2761 |
| 2762 |
| 2763 void BoxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2764 BoxFloat32x4SlowPath* slow_path = new BoxFloat32x4SlowPath(this); |
| 2765 compiler->AddSlowPathCode(slow_path); |
| 2766 |
| 2767 Register out_reg = locs()->out().reg(); |
| 2768 XmmRegister value = locs()->in(0).fpu_reg(); |
| 2769 |
| 2770 __ TryAllocate(compiler->float32x4_class(), |
| 2771 slow_path->entry_label(), |
| 2772 Assembler::kFarJump, |
| 2773 out_reg); |
| 2774 __ Bind(slow_path->exit_label()); |
| 2775 __ movups(FieldAddress(out_reg, Float32x4::value_offset()), value); |
| 2776 } |
| 2777 |
| 2778 |
| 2779 LocationSummary* UnboxFloat32x4Instr::MakeLocationSummary() const { |
| 2780 const intptr_t kNumInputs = 1; |
| 2781 const intptr_t kNumTemps = 0; |
| 2782 LocationSummary* summary = |
| 2783 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2784 summary->set_in(0, Location::RequiresRegister()); |
| 2785 summary->set_out(Location::RequiresFpuRegister()); |
| 2786 return summary; |
| 2787 } |
| 2788 |
| 2789 |
| 2790 void UnboxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2791 const intptr_t value_cid = value()->Type()->ToCid(); |
| 2792 const Register value = locs()->in(0).reg(); |
| 2793 const XmmRegister result = locs()->out().fpu_reg(); |
| 2794 |
| 2795 ASSERT(value_cid == kFloat32x4Cid); |
| 2796 __ movups(result, FieldAddress(value, Float32x4::value_offset())); |
| 2797 } |
| 2798 |
| 2799 |
| 2703 LocationSummary* BinaryDoubleOpInstr::MakeLocationSummary() const { | 2800 LocationSummary* BinaryDoubleOpInstr::MakeLocationSummary() const { |
| 2704 const intptr_t kNumInputs = 2; | 2801 const intptr_t kNumInputs = 2; |
| 2705 const intptr_t kNumTemps = 0; | 2802 const intptr_t kNumTemps = 0; |
| 2706 LocationSummary* summary = | 2803 LocationSummary* summary = |
| 2707 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2804 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2708 summary->set_in(0, Location::RequiresFpuRegister()); | 2805 summary->set_in(0, Location::RequiresFpuRegister()); |
| 2709 summary->set_in(1, Location::RequiresFpuRegister()); | 2806 summary->set_in(1, Location::RequiresFpuRegister()); |
| 2710 summary->set_out(Location::SameAsFirstInput()); | 2807 summary->set_out(Location::SameAsFirstInput()); |
| 2711 return summary; | 2808 return summary; |
| 2712 } | 2809 } |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3477 PcDescriptors::kOther, | 3574 PcDescriptors::kOther, |
| 3478 locs()); | 3575 locs()); |
| 3479 __ Drop(2); // Discard type arguments and receiver. | 3576 __ Drop(2); // Discard type arguments and receiver. |
| 3480 } | 3577 } |
| 3481 | 3578 |
| 3482 } // namespace dart | 3579 } // namespace dart |
| 3483 | 3580 |
| 3484 #undef __ | 3581 #undef __ |
| 3485 | 3582 |
| 3486 #endif // defined TARGET_ARCH_X64 | 3583 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |