src/hotspot/share/runtime/vmThread.hpp
changeset 59325 3636bab5e81e
parent 55128 35192d9c2b76
equal deleted inserted replaced
59324:5e8f9713e343 59325:3636bab5e81e
    28 #include "runtime/perfData.hpp"
    28 #include "runtime/perfData.hpp"
    29 #include "runtime/thread.hpp"
    29 #include "runtime/thread.hpp"
    30 #include "runtime/task.hpp"
    30 #include "runtime/task.hpp"
    31 #include "runtime/vmOperations.hpp"
    31 #include "runtime/vmOperations.hpp"
    32 
    32 
       
    33 class VM_QueueHead : public VM_None {
       
    34  public:
       
    35   VM_QueueHead() : VM_None("QueueHead") {}
       
    36 };
       
    37 
    33 //
    38 //
    34 // Prioritized queue of VM operations.
    39 // Prioritized queue of VM operations.
    35 //
    40 //
    36 // Encapsulates both queue management and
    41 // Encapsulates both queue management and
    37 // and priority policy
    42 // and priority policy
    50   VM_Operation* _queue       [nof_priorities];
    55   VM_Operation* _queue       [nof_priorities];
    51   // we also allow the vmThread to register the ops it has drained so we
    56   // we also allow the vmThread to register the ops it has drained so we
    52   // can scan them from oops_do
    57   // can scan them from oops_do
    53   VM_Operation* _drain_list;
    58   VM_Operation* _drain_list;
    54 
    59 
       
    60   static VM_QueueHead _queue_head[nof_priorities];
       
    61 
    55   // Double-linked non-empty list insert.
    62   // Double-linked non-empty list insert.
    56   void insert(VM_Operation* q,VM_Operation* n);
    63   void insert(VM_Operation* q,VM_Operation* n);
    57   void unlink(VM_Operation* q);
    64   void unlink(VM_Operation* q);
    58 
    65 
    59   // Basic queue manipulation
    66   // Basic queue manipulation
    60   bool queue_empty                (int prio);
    67   bool queue_empty                (int prio);
    61   void queue_add_front            (int prio, VM_Operation *op);
    68   void queue_add                  (int prio, VM_Operation *op);
    62   void queue_add_back             (int prio, VM_Operation *op);
       
    63   VM_Operation* queue_remove_front(int prio);
    69   VM_Operation* queue_remove_front(int prio);
    64   void queue_oops_do(int queue, OopClosure* f);
    70   void queue_oops_do(int queue, OopClosure* f);
    65   void drain_list_oops_do(OopClosure* f);
    71   void drain_list_oops_do(OopClosure* f);
    66   VM_Operation* queue_drain(int prio);
    72   VM_Operation* queue_drain(int prio);
    67   // lock-free query: may return the wrong answer but must not break
    73   // lock-free query: may return the wrong answer but must not break
    71   VMOperationQueue();
    77   VMOperationQueue();
    72 
    78 
    73   // Highlevel operations. Encapsulates policy
    79   // Highlevel operations. Encapsulates policy
    74   void add(VM_Operation *op);
    80   void add(VM_Operation *op);
    75   VM_Operation* remove_next();                        // Returns next or null
    81   VM_Operation* remove_next();                        // Returns next or null
    76   VM_Operation* remove_next_at_safepoint_priority()   { return queue_remove_front(SafepointPriority); }
       
    77   VM_Operation* drain_at_safepoint_priority() { return queue_drain(SafepointPriority); }
    82   VM_Operation* drain_at_safepoint_priority() { return queue_drain(SafepointPriority); }
    78   void set_drain_list(VM_Operation* list) { _drain_list = list; }
    83   void set_drain_list(VM_Operation* list) { _drain_list = list; }
    79   bool peek_at_safepoint_priority() { return queue_peek(SafepointPriority); }
    84   bool peek_at_safepoint_priority() { return queue_peek(SafepointPriority); }
    80 
    85 
    81   // GC support
    86   // GC support
   137   }
   142   }
   138 
   143 
   139 
   144 
   140   // Tester
   145   // Tester
   141   bool is_VM_thread() const                      { return true; }
   146   bool is_VM_thread() const                      { return true; }
   142   bool is_GC_thread() const                      { return true; }
       
   143 
   147 
   144   // The ever running loop for the VMThread
   148   // The ever running loop for the VMThread
   145   void loop();
   149   void loop();
       
   150   static void check_for_forced_cleanup();
   146 
   151 
   147   // Called to stop the VM thread
   152   // Called to stop the VM thread
   148   static void wait_for_vm_thread_exit();
   153   static void wait_for_vm_thread_exit();
   149   static bool should_terminate()                  { return _should_terminate; }
   154   static bool should_terminate()                  { return _should_terminate; }
   150   static bool is_terminated()                     { return _terminated == true; }
   155   static bool is_terminated()                     { return _terminated == true; }