Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: runtime/vm/intermediate_language_ia32.cc

Issue 19792007: Recognize Math's min and max function for doubles and inline the operation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 3616 matching lines...) Expand 10 before | Expand all | Expand 10 after
3627 summary->set_out(Location::RequiresFpuRegister()); 3627 summary->set_out(Location::RequiresFpuRegister());
3628 return summary; 3628 return summary;
3629 } 3629 }
3630 3630
3631 3631
3632 void MathSqrtInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3632 void MathSqrtInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3633 __ sqrtsd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg()); 3633 __ sqrtsd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg());
3634 } 3634 }
3635 3635
3636 3636
3637 LocationSummary* MathMinMaxInstr::MakeLocationSummary() const {
3638 if (result_cid() == kDoubleCid) {
3639 const intptr_t kNumInputs = 2;
3640 const intptr_t kNumTemps = 0;
3641 LocationSummary* summary =
3642 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3643 summary->set_in(0, Location::RequiresFpuRegister());
3644 summary->set_in(1, Location::RequiresFpuRegister());
3645 summary->set_out(Location::RequiresFpuRegister());
3646 return summary;
3647 }
3648 ASSERT(result_cid() == kSmiCid);
3649 UNIMPLEMENTED();
3650 return NULL;
3651 }
3652
3653
3654 void MathMinMaxInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3655 if (result_cid() == kDoubleCid) {
3656 Label done, is_left, is_nan;
3657 XmmRegister left = locs()->in(0).fpu_reg();
3658 XmmRegister right = locs()->in(1).fpu_reg();
3659 XmmRegister result = locs()->out().fpu_reg();
3660 __ comisd(left, right);
3661 __ j(PARITY_EVEN, &is_nan, Assembler::kNearJump);
3662 Condition double_condition;
3663 if (op_kind() == MethodRecognizer::kMathMin) {
3664 double_condition = TokenKindToDoubleCondition(Token::kLT);
3665 } else {
3666 ASSERT(op_kind() == MethodRecognizer::kMathMax);
3667 double_condition = TokenKindToDoubleCondition(Token::kGT);
3668 }
3669 __ j(double_condition, &is_left, Assembler::kNearJump);
3670 __ movsd(result, right);
3671 __ jmp(&done, Assembler::kNearJump);
3672 __ Bind(&is_left);
3673 __ movsd(result, left);
3674 __ jmp(&done);
3675 __ Bind(&is_nan);
3676 static double kNaN = NAN;
3677 __ movsd(result, Address::Absolute(reinterpret_cast<uword>(&kNaN)));
3678 __ Bind(&done);
3679 return;
3680 }
3681 ASSERT(result_cid() == kSmiCid);
3682 UNIMPLEMENTED();
3683 }
3684
3685
3637 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const { 3686 LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const {
3638 const intptr_t kNumInputs = 1; 3687 const intptr_t kNumInputs = 1;
3639 return LocationSummary::Make(kNumInputs, 3688 return LocationSummary::Make(kNumInputs,
3640 Location::SameAsFirstInput(), 3689 Location::SameAsFirstInput(),
3641 LocationSummary::kNoCall); 3690 LocationSummary::kNoCall);
3642 } 3691 }
3643 3692
3644 3693
3645 void UnarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3694 void UnarySmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3646 Register value = locs()->in(0).reg(); 3695 Register value = locs()->in(0).reg();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3792 return result; 3841 return result;
3793 } 3842 }
3794 3843
3795 3844
3796 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3845 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3797 __ EnterFrame(0); 3846 __ EnterFrame(0);
3798 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); 3847 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount());
3799 for (intptr_t i = 0; i < InputCount(); i++) { 3848 for (intptr_t i = 0; i < InputCount(); i++) {
3800 __ movsd(Address(ESP, kDoubleSize * i), locs()->in(i).fpu_reg()); 3849 __ movsd(Address(ESP, kDoubleSize * i), locs()->in(i).fpu_reg());
3801 } 3850 }
3802 // For pow-function return NAN if exponent is NAN. 3851 // For pow-function return NaN if exponent is NaN.
3803 Label do_call, skip_call; 3852 Label do_call, skip_call;
3804 if (recognized_kind() == MethodRecognizer::kDoublePow) { 3853 if (recognized_kind() == MethodRecognizer::kDoublePow) {
3805 XmmRegister exp = locs()->in(1).fpu_reg(); 3854 XmmRegister exp = locs()->in(1).fpu_reg();
3806 __ comisd(exp, exp); 3855 __ comisd(exp, exp);
3807 __ j(PARITY_ODD, &do_call, Assembler::kNearJump); // NaN -> false; 3856 __ j(PARITY_ODD, &do_call, Assembler::kNearJump); // NaN -> false;
3808 // Exponent is NaN, return NaN. 3857 // Exponent is NaN, return NaN.
3809 __ movsd(locs()->out().fpu_reg(), exp); 3858 __ movsd(locs()->out().fpu_reg(), exp);
3810 __ jmp(&skip_call, Assembler::kNearJump); 3859 __ jmp(&skip_call, Assembler::kNearJump);
3811 } 3860 }
3812 __ Bind(&do_call); 3861 __ Bind(&do_call);
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
4749 PcDescriptors::kOther, 4798 PcDescriptors::kOther,
4750 locs()); 4799 locs());
4751 __ Drop(2); // Discard type arguments and receiver. 4800 __ Drop(2); // Discard type arguments and receiver.
4752 } 4801 }
4753 4802
4754 } // namespace dart 4803 } // namespace dart
4755 4804
4756 #undef __ 4805 #undef __
4757 4806
4758 #endif // defined TARGET_ARCH_IA32 4807 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698