< prev index next >

src/hotspot/share/oops/cpCache.cpp

Print this page

 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "cds/heapShared.hpp"
 27 #include "classfile/resolutionErrors.hpp"
 28 #include "classfile/systemDictionary.hpp"
 29 #include "classfile/vmClasses.hpp"

 30 #include "interpreter/bytecodeStream.hpp"
 31 #include "interpreter/bytecodes.hpp"
 32 #include "interpreter/interpreter.hpp"
 33 #include "interpreter/linkResolver.hpp"
 34 #include "interpreter/rewriter.hpp"
 35 #include "logging/log.hpp"
 36 #include "logging/logStream.hpp"
 37 #include "memory/metadataFactory.hpp"
 38 #include "memory/metaspaceClosure.hpp"
 39 #include "memory/resourceArea.hpp"
 40 #include "oops/access.inline.hpp"
 41 #include "oops/compressedOops.hpp"
 42 #include "oops/constantPool.inline.hpp"
 43 #include "oops/cpCache.inline.hpp"
 44 #include "oops/objArrayOop.inline.hpp"
 45 #include "oops/oop.inline.hpp"
 46 #include "prims/methodHandles.hpp"
 47 #include "runtime/arguments.hpp"
 48 #include "runtime/atomic.hpp"
 49 #include "runtime/handles.inline.hpp"

688   }
689 
690   // Append invokedynamic entries at the end
691   int invokedynamic_offset = inverse_index_map.length();
692   for (int i = 0; i < invokedynamic_inverse_index_map.length(); i++) {
693     int offset = i + invokedynamic_offset;
694     ConstantPoolCacheEntry* e = entry_at(offset);
695     int original_index = invokedynamic_inverse_index_map.at(i);
696     e->initialize_entry(original_index);
697     assert(entry_at(offset) == e, "sanity");
698   }
699 
700   for (int ref = 0; ref < invokedynamic_references_map.length(); ref++) {
701     const int cpci = invokedynamic_references_map.at(ref);
702     if (cpci >= 0) {
703       entry_at(cpci)->initialize_resolved_reference_index(ref);
704     }
705   }
706 }
707 





708 void ConstantPoolCache::verify_just_initialized() {
709   DEBUG_ONLY(walk_entries_for_initialization(/*check_only = */ true));
710 }
711 
712 void ConstantPoolCache::remove_unshareable_info() {
713   walk_entries_for_initialization(/*check_only = */ false);
714 }
715 
716 void ConstantPoolCache::walk_entries_for_initialization(bool check_only) {
717   Arguments::assert_is_dumping_archive();
718   // When dumping the archive, we want to clean up the ConstantPoolCache
719   // to remove any effect of linking due to the execution of Java code --
720   // each ConstantPoolCacheEntry will have the same contents as if
721   // ConstantPoolCache::initialize has just returned:
722   //
723   // - We keep the ConstantPoolCache::constant_pool_index() bits for all entries.
724   // - We keep the "f2" field for entries used by invokedynamic and invokehandle
725   // - All other bits in the entries are cleared to zero.
726   ResourceMark rm;
727 

 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "cds/heapShared.hpp"
 27 #include "classfile/resolutionErrors.hpp"
 28 #include "classfile/systemDictionary.hpp"
 29 #include "classfile/vmClasses.hpp"
 30 #include "code/codeCache.hpp"
 31 #include "interpreter/bytecodeStream.hpp"
 32 #include "interpreter/bytecodes.hpp"
 33 #include "interpreter/interpreter.hpp"
 34 #include "interpreter/linkResolver.hpp"
 35 #include "interpreter/rewriter.hpp"
 36 #include "logging/log.hpp"
 37 #include "logging/logStream.hpp"
 38 #include "memory/metadataFactory.hpp"
 39 #include "memory/metaspaceClosure.hpp"
 40 #include "memory/resourceArea.hpp"
 41 #include "oops/access.inline.hpp"
 42 #include "oops/compressedOops.hpp"
 43 #include "oops/constantPool.inline.hpp"
 44 #include "oops/cpCache.inline.hpp"
 45 #include "oops/objArrayOop.inline.hpp"
 46 #include "oops/oop.inline.hpp"
 47 #include "prims/methodHandles.hpp"
 48 #include "runtime/arguments.hpp"
 49 #include "runtime/atomic.hpp"
 50 #include "runtime/handles.inline.hpp"

689   }
690 
691   // Append invokedynamic entries at the end
692   int invokedynamic_offset = inverse_index_map.length();
693   for (int i = 0; i < invokedynamic_inverse_index_map.length(); i++) {
694     int offset = i + invokedynamic_offset;
695     ConstantPoolCacheEntry* e = entry_at(offset);
696     int original_index = invokedynamic_inverse_index_map.at(i);
697     e->initialize_entry(original_index);
698     assert(entry_at(offset) == e, "sanity");
699   }
700 
701   for (int ref = 0; ref < invokedynamic_references_map.length(); ref++) {
702     const int cpci = invokedynamic_references_map.at(ref);
703     if (cpci >= 0) {
704       entry_at(cpci)->initialize_resolved_reference_index(ref);
705     }
706   }
707 }
708 
709 // Record the GC marking cycle when redefined vs. when found in the InstanceStackChunks.
710 void ConstantPoolCache::record_marking_cycle() {
711   _marking_cycle = CodeCache::marking_cycle();
712 }
713 
714 void ConstantPoolCache::verify_just_initialized() {
715   DEBUG_ONLY(walk_entries_for_initialization(/*check_only = */ true));
716 }
717 
718 void ConstantPoolCache::remove_unshareable_info() {
719   walk_entries_for_initialization(/*check_only = */ false);
720 }
721 
722 void ConstantPoolCache::walk_entries_for_initialization(bool check_only) {
723   Arguments::assert_is_dumping_archive();
724   // When dumping the archive, we want to clean up the ConstantPoolCache
725   // to remove any effect of linking due to the execution of Java code --
726   // each ConstantPoolCacheEntry will have the same contents as if
727   // ConstantPoolCache::initialize has just returned:
728   //
729   // - We keep the ConstantPoolCache::constant_pool_index() bits for all entries.
730   // - We keep the "f2" field for entries used by invokedynamic and invokehandle
731   // - All other bits in the entries are cleared to zero.
732   ResourceMark rm;
733 
< prev index next >