Chromium Code Reviews| 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_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 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 3683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3694 if (InputCount() == 2) { | 3694 if (InputCount() == 2) { |
| 3695 result->set_in(1, Location::FpuRegisterLocation(D7)); | 3695 result->set_in(1, Location::FpuRegisterLocation(D7)); |
| 3696 } | 3696 } |
| 3697 result->set_out(0, Location::FpuRegisterLocation(D0)); | 3697 result->set_out(0, Location::FpuRegisterLocation(D0)); |
| 3698 return result; | 3698 return result; |
| 3699 } | 3699 } |
| 3700 | 3700 |
| 3701 | 3701 |
| 3702 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3702 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3703 // For pow-function return NaN if exponent is NaN. | 3703 // For pow-function return NaN if exponent is NaN. |
| 3704 Label do_call, skip_call; | 3704 Label skip_call; |
| 3705 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { | 3705 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { |
| 3706 // Pseudo code: | 3706 // Pseudo code: |
| 3707 // if (exponent == 0.0) return 0.0; | 3707 // if (exponent == 0.0) return 1.0; |
| 3708 // if (base == 1.0) return 1.0; | 3708 // if (base == 1.0) return 1.0; |
| 3709 // if (base.isNaN || exponent.isNaN) { | 3709 // if (base.isNaN || exponent.isNaN) { |
| 3710 // return double.NAN; | 3710 // return double.NAN; |
| 3711 // } | 3711 // } |
| 3712 // if (base != -Infinity && exponent == 0.5) { | |
| 3713 // if (base == 0.0) return 0.0; | |
| 3714 // return sqrt(value); | |
| 3715 // } | |
| 3712 DRegister base = locs()->in(0).fpu_reg(); | 3716 DRegister base = locs()->in(0).fpu_reg(); |
| 3713 DRegister exp = locs()->in(1).fpu_reg(); | 3717 DRegister exp = locs()->in(1).fpu_reg(); |
| 3714 DRegister result = locs()->out(0).fpu_reg(); | 3718 DRegister result = locs()->out(0).fpu_reg(); |
| 3715 | 3719 |
| 3716 Label check_base_is_one; | 3720 Label do_call, check_base, return_nan; |
| 3717 | |
| 3718 // Check if exponent is 0.0 -> return 1.0; | |
| 3719 __ LoadObject(TMP, Double::ZoneHandle(Double::NewCanonical(0))); | 3721 __ LoadObject(TMP, Double::ZoneHandle(Double::NewCanonical(0))); |
|
zra
2014/04/03 17:04:46
__ LoadImmediate(DTMP, 0.0);
srdjan
2014/04/03 19:33:18
Done.
| |
| 3720 __ LoadDFromOffset(DTMP, TMP, Double::value_offset() - kHeapObjectTag); | 3722 __ LoadDFromOffset(DTMP, TMP, Double::value_offset() - kHeapObjectTag); |
| 3721 __ LoadObject(TMP, Double::ZoneHandle(Double::NewCanonical(1))); | 3723 __ LoadObject(TMP, Double::ZoneHandle(Double::NewCanonical(1))); |
|
zra
2014/04/03 17:04:46
__ LoadImmediate(result, 1.0);
srdjan
2014/04/03 19:33:18
Done.
| |
| 3722 __ LoadDFromOffset(result, TMP, Double::value_offset() - kHeapObjectTag); | 3724 __ LoadDFromOffset(result, TMP, Double::value_offset() - kHeapObjectTag); |
| 3723 // 'result' contains 1.0. | 3725 // exponent == 0.0 -> return 1.0; |
| 3724 __ cund(exp, exp); | 3726 __ cund(exp, exp); |
| 3725 __ bc1t(&check_base_is_one); // NaN -> not zero. | 3727 __ bc1t(&check_base); // NaN -> check base. |
| 3726 __ ceqd(exp, DTMP); | 3728 __ ceqd(exp, DTMP); |
| 3727 __ bc1t(&skip_call); // exp is 0.0, result is 1.0. | 3729 __ bc1t(&skip_call); // exp is 0.0, result is 1.0. |
| 3728 | 3730 |
| 3729 Label base_is_nan; | 3731 __ Bind(&check_base); |
| 3730 __ Bind(&check_base_is_one); | 3732 // Note: 'exp' could be NaN. |
| 3733 // base == 1.0 -> return 1.0; | |
| 3731 __ cund(base, base); | 3734 __ cund(base, base); |
| 3732 __ bc1t(&base_is_nan); | 3735 __ bc1t(&return_nan); |
| 3733 __ ceqd(base, result); | 3736 __ ceqd(base, result); |
| 3734 __ bc1t(&skip_call); // base and result are 1.0. | 3737 __ bc1t(&skip_call); // base and result are 1.0. |
| 3735 __ b(&do_call); | |
| 3736 | 3738 |
| 3737 __ Bind(&base_is_nan); | 3739 __ cund(exp, exp); |
| 3738 __ movd(result, base); // base is NaN, return NaN. | 3740 __ bc1f(&do_call); // Neither 'exp' nor 'base' are NaN. |
| 3741 | |
| 3742 __ Bind(&return_nan); | |
| 3743 __ LoadObject(TMP, Double::ZoneHandle(Double::NewCanonical(NAN))); | |
|
zra
2014/04/03 17:04:46
__ LoadImmediate(result, NAN);
srdjan
2014/04/03 19:33:18
Done.
| |
| 3744 __ LoadDFromOffset(result, TMP, Double::value_offset() - kHeapObjectTag); | |
| 3739 __ b(&skip_call); | 3745 __ b(&skip_call); |
| 3746 | |
| 3747 __ Bind(&do_call); | |
| 3748 // Before calling check if we could use sqrt instead of pow. | |
| 3749 Label do_pow, return_zero; | |
| 3750 __ LoadObject(TMP, Double::ZoneHandle(Double::NewCanonical(INFINITY))); | |
|
zra
2014/04/03 17:04:46
__ LoadImmediate(result, INFINITY);
srdjan
2014/04/03 19:33:18
Done.
| |
| 3751 __ LoadDFromOffset(result, TMP, Double::value_offset() - kHeapObjectTag); | |
| 3752 // base == -Infinity -> call pow; | |
| 3753 __ ceqd(base, result); | |
| 3754 __ b(&do_pow); | |
| 3755 | |
| 3756 // exponent == 0.5 ? | |
| 3757 __ LoadObject(TMP, Double::ZoneHandle(Double::NewCanonical(0.5))); | |
|
zra
2014/04/03 17:04:46
__ LoadImmediate(result, 0.5);
srdjan
2014/04/03 19:33:18
Done.
| |
| 3758 __ LoadDFromOffset(result, TMP, Double::value_offset() - kHeapObjectTag); | |
| 3759 __ ceqd(base, result); | |
| 3760 __ bc1f(&do_pow); | |
| 3761 | |
| 3762 // base == 0 -> return 0; | |
| 3763 __ ceqd(base, DTMP); | |
| 3764 __ bc1t(&return_zero); | |
| 3765 | |
| 3766 __ sqrtd(result, base); | |
| 3767 __ b(&skip_call); | |
| 3768 | |
| 3769 __ Bind(&return_zero); | |
| 3770 __ movd(result, DTMP); | |
| 3771 __ b(&skip_call); | |
| 3772 | |
| 3773 __ Bind(&do_pow); | |
| 3740 } | 3774 } |
| 3741 __ Bind(&do_call); | |
| 3742 // double values are passed and returned in vfp registers. | 3775 // double values are passed and returned in vfp registers. |
| 3743 __ CallRuntime(TargetFunction(), InputCount()); | 3776 __ CallRuntime(TargetFunction(), InputCount()); |
| 3744 __ Bind(&skip_call); | 3777 __ Bind(&skip_call); |
| 3745 } | 3778 } |
| 3746 | 3779 |
| 3747 | 3780 |
| 3781 | |
|
zra
2014/04/03 17:04:46
extra line
srdjan
2014/04/03 19:33:18
Done.
| |
| 3748 LocationSummary* MergedMathInstr::MakeLocationSummary(bool opt) const { | 3782 LocationSummary* MergedMathInstr::MakeLocationSummary(bool opt) const { |
| 3749 if (kind() == MergedMathInstr::kTruncDivMod) { | 3783 if (kind() == MergedMathInstr::kTruncDivMod) { |
| 3750 const intptr_t kNumInputs = 2; | 3784 const intptr_t kNumInputs = 2; |
| 3751 const intptr_t kNumTemps = 3; | 3785 const intptr_t kNumTemps = 3; |
| 3752 LocationSummary* summary = | 3786 LocationSummary* summary = |
| 3753 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 3787 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 3754 summary->set_in(0, Location::RequiresRegister()); | 3788 summary->set_in(0, Location::RequiresRegister()); |
| 3755 summary->set_in(1, Location::RequiresRegister()); | 3789 summary->set_in(1, Location::RequiresRegister()); |
| 3756 summary->set_temp(0, Location::RequiresRegister()); | 3790 summary->set_temp(0, Location::RequiresRegister()); |
| 3757 summary->set_temp(1, Location::RequiresRegister()); // result_div. | 3791 summary->set_temp(1, Location::RequiresRegister()); // result_div. |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4283 compiler->GenerateCall(token_pos(), | 4317 compiler->GenerateCall(token_pos(), |
| 4284 &label, | 4318 &label, |
| 4285 PcDescriptors::kOther, | 4319 PcDescriptors::kOther, |
| 4286 locs()); | 4320 locs()); |
| 4287 __ Drop(ArgumentCount()); // Discard arguments. | 4321 __ Drop(ArgumentCount()); // Discard arguments. |
| 4288 } | 4322 } |
| 4289 | 4323 |
| 4290 } // namespace dart | 4324 } // namespace dart |
| 4291 | 4325 |
| 4292 #endif // defined TARGET_ARCH_MIPS | 4326 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |