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

Unified Diff: runtime/vm/intermediate_language_arm.cc

Issue 23072044: Fix corner cases for double pow operation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_arm.cc
===================================================================
--- runtime/vm/intermediate_language_arm.cc (revision 26658)
+++ runtime/vm/intermediate_language_arm.cc (working copy)
@@ -4132,6 +4132,10 @@
if (InputCount() == 2) {
result->set_in(1, Location::FpuRegisterLocation(Q1));
}
+ if (recognized_kind() == MethodRecognizer::kMathDoublePow) {
+ result->AddTemp(Location::RegisterLocation(R2));
+ result->AddTemp(Location::FpuRegisterLocation(Q2));
+ }
result->set_out(Location::FpuRegisterLocation(Q0));
return result;
}
@@ -4141,14 +4145,37 @@
// For pow-function return NaN if exponent is NaN.
Label do_call, skip_call;
if (recognized_kind() == MethodRecognizer::kMathDoublePow) {
+ // Pseudo code:
+ // if (exponent == 0.0) return 0.0;
+ // if (base == 1.0) return 1.0;
+ // if (base.isNaN || exponent.isNaN) {
+ // return double.NAN;
+ // }
+ DRegister base = EvenDRegisterOf(locs()->in(0).fpu_reg());
DRegister exp = EvenDRegisterOf(locs()->in(1).fpu_reg());
DRegister result = EvenDRegisterOf(locs()->out().fpu_reg());
- __ vcmpd(exp, exp);
+ Register temp = locs()->temp(0).reg();
+ DRegister saved_base = EvenDRegisterOf(locs()->temp(1).fpu_reg());
+ ASSERT((base == result) && (result != saved_base));
+ Label check_base_is_one;
+ // Check if exponent is 0.0 -> return 1.0;
+ __ vmovd(saved_base, base);
+ __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(0)));
+ __ LoadDFromOffset(DTMP, temp, Double::value_offset() - kHeapObjectTag);
+ __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(1)));
+ __ LoadDFromOffset(result, temp, Double::value_offset() - kHeapObjectTag);
+ __ vcmpd(exp, DTMP);
__ vmstat();
- __ b(&do_call, VC); // NaN -> false;
- // Exponent is NaN, return NaN.
- __ vmovd(result, exp);
- __ b(&skip_call);
+ __ b(&check_base_is_one, VS); // NaN -> not zero.
+ __ b(&skip_call, EQ); // exp is 0.0, result is 1.0.
+
+ __ Bind(&check_base_is_one);
+ __ vcmpd(saved_base, result);
+ __ vmstat();
+ __ vmovd(result, saved_base, VS); // base is NaN, return NaN.
+ __ b(&skip_call, VS);
+ __ b(&skip_call, EQ); // base and result are 1.0.
+ __ vmovd(base, saved_base); // Restore base.
}
__ Bind(&do_call);
// We currently use 'hardfp' ('gnueabihf') rather than 'softfp'
« no previous file with comments | « no previous file | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698