annotate src/share/vm/code/stubs.cpp @ 17524:89152779163c

Merge with jdk8-b132
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 11:59:32 +0200
parents 4ca6dc0799b6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17524
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14909
diff changeset
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1490
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1490
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1490
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
26 #include "code/codeBlob.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
27 #include "code/stubs.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
28 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
29 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
30 #include "runtime/mutexLocker.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Implementation of StubQueue
a61af66fc99e Initial load
duke
parents:
diff changeset
34 //
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // Standard wrap-around queue implementation; the queue dimensions
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // are specified by the _queue_begin & _queue_end indices. The queue
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // can be in two states (transparent to the outside):
a61af66fc99e Initial load
duke
parents:
diff changeset
38 //
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // a) contiguous state: all queue entries in one block (or empty)
a61af66fc99e Initial load
duke
parents:
diff changeset
40 //
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Queue: |...|XXXXXXX|...............|
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // ^0 ^begin ^end ^size = limit
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // |_______|
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // one block
a61af66fc99e Initial load
duke
parents:
diff changeset
45 //
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // b) non-contiguous state: queue entries in two blocks
a61af66fc99e Initial load
duke
parents:
diff changeset
47 //
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Queue: |XXX|.......|XXXXXXX|.......|
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // ^0 ^end ^begin ^limit ^size
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // |___| |_______|
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // 1st block 2nd block
a61af66fc99e Initial load
duke
parents:
diff changeset
52 //
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // In the non-contiguous state, the wrap-around point is
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // indicated via the _buffer_limit index since the last
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // queue entry may not fill up the queue completely in
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // which case we need to know where the 2nd block's end
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // is to do the proper wrap-around. When removing the
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // last entry of the 2nd block, _buffer_limit is reset
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // to _buffer_size.
a61af66fc99e Initial load
duke
parents:
diff changeset
60 //
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // CAUTION: DO NOT MESS WITH THIS CODE IF YOU CANNOT PROVE
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // ITS CORRECTNESS! THIS CODE IS MORE SUBTLE THAN IT LOOKS!
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 StubQueue::StubQueue(StubInterface* stub_interface, int buffer_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 Mutex* lock, const char* name) : _mutex(lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 intptr_t size = round_to(buffer_size, 2*BytesPerWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 BufferBlob* blob = BufferBlob::create(name, size);
1490
f03d0a26bf83 6888954: argument formatting for assert() and friends
jcoomes
parents: 0
diff changeset
69 if( blob == NULL) {
10161
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 8767
diff changeset
70 vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, err_msg("CodeCache: no room for %s", name));
1490
f03d0a26bf83 6888954: argument formatting for assert() and friends
jcoomes
parents: 0
diff changeset
71 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _stub_interface = stub_interface;
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1552
diff changeset
73 _buffer_size = blob->content_size();
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1552
diff changeset
74 _buffer_limit = blob->content_size();
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1552
diff changeset
75 _stub_buffer = blob->content_begin();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _queue_begin = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 _queue_end = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 _number_of_stubs = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 register_queue(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 StubQueue::~StubQueue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Note: Currently StubQueues are never destroyed so nothing needs to be done here.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // If we want to implement the destructor, we need to release the BufferBlob
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // allocated in the constructor (i.e., we need to keep it around or look it
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // up via CodeCache::find_blob(...).
a61af66fc99e Initial load
duke
parents:
diff changeset
88 Unimplemented();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 Stub* StubQueue::stub_containing(address pc) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (contains(pc)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 for (Stub* s = first(); s != NULL; s = next(s)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if (stub_contains(s, pc)) return s;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 Stub* StubQueue::request_committed(int code_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 Stub* s = request(code_size);
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6842
diff changeset
104 CodeStrings strings;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6842
diff changeset
105 if (s != NULL) commit(code_size, strings);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return s;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 Stub* StubQueue::request(int requested_code_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 assert(requested_code_size > 0, "requested_code_size must be > 0");
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (_mutex != NULL) _mutex->lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 Stub* s = current_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 int requested_size = round_to(stub_code_size_to_size(requested_code_size), CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if (requested_size <= available_space()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if (is_contiguous()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Queue: |...|XXXXXXX|.............|
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // ^0 ^begin ^end ^size = limit
a61af66fc99e Initial load
duke
parents:
diff changeset
119 assert(_buffer_limit == _buffer_size, "buffer must be fully usable");
a61af66fc99e Initial load
duke
parents:
diff changeset
120 if (_queue_end + requested_size <= _buffer_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // code fits in at the end => nothing to do
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6842
diff changeset
122 CodeStrings strings;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6842
diff changeset
123 stub_initialize(s, requested_size, strings);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
124 return s;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // stub doesn't fit in at the queue end
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // => reduce buffer limit & wrap around
a61af66fc99e Initial load
duke
parents:
diff changeset
128 assert(!is_empty(), "just checkin'");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 _buffer_limit = _queue_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 _queue_end = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 if (requested_size <= available_space()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 assert(!is_contiguous(), "just checkin'");
a61af66fc99e Initial load
duke
parents:
diff changeset
136 assert(_buffer_limit <= _buffer_size, "queue invariant broken");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // Queue: |XXX|.......|XXXXXXX|.......|
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // ^0 ^end ^begin ^limit ^size
a61af66fc99e Initial load
duke
parents:
diff changeset
139 s = current_stub();
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6842
diff changeset
140 CodeStrings strings;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6842
diff changeset
141 stub_initialize(s, requested_size, strings);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
142 return s;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Not enough space left
a61af66fc99e Initial load
duke
parents:
diff changeset
145 if (_mutex != NULL) _mutex->unlock();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6842
diff changeset
150 void StubQueue::commit(int committed_code_size, CodeStrings& strings) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
151 assert(committed_code_size > 0, "committed_code_size must be > 0");
a61af66fc99e Initial load
duke
parents:
diff changeset
152 int committed_size = round_to(stub_code_size_to_size(committed_code_size), CodeEntryAlignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 Stub* s = current_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
154 assert(committed_size <= stub_size(s), "committed size must not exceed requested size");
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6842
diff changeset
155 stub_initialize(s, committed_size, strings);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
156 _queue_end += committed_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 _number_of_stubs++;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 if (_mutex != NULL) _mutex->unlock();
a61af66fc99e Initial load
duke
parents:
diff changeset
159 debug_only(stub_verify(s);)
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void StubQueue::remove_first() {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 if (number_of_stubs() == 0) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 Stub* s = first();
a61af66fc99e Initial load
duke
parents:
diff changeset
166 debug_only(stub_verify(s);)
a61af66fc99e Initial load
duke
parents:
diff changeset
167 stub_finalize(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 _queue_begin += stub_size(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 assert(_queue_begin <= _buffer_limit, "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
170 if (_queue_begin == _queue_end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // buffer empty
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // => reset queue indices
a61af66fc99e Initial load
duke
parents:
diff changeset
173 _queue_begin = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 _queue_end = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 _buffer_limit = _buffer_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 } else if (_queue_begin == _buffer_limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // buffer limit reached
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // => reset buffer limit & wrap around
a61af66fc99e Initial load
duke
parents:
diff changeset
179 _buffer_limit = _buffer_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 _queue_begin = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 _number_of_stubs--;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 void StubQueue::remove_first(int n) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 int i = MIN2(n, number_of_stubs());
a61af66fc99e Initial load
duke
parents:
diff changeset
188 while (i-- > 0) remove_first();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 void StubQueue::remove_all(){
a61af66fc99e Initial load
duke
parents:
diff changeset
193 debug_only(verify();)
a61af66fc99e Initial load
duke
parents:
diff changeset
194 remove_first(number_of_stubs());
a61af66fc99e Initial load
duke
parents:
diff changeset
195 assert(number_of_stubs() == 0, "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 enum { StubQueueLimit = 10 }; // there are only a few in the world
a61af66fc99e Initial load
duke
parents:
diff changeset
200 static StubQueue* registered_stub_queues[StubQueueLimit];
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 void StubQueue::register_queue(StubQueue* sq) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 for (int i = 0; i < StubQueueLimit; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if (registered_stub_queues[i] == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 registered_stub_queues[i] = sq;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 void StubQueue::queues_do(void f(StubQueue* sq)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 for (int i = 0; i < StubQueueLimit; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (registered_stub_queues[i] != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 f(registered_stub_queues[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 void StubQueue::stubs_do(void f(Stub* s)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 debug_only(verify();)
a61af66fc99e Initial load
duke
parents:
diff changeset
224 MutexLockerEx lock(_mutex);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 for (Stub* s = first(); s != NULL; s = next(s)) f(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 void StubQueue::verify() {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // verify only if initialized
a61af66fc99e Initial load
duke
parents:
diff changeset
231 if (_stub_buffer == NULL) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 MutexLockerEx lock(_mutex);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // verify index boundaries
a61af66fc99e Initial load
duke
parents:
diff changeset
234 guarantee(0 <= _buffer_size, "buffer size must be positive");
a61af66fc99e Initial load
duke
parents:
diff changeset
235 guarantee(0 <= _buffer_limit && _buffer_limit <= _buffer_size , "_buffer_limit out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
236 guarantee(0 <= _queue_begin && _queue_begin < _buffer_limit, "_queue_begin out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
237 guarantee(0 <= _queue_end && _queue_end <= _buffer_limit, "_queue_end out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // verify alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
239 guarantee(_buffer_size % CodeEntryAlignment == 0, "_buffer_size not aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
240 guarantee(_buffer_limit % CodeEntryAlignment == 0, "_buffer_limit not aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
241 guarantee(_queue_begin % CodeEntryAlignment == 0, "_queue_begin not aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
242 guarantee(_queue_end % CodeEntryAlignment == 0, "_queue_end not aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // verify buffer limit/size relationship
a61af66fc99e Initial load
duke
parents:
diff changeset
244 if (is_contiguous()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 guarantee(_buffer_limit == _buffer_size, "_buffer_limit must equal _buffer_size");
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // verify contents
a61af66fc99e Initial load
duke
parents:
diff changeset
248 int n = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
249 for (Stub* s = first(); s != NULL; s = next(s)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 stub_verify(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 n++;
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253 guarantee(n == number_of_stubs(), "number of stubs inconsistent");
a61af66fc99e Initial load
duke
parents:
diff changeset
254 guarantee(_queue_begin != _queue_end || n == 0, "buffer indices must be the same");
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 void StubQueue::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 MutexLockerEx lock(_mutex);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 for (Stub* s = first(); s != NULL; s = next(s)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 stub_print(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }