33 #include "opto/addnode.hpp"
34 #include "opto/castnode.hpp"
35 #include "opto/convertnode.hpp"
36 #include "opto/divnode.hpp"
37 #include "opto/idealGraphPrinter.hpp"
38 #include "opto/matcher.hpp"
39 #include "opto/memnode.hpp"
40 #include "opto/mulnode.hpp"
41 #include "opto/opaquenode.hpp"
42 #include "opto/parse.hpp"
43 #include "opto/runtime.hpp"
44 #include "runtime/deoptimization.hpp"
45 #include "runtime/sharedRuntime.hpp"
46
47 #ifndef PRODUCT
48 extern int explicit_null_checks_inserted,
49 explicit_null_checks_elided;
50 #endif
51
52 //---------------------------------array_load----------------------------------
53 void Parse::array_load(BasicType elem_type) {
54 const Type* elem = Type::TOP;
55 Node* adr = array_addressing(elem_type, 0, &elem);
56 if (stopped()) return; // guaranteed null or range check
57 dec_sp(2); // Pop array and index
58 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
59 Node* ld = make_load(control(), adr, elem, elem_type, adr_type, MemNode::unordered);
60 push(ld);
61 }
62
63
64 //--------------------------------array_store----------------------------------
65 void Parse::array_store(BasicType elem_type) {
66 const Type* elem = Type::TOP;
67 Node* adr = array_addressing(elem_type, 1, &elem);
68 if (stopped()) return; // guaranteed null or range check
69 Node* val = pop();
70 dec_sp(2); // Pop array and index
71 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
72 if (elem == TypeInt::BOOL) {
73 elem_type = T_BOOLEAN;
74 }
75 store_to_memory(control(), adr, val, elem_type, adr_type, StoreNode::release_if_reference(elem_type));
76 }
77
78
79 //------------------------------array_addressing-------------------------------
80 // Pull array and index from the stack. Compute pointer-to-element.
81 Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) {
82 Node *idx = peek(0+vals); // Get from stack without popping
83 Node *ary = peek(1+vals); // in case of exception
84
85 // Null check the array base, with correct stack contents
86 ary = null_check(ary, T_ARRAY);
87 // Compile-time detect of null-exception?
88 if (stopped()) return top();
89
90 const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr();
91 const TypeInt* sizetype = arytype->size();
92 const Type* elemtype = arytype->elem();
93
94 if (UseUniqueSubclasses && result2 != NULL) {
|
33 #include "opto/addnode.hpp"
34 #include "opto/castnode.hpp"
35 #include "opto/convertnode.hpp"
36 #include "opto/divnode.hpp"
37 #include "opto/idealGraphPrinter.hpp"
38 #include "opto/matcher.hpp"
39 #include "opto/memnode.hpp"
40 #include "opto/mulnode.hpp"
41 #include "opto/opaquenode.hpp"
42 #include "opto/parse.hpp"
43 #include "opto/runtime.hpp"
44 #include "runtime/deoptimization.hpp"
45 #include "runtime/sharedRuntime.hpp"
46
47 #ifndef PRODUCT
48 extern int explicit_null_checks_inserted,
49 explicit_null_checks_elided;
50 #endif
51
52 //---------------------------------array_load----------------------------------
53 void Parse::array_load(BasicType bt) {
54 const Type* elemtype = Type::TOP;
55 bool big_val = bt == T_DOUBLE || bt == T_LONG;
56 Node* adr = array_addressing(bt, 0, &elemtype);
57 if (stopped()) return; // guaranteed null or range check
58
59 pop(); // index (already used)
60 Node* array = pop(); // the array itself
61
62 if (elemtype == TypeInt::BOOL) {
63 bt = T_BOOLEAN;
64 } else if (bt == T_OBJECT) {
65 elemtype = _gvn.type(array)->is_aryptr()->elem()->make_oopptr();
66 }
67
68 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(bt);
69
70 Node* ld = access_load_at(array, adr, adr_type, elemtype, bt,
71 IN_HEAP | IN_HEAP_ARRAY | C2_CONTROL_DEPENDENT_LOAD);
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, MO_UNORDERED | IN_HEAP | IN_HEAP_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) {
|
2123 c = pop();
2124 d = pop();
2125 push( b );
2126 push( a );
2127 push( d );
2128 push( c );
2129 push( b );
2130 push( a );
2131 break;
2132
2133 case Bytecodes::_arraylength: {
2134 // Must do null-check with value on expression stack
2135 Node *ary = null_check(peek(), T_ARRAY);
2136 // Compile-time detect of null-exception?
2137 if (stopped()) return;
2138 a = pop();
2139 push(load_array_length(a));
2140 break;
2141 }
2142
2143 case Bytecodes::_baload: array_load(T_BYTE); break;
2144 case Bytecodes::_caload: array_load(T_CHAR); break;
2145 case Bytecodes::_iaload: array_load(T_INT); break;
2146 case Bytecodes::_saload: array_load(T_SHORT); break;
2147 case Bytecodes::_faload: array_load(T_FLOAT); break;
2148 case Bytecodes::_aaload: array_load(T_OBJECT); break;
2149 case Bytecodes::_laload: {
2150 a = array_addressing(T_LONG, 0);
2151 if (stopped()) return; // guaranteed null or range check
2152 dec_sp(2); // Pop array and index
2153 push_pair(make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS, MemNode::unordered));
2154 break;
2155 }
2156 case Bytecodes::_daload: {
2157 a = array_addressing(T_DOUBLE, 0);
2158 if (stopped()) return; // guaranteed null or range check
2159 dec_sp(2); // Pop array and index
2160 push_pair(make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES, MemNode::unordered));
2161 break;
2162 }
2163 case Bytecodes::_bastore: array_store(T_BYTE); break;
2164 case Bytecodes::_castore: array_store(T_CHAR); break;
2165 case Bytecodes::_iastore: array_store(T_INT); break;
2166 case Bytecodes::_sastore: array_store(T_SHORT); break;
2167 case Bytecodes::_fastore: array_store(T_FLOAT); break;
2168 case Bytecodes::_aastore: {
2169 d = array_addressing(T_OBJECT, 1);
2170 if (stopped()) return; // guaranteed null or range check
2171 array_store_check();
2172 c = pop(); // Oop to store
2173 b = pop(); // index (already used)
2174 a = pop(); // the array itself
2175 const TypeOopPtr* elemtype = _gvn.type(a)->is_aryptr()->elem()->make_oopptr();
2176 const TypeAryPtr* adr_type = TypeAryPtr::OOPS;
2177 Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT,
2178 StoreNode::release_if_reference(T_OBJECT));
2179 break;
2180 }
2181 case Bytecodes::_lastore: {
2182 a = array_addressing(T_LONG, 2);
2183 if (stopped()) return; // guaranteed null or range check
2184 c = pop_pair();
2185 dec_sp(2); // Pop array and index
2186 store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS, MemNode::unordered);
2187 break;
2188 }
2189 case Bytecodes::_dastore: {
2190 a = array_addressing(T_DOUBLE, 2);
2191 if (stopped()) return; // guaranteed null or range check
2192 c = pop_pair();
2193 dec_sp(2); // Pop array and index
2194 c = dstore_rounding(c);
2195 store_to_memory(control(), a, c, T_DOUBLE, TypeAryPtr::DOUBLES, MemNode::unordered);
2196 break;
2197 }
2198 case Bytecodes::_getfield:
2199 do_getfield();
2200 break;
2201
2202 case Bytecodes::_getstatic:
2203 do_getstatic();
2204 break;
2205
2206 case Bytecodes::_putfield:
2207 do_putfield();
2208 break;
2209
2210 case Bytecodes::_putstatic:
2211 do_putstatic();
2212 break;
2213
2214 case Bytecodes::_irem:
2215 do_irem();
2216 break;
|
2154 c = pop();
2155 d = pop();
2156 push( b );
2157 push( a );
2158 push( d );
2159 push( c );
2160 push( b );
2161 push( a );
2162 break;
2163
2164 case Bytecodes::_arraylength: {
2165 // Must do null-check with value on expression stack
2166 Node *ary = null_check(peek(), T_ARRAY);
2167 // Compile-time detect of null-exception?
2168 if (stopped()) return;
2169 a = pop();
2170 push(load_array_length(a));
2171 break;
2172 }
2173
2174 case Bytecodes::_baload: array_load(T_BYTE); break;
2175 case Bytecodes::_caload: array_load(T_CHAR); break;
2176 case Bytecodes::_iaload: array_load(T_INT); break;
2177 case Bytecodes::_saload: array_load(T_SHORT); break;
2178 case Bytecodes::_faload: array_load(T_FLOAT); break;
2179 case Bytecodes::_aaload: array_load(T_OBJECT); break;
2180 case Bytecodes::_laload: array_load(T_LONG); break;
2181 case Bytecodes::_daload: array_load(T_DOUBLE); break;
2182 case Bytecodes::_bastore: array_store(T_BYTE); break;
2183 case Bytecodes::_castore: array_store(T_CHAR); break;
2184 case Bytecodes::_iastore: array_store(T_INT); break;
2185 case Bytecodes::_sastore: array_store(T_SHORT); break;
2186 case Bytecodes::_fastore: array_store(T_FLOAT); break;
2187 case Bytecodes::_aastore: array_store(T_OBJECT); break;
2188 case Bytecodes::_lastore: array_store(T_LONG); break;
2189 case Bytecodes::_dastore: array_store(T_DOUBLE); break;
2190
2191 case Bytecodes::_getfield:
2192 do_getfield();
2193 break;
2194
2195 case Bytecodes::_getstatic:
2196 do_getstatic();
2197 break;
2198
2199 case Bytecodes::_putfield:
2200 do_putfield();
2201 break;
2202
2203 case Bytecodes::_putstatic:
2204 do_putstatic();
2205 break;
2206
2207 case Bytecodes::_irem:
2208 do_irem();
2209 break;
|