comparison src/share/vm/utilities/workgroup.cpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents 487f09bf44e0
children
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
1 /* 1 /*
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "memory/allocation.hpp" 26 #include "memory/allocation.hpp"
27 #include "memory/allocation.inline.hpp" 27 #include "memory/allocation.inline.hpp"
28 #include "runtime/os.hpp" 28 #include "runtime/os.hpp"
29 #include "utilities/workgroup.hpp" 29 #include "utilities/workgroup.hpp"
30
31 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
30 32
31 // Definitions of WorkGang methods. 33 // Definitions of WorkGang methods.
32 34
33 AbstractWorkGang::AbstractWorkGang(const char* name, 35 AbstractWorkGang::AbstractWorkGang(const char* name,
34 bool are_GC_task_threads, 36 bool are_GC_task_threads,
374 376
375 // *** WorkGangBarrierSync 377 // *** WorkGangBarrierSync
376 378
377 WorkGangBarrierSync::WorkGangBarrierSync() 379 WorkGangBarrierSync::WorkGangBarrierSync()
378 : _monitor(Mutex::safepoint, "work gang barrier sync", true), 380 : _monitor(Mutex::safepoint, "work gang barrier sync", true),
379 _n_workers(0), _n_completed(0), _should_reset(false) { 381 _n_workers(0), _n_completed(0), _should_reset(false), _aborted(false) {
380 } 382 }
381 383
382 WorkGangBarrierSync::WorkGangBarrierSync(uint n_workers, const char* name) 384 WorkGangBarrierSync::WorkGangBarrierSync(uint n_workers, const char* name)
383 : _monitor(Mutex::safepoint, name, true), 385 : _monitor(Mutex::safepoint, name, true),
384 _n_workers(n_workers), _n_completed(0), _should_reset(false) { 386 _n_workers(n_workers), _n_completed(0), _should_reset(false), _aborted(false) {
385 } 387 }
386 388
387 void WorkGangBarrierSync::set_n_workers(uint n_workers) { 389 void WorkGangBarrierSync::set_n_workers(uint n_workers) {
388 _n_workers = n_workers; 390 _n_workers = n_workers;
389 _n_completed = 0; 391 _n_completed = 0;
390 _should_reset = false; 392 _should_reset = false;
391 } 393 _aborted = false;
392 394 }
393 void WorkGangBarrierSync::enter() { 395
396 bool WorkGangBarrierSync::enter() {
394 MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag); 397 MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag);
395 if (should_reset()) { 398 if (should_reset()) {
396 // The should_reset() was set and we are the first worker to enter 399 // The should_reset() was set and we are the first worker to enter
397 // the sync barrier. We will zero the n_completed() count which 400 // the sync barrier. We will zero the n_completed() count which
398 // effectively resets the barrier. 401 // effectively resets the barrier.
411 // should_reset() flag and the barrier will be reset the first 414 // should_reset() flag and the barrier will be reset the first
412 // time a worker enters it again. 415 // time a worker enters it again.
413 set_should_reset(true); 416 set_should_reset(true);
414 monitor()->notify_all(); 417 monitor()->notify_all();
415 } else { 418 } else {
416 while (n_completed() != n_workers()) { 419 while (n_completed() != n_workers() && !aborted()) {
417 monitor()->wait(/* no_safepoint_check */ true); 420 monitor()->wait(/* no_safepoint_check */ true);
418 } 421 }
419 } 422 }
423 return !aborted();
424 }
425
426 void WorkGangBarrierSync::abort() {
427 MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag);
428 set_aborted();
429 monitor()->notify_all();
420 } 430 }
421 431
422 // SubTasksDone functions. 432 // SubTasksDone functions.
423 433
424 SubTasksDone::SubTasksDone(uint n) : 434 SubTasksDone::SubTasksDone(uint n) :