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