src/share/vm/memory/referenceProcessor.hpp

Wed, 13 Jan 2010 15:26:39 -0800

author
ysr
date
Wed, 13 Jan 2010 15:26:39 -0800
changeset 1601
7b0e9cba0307
parent 892
27a80744a83b
child 1625
4788266644c1
permissions
-rw-r--r--

6896647: card marks can be deferred too long
Summary: Deferred card marks are now flushed during the gc prologue. Parallel[Scavege,OldGC] and SerialGC no longer defer card marks generated by COMPILER2 as a result of ReduceInitialCardMarks. For these cases, introduced a diagnostic option to defer the card marks, only for the purposes of testing and diagnostics. CMS and G1 continue to defer card marks. Potential performance concern related to single-threaded flushing of deferred card marks in the gc prologue will be addressed in the future.
Reviewed-by: never, johnc

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
duke@435 173 // only used by the CMS collector.
duke@435 174 void preclean_discovered_references(BoolObjectClosure* is_alive,
duke@435 175 OopClosure* keep_alive,
duke@435 176 VoidClosure* complete_gc,
duke@435 177 YieldClosure* yield);
duke@435 178
duke@435 179 // Delete entries in the discovered lists that have
duke@435 180 // either a null referent or are not active. Such
duke@435 181 // Reference objects can result from the clearing
duke@435 182 // or enqueueing of Reference objects concurrent
duke@435 183 // with their discovery by a (concurrent) collector.
duke@435 184 // For a definition of "active" see java.lang.ref.Reference;
duke@435 185 // Refs are born active, become inactive when enqueued,
duke@435 186 // and never become active again. The state of being
duke@435 187 // active is encoded as follows: A Ref is active
duke@435 188 // if and only if its "next" field is NULL.
duke@435 189 void clean_up_discovered_references();
duke@435 190 void clean_up_discovered_reflist(DiscoveredList& refs_list);
duke@435 191
duke@435 192 // Returns the name of the discovered reference list
duke@435 193 // occupying the i / _num_q slot.
duke@435 194 const char* list_name(int i);
duke@435 195
coleenp@548 196 void enqueue_discovered_reflists(HeapWord* pending_list_addr, AbstractRefProcTaskExecutor* task_executor);
coleenp@548 197
duke@435 198 protected:
duke@435 199 // "Preclean" the given discovered reference list
duke@435 200 // by removing references with strongly reachable referents.
duke@435 201 // Currently used in support of CMS only.
duke@435 202 void preclean_discovered_reflist(DiscoveredList& refs_list,
duke@435 203 BoolObjectClosure* is_alive,
duke@435 204 OopClosure* keep_alive,
duke@435 205 VoidClosure* complete_gc,
duke@435 206 YieldClosure* yield);
duke@435 207
duke@435 208 int next_id() {
duke@435 209 int id = _next_id;
duke@435 210 if (++_next_id == _num_q) {
duke@435 211 _next_id = 0;
duke@435 212 }
duke@435 213 return id;
duke@435 214 }
duke@435 215 DiscoveredList* get_discovered_list(ReferenceType rt);
duke@435 216 inline void add_to_discovered_list_mt(DiscoveredList& refs_list, oop obj,
coleenp@548 217 HeapWord* discovered_addr);
duke@435 218 void verify_ok_to_handle_reflists() PRODUCT_RETURN;
duke@435 219
duke@435 220 void abandon_partial_discovered_list(DiscoveredList& refs_list);
duke@435 221
duke@435 222 // Calculate the number of jni handles.
duke@435 223 unsigned int count_jni_refs();
duke@435 224
duke@435 225 // Balances reference queues.
duke@435 226 void balance_queues(DiscoveredList ref_lists[]);
duke@435 227
duke@435 228 // Update (advance) the soft ref master clock field.
duke@435 229 void update_soft_ref_master_clock();
duke@435 230
duke@435 231 public:
duke@435 232 // constructor
duke@435 233 ReferenceProcessor():
duke@435 234 _span((HeapWord*)NULL, (HeapWord*)NULL),
duke@435 235 _discoveredSoftRefs(NULL), _discoveredWeakRefs(NULL),
duke@435 236 _discoveredFinalRefs(NULL), _discoveredPhantomRefs(NULL),
duke@435 237 _discovering_refs(false),
duke@435 238 _discovery_is_atomic(true),
duke@435 239 _enqueuing_is_done(false),
duke@435 240 _discovery_is_mt(false),
ysr@777 241 _discovered_list_needs_barrier(false),
ysr@777 242 _bs(NULL),
duke@435 243 _is_alive_non_header(NULL),
duke@435 244 _num_q(0),
duke@435 245 _processing_is_mt(false),
duke@435 246 _next_id(0)
duke@435 247 {}
duke@435 248
duke@435 249 ReferenceProcessor(MemRegion span, bool atomic_discovery,
ysr@777 250 bool mt_discovery,
ysr@777 251 int mt_degree = 1,
ysr@777 252 bool mt_processing = false,
ysr@777 253 bool discovered_list_needs_barrier = false);
duke@435 254
duke@435 255 // Allocates and initializes a reference processor.
duke@435 256 static ReferenceProcessor* create_ref_processor(
duke@435 257 MemRegion span,
duke@435 258 bool atomic_discovery,
duke@435 259 bool mt_discovery,
duke@435 260 BoolObjectClosure* is_alive_non_header = NULL,
duke@435 261 int parallel_gc_threads = 1,
ysr@777 262 bool mt_processing = false,
ysr@777 263 bool discovered_list_needs_barrier = false);
duke@435 264 // RefDiscoveryPolicy values
duke@435 265 enum {
duke@435 266 ReferenceBasedDiscovery = 0,
duke@435 267 ReferentBasedDiscovery = 1
duke@435 268 };
duke@435 269
duke@435 270 static void init_statics();
duke@435 271
duke@435 272 public:
duke@435 273 // get and set "is_alive_non_header" field
duke@435 274 BoolObjectClosure* is_alive_non_header() {
duke@435 275 return _is_alive_non_header;
duke@435 276 }
duke@435 277 void set_is_alive_non_header(BoolObjectClosure* is_alive_non_header) {
duke@435 278 _is_alive_non_header = is_alive_non_header;
duke@435 279 }
duke@435 280
duke@435 281 // get and set span
duke@435 282 MemRegion span() { return _span; }
duke@435 283 void set_span(MemRegion span) { _span = span; }
duke@435 284
duke@435 285 // start and stop weak ref discovery
duke@435 286 void enable_discovery() { _discovering_refs = true; }
duke@435 287 void disable_discovery() { _discovering_refs = false; }
duke@435 288 bool discovery_enabled() { return _discovering_refs; }
duke@435 289
duke@435 290 // whether discovery is atomic wrt other collectors
duke@435 291 bool discovery_is_atomic() const { return _discovery_is_atomic; }
duke@435 292 void set_atomic_discovery(bool atomic) { _discovery_is_atomic = atomic; }
duke@435 293
duke@435 294 // whether discovery is done by multiple threads same-old-timeously
duke@435 295 bool discovery_is_mt() const { return _discovery_is_mt; }
duke@435 296 void set_mt_discovery(bool mt) { _discovery_is_mt = mt; }
duke@435 297
duke@435 298 // Whether we are in a phase when _processing_ is MT.
duke@435 299 bool processing_is_mt() const { return _processing_is_mt; }
duke@435 300 void set_mt_processing(bool mt) { _processing_is_mt = mt; }
duke@435 301
duke@435 302 // whether all enqueuing of weak references is complete
duke@435 303 bool enqueuing_is_done() { return _enqueuing_is_done; }
duke@435 304 void set_enqueuing_is_done(bool v) { _enqueuing_is_done = v; }
duke@435 305
duke@435 306 // iterate over oops
duke@435 307 void weak_oops_do(OopClosure* f); // weak roots
duke@435 308 static void oops_do(OopClosure* f); // strong root(s)
duke@435 309
duke@435 310 // Discover a Reference object, using appropriate discovery criteria
duke@435 311 bool discover_reference(oop obj, ReferenceType rt);
duke@435 312
duke@435 313 // Process references found during GC (called by the garbage collector)
ysr@888 314 void process_discovered_references(BoolObjectClosure* is_alive,
duke@435 315 OopClosure* keep_alive,
duke@435 316 VoidClosure* complete_gc,
duke@435 317 AbstractRefProcTaskExecutor* task_executor);
duke@435 318
duke@435 319 public:
duke@435 320 // Enqueue references at end of GC (called by the garbage collector)
duke@435 321 bool enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor = NULL);
duke@435 322
ysr@777 323 // If a discovery is in process that is being superceded, abandon it: all
ysr@777 324 // the discovered lists will be empty, and all the objects on them will
ysr@777 325 // have NULL discovered fields. Must be called only at a safepoint.
ysr@777 326 void abandon_partial_discovery();
ysr@777 327
duke@435 328 // debugging
duke@435 329 void verify_no_references_recorded() PRODUCT_RETURN;
duke@435 330 static void verify();
duke@435 331
duke@435 332 // clear the discovered lists (unlinking each entry).
duke@435 333 void clear_discovered_references() PRODUCT_RETURN;
duke@435 334 };
duke@435 335
duke@435 336 // A utility class to disable reference discovery in
duke@435 337 // the scope which contains it, for given ReferenceProcessor.
duke@435 338 class NoRefDiscovery: StackObj {
duke@435 339 private:
duke@435 340 ReferenceProcessor* _rp;
duke@435 341 bool _was_discovering_refs;
duke@435 342 public:
duke@435 343 NoRefDiscovery(ReferenceProcessor* rp) : _rp(rp) {
duke@435 344 if (_was_discovering_refs = _rp->discovery_enabled()) {
duke@435 345 _rp->disable_discovery();
duke@435 346 }
duke@435 347 }
duke@435 348
duke@435 349 ~NoRefDiscovery() {
duke@435 350 if (_was_discovering_refs) {
duke@435 351 _rp->enable_discovery();
duke@435 352 }
duke@435 353 }
duke@435 354 };
duke@435 355
duke@435 356
duke@435 357 // A utility class to temporarily mutate the span of the
duke@435 358 // given ReferenceProcessor in the scope that contains it.
duke@435 359 class ReferenceProcessorSpanMutator: StackObj {
duke@435 360 private:
duke@435 361 ReferenceProcessor* _rp;
duke@435 362 MemRegion _saved_span;
duke@435 363
duke@435 364 public:
duke@435 365 ReferenceProcessorSpanMutator(ReferenceProcessor* rp,
duke@435 366 MemRegion span):
duke@435 367 _rp(rp) {
duke@435 368 _saved_span = _rp->span();
duke@435 369 _rp->set_span(span);
duke@435 370 }
duke@435 371
duke@435 372 ~ReferenceProcessorSpanMutator() {
duke@435 373 _rp->set_span(_saved_span);
duke@435 374 }
duke@435 375 };
duke@435 376
duke@435 377 // A utility class to temporarily change the MT'ness of
duke@435 378 // reference discovery for the given ReferenceProcessor
duke@435 379 // in the scope that contains it.
duke@435 380 class ReferenceProcessorMTMutator: StackObj {
duke@435 381 private:
duke@435 382 ReferenceProcessor* _rp;
duke@435 383 bool _saved_mt;
duke@435 384
duke@435 385 public:
duke@435 386 ReferenceProcessorMTMutator(ReferenceProcessor* rp,
duke@435 387 bool mt):
duke@435 388 _rp(rp) {
duke@435 389 _saved_mt = _rp->discovery_is_mt();
duke@435 390 _rp->set_mt_discovery(mt);
duke@435 391 }
duke@435 392
duke@435 393 ~ReferenceProcessorMTMutator() {
duke@435 394 _rp->set_mt_discovery(_saved_mt);
duke@435 395 }
duke@435 396 };
duke@435 397
duke@435 398
duke@435 399 // A utility class to temporarily change the disposition
duke@435 400 // of the "is_alive_non_header" closure field of the
duke@435 401 // given ReferenceProcessor in the scope that contains it.
duke@435 402 class ReferenceProcessorIsAliveMutator: StackObj {
duke@435 403 private:
duke@435 404 ReferenceProcessor* _rp;
duke@435 405 BoolObjectClosure* _saved_cl;
duke@435 406
duke@435 407 public:
duke@435 408 ReferenceProcessorIsAliveMutator(ReferenceProcessor* rp,
duke@435 409 BoolObjectClosure* cl):
duke@435 410 _rp(rp) {
duke@435 411 _saved_cl = _rp->is_alive_non_header();
duke@435 412 _rp->set_is_alive_non_header(cl);
duke@435 413 }
duke@435 414
duke@435 415 ~ReferenceProcessorIsAliveMutator() {
duke@435 416 _rp->set_is_alive_non_header(_saved_cl);
duke@435 417 }
duke@435 418 };
duke@435 419
duke@435 420 // A utility class to temporarily change the disposition
duke@435 421 // of the "discovery_is_atomic" field of the
duke@435 422 // given ReferenceProcessor in the scope that contains it.
duke@435 423 class ReferenceProcessorAtomicMutator: StackObj {
duke@435 424 private:
duke@435 425 ReferenceProcessor* _rp;
duke@435 426 bool _saved_atomic_discovery;
duke@435 427
duke@435 428 public:
duke@435 429 ReferenceProcessorAtomicMutator(ReferenceProcessor* rp,
duke@435 430 bool atomic):
duke@435 431 _rp(rp) {
duke@435 432 _saved_atomic_discovery = _rp->discovery_is_atomic();
duke@435 433 _rp->set_atomic_discovery(atomic);
duke@435 434 }
duke@435 435
duke@435 436 ~ReferenceProcessorAtomicMutator() {
duke@435 437 _rp->set_atomic_discovery(_saved_atomic_discovery);
duke@435 438 }
duke@435 439 };
duke@435 440
duke@435 441
duke@435 442 // A utility class to temporarily change the MT processing
duke@435 443 // disposition of the given ReferenceProcessor instance
duke@435 444 // in the scope that contains it.
duke@435 445 class ReferenceProcessorMTProcMutator: StackObj {
duke@435 446 private:
duke@435 447 ReferenceProcessor* _rp;
duke@435 448 bool _saved_mt;
duke@435 449
duke@435 450 public:
duke@435 451 ReferenceProcessorMTProcMutator(ReferenceProcessor* rp,
duke@435 452 bool mt):
duke@435 453 _rp(rp) {
duke@435 454 _saved_mt = _rp->processing_is_mt();
duke@435 455 _rp->set_mt_processing(mt);
duke@435 456 }
duke@435 457
duke@435 458 ~ReferenceProcessorMTProcMutator() {
duke@435 459 _rp->set_mt_processing(_saved_mt);
duke@435 460 }
duke@435 461 };
duke@435 462
duke@435 463
duke@435 464 // This class is an interface used to implement task execution for the
duke@435 465 // reference processing.
duke@435 466 class AbstractRefProcTaskExecutor {
duke@435 467 public:
duke@435 468
duke@435 469 // Abstract tasks to execute.
duke@435 470 class ProcessTask;
duke@435 471 class EnqueueTask;
duke@435 472
duke@435 473 // Executes a task using worker threads.
duke@435 474 virtual void execute(ProcessTask& task) = 0;
duke@435 475 virtual void execute(EnqueueTask& task) = 0;
duke@435 476
duke@435 477 // Switch to single threaded mode.
duke@435 478 virtual void set_single_threaded_mode() { };
duke@435 479 };
duke@435 480
duke@435 481 // Abstract reference processing task to execute.
duke@435 482 class AbstractRefProcTaskExecutor::ProcessTask {
duke@435 483 protected:
duke@435 484 ProcessTask(ReferenceProcessor& ref_processor,
duke@435 485 DiscoveredList refs_lists[],
duke@435 486 bool marks_oops_alive)
duke@435 487 : _ref_processor(ref_processor),
duke@435 488 _refs_lists(refs_lists),
duke@435 489 _marks_oops_alive(marks_oops_alive)
duke@435 490 { }
duke@435 491
duke@435 492 public:
duke@435 493 virtual void work(unsigned int work_id, BoolObjectClosure& is_alive,
duke@435 494 OopClosure& keep_alive,
duke@435 495 VoidClosure& complete_gc) = 0;
duke@435 496
duke@435 497 // Returns true if a task marks some oops as alive.
duke@435 498 bool marks_oops_alive() const
duke@435 499 { return _marks_oops_alive; }
duke@435 500
duke@435 501 protected:
duke@435 502 ReferenceProcessor& _ref_processor;
duke@435 503 DiscoveredList* _refs_lists;
duke@435 504 const bool _marks_oops_alive;
duke@435 505 };
duke@435 506
duke@435 507 // Abstract reference processing task to execute.
duke@435 508 class AbstractRefProcTaskExecutor::EnqueueTask {
duke@435 509 protected:
duke@435 510 EnqueueTask(ReferenceProcessor& ref_processor,
duke@435 511 DiscoveredList refs_lists[],
coleenp@548 512 HeapWord* pending_list_addr,
duke@435 513 oop sentinel_ref,
duke@435 514 int n_queues)
duke@435 515 : _ref_processor(ref_processor),
duke@435 516 _refs_lists(refs_lists),
duke@435 517 _pending_list_addr(pending_list_addr),
duke@435 518 _sentinel_ref(sentinel_ref),
duke@435 519 _n_queues(n_queues)
duke@435 520 { }
duke@435 521
duke@435 522 public:
duke@435 523 virtual void work(unsigned int work_id) = 0;
duke@435 524
duke@435 525 protected:
duke@435 526 ReferenceProcessor& _ref_processor;
duke@435 527 DiscoveredList* _refs_lists;
coleenp@548 528 HeapWord* _pending_list_addr;
duke@435 529 oop _sentinel_ref;
duke@435 530 int _n_queues;
duke@435 531 };

mercurial