< prev index next >

src/share/vm/oops/method.cpp

Print this page




2079 };
2080 
2081 void Method::set_on_stack(const bool value) {
2082   // Set both the method itself and its constant pool.  The constant pool
2083   // on stack means some method referring to it is also on the stack.
2084   constants()->set_on_stack(value);
2085 
2086   bool already_set = on_stack();
2087   _access_flags.set_on_stack(value);
2088   if (value && !already_set) {
2089     MetadataOnStackMark::record(this);
2090   }
2091 }
2092 
2093 // Called when the class loader is unloaded to make all methods weak.
2094 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) {
2095   loader_data->jmethod_ids()->clear_all_methods();
2096 }
2097 
2098 bool Method::has_method_vptr(const void* ptr) {
2099   Method m;
2100   // This assumes that the vtbl pointer is the first word of a C++ object.
2101   // This assumption is also in universe.cpp patch_klass_vtble
2102   void* vtbl2 = dereference_vptr((const void*)&m);
2103   void* this_vtbl = dereference_vptr(ptr);
2104   return vtbl2 == this_vtbl;




2105 }
2106 
2107 // Check that this pointer is valid by checking that the vtbl pointer matches
2108 bool Method::is_valid_method() const {
2109   if (this == NULL) {
2110     return false;
2111   } else if (!is_metaspace_object()) {


2112     return false;
2113   } else {
2114     return has_method_vptr((const void*)this);
2115   }

2116 }
2117 
2118 #ifndef PRODUCT
2119 void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) {
2120   out->print_cr("jni_method_id count = %d", loader_data->jmethod_ids()->count_methods());
2121 }
2122 #endif // PRODUCT
2123 
2124 
2125 // Printing
2126 
2127 #ifndef PRODUCT
2128 
2129 void Method::print_on(outputStream* st) const {
2130   ResourceMark rm;
2131   assert(is_method(), "must be method");
2132   st->print_cr("%s", internal_name());
2133   // get the effect of PrintOopAddress, always, for methods:
2134   st->print_cr(" - this oop:          " INTPTR_FORMAT, p2i(this));
2135   st->print   (" - method holder:     "); method_holder()->print_value_on(st); st->cr();




2079 };
2080 
2081 void Method::set_on_stack(const bool value) {
2082   // Set both the method itself and its constant pool.  The constant pool
2083   // on stack means some method referring to it is also on the stack.
2084   constants()->set_on_stack(value);
2085 
2086   bool already_set = on_stack();
2087   _access_flags.set_on_stack(value);
2088   if (value && !already_set) {
2089     MetadataOnStackMark::record(this);
2090   }
2091 }
2092 
2093 // Called when the class loader is unloaded to make all methods weak.
2094 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) {
2095   loader_data->jmethod_ids()->clear_all_methods();
2096 }
2097 
2098 bool Method::has_method_vptr(const void* ptr) {
2099   // Use SafeFetch to check if this is a valid pointer first
2100   // This assumes that the vtbl pointer is the first word of a C++ object.
2101   // This assumption is also in universe.cpp patch_klass_vtable
2102   intptr_t this_vptr = SafeFetchN((intptr_t*)ptr, intptr_t(1));
2103   if (this_vptr == 1) {
2104     return false;
2105   }
2106   Method m;
2107   void* vptr2 = dereference_vptr((const void*)&m);
2108   return (intptr_t)vptr2 == this_vptr;
2109 }
2110 
2111 // Check that this pointer is valid by checking that the vtbl pointer matches
2112 bool Method::is_valid_method() const {
2113   if (this == NULL) {
2114     return false;
2115   } else {
2116     // Quick sanity check on pointer.
2117     if ((intptr_t(this) & (wordSize-1)) != 0) {
2118       return false;
2119     } else {
2120       return has_method_vptr(this);
2121     }
2122   }
2123 }
2124 
2125 #ifndef PRODUCT
2126 void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) {
2127   out->print_cr("jni_method_id count = %d", loader_data->jmethod_ids()->count_methods());
2128 }
2129 #endif // PRODUCT
2130 
2131 
2132 // Printing
2133 
2134 #ifndef PRODUCT
2135 
2136 void Method::print_on(outputStream* st) const {
2137   ResourceMark rm;
2138   assert(is_method(), "must be method");
2139   st->print_cr("%s", internal_name());
2140   // get the effect of PrintOopAddress, always, for methods:
2141   st->print_cr(" - this oop:          " INTPTR_FORMAT, p2i(this));
2142   st->print   (" - method holder:     "); method_holder()->print_value_on(st); st->cr();


< prev index next >