< prev index next >

src/hotspot/share/oops/klass.cpp


41 #include "oops/instanceKlass.hpp"                                                                                                    
42 #include "oops/klass.inline.hpp"                                                                                                     
43 #include "oops/oop.inline.hpp"                                                                                                       
44 #include "oops/oopHandle.inline.hpp"                                                                                                 
45 #include "runtime/atomic.hpp"                                                                                                        
46 #include "runtime/handles.inline.hpp"                                                                                                
47 #include "runtime/orderAccess.hpp"                                                                                                   
48 #include "utilities/macros.hpp"                                                                                                      
49 #include "utilities/stack.inline.hpp"                                                                                                
50 
51 void Klass::set_java_mirror(Handle m) {                                                                                              
52   assert(!m.is_null(), "New mirror should never be null.");                                                                          
53   assert(_java_mirror.resolve() == NULL, "should only be used to initialize mirror");                                                
54   _java_mirror = class_loader_data()->add_handle(m);                                                                                 
55 }                                                                                                                                    
56 
57 oop Klass::java_mirror() const {                                                                                                     
58   return _java_mirror.resolve();                                                                                                     
59 }                                                                                                                                    
60 
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
61 bool Klass::is_cloneable() const {                                                                                                   
62   return _access_flags.is_cloneable_fast() ||                                                                                        
63          is_subtype_of(SystemDictionary::Cloneable_klass());                                                                         
64 }                                                                                                                                    
65 
66 void Klass::set_is_cloneable() {                                                                                                     
67   if (name() == vmSymbols::java_lang_invoke_MemberName()) {                                                                          
68     assert(is_final(), "no subclasses allowed");                                                                                     
69     // MemberName cloning should not be intrinsified and always happen in JVM_Clone.                                                 
70   } else if (is_instance_klass() && InstanceKlass::cast(this)->reference_type() != REF_NONE) {                                       
71     // Reference cloning should not be intrinsified and always happen in JVM_Clone.                                                  
72   } else {                                                                                                                           
73     _access_flags.set_is_cloneable_fast();                                                                                           
74   }                                                                                                                                  
75 }                                                                                                                                    
76 
77 void Klass::set_name(Symbol* n) {                                                                                                    
78   _name = n;                                                                                                                         
79   if (_name != NULL) _name->increment_refcount();                                                                                    

41 #include "oops/instanceKlass.hpp"
42 #include "oops/klass.inline.hpp"
43 #include "oops/oop.inline.hpp"
44 #include "oops/oopHandle.inline.hpp"
45 #include "runtime/atomic.hpp"
46 #include "runtime/handles.inline.hpp"
47 #include "runtime/orderAccess.hpp"
48 #include "utilities/macros.hpp"
49 #include "utilities/stack.inline.hpp"
50 
51 void Klass::set_java_mirror(Handle m) {
52   assert(!m.is_null(), "New mirror should never be null.");
53   assert(_java_mirror.resolve() == NULL, "should only be used to initialize mirror");
54   _java_mirror = class_loader_data()->add_handle(m);
55 }
56 
57 oop Klass::java_mirror() const {
58   return _java_mirror.resolve();
59 }
60 
61 oop Klass::java_mirror_no_keepalive() const {
62   return _java_mirror.peek();
63 }
64 
65 bool Klass::is_cloneable() const {
66   return _access_flags.is_cloneable_fast() ||
67          is_subtype_of(SystemDictionary::Cloneable_klass());
68 }
69 
70 void Klass::set_is_cloneable() {
71   if (name() == vmSymbols::java_lang_invoke_MemberName()) {
72     assert(is_final(), "no subclasses allowed");
73     // MemberName cloning should not be intrinsified and always happen in JVM_Clone.
74   } else if (is_instance_klass() && InstanceKlass::cast(this)->reference_type() != REF_NONE) {
75     // Reference cloning should not be intrinsified and always happen in JVM_Clone.
76   } else {
77     _access_flags.set_is_cloneable_fast();
78   }
79 }
80 
81 void Klass::set_name(Symbol* n) {
82   _name = n;
83   if (_name != NULL) _name->increment_refcount();

728   // This can be expensive, but it is worth checking that this klass is actually                                                     
729   // in the CLD graph but not in production.                                                                                         
730   assert(Metaspace::contains((address)this), "Should be");                                                                           
731 
732   guarantee(this->is_klass(),"should be klass");                                                                                     
733 
734   if (super() != NULL) {                                                                                                             
735     guarantee(super()->is_klass(), "should be klass");                                                                               
736   }                                                                                                                                  
737   if (secondary_super_cache() != NULL) {                                                                                             
738     Klass* ko = secondary_super_cache();                                                                                             
739     guarantee(ko->is_klass(), "should be klass");                                                                                    
740   }                                                                                                                                  
741   for ( uint i = 0; i < primary_super_limit(); i++ ) {                                                                               
742     Klass* ko = _primary_supers[i];                                                                                                  
743     if (ko != NULL) {                                                                                                                
744       guarantee(ko->is_klass(), "should be klass");                                                                                  
745     }                                                                                                                                
746   }                                                                                                                                  
747 
748   if (java_mirror() != NULL) {                                                                                                       
749     guarantee(oopDesc::is_oop(java_mirror()), "should be instance");                                                                 
750   }                                                                                                                                  
751 }                                                                                                                                    
752 
753 void Klass::oop_verify_on(oop obj, outputStream* st) {                                                                               
754   guarantee(oopDesc::is_oop(obj),  "should be oop");                                                                                 
755   guarantee(obj->klass()->is_klass(), "klass field is not a klass");                                                                 
756 }                                                                                                                                    
757 
758 Klass* Klass::decode_klass_raw(narrowKlass narrow_klass) {                                                                           
759   return (Klass*)(void*)( (uintptr_t)Universe::narrow_klass_base() +                                                                 
760                          ((uintptr_t)narrow_klass << Universe::narrow_klass_shift()));                                               
761 }                                                                                                                                    
762 
763 bool Klass::is_valid(Klass* k) {                                                                                                     
764   if (!is_aligned(k, sizeof(MetaWord))) return false;                                                                                
765   if ((size_t)k < os::min_page_size()) return false;                                                                                 
766 
767   if (!os::is_readable_range(k, k + 1)) return false;                                                                                
768   if (!MetaspaceUtils::is_range_in_committed(k, k + 1)) return false;                                                                

732   // This can be expensive, but it is worth checking that this klass is actually
733   // in the CLD graph but not in production.
734   assert(Metaspace::contains((address)this), "Should be");
735 
736   guarantee(this->is_klass(),"should be klass");
737 
738   if (super() != NULL) {
739     guarantee(super()->is_klass(), "should be klass");
740   }
741   if (secondary_super_cache() != NULL) {
742     Klass* ko = secondary_super_cache();
743     guarantee(ko->is_klass(), "should be klass");
744   }
745   for ( uint i = 0; i < primary_super_limit(); i++ ) {
746     Klass* ko = _primary_supers[i];
747     if (ko != NULL) {
748       guarantee(ko->is_klass(), "should be klass");
749     }
750   }
751 
752   if (java_mirror_no_keepalive() != NULL) {
753     guarantee(oopDesc::is_oop(java_mirror_no_keepalive()), "should be instance");
754   }
755 }
756 
757 void Klass::oop_verify_on(oop obj, outputStream* st) {
758   guarantee(oopDesc::is_oop(obj),  "should be oop");
759   guarantee(obj->klass()->is_klass(), "klass field is not a klass");
760 }
761 
762 Klass* Klass::decode_klass_raw(narrowKlass narrow_klass) {
763   return (Klass*)(void*)( (uintptr_t)Universe::narrow_klass_base() +
764                          ((uintptr_t)narrow_klass << Universe::narrow_klass_shift()));
765 }
766 
767 bool Klass::is_valid(Klass* k) {
768   if (!is_aligned(k, sizeof(MetaWord))) return false;
769   if ((size_t)k < os::min_page_size()) return false;
770 
771   if (!os::is_readable_range(k, k + 1)) return false;
772   if (!MetaspaceUtils::is_range_in_committed(k, k + 1)) return false;
< prev index next >