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