0
|
1 /*
|
|
2 * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
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 *
|
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
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 _oops_offset = size;
|
|
70 _oops_length = 0;
|
|
71 _frame_size = 0;
|
|
72 set_oop_maps(NULL);
|
|
73 }
|
|
74
|
|
75
|
|
76 // Creates a CodeBlob from a CodeBuffer. Sets up the size of the different regions,
|
|
77 // and copy code and relocation info.
|
|
78 CodeBlob::CodeBlob(
|
|
79 const char* name,
|
|
80 CodeBuffer* cb,
|
|
81 int header_size,
|
|
82 int size,
|
|
83 int frame_complete,
|
|
84 int frame_size,
|
|
85 OopMapSet* oop_maps
|
|
86 ) {
|
|
87 assert(size == round_to(size, oopSize), "unaligned size");
|
|
88 assert(header_size == round_to(header_size, oopSize), "unaligned size");
|
|
89
|
|
90 _name = name;
|
|
91 _size = size;
|
|
92 _frame_complete_offset = frame_complete;
|
|
93 _header_size = header_size;
|
|
94 _relocation_size = round_to(cb->total_relocation_size(), oopSize);
|
|
95 _instructions_offset = align_code_offset(header_size + _relocation_size);
|
|
96 _data_offset = _instructions_offset + round_to(cb->total_code_size(), oopSize);
|
|
97 _oops_offset = _size - round_to(cb->total_oop_size(), oopSize);
|
|
98 _oops_length = 0; // temporary, until the copy_oops handshake
|
|
99 assert(_oops_offset >= _data_offset, "codeBlob is too small");
|
|
100 assert(_data_offset <= size, "codeBlob is too small");
|
|
101
|
|
102 cb->copy_code_and_locs_to(this);
|
|
103 set_oop_maps(oop_maps);
|
|
104 _frame_size = frame_size;
|
|
105 #ifdef COMPILER1
|
|
106 // probably wrong for tiered
|
|
107 assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
|
|
108 #endif // COMPILER1
|
|
109 }
|
|
110
|
|
111
|
|
112 void CodeBlob::set_oop_maps(OopMapSet* p) {
|
|
113 // Danger Will Robinson! This method allocates a big
|
|
114 // chunk of memory, its your job to free it.
|
|
115 if (p != NULL) {
|
|
116 // We need to allocate a chunk big enough to hold the OopMapSet and all of its OopMaps
|
|
117 _oop_maps = (OopMapSet* )NEW_C_HEAP_ARRAY(unsigned char, p->heap_size());
|
|
118 p->copy_to((address)_oop_maps);
|
|
119 } else {
|
|
120 _oop_maps = NULL;
|
|
121 }
|
|
122 }
|
|
123
|
|
124
|
|
125 void CodeBlob::flush() {
|
|
126 if (_oop_maps) {
|
|
127 FREE_C_HEAP_ARRAY(unsigned char, _oop_maps);
|
|
128 _oop_maps = NULL;
|
|
129 }
|
|
130 _comments.free();
|
|
131 }
|
|
132
|
|
133
|
|
134 // Promote one word from an assembly-time handle to a live embedded oop.
|
|
135 inline void CodeBlob::initialize_immediate_oop(oop* dest, jobject handle) {
|
|
136 if (handle == NULL ||
|
|
137 // As a special case, IC oops are initialized to 1 or -1.
|
|
138 handle == (jobject) Universe::non_oop_word()) {
|
|
139 (*dest) = (oop)handle;
|
|
140 } else {
|
|
141 (*dest) = JNIHandles::resolve_non_null(handle);
|
|
142 }
|
|
143 }
|
|
144
|
|
145
|
|
146 void CodeBlob::copy_oops(GrowableArray<jobject>* array) {
|
|
147 assert(_oops_length == 0, "do this handshake just once, please");
|
|
148 int length = array->length();
|
|
149 assert((address)(oops_begin() + length) <= data_end(), "oops big enough");
|
|
150 oop* dest = oops_begin();
|
|
151 for (int index = 0 ; index < length; index++) {
|
|
152 initialize_immediate_oop(&dest[index], array->at(index));
|
|
153 }
|
|
154 _oops_length = length;
|
|
155
|
|
156 // Now we can fix up all the oops in the code.
|
|
157 // We need to do this in the code because
|
|
158 // the assembler uses jobjects as placeholders.
|
|
159 // The code and relocations have already been
|
|
160 // initialized by the CodeBlob constructor,
|
|
161 // so it is valid even at this early point to
|
|
162 // iterate over relocations and patch the code.
|
|
163 fix_oop_relocations(NULL, NULL, /*initialize_immediates=*/ true);
|
|
164 }
|
|
165
|
|
166
|
|
167 relocInfo::relocType CodeBlob::reloc_type_for_address(address pc) {
|
|
168 RelocIterator iter(this, pc, pc+1);
|
|
169 while (iter.next()) {
|
|
170 return (relocInfo::relocType) iter.type();
|
|
171 }
|
|
172 // No relocation info found for pc
|
|
173 ShouldNotReachHere();
|
|
174 return relocInfo::none; // dummy return value
|
|
175 }
|
|
176
|
|
177
|
|
178 bool CodeBlob::is_at_poll_return(address pc) {
|
|
179 RelocIterator iter(this, pc, pc+1);
|
|
180 while (iter.next()) {
|
|
181 if (iter.type() == relocInfo::poll_return_type)
|
|
182 return true;
|
|
183 }
|
|
184 return false;
|
|
185 }
|
|
186
|
|
187
|
|
188 bool CodeBlob::is_at_poll_or_poll_return(address pc) {
|
|
189 RelocIterator iter(this, pc, pc+1);
|
|
190 while (iter.next()) {
|
|
191 relocInfo::relocType t = iter.type();
|
|
192 if (t == relocInfo::poll_return_type || t == relocInfo::poll_type)
|
|
193 return true;
|
|
194 }
|
|
195 return false;
|
|
196 }
|
|
197
|
|
198
|
|
199 void CodeBlob::fix_oop_relocations(address begin, address end,
|
|
200 bool initialize_immediates) {
|
|
201 // re-patch all oop-bearing instructions, just in case some oops moved
|
|
202 RelocIterator iter(this, begin, end);
|
|
203 while (iter.next()) {
|
|
204 if (iter.type() == relocInfo::oop_type) {
|
|
205 oop_Relocation* reloc = iter.oop_reloc();
|
|
206 if (initialize_immediates && reloc->oop_is_immediate()) {
|
|
207 oop* dest = reloc->oop_addr();
|
|
208 initialize_immediate_oop(dest, (jobject) *dest);
|
|
209 }
|
|
210 // Refresh the oop-related bits of this instruction.
|
|
211 reloc->fix_oop_relocation();
|
|
212 }
|
|
213
|
|
214 // There must not be any interfering patches or breakpoints.
|
|
215 assert(!(iter.type() == relocInfo::breakpoint_type
|
|
216 && iter.breakpoint_reloc()->active()),
|
|
217 "no active breakpoint");
|
|
218 }
|
|
219 }
|
|
220
|
|
221 void CodeBlob::do_unloading(BoolObjectClosure* is_alive,
|
|
222 OopClosure* keep_alive,
|
|
223 bool unloading_occurred) {
|
|
224 ShouldNotReachHere();
|
|
225 }
|
|
226
|
|
227 OopMap* CodeBlob::oop_map_for_return_address(address return_address) {
|
|
228 address pc = return_address ;
|
|
229 assert (oop_maps() != NULL, "nope");
|
|
230 return oop_maps()->find_map_at_offset ((intptr_t) pc - (intptr_t) instructions_begin());
|
|
231 }
|
|
232
|
|
233
|
|
234 //----------------------------------------------------------------------------------------------------
|
|
235 // Implementation of BufferBlob
|
|
236
|
|
237
|
|
238 BufferBlob::BufferBlob(const char* name, int size)
|
|
239 : CodeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0)
|
|
240 {}
|
|
241
|
|
242 BufferBlob* BufferBlob::create(const char* name, int buffer_size) {
|
|
243 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
|
|
244
|
|
245 BufferBlob* blob = NULL;
|
|
246 unsigned int size = sizeof(BufferBlob);
|
|
247 // align the size to CodeEntryAlignment
|
|
248 size = align_code_offset(size);
|
|
249 size += round_to(buffer_size, oopSize);
|
|
250 assert(name != NULL, "must provide a name");
|
|
251 {
|
|
252
|
|
253 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
|
254 blob = new (size) BufferBlob(name, size);
|
|
255 }
|
|
256 // Track memory usage statistic after releasing CodeCache_lock
|
|
257 MemoryService::track_code_cache_memory_usage();
|
|
258
|
|
259 return blob;
|
|
260 }
|
|
261
|
|
262
|
|
263 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb)
|
|
264 : CodeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL)
|
|
265 {}
|
|
266
|
|
267 BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) {
|
|
268 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
|
|
269
|
|
270 BufferBlob* blob = NULL;
|
|
271 unsigned int size = allocation_size(cb, sizeof(BufferBlob));
|
|
272 assert(name != NULL, "must provide a name");
|
|
273 {
|
|
274
|
|
275 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
|
276 blob = new (size) BufferBlob(name, size, cb);
|
|
277 }
|
|
278 // Track memory usage statistic after releasing CodeCache_lock
|
|
279 MemoryService::track_code_cache_memory_usage();
|
|
280
|
|
281 return blob;
|
|
282 }
|
|
283
|
|
284
|
|
285 void* BufferBlob::operator new(size_t s, unsigned size) {
|
|
286 void* p = CodeCache::allocate(size);
|
|
287 return p;
|
|
288 }
|
|
289
|
|
290
|
|
291 void BufferBlob::free( BufferBlob *blob ) {
|
|
292 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
|
|
293 {
|
|
294 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
|
295 CodeCache::free((CodeBlob*)blob);
|
|
296 }
|
|
297 // Track memory usage statistic after releasing CodeCache_lock
|
|
298 MemoryService::track_code_cache_memory_usage();
|
|
299 }
|
|
300
|
|
301 bool BufferBlob::is_adapter_blob() const {
|
|
302 return (strcmp(AdapterHandlerEntry::name, name()) == 0);
|
|
303 }
|
|
304
|
|
305 //----------------------------------------------------------------------------------------------------
|
|
306 // Implementation of RuntimeStub
|
|
307
|
|
308 RuntimeStub::RuntimeStub(
|
|
309 const char* name,
|
|
310 CodeBuffer* cb,
|
|
311 int size,
|
|
312 int frame_complete,
|
|
313 int frame_size,
|
|
314 OopMapSet* oop_maps,
|
|
315 bool caller_must_gc_arguments
|
|
316 )
|
|
317 : CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps)
|
|
318 {
|
|
319 _caller_must_gc_arguments = caller_must_gc_arguments;
|
|
320 }
|
|
321
|
|
322
|
|
323 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
|
|
324 CodeBuffer* cb,
|
|
325 int frame_complete,
|
|
326 int frame_size,
|
|
327 OopMapSet* oop_maps,
|
|
328 bool caller_must_gc_arguments)
|
|
329 {
|
|
330 RuntimeStub* stub = NULL;
|
|
331 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
|
|
332 {
|
|
333 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
|
334 unsigned int size = allocation_size(cb, sizeof(RuntimeStub));
|
|
335 stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments);
|
|
336 }
|
|
337
|
|
338 // Do not hold the CodeCache lock during name formatting.
|
|
339 if (stub != NULL) {
|
|
340 char stub_id[256];
|
|
341 jio_snprintf(stub_id, sizeof(stub_id), "RuntimeStub - %s", stub_name);
|
|
342 if (PrintStubCode) {
|
|
343 tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, stub);
|
|
344 Disassembler::decode(stub->instructions_begin(), stub->instructions_end());
|
|
345 }
|
|
346 VTune::register_stub(stub_id, stub->instructions_begin(), stub->instructions_end());
|
|
347 Forte::register_stub(stub_id, stub->instructions_begin(), stub->instructions_end());
|
|
348
|
|
349 if (JvmtiExport::should_post_dynamic_code_generated()) {
|
|
350 JvmtiExport::post_dynamic_code_generated(stub_name, stub->instructions_begin(), stub->instructions_end());
|
|
351 }
|
|
352 }
|
|
353
|
|
354 // Track memory usage statistic after releasing CodeCache_lock
|
|
355 MemoryService::track_code_cache_memory_usage();
|
|
356
|
|
357 return stub;
|
|
358 }
|
|
359
|
|
360
|
|
361 void* RuntimeStub::operator new(size_t s, unsigned size) {
|
|
362 void* p = CodeCache::allocate(size);
|
|
363 if (!p) fatal("Initial size of CodeCache is too small");
|
|
364 return p;
|
|
365 }
|
|
366
|
|
367
|
|
368 //----------------------------------------------------------------------------------------------------
|
|
369 // Implementation of DeoptimizationBlob
|
|
370
|
|
371 DeoptimizationBlob::DeoptimizationBlob(
|
|
372 CodeBuffer* cb,
|
|
373 int size,
|
|
374 OopMapSet* oop_maps,
|
|
375 int unpack_offset,
|
|
376 int unpack_with_exception_offset,
|
|
377 int unpack_with_reexecution_offset,
|
|
378 int frame_size
|
|
379 )
|
|
380 : SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps)
|
|
381 {
|
|
382 _unpack_offset = unpack_offset;
|
|
383 _unpack_with_exception = unpack_with_exception_offset;
|
|
384 _unpack_with_reexecution = unpack_with_reexecution_offset;
|
|
385 #ifdef COMPILER1
|
|
386 _unpack_with_exception_in_tls = -1;
|
|
387 #endif
|
|
388 }
|
|
389
|
|
390
|
|
391 DeoptimizationBlob* DeoptimizationBlob::create(
|
|
392 CodeBuffer* cb,
|
|
393 OopMapSet* oop_maps,
|
|
394 int unpack_offset,
|
|
395 int unpack_with_exception_offset,
|
|
396 int unpack_with_reexecution_offset,
|
|
397 int frame_size)
|
|
398 {
|
|
399 DeoptimizationBlob* blob = NULL;
|
|
400 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
|
|
401 {
|
|
402 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
|
403 unsigned int size = allocation_size(cb, sizeof(DeoptimizationBlob));
|
|
404 blob = new (size) DeoptimizationBlob(cb,
|
|
405 size,
|
|
406 oop_maps,
|
|
407 unpack_offset,
|
|
408 unpack_with_exception_offset,
|
|
409 unpack_with_reexecution_offset,
|
|
410 frame_size);
|
|
411 }
|
|
412
|
|
413 // Do not hold the CodeCache lock during name formatting.
|
|
414 if (blob != NULL) {
|
|
415 char blob_id[256];
|
|
416 jio_snprintf(blob_id, sizeof(blob_id), "DeoptimizationBlob@" PTR_FORMAT, blob->instructions_begin());
|
|
417 if (PrintStubCode) {
|
|
418 tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
|
|
419 Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
|
|
420 }
|
|
421 VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
|
422 Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
|
423
|
|
424 if (JvmtiExport::should_post_dynamic_code_generated()) {
|
|
425 JvmtiExport::post_dynamic_code_generated("DeoptimizationBlob",
|
|
426 blob->instructions_begin(),
|
|
427 blob->instructions_end());
|
|
428 }
|
|
429 }
|
|
430
|
|
431 // Track memory usage statistic after releasing CodeCache_lock
|
|
432 MemoryService::track_code_cache_memory_usage();
|
|
433
|
|
434 return blob;
|
|
435 }
|
|
436
|
|
437
|
|
438 void* DeoptimizationBlob::operator new(size_t s, unsigned size) {
|
|
439 void* p = CodeCache::allocate(size);
|
|
440 if (!p) fatal("Initial size of CodeCache is too small");
|
|
441 return p;
|
|
442 }
|
|
443
|
|
444 //----------------------------------------------------------------------------------------------------
|
|
445 // Implementation of UncommonTrapBlob
|
|
446
|
|
447 #ifdef COMPILER2
|
|
448 UncommonTrapBlob::UncommonTrapBlob(
|
|
449 CodeBuffer* cb,
|
|
450 int size,
|
|
451 OopMapSet* oop_maps,
|
|
452 int frame_size
|
|
453 )
|
|
454 : SingletonBlob("UncommonTrapBlob", cb, sizeof(UncommonTrapBlob), size, frame_size, oop_maps)
|
|
455 {}
|
|
456
|
|
457
|
|
458 UncommonTrapBlob* UncommonTrapBlob::create(
|
|
459 CodeBuffer* cb,
|
|
460 OopMapSet* oop_maps,
|
|
461 int frame_size)
|
|
462 {
|
|
463 UncommonTrapBlob* 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(UncommonTrapBlob));
|
|
468 blob = new (size) UncommonTrapBlob(cb, size, oop_maps, frame_size);
|
|
469 }
|
|
470
|
|
471 // Do not hold the CodeCache lock during name formatting.
|
|
472 if (blob != NULL) {
|
|
473 char blob_id[256];
|
|
474 jio_snprintf(blob_id, sizeof(blob_id), "UncommonTrapBlob@" 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 VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
|
480 Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
|
481
|
|
482 if (JvmtiExport::should_post_dynamic_code_generated()) {
|
|
483 JvmtiExport::post_dynamic_code_generated("UncommonTrapBlob",
|
|
484 blob->instructions_begin(),
|
|
485 blob->instructions_end());
|
|
486 }
|
|
487 }
|
|
488
|
|
489 // Track memory usage statistic after releasing CodeCache_lock
|
|
490 MemoryService::track_code_cache_memory_usage();
|
|
491
|
|
492 return blob;
|
|
493 }
|
|
494
|
|
495
|
|
496 void* UncommonTrapBlob::operator new(size_t s, unsigned size) {
|
|
497 void* p = CodeCache::allocate(size);
|
|
498 if (!p) fatal("Initial size of CodeCache is too small");
|
|
499 return p;
|
|
500 }
|
|
501 #endif // COMPILER2
|
|
502
|
|
503
|
|
504 //----------------------------------------------------------------------------------------------------
|
|
505 // Implementation of ExceptionBlob
|
|
506
|
|
507 #ifdef COMPILER2
|
|
508 ExceptionBlob::ExceptionBlob(
|
|
509 CodeBuffer* cb,
|
|
510 int size,
|
|
511 OopMapSet* oop_maps,
|
|
512 int frame_size
|
|
513 )
|
|
514 : SingletonBlob("ExceptionBlob", cb, sizeof(ExceptionBlob), size, frame_size, oop_maps)
|
|
515 {}
|
|
516
|
|
517
|
|
518 ExceptionBlob* ExceptionBlob::create(
|
|
519 CodeBuffer* cb,
|
|
520 OopMapSet* oop_maps,
|
|
521 int frame_size)
|
|
522 {
|
|
523 ExceptionBlob* blob = NULL;
|
|
524 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
|
|
525 {
|
|
526 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
|
527 unsigned int size = allocation_size(cb, sizeof(ExceptionBlob));
|
|
528 blob = new (size) ExceptionBlob(cb, size, oop_maps, frame_size);
|
|
529 }
|
|
530
|
|
531 // We do not need to hold the CodeCache lock during name formatting
|
|
532 if (blob != NULL) {
|
|
533 char blob_id[256];
|
|
534 jio_snprintf(blob_id, sizeof(blob_id), "ExceptionBlob@" PTR_FORMAT, blob->instructions_begin());
|
|
535 if (PrintStubCode) {
|
|
536 tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
|
|
537 Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
|
|
538 }
|
|
539 VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
|
540 Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
|
541
|
|
542 if (JvmtiExport::should_post_dynamic_code_generated()) {
|
|
543 JvmtiExport::post_dynamic_code_generated("ExceptionBlob",
|
|
544 blob->instructions_begin(),
|
|
545 blob->instructions_end());
|
|
546 }
|
|
547 }
|
|
548
|
|
549 // Track memory usage statistic after releasing CodeCache_lock
|
|
550 MemoryService::track_code_cache_memory_usage();
|
|
551
|
|
552 return blob;
|
|
553 }
|
|
554
|
|
555
|
|
556 void* ExceptionBlob::operator new(size_t s, unsigned size) {
|
|
557 void* p = CodeCache::allocate(size);
|
|
558 if (!p) fatal("Initial size of CodeCache is too small");
|
|
559 return p;
|
|
560 }
|
|
561 #endif // COMPILER2
|
|
562
|
|
563
|
|
564 //----------------------------------------------------------------------------------------------------
|
|
565 // Implementation of SafepointBlob
|
|
566
|
|
567 SafepointBlob::SafepointBlob(
|
|
568 CodeBuffer* cb,
|
|
569 int size,
|
|
570 OopMapSet* oop_maps,
|
|
571 int frame_size
|
|
572 )
|
|
573 : SingletonBlob("SafepointBlob", cb, sizeof(SafepointBlob), size, frame_size, oop_maps)
|
|
574 {}
|
|
575
|
|
576
|
|
577 SafepointBlob* SafepointBlob::create(
|
|
578 CodeBuffer* cb,
|
|
579 OopMapSet* oop_maps,
|
|
580 int frame_size)
|
|
581 {
|
|
582 SafepointBlob* blob = NULL;
|
|
583 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
|
|
584 {
|
|
585 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
|
586 unsigned int size = allocation_size(cb, sizeof(SafepointBlob));
|
|
587 blob = new (size) SafepointBlob(cb, size, oop_maps, frame_size);
|
|
588 }
|
|
589
|
|
590 // We do not need to hold the CodeCache lock during name formatting.
|
|
591 if (blob != NULL) {
|
|
592 char blob_id[256];
|
|
593 jio_snprintf(blob_id, sizeof(blob_id), "SafepointBlob@" PTR_FORMAT, blob->instructions_begin());
|
|
594 if (PrintStubCode) {
|
|
595 tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
|
|
596 Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
|
|
597 }
|
|
598 VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
|
599 Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
|
|
600
|
|
601 if (JvmtiExport::should_post_dynamic_code_generated()) {
|
|
602 JvmtiExport::post_dynamic_code_generated("SafepointBlob",
|
|
603 blob->instructions_begin(),
|
|
604 blob->instructions_end());
|
|
605 }
|
|
606 }
|
|
607
|
|
608 // Track memory usage statistic after releasing CodeCache_lock
|
|
609 MemoryService::track_code_cache_memory_usage();
|
|
610
|
|
611 return blob;
|
|
612 }
|
|
613
|
|
614
|
|
615 void* SafepointBlob::operator new(size_t s, unsigned size) {
|
|
616 void* p = CodeCache::allocate(size);
|
|
617 if (!p) fatal("Initial size of CodeCache is too small");
|
|
618 return p;
|
|
619 }
|
|
620
|
|
621
|
|
622 //----------------------------------------------------------------------------------------------------
|
|
623 // Verification and printing
|
|
624
|
|
625 void CodeBlob::verify() {
|
|
626 ShouldNotReachHere();
|
|
627 }
|
|
628
|
|
629 #ifndef PRODUCT
|
|
630
|
|
631 void CodeBlob::print() const {
|
|
632 tty->print_cr("[CodeBlob (" INTPTR_FORMAT ")]", this);
|
|
633 tty->print_cr("Framesize: %d", _frame_size);
|
|
634 }
|
|
635
|
|
636
|
|
637 void CodeBlob::print_value_on(outputStream* st) const {
|
|
638 st->print_cr("[CodeBlob]");
|
|
639 }
|
|
640
|
|
641 #endif
|
|
642
|
|
643 void BufferBlob::verify() {
|
|
644 // unimplemented
|
|
645 }
|
|
646
|
|
647 #ifndef PRODUCT
|
|
648
|
|
649 void BufferBlob::print() const {
|
|
650 CodeBlob::print();
|
|
651 print_value_on(tty);
|
|
652 }
|
|
653
|
|
654
|
|
655 void BufferBlob::print_value_on(outputStream* st) const {
|
|
656 st->print_cr("BufferBlob (" INTPTR_FORMAT ") used for %s", this, name());
|
|
657 }
|
|
658
|
|
659
|
|
660 #endif
|
|
661
|
|
662 void RuntimeStub::verify() {
|
|
663 // unimplemented
|
|
664 }
|
|
665
|
|
666 #ifndef PRODUCT
|
|
667
|
|
668 void RuntimeStub::print() const {
|
|
669 CodeBlob::print();
|
|
670 tty->print("Runtime Stub (" INTPTR_FORMAT "): ", this);
|
|
671 tty->print_cr(name());
|
|
672 Disassembler::decode((CodeBlob*)this);
|
|
673 }
|
|
674
|
|
675
|
|
676 void RuntimeStub::print_value_on(outputStream* st) const {
|
|
677 st->print("RuntimeStub (" INTPTR_FORMAT "): ", this); st->print(name());
|
|
678 }
|
|
679
|
|
680 #endif
|
|
681
|
|
682 void SingletonBlob::verify() {
|
|
683 // unimplemented
|
|
684 }
|
|
685
|
|
686 #ifndef PRODUCT
|
|
687
|
|
688 void SingletonBlob::print() const {
|
|
689 CodeBlob::print();
|
|
690 tty->print_cr(name());
|
|
691 Disassembler::decode((CodeBlob*)this);
|
|
692 }
|
|
693
|
|
694
|
|
695 void SingletonBlob::print_value_on(outputStream* st) const {
|
|
696 st->print_cr(name());
|
|
697 }
|
|
698
|
|
699 void DeoptimizationBlob::print_value_on(outputStream* st) const {
|
|
700 st->print_cr("Deoptimization (frame not available)");
|
|
701 }
|
|
702
|
|
703 #endif // PRODUCT
|