src/share/vm/code/codeBlob.cpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 1
2d8a650513c2
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial