Tidy MIPS floating point helpers.
Fix initialization bug in thread.cc.
Change-Id: Ibdc81d6f5c8b1a245044bf901003179167a5d4f1
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index cb66b87..9854151 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -29,50 +29,6 @@
namespace art {
-extern "C" int art_cmpl_float(float a, float b) {
- if (a == b) {
- return 0;
- } else if (a < b) {
- return -1;
- } else if (a > b) {
- return 1;
- }
- return -1;
-}
-
-extern "C" int art_cmpg_float(float a, float b) {
- if (a == b) {
- return 0;
- } else if (a < b) {
- return -1;
- } else if (a > b) {
- return 1;
- }
- return 1;
-}
-
-extern "C" int art_cmpl_double(double a, double b) {
- if (a == b) {
- return 0;
- } else if (a < b) {
- return -1;
- } else if (a > b) {
- return 1;
- }
- return -1;
-}
-
-extern "C" int art_cmpg_double(double a, double b) {
- if (a == b) {
- return 0;
- } else if (a < b) {
- return -1;
- } else if (a > b) {
- return 1;
- }
- return 1;
-}
-
/*
* Report location to debugger. Note: dex_pc is the current offset within
* the method. However, because the offset alone cannot distinguish between
@@ -1022,34 +978,80 @@
return lr;
}
+int artCmplFloat(float a, float b) {
+ if (a == b) {
+ return 0;
+ } else if (a < b) {
+ return -1;
+ } else if (a > b) {
+ return 1;
+ }
+ return -1;
+}
+
+int artCmpgFloat(float a, float b) {
+ if (a == b) {
+ return 0;
+ } else if (a < b) {
+ return -1;
+ } else if (a > b) {
+ return 1;
+ }
+ return 1;
+}
+
+int artCmpgDouble(double a, double b) {
+ if (a == b) {
+ return 0;
+ } else if (a < b) {
+ return -1;
+ } else if (a > b) {
+ return 1;
+ }
+ return 1;
+}
+
+int artCmplDouble(double a, double b) {
+ if (a == b) {
+ return 0;
+ } else if (a < b) {
+ return -1;
+ } else if (a > b) {
+ return 1;
+ }
+ return -1;
+}
+
/*
* Float/double conversion requires clamping to min and max of integer form. If
* target doesn't support this normally, use these.
*/
int64_t D2L(double d) {
- static const double kMaxLong = (double)(int64_t)0x7fffffffffffffffULL;
- static const double kMinLong = (double)(int64_t)0x8000000000000000ULL;
- if (d >= kMaxLong)
- return (int64_t)0x7fffffffffffffffULL;
- else if (d <= kMinLong)
- return (int64_t)0x8000000000000000ULL;
- else if (d != d) // NaN case
- return 0;
- else
- return (int64_t)d;
+ static const double kMaxLong = (double) (int64_t) 0x7fffffffffffffffULL;
+ static const double kMinLong = (double) (int64_t) 0x8000000000000000ULL;
+ if (d >= kMaxLong) {
+ return (int64_t) 0x7fffffffffffffffULL;
+ } else if (d <= kMinLong) {
+ return (int64_t) 0x8000000000000000ULL;
+ } else if (d != d) { // NaN case
+ return 0;
+ } else {
+ return (int64_t) d;
+ }
}
int64_t F2L(float f) {
- static const float kMaxLong = (float)(int64_t)0x7fffffffffffffffULL;
- static const float kMinLong = (float)(int64_t)0x8000000000000000ULL;
- if (f >= kMaxLong)
- return (int64_t)0x7fffffffffffffffULL;
- else if (f <= kMinLong)
- return (int64_t)0x8000000000000000ULL;
- else if (f != f) // NaN case
- return 0;
- else
- return (int64_t)f;
+ static const float kMaxLong = (float) (int64_t) 0x7fffffffffffffffULL;
+ static const float kMinLong = (float) (int64_t) 0x8000000000000000ULL;
+ if (f >= kMaxLong) {
+ return (int64_t) 0x7fffffffffffffffULL;
+ } else if (f <= kMinLong) {
+ return (int64_t) 0x8000000000000000ULL;
+ } else if (f != f) { // NaN case
+ return 0;
+ } else {
+ return (int64_t) f;
+ }
}
} // namespace art
diff --git a/src/runtime_support.h b/src/runtime_support.h
index e297e2f..271cc83 100644
--- a/src/runtime_support.h
+++ b/src/runtime_support.h
@@ -43,6 +43,10 @@
void ObjectInitFromCode(Object* o);
extern void LockObjectFromCode(Thread* thread, Object* obj);
uint32_t artTraceMethodUnwindFromCode(Thread* self);
+extern int artCmpgDouble(double a, double b);
+extern int artCmplDouble(double a, double b);
+extern int artCmpgFloat(float a, float b);
+extern int artCmplFloat(float a, float b);
extern int64_t D2L(double d);
extern int64_t F2L(float f);
@@ -168,12 +172,6 @@
/* Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR] */
extern "C" long long __divdi3(long long op1, long long op2);
extern "C" long long __moddi3(long long op1, long long op2);
-
- /* Float and double comparison */
- extern "C" int art_cmpl_float(float a, float b);
- extern "C" int art_cmpl_double(double a, double b);
- extern "C" int art_cmpg_float(float a, float b);
- extern "C" int art_cmpg_double(double a, double b);
#endif
#endif // ART_SRC_RUNTIME_SUPPORT_H_
diff --git a/src/thread.cc b/src/thread.cc
index 48b8645..ee3bf26 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -93,10 +93,10 @@
pDdiv = __divdf3;
pDmul = muldf3;
pFmod = fmod;
- pCmplFloat = art_cmpl_float;
- pCmpgFloat = arg_cmpl_float;
- pCmplDouble = art_cmpl_double;
- pCmpgDouble = arg_cmpl_double;
+ pCmpgFloat = artCmpgFloat;
+ pCmplFloat = artCmplFloat;
+ pCmpgDouble = artCmpgDouble;
+ pCmplDouble = artCmplDouble;
#endif
#if defined(__arm__)
pShlLong = art_shl_long;