251 }
252
253 jfloat float_at(int which) {
254 assert(tag_at(which).is_float(), "Corrupted constant pool");
255 return *float_at_addr(which);
256 }
257
258 jdouble double_at(int which) {
259 assert(tag_at(which).is_double(), "Corrupted constant pool");
260 u8 tmp = Bytes::get_native_u8((address)&base()[which]);
261 return *((jdouble*)&tmp);
262 }
263
264 symbolOop symbol_at(int which) {
265 assert(tag_at(which).is_utf8(), "Corrupted constant pool");
266 return symbolOop(*obj_at_addr(which));
267 }
268
269 oop string_at(int which, TRAPS) {
270 constantPoolHandle h_this(THREAD, this);
271 return string_at_impl(h_this, which, CHECK_NULL);
272 }
273
274 // only called when we are sure a string entry is already resolved (via an
275 // earlier string_at call.
276 oop resolved_string_at(int which) {
277 assert(tag_at(which).is_string(), "Corrupted constant pool");
278 // Must do an acquire here in case another thread resolved the klass
279 // behind our back, lest we later load stale values thru the oop.
280 return (oop)OrderAccess::load_ptr_acquire(obj_at_addr(which));
281 }
282
283 // This method should only be used with a cpool lock or during parsing or gc
284 symbolOop unresolved_string_at(int which) { // Temporary until actual use
285 symbolOop s = symbolOop((oop)OrderAccess::load_ptr_acquire(obj_at_addr(which)));
286 // check that the string is still unresolved.
287 assert(tag_at(which).is_unresolved_string(), "Corrupted constant pool");
288 return s;
289 }
290
291 // Returns an UTF8 for a CONSTANT_String entry at a given index.
292 // UTF8 char* representation was chosen to avoid conversion of
293 // java_lang_Strings at resolved entries into symbolOops
294 // or vice versa.
295 char* string_at_noresolve(int which);
296
297 jint name_and_type_at(int which) {
298 assert(tag_at(which).is_name_and_type(), "Corrupted constant pool");
299 return *int_at_addr(which);
300 }
301
302 // The following methods (klass_ref_at, klass_ref_at_noresolve, name_ref_at,
303 // signature_ref_at, klass_ref_index_at, name_and_type_ref_index_at,
304 // name_ref_index_at, signature_ref_index_at) all expect constant pool indices
305 // from the bytecodes to be passed in, which are actually potentially byte-swapped
306 // contstant pool cache indices. See field_or_method_at.
307
308 // Lookup for entries consisting of (klass_index, name_and_type index)
309 klassOop klass_ref_at(int which, TRAPS);
310 symbolOop klass_ref_at_noresolve(int which);
311 symbolOop name_ref_at(int which);
312 symbolOop signature_ref_at(int which); // the type descriptor
313
314 int klass_ref_index_at(int which);
378 return *int_at_addr(i);
379 }
380
381 // Used while constructing constant pool (only by ClassFileParser)
382 jint klass_index_at(int which) {
383 assert(tag_at(which).is_klass_index(), "Corrupted constant pool");
384 return *int_at_addr(which);
385 }
386
387 jint string_index_at(int which) {
388 assert(tag_at(which).is_string_index(), "Corrupted constant pool");
389 return *int_at_addr(which);
390 }
391
392 // Performs the LinkResolver checks
393 static void verify_constant_pool_resolve(constantPoolHandle this_oop, KlassHandle klass, TRAPS);
394
395 // Implementation of methods that needs an exposed 'this' pointer, in order to
396 // handle GC while executing the method
397 static klassOop klass_at_impl(constantPoolHandle this_oop, int which, TRAPS);
398 static oop string_at_impl(constantPoolHandle this_oop, int which, TRAPS);
399
400 // Resolve string constants (to prevent allocation during compilation)
401 static void resolve_string_constants_impl(constantPoolHandle this_oop, TRAPS);
402
403 public:
404 // Merging constantPoolOop support:
405 bool compare_entry_to(int index1, constantPoolHandle cp2, int index2, TRAPS);
406 void copy_cp_to(int start_i, int end_i, constantPoolHandle to_cp, int to_i,
407 TRAPS);
408 void copy_entry_to(int from_i, constantPoolHandle to_cp, int to_i, TRAPS);
409 int find_matching_entry(int pattern_i, constantPoolHandle search_cp, TRAPS);
410 int orig_length() const { return _orig_length; }
411 void set_orig_length(int orig_length) { _orig_length = orig_length; }
412
413
414 // JVMTI accesss - GetConstantPool, RetransformClasses, ...
415 friend class JvmtiConstantPoolReconstituter;
416
417 private:
418 jint cpool_entry_size(jint idx);
|
251 }
252
253 jfloat float_at(int which) {
254 assert(tag_at(which).is_float(), "Corrupted constant pool");
255 return *float_at_addr(which);
256 }
257
258 jdouble double_at(int which) {
259 assert(tag_at(which).is_double(), "Corrupted constant pool");
260 u8 tmp = Bytes::get_native_u8((address)&base()[which]);
261 return *((jdouble*)&tmp);
262 }
263
264 symbolOop symbol_at(int which) {
265 assert(tag_at(which).is_utf8(), "Corrupted constant pool");
266 return symbolOop(*obj_at_addr(which));
267 }
268
269 oop string_at(int which, TRAPS) {
270 constantPoolHandle h_this(THREAD, this);
271 return string_at_impl(h_this, which, false, CHECK_NULL);
272 }
273
274 bool is_pseudo_string_at(int which);
275
276 oop pseudo_string_at(int which, TRAPS) {
277 constantPoolHandle h_this(THREAD, this);
278 return string_at_impl(h_this, which, true, CHECK_NULL);
279 }
280
281 // only called when we are sure a string entry is already resolved (via an
282 // earlier string_at call.
283 oop resolved_string_at(int which) {
284 assert(tag_at(which).is_string(), "Corrupted constant pool");
285 // Must do an acquire here in case another thread resolved the klass
286 // behind our back, lest we later load stale values thru the oop.
287 return (oop)OrderAccess::load_ptr_acquire(obj_at_addr(which));
288 }
289
290 // This method should only be used with a cpool lock or during parsing or gc
291 symbolOop unresolved_string_at(int which) { // Temporary until actual use
292 symbolOop s = symbolOop((oop)OrderAccess::load_ptr_acquire(obj_at_addr(which)));
293 // check that the string is still unresolved.
294 assert(tag_at(which).is_unresolved_string(), "Corrupted constant pool");
295 return s;
296 }
297
298 // Returns an UTF8 for a CONSTANT_String entry at a given index.
299 // UTF8 char* representation was chosen to avoid conversion of
300 // java_lang_Strings at resolved entries into symbolOops
301 // or vice versa.
302 // Caller is responsible for checking for pseudo-strings.
303 char* string_at_noresolve(int which);
304
305 jint name_and_type_at(int which) {
306 assert(tag_at(which).is_name_and_type(), "Corrupted constant pool");
307 return *int_at_addr(which);
308 }
309
310 // The following methods (klass_ref_at, klass_ref_at_noresolve, name_ref_at,
311 // signature_ref_at, klass_ref_index_at, name_and_type_ref_index_at,
312 // name_ref_index_at, signature_ref_index_at) all expect constant pool indices
313 // from the bytecodes to be passed in, which are actually potentially byte-swapped
314 // contstant pool cache indices. See field_or_method_at.
315
316 // Lookup for entries consisting of (klass_index, name_and_type index)
317 klassOop klass_ref_at(int which, TRAPS);
318 symbolOop klass_ref_at_noresolve(int which);
319 symbolOop name_ref_at(int which);
320 symbolOop signature_ref_at(int which); // the type descriptor
321
322 int klass_ref_index_at(int which);
386 return *int_at_addr(i);
387 }
388
389 // Used while constructing constant pool (only by ClassFileParser)
390 jint klass_index_at(int which) {
391 assert(tag_at(which).is_klass_index(), "Corrupted constant pool");
392 return *int_at_addr(which);
393 }
394
395 jint string_index_at(int which) {
396 assert(tag_at(which).is_string_index(), "Corrupted constant pool");
397 return *int_at_addr(which);
398 }
399
400 // Performs the LinkResolver checks
401 static void verify_constant_pool_resolve(constantPoolHandle this_oop, KlassHandle klass, TRAPS);
402
403 // Implementation of methods that needs an exposed 'this' pointer, in order to
404 // handle GC while executing the method
405 static klassOop klass_at_impl(constantPoolHandle this_oop, int which, TRAPS);
406 static oop string_at_impl(constantPoolHandle this_oop, int which, bool pseudo_ok, TRAPS);
407
408 // Resolve string constants (to prevent allocation during compilation)
409 static void resolve_string_constants_impl(constantPoolHandle this_oop, TRAPS);
410
411 public:
412 // Merging constantPoolOop support:
413 bool compare_entry_to(int index1, constantPoolHandle cp2, int index2, TRAPS);
414 void copy_cp_to(int start_i, int end_i, constantPoolHandle to_cp, int to_i,
415 TRAPS);
416 void copy_entry_to(int from_i, constantPoolHandle to_cp, int to_i, TRAPS);
417 int find_matching_entry(int pattern_i, constantPoolHandle search_cp, TRAPS);
418 int orig_length() const { return _orig_length; }
419 void set_orig_length(int orig_length) { _orig_length = orig_length; }
420
421
422 // JVMTI accesss - GetConstantPool, RetransformClasses, ...
423 friend class JvmtiConstantPoolReconstituter;
424
425 private:
426 jint cpool_entry_size(jint idx);
|