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

Unified Diff: src/utils.h

Issue 2252863003: [turbofan] Add Float32(Max|Min) machine operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Extract the code of the (min|max) calculation. Created 4 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
Index: src/utils.h
diff --git a/src/utils.h b/src/utils.h
index f95a136f96e6b0494057193d9f2da28e4faa8b86..0797d9977dbfce8059111f5f6158c392eea9f6bc 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -200,6 +200,23 @@ T Min(T a, T b) {
return a < b ? a : b;
}
+// Returns the maximum of the two parameters according to JavaScript semantics.
+template <typename T>
+T JSMax(T x, T y) {
+ if (std::isnan(x)) return x;
+ if (std::isnan(y)) return y;
+ if (std::signbit(x) < std::signbit(y)) return x;
+ return std::max(x, y);
+}
+
+// Returns the maximum of the two parameters according to JavaScript semantics.
+template <typename T>
+T JSMin(T x, T y) {
+ if (std::isnan(x)) return x;
+ if (std::isnan(y)) return y;
+ if (std::signbit(x) < std::signbit(y)) return y;
+ return std::min(x, y);
+}
// Returns the absolute value of its argument.
template <typename T>

Powered by Google App Engine
This is Rietveld 408576698