src/share/vm/memory/referenceProcessor.hpp

Sun, 11 Oct 2009 16:19:25 -0700

author
jcoomes
date
Sun, 11 Oct 2009 16:19:25 -0700
changeset 1844
cff162798819
parent 1679
745c853ee57f
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6888953: some calls to function-like macros are missing semicolons
Reviewed-by: pbk, kvn

duke@435 1 /*
xdono@631 2 * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // ReferenceProcessor class encapsulates the per-"collector" processing
ysr@888 26 // of java.lang.Reference objects for GC. The interface is useful for supporting
duke@435 27 // a generational abstraction, in particular when there are multiple
duke@435 28 // generations that are being independently collected -- possibly
duke@435 29 // concurrently and/or incrementally. Note, however, that the
duke@435 30 // ReferenceProcessor class abstracts away from a generational setting
duke@435 31 // by using only a heap interval (called "span" below), thus allowing
duke@435 32 // its use in a straightforward manner in a general, non-generational
duke@435 33 // setting.
duke@435 34 //
duke@435 35 // The basic idea is that each ReferenceProcessor object concerns
duke@435 36 // itself with ("weak") reference processing in a specific "span"
duke@435 37 // of the heap of interest to a specific collector. Currently,
duke@435 38 // the span is a convex interval of the heap, but, efficiency
duke@435 39 // apart, there seems to be no reason it couldn't be extended
duke@435 40 // (with appropriate modifications) to any "non-convex interval".
duke@435 41
duke@435 42 // forward references
duke@435 43 class ReferencePolicy;
duke@435 44 class AbstractRefProcTaskExecutor;
duke@435 45 class DiscoveredList;
duke@435 46
duke@435 47 class ReferenceProcessor : public CHeapObj {
duke@435 48 protected:
duke@435 49 // End of list marker
duke@435 50 static oop _sentinelRef;
duke@435 51 MemRegion _span; // (right-open) interval of heap
duke@435 52 // subject to wkref discovery
duke@435 53 bool _discovering_refs; // true when discovery enabled
duke@435 54 bool _discovery_is_atomic; // if discovery is atomic wrt
duke@435 55 // other collectors in configuration
duke@435 56 bool _discovery_is_mt; // true if reference discovery is MT.
ysr@777 57 // If true, setting "next" field of a discovered refs list requires
ysr@777 58 // write barrier(s). (Must be true if used in a collector in which
ysr@777 59 // elements of a discovered list may be moved during discovery: for
ysr@777 60 // example, a collector like Garbage-First that moves objects during a
ysr@777 61 // long-term concurrent marking phase that does weak reference
ysr@777 62 // discovery.)
ysr@777 63 bool _discovered_list_needs_barrier;
ysr@777 64 BarrierSet* _bs; // Cached copy of BarrierSet.
duke@435 65 bool _enqueuing_is_done; // true if all weak references enqueued
duke@435 66 bool _processing_is_mt; // true during phases when
duke@435 67 // reference processing is MT.
duke@435 68 int _next_id; // round-robin counter in
duke@435 69 // support of work distribution
duke@435 70
duke@435 71 // For collectors that do not keep GC marking information
duke@435 72 // in the object header, this field holds a closure that
duke@435 73 // helps the reference processor determine the reachability
duke@435 74 // of an oop (the field is currently initialized to NULL for
duke@435 75 // all collectors but the CMS collector).
duke@435 76 BoolObjectClosure* _is_alive_non_header;
duke@435 77
ysr@888 78 // Soft ref clearing policies
ysr@888 79 // . the default policy
ysr@888 80 static ReferencePolicy* _default_soft_ref_policy;
ysr@888 81 // . the "clear all" policy
ysr@888 82 static ReferencePolicy* _always_clear_soft_ref_policy;
ysr@888 83 // . the current policy below is either one of the above
ysr@888 84 ReferencePolicy* _current_soft_ref_policy;
ysr@888 85
duke@435 86 // The discovered ref lists themselves
coleenp@548 87
coleenp@548 88 // The MT'ness degree of the queues below
coleenp@548 89 int _num_q;
coleenp@548 90 // Arrays of lists of oops, one per thread
coleenp@548 91 DiscoveredList* _discoveredSoftRefs;
duke@435 92 DiscoveredList* _discoveredWeakRefs;
duke@435 93 DiscoveredList* _discoveredFinalRefs;
duke@435 94 DiscoveredList* _discoveredPhantomRefs;
duke@435 95
duke@435 96 public:
coleenp@548 97 int num_q() { return _num_q; }
duke@435 98 DiscoveredList* discovered_soft_refs() { return _discoveredSoftRefs; }
coleenp@548 99 static oop sentinel_ref() { return _sentinelRef; }
coleenp@548 100 static oop* adr_sentinel_ref() { return &_sentinelRef; }
ysr@892 101 ReferencePolicy* setup_policy(bool always_clear) {
ysr@888 102 _current_soft_ref_policy = always_clear ?
ysr@888 103 _always_clear_soft_ref_policy : _default_soft_ref_policy;
ysr@892 104 _current_soft_ref_policy->setup(); // snapshot the policy threshold
ysr@888 105 return _current_soft_ref_policy;
ysr@888 106 }
duke@435 107
duke@435 108 public:
duke@435 109 // Process references with a certain reachability level.
duke@435 110 void process_discovered_reflist(DiscoveredList refs_lists[],
duke@435 111 ReferencePolicy* policy,
duke@435 112 bool clear_referent,
duke@435 113 BoolObjectClosure* is_alive,
duke@435 114 OopClosure* keep_alive,
duke@435 115 VoidClosure* complete_gc,
duke@435 116 AbstractRefProcTaskExecutor* task_executor);
duke@435 117
duke@435 118 void process_phaseJNI(BoolObjectClosure* is_alive,
duke@435 119 OopClosure* keep_alive,
duke@435 120 VoidClosure* complete_gc);
duke@435 121
duke@435 122 // Work methods used by the method process_discovered_reflist
duke@435 123 // Phase1: keep alive all those referents that are otherwise
duke@435 124 // dead but which must be kept alive by policy (and their closure).
coleenp@548 125 void process_phase1(DiscoveredList& refs_list,
duke@435 126 ReferencePolicy* policy,
duke@435 127 BoolObjectClosure* is_alive,
duke@435 128 OopClosure* keep_alive,
duke@435 129 VoidClosure* complete_gc);
duke@435 130 // Phase2: remove all those references whose referents are
duke@435 131 // reachable.
coleenp@548 132 inline void process_phase2(DiscoveredList& refs_list,
duke@435 133 BoolObjectClosure* is_alive,
duke@435 134 OopClosure* keep_alive,
duke@435 135 VoidClosure* complete_gc) {
duke@435 136 if (discovery_is_atomic()) {
duke@435 137 // complete_gc is ignored in this case for this phase
coleenp@548 138 pp2_work(refs_list, is_alive, keep_alive);
duke@435 139 } else {
duke@435 140 assert(complete_gc != NULL, "Error");
coleenp@548 141 pp2_work_concurrent_discovery(refs_list, is_alive,
duke@435 142 keep_alive, complete_gc);
duke@435 143 }
duke@435 144 }
duke@435 145 // Work methods in support of process_phase2
coleenp@548 146 void pp2_work(DiscoveredList& refs_list,
duke@435 147 BoolObjectClosure* is_alive,
duke@435 148 OopClosure* keep_alive);
duke@435 149 void pp2_work_concurrent_discovery(
coleenp@548 150 DiscoveredList& refs_list,
duke@435 151 BoolObjectClosure* is_alive,
duke@435 152 OopClosure* keep_alive,
duke@435 153 VoidClosure* complete_gc);
duke@435 154 // Phase3: process the referents by either clearing them
duke@435 155 // or keeping them alive (and their closure)
coleenp@548 156 void process_phase3(DiscoveredList& refs_list,
duke@435 157 bool clear_referent,
duke@435 158 BoolObjectClosure* is_alive,
duke@435 159 OopClosure* keep_alive,
duke@435 160 VoidClosure* complete_gc);
duke@435 161
duke@435 162 // Enqueue references with a certain reachability level
coleenp@548 163 void enqueue_discovered_reflist(DiscoveredList& refs_list, HeapWord* pending_list_addr);
duke@435 164
duke@435 165 // "Preclean" all the discovered reference lists
duke@435 166 // by removing references with strongly reachable referents.
duke@435 167 // The first argument is a predicate on an oop that indicates
duke@435 168 // its (strong) reachability and the second is a closure that
duke@435 169 // may be used to incrementalize or abort the precleaning process.
duke@435 170 // The caller is responsible for taking care of potential
duke@435 171 // interference with concurrent operations on these lists
duke@435 172 // (or predicates involved) by other threads. Currently
jmasa@1625 173 // only used by the CMS collector. should_unload_classes is
jmasa@1625 174 // used to aid assertion checking when classes are collected.
duke@435 175 void preclean_discovered_references(BoolObjectClosure* is_alive,
duke@435 176 OopClosure* keep_alive,
duke@435 177 VoidClosure* complete_gc,
jmasa@1625 178 YieldClosure* yield,
jmasa@1625 179 bool should_unload_classes);
duke@435 180
duke@435 181 // Delete entries in the discovered lists that have
duke@435 182 // either a null referent or are not active. Such
duke@435 183 // Reference objects can result from the clearing
duke@435 184 // or enqueueing of Reference objects concurrent
duke@435 185 // with their discovery by a (concurrent) collector.
duke@435 186 // For a definition of "active" see java.lang.ref.Reference;
duke@435 187 // Refs are born active, become inactive when enqueued,
duke@435 188 // and never become active again. The state of being
duke@435 189 // active is encoded as follows: A Ref is active
duke@435 190 // if and only if its "next" field is NULL.
duke@435 191 void clean_up_discovered_references();
duke@435 192 void clean_up_discovered_reflist(DiscoveredList& refs_list);
duke@435 193
duke@435 194 // Returns the name of the discovered reference list
duke@435 195 // occupying the i / _num_q slot.
duke@435 196 const char* list_name(int i);
duke@435 197
coleenp@548 198 void enqueue_discovered_reflists(HeapWord* pending_list_addr, AbstractRefProcTaskExecutor* task_executor);
coleenp@548 199
duke@435 200 protected:
duke@435 201 // "Preclean" the given discovered reference list
duke@435 202 // by removing references with strongly reachable referents.
duke@435 203 // Currently used in support of CMS only.
duke@435 204 void preclean_discovered_reflist(DiscoveredList& refs_list,
duke@435 205 BoolObjectClosure* is_alive,
duke@435 206 OopClosure* keep_alive,
duke@435 207 VoidClosure* complete_gc,
duke@435 208 YieldClosure* yield);
duke@435 209
duke@435 210 int next_id() {
duke@435 211 int id = _next_id;
duke@435 212 if (++_next_id == _num_q) {
duke@435 213 _next_id = 0;
duke@435 214 }
duke@435 215 return id;
duke@435 216 }
duke@435 217 DiscoveredList* get_discovered_list(ReferenceType rt);
duke@435 218 inline void add_to_discovered_list_mt(DiscoveredList& refs_list, oop obj,
coleenp@548 219 HeapWord* discovered_addr);
duke@435 220 void verify_ok_to_handle_reflists() PRODUCT_RETURN;
duke@435 221
duke@435 222 void abandon_partial_discovered_list(DiscoveredList& refs_list);
duke@435 223
duke@435 224 // Calculate the number of jni handles.
duke@435 225 unsigned int count_jni_refs();
duke@435 226
duke@435 227 // Balances reference queues.
duke@435 228 void balance_queues(DiscoveredList ref_lists[]);
duke@435 229
duke@435 230 // Update (advance) the soft ref master clock field.
duke@435 231 void update_soft_ref_master_clock();
duke@435 232
duke@435 233 public:
duke@435 234 // constructor
duke@435 235 ReferenceProcessor():
duke@435 236 _span((HeapWord*)NULL, (HeapWord*)NULL),
duke@435 237 _discoveredSoftRefs(NULL), _discoveredWeakRefs(NULL),
duke@435 238 _discoveredFinalRefs(NULL), _discoveredPhantomRefs(NULL),
duke@435 239 _discovering_refs(false),
duke@435 240 _discovery_is_atomic(true),
duke@435 241 _enqueuing_is_done(false),
duke@435 242 _discovery_is_mt(false),
ysr@777 243 _discovered_list_needs_barrier(false),
ysr@777 244 _bs(NULL),
duke@435 245 _is_alive_non_header(NULL),
duke@435 246 _num_q(0),
duke@435 247 _processing_is_mt(false),
duke@435 248 _next_id(0)
duke@435 249 {}
duke@435 250
duke@435 251 ReferenceProcessor(MemRegion span, bool atomic_discovery,
ysr@777 252 bool mt_discovery,
ysr@777 253 int mt_degree = 1,
ysr@777 254 bool mt_processing = false,
ysr@777 255 bool discovered_list_needs_barrier = false);
duke@435 256
duke@435 257 // Allocates and initializes a reference processor.
duke@435 258 static ReferenceProcessor* create_ref_processor(
duke@435 259 MemRegion span,
duke@435 260 bool atomic_discovery,
duke@435 261 bool mt_discovery,
duke@435 262 BoolObjectClosure* is_alive_non_header = NULL,
duke@435 263 int parallel_gc_threads = 1,
ysr@777 264 bool mt_processing = false,
ysr@777 265 bool discovered_list_needs_barrier = false);
johnc@1679 266
duke@435 267 // RefDiscoveryPolicy values
johnc@1679 268 enum DiscoveryPolicy {
duke@435 269 ReferenceBasedDiscovery = 0,
johnc@1679 270 ReferentBasedDiscovery = 1,
johnc@1679 271 DiscoveryPolicyMin = ReferenceBasedDiscovery,
johnc@1679 272 DiscoveryPolicyMax = ReferentBasedDiscovery
duke@435 273 };
duke@435 274
duke@435 275 static void init_statics();
duke@435 276
duke@435 277 public:
duke@435 278 // get and set "is_alive_non_header" field
duke@435 279 BoolObjectClosure* is_alive_non_header() {
duke@435 280 return _is_alive_non_header;
duke@435 281 }
duke@435 282 void set_is_alive_non_header(BoolObjectClosure* is_alive_non_header) {
duke@435 283 _is_alive_non_header = is_alive_non_header;
duke@435 284 }
duke@435 285
duke@435 286 // get and set span
duke@435 287 MemRegion span() { return _span; }
duke@435 288 void set_span(MemRegion span) { _span = span; }
duke@435 289
duke@435 290 // start and stop weak ref discovery
duke@435 291 void enable_discovery() { _discovering_refs = true; }
duke@435 292 void disable_discovery() { _discovering_refs = false; }
duke@435 293 bool discovery_enabled() { return _discovering_refs; }
duke@435 294
duke@435 295 // whether discovery is atomic wrt other collectors
duke@435 296 bool discovery_is_atomic() const { return _discovery_is_atomic; }
duke@435 297 void set_atomic_discovery(bool atomic) { _discovery_is_atomic = atomic; }
duke@435 298
duke@435 299 // whether discovery is done by multiple threads same-old-timeously
duke@435 300 bool discovery_is_mt() const { return _discovery_is_mt; }
duke@435 301 void set_mt_discovery(bool mt) { _discovery_is_mt = mt; }
duke@435 302
duke@435 303 // Whether we are in a phase when _processing_ is MT.
duke@435 304 bool processing_is_mt() const { return _processing_is_mt; }
duke@435 305 void set_mt_processing(bool mt) { _processing_is_mt = mt; }
duke@435 306
duke@435 307 // whether all enqueuing of weak references is complete
duke@435 308 bool enqueuing_is_done() { return _enqueuing_is_done; }
duke@435 309 void set_enqueuing_is_done(bool v) { _enqueuing_is_done = v; }
duke@435 310
duke@435 311 // iterate over oops
duke@435 312 void weak_oops_do(OopClosure* f); // weak roots
duke@435 313 static void oops_do(OopClosure* f); // strong root(s)
duke@435 314
duke@435 315 // Discover a Reference object, using appropriate discovery criteria
duke@435 316 bool discover_reference(oop obj, ReferenceType rt);
duke@435 317
duke@435 318 // Process references found during GC (called by the garbage collector)
ysr@888 319 void process_discovered_references(BoolObjectClosure* is_alive,
duke@435 320 OopClosure* keep_alive,
duke@435 321 VoidClosure* complete_gc,
duke@435 322 AbstractRefProcTaskExecutor* task_executor);
duke@435 323
duke@435 324 public:
duke@435 325 // Enqueue references at end of GC (called by the garbage collector)
duke@435 326 bool enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor = NULL);
duke@435 327
ysr@777 328 // If a discovery is in process that is being superceded, abandon it: all
ysr@777 329 // the discovered lists will be empty, and all the objects on them will
ysr@777 330 // have NULL discovered fields. Must be called only at a safepoint.
ysr@777 331 void abandon_partial_discovery();
ysr@777 332
duke@435 333 // debugging
duke@435 334 void verify_no_references_recorded() PRODUCT_RETURN;
duke@435 335 static void verify();
duke@435 336
duke@435 337 // clear the discovered lists (unlinking each entry).
duke@435 338 void clear_discovered_references() PRODUCT_RETURN;
duke@435 339 };
duke@435 340
duke@435 341 // A utility class to disable reference discovery in
duke@435 342 // the scope which contains it, for given ReferenceProcessor.
duke@435 343 class NoRefDiscovery: StackObj {
duke@435 344 private:
duke@435 345 ReferenceProcessor* _rp;
duke@435 346 bool _was_discovering_refs;
duke@435 347 public:
duke@435 348 NoRefDiscovery(ReferenceProcessor* rp) : _rp(rp) {
duke@435 349 if (_was_discovering_refs = _rp->discovery_enabled()) {
duke@435 350 _rp->disable_discovery();
duke@435 351 }
duke@435 352 }
duke@435 353
duke@435 354 ~NoRefDiscovery() {
duke@435 355 if (_was_discovering_refs) {
duke@435 356 _rp->enable_discovery();
duke@435 357 }
duke@435 358 }
duke@435 359 };
duke@435 360
duke@435 361
duke@435 362 // A utility class to temporarily mutate the span of the
duke@435 363 // given ReferenceProcessor in the scope that contains it.
duke@435 364 class ReferenceProcessorSpanMutator: StackObj {
duke@435 365 private:
duke@435 366 ReferenceProcessor* _rp;
duke@435 367 MemRegion _saved_span;
duke@435 368
duke@435 369 public:
duke@435 370 ReferenceProcessorSpanMutator(ReferenceProcessor* rp,
duke@435 371 MemRegion span):
duke@435 372 _rp(rp) {
duke@435 373 _saved_span = _rp->span();
duke@435 374 _rp->set_span(span);
duke@435 375 }
duke@435 376
duke@435 377 ~ReferenceProcessorSpanMutator() {
duke@435 378 _rp->set_span(_saved_span);
duke@435 379 }
duke@435 380 };
duke@435 381
duke@435 382 // A utility class to temporarily change the MT'ness of
duke@435 383 // reference discovery for the given ReferenceProcessor
duke@435 384 // in the scope that contains it.
duke@435 385 class ReferenceProcessorMTMutator: StackObj {
duke@435 386 private:
duke@435 387 ReferenceProcessor* _rp;
duke@435 388 bool _saved_mt;
duke@435 389
duke@435 390 public:
duke@435 391 ReferenceProcessorMTMutator(ReferenceProcessor* rp,
duke@435 392 bool mt):
duke@435 393 _rp(rp) {
duke@435 394 _saved_mt = _rp->discovery_is_mt();
duke@435 395 _rp->set_mt_discovery(mt);
duke@435 396 }
duke@435 397
duke@435 398 ~ReferenceProcessorMTMutator() {
duke@435 399 _rp->set_mt_discovery(_saved_mt);
duke@435 400 }
duke@435 401 };
duke@435 402
duke@435 403
duke@435 404 // A utility class to temporarily change the disposition
duke@435 405 // of the "is_alive_non_header" closure field of the
duke@435 406 // given ReferenceProcessor in the scope that contains it.
duke@435 407 class ReferenceProcessorIsAliveMutator: StackObj {
duke@435 408 private:
duke@435 409 ReferenceProcessor* _rp;
duke@435 410 BoolObjectClosure* _saved_cl;
duke@435 411
duke@435 412 public:
duke@435 413 ReferenceProcessorIsAliveMutator(ReferenceProcessor* rp,
duke@435 414 BoolObjectClosure* cl):
duke@435 415 _rp(rp) {
duke@435 416 _saved_cl = _rp->is_alive_non_header();
duke@435 417 _rp->set_is_alive_non_header(cl);
duke@435 418 }
duke@435 419
duke@435 420 ~ReferenceProcessorIsAliveMutator() {
duke@435 421 _rp->set_is_alive_non_header(_saved_cl);
duke@435 422 }
duke@435 423 };
duke@435 424
duke@435 425 // A utility class to temporarily change the disposition
duke@435 426 // of the "discovery_is_atomic" field of the
duke@435 427 // given ReferenceProcessor in the scope that contains it.
duke@435 428 class ReferenceProcessorAtomicMutator: StackObj {
duke@435 429 private:
duke@435 430 ReferenceProcessor* _rp;
duke@435 431 bool _saved_atomic_discovery;
duke@435 432
duke@435 433 public:
duke@435 434 ReferenceProcessorAtomicMutator(ReferenceProcessor* rp,
duke@435 435 bool atomic):
duke@435 436 _rp(rp) {
duke@435 437 _saved_atomic_discovery = _rp->discovery_is_atomic();
duke@435 438 _rp->set_atomic_discovery(atomic);
duke@435 439 }
duke@435 440
duke@435 441 ~ReferenceProcessorAtomicMutator() {
duke@435 442 _rp->set_atomic_discovery(_saved_atomic_discovery);
duke@435 443 }
duke@435 444 };
duke@435 445
duke@435 446
duke@435 447 // A utility class to temporarily change the MT processing
duke@435 448 // disposition of the given ReferenceProcessor instance
duke@435 449 // in the scope that contains it.
duke@435 450 class ReferenceProcessorMTProcMutator: StackObj {
duke@435 451 private:
duke@435 452 ReferenceProcessor* _rp;
duke@435 453 bool _saved_mt;
duke@435 454
duke@435 455 public:
duke@435 456 ReferenceProcessorMTProcMutator(ReferenceProcessor* rp,
duke@435 457 bool mt):
duke@435 458 _rp(rp) {
duke@435 459 _saved_mt = _rp->processing_is_mt();
duke@435 460 _rp->set_mt_processing(mt);
duke@435 461 }
duke@435 462
duke@435 463 ~ReferenceProcessorMTProcMutator() {
duke@435 464 _rp->set_mt_processing(_saved_mt);
duke@435 465 }
duke@435 466 };
duke@435 467
duke@435 468
duke@435 469 // This class is an interface used to implement task execution for the
duke@435 470 // reference processing.
duke@435 471 class AbstractRefProcTaskExecutor {
duke@435 472 public:
duke@435 473
duke@435 474 // Abstract tasks to execute.
duke@435 475 class ProcessTask;
duke@435 476 class EnqueueTask;
duke@435 477
duke@435 478 // Executes a task using worker threads.
duke@435 479 virtual void execute(ProcessTask& task) = 0;
duke@435 480 virtual void execute(EnqueueTask& task) = 0;
duke@435 481
duke@435 482 // Switch to single threaded mode.
duke@435 483 virtual void set_single_threaded_mode() { };
duke@435 484 };
duke@435 485
duke@435 486 // Abstract reference processing task to execute.
duke@435 487 class AbstractRefProcTaskExecutor::ProcessTask {
duke@435 488 protected:
duke@435 489 ProcessTask(ReferenceProcessor& ref_processor,
duke@435 490 DiscoveredList refs_lists[],
duke@435 491 bool marks_oops_alive)
duke@435 492 : _ref_processor(ref_processor),
duke@435 493 _refs_lists(refs_lists),
duke@435 494 _marks_oops_alive(marks_oops_alive)
duke@435 495 { }
duke@435 496
duke@435 497 public:
duke@435 498 virtual void work(unsigned int work_id, BoolObjectClosure& is_alive,
duke@435 499 OopClosure& keep_alive,
duke@435 500 VoidClosure& complete_gc) = 0;
duke@435 501
duke@435 502 // Returns true if a task marks some oops as alive.
duke@435 503 bool marks_oops_alive() const
duke@435 504 { return _marks_oops_alive; }
duke@435 505
duke@435 506 protected:
duke@435 507 ReferenceProcessor& _ref_processor;
duke@435 508 DiscoveredList* _refs_lists;
duke@435 509 const bool _marks_oops_alive;
duke@435 510 };
duke@435 511
duke@435 512 // Abstract reference processing task to execute.
duke@435 513 class AbstractRefProcTaskExecutor::EnqueueTask {
duke@435 514 protected:
duke@435 515 EnqueueTask(ReferenceProcessor& ref_processor,
duke@435 516 DiscoveredList refs_lists[],
coleenp@548 517 HeapWord* pending_list_addr,
duke@435 518 oop sentinel_ref,
duke@435 519 int n_queues)
duke@435 520 : _ref_processor(ref_processor),
duke@435 521 _refs_lists(refs_lists),
duke@435 522 _pending_list_addr(pending_list_addr),
duke@435 523 _sentinel_ref(sentinel_ref),
duke@435 524 _n_queues(n_queues)
duke@435 525 { }
duke@435 526
duke@435 527 public:
duke@435 528 virtual void work(unsigned int work_id) = 0;
duke@435 529
duke@435 530 protected:
duke@435 531 ReferenceProcessor& _ref_processor;
duke@435 532 DiscoveredList* _refs_lists;
coleenp@548 533 HeapWord* _pending_list_addr;
duke@435 534 oop _sentinel_ref;
duke@435 535 int _n_queues;
duke@435 536 };

mercurial