diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/dfg/DFGArithMode.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGArithMode.h')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGArithMode.h | 50 |
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 - |