| 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 3682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3693 | 3693 |
| 3694 | 3694 |
| 3695 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const { | 3695 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const { |
| 3696 const intptr_t kNumInputs = 1; | 3696 const intptr_t kNumInputs = 1; |
| 3697 return LocationSummary::Make(kNumInputs, | 3697 return LocationSummary::Make(kNumInputs, |
| 3698 Location::SameAsFirstInput(), | 3698 Location::SameAsFirstInput(), |
| 3699 LocationSummary::kNoCall); | 3699 LocationSummary::kNoCall); |
| 3700 } | 3700 } |
| 3701 | 3701 |
| 3702 | 3702 |
| 3703 LocationSummary* MathMinMaxInstr::MakeLocationSummary() const { |
| 3704 if (result_cid() == kDoubleCid) { |
| 3705 const intptr_t kNumInputs = 2; |
| 3706 const intptr_t kNumTemps = 1; |
| 3707 LocationSummary* summary = |
| 3708 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 3709 summary->set_in(0, Location::RequiresFpuRegister()); |
| 3710 summary->set_in(1, Location::RequiresFpuRegister()); |
| 3711 summary->set_temp(0, Location::RequiresRegister()); |
| 3712 summary->set_out(Location::RequiresFpuRegister()); |
| 3713 return summary; |
| 3714 } |
| 3715 ASSERT(result_cid() == kSmiCid); |
| 3716 UNIMPLEMENTED(); |
| 3717 return NULL; |
| 3718 } |
| 3719 |
| 3720 |
| 3721 void MathMinMaxInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3722 if (result_cid() == kDoubleCid) { |
| 3723 Label done, is_left, is_nan; |
| 3724 XmmRegister left = locs()->in(0).fpu_reg(); |
| 3725 XmmRegister right = locs()->in(1).fpu_reg(); |
| 3726 XmmRegister result = locs()->out().fpu_reg(); |
| 3727 Register temp = locs()->temp(0).reg(); |
| 3728 __ comisd(left, right); |
| 3729 __ j(PARITY_EVEN, &is_nan, Assembler::kNearJump); |
| 3730 Condition double_condition; |
| 3731 if (op_kind() == MethodRecognizer::kMathMin) { |
| 3732 double_condition = TokenKindToDoubleCondition(Token::kLT); |
| 3733 } else { |
| 3734 ASSERT(op_kind() == MethodRecognizer::kMathMax); |
| 3735 double_condition = TokenKindToDoubleCondition(Token::kGT); |
| 3736 } |
| 3737 __ j(double_condition, &is_left, Assembler::kNearJump); |
| 3738 __ movsd(result, right); |
| 3739 __ jmp(&done, Assembler::kNearJump); |
| 3740 __ Bind(&is_left); |
| 3741 __ movsd(result, left); |
| 3742 __ jmp(&done); |
| 3743 __ Bind(&is_nan); |
| 3744 static double kNaN = NAN; |
| 3745 __ movq(temp, Immediate(reinterpret_cast<intptr_t>(&kNaN))); |
| 3746 __ movsd(result, Address(temp, 0)); |
| 3747 __ Bind(&done); |
| 3748 return; |
| 3749 } |
| 3750 ASSERT(result_cid() == kSmiCid); |
| 3751 UNIMPLEMENTED(); |
| 3752 } |
| 3753 |
| 3754 |
| 3703 void UnarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3755 void UnarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3704 Register value = locs()->in(0).reg(); | 3756 Register value = locs()->in(0).reg(); |
| 3705 ASSERT(value == locs()->out().reg()); | 3757 ASSERT(value == locs()->out().reg()); |
| 3706 switch (op_kind()) { | 3758 switch (op_kind()) { |
| 3707 case Token::kNEGATE: { | 3759 case Token::kNEGATE: { |
| 3708 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 3760 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 3709 kDeoptUnaryOp); | 3761 kDeoptUnaryOp); |
| 3710 __ negq(value); | 3762 __ negq(value); |
| 3711 __ j(OVERFLOW, deopt); | 3763 __ j(OVERFLOW, deopt); |
| 3712 Emit53BitOverflowCheck(compiler, deopt, value); | 3764 Emit53BitOverflowCheck(compiler, deopt, value); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3871 | 3923 |
| 3872 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3924 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3873 ASSERT(locs()->in(0).fpu_reg() == XMM1); | 3925 ASSERT(locs()->in(0).fpu_reg() == XMM1); |
| 3874 __ EnterFrame(0); | 3926 __ EnterFrame(0); |
| 3875 __ ReserveAlignedFrameSpace(0); | 3927 __ ReserveAlignedFrameSpace(0); |
| 3876 __ movaps(XMM0, locs()->in(0).fpu_reg()); | 3928 __ movaps(XMM0, locs()->in(0).fpu_reg()); |
| 3877 if (InputCount() == 2) { | 3929 if (InputCount() == 2) { |
| 3878 ASSERT(locs()->in(1).fpu_reg() == XMM2); | 3930 ASSERT(locs()->in(1).fpu_reg() == XMM2); |
| 3879 __ movaps(XMM1, locs()->in(1).fpu_reg()); | 3931 __ movaps(XMM1, locs()->in(1).fpu_reg()); |
| 3880 } | 3932 } |
| 3881 // For pow-function return NAN if exponent is NAN. | 3933 // For pow-function return NaN if exponent is NaN. |
| 3882 Label do_call, skip_call; | 3934 Label do_call, skip_call; |
| 3883 if (recognized_kind() == MethodRecognizer::kDoublePow) { | 3935 if (recognized_kind() == MethodRecognizer::kDoublePow) { |
| 3884 XmmRegister exp = locs()->in(1).fpu_reg(); | 3936 XmmRegister exp = locs()->in(1).fpu_reg(); |
| 3885 __ comisd(exp, exp); | 3937 __ comisd(exp, exp); |
| 3886 __ j(PARITY_ODD, &do_call, Assembler::kNearJump); // NaN -> false; | 3938 __ j(PARITY_ODD, &do_call, Assembler::kNearJump); // NaN -> false; |
| 3887 // Exponent is NaN, return NaN. | 3939 // Exponent is NaN, return NaN. |
| 3888 __ movaps(locs()->out().fpu_reg(), exp); | 3940 __ movaps(locs()->out().fpu_reg(), exp); |
| 3889 __ jmp(&skip_call, Assembler::kNearJump); | 3941 __ jmp(&skip_call, Assembler::kNearJump); |
| 3890 } | 3942 } |
| 3891 __ Bind(&do_call); | 3943 __ Bind(&do_call); |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4420 PcDescriptors::kOther, | 4472 PcDescriptors::kOther, |
| 4421 locs()); | 4473 locs()); |
| 4422 __ Drop(2); // Discard type arguments and receiver. | 4474 __ Drop(2); // Discard type arguments and receiver. |
| 4423 } | 4475 } |
| 4424 | 4476 |
| 4425 } // namespace dart | 4477 } // namespace dart |
| 4426 | 4478 |
| 4427 #undef __ | 4479 #undef __ |
| 4428 | 4480 |
| 4429 #endif // defined TARGET_ARCH_X64 | 4481 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |