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