Mercurial > hg > graal-compiler
annotate src/share/vm/code/codeBlob.cpp @ 1722:effb55808a18
Merge
author | johnc |
---|---|
date | Wed, 18 Aug 2010 17:44:33 -0400 |
parents | 126ea7725993 |
children | 3e8fbc61cee8 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1299
diff
changeset
|
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1299
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1299
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:
1299
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_codeBlob.cpp.incl" | |
27 | |
28 unsigned int align_code_offset(int offset) { | |
29 // align the size to CodeEntryAlignment | |
30 return | |
31 ((offset + (int)CodeHeap::header_size() + (CodeEntryAlignment-1)) & ~(CodeEntryAlignment-1)) | |
32 - (int)CodeHeap::header_size(); | |
33 } | |
34 | |
35 | |
36 // This must be consistent with the CodeBlob constructor's layout actions. | |
37 unsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) { | |
38 unsigned int size = header_size; | |
39 size += round_to(cb->total_relocation_size(), oopSize); | |
40 // align the size to CodeEntryAlignment | |
41 size = align_code_offset(size); | |
42 size += round_to(cb->total_code_size(), oopSize); | |
43 size += round_to(cb->total_oop_size(), oopSize); | |
44 return size; | |
45 } | |
46 | |
47 | |
48 // Creates a simple CodeBlob. Sets up the size of the different regions. | |
49 CodeBlob::CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size) { | |
50 assert(size == round_to(size, oopSize), "unaligned size"); | |
51 assert(locs_size == round_to(locs_size, oopSize), "unaligned size"); | |
52 assert(header_size == round_to(header_size, oopSize), "unaligned size"); | |
53 assert(!UseRelocIndex, "no space allocated for reloc index yet"); | |
54 | |
55 // Note: If UseRelocIndex is enabled, there needs to be (at least) one | |
56 // extra word for the relocation information, containing the reloc | |
57 // index table length. Unfortunately, the reloc index table imple- | |
58 // mentation is not easily understandable and thus it is not clear | |
59 // what exactly the format is supposed to be. For now, we just turn | |
60 // off the use of this table (gri 7/6/2000). | |
61 | |
62 _name = name; | |
63 _size = size; | |
64 _frame_complete_offset = frame_complete; | |
65 _header_size = header_size; | |
66 _relocation_size = locs_size; | |
67 _instructions_offset = align_code_offset(header_size + locs_size); | |
68 _data_offset = size; | |
69 _frame_size = 0; | |
70 set_oop_maps(NULL); | |
71 } | |
72 | |
73 | |
74 // Creates a CodeBlob from a CodeBuffer. Sets up the size of the different regions, | |
75 // and copy code and relocation info. | |
76 CodeBlob::CodeBlob( | |
77 const char* name, | |
78 CodeBuffer* cb, | |
79 int header_size, | |
80 int size, | |
81 int frame_complete, | |
82 int frame_size, | |
83 OopMapSet* oop_maps | |
84 ) { | |
85 assert(size == round_to(size, oopSize), "unaligned size"); | |
86 assert(header_size == round_to(header_size, oopSize), "unaligned size"); | |
87 | |
88 _name = name; | |
89 _size = size; | |
90 _frame_complete_offset = frame_complete; | |
91 _header_size = header_size; | |
92 _relocation_size = round_to(cb->total_relocation_size(), oopSize); | |
93 _instructions_offset = align_code_offset(header_size + _relocation_size); | |
94 _data_offset = _instructions_offset + round_to(cb->total_code_size(), oopSize); | |
95 assert(_data_offset <= size, "codeBlob is too small"); | |
96 | |
97 cb->copy_code_and_locs_to(this); | |
98 set_oop_maps(oop_maps); | |
99 _frame_size = frame_size; | |
100 #ifdef COMPILER1 | |
101 // probably wrong for tiered | |
102 assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs"); | |
103 #endif // COMPILER1 | |
104 } | |
105 | |
106 | |
107 void CodeBlob::set_oop_maps(OopMapSet* p) { | |
108 // Danger Will Robinson! This method allocates a big | |
109 // chunk of memory, its your job to free it. | |
110 if (p != NULL) { | |
111 // We need to allocate a chunk big enough to hold the OopMapSet and all of its OopMaps | |
112 _oop_maps = (OopMapSet* )NEW_C_HEAP_ARRAY(unsigned char, p->heap_size()); | |
113 p->copy_to((address)_oop_maps); | |
114 } else { | |
115 _oop_maps = NULL; | |
116 } | |
117 } | |
118 | |
119 | |
120 void CodeBlob::flush() { | |
121 if (_oop_maps) { | |
122 FREE_C_HEAP_ARRAY(unsigned char, _oop_maps); | |
123 _oop_maps = NULL; | |
124 } | |
125 _comments.free(); | |
126 } | |
127 | |
128 | |
129 OopMap* CodeBlob::oop_map_for_return_address(address return_address) { | |
130 address pc = return_address ; | |
131 assert (oop_maps() != NULL, "nope"); | |
132 return oop_maps()->find_map_at_offset ((intptr_t) pc - (intptr_t) instructions_begin()); | |
133 } | |
134 | |
135 | |
136 //---------------------------------------------------------------------------------------------------- | |
137 // Implementation of BufferBlob | |
138 | |
139 | |
140 BufferBlob::BufferBlob(const char* name, int size) | |
141 : CodeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0) | |
142 {} | |
143 | |
144 BufferBlob* BufferBlob::create(const char* name, int buffer_size) { | |
145 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock | |
146 | |
147 BufferBlob* blob = NULL; | |
148 unsigned int size = sizeof(BufferBlob); | |
149 // align the size to CodeEntryAlignment | |
150 size = align_code_offset(size); | |
151 size += round_to(buffer_size, oopSize); | |
152 assert(name != NULL, "must provide a name"); | |
153 { | |
154 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
155 blob = new (size) BufferBlob(name, size); | |
156 } | |
157 // Track memory usage statistic after releasing CodeCache_lock | |
158 MemoryService::track_code_cache_memory_usage(); | |
159 | |
160 return blob; | |
161 } | |
162 | |
163 | |
164 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb) | |
165 : CodeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL) | |
166 {} | |
167 | |
168 BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) { | |
169 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock | |
170 | |
171 BufferBlob* blob = NULL; | |
172 unsigned int size = allocation_size(cb, sizeof(BufferBlob)); | |
173 assert(name != NULL, "must provide a name"); | |
174 { | |
175 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
176 blob = new (size) BufferBlob(name, size, cb); | |
177 } | |
178 // Track memory usage statistic after releasing CodeCache_lock | |
179 MemoryService::track_code_cache_memory_usage(); | |
180 | |
181 return blob; | |
182 } | |
183 | |
184 | |
185 void* BufferBlob::operator new(size_t s, unsigned size) { | |
186 void* p = CodeCache::allocate(size); | |
187 return p; | |
188 } | |
189 | |
190 | |
191 void BufferBlob::free( BufferBlob *blob ) { | |
192 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock | |
193 { | |
194 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
195 CodeCache::free((CodeBlob*)blob); | |
196 } | |
197 // Track memory usage statistic after releasing CodeCache_lock | |
198 MemoryService::track_code_cache_memory_usage(); | |
199 } | |
200 | |
1299
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
201 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
202 //---------------------------------------------------------------------------------------------------- |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
203 // Implementation of AdapterBlob |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
204 |
1663 | 205 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) : |
206 BufferBlob("I2C/C2I adapters", size, cb) { | |
207 CodeCache::commit(this); | |
208 } | |
209 | |
1299
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
210 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) { |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
211 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
212 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
213 AdapterBlob* blob = NULL; |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
214 unsigned int size = allocation_size(cb, sizeof(AdapterBlob)); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
215 { |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
216 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
217 blob = new (size) AdapterBlob(size, cb); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
218 } |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
219 // Track memory usage statistic after releasing CodeCache_lock |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
220 MemoryService::track_code_cache_memory_usage(); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
221 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
222 return blob; |
0 | 223 } |
224 | |
1299
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
225 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
226 //---------------------------------------------------------------------------------------------------- |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
227 // Implementation of MethodHandlesAdapterBlob |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
228 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
229 MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) { |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
230 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
231 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
232 MethodHandlesAdapterBlob* blob = NULL; |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
233 unsigned int size = sizeof(MethodHandlesAdapterBlob); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
234 // align the size to CodeEntryAlignment |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
235 size = align_code_offset(size); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
236 size += round_to(buffer_size, oopSize); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
237 { |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
238 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
239 blob = new (size) MethodHandlesAdapterBlob(size); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
240 } |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
241 // Track memory usage statistic after releasing CodeCache_lock |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
242 MemoryService::track_code_cache_memory_usage(); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
243 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
244 return blob; |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
245 } |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
246 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
0
diff
changeset
|
247 |
0 | 248 //---------------------------------------------------------------------------------------------------- |
249 // Implementation of RuntimeStub | |
250 | |
251 RuntimeStub::RuntimeStub( | |
252 const char* name, | |
253 CodeBuffer* cb, | |
254 int size, | |
255 int frame_complete, | |
256 int frame_size, | |
257 OopMapSet* oop_maps, | |
258 bool caller_must_gc_arguments | |
259 ) | |
260 : CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps) | |
261 { | |
262 _caller_must_gc_arguments = caller_must_gc_arguments; | |
263 } | |
264 | |
265 | |
266 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name, | |
267 CodeBuffer* cb, | |
268 int frame_complete, | |
269 int frame_size, | |
270 OopMapSet* oop_maps, | |
271 bool caller_must_gc_arguments) | |
272 { | |
273 RuntimeStub* stub = NULL; | |
274 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock | |
275 { | |
276 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
277 unsigned int size = allocation_size(cb, sizeof(RuntimeStub)); | |
278 stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments); | |
279 } | |
280 | |
281 // Do not hold the CodeCache lock during name formatting. | |
282 if (stub != NULL) { | |
283 char stub_id[256]; | |
284 jio_snprintf(stub_id, sizeof(stub_id), "RuntimeStub - %s", stub_name); | |
285 if (PrintStubCode) { | |
286 tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, stub); | |
287 Disassembler::decode(stub->instructions_begin(), stub->instructions_end()); | |
288 } | |
289 Forte::register_stub(stub_id, stub->instructions_begin(), stub->instructions_end()); | |
290 | |
291 if (JvmtiExport::should_post_dynamic_code_generated()) { | |
292 JvmtiExport::post_dynamic_code_generated(stub_name, stub->instructions_begin(), stub->instructions_end()); | |
293 } | |
294 } | |
295 | |
296 // Track memory usage statistic after releasing CodeCache_lock | |
297 MemoryService::track_code_cache_memory_usage(); | |
298 | |
299 return stub; | |
300 } | |
301 | |
302 | |
303 void* RuntimeStub::operator new(size_t s, unsigned size) { | |
304 void* p = CodeCache::allocate(size); | |
305 if (!p) fatal("Initial size of CodeCache is too small"); | |
306 return p; | |
307 } | |
308 | |
309 | |
310 //---------------------------------------------------------------------------------------------------- | |
311 // Implementation of DeoptimizationBlob | |
312 | |
313 DeoptimizationBlob::DeoptimizationBlob( | |
314 CodeBuffer* cb, | |
315 int size, | |
316 OopMapSet* oop_maps, | |
317 int unpack_offset, | |
318 int unpack_with_exception_offset, | |
319 int unpack_with_reexecution_offset, | |
320 int frame_size | |
321 ) | |
322 : SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps) | |
323 { | |
324 _unpack_offset = unpack_offset; | |
325 _unpack_with_exception = unpack_with_exception_offset; | |
326 _unpack_with_reexecution = unpack_with_reexecution_offset; | |
327 #ifdef COMPILER1 | |
328 _unpack_with_exception_in_tls = -1; | |
329 #endif | |
330 } | |
331 | |
332 | |
333 DeoptimizationBlob* DeoptimizationBlob::create( | |
334 CodeBuffer* cb, | |
335 OopMapSet* oop_maps, | |
336 int unpack_offset, | |
337 int unpack_with_exception_offset, | |
338 int unpack_with_reexecution_offset, | |
339 int frame_size) | |
340 { | |
341 DeoptimizationBlob* blob = NULL; | |
342 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock | |
343 { | |
344 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
345 unsigned int size = allocation_size(cb, sizeof(DeoptimizationBlob)); | |
346 blob = new (size) DeoptimizationBlob(cb, | |
347 size, | |
348 oop_maps, | |
349 unpack_offset, | |
350 unpack_with_exception_offset, | |
351 unpack_with_reexecution_offset, | |
352 frame_size); | |
353 } | |
354 | |
355 // Do not hold the CodeCache lock during name formatting. | |
356 if (blob != NULL) { | |
357 char blob_id[256]; | |
358 jio_snprintf(blob_id, sizeof(blob_id), "DeoptimizationBlob@" PTR_FORMAT, blob->instructions_begin()); | |
359 if (PrintStubCode) { | |
360 tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob); | |
361 Disassembler::decode(blob->instructions_begin(), blob->instructions_end()); | |
362 } | |
363 Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end()); | |
364 | |
365 if (JvmtiExport::should_post_dynamic_code_generated()) { | |
366 JvmtiExport::post_dynamic_code_generated("DeoptimizationBlob", | |
367 blob->instructions_begin(), | |
368 blob->instructions_end()); | |
369 } | |
370 } | |
371 | |
372 // Track memory usage statistic after releasing CodeCache_lock | |
373 MemoryService::track_code_cache_memory_usage(); | |
374 | |
375 return blob; | |
376 } | |
377 | |
378 | |
379 void* DeoptimizationBlob::operator new(size_t s, unsigned size) { | |
380 void* p = CodeCache::allocate(size); | |
381 if (!p) fatal("Initial size of CodeCache is too small"); | |
382 return p; | |
383 } | |
384 | |
385 //---------------------------------------------------------------------------------------------------- | |
386 // Implementation of UncommonTrapBlob | |
387 | |
388 #ifdef COMPILER2 | |
389 UncommonTrapBlob::UncommonTrapBlob( | |
390 CodeBuffer* cb, | |
391 int size, | |
392 OopMapSet* oop_maps, | |
393 int frame_size | |
394 ) | |
395 : SingletonBlob("UncommonTrapBlob", cb, sizeof(UncommonTrapBlob), size, frame_size, oop_maps) | |
396 {} | |
397 | |
398 | |
399 UncommonTrapBlob* UncommonTrapBlob::create( | |
400 CodeBuffer* cb, | |
401 OopMapSet* oop_maps, | |
402 int frame_size) | |
403 { | |
404 UncommonTrapBlob* blob = NULL; | |
405 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock | |
406 { | |
407 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
408 unsigned int size = allocation_size(cb, sizeof(UncommonTrapBlob)); | |
409 blob = new (size) UncommonTrapBlob(cb, size, oop_maps, frame_size); | |
410 } | |
411 | |
412 // Do not hold the CodeCache lock during name formatting. | |
413 if (blob != NULL) { | |
414 char blob_id[256]; | |
415 jio_snprintf(blob_id, sizeof(blob_id), "UncommonTrapBlob@" PTR_FORMAT, blob->instructions_begin()); | |
416 if (PrintStubCode) { | |
417 tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob); | |
418 Disassembler::decode(blob->instructions_begin(), blob->instructions_end()); | |
419 } | |
420 Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end()); | |
421 | |
422 if (JvmtiExport::should_post_dynamic_code_generated()) { | |
423 JvmtiExport::post_dynamic_code_generated("UncommonTrapBlob", | |
424 blob->instructions_begin(), | |
425 blob->instructions_end()); | |
426 } | |
427 } | |
428 | |
429 // Track memory usage statistic after releasing CodeCache_lock | |
430 MemoryService::track_code_cache_memory_usage(); | |
431 | |
432 return blob; | |
433 } | |
434 | |
435 | |
436 void* UncommonTrapBlob::operator new(size_t s, unsigned size) { | |
437 void* p = CodeCache::allocate(size); | |
438 if (!p) fatal("Initial size of CodeCache is too small"); | |
439 return p; | |
440 } | |
441 #endif // COMPILER2 | |
442 | |
443 | |
444 //---------------------------------------------------------------------------------------------------- | |
445 // Implementation of ExceptionBlob | |
446 | |
447 #ifdef COMPILER2 | |
448 ExceptionBlob::ExceptionBlob( | |
449 CodeBuffer* cb, | |
450 int size, | |
451 OopMapSet* oop_maps, | |
452 int frame_size | |
453 ) | |
454 : SingletonBlob("ExceptionBlob", cb, sizeof(ExceptionBlob), size, frame_size, oop_maps) | |
455 {} | |
456 | |
457 | |
458 ExceptionBlob* ExceptionBlob::create( | |
459 CodeBuffer* cb, | |
460 OopMapSet* oop_maps, | |
461 int frame_size) | |
462 { | |
463 ExceptionBlob* blob = NULL; | |
464 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock | |
465 { | |
466 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
467 unsigned int size = allocation_size(cb, sizeof(ExceptionBlob)); | |
468 blob = new (size) ExceptionBlob(cb, size, oop_maps, frame_size); | |
469 } | |
470 | |
471 // We do not need to hold the CodeCache lock during name formatting | |
472 if (blob != NULL) { | |
473 char blob_id[256]; | |
474 jio_snprintf(blob_id, sizeof(blob_id), "ExceptionBlob@" PTR_FORMAT, blob->instructions_begin()); | |
475 if (PrintStubCode) { | |
476 tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob); | |
477 Disassembler::decode(blob->instructions_begin(), blob->instructions_end()); | |
478 } | |
479 Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end()); | |
480 | |
481 if (JvmtiExport::should_post_dynamic_code_generated()) { | |
482 JvmtiExport::post_dynamic_code_generated("ExceptionBlob", | |
483 blob->instructions_begin(), | |
484 blob->instructions_end()); | |
485 } | |
486 } | |
487 | |
488 // Track memory usage statistic after releasing CodeCache_lock | |
489 MemoryService::track_code_cache_memory_usage(); | |
490 | |
491 return blob; | |
492 } | |
493 | |
494 | |
495 void* ExceptionBlob::operator new(size_t s, unsigned size) { | |
496 void* p = CodeCache::allocate(size); | |
497 if (!p) fatal("Initial size of CodeCache is too small"); | |
498 return p; | |
499 } | |
500 #endif // COMPILER2 | |
501 | |
502 | |
503 //---------------------------------------------------------------------------------------------------- | |
504 // Implementation of SafepointBlob | |
505 | |
506 SafepointBlob::SafepointBlob( | |
507 CodeBuffer* cb, | |
508 int size, | |
509 OopMapSet* oop_maps, | |
510 int frame_size | |
511 ) | |
512 : SingletonBlob("SafepointBlob", cb, sizeof(SafepointBlob), size, frame_size, oop_maps) | |
513 {} | |
514 | |
515 | |
516 SafepointBlob* SafepointBlob::create( | |
517 CodeBuffer* cb, | |
518 OopMapSet* oop_maps, | |
519 int frame_size) | |
520 { | |
521 SafepointBlob* blob = NULL; | |
522 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock | |
523 { | |
524 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
525 unsigned int size = allocation_size(cb, sizeof(SafepointBlob)); | |
526 blob = new (size) SafepointBlob(cb, size, oop_maps, frame_size); | |
527 } | |
528 | |
529 // We do not need to hold the CodeCache lock during name formatting. | |
530 if (blob != NULL) { | |
531 char blob_id[256]; | |
532 jio_snprintf(blob_id, sizeof(blob_id), "SafepointBlob@" PTR_FORMAT, blob->instructions_begin()); | |
533 if (PrintStubCode) { | |
534 tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob); | |
535 Disassembler::decode(blob->instructions_begin(), blob->instructions_end()); | |
536 } | |
537 Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end()); | |
538 | |
539 if (JvmtiExport::should_post_dynamic_code_generated()) { | |
540 JvmtiExport::post_dynamic_code_generated("SafepointBlob", | |
541 blob->instructions_begin(), | |
542 blob->instructions_end()); | |
543 } | |
544 } | |
545 | |
546 // Track memory usage statistic after releasing CodeCache_lock | |
547 MemoryService::track_code_cache_memory_usage(); | |
548 | |
549 return blob; | |
550 } | |
551 | |
552 | |
553 void* SafepointBlob::operator new(size_t s, unsigned size) { | |
554 void* p = CodeCache::allocate(size); | |
555 if (!p) fatal("Initial size of CodeCache is too small"); | |
556 return p; | |
557 } | |
558 | |
559 | |
560 //---------------------------------------------------------------------------------------------------- | |
561 // Verification and printing | |
562 | |
563 void CodeBlob::verify() { | |
564 ShouldNotReachHere(); | |
565 } | |
566 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
567 void CodeBlob::print_on(outputStream* st) const { |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
568 st->print_cr("[CodeBlob (" INTPTR_FORMAT ")]", this); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
569 st->print_cr("Framesize: %d", _frame_size); |
0 | 570 } |
571 | |
572 void CodeBlob::print_value_on(outputStream* st) const { | |
573 st->print_cr("[CodeBlob]"); | |
574 } | |
575 | |
576 void BufferBlob::verify() { | |
577 // unimplemented | |
578 } | |
579 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
580 void BufferBlob::print_on(outputStream* st) const { |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
581 CodeBlob::print_on(st); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
582 print_value_on(st); |
0 | 583 } |
584 | |
585 void BufferBlob::print_value_on(outputStream* st) const { | |
586 st->print_cr("BufferBlob (" INTPTR_FORMAT ") used for %s", this, name()); | |
587 } | |
588 | |
589 void RuntimeStub::verify() { | |
590 // unimplemented | |
591 } | |
592 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
593 void RuntimeStub::print_on(outputStream* st) const { |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
594 CodeBlob::print_on(st); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
595 st->print("Runtime Stub (" INTPTR_FORMAT "): ", this); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
596 st->print_cr(name()); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
597 Disassembler::decode((CodeBlob*)this, st); |
0 | 598 } |
599 | |
600 void RuntimeStub::print_value_on(outputStream* st) const { | |
601 st->print("RuntimeStub (" INTPTR_FORMAT "): ", this); st->print(name()); | |
602 } | |
603 | |
604 void SingletonBlob::verify() { | |
605 // unimplemented | |
606 } | |
607 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
608 void SingletonBlob::print_on(outputStream* st) const { |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
609 CodeBlob::print_on(st); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
610 st->print_cr(name()); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1663
diff
changeset
|
611 Disassembler::decode((CodeBlob*)this, st); |
0 | 612 } |
613 | |
614 void SingletonBlob::print_value_on(outputStream* st) const { | |
615 st->print_cr(name()); | |
616 } | |
617 | |
618 void DeoptimizationBlob::print_value_on(outputStream* st) const { | |
619 st->print_cr("Deoptimization (frame not available)"); | |
620 } |