codeBlob.cpp revision 1472
0N/A/*
1472N/A * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
0N/A# include "incls/_precompiled.incl"
0N/A# include "incls/_codeBlob.cpp.incl"
0N/A
0N/Aunsigned int align_code_offset(int offset) {
0N/A // align the size to CodeEntryAlignment
0N/A return
0N/A ((offset + (int)CodeHeap::header_size() + (CodeEntryAlignment-1)) & ~(CodeEntryAlignment-1))
0N/A - (int)CodeHeap::header_size();
0N/A}
0N/A
0N/A
0N/A// This must be consistent with the CodeBlob constructor's layout actions.
0N/Aunsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) {
0N/A unsigned int size = header_size;
0N/A size += round_to(cb->total_relocation_size(), oopSize);
0N/A // align the size to CodeEntryAlignment
0N/A size = align_code_offset(size);
0N/A size += round_to(cb->total_code_size(), oopSize);
0N/A size += round_to(cb->total_oop_size(), oopSize);
0N/A return size;
0N/A}
0N/A
0N/A
0N/A// Creates a simple CodeBlob. Sets up the size of the different regions.
0N/ACodeBlob::CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size) {
0N/A assert(size == round_to(size, oopSize), "unaligned size");
0N/A assert(locs_size == round_to(locs_size, oopSize), "unaligned size");
0N/A assert(header_size == round_to(header_size, oopSize), "unaligned size");
0N/A assert(!UseRelocIndex, "no space allocated for reloc index yet");
0N/A
0N/A // Note: If UseRelocIndex is enabled, there needs to be (at least) one
0N/A // extra word for the relocation information, containing the reloc
0N/A // index table length. Unfortunately, the reloc index table imple-
0N/A // mentation is not easily understandable and thus it is not clear
0N/A // what exactly the format is supposed to be. For now, we just turn
0N/A // off the use of this table (gri 7/6/2000).
0N/A
0N/A _name = name;
0N/A _size = size;
0N/A _frame_complete_offset = frame_complete;
0N/A _header_size = header_size;
0N/A _relocation_size = locs_size;
0N/A _instructions_offset = align_code_offset(header_size + locs_size);
0N/A _data_offset = size;
0N/A _oops_offset = size;
0N/A _oops_length = 0;
0N/A _frame_size = 0;
0N/A set_oop_maps(NULL);
0N/A}
0N/A
0N/A
0N/A// Creates a CodeBlob from a CodeBuffer. Sets up the size of the different regions,
0N/A// and copy code and relocation info.
0N/ACodeBlob::CodeBlob(
0N/A const char* name,
0N/A CodeBuffer* cb,
0N/A int header_size,
0N/A int size,
0N/A int frame_complete,
0N/A int frame_size,
0N/A OopMapSet* oop_maps
0N/A) {
0N/A assert(size == round_to(size, oopSize), "unaligned size");
0N/A assert(header_size == round_to(header_size, oopSize), "unaligned size");
0N/A
0N/A _name = name;
0N/A _size = size;
0N/A _frame_complete_offset = frame_complete;
0N/A _header_size = header_size;
0N/A _relocation_size = round_to(cb->total_relocation_size(), oopSize);
0N/A _instructions_offset = align_code_offset(header_size + _relocation_size);
0N/A _data_offset = _instructions_offset + round_to(cb->total_code_size(), oopSize);
0N/A _oops_offset = _size - round_to(cb->total_oop_size(), oopSize);
0N/A _oops_length = 0; // temporary, until the copy_oops handshake
0N/A assert(_oops_offset >= _data_offset, "codeBlob is too small");
0N/A assert(_data_offset <= size, "codeBlob is too small");
0N/A
0N/A cb->copy_code_and_locs_to(this);
0N/A set_oop_maps(oop_maps);
0N/A _frame_size = frame_size;
0N/A#ifdef COMPILER1
0N/A // probably wrong for tiered
0N/A assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
0N/A#endif // COMPILER1
0N/A}
0N/A
0N/A
0N/Avoid CodeBlob::set_oop_maps(OopMapSet* p) {
0N/A // Danger Will Robinson! This method allocates a big
0N/A // chunk of memory, its your job to free it.
0N/A if (p != NULL) {
0N/A // We need to allocate a chunk big enough to hold the OopMapSet and all of its OopMaps
0N/A _oop_maps = (OopMapSet* )NEW_C_HEAP_ARRAY(unsigned char, p->heap_size());
0N/A p->copy_to((address)_oop_maps);
0N/A } else {
0N/A _oop_maps = NULL;
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid CodeBlob::flush() {
0N/A if (_oop_maps) {
0N/A FREE_C_HEAP_ARRAY(unsigned char, _oop_maps);
0N/A _oop_maps = NULL;
0N/A }
0N/A _comments.free();
0N/A}
0N/A
0N/A
0N/A// Promote one word from an assembly-time handle to a live embedded oop.
0N/Ainline void CodeBlob::initialize_immediate_oop(oop* dest, jobject handle) {
0N/A if (handle == NULL ||
0N/A // As a special case, IC oops are initialized to 1 or -1.
0N/A handle == (jobject) Universe::non_oop_word()) {
0N/A (*dest) = (oop)handle;
0N/A } else {
0N/A (*dest) = JNIHandles::resolve_non_null(handle);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid CodeBlob::copy_oops(GrowableArray<jobject>* array) {
0N/A assert(_oops_length == 0, "do this handshake just once, please");
0N/A int length = array->length();
0N/A assert((address)(oops_begin() + length) <= data_end(), "oops big enough");
0N/A oop* dest = oops_begin();
0N/A for (int index = 0 ; index < length; index++) {
0N/A initialize_immediate_oop(&dest[index], array->at(index));
0N/A }
0N/A _oops_length = length;
0N/A
0N/A // Now we can fix up all the oops in the code.
0N/A // We need to do this in the code because
0N/A // the assembler uses jobjects as placeholders.
0N/A // The code and relocations have already been
0N/A // initialized by the CodeBlob constructor,
0N/A // so it is valid even at this early point to
0N/A // iterate over relocations and patch the code.
0N/A fix_oop_relocations(NULL, NULL, /*initialize_immediates=*/ true);
0N/A}
0N/A
0N/A
0N/ArelocInfo::relocType CodeBlob::reloc_type_for_address(address pc) {
0N/A RelocIterator iter(this, pc, pc+1);
0N/A while (iter.next()) {
0N/A return (relocInfo::relocType) iter.type();
0N/A }
0N/A // No relocation info found for pc
0N/A ShouldNotReachHere();
0N/A return relocInfo::none; // dummy return value
0N/A}
0N/A
0N/A
0N/Abool CodeBlob::is_at_poll_return(address pc) {
0N/A RelocIterator iter(this, pc, pc+1);
0N/A while (iter.next()) {
0N/A if (iter.type() == relocInfo::poll_return_type)
0N/A return true;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A
0N/Abool CodeBlob::is_at_poll_or_poll_return(address pc) {
0N/A RelocIterator iter(this, pc, pc+1);
0N/A while (iter.next()) {
0N/A relocInfo::relocType t = iter.type();
0N/A if (t == relocInfo::poll_return_type || t == relocInfo::poll_type)
0N/A return true;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A
0N/Avoid CodeBlob::fix_oop_relocations(address begin, address end,
0N/A bool initialize_immediates) {
0N/A // re-patch all oop-bearing instructions, just in case some oops moved
0N/A RelocIterator iter(this, begin, end);
0N/A while (iter.next()) {
0N/A if (iter.type() == relocInfo::oop_type) {
0N/A oop_Relocation* reloc = iter.oop_reloc();
0N/A if (initialize_immediates && reloc->oop_is_immediate()) {
0N/A oop* dest = reloc->oop_addr();
0N/A initialize_immediate_oop(dest, (jobject) *dest);
0N/A }
0N/A // Refresh the oop-related bits of this instruction.
0N/A reloc->fix_oop_relocation();
0N/A }
0N/A
0N/A // There must not be any interfering patches or breakpoints.
0N/A assert(!(iter.type() == relocInfo::breakpoint_type
0N/A && iter.breakpoint_reloc()->active()),
0N/A "no active breakpoint");
0N/A }
0N/A}
0N/A
0N/Avoid CodeBlob::do_unloading(BoolObjectClosure* is_alive,
0N/A OopClosure* keep_alive,
0N/A bool unloading_occurred) {
0N/A ShouldNotReachHere();
0N/A}
0N/A
0N/AOopMap* CodeBlob::oop_map_for_return_address(address return_address) {
0N/A address pc = return_address ;
0N/A assert (oop_maps() != NULL, "nope");
0N/A return oop_maps()->find_map_at_offset ((intptr_t) pc - (intptr_t) instructions_begin());
0N/A}
0N/A
0N/A
0N/A//----------------------------------------------------------------------------------------------------
0N/A// Implementation of BufferBlob
0N/A
0N/A
0N/ABufferBlob::BufferBlob(const char* name, int size)
0N/A: CodeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0)
0N/A{}
0N/A
0N/ABufferBlob* BufferBlob::create(const char* name, int buffer_size) {
0N/A ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
0N/A
0N/A BufferBlob* blob = NULL;
0N/A unsigned int size = sizeof(BufferBlob);
0N/A // align the size to CodeEntryAlignment
0N/A size = align_code_offset(size);
0N/A size += round_to(buffer_size, oopSize);
0N/A assert(name != NULL, "must provide a name");
0N/A {
0N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
0N/A blob = new (size) BufferBlob(name, size);
0N/A }
0N/A // Track memory usage statistic after releasing CodeCache_lock
0N/A MemoryService::track_code_cache_memory_usage();
0N/A
0N/A return blob;
0N/A}
0N/A
0N/A
0N/ABufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb)
0N/A : CodeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL)
0N/A{}
0N/A
0N/ABufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) {
0N/A ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
0N/A
0N/A BufferBlob* blob = NULL;
0N/A unsigned int size = allocation_size(cb, sizeof(BufferBlob));
0N/A assert(name != NULL, "must provide a name");
0N/A {
0N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
0N/A blob = new (size) BufferBlob(name, size, cb);
0N/A }
0N/A // Track memory usage statistic after releasing CodeCache_lock
0N/A MemoryService::track_code_cache_memory_usage();
0N/A
0N/A return blob;
0N/A}
0N/A
0N/A
0N/Avoid* BufferBlob::operator new(size_t s, unsigned size) {
0N/A void* p = CodeCache::allocate(size);
0N/A return p;
0N/A}
0N/A
0N/A
0N/Avoid BufferBlob::free( BufferBlob *blob ) {
0N/A ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
0N/A {
0N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
0N/A CodeCache::free((CodeBlob*)blob);
0N/A }
0N/A // Track memory usage statistic after releasing CodeCache_lock
0N/A MemoryService::track_code_cache_memory_usage();
0N/A}
0N/A
1299N/A
1299N/A//----------------------------------------------------------------------------------------------------
1299N/A// Implementation of AdapterBlob
1299N/A
1299N/AAdapterBlob* AdapterBlob::create(CodeBuffer* cb) {
1299N/A ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
1299N/A
1299N/A AdapterBlob* blob = NULL;
1299N/A unsigned int size = allocation_size(cb, sizeof(AdapterBlob));
1299N/A {
1299N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1299N/A blob = new (size) AdapterBlob(size, cb);
1299N/A }
1299N/A // Track memory usage statistic after releasing CodeCache_lock
1299N/A MemoryService::track_code_cache_memory_usage();
1299N/A
1299N/A return blob;
0N/A}
0N/A
1299N/A
1299N/A//----------------------------------------------------------------------------------------------------
1299N/A// Implementation of MethodHandlesAdapterBlob
1299N/A
1299N/AMethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) {
1299N/A ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
1299N/A
1299N/A MethodHandlesAdapterBlob* blob = NULL;
1299N/A unsigned int size = sizeof(MethodHandlesAdapterBlob);
1299N/A // align the size to CodeEntryAlignment
1299N/A size = align_code_offset(size);
1299N/A size += round_to(buffer_size, oopSize);
1299N/A {
1299N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1299N/A blob = new (size) MethodHandlesAdapterBlob(size);
1299N/A }
1299N/A // Track memory usage statistic after releasing CodeCache_lock
1299N/A MemoryService::track_code_cache_memory_usage();
1299N/A
1299N/A return blob;
1299N/A}
1299N/A
1299N/A
0N/A//----------------------------------------------------------------------------------------------------
0N/A// Implementation of RuntimeStub
0N/A
0N/ARuntimeStub::RuntimeStub(
0N/A const char* name,
0N/A CodeBuffer* cb,
0N/A int size,
0N/A int frame_complete,
0N/A int frame_size,
0N/A OopMapSet* oop_maps,
0N/A bool caller_must_gc_arguments
0N/A)
0N/A: CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps)
0N/A{
0N/A _caller_must_gc_arguments = caller_must_gc_arguments;
0N/A}
0N/A
0N/A
0N/ARuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
0N/A CodeBuffer* cb,
0N/A int frame_complete,
0N/A int frame_size,
0N/A OopMapSet* oop_maps,
0N/A bool caller_must_gc_arguments)
0N/A{
0N/A RuntimeStub* stub = NULL;
0N/A ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
0N/A {
0N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
0N/A unsigned int size = allocation_size(cb, sizeof(RuntimeStub));
0N/A stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments);
0N/A }
0N/A
0N/A // Do not hold the CodeCache lock during name formatting.
0N/A if (stub != NULL) {
0N/A char stub_id[256];
0N/A jio_snprintf(stub_id, sizeof(stub_id), "RuntimeStub - %s", stub_name);
0N/A if (PrintStubCode) {
0N/A tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, stub);
0N/A Disassembler::decode(stub->instructions_begin(), stub->instructions_end());
0N/A }
0N/A VTune::register_stub(stub_id, stub->instructions_begin(), stub->instructions_end());
0N/A Forte::register_stub(stub_id, stub->instructions_begin(), stub->instructions_end());
0N/A
0N/A if (JvmtiExport::should_post_dynamic_code_generated()) {
0N/A JvmtiExport::post_dynamic_code_generated(stub_name, stub->instructions_begin(), stub->instructions_end());
0N/A }
0N/A }
0N/A
0N/A // Track memory usage statistic after releasing CodeCache_lock
0N/A MemoryService::track_code_cache_memory_usage();
0N/A
0N/A return stub;
0N/A}
0N/A
0N/A
0N/Avoid* RuntimeStub::operator new(size_t s, unsigned size) {
0N/A void* p = CodeCache::allocate(size);
0N/A if (!p) fatal("Initial size of CodeCache is too small");
0N/A return p;
0N/A}
0N/A
0N/A
0N/A//----------------------------------------------------------------------------------------------------
0N/A// Implementation of DeoptimizationBlob
0N/A
0N/ADeoptimizationBlob::DeoptimizationBlob(
0N/A CodeBuffer* cb,
0N/A int size,
0N/A OopMapSet* oop_maps,
0N/A int unpack_offset,
0N/A int unpack_with_exception_offset,
0N/A int unpack_with_reexecution_offset,
0N/A int frame_size
0N/A)
0N/A: SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps)
0N/A{
0N/A _unpack_offset = unpack_offset;
0N/A _unpack_with_exception = unpack_with_exception_offset;
0N/A _unpack_with_reexecution = unpack_with_reexecution_offset;
0N/A#ifdef COMPILER1
0N/A _unpack_with_exception_in_tls = -1;
0N/A#endif
0N/A}
0N/A
0N/A
0N/ADeoptimizationBlob* DeoptimizationBlob::create(
0N/A CodeBuffer* cb,
0N/A OopMapSet* oop_maps,
0N/A int unpack_offset,
0N/A int unpack_with_exception_offset,
0N/A int unpack_with_reexecution_offset,
0N/A int frame_size)
0N/A{
0N/A DeoptimizationBlob* blob = NULL;
0N/A ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
0N/A {
0N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
0N/A unsigned int size = allocation_size(cb, sizeof(DeoptimizationBlob));
0N/A blob = new (size) DeoptimizationBlob(cb,
0N/A size,
0N/A oop_maps,
0N/A unpack_offset,
0N/A unpack_with_exception_offset,
0N/A unpack_with_reexecution_offset,
0N/A frame_size);
0N/A }
0N/A
0N/A // Do not hold the CodeCache lock during name formatting.
0N/A if (blob != NULL) {
0N/A char blob_id[256];
0N/A jio_snprintf(blob_id, sizeof(blob_id), "DeoptimizationBlob@" PTR_FORMAT, blob->instructions_begin());
0N/A if (PrintStubCode) {
0N/A tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
0N/A Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
0N/A }
0N/A VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
0N/A Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
0N/A
0N/A if (JvmtiExport::should_post_dynamic_code_generated()) {
0N/A JvmtiExport::post_dynamic_code_generated("DeoptimizationBlob",
0N/A blob->instructions_begin(),
0N/A blob->instructions_end());
0N/A }
0N/A }
0N/A
0N/A // Track memory usage statistic after releasing CodeCache_lock
0N/A MemoryService::track_code_cache_memory_usage();
0N/A
0N/A return blob;
0N/A}
0N/A
0N/A
0N/Avoid* DeoptimizationBlob::operator new(size_t s, unsigned size) {
0N/A void* p = CodeCache::allocate(size);
0N/A if (!p) fatal("Initial size of CodeCache is too small");
0N/A return p;
0N/A}
0N/A
0N/A//----------------------------------------------------------------------------------------------------
0N/A// Implementation of UncommonTrapBlob
0N/A
0N/A#ifdef COMPILER2
0N/AUncommonTrapBlob::UncommonTrapBlob(
0N/A CodeBuffer* cb,
0N/A int size,
0N/A OopMapSet* oop_maps,
0N/A int frame_size
0N/A)
0N/A: SingletonBlob("UncommonTrapBlob", cb, sizeof(UncommonTrapBlob), size, frame_size, oop_maps)
0N/A{}
0N/A
0N/A
0N/AUncommonTrapBlob* UncommonTrapBlob::create(
0N/A CodeBuffer* cb,
0N/A OopMapSet* oop_maps,
0N/A int frame_size)
0N/A{
0N/A UncommonTrapBlob* blob = NULL;
0N/A ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
0N/A {
0N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
0N/A unsigned int size = allocation_size(cb, sizeof(UncommonTrapBlob));
0N/A blob = new (size) UncommonTrapBlob(cb, size, oop_maps, frame_size);
0N/A }
0N/A
0N/A // Do not hold the CodeCache lock during name formatting.
0N/A if (blob != NULL) {
0N/A char blob_id[256];
0N/A jio_snprintf(blob_id, sizeof(blob_id), "UncommonTrapBlob@" PTR_FORMAT, blob->instructions_begin());
0N/A if (PrintStubCode) {
0N/A tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
0N/A Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
0N/A }
0N/A VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
0N/A Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
0N/A
0N/A if (JvmtiExport::should_post_dynamic_code_generated()) {
0N/A JvmtiExport::post_dynamic_code_generated("UncommonTrapBlob",
0N/A blob->instructions_begin(),
0N/A blob->instructions_end());
0N/A }
0N/A }
0N/A
0N/A // Track memory usage statistic after releasing CodeCache_lock
0N/A MemoryService::track_code_cache_memory_usage();
0N/A
0N/A return blob;
0N/A}
0N/A
0N/A
0N/Avoid* UncommonTrapBlob::operator new(size_t s, unsigned size) {
0N/A void* p = CodeCache::allocate(size);
0N/A if (!p) fatal("Initial size of CodeCache is too small");
0N/A return p;
0N/A}
0N/A#endif // COMPILER2
0N/A
0N/A
0N/A//----------------------------------------------------------------------------------------------------
0N/A// Implementation of ExceptionBlob
0N/A
0N/A#ifdef COMPILER2
0N/AExceptionBlob::ExceptionBlob(
0N/A CodeBuffer* cb,
0N/A int size,
0N/A OopMapSet* oop_maps,
0N/A int frame_size
0N/A)
0N/A: SingletonBlob("ExceptionBlob", cb, sizeof(ExceptionBlob), size, frame_size, oop_maps)
0N/A{}
0N/A
0N/A
0N/AExceptionBlob* ExceptionBlob::create(
0N/A CodeBuffer* cb,
0N/A OopMapSet* oop_maps,
0N/A int frame_size)
0N/A{
0N/A ExceptionBlob* blob = NULL;
0N/A ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
0N/A {
0N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
0N/A unsigned int size = allocation_size(cb, sizeof(ExceptionBlob));
0N/A blob = new (size) ExceptionBlob(cb, size, oop_maps, frame_size);
0N/A }
0N/A
0N/A // We do not need to hold the CodeCache lock during name formatting
0N/A if (blob != NULL) {
0N/A char blob_id[256];
0N/A jio_snprintf(blob_id, sizeof(blob_id), "ExceptionBlob@" PTR_FORMAT, blob->instructions_begin());
0N/A if (PrintStubCode) {
0N/A tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
0N/A Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
0N/A }
0N/A VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
0N/A Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
0N/A
0N/A if (JvmtiExport::should_post_dynamic_code_generated()) {
0N/A JvmtiExport::post_dynamic_code_generated("ExceptionBlob",
0N/A blob->instructions_begin(),
0N/A blob->instructions_end());
0N/A }
0N/A }
0N/A
0N/A // Track memory usage statistic after releasing CodeCache_lock
0N/A MemoryService::track_code_cache_memory_usage();
0N/A
0N/A return blob;
0N/A}
0N/A
0N/A
0N/Avoid* ExceptionBlob::operator new(size_t s, unsigned size) {
0N/A void* p = CodeCache::allocate(size);
0N/A if (!p) fatal("Initial size of CodeCache is too small");
0N/A return p;
0N/A}
0N/A#endif // COMPILER2
0N/A
0N/A
0N/A//----------------------------------------------------------------------------------------------------
0N/A// Implementation of SafepointBlob
0N/A
0N/ASafepointBlob::SafepointBlob(
0N/A CodeBuffer* cb,
0N/A int size,
0N/A OopMapSet* oop_maps,
0N/A int frame_size
0N/A)
0N/A: SingletonBlob("SafepointBlob", cb, sizeof(SafepointBlob), size, frame_size, oop_maps)
0N/A{}
0N/A
0N/A
0N/ASafepointBlob* SafepointBlob::create(
0N/A CodeBuffer* cb,
0N/A OopMapSet* oop_maps,
0N/A int frame_size)
0N/A{
0N/A SafepointBlob* blob = NULL;
0N/A ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
0N/A {
0N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
0N/A unsigned int size = allocation_size(cb, sizeof(SafepointBlob));
0N/A blob = new (size) SafepointBlob(cb, size, oop_maps, frame_size);
0N/A }
0N/A
0N/A // We do not need to hold the CodeCache lock during name formatting.
0N/A if (blob != NULL) {
0N/A char blob_id[256];
0N/A jio_snprintf(blob_id, sizeof(blob_id), "SafepointBlob@" PTR_FORMAT, blob->instructions_begin());
0N/A if (PrintStubCode) {
0N/A tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
0N/A Disassembler::decode(blob->instructions_begin(), blob->instructions_end());
0N/A }
0N/A VTune::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
0N/A Forte::register_stub(blob_id, blob->instructions_begin(), blob->instructions_end());
0N/A
0N/A if (JvmtiExport::should_post_dynamic_code_generated()) {
0N/A JvmtiExport::post_dynamic_code_generated("SafepointBlob",
0N/A blob->instructions_begin(),
0N/A blob->instructions_end());
0N/A }
0N/A }
0N/A
0N/A // Track memory usage statistic after releasing CodeCache_lock
0N/A MemoryService::track_code_cache_memory_usage();
0N/A
0N/A return blob;
0N/A}
0N/A
0N/A
0N/Avoid* SafepointBlob::operator new(size_t s, unsigned size) {
0N/A void* p = CodeCache::allocate(size);
0N/A if (!p) fatal("Initial size of CodeCache is too small");
0N/A return p;
0N/A}
0N/A
0N/A
0N/A//----------------------------------------------------------------------------------------------------
0N/A// Verification and printing
0N/A
0N/Avoid CodeBlob::verify() {
0N/A ShouldNotReachHere();
0N/A}
0N/A
0N/A#ifndef PRODUCT
0N/A
0N/Avoid CodeBlob::print() const {
0N/A tty->print_cr("[CodeBlob (" INTPTR_FORMAT ")]", this);
0N/A tty->print_cr("Framesize: %d", _frame_size);
0N/A}
0N/A
0N/A
0N/Avoid CodeBlob::print_value_on(outputStream* st) const {
0N/A st->print_cr("[CodeBlob]");
0N/A}
0N/A
0N/A#endif
0N/A
0N/Avoid BufferBlob::verify() {
0N/A // unimplemented
0N/A}
0N/A
0N/A#ifndef PRODUCT
0N/A
0N/Avoid BufferBlob::print() const {
0N/A CodeBlob::print();
0N/A print_value_on(tty);
0N/A}
0N/A
0N/A
0N/Avoid BufferBlob::print_value_on(outputStream* st) const {
0N/A st->print_cr("BufferBlob (" INTPTR_FORMAT ") used for %s", this, name());
0N/A}
0N/A
0N/A
0N/A#endif
0N/A
0N/Avoid RuntimeStub::verify() {
0N/A // unimplemented
0N/A}
0N/A
0N/A#ifndef PRODUCT
0N/A
0N/Avoid RuntimeStub::print() const {
0N/A CodeBlob::print();
0N/A tty->print("Runtime Stub (" INTPTR_FORMAT "): ", this);
0N/A tty->print_cr(name());
0N/A Disassembler::decode((CodeBlob*)this);
0N/A}
0N/A
0N/A
0N/Avoid RuntimeStub::print_value_on(outputStream* st) const {
0N/A st->print("RuntimeStub (" INTPTR_FORMAT "): ", this); st->print(name());
0N/A}
0N/A
0N/A#endif
0N/A
0N/Avoid SingletonBlob::verify() {
0N/A // unimplemented
0N/A}
0N/A
0N/A#ifndef PRODUCT
0N/A
0N/Avoid SingletonBlob::print() const {
0N/A CodeBlob::print();
0N/A tty->print_cr(name());
0N/A Disassembler::decode((CodeBlob*)this);
0N/A}
0N/A
0N/A
0N/Avoid SingletonBlob::print_value_on(outputStream* st) const {
0N/A st->print_cr(name());
0N/A}
0N/A
0N/Avoid DeoptimizationBlob::print_value_on(outputStream* st) const {
0N/A st->print_cr("Deoptimization (frame not available)");
0N/A}
0N/A
0N/A#endif // PRODUCT