src/share/vm/code/codeBlob.cpp

Wed, 14 Oct 2020 17:44:48 +0800

author
aoqi
date
Wed, 14 Oct 2020 17:44:48 +0800
changeset 9931
fd44df5e3bc3
parent 9203
53eec13fbaa5
parent 9861
a248d0be1309
permissions
-rw-r--r--

Merge

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

mercurial