hotspot/src/share/vm/oops/cpCache.cpp
changeset 21557 55115e0708f1
parent 21079 7028d0cb9b49
child 22859 7b88983393b7
equal deleted inserted replaced
21556:e75cd34a59e0 21557:55115e0708f1
   552 }
   552 }
   553 
   553 
   554 // Implementation of ConstantPoolCache
   554 // Implementation of ConstantPoolCache
   555 
   555 
   556 ConstantPoolCache* ConstantPoolCache::allocate(ClassLoaderData* loader_data,
   556 ConstantPoolCache* ConstantPoolCache::allocate(ClassLoaderData* loader_data,
   557                                      int length,
       
   558                                      const intStack& index_map,
   557                                      const intStack& index_map,
       
   558                                      const intStack& invokedynamic_index_map,
   559                                      const intStack& invokedynamic_map, TRAPS) {
   559                                      const intStack& invokedynamic_map, TRAPS) {
       
   560 
       
   561   const int length = index_map.length() + invokedynamic_index_map.length();
   560   int size = ConstantPoolCache::size(length);
   562   int size = ConstantPoolCache::size(length);
   561 
   563 
   562   return new (loader_data, size, false, MetaspaceObj::ConstantPoolCacheType, THREAD)
   564   return new (loader_data, size, false, MetaspaceObj::ConstantPoolCacheType, THREAD)
   563     ConstantPoolCache(length, index_map, invokedynamic_map);
   565     ConstantPoolCache(length, index_map, invokedynamic_index_map, invokedynamic_map);
   564 }
   566 }
   565 
   567 
   566 void ConstantPoolCache::initialize(const intArray& inverse_index_map,
   568 void ConstantPoolCache::initialize(const intArray& inverse_index_map,
       
   569                                    const intArray& invokedynamic_inverse_index_map,
   567                                    const intArray& invokedynamic_references_map) {
   570                                    const intArray& invokedynamic_references_map) {
   568   assert(inverse_index_map.length() == length(), "inverse index map must have same length as cache");
   571   for (int i = 0; i < inverse_index_map.length(); i++) {
   569   for (int i = 0; i < length(); i++) {
       
   570     ConstantPoolCacheEntry* e = entry_at(i);
   572     ConstantPoolCacheEntry* e = entry_at(i);
   571     int original_index = inverse_index_map[i];
   573     int original_index = inverse_index_map[i];
   572     e->initialize_entry(original_index);
   574     e->initialize_entry(original_index);
   573     assert(entry_at(i) == e, "sanity");
   575     assert(entry_at(i) == e, "sanity");
   574   }
   576   }
       
   577 
       
   578   // Append invokedynamic entries at the end
       
   579   int invokedynamic_offset = inverse_index_map.length();
       
   580   for (int i = 0; i < invokedynamic_inverse_index_map.length(); i++) {
       
   581     int offset = i + invokedynamic_offset;
       
   582     ConstantPoolCacheEntry* e = entry_at(offset);
       
   583     int original_index = invokedynamic_inverse_index_map[i];
       
   584     e->initialize_entry(original_index);
       
   585     assert(entry_at(offset) == e, "sanity");
       
   586   }
       
   587 
   575   for (int ref = 0; ref < invokedynamic_references_map.length(); ref++) {
   588   for (int ref = 0; ref < invokedynamic_references_map.length(); ref++) {
   576     const int cpci = invokedynamic_references_map[ref];
   589     const int cpci = invokedynamic_references_map[ref];
   577     if (cpci >= 0) {
   590     if (cpci >= 0) {
   578 #ifdef ASSERT
   591 #ifdef ASSERT
   579       // invokedynamic and invokehandle have more entries; check if they
   592       // invokedynamic and invokehandle have more entries; check if they