398 // A constant pool cache is a runtime data structure set aside to a constant pool. The cache
399 // holds interpreter runtime information for all field access and invoke bytecodes. The cache
400 // is created and initialized before a class is actively used (i.e., initialized), the indivi-
401 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*).
402
403 class ConstantPoolCache: public MetaspaceObj {
404 friend class VMStructs;
405 friend class MetadataFactory;
406 private:
407 // If you add a new field that points to any metaspace object, you
408 // must add this field to ConstantPoolCache::metaspace_pointers_do().
409 int _length;
410 ConstantPool* _constant_pool; // the corresponding constant pool
411
412 // The following fields need to be modified at runtime, so they cannot be
413 // stored in the ConstantPool, which is read-only.
414 // Array of resolved objects from the constant pool and map from resolved
415 // object index to original constant pool index
416 jobject _resolved_references;
417 Array<u2>* _reference_map;
418
419 // Sizing
420 debug_only(friend class ClassVerifier;)
421
422 // Constructor
423 ConstantPoolCache(int length,
424 const intStack& inverse_index_map,
425 const intStack& invokedynamic_inverse_index_map,
426 const intStack& invokedynamic_references_map) :
427 _length(length),
428 _constant_pool(NULL) {
429 initialize(inverse_index_map, invokedynamic_inverse_index_map,
430 invokedynamic_references_map);
431 for (int i = 0; i < length; i++) {
432 assert(entry_at(i)->is_f1_null(), "Failed to clear?");
433 }
434 }
435
436 // Initialization
437 void initialize(const intArray& inverse_index_map,
438 const intArray& invokedynamic_inverse_index_map,
439 const intArray& invokedynamic_references_map);
440 public:
441 static ConstantPoolCache* allocate(ClassLoaderData* loader_data,
442 const intStack& cp_cache_map,
443 const intStack& invokedynamic_cp_cache_map,
444 const intStack& invokedynamic_references_map, TRAPS);
445 bool is_constantPoolCache() const { return true; }
446
447 int length() const { return _length; }
448 void metaspace_pointers_do(MetaspaceClosure* it);
449 MetaspaceObj::Type type() const { return ConstantPoolCacheType; }
450
451 jobject resolved_references() { return _resolved_references; }
452 void set_resolved_references(jobject s) { _resolved_references = s; }
453 Array<u2>* reference_map() const { return _reference_map; }
454 void set_reference_map(Array<u2>* o) { _reference_map = o; }
455
456 // Assembly code support
457 static int resolved_references_offset_in_bytes() { return offset_of(ConstantPoolCache, _resolved_references); }
458
459 private:
460 void set_length(int length) { _length = length; }
461
462 static int header_size() { return sizeof(ConstantPoolCache) / wordSize; }
463 static int size(int length) { return align_metadata_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); }
464 public:
465 int size() const { return size(length()); }
466 private:
467
468 // Helpers
469 ConstantPool** constant_pool_addr() { return &_constant_pool; }
|
398 // A constant pool cache is a runtime data structure set aside to a constant pool. The cache
399 // holds interpreter runtime information for all field access and invoke bytecodes. The cache
400 // is created and initialized before a class is actively used (i.e., initialized), the indivi-
401 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*).
402
403 class ConstantPoolCache: public MetaspaceObj {
404 friend class VMStructs;
405 friend class MetadataFactory;
406 private:
407 // If you add a new field that points to any metaspace object, you
408 // must add this field to ConstantPoolCache::metaspace_pointers_do().
409 int _length;
410 ConstantPool* _constant_pool; // the corresponding constant pool
411
412 // The following fields need to be modified at runtime, so they cannot be
413 // stored in the ConstantPool, which is read-only.
414 // Array of resolved objects from the constant pool and map from resolved
415 // object index to original constant pool index
416 jobject _resolved_references;
417 Array<u2>* _reference_map;
418 // The narrowOop pointer to the archived resolved_references. Set at CDS dump
419 // time when caching java heap object is supported.
420 CDS_JAVA_HEAP_ONLY(narrowOop _archived_references;)
421
422 // Sizing
423 debug_only(friend class ClassVerifier;)
424
425 // Constructor
426 ConstantPoolCache(int length,
427 const intStack& inverse_index_map,
428 const intStack& invokedynamic_inverse_index_map,
429 const intStack& invokedynamic_references_map) :
430 _length(length),
431 _constant_pool(NULL) {
432 CDS_JAVA_HEAP_ONLY(_archived_references = 0;)
433 initialize(inverse_index_map, invokedynamic_inverse_index_map,
434 invokedynamic_references_map);
435 for (int i = 0; i < length; i++) {
436 assert(entry_at(i)->is_f1_null(), "Failed to clear?");
437 }
438 }
439
440 // Initialization
441 void initialize(const intArray& inverse_index_map,
442 const intArray& invokedynamic_inverse_index_map,
443 const intArray& invokedynamic_references_map);
444 public:
445 static ConstantPoolCache* allocate(ClassLoaderData* loader_data,
446 const intStack& cp_cache_map,
447 const intStack& invokedynamic_cp_cache_map,
448 const intStack& invokedynamic_references_map, TRAPS);
449 bool is_constantPoolCache() const { return true; }
450
451 int length() const { return _length; }
452 void metaspace_pointers_do(MetaspaceClosure* it);
453 MetaspaceObj::Type type() const { return ConstantPoolCacheType; }
454
455 oop archived_references() NOT_CDS_JAVA_HEAP_RETURN_(NULL);
456 void set_archived_references(oop o) NOT_CDS_JAVA_HEAP_RETURN;
457
458 jobject resolved_references() { return _resolved_references; }
459 void set_resolved_references(jobject s) { _resolved_references = s; }
460 Array<u2>* reference_map() const { return _reference_map; }
461 void set_reference_map(Array<u2>* o) { _reference_map = o; }
462
463 // Assembly code support
464 static int resolved_references_offset_in_bytes() { return offset_of(ConstantPoolCache, _resolved_references); }
465
466 private:
467 void set_length(int length) { _length = length; }
468
469 static int header_size() { return sizeof(ConstantPoolCache) / wordSize; }
470 static int size(int length) { return align_metadata_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); }
471 public:
472 int size() const { return size(length()); }
473 private:
474
475 // Helpers
476 ConstantPool** constant_pool_addr() { return &_constant_pool; }
|