src/share/vm/prims/jvmtiEnv.cpp

Print this page




1447       }
1448     }
1449 
1450     // If any of the top 2 frames is a compiled one, need to deoptimize it
1451     for (int i = 0; i < 2; i++) {
1452       if (!is_interpreted[i]) {
1453         Deoptimization::deoptimize_frame(java_thread, frame_sp[i]);
1454       }
1455     }
1456 
1457     // Update the thread state to reflect that the top frame is popped
1458     // so that cur_stack_depth is maintained properly and all frameIDs
1459     // are invalidated.
1460     // The current frame will be popped later when the suspended thread
1461     // is resumed and right before returning from VM to Java.
1462     // (see call_VM_base() in assembler_<cpu>.cpp).
1463 
1464     // It's fine to update the thread state here because no JVMTI events
1465     // shall be posted for this PopFrame.
1466 



1467     state->update_for_pop_top_frame();









1468     java_thread->set_popframe_condition(JavaThread::popframe_pending_bit);
1469     // Set pending step flag for this popframe and it is cleared when next
1470     // step event is posted.
1471     state->set_pending_step_for_popframe();
1472   }
1473 
1474   return JVMTI_ERROR_NONE;
1475 } /* end PopFrame */
1476 
1477 
1478 // Threads_lock NOT held, java_thread not protected by lock
1479 // java_thread - pre-checked
1480 // java_thread - unchecked
1481 // depth - pre-checked as non-negative
1482 // method_ptr - pre-checked for NULL
1483 // location_ptr - pre-checked for NULL
1484 jvmtiError
1485 JvmtiEnv::GetFrameLocation(JavaThread* java_thread, jint depth, jmethodID* method_ptr, jlocation* location_ptr) {
1486   jvmtiError err = JVMTI_ERROR_NONE;
1487 
1488   // It is only safe to perform the direct operation on the current
1489   // thread. All other usage needs to use a vm-safepoint-op for safety.
1490   if (java_thread == JavaThread::current()) {
1491     err = get_frame_location(java_thread, depth, method_ptr, location_ptr);
1492   } else {
1493     // JVMTI get java stack frame location at safepoint.
1494     VM_GetFrameLocation op(this, java_thread, depth, method_ptr, location_ptr);
1495     VMThread::execute(&op);
1496     err = op.result();
1497   }
1498   return err;
1499 } /* end GetFrameLocation */
1500 
1501 
1502 // Threads_lock NOT held, java_thread not protected by lock
1503 // java_thread - pre-checked
1504 // java_thread - unchecked
1505 // depth - pre-checked as non-negative
1506 jvmtiError
1507 JvmtiEnv::NotifyFramePop(JavaThread* java_thread, jint depth) {

1508   ResourceMark rm;
1509   uint32_t debug_bits = 0;
1510 
1511   JvmtiThreadState *state = JvmtiThreadState::state_for(java_thread);
1512   if (state == NULL) {
1513     return JVMTI_ERROR_THREAD_NOT_ALIVE;
1514   }
1515 
1516   if (!JvmtiEnv::is_thread_fully_suspended(java_thread, true, &debug_bits)) {
1517       return JVMTI_ERROR_THREAD_NOT_SUSPENDED;
1518   }
1519 
1520   if (TraceJVMTICalls) {
1521     JvmtiSuspendControl::print();
1522   }
1523 
1524   vframe *vf = vframeFor(java_thread, depth);
1525   if (vf == NULL) {
1526     return JVMTI_ERROR_NO_MORE_FRAMES;
1527   }
1528 
1529   if (!vf->is_java_frame() || ((javaVFrame*) vf)->method()->is_native()) {
1530     return JVMTI_ERROR_OPAQUE_FRAME;
1531   }
1532 
1533   assert(vf->frame_pointer() != NULL, "frame pointer mustn't be NULL");
1534 



1535   int frame_number = state->count_frames() - depth;
1536   state->env_thread_state(this)->set_frame_pop(frame_number);
1537 
1538   return JVMTI_ERROR_NONE;




1539 } /* end NotifyFramePop */
1540 
1541 
1542   //
1543   // Force Early Return functions
1544   //
1545 
1546 // Threads_lock NOT held, java_thread not protected by lock
1547 // java_thread - pre-checked
1548 jvmtiError
1549 JvmtiEnv::ForceEarlyReturnObject(JavaThread* java_thread, jobject value) {
1550   jvalue val;
1551   val.l = value;
1552   return force_early_return(java_thread, val, atos);
1553 } /* end ForceEarlyReturnObject */
1554 
1555 
1556 // Threads_lock NOT held, java_thread not protected by lock
1557 // java_thread - pre-checked
1558 jvmtiError




