src/share/vm/memory/metaspaceShared.cpp
Print this page
*** 28,37 ****
--- 28,39 ----
#include "classfile/placeholders.hpp"
#include "classfile/sharedClassUtil.hpp"
#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "code/codeCache.hpp"
+ #include "interpreter/bytecodes.hpp"
+ #include "interpreter/bytecodeStream.hpp"
#include "memory/filemap.hpp"
#include "memory/gcLocker.hpp"
#include "memory/metaspace.hpp"
#include "memory/metaspaceShared.hpp"
#include "oops/objArrayOop.hpp"
*** 102,120 ****
Klass* k = _global_klass_objects->at(i);
k->remove_unshareable_info();
}
}
! // Walk all methods in the class list and assign a fingerprint.
! // so that this part of the ConstMethod* is read only.
! static void calculate_fingerprints() {
for (int i = 0; i < _global_klass_objects->length(); i++) {
Klass* k = _global_klass_objects->at(i);
if (k->oop_is_instance()) {
InstanceKlass* ik = InstanceKlass::cast(k);
for (int i = 0; i < ik->methods()->length(); i++) {
Method* m = ik->methods()->at(i);
Fingerprinter fp(m);
// The side effect of this call sets method's fingerprint field.
fp.fingerprint();
}
}
--- 104,141 ----
Klass* k = _global_klass_objects->at(i);
k->remove_unshareable_info();
}
}
! static void rewrite_nofast_bytecode(Method* method) {
! RawBytecodeStream bcs(method);
! while (!bcs.is_last_bytecode()) {
! Bytecodes::Code opcode = bcs.raw_next();
! switch (opcode) {
! case Bytecodes::_getfield: *bcs.bcp() = Bytecodes::_nofast_getfield; break;
! case Bytecodes::_putfield: *bcs.bcp() = Bytecodes::_nofast_putfield; break;
! case Bytecodes::_aload_0: *bcs.bcp() = Bytecodes::_nofast_aload_0; break;
! case Bytecodes::_iload: *bcs.bcp() = Bytecodes::_nofast_iload; break;
! case Bytecodes::_invokevirtual: *bcs.bcp() = Bytecodes::_nofast_invokevirtual; break;
! default: break;
! }
! }
! }
!
! // Walk all methods in the class list to ensure that they won't be modified at
! // run time. This includes:
! // [1] Rewrite all bytecodes as needed, so that the ConstMethod* will not be modified
! // at run time by RewriteBytecodes/RewriteFrequentPairs
! // [2] Assign a fingerprint, so one doesn't need to be assigned at run-time.
! static void rewrite_nofast_bytecodes_and_calculate_fingerprints() {
for (int i = 0; i < _global_klass_objects->length(); i++) {
Klass* k = _global_klass_objects->at(i);
if (k->oop_is_instance()) {
InstanceKlass* ik = InstanceKlass::cast(k);
for (int i = 0; i < ik->methods()->length(); i++) {
Method* m = ik->methods()->at(i);
+ rewrite_nofast_bytecode(m);
Fingerprinter fp(m);
// The side effect of this call sets method's fingerprint field.
fp.fingerprint();
}
}
*** 474,486 ****
tty->print_cr(" instance classes = %5d", num_inst);
tty->print_cr(" obj array classes = %5d", num_obj_array);
tty->print_cr(" type array classes = %5d", num_type_array);
}
! // Update all the fingerprints in the shared methods.
! tty->print("Calculating fingerprints ... ");
! calculate_fingerprints();
tty->print_cr("done. ");
// Remove all references outside the metadata
tty->print("Removing unshareable information ... ");
remove_unshareable_in_classes();
--- 495,508 ----
tty->print_cr(" instance classes = %5d", num_inst);
tty->print_cr(" obj array classes = %5d", num_obj_array);
tty->print_cr(" type array classes = %5d", num_type_array);
}
!
! // Ensure the ConstMethods won't be modified at run-time
! tty->print("Updating ConstMethods ... ");
! rewrite_nofast_bytecodes_and_calculate_fingerprints();
tty->print_cr("done. ");
// Remove all references outside the metadata
tty->print("Removing unshareable information ... ");
remove_unshareable_in_classes();