src/share/vm/code/codeBlob.cpp

Thu, 24 May 2018 18:41:44 +0800

author
aoqi
date
Thu, 24 May 2018 18:41:44 +0800
changeset 8856
ac27a9c85bea
parent 7535
7ae4e26cb1e0
child 9203
53eec13fbaa5
permissions
-rw-r--r--

Merge

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

mercurial