< prev index next >

src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp

Print this page




 186   // enclosing blobs.
 187   CodeCache::blobs_do(do_blob);
 188 
 189   // make the global list the instance list so that it can be used
 190   // for other iterations.
 191   _code_blobs = _global_code_blobs;
 192   _global_code_blobs = NULL;
 193 }
 194 
 195 
 196 // Generate a DYNAMIC_CODE_GENERATED event for each non-nmethod code blob.
 197 
 198 jvmtiError JvmtiCodeBlobEvents::generate_dynamic_code_events(JvmtiEnv* env) {
 199   CodeBlobCollector collector;
 200 
 201   // First collect all the code blobs.  This has to be done in a
 202   // single pass over the code cache with CodeCache_lock held because
 203   // there isn't any safe way to iterate over regular CodeBlobs since
 204   // they can be freed at any point.
 205   {
 206     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 207     collector.collect();
 208   }
 209 
 210   // iterate over the collected list and post an event for each blob
 211   JvmtiCodeBlobDesc* blob = collector.first();
 212   while (blob != NULL) {
 213     JvmtiExport::post_dynamic_code_generated(env, blob->name(), blob->code_begin(), blob->code_end());
 214     blob = collector.next();
 215   }
 216   return JVMTI_ERROR_NONE;
 217 }
 218 
 219 
 220 // Generate a COMPILED_METHOD_LOAD event for each nnmethod
 221 jvmtiError JvmtiCodeBlobEvents::generate_compiled_method_load_events(JvmtiEnv* env) {
 222   HandleMark hm;
 223 
 224   // Walk the CodeCache notifying for live nmethods.  The code cache
 225   // may be changing while this is happening which is ok since newly
 226   // created nmethod will notify normally and nmethods which are freed
 227   // can be safely skipped.
 228   MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 229   // Iterate over non-profiled and profiled nmethods
 230   NMethodIterator iter(NMethodIterator::only_alive_and_not_unloading);
 231   while(iter.next()) {
 232     nmethod* current = iter.method();
 233     // Lock the nmethod so it can't be freed
 234     nmethodLocker nml(current);
 235 
 236     // Don't hold the lock over the notify or jmethodID creation
 237     MutexUnlocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 238     current->get_and_cache_jmethod_id();
 239     JvmtiExport::post_compiled_method_load(env, current);
 240   }
 241   return JVMTI_ERROR_NONE;
 242 }
 243 
 244 
 245 // create a C-heap allocated address location map for an nmethod
 246 void JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nmethod *nm,
 247                                                         jvmtiAddrLocationMap** map_ptr,
 248                                                         jint *map_length_ptr)
 249 {
 250   ResourceMark rm;
 251   jvmtiAddrLocationMap* map = NULL;
 252   jint map_length = 0;
 253 
 254 
 255   // Generate line numbers using PcDesc and ScopeDesc info
 256   methodHandle mh(nm->method());
 257 
 258   if (!mh->is_native()) {
 259     PcDesc *pcd;




 186   // enclosing blobs.
 187   CodeCache::blobs_do(do_blob);
 188 
 189   // make the global list the instance list so that it can be used
 190   // for other iterations.
 191   _code_blobs = _global_code_blobs;
 192   _global_code_blobs = NULL;
 193 }
 194 
 195 
 196 // Generate a DYNAMIC_CODE_GENERATED event for each non-nmethod code blob.
 197 
 198 jvmtiError JvmtiCodeBlobEvents::generate_dynamic_code_events(JvmtiEnv* env) {
 199   CodeBlobCollector collector;
 200 
 201   // First collect all the code blobs.  This has to be done in a
 202   // single pass over the code cache with CodeCache_lock held because
 203   // there isn't any safe way to iterate over regular CodeBlobs since
 204   // they can be freed at any point.
 205   {
 206     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 207     collector.collect();
 208   }
 209 
 210   // iterate over the collected list and post an event for each blob
 211   JvmtiCodeBlobDesc* blob = collector.first();
 212   while (blob != NULL) {
 213     JvmtiExport::post_dynamic_code_generated(env, blob->name(), blob->code_begin(), blob->code_end());
 214     blob = collector.next();
 215   }
 216   return JVMTI_ERROR_NONE;
 217 }
 218 
 219 
 220 // Generate a COMPILED_METHOD_LOAD event for each nnmethod
 221 jvmtiError JvmtiCodeBlobEvents::generate_compiled_method_load_events(JvmtiEnv* env) {
 222   HandleMark hm;
 223 
 224   // Walk the CodeCache notifying for live nmethods.  The code cache
 225   // may be changing while this is happening which is ok since newly
 226   // created nmethod will notify normally and nmethods which are freed
 227   // can be safely skipped.
 228   MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 229   // Iterate over non-profiled and profiled nmethods
 230   NMethodIterator iter(NMethodIterator::only_alive_and_not_unloading);
 231   while(iter.next()) {
 232     nmethod* current = iter.method();
 233     // Lock the nmethod so it can't be freed
 234     nmethodLocker nml(current);
 235 
 236     // Don't hold the lock over the notify or jmethodID creation
 237     MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 238     current->get_and_cache_jmethod_id();
 239     JvmtiExport::post_compiled_method_load(current);
 240   }
 241   return JVMTI_ERROR_NONE;
 242 }
 243 
 244 
 245 // create a C-heap allocated address location map for an nmethod
 246 void JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nmethod *nm,
 247                                                         jvmtiAddrLocationMap** map_ptr,
 248                                                         jint *map_length_ptr)
 249 {
 250   ResourceMark rm;
 251   jvmtiAddrLocationMap* map = NULL;
 252   jint map_length = 0;
 253 
 254 
 255   // Generate line numbers using PcDesc and ScopeDesc info
 256   methodHandle mh(nm->method());
 257 
 258   if (!mh->is_native()) {
 259     PcDesc *pcd;


< prev index next >