722 assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
723 return (WorkerThread*) this;
724 }
725
726 void set_id(uint work_id) { _id = work_id; }
727 uint id() const { return _id; }
728 };
729
730 // A single WatcherThread is used for simulating timer interrupts.
731 class WatcherThread: public Thread {
732 friend class VMStructs;
733 public:
734 virtual void run();
735
736 private:
737 static WatcherThread* _watcher_thread;
738
739 static bool _startable;
740 // volatile due to at least one lock-free read
741 volatile static bool _should_terminate;
742
743 os::WatcherThreadCrashProtection* _crash_protection;
744 public:
745 enum SomeConstants {
746 delay_interval = 10 // interrupt delay in milliseconds
747 };
748
749 // Constructor
750 WatcherThread();
751
752 // No destruction allowed
753 ~WatcherThread() {
754 guarantee(false, "WatcherThread deletion must fix the race with VM termination");
755 }
756
757 // Tester
758 bool is_Watcher_thread() const { return true; }
759
760 // Printing
761 char* name() const { return (char*)"VM Periodic Task Thread"; }
762 void print_on(outputStream* st) const;
763 void unpark();
764
765 // Returns the single instance of WatcherThread
766 static WatcherThread* watcher_thread() { return _watcher_thread; }
767
768 // Create and start the single instance of WatcherThread, or stop it on shutdown
769 static void start();
770 static void stop();
771 // Only allow start once the VM is sufficiently initialized
772 // Otherwise the first task to enroll will trigger the start
773 static void make_startable();
774
775 void set_crash_protection(os::WatcherThreadCrashProtection* crash_protection) {
776 assert(Thread::current()->is_Watcher_thread(), "Can only be set by WatcherThread");
777 _crash_protection = crash_protection;
778 }
779
780 bool has_crash_protection() const { return _crash_protection != NULL; }
781 os::WatcherThreadCrashProtection* crash_protection() const { return _crash_protection; }
782
783 private:
784 int sleep() const;
785 };
786
787
788 class CompilerThread;
789
790 typedef void (*ThreadFunction)(JavaThread*, TRAPS);
791
792 class JavaThread: public Thread {
793 friend class VMStructs;
794 friend class JVMCIVMStructs;
795 friend class WhiteBox;
796 private:
797 JavaThread* _next; // The next thread in the Threads list
798 oop _threadObj; // The Java level thread object
799
800 #ifdef ASSERT
801 private:
802 int _java_call_counter;
|
722 assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
723 return (WorkerThread*) this;
724 }
725
726 void set_id(uint work_id) { _id = work_id; }
727 uint id() const { return _id; }
728 };
729
730 // A single WatcherThread is used for simulating timer interrupts.
731 class WatcherThread: public Thread {
732 friend class VMStructs;
733 public:
734 virtual void run();
735
736 private:
737 static WatcherThread* _watcher_thread;
738
739 static bool _startable;
740 // volatile due to at least one lock-free read
741 volatile static bool _should_terminate;
742 public:
743 enum SomeConstants {
744 delay_interval = 10 // interrupt delay in milliseconds
745 };
746
747 // Constructor
748 WatcherThread();
749
750 // No destruction allowed
751 ~WatcherThread() {
752 guarantee(false, "WatcherThread deletion must fix the race with VM termination");
753 }
754
755 // Tester
756 bool is_Watcher_thread() const { return true; }
757
758 // Printing
759 char* name() const { return (char*)"VM Periodic Task Thread"; }
760 void print_on(outputStream* st) const;
761 void unpark();
762
763 // Returns the single instance of WatcherThread
764 static WatcherThread* watcher_thread() { return _watcher_thread; }
765
766 // Create and start the single instance of WatcherThread, or stop it on shutdown
767 static void start();
768 static void stop();
769 // Only allow start once the VM is sufficiently initialized
770 // Otherwise the first task to enroll will trigger the start
771 static void make_startable();
772 private:
773 int sleep() const;
774 };
775
776
777 class CompilerThread;
778
779 typedef void (*ThreadFunction)(JavaThread*, TRAPS);
780
781 class JavaThread: public Thread {
782 friend class VMStructs;
783 friend class JVMCIVMStructs;
784 friend class WhiteBox;
785 private:
786 JavaThread* _next; // The next thread in the Threads list
787 oop _threadObj; // The Java level thread object
788
789 #ifdef ASSERT
790 private:
791 int _java_call_counter;
|