1447       }
1448     }
1449 
1450     // If any of the top 2 frames is a compiled one, need to deoptimize it
1451     for (int i = 0; i < 2; i++) {
1452       if (!is_interpreted[i]) {
1453         Deoptimization::deoptimize_frame(java_thread, frame_sp[i]);
1454       }
1455     }
1456 
1457     // Update the thread state to reflect that the top frame is popped
1458     // so that cur_stack_depth is maintained properly and all frameIDs
1459     // are invalidated.
1460     // The current frame will be popped later when the suspended thread
1461     // is resumed and right before returning from VM to Java.
1462     // (see call_VM_base() in assembler_<cpu>.cpp).
1463 
1464     // It's fine to update the thread state here because no JVMTI events
1465     // shall be posted for this PopFrame.
1466 
1467     // It is only safe to perform the direct operation on the current
1468     // thread. All other usage needs to use a vm-safepoint-op for safety.
1469     if (java_thread == JavaThread::current()) {
1470       state->update_for_pop_top_frame();
1471     } else {
1472       VM_UpdateForPopTopFrame op(state);
1473       VMThread::execute(&op);
1474       jvmtiError err = op.result();
1475       if (err != JVMTI_ERROR_NONE) {
1476         return err;
1477       }
1478     }
1479 
1480     java_thread->set_popframe_condition(JavaThread::popframe_pending_bit);
1481     // Set pending step flag for this popframe and it is cleared when next
1482     // step event is posted.
1483     state->set_pending_step_for_popframe();
1484   }
1485 
1486   return JVMTI_ERROR_NONE;
1487 } /* end PopFrame */
1488 
1489 
1490 // Threads_lock NOT held, java_thread not protected by lock
1491 // java_thread - pre-checked
1492 // java_thread - unchecked
1493 // depth - pre-checked as non-negative
1494 // method_ptr - pre-checked for NULL
1495 // location_ptr - pre-checked for NULL
1496 jvmtiError
1497 JvmtiEnv::GetFrameLocation(JavaThread* java_thread, jint depth, jmethodID* method_ptr, jlocation* location_ptr) {
1498   jvmtiError err = JVMTI_ERROR_NONE;
1499 
1500   // It is only safe to perform the direct operation on the current
1501   // thread. All other usage needs to use a vm-safepoint-op for safety.
1502   if (java_thread == JavaThread::current()) {
1503     err = get_frame_location(java_thread, depth, method_ptr, location_ptr);
1504   } else {
1505     // JVMTI get java stack frame location at safepoint.
1506     VM_GetFrameLocation op(this, java_thread, depth, method_ptr, location_ptr);
1507     VMThread::execute(&op);
1508     err = op.result();
1509   }
1510   return err;
1511 } /* end GetFrameLocation */
1512 
1513 
1514 // Threads_lock NOT held, java_thread not protected by lock
1515 // java_thread - pre-checked
1516 // java_thread - unchecked
1517 // depth - pre-checked as non-negative
1518 jvmtiError
1519 JvmtiEnv::NotifyFramePop(JavaThread* java_thread, jint depth) {
1520   jvmtiError err = JVMTI_ERROR_NONE;
1521   ResourceMark rm;
1522   uint32_t debug_bits = 0;
1523 
1524   JvmtiThreadState *state = JvmtiThreadState::state_for(java_thread);
1525   if (state == NULL) {
1526     return JVMTI_ERROR_THREAD_NOT_ALIVE;
1527   }
1528 
1529   if (!JvmtiEnv::is_thread_fully_suspended(java_thread, true, &debug_bits)) {
1530       return JVMTI_ERROR_THREAD_NOT_SUSPENDED;
1531   }
1532 
1533   if (TraceJVMTICalls) {
1534     JvmtiSuspendControl::print();
1535   }
1536 
1537   vframe *vf = vframeFor(java_thread, depth);
1538   if (vf == NULL) {
1539     return JVMTI_ERROR_NO_MORE_FRAMES;
1540   }
1541 
1542   if (!vf->is_java_frame() || ((javaVFrame*) vf)->method()->is_native()) {
1543     return JVMTI_ERROR_OPAQUE_FRAME;
1544   }
1545 
1546   assert(vf->frame_pointer() != NULL, "frame pointer mustn't be NULL");
1547 
1548   // It is only safe to perform the direct operation on the current
1549   // thread. All other usage needs to use a vm-safepoint-op for safety.
1550   if (java_thread == JavaThread::current()) {
1551     int frame_number = state->count_frames() - depth;
1552     state->env_thread_state(this)->set_frame_pop(frame_number);
1553   } else {
1554     VM_SetFramePop op(this, state, depth);
1555     VMThread::execute(&op);
1556     err = op.result();
1557   }
1558   return err;
1559 } /* end NotifyFramePop */
1560 
1561 
1562   //
1563   // Force Early Return functions
1564   //
1565 
1566 // Threads_lock NOT held, java_thread not protected by lock
1567 // java_thread - pre-checked
1568 jvmtiError
1569 JvmtiEnv::ForceEarlyReturnObject(JavaThread* java_thread, jobject value) {
1570   jvalue val;
1571   val.l = value;
1572   return force_early_return(java_thread, val, atos);
1573 } /* end ForceEarlyReturnObject */
1574 
1575 
1576 // Threads_lock NOT held, java_thread not protected by lock
1577 // java_thread - pre-checked
1578 jvmtiError