396 for (ZMarkStripe* victim_stripe = _stripes.stripe_next(stripe);
397 victim_stripe != stripe;
398 victim_stripe = _stripes.stripe_next(victim_stripe)) {
399 ZMarkStack* const stack = victim_stripe->steal_stack();
400 if (stack != NULL) {
401 // Success, install the stolen stack
402 stacks->install(&_stripes, stripe, stack);
403 return true;
404 }
405 }
406
407 // Nothing to steal
408 return false;
409 }
410
411 void ZMark::idle() const {
412 ZStatTimer timer(ZSubPhaseConcurrentMarkIdle);
413 os::naked_short_sleep(1);
414 }
415
416 class ZMarkFlushAndFreeStacksClosure : public ThreadClosure {
417 private:
418 ZMark* const _mark;
419 bool _flushed;
420
421 public:
422 ZMarkFlushAndFreeStacksClosure(ZMark* mark) :
423 _mark(mark),
424 _flushed(false) {}
425
426 void do_thread(Thread* thread) {
427 if (_mark->flush_and_free(thread)) {
428 _flushed = true;
429 }
430 }
431
432 bool flushed() const {
433 return _flushed;
434 }
435 };
436
437 bool ZMark::flush(bool at_safepoint) {
438 ZMarkFlushAndFreeStacksClosure cl(this);
439 if (at_safepoint) {
440 Threads::threads_do(&cl);
441 } else {
442 Handshake::execute(&cl);
|
396 for (ZMarkStripe* victim_stripe = _stripes.stripe_next(stripe);
397 victim_stripe != stripe;
398 victim_stripe = _stripes.stripe_next(victim_stripe)) {
399 ZMarkStack* const stack = victim_stripe->steal_stack();
400 if (stack != NULL) {
401 // Success, install the stolen stack
402 stacks->install(&_stripes, stripe, stack);
403 return true;
404 }
405 }
406
407 // Nothing to steal
408 return false;
409 }
410
411 void ZMark::idle() const {
412 ZStatTimer timer(ZSubPhaseConcurrentMarkIdle);
413 os::naked_short_sleep(1);
414 }
415
416 class ZMarkFlushAndFreeStacksClosure : public HandshakeClosure {
417 private:
418 ZMark* const _mark;
419 bool _flushed;
420
421 public:
422 ZMarkFlushAndFreeStacksClosure(ZMark* mark) :
423 HandshakeClosure("ZMarkFlushAndFreeStacks"),
424 _mark(mark),
425 _flushed(false) {}
426
427 void do_thread(Thread* thread) {
428 if (_mark->flush_and_free(thread)) {
429 _flushed = true;
430 }
431 }
432
433 bool flushed() const {
434 return _flushed;
435 }
436 };
437
438 bool ZMark::flush(bool at_safepoint) {
439 ZMarkFlushAndFreeStacksClosure cl(this);
440 if (at_safepoint) {
441 Threads::threads_do(&cl);
442 } else {
443 Handshake::execute(&cl);
|