1 /* |
1 /* |
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2011, 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. |
36 #endif |
36 #endif |
37 #ifdef TARGET_OS_FAMILY_windows |
37 #ifdef TARGET_OS_FAMILY_windows |
38 # include "thread_windows.inline.hpp" |
38 # include "thread_windows.inline.hpp" |
39 #endif |
39 #endif |
40 |
40 |
41 PtrQueue::PtrQueue(PtrQueueSet* qset_, bool perm, bool active) : |
41 PtrQueue::PtrQueue(PtrQueueSet* qset, bool perm, bool active) : |
42 _qset(qset_), _buf(NULL), _index(0), _active(active), |
42 _qset(qset), _buf(NULL), _index(0), _active(active), |
43 _perm(perm), _lock(NULL) |
43 _perm(perm), _lock(NULL) |
44 {} |
44 {} |
45 |
45 |
46 void PtrQueue::flush() { |
46 void PtrQueue::flush() { |
47 if (!_perm && _buf != NULL) { |
47 if (!_perm && _buf != NULL) { |
151 n--; |
151 n--; |
152 } |
152 } |
153 } |
153 } |
154 |
154 |
155 void PtrQueue::handle_zero_index() { |
155 void PtrQueue::handle_zero_index() { |
156 assert(0 == _index, "Precondition."); |
156 assert(_index == 0, "Precondition."); |
|
157 |
157 // This thread records the full buffer and allocates a new one (while |
158 // This thread records the full buffer and allocates a new one (while |
158 // holding the lock if there is one). |
159 // holding the lock if there is one). |
159 if (_buf != NULL) { |
160 if (_buf != NULL) { |
|
161 if (!should_enqueue_buffer()) { |
|
162 assert(_index > 0, "the buffer can only be re-used if it's not full"); |
|
163 return; |
|
164 } |
|
165 |
160 if (_lock) { |
166 if (_lock) { |
161 assert(_lock->owned_by_self(), "Required."); |
167 assert(_lock->owned_by_self(), "Required."); |
162 |
168 |
163 // The current PtrQ may be the shared dirty card queue and |
169 // The current PtrQ may be the shared dirty card queue and |
164 // may be being manipulated by more than one worker thread |
170 // may be being manipulated by more than one worker thread |