comparison src/share/vm/gc_implementation/g1/ptrQueue.cpp @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents 63a4eb8bcd23
children 89152779163c
comparison
equal deleted inserted replaced
14908:8db6e76cb658 14909:4ca6dc0799b6
1 /* 1 /*
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2012, 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.
69 69
70 void PtrQueue::locking_enqueue_completed_buffer(void** buf) { 70 void PtrQueue::locking_enqueue_completed_buffer(void** buf) {
71 assert(_lock->owned_by_self(), "Required."); 71 assert(_lock->owned_by_self(), "Required.");
72 72
73 // We have to unlock _lock (which may be Shared_DirtyCardQ_lock) before 73 // We have to unlock _lock (which may be Shared_DirtyCardQ_lock) before
74 // we acquire DirtyCardQ_CBL_mon inside enqueue_complete_buffer as they 74 // we acquire DirtyCardQ_CBL_mon inside enqeue_complete_buffer as they
75 // have the same rank and we may get the "possible deadlock" message 75 // have the same rank and we may get the "possible deadlock" message
76 _lock->unlock(); 76 _lock->unlock();
77 77
78 qset()->enqueue_complete_buffer(buf); 78 qset()->enqueue_complete_buffer(buf);
79 // We must relock only because the caller will unlock, for the normal 79 // We must relock only because the caller will unlock, for the normal
149 if (_lock) { 149 if (_lock) {
150 assert(_lock->owned_by_self(), "Required."); 150 assert(_lock->owned_by_self(), "Required.");
151 151
152 // The current PtrQ may be the shared dirty card queue and 152 // The current PtrQ may be the shared dirty card queue and
153 // may be being manipulated by more than one worker thread 153 // may be being manipulated by more than one worker thread
154 // during a pause. Since the enqueueing of the completed 154 // during a pause. Since the enqueuing of the completed
155 // buffer unlocks the Shared_DirtyCardQ_lock more than one 155 // buffer unlocks the Shared_DirtyCardQ_lock more than one
156 // worker thread can 'race' on reading the shared queue attributes 156 // worker thread can 'race' on reading the shared queue attributes
157 // (_buf and _index) and multiple threads can call into this 157 // (_buf and _index) and multiple threads can call into this
158 // routine for the same buffer. This will cause the completed 158 // routine for the same buffer. This will cause the completed
159 // buffer to be added to the CBL multiple times. 159 // buffer to be added to the CBL multiple times.
168 void** buf = _buf; // local pointer to completed buffer 168 void** buf = _buf; // local pointer to completed buffer
169 _buf = NULL; // clear shared _buf field 169 _buf = NULL; // clear shared _buf field
170 170
171 locking_enqueue_completed_buffer(buf); // enqueue completed buffer 171 locking_enqueue_completed_buffer(buf); // enqueue completed buffer
172 172
173 // While the current thread was enqueueing the buffer another thread 173 // While the current thread was enqueuing the buffer another thread
174 // may have a allocated a new buffer and inserted it into this pointer 174 // may have a allocated a new buffer and inserted it into this pointer
175 // queue. If that happens then we just return so that the current 175 // queue. If that happens then we just return so that the current
176 // thread doesn't overwrite the buffer allocated by the other thread 176 // thread doesn't overwrite the buffer allocated by the other thread
177 // and potentially losing some dirtied cards. 177 // and potentially losing some dirtied cards.
178 178