211 212 // iterate over the collected list and post an event for each blob 213 JvmtiCodeBlobDesc* blob = collector.first(); 214 while (blob != NULL) { 215 JvmtiExport::post_dynamic_code_generated(env, blob->name(), blob->code_begin(), blob->code_end()); 216 blob = collector.next(); 217 } 218 return JVMTI_ERROR_NONE; 219 } 220 221 222 // Generate a COMPILED_METHOD_LOAD event for each nnmethod 223 jvmtiError JvmtiCodeBlobEvents::generate_compiled_method_load_events(JvmtiEnv* env) { 224 HandleMark hm; 225 226 // Walk the CodeCache notifying for live nmethods. The code cache 227 // may be changing while this is happening which is ok since newly 228 // created nmethod will notify normally and nmethods which are freed 229 // can be safely skipped. 230 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 231 nmethod* current = CodeCache::first_nmethod(); 232 while (current != NULL) { 233 // Only notify for live nmethods 234 if (current->is_alive()) { 235 // Lock the nmethod so it can't be freed 236 nmethodLocker nml(current); 237 238 // Don't hold the lock over the notify or jmethodID creation 239 MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 240 current->get_and_cache_jmethod_id(); 241 JvmtiExport::post_compiled_method_load(current); 242 } 243 current = CodeCache::next_nmethod(current); 244 } 245 return JVMTI_ERROR_NONE; 246 } 247 248 249 // create a C-heap allocated address location map for an nmethod 250 void JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nmethod *nm, 251 jvmtiAddrLocationMap** map_ptr, 252 jint *map_length_ptr) 253 { 254 ResourceMark rm; 255 jvmtiAddrLocationMap* map = NULL; 256 jint map_length = 0; 257 258 259 // Generate line numbers using PcDesc and ScopeDesc info 260 methodHandle mh(nm->method()); 261 262 if (!mh->is_native()) { 263 PcDesc *pcd; | 211 212 // iterate over the collected list and post an event for each blob 213 JvmtiCodeBlobDesc* blob = collector.first(); 214 while (blob != NULL) { 215 JvmtiExport::post_dynamic_code_generated(env, blob->name(), blob->code_begin(), blob->code_end()); 216 blob = collector.next(); 217 } 218 return JVMTI_ERROR_NONE; 219 } 220 221 222 // Generate a COMPILED_METHOD_LOAD event for each nnmethod 223 jvmtiError JvmtiCodeBlobEvents::generate_compiled_method_load_events(JvmtiEnv* env) { 224 HandleMark hm; 225 226 // Walk the CodeCache notifying for live nmethods. The code cache 227 // may be changing while this is happening which is ok since newly 228 // created nmethod will notify normally and nmethods which are freed 229 // can be safely skipped. 230 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 231 // Iterate over non-profiled and profiled nmethods 232 NMethodIterator iter; 233 while(iter.next_alive()) { 234 nmethod* current = iter.method(); 235 // Lock the nmethod so it can't be freed 236 nmethodLocker nml(current); 237 238 // Don't hold the lock over the notify or jmethodID creation 239 MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 240 current->get_and_cache_jmethod_id(); 241 JvmtiExport::post_compiled_method_load(current); 242 } 243 return JVMTI_ERROR_NONE; 244 } 245 246 247 // create a C-heap allocated address location map for an nmethod 248 void JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nmethod *nm, 249 jvmtiAddrLocationMap** map_ptr, 250 jint *map_length_ptr) 251 { 252 ResourceMark rm; 253 jvmtiAddrLocationMap* map = NULL; 254 jint map_length = 0; 255 256 257 // Generate line numbers using PcDesc and ScopeDesc info 258 methodHandle mh(nm->method()); 259 260 if (!mh->is_native()) { 261 PcDesc *pcd; |