< prev index next >

src/hotspot/share/prims/jvmtiEnv.cpp

Print this page




1697     }
1698 
1699     // If any of the top 2 frames is a compiled one, need to deoptimize it
1700     for (int i = 0; i < 2; i++) {
1701       if (!is_interpreted[i]) {
1702         Deoptimization::deoptimize_frame(java_thread, frame_sp[i]);
1703       }
1704     }
1705 
1706     // Update the thread state to reflect that the top frame is popped
1707     // so that cur_stack_depth is maintained properly and all frameIDs
1708     // are invalidated.
1709     // The current frame will be popped later when the suspended thread
1710     // is resumed and right before returning from VM to Java.
1711     // (see call_VM_base() in assembler_<cpu>.cpp).
1712 
1713     // It's fine to update the thread state here because no JVMTI events
1714     // shall be posted for this PopFrame.
1715 
1716     // It is only safe to perform the direct operation on the current
1717     // thread. All other usage needs to use a vm-safepoint-op for safety.


1718     if (java_thread == JavaThread::current()) {
1719       state->update_for_pop_top_frame();
1720     } else {
1721       VM_UpdateForPopTopFrame op(state);
1722       VMThread::execute(&op);
1723       jvmtiError err = op.result();
1724       if (err != JVMTI_ERROR_NONE) {
1725         return err;
1726       }
1727     }

1728 
1729     java_thread->set_popframe_condition(JavaThread::popframe_pending_bit);
1730     // Set pending step flag for this popframe and it is cleared when next
1731     // step event is posted.
1732     state->set_pending_step_for_popframe();
1733   }
1734 
1735   return JVMTI_ERROR_NONE;
1736 } /* end PopFrame */
1737 
1738 
1739 // Threads_lock NOT held, java_thread not protected by lock
1740 // java_thread - pre-checked
1741 // java_thread - unchecked
1742 // depth - pre-checked as non-negative
1743 // method_ptr - pre-checked for NULL
1744 // location_ptr - pre-checked for NULL
1745 jvmtiError
1746 JvmtiEnv::GetFrameLocation(JavaThread* java_thread, jint depth, jmethodID* method_ptr, jlocation* location_ptr) {
1747   jvmtiError err = JVMTI_ERROR_NONE;


1779     return JVMTI_ERROR_THREAD_NOT_SUSPENDED;
1780   }
1781 
1782   if (TraceJVMTICalls) {
1783     JvmtiSuspendControl::print();
1784   }
1785 
1786   vframe *vf = vframeFor(java_thread, depth);
1787   if (vf == NULL) {
1788     return JVMTI_ERROR_NO_MORE_FRAMES;
1789   }
1790 
1791   if (!vf->is_java_frame() || ((javaVFrame*) vf)->method()->is_native()) {
1792     return JVMTI_ERROR_OPAQUE_FRAME;
1793   }
1794 
1795   assert(vf->frame_pointer() != NULL, "frame pointer mustn't be NULL");
1796 
1797   // It is only safe to perform the direct operation on the current
1798   // thread. All other usage needs to use a vm-safepoint-op for safety.

1799   if (java_thread == JavaThread::current()) {
1800     int frame_number = state->count_frames() - depth;
1801     state->env_thread_state(this)->set_frame_pop(frame_number);
1802   } else {
1803     VM_SetFramePop op(this, state, depth);
1804     VMThread::execute(&op);
1805     err = op.result();
1806   }
1807   return err;
1808 } /* end NotifyFramePop */
1809 
1810 
1811   //
1812   // Force Early Return functions
1813   //
1814 
1815 // Threads_lock NOT held, java_thread not protected by lock
1816 // java_thread - pre-checked
1817 jvmtiError
1818 JvmtiEnv::ForceEarlyReturnObject(JavaThread* java_thread, jobject value) {
1819   jvalue val;
1820   val.l = value;
1821   return force_early_return(java_thread, val, atos);
1822 } /* end ForceEarlyReturnObject */
1823 
1824 
1825 // Threads_lock NOT held, java_thread not protected by lock




1697     }
1698 
1699     // If any of the top 2 frames is a compiled one, need to deoptimize it
1700     for (int i = 0; i < 2; i++) {
1701       if (!is_interpreted[i]) {
1702         Deoptimization::deoptimize_frame(java_thread, frame_sp[i]);
1703       }
1704     }
1705 
1706     // Update the thread state to reflect that the top frame is popped
1707     // so that cur_stack_depth is maintained properly and all frameIDs
1708     // are invalidated.
1709     // The current frame will be popped later when the suspended thread
1710     // is resumed and right before returning from VM to Java.
1711     // (see call_VM_base() in assembler_<cpu>.cpp).
1712 
1713     // It's fine to update the thread state here because no JVMTI events
1714     // shall be posted for this PopFrame.
1715 
1716     // It is only safe to perform the direct operation on the current
1717     // thread. All other usage needs to use a handshake for safety.
1718     {
1719       MutexLocker mu(JvmtiThreadState_lock);
1720       if (java_thread == JavaThread::current()) {
1721         state->update_for_pop_top_frame();
1722       } else {
1723         UpdateForPopTopFrameClosure op(state);
1724         bool executed = Handshake::execute_direct(&op, java_thread);
1725         jvmtiError err = executed ? op.result() : JVMTI_ERROR_THREAD_NOT_ALIVE;
1726         if (err != JVMTI_ERROR_NONE) {
1727           return err;
1728         }
1729       }
1730     }
1731 
1732     java_thread->set_popframe_condition(JavaThread::popframe_pending_bit);
1733     // Set pending step flag for this popframe and it is cleared when next
1734     // step event is posted.
1735     state->set_pending_step_for_popframe();
1736   }
1737 
1738   return JVMTI_ERROR_NONE;
1739 } /* end PopFrame */
1740 
1741 
1742 // Threads_lock NOT held, java_thread not protected by lock
1743 // java_thread - pre-checked
1744 // java_thread - unchecked
1745 // depth - pre-checked as non-negative
1746 // method_ptr - pre-checked for NULL
1747 // location_ptr - pre-checked for NULL
1748 jvmtiError
1749 JvmtiEnv::GetFrameLocation(JavaThread* java_thread, jint depth, jmethodID* method_ptr, jlocation* location_ptr) {
1750   jvmtiError err = JVMTI_ERROR_NONE;


1782     return JVMTI_ERROR_THREAD_NOT_SUSPENDED;
1783   }
1784 
1785   if (TraceJVMTICalls) {
1786     JvmtiSuspendControl::print();
1787   }
1788 
1789   vframe *vf = vframeFor(java_thread, depth);
1790   if (vf == NULL) {
1791     return JVMTI_ERROR_NO_MORE_FRAMES;
1792   }
1793 
1794   if (!vf->is_java_frame() || ((javaVFrame*) vf)->method()->is_native()) {
1795     return JVMTI_ERROR_OPAQUE_FRAME;
1796   }
1797 
1798   assert(vf->frame_pointer() != NULL, "frame pointer mustn't be NULL");
1799 
1800   // It is only safe to perform the direct operation on the current
1801   // thread. All other usage needs to use a vm-safepoint-op for safety.
1802   MutexLocker mu(JvmtiThreadState_lock);
1803   if (java_thread == JavaThread::current()) {
1804     int frame_number = state->count_frames() - depth;
1805     state->env_thread_state(this)->set_frame_pop(frame_number);
1806   } else {
1807     SetFramePopClosure op(this, state, depth);
1808     bool executed = Handshake::execute_direct(&op, java_thread);
1809     err = executed ? op.result() : JVMTI_ERROR_THREAD_NOT_ALIVE;
1810   }
1811   return err;
1812 } /* end NotifyFramePop */
1813 
1814 
1815   //
1816   // Force Early Return functions
1817   //
1818 
1819 // Threads_lock NOT held, java_thread not protected by lock
1820 // java_thread - pre-checked
1821 jvmtiError
1822 JvmtiEnv::ForceEarlyReturnObject(JavaThread* java_thread, jobject value) {
1823   jvalue val;
1824   val.l = value;
1825   return force_early_return(java_thread, val, atos);
1826 } /* end ForceEarlyReturnObject */
1827 
1828 
1829 // Threads_lock NOT held, java_thread not protected by lock


< prev index next >