hotspot/src/share/vm/oops/instanceKlass.cpp
changeset 41182 dbd59c1da636
parent 40927 59f3c8a69541
child 41183 207b92e69457
equal deleted inserted replaced
41181:2ce2f1c582ca 41182:dbd59c1da636
    39 #include "jvmtifiles/jvmti.h"
    39 #include "jvmtifiles/jvmti.h"
    40 #include "logging/log.hpp"
    40 #include "logging/log.hpp"
    41 #include "memory/heapInspection.hpp"
    41 #include "memory/heapInspection.hpp"
    42 #include "memory/iterator.inline.hpp"
    42 #include "memory/iterator.inline.hpp"
    43 #include "memory/metadataFactory.hpp"
    43 #include "memory/metadataFactory.hpp"
       
    44 #include "memory/metaspaceShared.hpp"
    44 #include "memory/oopFactory.hpp"
    45 #include "memory/oopFactory.hpp"
    45 #include "memory/resourceArea.hpp"
    46 #include "memory/resourceArea.hpp"
    46 #include "oops/fieldStreams.hpp"
    47 #include "oops/fieldStreams.hpp"
    47 #include "oops/instanceClassLoaderKlass.hpp"
    48 #include "oops/instanceClassLoaderKlass.hpp"
    48 #include "oops/instanceKlass.inline.hpp"
    49 #include "oops/instanceKlass.inline.hpp"
  1970   for (int i = 0; i < methods()->length(); i++) {
  1971   for (int i = 0; i < methods()->length(); i++) {
  1971     Method* m = methods()->at(i);
  1972     Method* m = methods()->at(i);
  1972     m->remove_unshareable_info();
  1973     m->remove_unshareable_info();
  1973   }
  1974   }
  1974 
  1975 
  1975   // cached_class_file might be pointing to a malloc'ed buffer allocated by
       
  1976   // event-based tracing code at CDS dump time. It's not usable at runtime
       
  1977   // so let's clear it.
       
  1978   set_cached_class_file(NULL);
       
  1979 
       
  1980   // do array classes also.
  1976   // do array classes also.
  1981   array_klasses_do(remove_unshareable_in_class);
  1977   array_klasses_do(remove_unshareable_in_class);
  1982 }
  1978 }
  1983 
  1979 
  1984 static void restore_unshareable_in_class(Klass* k, TRAPS) {
  1980 static void restore_unshareable_in_class(Klass* k, TRAPS) {
  2068   ik->release_C_heap_structures();
  2064   ik->release_C_heap_structures();
  2069   ik->constants()->release_C_heap_structures();
  2065   ik->constants()->release_C_heap_structures();
  2070 }
  2066 }
  2071 
  2067 
  2072 void InstanceKlass::release_C_heap_structures() {
  2068 void InstanceKlass::release_C_heap_structures() {
       
  2069   assert(!this->is_shared(), "should not be called for a shared class");
  2073 
  2070 
  2074   // Can't release the constant pool here because the constant pool can be
  2071   // Can't release the constant pool here because the constant pool can be
  2075   // deallocated separately from the InstanceKlass for default methods and
  2072   // deallocated separately from the InstanceKlass for default methods and
  2076   // redefine classes.
  2073   // redefine classes.
  2077 
  2074 
  3651   Method* method = holder->method_with_orig_idnum(idnum);
  3648   Method* method = holder->method_with_orig_idnum(idnum);
  3652   return method;
  3649   return method;
  3653 }
  3650 }
  3654 
  3651 
  3655 #if INCLUDE_JVMTI
  3652 #if INCLUDE_JVMTI
       
  3653 JvmtiCachedClassFileData* InstanceKlass::get_cached_class_file() {
       
  3654   if (MetaspaceShared::is_in_shared_space(_cached_class_file)) {
       
  3655     // Ignore the archived class stream data
       
  3656     return NULL;
       
  3657   } else {
       
  3658     return _cached_class_file;
       
  3659   }
       
  3660 }
       
  3661 
  3656 jint InstanceKlass::get_cached_class_file_len() {
  3662 jint InstanceKlass::get_cached_class_file_len() {
  3657   return VM_RedefineClasses::get_cached_class_file_len(_cached_class_file);
  3663   return VM_RedefineClasses::get_cached_class_file_len(_cached_class_file);
  3658 }
  3664 }
  3659 
  3665 
  3660 unsigned char * InstanceKlass::get_cached_class_file_bytes() {
  3666 unsigned char * InstanceKlass::get_cached_class_file_bytes() {
  3661   return VM_RedefineClasses::get_cached_class_file_bytes(_cached_class_file);
  3667   return VM_RedefineClasses::get_cached_class_file_bytes(_cached_class_file);
  3662 }
  3668 }
       
  3669 
       
  3670 #if INCLUDE_CDS
       
  3671 JvmtiCachedClassFileData* InstanceKlass::get_archived_class_data() {
       
  3672   assert(this->is_shared(), "class should be shared");
       
  3673   if (MetaspaceShared::is_in_shared_space(_cached_class_file)) {
       
  3674     return _cached_class_file;
       
  3675   } else {
       
  3676     return NULL;
       
  3677   }
       
  3678 }
  3663 #endif
  3679 #endif
       
  3680 #endif