--- old/src/share/vm/opto/mathexactnode.hpp 2014-01-30 13:51:38.189910951 +0100 +++ new/src/share/vm/opto/mathexactnode.hpp 2014-01-30 13:51:38.089910954 +0100 @@ -27,128 +27,153 @@ #include "opto/multnode.hpp" #include "opto/node.hpp" +#include "opto/addnode.hpp" #include "opto/subnode.hpp" #include "opto/type.hpp" -class BoolNode; -class IfNode; -class Node; - class PhaseGVN; class PhaseTransform; -class MathExactNode : public MultiNode { +class OverflowNode : public CmpNode { public: - MathExactNode(Node* ctrl, Node* in1); - MathExactNode(Node* ctrl, Node* in1, Node* in2); - enum { - result_proj_node = 0, - flags_proj_node = 1 - }; - virtual int Opcode() const; - virtual Node* Identity(PhaseTransform* phase) { return this; } - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape) { return NULL; } - virtual const Type* Value(PhaseTransform* phase) const { return bottom_type(); } - virtual uint hash() const { return NO_HASH; } - virtual bool is_CFG() const { return false; } - virtual uint ideal_reg() const { return NotAMachineReg; } + OverflowNode(Node* in1); + OverflowNode(Node* in1, Node* in2); + virtual uint ideal_reg() const { return Op_RegFlags; } - ProjNode* result_node() const { return proj_out(result_proj_node); } - ProjNode* flags_node() const { return proj_out(flags_proj_node); } - Node* control_node() const; - Node* non_throwing_branch() const; -protected: - IfNode* if_node() const; - BoolNode* bool_node() const; - Node* no_overflow(PhaseGVN *phase, Node* new_result); -}; + template + class AddHelper { + public: + typedef typename OverflowOp::ConstantType ConstantType; + typedef typename OverflowOp::TypeClass TypeClass; + static bool will_overflow(ConstantType value1, ConstantType value2); + static bool can_overflow(const Type* type1, const Type* type2); + }; + template + class SubHelper { + public: + typedef typename OverflowOp::ConstantType ConstantType; + typedef typename OverflowOp::TypeClass TypeClass; + static bool will_overflow(ConstantType value1, ConstantType value2); + static bool can_overflow(const Type* type1, const Type* type2); + }; -class MathExactINode : public MathExactNode { - public: - MathExactINode(Node* ctrl, Node* in1) : MathExactNode(ctrl, in1) {} - MathExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactNode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node* match(const ProjNode* proj, const Matcher* m); - virtual const Type* bottom_type() const { return TypeTuple::INT_CC_PAIR; } + template + class MulHelper { + public: + typedef typename OverflowOp::ConstantType ConstantType; + typedef typename OverflowOp::TypeClass TypeClass; + static bool can_overflow(const Type* type1, const Type* type2); + }; }; -class MathExactLNode : public MathExactNode { +class OverflowINode : public OverflowNode { public: - MathExactLNode(Node* ctrl, Node* in1) : MathExactNode(ctrl, in1) {} - MathExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactNode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node* match(const ProjNode* proj, const Matcher* m); - virtual const Type* bottom_type() const { return TypeTuple::LONG_CC_PAIR; } -}; + enum { + IsLong = false + }; + typedef jint ConstantType; + typedef TypeInt TypeClass; -class AddExactINode : public MathExactINode { -public: - AddExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); -}; + OverflowINode(Node* in1) : OverflowNode(in1) {} + OverflowINode(Node* in1, Node* in2) : OverflowNode(in1, in2) {} + Node* Ideal(PhaseGVN* phase, bool can_reshape); + const Type* Value(PhaseTransform* phase) const; + const Type* sub(const Type* t1, const Type* t2) const; -class AddExactLNode : public MathExactLNode { -public: - AddExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); + virtual bool will_overflow(jint v1, jint v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; }; -class SubExactINode : public MathExactINode { + +class OverflowLNode : public OverflowNode { public: - SubExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {} - virtual int Opcode() const; + enum { + IsLong = true + }; + typedef jlong ConstantType; + typedef TypeLong TypeClass; + + OverflowLNode(Node* in1) : OverflowNode(in1) {} + OverflowLNode(Node* in1, Node* in2) : OverflowNode(in1, in2) {} virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); + const Type* sub(const Type* t1, const Type* t2) const; + const Type* Value(PhaseTransform* phase) const; + + virtual bool will_overflow(jlong v1, jlong v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; }; -class SubExactLNode : public MathExactLNode { +class OverflowAddINode : public OverflowINode { public: - SubExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {} + typedef AddINode MathOp; + typedef OverflowNode::AddHelper OverflowHelper; + + OverflowAddINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {} virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); + + virtual bool will_overflow(jint v1, jint v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; }; -class NegExactINode : public MathExactINode { +class OverflowSubINode : public OverflowINode { public: - NegExactINode(Node* ctrl, Node* in1) : MathExactINode(ctrl, in1) {} + typedef SubINode MathOp; + typedef OverflowNode::SubHelper OverflowHelper; + + OverflowSubINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {} virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); + + virtual bool will_overflow(jint v1, jint v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; }; -class NegExactLNode : public MathExactLNode { +class OverflowMulINode : public OverflowINode { public: - NegExactLNode(Node* ctrl, Node* in1) : MathExactLNode(ctrl, in1) {} + typedef MulINode MathOp; + typedef OverflowNode::MulHelper OverflowHelper; + + OverflowMulINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {} virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); + + virtual bool will_overflow(jint v1, jint v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; }; -class MulExactINode : public MathExactINode { +class OverflowAddLNode : public OverflowLNode { public: - MulExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {} + typedef AddLNode MathOp; + typedef OverflowNode::AddHelper OverflowHelper; + + OverflowAddLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {} virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); + + virtual bool will_overflow(jlong v1, jlong v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; }; -class MulExactLNode : public MathExactLNode { +class OverflowSubLNode : public OverflowLNode { public: - MulExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {} + typedef SubLNode MathOp; + typedef OverflowNode::SubHelper OverflowHelper; + + OverflowSubLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {} virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); + + virtual bool will_overflow(jlong v1, jlong v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; }; -class FlagsProjNode : public ProjNode { +class OverflowMulLNode : public OverflowLNode { public: - FlagsProjNode(Node* src, uint con) : ProjNode(src, con) { - init_class_id(Class_FlagsProj); - } + typedef MulLNode MathOp; + typedef OverflowNode::MulHelper OverflowHelper; + OverflowMulLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {} virtual int Opcode() const; - virtual bool is_CFG() const { return false; } - virtual const Type* bottom_type() const { return TypeInt::CC; } - virtual uint ideal_reg() const { return Op_RegFlags; } -}; + virtual bool will_overflow(jlong v1, jlong v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; +}; #endif