| 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 4389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4400 break; | 4400 break; |
| 4401 case Token::kSUB: | 4401 case Token::kSUB: |
| 4402 __ subpl(left, right); | 4402 __ subpl(left, right); |
| 4403 break; | 4403 break; |
| 4404 default: UNREACHABLE(); | 4404 default: UNREACHABLE(); |
| 4405 } | 4405 } |
| 4406 } | 4406 } |
| 4407 | 4407 |
| 4408 | 4408 |
| 4409 LocationSummary* MathUnaryInstr::MakeLocationSummary(bool opt) const { | 4409 LocationSummary* MathUnaryInstr::MakeLocationSummary(bool opt) const { |
| 4410 if ((kind() == MethodRecognizer::kMathSin) || | 4410 if ((kind() == MathUnaryInstr::kSin) || (kind() == MathUnaryInstr::kCos)) { |
| 4411 (kind() == MethodRecognizer::kMathCos)) { | |
| 4412 // Calling convention on x64 uses XMM0 and XMM1 to pass the first two | 4411 // Calling convention on x64 uses XMM0 and XMM1 to pass the first two |
| 4413 // double arguments and XMM0 to return the result. Unfortunately | 4412 // double arguments and XMM0 to return the result. Unfortunately |
| 4414 // currently we can't specify these registers because ParallelMoveResolver | 4413 // currently we can't specify these registers because ParallelMoveResolver |
| 4415 // assumes that XMM0 is free at all times. | 4414 // assumes that XMM0 is free at all times. |
| 4416 // TODO(vegorov): allow XMM0 to be used. | 4415 // TODO(vegorov): allow XMM0 to be used. |
| 4417 const intptr_t kNumTemps = 1; | 4416 const intptr_t kNumTemps = 1; |
| 4418 LocationSummary* summary = | 4417 LocationSummary* summary = |
| 4419 new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall); | 4418 new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall); |
| 4420 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); | 4419 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); |
| 4421 // R13 is chosen because it is callee saved so we do not need to back it | 4420 // R13 is chosen because it is callee saved so we do not need to back it |
| 4422 // up before calling into the runtime. | 4421 // up before calling into the runtime. |
| 4423 summary->set_temp(0, Location::RegisterLocation(R13)); | 4422 summary->set_temp(0, Location::RegisterLocation(R13)); |
| 4424 summary->set_out(0, Location::FpuRegisterLocation(XMM1)); | 4423 summary->set_out(0, Location::FpuRegisterLocation(XMM1)); |
| 4425 return summary; | 4424 return summary; |
| 4426 } | 4425 } |
| 4427 ASSERT(kind() == MethodRecognizer::kMathSqrt); | 4426 ASSERT((kind() == MathUnaryInstr::kSqrt) || |
| 4427 (kind() == MathUnaryInstr::kDoubleSquare)); |
| 4428 const intptr_t kNumInputs = 1; | 4428 const intptr_t kNumInputs = 1; |
| 4429 const intptr_t kNumTemps = 0; | 4429 const intptr_t kNumTemps = 0; |
| 4430 LocationSummary* summary = | 4430 LocationSummary* summary = |
| 4431 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4431 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 4432 summary->set_in(0, Location::RequiresFpuRegister()); | 4432 summary->set_in(0, Location::RequiresFpuRegister()); |
| 4433 summary->set_out(0, Location::RequiresFpuRegister()); | 4433 if (kind() == MathUnaryInstr::kDoubleSquare) { |
| 4434 summary->set_out(0, Location::SameAsFirstInput()); |
| 4435 } else { |
| 4436 summary->set_out(0, Location::RequiresFpuRegister()); |
| 4437 } |
| 4434 return summary; | 4438 return summary; |
| 4435 } | 4439 } |
| 4436 | 4440 |
| 4437 | 4441 |
| 4438 void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4442 void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 4439 if (kind() == MethodRecognizer::kMathSqrt) { | 4443 if (kind() == MathUnaryInstr::kSqrt) { |
| 4440 __ sqrtsd(locs()->out(0).fpu_reg(), locs()->in(0).fpu_reg()); | 4444 __ sqrtsd(locs()->out(0).fpu_reg(), locs()->in(0).fpu_reg()); |
| 4445 } else if (kind() == MathUnaryInstr::kDoubleSquare) { |
| 4446 XmmRegister value_reg = locs()->in(0).fpu_reg(); |
| 4447 __ mulsd(value_reg, value_reg); |
| 4448 ASSERT(value_reg == locs()->out(0).fpu_reg()); |
| 4441 } else { | 4449 } else { |
| 4442 ASSERT((kind() == MethodRecognizer::kMathSin) || | 4450 ASSERT((kind() == MathUnaryInstr::kSin) || |
| 4443 (kind() == MethodRecognizer::kMathCos)); | 4451 (kind() == MathUnaryInstr::kCos)); |
| 4444 // Save RSP. | 4452 // Save RSP. |
| 4445 __ movq(locs()->temp(0).reg(), RSP); | 4453 __ movq(locs()->temp(0).reg(), RSP); |
| 4446 __ ReserveAlignedFrameSpace(0); | 4454 __ ReserveAlignedFrameSpace(0); |
| 4447 __ movaps(XMM0, locs()->in(0).fpu_reg()); | 4455 __ movaps(XMM0, locs()->in(0).fpu_reg()); |
| 4448 __ CallRuntime(TargetFunction(), InputCount()); | 4456 __ CallRuntime(TargetFunction(), InputCount()); |
| 4449 __ movaps(locs()->out(0).fpu_reg(), XMM0); | 4457 __ movaps(locs()->out(0).fpu_reg(), XMM0); |
| 4450 // Restore RSP. | 4458 // Restore RSP. |
| 4451 __ movq(RSP, locs()->temp(0).reg()); | 4459 __ movq(RSP, locs()->temp(0).reg()); |
| 4452 } | 4460 } |
| 4453 } | 4461 } |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5600 PcDescriptors::kOther, | 5608 PcDescriptors::kOther, |
| 5601 locs()); | 5609 locs()); |
| 5602 __ Drop(ArgumentCount()); // Discard arguments. | 5610 __ Drop(ArgumentCount()); // Discard arguments. |
| 5603 } | 5611 } |
| 5604 | 5612 |
| 5605 } // namespace dart | 5613 } // namespace dart |
| 5606 | 5614 |
| 5607 #undef __ | 5615 #undef __ |
| 5608 | 5616 |
| 5609 #endif // defined TARGET_ARCH_X64 | 5617 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |