Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/os.hpp @ 10405:f2110083203d
8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
author | sla |
---|---|
date | Mon, 10 Jun 2013 11:30:51 +0200 |
parents | c18152e0554e |
children | 836a62f43af9 a837fa3d3f86 |
comparison
equal
deleted
inserted
replaced
10404:d0add7016434 | 10405:f2110083203d |
---|---|
779 // Causes the VM to wait until an external stimulus has been applied | 779 // Causes the VM to wait until an external stimulus has been applied |
780 // (for Unix, that stimulus is a signal, for Windows, an external | 780 // (for Unix, that stimulus is a signal, for Windows, an external |
781 // ResumeThread call) | 781 // ResumeThread call) |
782 static void pause(); | 782 static void pause(); |
783 | 783 |
784 class SuspendedThreadTaskContext { | |
785 public: | |
786 SuspendedThreadTaskContext(Thread* thread, void *ucontext) : _thread(thread), _ucontext(ucontext) {} | |
787 Thread* thread() const { return _thread; } | |
788 void* ucontext() const { return _ucontext; } | |
789 private: | |
790 Thread* _thread; | |
791 void* _ucontext; | |
792 }; | |
793 | |
794 class SuspendedThreadTask { | |
795 public: | |
796 SuspendedThreadTask(Thread* thread) : _thread(thread), _done(false) {} | |
797 virtual ~SuspendedThreadTask() {} | |
798 void run(); | |
799 bool is_done() { return _done; } | |
800 virtual void do_task(const SuspendedThreadTaskContext& context) = 0; | |
801 protected: | |
802 private: | |
803 void internal_do_task(); | |
804 Thread* _thread; | |
805 bool _done; | |
806 }; | |
807 | |
808 #ifndef TARGET_OS_FAMILY_windows | |
809 // Suspend/resume support | |
810 // Protocol: | |
811 // | |
812 // a thread starts in SR_RUNNING | |
813 // | |
814 // SR_RUNNING can go to | |
815 // * SR_SUSPEND_REQUEST when the WatcherThread wants to suspend it | |
816 // SR_SUSPEND_REQUEST can go to | |
817 // * SR_RUNNING if WatcherThread decides it waited for SR_SUSPENDED too long (timeout) | |
818 // * SR_SUSPENDED if the stopped thread receives the signal and switches state | |
819 // SR_SUSPENDED can go to | |
820 // * SR_WAKEUP_REQUEST when the WatcherThread has done the work and wants to resume | |
821 // SR_WAKEUP_REQUEST can go to | |
822 // * SR_RUNNING when the stopped thread receives the signal | |
823 // * SR_WAKEUP_REQUEST on timeout (resend the signal and try again) | |
824 class SuspendResume { | |
825 public: | |
826 enum State { | |
827 SR_RUNNING, | |
828 SR_SUSPEND_REQUEST, | |
829 SR_SUSPENDED, | |
830 SR_WAKEUP_REQUEST | |
831 }; | |
832 | |
833 private: | |
834 volatile State _state; | |
835 | |
836 private: | |
837 /* try to switch state from state "from" to state "to" | |
838 * returns the state set after the method is complete | |
839 */ | |
840 State switch_state(State from, State to); | |
841 | |
842 public: | |
843 SuspendResume() : _state(SR_RUNNING) { } | |
844 | |
845 State state() const { return _state; } | |
846 | |
847 State request_suspend() { | |
848 return switch_state(SR_RUNNING, SR_SUSPEND_REQUEST); | |
849 } | |
850 | |
851 State cancel_suspend() { | |
852 return switch_state(SR_SUSPEND_REQUEST, SR_RUNNING); | |
853 } | |
854 | |
855 State suspended() { | |
856 return switch_state(SR_SUSPEND_REQUEST, SR_SUSPENDED); | |
857 } | |
858 | |
859 State request_wakeup() { | |
860 return switch_state(SR_SUSPENDED, SR_WAKEUP_REQUEST); | |
861 } | |
862 | |
863 State running() { | |
864 return switch_state(SR_WAKEUP_REQUEST, SR_RUNNING); | |
865 } | |
866 | |
867 bool is_running() const { | |
868 return _state == SR_RUNNING; | |
869 } | |
870 | |
871 bool is_suspend_request() const { | |
872 return _state == SR_SUSPEND_REQUEST; | |
873 } | |
874 | |
875 bool is_suspended() const { | |
876 return _state == SR_SUSPENDED; | |
877 } | |
878 }; | |
879 #endif | |
880 | |
881 | |
784 protected: | 882 protected: |
785 static long _rand_seed; // seed for random number generator | 883 static long _rand_seed; // seed for random number generator |
786 static int _processor_count; // number of processors | 884 static int _processor_count; // number of processors |
787 | 885 |
788 static char* format_boot_path(const char* format_string, | 886 static char* format_boot_path(const char* format_string, |