summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/dfg/DFGArithMode.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGArithMode.h')
-rw-r--r--Source/JavaScriptCore/dfg/DFGArithMode.h50
1 files changed, 45 insertions, 5 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGArithMode.h b/Source/JavaScriptCore/dfg/DFGArithMode.h
index 073ed6aba..24a7952dd 100644
--- a/Source/JavaScriptCore/dfg/DFGArithMode.h
+++ b/Source/JavaScriptCore/dfg/DFGArithMode.h
@@ -23,8 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef DFGArithMode_h
-#define DFGArithMode_h
+#pragma once
#if ENABLE(DFG_JIT)
@@ -40,6 +39,14 @@ enum Mode {
CheckOverflowAndNegativeZero, // Check for both overflow and negative zero.
DoOverflow // Up-convert to the smallest type that soundly represents all possible results after input type speculation.
};
+
+// Define the type of operation the rounding operation will perform.
+enum class RoundingMode {
+ Int32, // The round operation produces a integer and -0 is considered as 0.
+ Int32WithNegativeZeroCheck, // The round operation produces a integer and checks for -0.
+ Double // The round operation produce a double. The result can be -0, NaN or (+/-)Infinity.
+};
+
} // namespace Arith
inline bool doesOverflow(Arith::Mode mode)
@@ -97,16 +104,49 @@ inline bool shouldCheckNegativeZero(Arith::Mode mode)
return true;
}
+inline bool subsumes(Arith::Mode earlier, Arith::Mode later)
+{
+ switch (earlier) {
+ case Arith::CheckOverflow:
+ switch (later) {
+ case Arith::Unchecked:
+ case Arith::CheckOverflow:
+ return true;
+ default:
+ return false;
+ }
+ case Arith::CheckOverflowAndNegativeZero:
+ switch (later) {
+ case Arith::Unchecked:
+ case Arith::CheckOverflow:
+ case Arith::CheckOverflowAndNegativeZero:
+ return true;
+ default:
+ return false;
+ }
+ default:
+ return earlier == later;
+ }
+}
+
+inline bool producesInteger(Arith::RoundingMode mode)
+{
+ return mode == Arith::RoundingMode::Int32WithNegativeZeroCheck || mode == Arith::RoundingMode::Int32;
+}
+
+inline bool shouldCheckNegativeZero(Arith::RoundingMode mode)
+{
+ return mode == Arith::RoundingMode::Int32WithNegativeZeroCheck;
+}
+
} } // namespace JSC::DFG
namespace WTF {
class PrintStream;
void printInternal(PrintStream&, JSC::DFG::Arith::Mode);
+void printInternal(PrintStream&, JSC::DFG::Arith::RoundingMode);
} // namespace WTF
#endif // ENABLE(DFG_JIT)
-
-#endif // DFGArithMode_h
-