--- old/src/share/vm/opto/library_call.cpp 2014-01-23 12:10:12.371190583 +0100 +++ new/src/share/vm/opto/library_call.cpp 2014-01-23 12:10:12.267190586 +0100 @@ -203,7 +203,7 @@ bool inline_math_native(vmIntrinsics::ID id); bool inline_trig(vmIntrinsics::ID id); bool inline_math(vmIntrinsics::ID id); - void inline_math_mathExact(Node* math); + void inline_math_mathExact(Node* math, Node* test); bool inline_math_addExactI(bool is_increment); bool inline_math_addExactL(bool is_increment); bool inline_math_multiplyExactI(); @@ -517,31 +517,31 @@ case vmIntrinsics::_incrementExactI: case vmIntrinsics::_addExactI: - if (!Matcher::match_rule_supported(Op_AddExactI) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowAddI) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_incrementExactL: case vmIntrinsics::_addExactL: - if (!Matcher::match_rule_supported(Op_AddExactL) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowAddL) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_decrementExactI: case vmIntrinsics::_subtractExactI: - if (!Matcher::match_rule_supported(Op_SubExactI) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_decrementExactL: case vmIntrinsics::_subtractExactL: - if (!Matcher::match_rule_supported(Op_SubExactL) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowSubL) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_negateExactI: - if (!Matcher::match_rule_supported(Op_NegExactI) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_negateExactL: - if (!Matcher::match_rule_supported(Op_NegExactL) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowSubL) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_multiplyExactI: - if (!Matcher::match_rule_supported(Op_MulExactI) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowMulI) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_multiplyExactL: - if (!Matcher::match_rule_supported(Op_MulExactL) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowMulL) || !UseMathExactIntrinsics) return NULL; break; default: @@ -1970,18 +1970,8 @@ return true; } -void LibraryCallKit::inline_math_mathExact(Node* math) { - // If we didn't get the expected opcode it means we have optimized - // the node to something else and don't need the exception edge. - if (!math->is_MathExact()) { - set_result(math); - return; - } - - Node* result = _gvn.transform( new(C) ProjNode(math, MathExactNode::result_proj_node)); - Node* flags = _gvn.transform( new(C) FlagsProjNode(math, MathExactNode::flags_proj_node)); - - Node* bol = _gvn.transform( new (C) BoolNode(flags, BoolTest::overflow) ); +void LibraryCallKit::inline_math_mathExact(Node* math, Node *test) { + Node* bol = _gvn.transform( new (C) BoolNode(test, BoolTest::overflow) ); IfNode* check = create_and_map_if(control(), bol, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); Node* fast_path = _gvn.transform( new (C) IfFalseNode(check)); Node* slow_path = _gvn.transform( new (C) IfTrueNode(check) ); @@ -1999,7 +1989,7 @@ } set_control(fast_path); - set_result(result); + set_result(math); } bool LibraryCallKit::inline_math_addExactI(bool is_increment) { @@ -2012,8 +2002,10 @@ arg2 = argument(1); } - Node* add = _gvn.transform( new(C) AddExactINode(NULL, arg1, arg2) ); - inline_math_mathExact(add); + Node* add = _gvn.transform( new(C) AddINode(arg1, arg2) ); + Node* ofcheck = _gvn.transform( new(C) OverflowAddINode(arg1, arg2) ); + + inline_math_mathExact(add, ofcheck); return true; } @@ -2029,8 +2021,9 @@ // argument(3) == TOP } - Node* add = _gvn.transform(new(C) AddExactLNode(NULL, arg1, arg2)); - inline_math_mathExact(add); + Node* add = _gvn.transform(new(C) AddLNode(arg1, arg2)); + Node* ofcheck = _gvn.transform( new(C) OverflowAddLNode(arg1, arg2) ); + inline_math_mathExact(add, ofcheck); return true; } @@ -2044,8 +2037,9 @@ arg2 = argument(1); } - Node* sub = _gvn.transform(new(C) SubExactINode(NULL, arg1, arg2)); - inline_math_mathExact(sub); + Node* sub = _gvn.transform(new(C) SubINode(arg1, arg2)); + Node* ofcheck = _gvn.transform(new (C) OverflowSubINode(arg1, arg2)); + inline_math_mathExact(sub, ofcheck); return true; } @@ -2061,16 +2055,18 @@ // argument(3) == TOP } - Node* sub = _gvn.transform(new(C) SubExactLNode(NULL, arg1, arg2)); - inline_math_mathExact(sub); + Node* sub = _gvn.transform(new(C) SubLNode(arg1, arg2)); + Node* ofcheck = _gvn.transform(new (C) OverflowSubLNode(arg1, arg2)); + inline_math_mathExact(sub, ofcheck); return true; } bool LibraryCallKit::inline_math_negateExactI() { Node* arg1 = argument(0); - Node* neg = _gvn.transform(new(C) NegExactINode(NULL, arg1)); - inline_math_mathExact(neg); + Node* neg = _gvn.transform(new(C) SubINode(intcon(0), arg1)); + Node* ofcheck = _gvn.transform(new (C) OverflowSubINode(intcon(0), arg1)); + inline_math_mathExact(neg, ofcheck); return true; } @@ -2078,8 +2074,9 @@ Node* arg1 = argument(0); // argument(1) == TOP - Node* neg = _gvn.transform(new(C) NegExactLNode(NULL, arg1)); - inline_math_mathExact(neg); + Node* neg = _gvn.transform(new(C) SubLNode(longcon(0), arg1)); + Node* ofcheck = _gvn.transform(new (C) OverflowSubLNode(longcon(0), arg1)); + inline_math_mathExact(neg, ofcheck); return true; } @@ -2087,8 +2084,9 @@ Node* arg1 = argument(0); Node* arg2 = argument(1); - Node* mul = _gvn.transform(new(C) MulExactINode(NULL, arg1, arg2)); - inline_math_mathExact(mul); + Node* mul = _gvn.transform(new(C) MulINode(arg1, arg2)); + Node* ofcheck = _gvn.transform(new (C) OverflowMulINode(arg1, arg2)); + inline_math_mathExact(mul, ofcheck); return true; } @@ -2098,8 +2096,9 @@ Node* arg2 = argument(2); // argument(3) == TOP - Node* mul = _gvn.transform(new(C) MulExactLNode(NULL, arg1, arg2)); - inline_math_mathExact(mul); + Node* mul = _gvn.transform(new(C) MulLNode(arg1, arg2)); + Node* ofcheck = _gvn.transform(new (C) OverflowMulLNode(arg1, arg2)); + inline_math_mathExact(mul, ofcheck); return true; }