60 #include "classfile/vmClasses.hpp"
61 #include "classfile/vmSymbols.hpp"
62 #include "code/aotCodeCache.hpp"
63 #include "code/codeCache.hpp"
64 #include "gc/shared/gcVMOperations.hpp"
65 #include "interpreter/bytecodes.hpp"
66 #include "interpreter/bytecodeStream.hpp"
67 #include "jvm_io.h"
68 #include "logging/log.hpp"
69 #include "logging/logMessage.hpp"
70 #include "logging/logStream.hpp"
71 #include "memory/memoryReserver.hpp"
72 #include "memory/metaspace.hpp"
73 #include "memory/metaspaceClosure.hpp"
74 #include "memory/oopFactory.hpp"
75 #include "memory/resourceArea.hpp"
76 #include "memory/universe.hpp"
77 #include "nmt/memTracker.hpp"
78 #include "oops/compressedKlass.hpp"
79 #include "oops/constantPool.inline.hpp"
80 #include "oops/instanceMirrorKlass.hpp"
81 #include "oops/klass.inline.hpp"
82 #include "oops/objArrayOop.hpp"
83 #include "oops/oop.inline.hpp"
84 #include "oops/oopHandle.hpp"
85 #include "oops/resolvedFieldEntry.hpp"
86 #include "oops/trainingData.hpp"
87 #include "prims/jvmtiExport.hpp"
88 #include "runtime/arguments.hpp"
89 #include "runtime/globals.hpp"
90 #include "runtime/globals_extension.hpp"
91 #include "runtime/handles.inline.hpp"
92 #include "runtime/javaCalls.hpp"
93 #include "runtime/os.inline.hpp"
94 #include "runtime/safepointVerifiers.hpp"
95 #include "runtime/sharedRuntime.hpp"
96 #include "runtime/vmOperations.hpp"
97 #include "runtime/vmThread.hpp"
98 #include "sanitizers/leak.hpp"
99 #include "services/management.hpp"
486 // AOTMetaspace::early_serialize(). Such functions must not produce side effects that
487 // assume we will always decides to map the archive.
488
489 void AOTMetaspace::early_serialize(SerializeClosure* soc) {
490 int tag = 0;
491 soc->do_tag(--tag);
492 CDS_JAVA_HEAP_ONLY(Modules::serialize_archived_module_info(soc);)
493 soc->do_tag(666);
494 }
495
496 void AOTMetaspace::serialize(SerializeClosure* soc) {
497 int tag = 0;
498 soc->do_tag(--tag);
499
500 // Verify the sizes of various metadata in the system.
501 soc->do_tag(sizeof(Method));
502 soc->do_tag(sizeof(ConstMethod));
503 soc->do_tag(arrayOopDesc::base_offset_in_bytes(T_BYTE));
504 soc->do_tag(sizeof(ConstantPool));
505 soc->do_tag(sizeof(ConstantPoolCache));
506 soc->do_tag(objArrayOopDesc::base_offset_in_bytes());
507 soc->do_tag(typeArrayOopDesc::base_offset_in_bytes(T_BYTE));
508 soc->do_tag(sizeof(Symbol));
509
510 // Need to do this first, as subsequent steps may call virtual functions
511 // in archived Metadata objects.
512 CppVtables::serialize(soc);
513 soc->do_tag(--tag);
514
515 // Dump/restore miscellaneous metadata.
516 JavaClasses::serialize_offsets(soc);
517 Universe::serialize(soc);
518 soc->do_tag(--tag);
519
520 // Dump/restore references to commonly used names and signatures.
521 vmSymbols::serialize(soc);
522 soc->do_tag(--tag);
523
524 // Dump/restore the symbol/string/subgraph_info tables
525 SymbolTable::serialize_shared_table_header(soc);
526 StringTable::serialize_shared_table_header(soc);
565 lsh.print("Rewriting bytecodes for ");
566 method()->print_external_name(&lsh);
567 lsh.print("\n");
568 }
569
570 while (!bcs.is_last_bytecode()) {
571 Bytecodes::Code opcode = bcs.next();
572 // Use current opcode as the default value of new_code
573 new_code = opcode;
574 switch(opcode) {
575 case Bytecodes::_getfield: {
576 uint rfe_index = bcs.get_index_u2();
577 bool is_resolved = cp->is_resolved(rfe_index, opcode);
578 if (is_resolved) {
579 assert(!CDSConfig::is_dumping_preimage_static_archive(), "preimage should not have resolved field references");
580 ResolvedFieldEntry* rfe = cp->resolved_field_entry_at(bcs.get_index_u2());
581 switch(rfe->tos_state()) {
582 case btos:
583 // fallthrough
584 case ztos: new_code = Bytecodes::_fast_bgetfield; break;
585 case atos: new_code = Bytecodes::_fast_agetfield; break;
586 case itos: new_code = Bytecodes::_fast_igetfield; break;
587 case ctos: new_code = Bytecodes::_fast_cgetfield; break;
588 case stos: new_code = Bytecodes::_fast_sgetfield; break;
589 case ltos: new_code = Bytecodes::_fast_lgetfield; break;
590 case ftos: new_code = Bytecodes::_fast_fgetfield; break;
591 case dtos: new_code = Bytecodes::_fast_dgetfield; break;
592 default:
593 ShouldNotReachHere();
594 break;
595 }
596 } else {
597 new_code = Bytecodes::_nofast_getfield;
598 }
599 break;
600 }
601 case Bytecodes::_putfield: {
602 uint rfe_index = bcs.get_index_u2();
603 bool is_resolved = cp->is_resolved(rfe_index, opcode);
604 if (is_resolved) {
605 assert(!CDSConfig::is_dumping_preimage_static_archive(), "preimage should not have resolved field references");
606 ResolvedFieldEntry* rfe = cp->resolved_field_entry_at(bcs.get_index_u2());
607 switch(rfe->tos_state()) {
608 case btos: new_code = Bytecodes::_fast_bputfield; break;
609 case ztos: new_code = Bytecodes::_fast_zputfield; break;
610 case atos: new_code = Bytecodes::_fast_aputfield; break;
611 case itos: new_code = Bytecodes::_fast_iputfield; break;
612 case ctos: new_code = Bytecodes::_fast_cputfield; break;
613 case stos: new_code = Bytecodes::_fast_sputfield; break;
614 case ltos: new_code = Bytecodes::_fast_lputfield; break;
615 case ftos: new_code = Bytecodes::_fast_fputfield; break;
616 case dtos: new_code = Bytecodes::_fast_dputfield; break;
617 default:
618 ShouldNotReachHere();
619 break;
620 }
621 } else {
622 new_code = Bytecodes::_nofast_putfield;
623 }
624 break;
625 }
626 case Bytecodes::_aload_0:
627 // Revert _fast_Xaccess_0 or _aload_0 to _nofast_aload_0
628 new_code = Bytecodes::_nofast_aload_0;
629 break;
630 case Bytecodes::_iload:
|
60 #include "classfile/vmClasses.hpp"
61 #include "classfile/vmSymbols.hpp"
62 #include "code/aotCodeCache.hpp"
63 #include "code/codeCache.hpp"
64 #include "gc/shared/gcVMOperations.hpp"
65 #include "interpreter/bytecodes.hpp"
66 #include "interpreter/bytecodeStream.hpp"
67 #include "jvm_io.h"
68 #include "logging/log.hpp"
69 #include "logging/logMessage.hpp"
70 #include "logging/logStream.hpp"
71 #include "memory/memoryReserver.hpp"
72 #include "memory/metaspace.hpp"
73 #include "memory/metaspaceClosure.hpp"
74 #include "memory/oopFactory.hpp"
75 #include "memory/resourceArea.hpp"
76 #include "memory/universe.hpp"
77 #include "nmt/memTracker.hpp"
78 #include "oops/compressedKlass.hpp"
79 #include "oops/constantPool.inline.hpp"
80 #include "oops/flatArrayKlass.hpp"
81 #include "oops/inlineKlass.hpp"
82 #include "oops/instanceMirrorKlass.hpp"
83 #include "oops/klass.inline.hpp"
84 #include "oops/objArrayOop.hpp"
85 #include "oops/oop.inline.hpp"
86 #include "oops/oopHandle.hpp"
87 #include "oops/resolvedFieldEntry.hpp"
88 #include "oops/trainingData.hpp"
89 #include "prims/jvmtiExport.hpp"
90 #include "runtime/arguments.hpp"
91 #include "runtime/globals.hpp"
92 #include "runtime/globals_extension.hpp"
93 #include "runtime/handles.inline.hpp"
94 #include "runtime/javaCalls.hpp"
95 #include "runtime/os.inline.hpp"
96 #include "runtime/safepointVerifiers.hpp"
97 #include "runtime/sharedRuntime.hpp"
98 #include "runtime/vmOperations.hpp"
99 #include "runtime/vmThread.hpp"
100 #include "sanitizers/leak.hpp"
101 #include "services/management.hpp"
488 // AOTMetaspace::early_serialize(). Such functions must not produce side effects that
489 // assume we will always decides to map the archive.
490
491 void AOTMetaspace::early_serialize(SerializeClosure* soc) {
492 int tag = 0;
493 soc->do_tag(--tag);
494 CDS_JAVA_HEAP_ONLY(Modules::serialize_archived_module_info(soc);)
495 soc->do_tag(666);
496 }
497
498 void AOTMetaspace::serialize(SerializeClosure* soc) {
499 int tag = 0;
500 soc->do_tag(--tag);
501
502 // Verify the sizes of various metadata in the system.
503 soc->do_tag(sizeof(Method));
504 soc->do_tag(sizeof(ConstMethod));
505 soc->do_tag(arrayOopDesc::base_offset_in_bytes(T_BYTE));
506 soc->do_tag(sizeof(ConstantPool));
507 soc->do_tag(sizeof(ConstantPoolCache));
508 soc->do_tag(refArrayOopDesc::base_offset_in_bytes());
509 soc->do_tag(typeArrayOopDesc::base_offset_in_bytes(T_BYTE));
510 soc->do_tag(sizeof(Symbol));
511
512 // Need to do this first, as subsequent steps may call virtual functions
513 // in archived Metadata objects.
514 CppVtables::serialize(soc);
515 soc->do_tag(--tag);
516
517 // Dump/restore miscellaneous metadata.
518 JavaClasses::serialize_offsets(soc);
519 Universe::serialize(soc);
520 soc->do_tag(--tag);
521
522 // Dump/restore references to commonly used names and signatures.
523 vmSymbols::serialize(soc);
524 soc->do_tag(--tag);
525
526 // Dump/restore the symbol/string/subgraph_info tables
527 SymbolTable::serialize_shared_table_header(soc);
528 StringTable::serialize_shared_table_header(soc);
567 lsh.print("Rewriting bytecodes for ");
568 method()->print_external_name(&lsh);
569 lsh.print("\n");
570 }
571
572 while (!bcs.is_last_bytecode()) {
573 Bytecodes::Code opcode = bcs.next();
574 // Use current opcode as the default value of new_code
575 new_code = opcode;
576 switch(opcode) {
577 case Bytecodes::_getfield: {
578 uint rfe_index = bcs.get_index_u2();
579 bool is_resolved = cp->is_resolved(rfe_index, opcode);
580 if (is_resolved) {
581 assert(!CDSConfig::is_dumping_preimage_static_archive(), "preimage should not have resolved field references");
582 ResolvedFieldEntry* rfe = cp->resolved_field_entry_at(bcs.get_index_u2());
583 switch(rfe->tos_state()) {
584 case btos:
585 // fallthrough
586 case ztos: new_code = Bytecodes::_fast_bgetfield; break;
587 case atos: {
588 if (rfe->is_flat()) {
589 new_code = Bytecodes::_fast_vgetfield;
590 } else {
591 new_code = Bytecodes::_fast_agetfield;
592 }
593 break;
594 }
595 case itos: new_code = Bytecodes::_fast_igetfield; break;
596 case ctos: new_code = Bytecodes::_fast_cgetfield; break;
597 case stos: new_code = Bytecodes::_fast_sgetfield; break;
598 case ltos: new_code = Bytecodes::_fast_lgetfield; break;
599 case ftos: new_code = Bytecodes::_fast_fgetfield; break;
600 case dtos: new_code = Bytecodes::_fast_dgetfield; break;
601 default:
602 ShouldNotReachHere();
603 break;
604 }
605 } else {
606 new_code = Bytecodes::_nofast_getfield;
607 }
608 break;
609 }
610 case Bytecodes::_putfield: {
611 uint rfe_index = bcs.get_index_u2();
612 bool is_resolved = cp->is_resolved(rfe_index, opcode);
613 if (is_resolved) {
614 assert(!CDSConfig::is_dumping_preimage_static_archive(), "preimage should not have resolved field references");
615 ResolvedFieldEntry* rfe = cp->resolved_field_entry_at(bcs.get_index_u2());
616 switch(rfe->tos_state()) {
617 case btos: new_code = Bytecodes::_fast_bputfield; break;
618 case ztos: new_code = Bytecodes::_fast_zputfield; break;
619 case atos: {
620 if (rfe->is_flat() || rfe->is_null_free_inline_type()) {
621 new_code = Bytecodes::_fast_vputfield;
622 } else {
623 new_code = Bytecodes::_fast_aputfield;
624 }
625 break;
626 }
627 case itos: new_code = Bytecodes::_fast_iputfield; break;
628 case ctos: new_code = Bytecodes::_fast_cputfield; break;
629 case stos: new_code = Bytecodes::_fast_sputfield; break;
630 case ltos: new_code = Bytecodes::_fast_lputfield; break;
631 case ftos: new_code = Bytecodes::_fast_fputfield; break;
632 case dtos: new_code = Bytecodes::_fast_dputfield; break;
633 default:
634 ShouldNotReachHere();
635 break;
636 }
637 } else {
638 new_code = Bytecodes::_nofast_putfield;
639 }
640 break;
641 }
642 case Bytecodes::_aload_0:
643 // Revert _fast_Xaccess_0 or _aload_0 to _nofast_aload_0
644 new_code = Bytecodes::_nofast_aload_0;
645 break;
646 case Bytecodes::_iload:
|