< prev index next >

hotspot/src/share/vm/oops/cpCache.cpp

Print this page
rev 10452 : imported patch primitive arrays


 551 
 552 // Implementation of ConstantPoolCache
 553 
 554 ConstantPoolCache* ConstantPoolCache::allocate(ClassLoaderData* loader_data,
 555                                      const intStack& index_map,
 556                                      const intStack& invokedynamic_index_map,
 557                                      const intStack& invokedynamic_map, TRAPS) {
 558 
 559   const int length = index_map.length() + invokedynamic_index_map.length();
 560   int size = ConstantPoolCache::size(length);
 561 
 562   return new (loader_data, size, false, MetaspaceObj::ConstantPoolCacheType, THREAD)
 563     ConstantPoolCache(length, index_map, invokedynamic_index_map, invokedynamic_map);
 564 }
 565 
 566 void ConstantPoolCache::initialize(const intArray& inverse_index_map,
 567                                    const intArray& invokedynamic_inverse_index_map,
 568                                    const intArray& invokedynamic_references_map) {
 569   for (int i = 0; i < inverse_index_map.length(); i++) {
 570     ConstantPoolCacheEntry* e = entry_at(i);
 571     int original_index = inverse_index_map[i];
 572     e->initialize_entry(original_index);
 573     assert(entry_at(i) == e, "sanity");
 574   }
 575 
 576   // Append invokedynamic entries at the end
 577   int invokedynamic_offset = inverse_index_map.length();
 578   for (int i = 0; i < invokedynamic_inverse_index_map.length(); i++) {
 579     int offset = i + invokedynamic_offset;
 580     ConstantPoolCacheEntry* e = entry_at(offset);
 581     int original_index = invokedynamic_inverse_index_map[i];
 582     e->initialize_entry(original_index);
 583     assert(entry_at(offset) == e, "sanity");
 584   }
 585 
 586   for (int ref = 0; ref < invokedynamic_references_map.length(); ref++) {
 587     const int cpci = invokedynamic_references_map[ref];
 588     if (cpci >= 0) {
 589 #ifdef ASSERT
 590       // invokedynamic and invokehandle have more entries; check if they
 591       // all point to the same constant pool cache entry.
 592       for (int entry = 1; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) {
 593         const int cpci_next = invokedynamic_references_map[ref + entry];
 594         assert(cpci == cpci_next, "%d == %d", cpci, cpci_next);
 595       }
 596 #endif
 597       entry_at(cpci)->initialize_resolved_reference_index(ref);
 598       ref += ConstantPoolCacheEntry::_indy_resolved_references_entries - 1;  // skip extra entries
 599     }
 600   }
 601 }
 602 
 603 #if INCLUDE_JVMTI
 604 // RedefineClasses() API support:
 605 // If any entry of this ConstantPoolCache points to any of
 606 // old_methods, replace it with the corresponding new_method.
 607 void ConstantPoolCache::adjust_method_entries(InstanceKlass* holder, bool * trace_name_printed) {
 608   for (int i = 0; i < length(); i++) {
 609     ConstantPoolCacheEntry* entry = entry_at(i);
 610     Method* old_method = entry->get_interesting_method_entry(holder);
 611     if (old_method == NULL || !old_method->is_old()) {
 612       continue; // skip uninteresting entries
 613     }




 551 
 552 // Implementation of ConstantPoolCache
 553 
 554 ConstantPoolCache* ConstantPoolCache::allocate(ClassLoaderData* loader_data,
 555                                      const intStack& index_map,
 556                                      const intStack& invokedynamic_index_map,
 557                                      const intStack& invokedynamic_map, TRAPS) {
 558 
 559   const int length = index_map.length() + invokedynamic_index_map.length();
 560   int size = ConstantPoolCache::size(length);
 561 
 562   return new (loader_data, size, false, MetaspaceObj::ConstantPoolCacheType, THREAD)
 563     ConstantPoolCache(length, index_map, invokedynamic_index_map, invokedynamic_map);
 564 }
 565 
 566 void ConstantPoolCache::initialize(const intArray& inverse_index_map,
 567                                    const intArray& invokedynamic_inverse_index_map,
 568                                    const intArray& invokedynamic_references_map) {
 569   for (int i = 0; i < inverse_index_map.length(); i++) {
 570     ConstantPoolCacheEntry* e = entry_at(i);
 571     int original_index = inverse_index_map.at(i);
 572     e->initialize_entry(original_index);
 573     assert(entry_at(i) == e, "sanity");
 574   }
 575 
 576   // Append invokedynamic entries at the end
 577   int invokedynamic_offset = inverse_index_map.length();
 578   for (int i = 0; i < invokedynamic_inverse_index_map.length(); i++) {
 579     int offset = i + invokedynamic_offset;
 580     ConstantPoolCacheEntry* e = entry_at(offset);
 581     int original_index = invokedynamic_inverse_index_map.at(i);
 582     e->initialize_entry(original_index);
 583     assert(entry_at(offset) == e, "sanity");
 584   }
 585 
 586   for (int ref = 0; ref < invokedynamic_references_map.length(); ref++) {
 587     const int cpci = invokedynamic_references_map.at(ref);
 588     if (cpci >= 0) {
 589 #ifdef ASSERT
 590       // invokedynamic and invokehandle have more entries; check if they
 591       // all point to the same constant pool cache entry.
 592       for (int entry = 1; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) {
 593         const int cpci_next = invokedynamic_references_map.at(ref + entry);
 594         assert(cpci == cpci_next, "%d == %d", cpci, cpci_next);
 595       }
 596 #endif
 597       entry_at(cpci)->initialize_resolved_reference_index(ref);
 598       ref += ConstantPoolCacheEntry::_indy_resolved_references_entries - 1;  // skip extra entries
 599     }
 600   }
 601 }
 602 
 603 #if INCLUDE_JVMTI
 604 // RedefineClasses() API support:
 605 // If any entry of this ConstantPoolCache points to any of
 606 // old_methods, replace it with the corresponding new_method.
 607 void ConstantPoolCache::adjust_method_entries(InstanceKlass* holder, bool * trace_name_printed) {
 608   for (int i = 0; i < length(); i++) {
 609     ConstantPoolCacheEntry* entry = entry_at(i);
 610     Method* old_method = entry->get_interesting_method_entry(holder);
 611     if (old_method == NULL || !old_method->is_old()) {
 612       continue; // skip uninteresting entries
 613     }


< prev index next >