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

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: Type is number now. 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
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | src/wasm/wasm-interpreter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
diff --git a/src/utils.h b/src/utils.h
index a58439971f4c1f5ac291c7188a703a5b404946e3..8eca39207d4aa55b222870a2e36e7ce53a273bc8 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 x > y ? 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 x > y ? y : x;
+}
// Returns the absolute value of its argument.
template <typename T>
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | src/wasm/wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698