34 #include "opto/addnode.hpp"
35 #include "opto/castnode.hpp"
36 #include "opto/convertnode.hpp"
37 #include "opto/divnode.hpp"
38 #include "opto/idealGraphPrinter.hpp"
39 #include "opto/matcher.hpp"
40 #include "opto/memnode.hpp"
41 #include "opto/mulnode.hpp"
42 #include "opto/opaquenode.hpp"
43 #include "opto/parse.hpp"
44 #include "opto/runtime.hpp"
45 #include "runtime/deoptimization.hpp"
46 #include "runtime/sharedRuntime.hpp"
47
48 #ifndef PRODUCT
49 extern int explicit_null_checks_inserted,
50 explicit_null_checks_elided;
51 #endif
52
53 //---------------------------------array_load----------------------------------
54 void Parse::array_load(BasicType elem_type) {
55 const Type* elem = Type::TOP;
56 Node* adr = array_addressing(elem_type, 0, &elem);
57 if (stopped()) return; // guaranteed null or range check
58 dec_sp(2); // Pop array and index
59 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
60 Node* ld = make_load(control(), adr, elem, elem_type, adr_type, MemNode::unordered);
61 push(ld);
62 }
63
64
65 //--------------------------------array_store----------------------------------
66 void Parse::array_store(BasicType elem_type) {
67 const Type* elem = Type::TOP;
68 Node* adr = array_addressing(elem_type, 1, &elem);
69 if (stopped()) return; // guaranteed null or range check
70 Node* val = pop();
71 dec_sp(2); // Pop array and index
72 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
73 if (elem == TypeInt::BOOL) {
74 elem_type = T_BOOLEAN;
75 }
76 store_to_memory(control(), adr, val, elem_type, adr_type, StoreNode::release_if_reference(elem_type));
77 }
78
79
80 //------------------------------array_addressing-------------------------------
81 // Pull array and index from the stack. Compute pointer-to-element.
82 Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) {
83 Node *idx = peek(0+vals); // Get from stack without popping
84 Node *ary = peek(1+vals); // in case of exception
85
86 // Null check the array base, with correct stack contents
87 ary = null_check(ary, T_ARRAY);
88 // Compile-time detect of null-exception?
89 if (stopped()) return top();
90
91 const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr();
92 const TypeInt* sizetype = arytype->size();
93 const Type* elemtype = arytype->elem();
94
95 if (UseUniqueSubclasses && result2 != NULL) {
96 const Type* el = elemtype->make_ptr();
1696 push( b );
1697 push( a );
1698 break;
1699
1700 case Bytecodes::_arraylength: {
1701 // Must do null-check with value on expression stack
1702 Node *ary = null_check(peek(), T_ARRAY);
1703 // Compile-time detect of null-exception?
1704 if (stopped()) return;
1705 a = pop();
1706 push(load_array_length(a));
1707 break;
1708 }
1709
1710 case Bytecodes::_baload: array_load(T_BYTE); break;
1711 case Bytecodes::_caload: array_load(T_CHAR); break;
1712 case Bytecodes::_iaload: array_load(T_INT); break;
1713 case Bytecodes::_saload: array_load(T_SHORT); break;
1714 case Bytecodes::_faload: array_load(T_FLOAT); break;
1715 case Bytecodes::_aaload: array_load(T_OBJECT); break;
1716 case Bytecodes::_laload: {
1717 a = array_addressing(T_LONG, 0);
1718 if (stopped()) return; // guaranteed null or range check
1719 dec_sp(2); // Pop array and index
1720 push_pair(make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS, MemNode::unordered));
1721 break;
1722 }
1723 case Bytecodes::_daload: {
1724 a = array_addressing(T_DOUBLE, 0);
1725 if (stopped()) return; // guaranteed null or range check
1726 dec_sp(2); // Pop array and index
1727 push_pair(make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES, MemNode::unordered));
1728 break;
1729 }
1730 case Bytecodes::_bastore: array_store(T_BYTE); break;
1731 case Bytecodes::_castore: array_store(T_CHAR); break;
1732 case Bytecodes::_iastore: array_store(T_INT); break;
1733 case Bytecodes::_sastore: array_store(T_SHORT); break;
1734 case Bytecodes::_fastore: array_store(T_FLOAT); break;
1735 case Bytecodes::_aastore: {
1736 d = array_addressing(T_OBJECT, 1);
1737 if (stopped()) return; // guaranteed null or range check
1738 array_store_check();
1739 c = pop(); // Oop to store
1740 b = pop(); // index (already used)
1741 a = pop(); // the array itself
1742 const TypeOopPtr* elemtype = _gvn.type(a)->is_aryptr()->elem()->make_oopptr();
1743 const TypeAryPtr* adr_type = TypeAryPtr::OOPS;
1744 Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT,
1745 StoreNode::release_if_reference(T_OBJECT));
1746 break;
1747 }
1748 case Bytecodes::_lastore: {
1749 a = array_addressing(T_LONG, 2);
1750 if (stopped()) return; // guaranteed null or range check
1751 c = pop_pair();
1752 dec_sp(2); // Pop array and index
1753 store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS, MemNode::unordered);
1754 break;
1755 }
1756 case Bytecodes::_dastore: {
1757 a = array_addressing(T_DOUBLE, 2);
1758 if (stopped()) return; // guaranteed null or range check
1759 c = pop_pair();
1760 dec_sp(2); // Pop array and index
1761 c = dstore_rounding(c);
1762 store_to_memory(control(), a, c, T_DOUBLE, TypeAryPtr::DOUBLES, MemNode::unordered);
1763 break;
1764 }
1765 case Bytecodes::_getfield:
1766 do_getfield();
1767 break;
1768
1769 case Bytecodes::_getstatic:
1770 do_getstatic();
1771 break;
1772
1773 case Bytecodes::_putfield:
1774 do_putfield();
1775 break;
1776
1777 case Bytecodes::_putstatic:
1778 do_putstatic();
1779 break;
1780
1781 case Bytecodes::_irem:
1782 do_irem();
1783 break;
1784 case Bytecodes::_idiv:
|
34 #include "opto/addnode.hpp"
35 #include "opto/castnode.hpp"
36 #include "opto/convertnode.hpp"
37 #include "opto/divnode.hpp"
38 #include "opto/idealGraphPrinter.hpp"
39 #include "opto/matcher.hpp"
40 #include "opto/memnode.hpp"
41 #include "opto/mulnode.hpp"
42 #include "opto/opaquenode.hpp"
43 #include "opto/parse.hpp"
44 #include "opto/runtime.hpp"
45 #include "runtime/deoptimization.hpp"
46 #include "runtime/sharedRuntime.hpp"
47
48 #ifndef PRODUCT
49 extern int explicit_null_checks_inserted,
50 explicit_null_checks_elided;
51 #endif
52
53 //---------------------------------array_load----------------------------------
54 void Parse::array_load(BasicType bt) {
55 const Type* elemtype = Type::TOP;
56 bool big_val = bt == T_DOUBLE || bt == T_LONG;
57 Node* adr = array_addressing(bt, 0, &elemtype);
58 if (stopped()) return; // guaranteed null or range check
59
60 pop(); // index (already used)
61 Node* array = pop(); // the array itself
62
63 if (elemtype == TypeInt::BOOL) {
64 bt = T_BOOLEAN;
65 } else if (bt == T_OBJECT) {
66 elemtype = _gvn.type(array)->is_aryptr()->elem()->make_oopptr();
67 }
68
69 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(bt);
70
71 Node* ld = access_load_at(array, adr, adr_type, elemtype, bt, C2_MO_RELAXED | C2_ACCESS_ON_HEAP | C2_ACCESS_ON_ARRAY);
72 if (big_val) {
73 push_pair(ld);
74 } else {
75 push(ld);
76 }
77 }
78
79
80 //--------------------------------array_store----------------------------------
81 void Parse::array_store(BasicType bt) {
82 const Type* elemtype = Type::TOP;
83 bool big_val = bt == T_DOUBLE || bt == T_LONG;
84 Node* adr = array_addressing(bt, big_val ? 2 : 1, &elemtype);
85 if (stopped()) return; // guaranteed null or range check
86 if (bt == T_OBJECT) {
87 array_store_check();
88 }
89 Node* val; // Oop to store
90 if (big_val) {
91 val = pop_pair();
92 } else {
93 val = pop();
94 }
95 pop(); // index (already used)
96 Node* array = pop(); // the array itself
97
98 if (elemtype == TypeInt::BOOL) {
99 bt = T_BOOLEAN;
100 } else if (bt == T_OBJECT) {
101 elemtype = _gvn.type(array)->is_aryptr()->elem()->make_oopptr();
102 }
103
104 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(bt);
105
106 access_store_at(control(), array, adr, adr_type, val, elemtype, bt, C2_MO_RELAXED | C2_ACCESS_ON_HEAP | C2_ACCESS_ON_ARRAY);
107 }
108
109
110 //------------------------------array_addressing-------------------------------
111 // Pull array and index from the stack. Compute pointer-to-element.
112 Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) {
113 Node *idx = peek(0+vals); // Get from stack without popping
114 Node *ary = peek(1+vals); // in case of exception
115
116 // Null check the array base, with correct stack contents
117 ary = null_check(ary, T_ARRAY);
118 // Compile-time detect of null-exception?
119 if (stopped()) return top();
120
121 const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr();
122 const TypeInt* sizetype = arytype->size();
123 const Type* elemtype = arytype->elem();
124
125 if (UseUniqueSubclasses && result2 != NULL) {
126 const Type* el = elemtype->make_ptr();
1726 push( b );
1727 push( a );
1728 break;
1729
1730 case Bytecodes::_arraylength: {
1731 // Must do null-check with value on expression stack
1732 Node *ary = null_check(peek(), T_ARRAY);
1733 // Compile-time detect of null-exception?
1734 if (stopped()) return;
1735 a = pop();
1736 push(load_array_length(a));
1737 break;
1738 }
1739
1740 case Bytecodes::_baload: array_load(T_BYTE); break;
1741 case Bytecodes::_caload: array_load(T_CHAR); break;
1742 case Bytecodes::_iaload: array_load(T_INT); break;
1743 case Bytecodes::_saload: array_load(T_SHORT); break;
1744 case Bytecodes::_faload: array_load(T_FLOAT); break;
1745 case Bytecodes::_aaload: array_load(T_OBJECT); break;
1746 case Bytecodes::_laload: array_load(T_LONG); break;
1747 case Bytecodes::_daload: array_load(T_DOUBLE); break;
1748 case Bytecodes::_bastore: array_store(T_BYTE); break;
1749 case Bytecodes::_castore: array_store(T_CHAR); break;
1750 case Bytecodes::_iastore: array_store(T_INT); break;
1751 case Bytecodes::_sastore: array_store(T_SHORT); break;
1752 case Bytecodes::_fastore: array_store(T_FLOAT); break;
1753 case Bytecodes::_aastore: array_store(T_OBJECT); break;
1754 case Bytecodes::_lastore: array_store(T_LONG); break;
1755 case Bytecodes::_dastore: array_store(T_DOUBLE); break;
1756
1757 case Bytecodes::_getfield:
1758 do_getfield();
1759 break;
1760
1761 case Bytecodes::_getstatic:
1762 do_getstatic();
1763 break;
1764
1765 case Bytecodes::_putfield:
1766 do_putfield();
1767 break;
1768
1769 case Bytecodes::_putstatic:
1770 do_putstatic();
1771 break;
1772
1773 case Bytecodes::_irem:
1774 do_irem();
1775 break;
1776 case Bytecodes::_idiv:
|