Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/parse2.cpp @ 7194:beebba0acc11
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
Reviewed-by: kvn, jrose
author | twisti |
---|---|
date | Mon, 26 Nov 2012 17:25:11 -0800 |
parents | 8e47bac5643a |
children | e370f63dc5b1 |
comparison
equal
deleted
inserted
replaced
7193:ee32440febeb | 7194:beebba0acc11 |
---|---|
46 //---------------------------------array_load---------------------------------- | 46 //---------------------------------array_load---------------------------------- |
47 void Parse::array_load(BasicType elem_type) { | 47 void Parse::array_load(BasicType elem_type) { |
48 const Type* elem = Type::TOP; | 48 const Type* elem = Type::TOP; |
49 Node* adr = array_addressing(elem_type, 0, &elem); | 49 Node* adr = array_addressing(elem_type, 0, &elem); |
50 if (stopped()) return; // guaranteed null or range check | 50 if (stopped()) return; // guaranteed null or range check |
51 _sp -= 2; // Pop array and index | 51 dec_sp(2); // Pop array and index |
52 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type); | 52 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type); |
53 Node* ld = make_load(control(), adr, elem, elem_type, adr_type); | 53 Node* ld = make_load(control(), adr, elem, elem_type, adr_type); |
54 push(ld); | 54 push(ld); |
55 } | 55 } |
56 | 56 |
58 //--------------------------------array_store---------------------------------- | 58 //--------------------------------array_store---------------------------------- |
59 void Parse::array_store(BasicType elem_type) { | 59 void Parse::array_store(BasicType elem_type) { |
60 Node* adr = array_addressing(elem_type, 1); | 60 Node* adr = array_addressing(elem_type, 1); |
61 if (stopped()) return; // guaranteed null or range check | 61 if (stopped()) return; // guaranteed null or range check |
62 Node* val = pop(); | 62 Node* val = pop(); |
63 _sp -= 2; // Pop array and index | 63 dec_sp(2); // Pop array and index |
64 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type); | 64 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type); |
65 store_to_memory(control(), adr, val, elem_type, adr_type); | 65 store_to_memory(control(), adr, val, elem_type, adr_type); |
66 } | 66 } |
67 | 67 |
68 | 68 |
71 Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) { | 71 Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) { |
72 Node *idx = peek(0+vals); // Get from stack without popping | 72 Node *idx = peek(0+vals); // Get from stack without popping |
73 Node *ary = peek(1+vals); // in case of exception | 73 Node *ary = peek(1+vals); // in case of exception |
74 | 74 |
75 // Null check the array base, with correct stack contents | 75 // Null check the array base, with correct stack contents |
76 ary = do_null_check(ary, T_ARRAY); | 76 ary = null_check(ary, T_ARRAY); |
77 // Compile-time detect of null-exception? | 77 // Compile-time detect of null-exception? |
78 if (stopped()) return top(); | 78 if (stopped()) return top(); |
79 | 79 |
80 const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr(); | 80 const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr(); |
81 const TypeInt* sizetype = arytype->size(); | 81 const TypeInt* sizetype = arytype->size(); |
679 push(res); | 679 push(res); |
680 } | 680 } |
681 | 681 |
682 void Parse::do_irem() { | 682 void Parse::do_irem() { |
683 // Must keep both values on the expression-stack during null-check | 683 // Must keep both values on the expression-stack during null-check |
684 do_null_check(peek(), T_INT); | 684 zero_check_int(peek()); |
685 // Compile-time detect of null-exception? | 685 // Compile-time detect of null-exception? |
686 if (stopped()) return; | 686 if (stopped()) return; |
687 | 687 |
688 Node* b = pop(); | 688 Node* b = pop(); |
689 Node* a = pop(); | 689 Node* a = pop(); |
956 int bc_depth = - Bytecodes::depth(iter().cur_bc()); | 956 int bc_depth = - Bytecodes::depth(iter().cur_bc()); |
957 assert(bc_depth == 1 || bc_depth == 2, "only two kinds of branches"); | 957 assert(bc_depth == 1 || bc_depth == 2, "only two kinds of branches"); |
958 DEBUG_ONLY(sync_jvms()); // argument(n) requires a synced jvms | 958 DEBUG_ONLY(sync_jvms()); // argument(n) requires a synced jvms |
959 assert(argument(0) != NULL, "must exist"); | 959 assert(argument(0) != NULL, "must exist"); |
960 assert(bc_depth == 1 || argument(1) != NULL, "two must exist"); | 960 assert(bc_depth == 1 || argument(1) != NULL, "two must exist"); |
961 _sp += bc_depth; | 961 inc_sp(bc_depth); |
962 return bc_depth; | 962 return bc_depth; |
963 } | 963 } |
964 | 964 |
965 //----------------------------------do_ifnull---------------------------------- | 965 //----------------------------------do_ifnull---------------------------------- |
966 void Parse::do_ifnull(BoolTest::mask btest, Node *c) { | 966 void Parse::do_ifnull(BoolTest::mask btest, Node *c) { |
1579 break; | 1579 break; |
1580 case Bytecodes::_dstore: | 1580 case Bytecodes::_dstore: |
1581 set_pair_local( iter().get_index(), dstore_rounding(pop_pair()) ); | 1581 set_pair_local( iter().get_index(), dstore_rounding(pop_pair()) ); |
1582 break; | 1582 break; |
1583 | 1583 |
1584 case Bytecodes::_pop: _sp -= 1; break; | 1584 case Bytecodes::_pop: dec_sp(1); break; |
1585 case Bytecodes::_pop2: _sp -= 2; break; | 1585 case Bytecodes::_pop2: dec_sp(2); break; |
1586 case Bytecodes::_swap: | 1586 case Bytecodes::_swap: |
1587 a = pop(); | 1587 a = pop(); |
1588 b = pop(); | 1588 b = pop(); |
1589 push(a); | 1589 push(a); |
1590 push(b); | 1590 push(b); |
1648 push( a ); | 1648 push( a ); |
1649 break; | 1649 break; |
1650 | 1650 |
1651 case Bytecodes::_arraylength: { | 1651 case Bytecodes::_arraylength: { |
1652 // Must do null-check with value on expression stack | 1652 // Must do null-check with value on expression stack |
1653 Node *ary = do_null_check(peek(), T_ARRAY); | 1653 Node *ary = null_check(peek(), T_ARRAY); |
1654 // Compile-time detect of null-exception? | 1654 // Compile-time detect of null-exception? |
1655 if (stopped()) return; | 1655 if (stopped()) return; |
1656 a = pop(); | 1656 a = pop(); |
1657 push(load_array_length(a)); | 1657 push(load_array_length(a)); |
1658 break; | 1658 break; |
1665 case Bytecodes::_faload: array_load(T_FLOAT); break; | 1665 case Bytecodes::_faload: array_load(T_FLOAT); break; |
1666 case Bytecodes::_aaload: array_load(T_OBJECT); break; | 1666 case Bytecodes::_aaload: array_load(T_OBJECT); break; |
1667 case Bytecodes::_laload: { | 1667 case Bytecodes::_laload: { |
1668 a = array_addressing(T_LONG, 0); | 1668 a = array_addressing(T_LONG, 0); |
1669 if (stopped()) return; // guaranteed null or range check | 1669 if (stopped()) return; // guaranteed null or range check |
1670 _sp -= 2; // Pop array and index | 1670 dec_sp(2); // Pop array and index |
1671 push_pair( make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS)); | 1671 push_pair(make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS)); |
1672 break; | 1672 break; |
1673 } | 1673 } |
1674 case Bytecodes::_daload: { | 1674 case Bytecodes::_daload: { |
1675 a = array_addressing(T_DOUBLE, 0); | 1675 a = array_addressing(T_DOUBLE, 0); |
1676 if (stopped()) return; // guaranteed null or range check | 1676 if (stopped()) return; // guaranteed null or range check |
1677 _sp -= 2; // Pop array and index | 1677 dec_sp(2); // Pop array and index |
1678 push_pair( make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES)); | 1678 push_pair(make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES)); |
1679 break; | 1679 break; |
1680 } | 1680 } |
1681 case Bytecodes::_bastore: array_store(T_BYTE); break; | 1681 case Bytecodes::_bastore: array_store(T_BYTE); break; |
1682 case Bytecodes::_castore: array_store(T_CHAR); break; | 1682 case Bytecodes::_castore: array_store(T_CHAR); break; |
1683 case Bytecodes::_iastore: array_store(T_INT); break; | 1683 case Bytecodes::_iastore: array_store(T_INT); break; |
1697 } | 1697 } |
1698 case Bytecodes::_lastore: { | 1698 case Bytecodes::_lastore: { |
1699 a = array_addressing(T_LONG, 2); | 1699 a = array_addressing(T_LONG, 2); |
1700 if (stopped()) return; // guaranteed null or range check | 1700 if (stopped()) return; // guaranteed null or range check |
1701 c = pop_pair(); | 1701 c = pop_pair(); |
1702 _sp -= 2; // Pop array and index | 1702 dec_sp(2); // Pop array and index |
1703 store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS); | 1703 store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS); |
1704 break; | 1704 break; |
1705 } | 1705 } |
1706 case Bytecodes::_dastore: { | 1706 case Bytecodes::_dastore: { |
1707 a = array_addressing(T_DOUBLE, 2); | 1707 a = array_addressing(T_DOUBLE, 2); |
1708 if (stopped()) return; // guaranteed null or range check | 1708 if (stopped()) return; // guaranteed null or range check |
1709 c = pop_pair(); | 1709 c = pop_pair(); |
1710 _sp -= 2; // Pop array and index | 1710 dec_sp(2); // Pop array and index |
1711 c = dstore_rounding(c); | 1711 c = dstore_rounding(c); |
1712 store_to_memory(control(), a, c, T_DOUBLE, TypeAryPtr::DOUBLES); | 1712 store_to_memory(control(), a, c, T_DOUBLE, TypeAryPtr::DOUBLES); |
1713 break; | 1713 break; |
1714 } | 1714 } |
1715 case Bytecodes::_getfield: | 1715 case Bytecodes::_getfield: |
1731 case Bytecodes::_irem: | 1731 case Bytecodes::_irem: |
1732 do_irem(); | 1732 do_irem(); |
1733 break; | 1733 break; |
1734 case Bytecodes::_idiv: | 1734 case Bytecodes::_idiv: |
1735 // Must keep both values on the expression-stack during null-check | 1735 // Must keep both values on the expression-stack during null-check |
1736 do_null_check(peek(), T_INT); | 1736 zero_check_int(peek()); |
1737 // Compile-time detect of null-exception? | 1737 // Compile-time detect of null-exception? |
1738 if (stopped()) return; | 1738 if (stopped()) return; |
1739 b = pop(); | 1739 b = pop(); |
1740 a = pop(); | 1740 a = pop(); |
1741 push( _gvn.transform( new (C) DivINode(control(),a,b) ) ); | 1741 push( _gvn.transform( new (C) DivINode(control(),a,b) ) ); |
2039 break; | 2039 break; |
2040 | 2040 |
2041 case Bytecodes::_lrem: | 2041 case Bytecodes::_lrem: |
2042 // Must keep both values on the expression-stack during null-check | 2042 // Must keep both values on the expression-stack during null-check |
2043 assert(peek(0) == top(), "long word order"); | 2043 assert(peek(0) == top(), "long word order"); |
2044 do_null_check(peek(1), T_LONG); | 2044 zero_check_long(peek(1)); |
2045 // Compile-time detect of null-exception? | 2045 // Compile-time detect of null-exception? |
2046 if (stopped()) return; | 2046 if (stopped()) return; |
2047 b = pop_pair(); | 2047 b = pop_pair(); |
2048 a = pop_pair(); | 2048 a = pop_pair(); |
2049 c = _gvn.transform( new (C) ModLNode(control(),a,b) ); | 2049 c = _gvn.transform( new (C) ModLNode(control(),a,b) ); |
2051 break; | 2051 break; |
2052 | 2052 |
2053 case Bytecodes::_ldiv: | 2053 case Bytecodes::_ldiv: |
2054 // Must keep both values on the expression-stack during null-check | 2054 // Must keep both values on the expression-stack during null-check |
2055 assert(peek(0) == top(), "long word order"); | 2055 assert(peek(0) == top(), "long word order"); |
2056 do_null_check(peek(1), T_LONG); | 2056 zero_check_long(peek(1)); |
2057 // Compile-time detect of null-exception? | 2057 // Compile-time detect of null-exception? |
2058 if (stopped()) return; | 2058 if (stopped()) return; |
2059 b = pop_pair(); | 2059 b = pop_pair(); |
2060 a = pop_pair(); | 2060 a = pop_pair(); |
2061 c = _gvn.transform( new (C) DivLNode(control(),a,b) ); | 2061 c = _gvn.transform( new (C) DivLNode(control(),a,b) ); |
2173 return_current(pop_pair()); | 2173 return_current(pop_pair()); |
2174 break; | 2174 break; |
2175 | 2175 |
2176 case Bytecodes::_athrow: | 2176 case Bytecodes::_athrow: |
2177 // null exception oop throws NULL pointer exception | 2177 // null exception oop throws NULL pointer exception |
2178 do_null_check(peek(), T_OBJECT); | 2178 null_check(peek()); |
2179 if (stopped()) return; | 2179 if (stopped()) return; |
2180 // Hook the thrown exception directly to subsequent handlers. | 2180 // Hook the thrown exception directly to subsequent handlers. |
2181 if (BailoutToInterpreterForThrows) { | 2181 if (BailoutToInterpreterForThrows) { |
2182 // Keep method interpreted from now on. | 2182 // Keep method interpreted from now on. |
2183 uncommon_trap(Deoptimization::Reason_unhandled, | 2183 uncommon_trap(Deoptimization::Reason_unhandled, |