src/share/vm/code/codeBlob.cpp

Fri, 27 Aug 2010 01:51:27 -0700

author
twisti
date
Fri, 27 Aug 2010 01:51:27 -0700
changeset 2117
0878d7bae69f
parent 2103
3e8fbc61cee8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6961697: move nmethod constants section before instruction section
Summary: This is a preparation for 6961690.
Reviewed-by: kvn, never

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

mercurial