summaryrefslogtreecommitdiff
path: root/runtime/interpreter/unstarted_runtime.cc
diff options
context:
space:
mode:
author Sergio Giro <sgiro@google.com> 2016-04-12 13:39:24 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-04-12 13:39:24 +0000
commitb2880a9c743e433ddaede6bb54911a4b6483ee0a (patch)
tree35176339736b1d0493955402320241f7f01672bc /runtime/interpreter/unstarted_runtime.cc
parent04c2b2de69460d41e0c39c1f7d9fb77376c3aa8b (diff)
parent8326120c1a4c0d52ee4ef0fabe09cb28e0c48470 (diff)
Merge "unstarted_runtime: add cutout for Math.floor"
Diffstat (limited to 'runtime/interpreter/unstarted_runtime.cc')
-rw-r--r--runtime/interpreter/unstarted_runtime.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc
index 4615ec9aa4..80ffedcaa0 100644
--- a/runtime/interpreter/unstarted_runtime.cc
+++ b/runtime/interpreter/unstarted_runtime.cc
@@ -524,9 +524,7 @@ void UnstartedRuntime::UnstartedThreadLocalGet(
}
}
-void UnstartedRuntime::UnstartedMathCeil(
- Thread* self ATTRIBUTE_UNUSED, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) {
- double in = shadow_frame->GetVRegDouble(arg_offset);
+static double ComputeCeil(double in) {
double out;
// Special cases:
// 1) NaN, infinity, +0, -0 -> out := in. All are guaranteed by cmath.
@@ -536,7 +534,21 @@ void UnstartedRuntime::UnstartedMathCeil(
} else {
out = ceil(in);
}
- result->SetD(out);
+ return out;
+}
+
+void UnstartedRuntime::UnstartedMathCeil(
+ Thread* self ATTRIBUTE_UNUSED, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) {
+ double in = shadow_frame->GetVRegDouble(arg_offset);
+ result->SetD(ComputeCeil(in));
+}
+
+void UnstartedRuntime::UnstartedMathFloor(
+ Thread* self ATTRIBUTE_UNUSED, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) {
+ double in = shadow_frame->GetVRegDouble(arg_offset);
+ // From the JavaDocs:
+ // "Note that the value of Math.ceil(x) is exactly the value of -Math.floor(-x)."
+ result->SetD(-ComputeCeil(-in));
}
void UnstartedRuntime::UnstartedObjectHashCode(