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