| 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 try_sqrt, check_base, return_nan; |
| 3717 | 3721 __ LoadImmediate(DTMP, 0.0); |
| 3718 // Check if exponent is 0.0 -> return 1.0; | 3722 __ LoadImmediate(result, 1.0); |
| 3719 __ LoadObject(TMP, Double::ZoneHandle(Double::NewCanonical(0))); | 3723 // exponent == 0.0 -> return 1.0; |
| 3720 __ LoadDFromOffset(DTMP, TMP, Double::value_offset() - kHeapObjectTag); | |
| 3721 __ LoadObject(TMP, Double::ZoneHandle(Double::NewCanonical(1))); | |
| 3722 __ LoadDFromOffset(result, TMP, Double::value_offset() - kHeapObjectTag); | |
| 3723 // 'result' contains 1.0. | |
| 3724 __ cund(exp, exp); | 3724 __ cund(exp, exp); |
| 3725 __ bc1t(&check_base_is_one); // NaN -> not zero. | 3725 __ bc1t(&check_base); // NaN -> check base. |
| 3726 __ ceqd(exp, DTMP); | 3726 __ ceqd(exp, DTMP); |
| 3727 __ bc1t(&skip_call); // exp is 0.0, result is 1.0. | 3727 __ bc1t(&skip_call); // exp is 0.0, result is 1.0. |
| 3728 | 3728 |
| 3729 Label base_is_nan; | 3729 __ Bind(&check_base); |
| 3730 __ Bind(&check_base_is_one); | 3730 // Note: 'exp' could be NaN. |
| 3731 // base == 1.0 -> return 1.0; |
| 3731 __ cund(base, base); | 3732 __ cund(base, base); |
| 3732 __ bc1t(&base_is_nan); | 3733 __ bc1t(&return_nan); |
| 3733 __ ceqd(base, result); | 3734 __ ceqd(base, result); |
| 3734 __ bc1t(&skip_call); // base and result are 1.0. | 3735 __ bc1t(&skip_call); // base and result are 1.0. |
| 3735 __ b(&do_call); | |
| 3736 | 3736 |
| 3737 __ Bind(&base_is_nan); | 3737 __ cund(exp, exp); |
| 3738 __ movd(result, base); // base is NaN, return NaN. | 3738 __ bc1f(&try_sqrt); // Neither 'exp' nor 'base' are NaN. |
| 3739 |
| 3740 __ Bind(&return_nan); |
| 3741 __ LoadImmediate(result, NAN); |
| 3739 __ b(&skip_call); | 3742 __ b(&skip_call); |
| 3743 |
| 3744 __ Bind(&try_sqrt); |
| 3745 // Before calling pow, check if we could use sqrt instead of pow. |
| 3746 Label do_pow, return_zero; |
| 3747 __ LoadImmediate(result, INFINITY); |
| 3748 // base == -Infinity -> call pow; |
| 3749 __ ceqd(base, result); |
| 3750 __ b(&do_pow); |
| 3751 |
| 3752 // exponent == 0.5 ? |
| 3753 __ LoadImmediate(result, 0.5); |
| 3754 __ ceqd(base, result); |
| 3755 __ bc1f(&do_pow); |
| 3756 |
| 3757 // base == 0 -> return 0; |
| 3758 __ ceqd(base, DTMP); |
| 3759 __ bc1t(&return_zero); |
| 3760 |
| 3761 __ sqrtd(result, base); |
| 3762 __ b(&skip_call); |
| 3763 |
| 3764 __ Bind(&return_zero); |
| 3765 __ movd(result, DTMP); |
| 3766 __ b(&skip_call); |
| 3767 |
| 3768 __ Bind(&do_pow); |
| 3740 } | 3769 } |
| 3741 __ Bind(&do_call); | |
| 3742 // double values are passed and returned in vfp registers. | 3770 // double values are passed and returned in vfp registers. |
| 3743 __ CallRuntime(TargetFunction(), InputCount()); | 3771 __ CallRuntime(TargetFunction(), InputCount()); |
| 3744 __ Bind(&skip_call); | 3772 __ Bind(&skip_call); |
| 3745 } | 3773 } |
| 3746 | 3774 |
| 3747 | 3775 |
| 3748 LocationSummary* MergedMathInstr::MakeLocationSummary(bool opt) const { | 3776 LocationSummary* MergedMathInstr::MakeLocationSummary(bool opt) const { |
| 3749 if (kind() == MergedMathInstr::kTruncDivMod) { | 3777 if (kind() == MergedMathInstr::kTruncDivMod) { |
| 3750 const intptr_t kNumInputs = 2; | 3778 const intptr_t kNumInputs = 2; |
| 3751 const intptr_t kNumTemps = 3; | 3779 const intptr_t kNumTemps = 3; |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4283 compiler->GenerateCall(token_pos(), | 4311 compiler->GenerateCall(token_pos(), |
| 4284 &label, | 4312 &label, |
| 4285 PcDescriptors::kOther, | 4313 PcDescriptors::kOther, |
| 4286 locs()); | 4314 locs()); |
| 4287 __ Drop(ArgumentCount()); // Discard arguments. | 4315 __ Drop(ArgumentCount()); // Discard arguments. |
| 4288 } | 4316 } |
| 4289 | 4317 |
| 4290 } // namespace dart | 4318 } // namespace dart |
| 4291 | 4319 |
| 4292 #endif // defined TARGET_ARCH_MIPS | 4320 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |