< prev index next >

src/hotspot/share/prims/jvmtiEnvBase.cpp

Print this page
rev 56101 : 8227745: Enable Escape Analysis for better performance when debugging
Reviewed-by: ???


1309         !jt->is_hidden_from_external_view()) {
1310       ++_final_thread_count;
1311       // Handle block of the calling thread is used to create local refs.
1312       fill_frames((jthread)JNIHandles::make_local(_calling_thread, thread_oop),
1313                   jt, thread_oop);
1314     }
1315   }
1316   allocate_and_fill_stacks(_final_thread_count);
1317 }
1318 
1319 // Verifies that the top frame is a java frame in an expected state.
1320 // Deoptimizes frame if needed.
1321 // Checks that the frame method signature matches the return type (tos).
1322 // HandleMark must be defined in the caller only.
1323 // It is to keep a ret_ob_h handle alive after return to the caller.
1324 jvmtiError
1325 JvmtiEnvBase::check_top_frame(JavaThread* current_thread, JavaThread* java_thread,
1326                               jvalue value, TosState tos, Handle* ret_ob_h) {
1327   ResourceMark rm(current_thread);
1328 







1329   vframe *vf = vframeFor(java_thread, 0);
1330   NULL_CHECK(vf, JVMTI_ERROR_NO_MORE_FRAMES);
1331 
1332   javaVFrame *jvf = (javaVFrame*) vf;
1333   if (!vf->is_java_frame() || jvf->method()->is_native()) {
1334     return JVMTI_ERROR_OPAQUE_FRAME;
1335   }
1336 
1337   // If the frame is a compiled one, need to deoptimize it.
1338   if (vf->is_compiled_frame()) {
1339     if (!vf->fr().can_be_deoptimized()) {
1340       return JVMTI_ERROR_OPAQUE_FRAME;
1341     }
1342     Deoptimization::deoptimize_frame(java_thread, jvf->fr().id());






1343   }
1344 
1345   // Get information about method return type
1346   Symbol* signature = jvf->method()->signature();
1347 
1348   ResultTypeFinder rtf(signature);
1349   TosState fr_tos = as_TosState(rtf.type());
1350   if (fr_tos != tos) {
1351     if (tos != itos || (fr_tos != btos && fr_tos != ztos && fr_tos != ctos && fr_tos != stos)) {
1352       return JVMTI_ERROR_TYPE_MISMATCH;
1353     }
1354   }
1355 
1356   // Check that the jobject class matches the return type signature.
1357   jobject jobj = value.l;
1358   if (tos == atos && jobj != NULL) { // NULL reference is allowed
1359     Handle ob_h(current_thread, JNIHandles::resolve_external_guard(jobj));
1360     NULL_CHECK(ob_h, JVMTI_ERROR_INVALID_OBJECT);
1361     Klass* ob_k = ob_h()->klass();
1362     NULL_CHECK(ob_k, JVMTI_ERROR_INVALID_OBJECT);




1309         !jt->is_hidden_from_external_view()) {
1310       ++_final_thread_count;
1311       // Handle block of the calling thread is used to create local refs.
1312       fill_frames((jthread)JNIHandles::make_local(_calling_thread, thread_oop),
1313                   jt, thread_oop);
1314     }
1315   }
1316   allocate_and_fill_stacks(_final_thread_count);
1317 }
1318 
1319 // Verifies that the top frame is a java frame in an expected state.
1320 // Deoptimizes frame if needed.
1321 // Checks that the frame method signature matches the return type (tos).
1322 // HandleMark must be defined in the caller only.
1323 // It is to keep a ret_ob_h handle alive after return to the caller.
1324 jvmtiError
1325 JvmtiEnvBase::check_top_frame(JavaThread* current_thread, JavaThread* java_thread,
1326                               jvalue value, TosState tos, Handle* ret_ob_h) {
1327   ResourceMark rm(current_thread);
1328 
1329   if (java_thread->frames_to_pop_failed_realloc() > 0) {
1330     // VM is in the process of popping the top frame, because it has scalar replaced objects
1331     // which could not be reallocated on the heap.
1332     // Return JVMTI_ERROR_OUT_OF_MEMORY to avoid interfering with the VM.
1333     return JVMTI_ERROR_OUT_OF_MEMORY;
1334   }
1335 
1336   vframe *vf = vframeFor(java_thread, 0);
1337   NULL_CHECK(vf, JVMTI_ERROR_NO_MORE_FRAMES);
1338 
1339   javaVFrame *jvf = (javaVFrame*) vf;
1340   if (!vf->is_java_frame() || jvf->method()->is_native()) {
1341     return JVMTI_ERROR_OPAQUE_FRAME;
1342   }
1343 
1344   // If the frame is a compiled one, need to deoptimize it.
1345   if (vf->is_compiled_frame()) {
1346     if (!vf->fr().can_be_deoptimized()) {
1347       return JVMTI_ERROR_OPAQUE_FRAME;
1348     }
1349     Deoptimization::deoptimize_frame(java_thread, jvf->fr().id());
1350     // eagerly reallocate scalar replaced objects
1351     JVMTIEscapeBarrier eb(current_thread, java_thread, true);
1352     if (!eb.deoptimize_objects(jvf->fr().id())) {
1353       // reallocation of scalar replaced objects failed -> return with error
1354       return JVMTI_ERROR_OUT_OF_MEMORY;
1355     }
1356   }
1357 
1358   // Get information about method return type
1359   Symbol* signature = jvf->method()->signature();
1360 
1361   ResultTypeFinder rtf(signature);
1362   TosState fr_tos = as_TosState(rtf.type());
1363   if (fr_tos != tos) {
1364     if (tos != itos || (fr_tos != btos && fr_tos != ztos && fr_tos != ctos && fr_tos != stos)) {
1365       return JVMTI_ERROR_TYPE_MISMATCH;
1366     }
1367   }
1368 
1369   // Check that the jobject class matches the return type signature.
1370   jobject jobj = value.l;
1371   if (tos == atos && jobj != NULL) { // NULL reference is allowed
1372     Handle ob_h(current_thread, JNIHandles::resolve_external_guard(jobj));
1373     NULL_CHECK(ob_h, JVMTI_ERROR_INVALID_OBJECT);
1374     Klass* ob_k = ob_h()->klass();
1375     NULL_CHECK(ob_k, JVMTI_ERROR_INVALID_OBJECT);


< prev index next >