98 return top(); |
98 return top(); |
99 } |
99 } |
100 |
100 |
101 // Do the range check |
101 // Do the range check |
102 if (GenerateRangeChecks && need_range_check) { |
102 if (GenerateRangeChecks && need_range_check) { |
103 // Range is constant in array-oop, so we can use the original state of mem |
|
104 Node* len = load_array_length(ary); |
|
105 Node* tst; |
103 Node* tst; |
106 if (sizetype->_hi <= 0) { |
104 if (sizetype->_hi <= 0) { |
107 // If the greatest array bound is negative, we can conclude that we're |
105 // The greatest array bound is negative, so we can conclude that we're |
108 // compiling unreachable code, but the unsigned compare trick used below |
106 // compiling unreachable code, but the unsigned compare trick used below |
109 // only works with non-negative lengths. Instead, hack "tst" to be zero so |
107 // only works with non-negative lengths. Instead, hack "tst" to be zero so |
110 // the uncommon_trap path will always be taken. |
108 // the uncommon_trap path will always be taken. |
111 tst = _gvn.intcon(0); |
109 tst = _gvn.intcon(0); |
112 } else { |
110 } else { |
|
111 // Range is constant in array-oop, so we can use the original state of mem |
|
112 Node* len = load_array_length(ary); |
|
113 |
113 // Test length vs index (standard trick using unsigned compare) |
114 // Test length vs index (standard trick using unsigned compare) |
114 Node* chk = _gvn.transform( new (C, 3) CmpUNode(idx, len) ); |
115 Node* chk = _gvn.transform( new (C, 3) CmpUNode(idx, len) ); |
115 BoolTest::mask btest = BoolTest::lt; |
116 BoolTest::mask btest = BoolTest::lt; |
116 tst = _gvn.transform( new (C, 2) BoolNode(chk, btest) ); |
117 tst = _gvn.transform( new (C, 2) BoolNode(chk, btest) ); |
117 } |
118 } |
135 } |
136 } |
136 } |
137 } |
137 // Check for always knowing you are throwing a range-check exception |
138 // Check for always knowing you are throwing a range-check exception |
138 if (stopped()) return top(); |
139 if (stopped()) return top(); |
139 |
140 |
140 Node* ptr = array_element_address( ary, idx, type, sizetype); |
141 Node* ptr = array_element_address(ary, idx, type, sizetype); |
141 |
142 |
142 if (result2 != NULL) *result2 = elemtype; |
143 if (result2 != NULL) *result2 = elemtype; |
|
144 |
|
145 assert(ptr != top(), "top should go hand-in-hand with stopped"); |
|
146 |
143 return ptr; |
147 return ptr; |
144 } |
148 } |
145 |
149 |
146 |
150 |
147 // returns IfNode |
151 // returns IfNode |