21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/javaClasses.hpp"
27 #include "gc_implementation/g1/g1StringDedupQueue.hpp"
28 #include "memory/gcLocker.hpp"
29 #include "runtime/mutexLocker.hpp"
30 #include "utilities/stack.inline.hpp"
31
32 G1StringDedupQueue* G1StringDedupQueue::_queue = NULL;
33 const size_t G1StringDedupQueue::_max_size = 1000000; // Max number of elements per queue
34 const size_t G1StringDedupQueue::_max_cache_size = 0; // Max cache size per queue
35
36 G1StringDedupQueue::G1StringDedupQueue() :
37 _cursor(0),
38 _cancel(false),
39 _empty(true),
40 _dropped(0) {
41 _nqueues = MAX2(ParallelGCThreads, (size_t)1);
42 _queues = NEW_C_HEAP_ARRAY(G1StringDedupWorkerQueue, _nqueues, mtGC);
43 for (size_t i = 0; i < _nqueues; i++) {
44 new (_queues + i) G1StringDedupWorkerQueue(G1StringDedupWorkerQueue::default_segment_size(), _max_cache_size, _max_size);
45 }
46 }
47
48 G1StringDedupQueue::~G1StringDedupQueue() {
49 ShouldNotReachHere();
50 }
51
52 void G1StringDedupQueue::create() {
53 assert(_queue == NULL, "One string deduplication queue allowed");
54 _queue = new G1StringDedupQueue();
55 }
56
57 void G1StringDedupQueue::wait() {
58 MonitorLockerEx ml(StringDedupQueue_lock, Mutex::_no_safepoint_check_flag);
59 while (_queue->_empty && !_queue->_cancel) {
60 ml.wait(Mutex::_no_safepoint_check_flag);
61 }
|
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/javaClasses.hpp"
27 #include "gc_implementation/g1/g1StringDedupQueue.hpp"
28 #include "memory/gcLocker.hpp"
29 #include "runtime/mutexLocker.hpp"
30 #include "utilities/stack.inline.hpp"
31
32 G1StringDedupQueue* G1StringDedupQueue::_queue = NULL;
33 const size_t G1StringDedupQueue::_max_size = 1000000; // Max number of elements per queue
34 const size_t G1StringDedupQueue::_max_cache_size = 0; // Max cache size per queue
35
36 G1StringDedupQueue::G1StringDedupQueue() :
37 _cursor(0),
38 _cancel(false),
39 _empty(true),
40 _dropped(0) {
41 _nqueues = MAX2(ParallelGCThreads, (uintx)1);
42 _queues = NEW_C_HEAP_ARRAY(G1StringDedupWorkerQueue, _nqueues, mtGC);
43 for (size_t i = 0; i < _nqueues; i++) {
44 new (_queues + i) G1StringDedupWorkerQueue(G1StringDedupWorkerQueue::default_segment_size(), _max_cache_size, _max_size);
45 }
46 }
47
48 G1StringDedupQueue::~G1StringDedupQueue() {
49 ShouldNotReachHere();
50 }
51
52 void G1StringDedupQueue::create() {
53 assert(_queue == NULL, "One string deduplication queue allowed");
54 _queue = new G1StringDedupQueue();
55 }
56
57 void G1StringDedupQueue::wait() {
58 MonitorLockerEx ml(StringDedupQueue_lock, Mutex::_no_safepoint_check_flag);
59 while (_queue->_empty && !_queue->_cancel) {
60 ml.wait(Mutex::_no_safepoint_check_flag);
61 }
|