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"
484 // AOTMetaspace::early_serialize(). Such functions must not produce side effects that
485 // assume we will always decides to map the archive.
486
487 void AOTMetaspace::early_serialize(SerializeClosure* soc) {
488 int tag = 0;
489 soc->do_tag(--tag);
490 CDS_JAVA_HEAP_ONLY(Modules::serialize_archived_module_info(soc);)
491 soc->do_tag(666);
492 }
493
494 void AOTMetaspace::serialize(SerializeClosure* soc) {
495 int tag = 0;
496 soc->do_tag(--tag);
497
498 // Verify the sizes of various metadata in the system.
499 soc->do_tag(sizeof(Method));
500 soc->do_tag(sizeof(ConstMethod));
501 soc->do_tag(arrayOopDesc::base_offset_in_bytes(T_BYTE));
502 soc->do_tag(sizeof(ConstantPool));
503 soc->do_tag(sizeof(ConstantPoolCache));
504 soc->do_tag(objArrayOopDesc::base_offset_in_bytes());
505 soc->do_tag(typeArrayOopDesc::base_offset_in_bytes(T_BYTE));
506 soc->do_tag(sizeof(Symbol));
507
508 // Need to do this first, as subsequent steps may call virtual functions
509 // in archived Metadata objects.
510 CppVtables::serialize(soc);
511 soc->do_tag(--tag);
512
513 // Dump/restore miscellaneous metadata.
514 JavaClasses::serialize_offsets(soc);
515 Universe::serialize(soc);
516 soc->do_tag(--tag);
517
518 // Dump/restore references to commonly used names and signatures.
519 vmSymbols::serialize(soc);
520 soc->do_tag(--tag);
521
522 // Dump/restore the symbol/string/subgraph_info tables
523 SymbolTable::serialize_shared_table_header(soc);
524 StringTable::serialize_shared_table_header(soc);
563 lsh.print("Rewriting bytecodes for ");
564 method()->print_external_name(&lsh);
565 lsh.print("\n");
566 }
567
568 while (!bcs.is_last_bytecode()) {
569 Bytecodes::Code opcode = bcs.next();
570 // Use current opcode as the default value of new_code
571 new_code = opcode;
572 switch(opcode) {
573 case Bytecodes::_getfield: {
574 uint rfe_index = bcs.get_index_u2();
575 bool is_resolved = cp->is_resolved(rfe_index, opcode);
576 if (is_resolved) {
577 assert(!CDSConfig::is_dumping_preimage_static_archive(), "preimage should not have resolved field references");
578 ResolvedFieldEntry* rfe = cp->resolved_field_entry_at(bcs.get_index_u2());
579 switch(rfe->tos_state()) {
580 case btos:
581 // fallthrough
582 case ztos: new_code = Bytecodes::_fast_bgetfield; break;
583 case atos: new_code = Bytecodes::_fast_agetfield; break;
584 case itos: new_code = Bytecodes::_fast_igetfield; break;
585 case ctos: new_code = Bytecodes::_fast_cgetfield; break;
586 case stos: new_code = Bytecodes::_fast_sgetfield; break;
587 case ltos: new_code = Bytecodes::_fast_lgetfield; break;
588 case ftos: new_code = Bytecodes::_fast_fgetfield; break;
589 case dtos: new_code = Bytecodes::_fast_dgetfield; break;
590 default:
591 ShouldNotReachHere();
592 break;
593 }
594 } else {
595 new_code = Bytecodes::_nofast_getfield;
596 }
597 break;
598 }
599 case Bytecodes::_putfield: {
600 uint rfe_index = bcs.get_index_u2();
601 bool is_resolved = cp->is_resolved(rfe_index, opcode);
602 if (is_resolved) {
603 assert(!CDSConfig::is_dumping_preimage_static_archive(), "preimage should not have resolved field references");
604 ResolvedFieldEntry* rfe = cp->resolved_field_entry_at(bcs.get_index_u2());
605 switch(rfe->tos_state()) {
606 case btos: new_code = Bytecodes::_fast_bputfield; break;
607 case ztos: new_code = Bytecodes::_fast_zputfield; break;
608 case atos: new_code = Bytecodes::_fast_aputfield; break;
609 case itos: new_code = Bytecodes::_fast_iputfield; break;
610 case ctos: new_code = Bytecodes::_fast_cputfield; break;
611 case stos: new_code = Bytecodes::_fast_sputfield; break;
612 case ltos: new_code = Bytecodes::_fast_lputfield; break;
613 case ftos: new_code = Bytecodes::_fast_fputfield; break;
614 case dtos: new_code = Bytecodes::_fast_dputfield; break;
615 default:
616 ShouldNotReachHere();
617 break;
618 }
619 } else {
620 new_code = Bytecodes::_nofast_putfield;
621 }
622 break;
623 }
624 case Bytecodes::_aload_0:
625 // Revert _fast_Xaccess_0 or _aload_0 to _nofast_aload_0
626 new_code = Bytecodes::_nofast_aload_0;
627 break;
628 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"
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(refArrayOopDesc::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: {
586 if (rfe->is_flat()) {
587 new_code = Bytecodes::_fast_vgetfield;
588 } else {
589 new_code = Bytecodes::_fast_agetfield;
590 }
591 break;
592 }
593 case itos: new_code = Bytecodes::_fast_igetfield; break;
594 case ctos: new_code = Bytecodes::_fast_cgetfield; break;
595 case stos: new_code = Bytecodes::_fast_sgetfield; break;
596 case ltos: new_code = Bytecodes::_fast_lgetfield; break;
597 case ftos: new_code = Bytecodes::_fast_fgetfield; break;
598 case dtos: new_code = Bytecodes::_fast_dgetfield; break;
599 default:
600 ShouldNotReachHere();
601 break;
602 }
603 } else {
604 new_code = Bytecodes::_nofast_getfield;
605 }
606 break;
607 }
608 case Bytecodes::_putfield: {
609 uint rfe_index = bcs.get_index_u2();
610 bool is_resolved = cp->is_resolved(rfe_index, opcode);
611 if (is_resolved) {
612 assert(!CDSConfig::is_dumping_preimage_static_archive(), "preimage should not have resolved field references");
613 ResolvedFieldEntry* rfe = cp->resolved_field_entry_at(bcs.get_index_u2());
614 switch(rfe->tos_state()) {
615 case btos: new_code = Bytecodes::_fast_bputfield; break;
616 case ztos: new_code = Bytecodes::_fast_zputfield; break;
617 case atos: {
618 if (rfe->is_flat() || rfe->is_null_free_inline_type()) {
619 new_code = Bytecodes::_fast_vputfield;
620 } else {
621 new_code = Bytecodes::_fast_aputfield;
622 }
623 break;
624 }
625 case itos: new_code = Bytecodes::_fast_iputfield; break;
626 case ctos: new_code = Bytecodes::_fast_cputfield; break;
627 case stos: new_code = Bytecodes::_fast_sputfield; break;
628 case ltos: new_code = Bytecodes::_fast_lputfield; break;
629 case ftos: new_code = Bytecodes::_fast_fputfield; break;
630 case dtos: new_code = Bytecodes::_fast_dputfield; break;
631 default:
632 ShouldNotReachHere();
633 break;
634 }
635 } else {
636 new_code = Bytecodes::_nofast_putfield;
637 }
638 break;
639 }
640 case Bytecodes::_aload_0:
641 // Revert _fast_Xaccess_0 or _aload_0 to _nofast_aload_0
642 new_code = Bytecodes::_nofast_aload_0;
643 break;
644 case Bytecodes::_iload:
|