src/hotspot/share/memory/metaspaceShared.cpp
changeset 59056 15936b142f86
parent 58447 319173c62caa
child 59070 22ee476cc664
equal deleted inserted replaced
59055:57ad70bcf06c 59056:15936b142f86
   594   Universe::set_long_mirror(NULL);
   594   Universe::set_long_mirror(NULL);
   595   Universe::set_short_mirror(NULL);
   595   Universe::set_short_mirror(NULL);
   596   Universe::set_void_mirror(NULL);
   596   Universe::set_void_mirror(NULL);
   597 }
   597 }
   598 
   598 
   599 static void rewrite_nofast_bytecode(Method* method) {
   599 static void rewrite_nofast_bytecode(const methodHandle& method) {
   600   BytecodeStream bcs(method);
   600   BytecodeStream bcs(method);
   601   while (!bcs.is_last_bytecode()) {
   601   while (!bcs.is_last_bytecode()) {
   602     Bytecodes::Code opcode = bcs.next();
   602     Bytecodes::Code opcode = bcs.next();
   603     switch (opcode) {
   603     switch (opcode) {
   604     case Bytecodes::_getfield:      *bcs.bcp() = Bytecodes::_nofast_getfield;      break;
   604     case Bytecodes::_getfield:      *bcs.bcp() = Bytecodes::_nofast_getfield;      break;
   618 // Walk all methods in the class list to ensure that they won't be modified at
   618 // Walk all methods in the class list to ensure that they won't be modified at
   619 // run time. This includes:
   619 // run time. This includes:
   620 // [1] Rewrite all bytecodes as needed, so that the ConstMethod* will not be modified
   620 // [1] Rewrite all bytecodes as needed, so that the ConstMethod* will not be modified
   621 //     at run time by RewriteBytecodes/RewriteFrequentPairs
   621 //     at run time by RewriteBytecodes/RewriteFrequentPairs
   622 // [2] Assign a fingerprint, so one doesn't need to be assigned at run-time.
   622 // [2] Assign a fingerprint, so one doesn't need to be assigned at run-time.
   623 static void rewrite_nofast_bytecodes_and_calculate_fingerprints() {
   623 static void rewrite_nofast_bytecodes_and_calculate_fingerprints(Thread* thread) {
   624   for (int i = 0; i < _global_klass_objects->length(); i++) {
   624   for (int i = 0; i < _global_klass_objects->length(); i++) {
   625     Klass* k = _global_klass_objects->at(i);
   625     Klass* k = _global_klass_objects->at(i);
   626     if (k->is_instance_klass()) {
   626     if (k->is_instance_klass()) {
   627       InstanceKlass* ik = InstanceKlass::cast(k);
   627       InstanceKlass* ik = InstanceKlass::cast(k);
   628       MetaspaceShared::rewrite_nofast_bytecodes_and_calculate_fingerprints(ik);
   628       MetaspaceShared::rewrite_nofast_bytecodes_and_calculate_fingerprints(thread, ik);
   629     }
   629     }
   630   }
   630   }
   631 }
   631 }
   632 
   632 
   633 void MetaspaceShared::rewrite_nofast_bytecodes_and_calculate_fingerprints(InstanceKlass* ik) {
   633 void MetaspaceShared::rewrite_nofast_bytecodes_and_calculate_fingerprints(Thread* thread, InstanceKlass* ik) {
   634   for (int i = 0; i < ik->methods()->length(); i++) {
   634   for (int i = 0; i < ik->methods()->length(); i++) {
   635     Method* m = ik->methods()->at(i);
   635     methodHandle m(thread, ik->methods()->at(i));
   636     rewrite_nofast_bytecode(m);
   636     rewrite_nofast_bytecode(m);
   637     Fingerprinter fp(m);
   637     Fingerprinter fp(m);
   638     // The side effect of this call sets method's fingerprint field.
   638     // The side effect of this call sets method's fingerprint field.
   639     fp.fingerprint();
   639     fp.fingerprint();
   640   }
   640   }
  1491     tty->print_cr("    type array classes = %5d", num_type_array);
  1491     tty->print_cr("    type array classes = %5d", num_type_array);
  1492   }
  1492   }
  1493 
  1493 
  1494   // Ensure the ConstMethods won't be modified at run-time
  1494   // Ensure the ConstMethods won't be modified at run-time
  1495   tty->print("Updating ConstMethods ... ");
  1495   tty->print("Updating ConstMethods ... ");
  1496   rewrite_nofast_bytecodes_and_calculate_fingerprints();
  1496   rewrite_nofast_bytecodes_and_calculate_fingerprints(THREAD);
  1497   tty->print_cr("done. ");
  1497   tty->print_cr("done. ");
  1498 
  1498 
  1499   // Remove all references outside the metadata
  1499   // Remove all references outside the metadata
  1500   tty->print("Removing unshareable information ... ");
  1500   tty->print("Removing unshareable information ... ");
  1501   remove_unshareable_in_classes();
  1501   remove_unshareable_in_classes();