1.1 --- a/src/share/vm/utilities/workgroup.hpp Wed Jun 04 13:51:09 2008 -0700 1.2 +++ b/src/share/vm/utilities/workgroup.hpp Thu Jun 05 15:57:56 2008 -0700 1.3 @@ -72,7 +72,8 @@ 1.4 // Here's the public interface to this class. 1.5 public: 1.6 // Constructor and destructor. 1.7 - AbstractWorkGang(const char* name, bool are_GC_threads); 1.8 + AbstractWorkGang(const char* name, bool are_GC_task_threads, 1.9 + bool are_ConcurrentGC_threads); 1.10 ~AbstractWorkGang(); 1.11 // Run a task, returns when the task is done (or terminated). 1.12 virtual void run_task(AbstractGangTask* task) = 0; 1.13 @@ -83,7 +84,8 @@ 1.14 const char* name() const; 1.15 protected: 1.16 // Initialize only instance data. 1.17 - const bool _are_GC_threads; 1.18 + const bool _are_GC_task_threads; 1.19 + const bool _are_ConcurrentGC_threads; 1.20 // Printing support. 1.21 const char* _name; 1.22 // The monitor which protects these data, 1.23 @@ -130,8 +132,11 @@ 1.24 int finished_workers() const { 1.25 return _finished_workers; 1.26 } 1.27 - bool are_GC_threads() const { 1.28 - return _are_GC_threads; 1.29 + bool are_GC_task_threads() const { 1.30 + return _are_GC_task_threads; 1.31 + } 1.32 + bool are_ConcurrentGC_threads() const { 1.33 + return _are_ConcurrentGC_threads; 1.34 } 1.35 // Predicates. 1.36 bool is_idle() const { 1.37 @@ -190,7 +195,8 @@ 1.38 class WorkGang: public AbstractWorkGang { 1.39 public: 1.40 // Constructor 1.41 - WorkGang(const char* name, int workers, bool are_GC_threads); 1.42 + WorkGang(const char* name, int workers, 1.43 + bool are_GC_task_threads, bool are_ConcurrentGC_threads); 1.44 // Run a task, returns when the task is done (or terminated). 1.45 virtual void run_task(AbstractGangTask* task); 1.46 }; 1.47 @@ -206,6 +212,7 @@ 1.48 virtual void run(); 1.49 // Predicate for Thread 1.50 virtual bool is_GC_task_thread() const; 1.51 + virtual bool is_ConcurrentGC_thread() const; 1.52 // Printing 1.53 void print_on(outputStream* st) const; 1.54 virtual void print() const { print_on(tty); } 1.55 @@ -228,12 +235,17 @@ 1.56 Monitor _monitor; 1.57 int _n_workers; 1.58 int _n_completed; 1.59 + bool _should_reset; 1.60 1.61 - Monitor* monitor() { return &_monitor; } 1.62 - int n_workers() { return _n_workers; } 1.63 - int n_completed() { return _n_completed; } 1.64 + Monitor* monitor() { return &_monitor; } 1.65 + int n_workers() { return _n_workers; } 1.66 + int n_completed() { return _n_completed; } 1.67 + bool should_reset() { return _should_reset; } 1.68 1.69 - void inc_completed() { _n_completed++; } 1.70 + void zero_completed() { _n_completed = 0; } 1.71 + void inc_completed() { _n_completed++; } 1.72 + 1.73 + void set_should_reset(bool v) { _should_reset = v; } 1.74 1.75 public: 1.76 WorkGangBarrierSync(); 1.77 @@ -343,3 +355,42 @@ 1.78 // cleanup if necessary. 1.79 bool all_tasks_completed(); 1.80 }; 1.81 + 1.82 +// Represents a set of free small integer ids. 1.83 +class FreeIdSet { 1.84 + enum { 1.85 + end_of_list = -1, 1.86 + claimed = -2 1.87 + }; 1.88 + 1.89 + int _sz; 1.90 + Monitor* _mon; 1.91 + 1.92 + int* _ids; 1.93 + int _hd; 1.94 + int _waiters; 1.95 + int _claimed; 1.96 + 1.97 + static bool _safepoint; 1.98 + typedef FreeIdSet* FreeIdSetPtr; 1.99 + static const int NSets = 10; 1.100 + static FreeIdSetPtr _sets[NSets]; 1.101 + static bool _stat_init; 1.102 + int _index; 1.103 + 1.104 +public: 1.105 + FreeIdSet(int sz, Monitor* mon); 1.106 + ~FreeIdSet(); 1.107 + 1.108 + static void set_safepoint(bool b); 1.109 + 1.110 + // Attempt to claim the given id permanently. Returns "true" iff 1.111 + // successful. 1.112 + bool claim_perm_id(int i); 1.113 + 1.114 + // Returns an unclaimed parallel id (waiting for one to be released if 1.115 + // necessary). Returns "-1" if a GC wakes up a wait for an id. 1.116 + int claim_par_id(); 1.117 + 1.118 + void release_par_id(int id); 1.119 +};