156 // ------------------------------------------------------------------
157 // Constant pool access
158 // ------------------------------------------------------------------
159
160 // ------------------------------------------------------------------
161 // ciBytecodeStream::get_klass_index
162 //
163 // If this bytecodes references a klass, return the index of the
164 // referenced klass.
165 int ciBytecodeStream::get_klass_index() const {
166 switch(cur_bc()) {
167 case Bytecodes::_ldc:
168 return get_index_u1();
169 case Bytecodes::_ldc_w:
170 case Bytecodes::_ldc2_w:
171 case Bytecodes::_checkcast:
172 case Bytecodes::_instanceof:
173 case Bytecodes::_anewarray:
174 case Bytecodes::_multianewarray:
175 case Bytecodes::_new:
176 case Bytecodes::_newarray:
177 return get_index_u2();
178 default:
179 ShouldNotReachHere();
180 return 0;
181 }
182 }
183
184 // ------------------------------------------------------------------
185 // ciBytecodeStream::get_klass
186 //
187 // If this bytecode is a new, newarray, multianewarray, instanceof,
188 // or checkcast, get the referenced klass.
189 ciKlass* ciBytecodeStream::get_klass(bool& will_link) {
190 VM_ENTRY_MARK;
191 constantPoolHandle cpool(THREAD, _method->get_Method()->constants());
192 return CURRENT_ENV->get_klass_by_index(cpool, get_klass_index(), will_link, _holder);
193 }
194
195 // ciBytecodeStream::get_klass
196 //
197 // If this bytecode is a new, newarray, multianewarray, instanceof,
198 // or checkcast, get the referenced klass. Retuns an unloaded ciKlass
199 // if the referenced klass is not accessible.
200 ciKlass* ciBytecodeStream::get_klass() {
201 bool will_link;
202 ciKlass* klass = get_klass(will_link);
203 if (!will_link && klass->is_loaded()) { // klass not accessible
204 VM_ENTRY_MARK;
205 klass = CURRENT_ENV->get_unloaded_klass(_holder, klass->name());
206 }
207 return klass;
208 }
209
210 // ------------------------------------------------------------------
211 // ciBytecodeStream::get_constant_raw_index
212 //
213 // If this bytecode is one of the ldc variants, get the index of the
214 // referenced constant.
215 int ciBytecodeStream::get_constant_raw_index() const {
216 // work-alike for Bytecode_loadconstant::raw_index()
217 switch (cur_bc()) {
218 case Bytecodes::_ldc:
219 return get_index_u1();
220 case Bytecodes::_ldc_w:
221 case Bytecodes::_ldc2_w:
222 return get_index_u2();
223 default:
224 ShouldNotReachHere();
225 return 0;
226 }
227 }
228
229 // ------------------------------------------------------------------
280 return _method->get_Method()->constants()->tag_at(index);
281 }
282
283 // ------------------------------------------------------------------
284 // ciBytecodeStream::get_basic_type_for_constant_at
285 //
286 BasicType ciBytecodeStream::get_basic_type_for_constant_at(int index) const {
287 VM_ENTRY_MARK;
288 return _method->get_Method()->constants()->basic_type_for_constant_at(index);
289 }
290
291 // ------------------------------------------------------------------
292 // ciBytecodeStream::get_field_index
293 //
294 // If this is a field access bytecode, get the constant pool
295 // index of the referenced field.
296 int ciBytecodeStream::get_field_index() {
297 assert(cur_bc() == Bytecodes::_getfield ||
298 cur_bc() == Bytecodes::_putfield ||
299 cur_bc() == Bytecodes::_getstatic ||
300 cur_bc() == Bytecodes::_putstatic, "wrong bc");
301 return get_index_u2_cpcache();
302 }
303
304
305 // ------------------------------------------------------------------
306 // ciBytecodeStream::get_field
307 //
308 // If this bytecode is one of get_field, get_static, put_field,
309 // or put_static, get the referenced field.
310 ciField* ciBytecodeStream::get_field(bool& will_link) {
311 ciField* f = CURRENT_ENV->get_field_by_index(_holder, get_field_index());
312 will_link = f->will_link(_method, _bc);
313 return f;
314 }
315
316
317 // ------------------------------------------------------------------
318 // ciBytecodeStream::get_declared_field_holder
319 //
320 // Get the declared holder of the currently referenced field.
|
156 // ------------------------------------------------------------------
157 // Constant pool access
158 // ------------------------------------------------------------------
159
160 // ------------------------------------------------------------------
161 // ciBytecodeStream::get_klass_index
162 //
163 // If this bytecodes references a klass, return the index of the
164 // referenced klass.
165 int ciBytecodeStream::get_klass_index() const {
166 switch(cur_bc()) {
167 case Bytecodes::_ldc:
168 return get_index_u1();
169 case Bytecodes::_ldc_w:
170 case Bytecodes::_ldc2_w:
171 case Bytecodes::_checkcast:
172 case Bytecodes::_instanceof:
173 case Bytecodes::_anewarray:
174 case Bytecodes::_multianewarray:
175 case Bytecodes::_new:
176 case Bytecodes::_aconst_init:
177 case Bytecodes::_newarray:
178 return get_index_u2();
179 default:
180 ShouldNotReachHere();
181 return 0;
182 }
183 }
184
185 // ------------------------------------------------------------------
186 // ciBytecodeStream::get_klass
187 //
188 // If this bytecode is a new, newarray, multianewarray, instanceof,
189 // or checkcast, get the referenced klass.
190 ciKlass* ciBytecodeStream::get_klass(bool& will_link) {
191 VM_ENTRY_MARK;
192 constantPoolHandle cpool(THREAD, _method->get_Method()->constants());
193 return CURRENT_ENV->get_klass_by_index(cpool, get_klass_index(), will_link, _holder);
194 }
195
196 // ciBytecodeStream::get_klass
197 //
198 // If this bytecode is a new, newarray, multianewarray, instanceof,
199 // or checkcast, get the referenced klass. Retuns an unloaded ciKlass
200 // if the referenced klass is not accessible.
201 ciKlass* ciBytecodeStream::get_klass() {
202 bool will_link;
203 ciKlass* klass = get_klass(will_link);
204 if (!will_link && klass->is_loaded()) { // klass not accessible
205 VM_ENTRY_MARK;
206 klass = CURRENT_ENV->get_unloaded_klass(_holder, klass->name());
207 }
208 return klass;
209 }
210
211 // ------------------------------------------------------------------
212 // ciBytecodeStream::is_inline_klass
213 //
214 // Check if the klass is an inline klass.
215 bool ciBytecodeStream::has_Q_signature() const {
216 VM_ENTRY_MARK;
217 constantPoolHandle cpool(THREAD, _method->get_Method()->constants());
218 return CURRENT_ENV->has_Q_signature(cpool, get_klass_index());
219 }
220
221 // ------------------------------------------------------------------
222 // ciBytecodeStream::get_constant_raw_index
223 //
224 // If this bytecode is one of the ldc variants, get the index of the
225 // referenced constant.
226 int ciBytecodeStream::get_constant_raw_index() const {
227 // work-alike for Bytecode_loadconstant::raw_index()
228 switch (cur_bc()) {
229 case Bytecodes::_ldc:
230 return get_index_u1();
231 case Bytecodes::_ldc_w:
232 case Bytecodes::_ldc2_w:
233 return get_index_u2();
234 default:
235 ShouldNotReachHere();
236 return 0;
237 }
238 }
239
240 // ------------------------------------------------------------------
291 return _method->get_Method()->constants()->tag_at(index);
292 }
293
294 // ------------------------------------------------------------------
295 // ciBytecodeStream::get_basic_type_for_constant_at
296 //
297 BasicType ciBytecodeStream::get_basic_type_for_constant_at(int index) const {
298 VM_ENTRY_MARK;
299 return _method->get_Method()->constants()->basic_type_for_constant_at(index);
300 }
301
302 // ------------------------------------------------------------------
303 // ciBytecodeStream::get_field_index
304 //
305 // If this is a field access bytecode, get the constant pool
306 // index of the referenced field.
307 int ciBytecodeStream::get_field_index() {
308 assert(cur_bc() == Bytecodes::_getfield ||
309 cur_bc() == Bytecodes::_putfield ||
310 cur_bc() == Bytecodes::_getstatic ||
311 cur_bc() == Bytecodes::_putstatic ||
312 cur_bc() == Bytecodes::_withfield, "wrong bc");
313 return get_index_u2_cpcache();
314 }
315
316
317 // ------------------------------------------------------------------
318 // ciBytecodeStream::get_field
319 //
320 // If this bytecode is one of get_field, get_static, put_field,
321 // or put_static, get the referenced field.
322 ciField* ciBytecodeStream::get_field(bool& will_link) {
323 ciField* f = CURRENT_ENV->get_field_by_index(_holder, get_field_index());
324 will_link = f->will_link(_method, _bc);
325 return f;
326 }
327
328
329 // ------------------------------------------------------------------
330 // ciBytecodeStream::get_declared_field_holder
331 //
332 // Get the declared holder of the currently referenced field.
|