| 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/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 5623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5634 const intptr_t kNumTemps = 0; | 5634 const intptr_t kNumTemps = 0; |
| 5635 LocationSummary* summary = new (zone) | 5635 LocationSummary* summary = new (zone) |
| 5636 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 5636 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 5637 // Both inputs must be writable because they will be untagged. | 5637 // Both inputs must be writable because they will be untagged. |
| 5638 summary->set_in(0, Location::RegisterLocation(RAX)); | 5638 summary->set_in(0, Location::RegisterLocation(RAX)); |
| 5639 summary->set_in(1, Location::WritableRegister()); | 5639 summary->set_in(1, Location::WritableRegister()); |
| 5640 summary->set_out(0, Location::Pair(Location::RegisterLocation(RAX), | 5640 summary->set_out(0, Location::Pair(Location::RegisterLocation(RAX), |
| 5641 Location::RegisterLocation(RDX))); | 5641 Location::RegisterLocation(RDX))); |
| 5642 return summary; | 5642 return summary; |
| 5643 } | 5643 } |
| 5644 if (kind() == MergedMathInstr::kSinCos) { | |
| 5645 const intptr_t kNumInputs = 1; | |
| 5646 const intptr_t kNumTemps = 1; | |
| 5647 LocationSummary* summary = new (zone) | |
| 5648 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall); | |
| 5649 // Because we always call into the runtime (LocationSummary::kCall) we | |
| 5650 // must specify each input, temp, and output register explicitly. | |
| 5651 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); | |
| 5652 // R13 is chosen because it is callee saved so we do not need to back it | |
| 5653 // up before calling into the runtime. | |
| 5654 summary->set_temp(0, Location::RegisterLocation(R13)); | |
| 5655 summary->set_out(0, Location::Pair(Location::FpuRegisterLocation(XMM2), | |
| 5656 Location::FpuRegisterLocation(XMM3))); | |
| 5657 return summary; | |
| 5658 } | |
| 5659 UNIMPLEMENTED(); | 5644 UNIMPLEMENTED(); |
| 5660 return NULL; | 5645 return NULL; |
| 5661 } | 5646 } |
| 5662 | 5647 |
| 5663 | 5648 |
| 5664 typedef void (*SinCosCFunction)(double x, double* res_sin, double* res_cos); | |
| 5665 | |
| 5666 extern const RuntimeEntry kSinCosRuntimeEntry( | |
| 5667 "libc_sincos", | |
| 5668 reinterpret_cast<RuntimeFunction>(static_cast<SinCosCFunction>(&SinCos)), | |
| 5669 1, | |
| 5670 true, | |
| 5671 true); | |
| 5672 | |
| 5673 | |
| 5674 void MergedMathInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 5649 void MergedMathInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 5675 Label* deopt = NULL; | 5650 Label* deopt = NULL; |
| 5676 if (CanDeoptimize()) { | 5651 if (CanDeoptimize()) { |
| 5677 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinarySmiOp); | 5652 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinarySmiOp); |
| 5678 } | 5653 } |
| 5679 if (kind() == MergedMathInstr::kTruncDivMod) { | 5654 if (kind() == MergedMathInstr::kTruncDivMod) { |
| 5680 Register left = locs()->in(0).reg(); | 5655 Register left = locs()->in(0).reg(); |
| 5681 Register right = locs()->in(1).reg(); | 5656 Register right = locs()->in(1).reg(); |
| 5682 ASSERT(locs()->out(0).IsPairLocation()); | 5657 ASSERT(locs()->out(0).IsPairLocation()); |
| 5683 PairLocation* pair = locs()->out(0).AsPairLocation(); | 5658 PairLocation* pair = locs()->out(0).AsPairLocation(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5757 __ subq(RDX, right); | 5732 __ subq(RDX, right); |
| 5758 } | 5733 } |
| 5759 __ Bind(&all_done); | 5734 __ Bind(&all_done); |
| 5760 | 5735 |
| 5761 __ SmiTag(RAX); | 5736 __ SmiTag(RAX); |
| 5762 __ SmiTag(RDX); | 5737 __ SmiTag(RDX); |
| 5763 // Note that the result of an integer division/modulo of two | 5738 // Note that the result of an integer division/modulo of two |
| 5764 // in-range arguments, cannot create out-of-range result. | 5739 // in-range arguments, cannot create out-of-range result. |
| 5765 return; | 5740 return; |
| 5766 } | 5741 } |
| 5767 if (kind() == MergedMathInstr::kSinCos) { | |
| 5768 ASSERT(locs()->out(0).IsPairLocation()); | |
| 5769 PairLocation* pair = locs()->out(0).AsPairLocation(); | |
| 5770 XmmRegister out1 = pair->At(0).fpu_reg(); | |
| 5771 XmmRegister out2 = pair->At(1).fpu_reg(); | |
| 5772 | |
| 5773 // Save RSP. | |
| 5774 __ movq(locs()->temp(0).reg(), RSP); | |
| 5775 // +-------------------------------+ | |
| 5776 // | double-argument | <- TOS | |
| 5777 // +-------------------------------+ | |
| 5778 // | address-cos-result | +8 | |
| 5779 // +-------------------------------+ | |
| 5780 // | address-sin-result | +16 | |
| 5781 // +-------------------------------+ | |
| 5782 // | double-storage-for-cos-result | +24 | |
| 5783 // +-------------------------------+ | |
| 5784 // | double-storage-for-sin-result | +32 | |
| 5785 // +-------------------------------+ | |
| 5786 // .... | |
| 5787 __ ReserveAlignedFrameSpace(kDoubleSize * 3 + kWordSize * 2); | |
| 5788 __ movsd(Address(RSP, 0), locs()->in(0).fpu_reg()); | |
| 5789 | |
| 5790 __ leaq(RDI, Address(RSP, 2 * kWordSize + kDoubleSize)); | |
| 5791 __ leaq(RSI, Address(RSP, 2 * kWordSize + 2 * kDoubleSize)); | |
| 5792 __ movaps(XMM0, locs()->in(0).fpu_reg()); | |
| 5793 | |
| 5794 __ CallRuntime(kSinCosRuntimeEntry, InputCount()); | |
| 5795 __ movsd(out2, Address(RSP, 2 * kWordSize + kDoubleSize * 2)); // sin. | |
| 5796 __ movsd(out1, Address(RSP, 2 * kWordSize + kDoubleSize)); // cos. | |
| 5797 // Restore RSP. | |
| 5798 __ movq(RSP, locs()->temp(0).reg()); | |
| 5799 | |
| 5800 return; | |
| 5801 } | |
| 5802 UNIMPLEMENTED(); | 5742 UNIMPLEMENTED(); |
| 5803 } | 5743 } |
| 5804 | 5744 |
| 5805 | 5745 |
| 5806 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary( | 5746 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary( |
| 5807 Zone* zone, | 5747 Zone* zone, |
| 5808 bool opt) const { | 5748 bool opt) const { |
| 5809 return MakeCallSummary(zone); | 5749 return MakeCallSummary(zone); |
| 5810 } | 5750 } |
| 5811 | 5751 |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6808 __ Drop(1); | 6748 __ Drop(1); |
| 6809 __ popq(result); | 6749 __ popq(result); |
| 6810 } | 6750 } |
| 6811 | 6751 |
| 6812 | 6752 |
| 6813 } // namespace dart | 6753 } // namespace dart |
| 6814 | 6754 |
| 6815 #undef __ | 6755 #undef __ |
| 6816 | 6756 |
| 6817 #endif // defined TARGET_ARCH_X64 | 6757 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |