codeBlob.cpp revision 1682
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This code is free software; you can redistribute it and/or modify it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * under the terms of the GNU General Public License version 2 only, as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * published by the Free Software Foundation.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This code is distributed in the hope that it will be useful, but WITHOUT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * version 2 for more details (a copy is included in the LICENSE file that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * accompanied this code).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You should have received a copy of the GNU General Public License version
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2 along with this work; if not, write to the Free Software Foundation,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or visit www.oracle.com if you need additional information or have any
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * questions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# include "incls/_precompiled.incl"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# include "incls/_codeBlob.cpp.incl"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteunsigned int align_code_offset(int offset) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // align the size to CodeEntryAlignment
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((offset + (int)CodeHeap::header_size() + (CodeEntryAlignment-1)) & ~(CodeEntryAlignment-1))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte - (int)CodeHeap::header_size();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// This must be consistent with the CodeBlob constructor's layout actions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteunsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int size = header_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size += round_to(cb->total_relocation_size(), oopSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // align the size to CodeEntryAlignment
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = align_code_offset(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size += round_to(cb->total_content_size(), oopSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size += round_to(cb->total_oop_size(), oopSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Creates a simple CodeBlob. Sets up the size of the different regions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCodeBlob::CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(size == round_to(size, oopSize), "unaligned size");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(locs_size == round_to(locs_size, oopSize), "unaligned size");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(header_size == round_to(header_size, oopSize), "unaligned size");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(!UseRelocIndex, "no space allocated for reloc index yet");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Note: If UseRelocIndex is enabled, there needs to be (at least) one
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // extra word for the relocation information, containing the reloc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // index table length. Unfortunately, the reloc index table imple-
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // mentation is not easily understandable and thus it is not clear
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // what exactly the format is supposed to be. For now, we just turn
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // off the use of this table (gri 7/6/2000).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _name = name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _size = size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _frame_complete_offset = frame_complete;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _header_size = header_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _relocation_size = locs_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _content_offset = align_code_offset(header_size + _relocation_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _code_offset = _content_offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _data_offset = size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _frame_size = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte set_oop_maps(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Creates a CodeBlob from a CodeBuffer. Sets up the size of the different regions,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// and copy code and relocation info.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCodeBlob::CodeBlob(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char* name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int header_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_complete,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OopMapSet* oop_maps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(size == round_to(size, oopSize), "unaligned size");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(header_size == round_to(header_size, oopSize), "unaligned size");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _name = name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _size = size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _frame_complete_offset = frame_complete;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _header_size = header_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _relocation_size = round_to(cb->total_relocation_size(), oopSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _content_offset = align_code_offset(header_size + _relocation_size);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki _code_offset = _content_offset + cb->total_offset_of(cb->insts());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _data_offset = _content_offset + round_to(cb->total_content_size(), oopSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(_data_offset <= size, "codeBlob is too small");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cb->copy_code_and_locs_to(this);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte set_oop_maps(oop_maps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _frame_size = frame_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef COMPILER1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // probably wrong for tiered
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif // COMPILER1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid CodeBlob::set_oop_maps(OopMapSet* p) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Danger Will Robinson! This method allocates a big
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // chunk of memory, its your job to free it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // We need to allocate a chunk big enough to hold the OopMapSet and all of its OopMaps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _oop_maps = (OopMapSet* )NEW_C_HEAP_ARRAY(unsigned char, p->heap_size());
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki p->copy_to((address)_oop_maps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _oop_maps = NULL;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakkivoid CodeBlob::flush() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_oop_maps) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FREE_C_HEAP_ARRAY(unsigned char, _oop_maps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _oop_maps = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _comments.free();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOopMap* CodeBlob::oop_map_for_return_address(address return_address) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki assert(oop_maps() != NULL, "nope");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return oop_maps()->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte//----------------------------------------------------------------------------------------------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Implementation of BufferBlob
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBufferBlob::BufferBlob(const char* name, int size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte: CodeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya PrakkiBufferBlob* BufferBlob::create(const char* name, int buffer_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki BufferBlob* blob = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int size = sizeof(BufferBlob);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // align the size to CodeEntryAlignment
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = align_code_offset(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size += round_to(buffer_size, oopSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(name != NULL, "must provide a name");
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki blob = new (size) BufferBlob(name, size);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Track memory usage statistic after releasing CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MemoryService::track_code_cache_memory_usage();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return blob;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte : CodeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BufferBlob* blob = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int size = allocation_size(cb, sizeof(BufferBlob));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(name != NULL, "must provide a name");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte blob = new (size) BufferBlob(name, size, cb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Track memory usage statistic after releasing CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MemoryService::track_code_cache_memory_usage();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return blob;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid* BufferBlob::operator new(size_t s, unsigned size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void* p = CodeCache::allocate(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid BufferBlob::free( BufferBlob *blob ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeCache::free((CodeBlob*)blob);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki // Track memory usage statistic after releasing CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MemoryService::track_code_cache_memory_usage();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte//----------------------------------------------------------------------------------------------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Implementation of AdapterBlob
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAdapterBlob::AdapterBlob(int size, CodeBuffer* cb) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BufferBlob("I2C/C2I adapters", size, cb) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeCache::commit(this);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAdapterBlob* AdapterBlob::create(CodeBuffer* cb) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterBlob* blob = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int size = allocation_size(cb, sizeof(AdapterBlob));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte blob = new (size) AdapterBlob(size, cb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Track memory usage statistic after releasing CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MemoryService::track_code_cache_memory_usage();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return blob;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte//----------------------------------------------------------------------------------------------------
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki// Implementation of MethodHandlesAdapterBlob
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MethodHandlesAdapterBlob* blob = NULL;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki unsigned int size = sizeof(MethodHandlesAdapterBlob);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // align the size to CodeEntryAlignment
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = align_code_offset(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size += round_to(buffer_size, oopSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte blob = new (size) MethodHandlesAdapterBlob(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Track memory usage statistic after releasing CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MemoryService::track_code_cache_memory_usage();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return blob;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte//----------------------------------------------------------------------------------------------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Implementation of RuntimeStub
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRuntimeStub::RuntimeStub(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char* name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_complete,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki int frame_size,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki OopMapSet* oop_maps,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki bool caller_must_gc_arguments
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte: CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _caller_must_gc_arguments = caller_must_gc_arguments;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_complete,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OopMapSet* oop_maps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bool caller_must_gc_arguments)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RuntimeStub* stub = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int size = allocation_size(cb, sizeof(RuntimeStub));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Do not hold the CodeCache lock during name formatting.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stub != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char stub_id[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte jio_snprintf(stub_id, sizeof(stub_id), "RuntimeStub - %s", stub_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PrintStubCode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, stub);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki Disassembler::decode(stub->code_begin(), stub->code_end());
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (JvmtiExport::should_post_dynamic_code_generated()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte JvmtiExport::post_dynamic_code_generated(stub_name, stub->code_begin(), stub->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Track memory usage statistic after releasing CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MemoryService::track_code_cache_memory_usage();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return stub;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakkivoid* RuntimeStub::operator new(size_t s, unsigned size) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki void* p = CodeCache::allocate(size);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki if (!p) fatal("Initial size of CodeCache is too small");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte//----------------------------------------------------------------------------------------------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Implementation of DeoptimizationBlob
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDeoptimizationBlob::DeoptimizationBlob(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OopMapSet* oop_maps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int unpack_offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int unpack_with_exception_offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int unpack_with_reexecution_offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte: SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _unpack_offset = unpack_offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _unpack_with_exception = unpack_with_exception_offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _unpack_with_reexecution = unpack_with_reexecution_offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef COMPILER1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _unpack_with_exception_in_tls = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDeoptimizationBlob* DeoptimizationBlob::create(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki OopMapSet* oop_maps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int unpack_offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int unpack_with_exception_offset,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki int unpack_with_reexecution_offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DeoptimizationBlob* blob = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int size = allocation_size(cb, sizeof(DeoptimizationBlob));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte blob = new (size) DeoptimizationBlob(cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte oop_maps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unpack_offset,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki unpack_with_exception_offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unpack_with_reexecution_offset,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte frame_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Do not hold the CodeCache lock during name formatting.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (blob != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char blob_id[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte jio_snprintf(blob_id, sizeof(blob_id), "DeoptimizationBlob@" PTR_FORMAT, blob->code_begin());
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki if (PrintStubCode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Disassembler::decode(blob->code_begin(), blob->code_end());
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki }
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki Forte::register_stub(blob_id, blob->code_begin(), blob->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (JvmtiExport::should_post_dynamic_code_generated()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte JvmtiExport::post_dynamic_code_generated("DeoptimizationBlob", blob->code_begin(), blob->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki // Track memory usage statistic after releasing CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MemoryService::track_code_cache_memory_usage();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return blob;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid* DeoptimizationBlob::operator new(size_t s, unsigned size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void* p = CodeCache::allocate(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!p) fatal("Initial size of CodeCache is too small");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte//----------------------------------------------------------------------------------------------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Implementation of UncommonTrapBlob
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef COMPILER2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteUncommonTrapBlob::UncommonTrapBlob(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OopMapSet* oop_maps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte: SingletonBlob("UncommonTrapBlob", cb, sizeof(UncommonTrapBlob), size, frame_size, oop_maps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya PrakkiUncommonTrapBlob* UncommonTrapBlob::create(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OopMapSet* oop_maps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UncommonTrapBlob* blob = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki unsigned int size = allocation_size(cb, sizeof(UncommonTrapBlob));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte blob = new (size) UncommonTrapBlob(cb, size, oop_maps, frame_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki // Do not hold the CodeCache lock during name formatting.
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki if (blob != NULL) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki char blob_id[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte jio_snprintf(blob_id, sizeof(blob_id), "UncommonTrapBlob@" PTR_FORMAT, blob->code_begin());
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki if (PrintStubCode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Disassembler::decode(blob->code_begin(), blob->code_end());
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Forte::register_stub(blob_id, blob->code_begin(), blob->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (JvmtiExport::should_post_dynamic_code_generated()) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki JvmtiExport::post_dynamic_code_generated("UncommonTrapBlob", blob->code_begin(), blob->code_end());
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Track memory usage statistic after releasing CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MemoryService::track_code_cache_memory_usage();
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return blob;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid* UncommonTrapBlob::operator new(size_t s, unsigned size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void* p = CodeCache::allocate(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!p) fatal("Initial size of CodeCache is too small");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif // COMPILER2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte//----------------------------------------------------------------------------------------------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Implementation of ExceptionBlob
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef COMPILER2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteExceptionBlob::ExceptionBlob(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OopMapSet* oop_maps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte: SingletonBlob("ExceptionBlob", cb, sizeof(ExceptionBlob), size, frame_size, oop_maps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteExceptionBlob* ExceptionBlob::create(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OopMapSet* oop_maps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ExceptionBlob* blob = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int size = allocation_size(cb, sizeof(ExceptionBlob));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte blob = new (size) ExceptionBlob(cb, size, oop_maps, frame_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki // We do not need to hold the CodeCache lock during name formatting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (blob != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char blob_id[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte jio_snprintf(blob_id, sizeof(blob_id), "ExceptionBlob@" PTR_FORMAT, blob->code_begin());
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki if (PrintStubCode) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Disassembler::decode(blob->code_begin(), blob->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Forte::register_stub(blob_id, blob->code_begin(), blob->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (JvmtiExport::should_post_dynamic_code_generated()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte JvmtiExport::post_dynamic_code_generated("ExceptionBlob", blob->code_begin(), blob->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Track memory usage statistic after releasing CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MemoryService::track_code_cache_memory_usage();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return blob;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid* ExceptionBlob::operator new(size_t s, unsigned size) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki void* p = CodeCache::allocate(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!p) fatal("Initial size of CodeCache is too small");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif // COMPILER2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte//----------------------------------------------------------------------------------------------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Implementation of SafepointBlob
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSafepointBlob::SafepointBlob(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OopMapSet* oop_maps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte: SingletonBlob("SafepointBlob", cb, sizeof(SafepointBlob), size, frame_size, oop_maps)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSafepointBlob* SafepointBlob::create(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBuffer* cb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OopMapSet* oop_maps,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int frame_size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SafepointBlob* blob = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned int size = allocation_size(cb, sizeof(SafepointBlob));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte blob = new (size) SafepointBlob(cb, size, oop_maps, frame_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // We do not need to hold the CodeCache lock during name formatting.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (blob != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char blob_id[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte jio_snprintf(blob_id, sizeof(blob_id), "SafepointBlob@" PTR_FORMAT, blob->code_begin());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (PrintStubCode) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tty->print_cr("Decoding %s " INTPTR_FORMAT, blob_id, blob);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Disassembler::decode(blob->code_begin(), blob->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Forte::register_stub(blob_id, blob->code_begin(), blob->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (JvmtiExport::should_post_dynamic_code_generated()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte JvmtiExport::post_dynamic_code_generated("SafepointBlob", blob->code_begin(), blob->code_end());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Track memory usage statistic after releasing CodeCache_lock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MemoryService::track_code_cache_memory_usage();
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki return blob;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid* SafepointBlob::operator new(size_t s, unsigned size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void* p = CodeCache::allocate(size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!p) fatal("Initial size of CodeCache is too small");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte//----------------------------------------------------------------------------------------------------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Verification and printing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid CodeBlob::verify() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ShouldNotReachHere();
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki}
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid CodeBlob::print_on(outputStream* st) const {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st->print_cr("[CodeBlob (" INTPTR_FORMAT ")]", this);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st->print_cr("Framesize: %d", _frame_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid CodeBlob::print_value_on(outputStream* st) const {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st->print_cr("[CodeBlob]");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid BufferBlob::verify() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // unimplemented
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid BufferBlob::print_on(outputStream* st) const {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBlob::print_on(st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_value_on(st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid BufferBlob::print_value_on(outputStream* st) const {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st->print_cr("BufferBlob (" INTPTR_FORMAT ") used for %s", this, name());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid RuntimeStub::verify() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // unimplemented
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid RuntimeStub::print_on(outputStream* st) const {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBlob::print_on(st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st->print("Runtime Stub (" INTPTR_FORMAT "): ", this);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st->print_cr(name());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Disassembler::decode((CodeBlob*)this, st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid RuntimeStub::print_value_on(outputStream* st) const {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st->print("RuntimeStub (" INTPTR_FORMAT "): ", this); st->print(name());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid SingletonBlob::verify() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // unimplemented
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid SingletonBlob::print_on(outputStream* st) const {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CodeBlob::print_on(st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st->print_cr(name());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Disassembler::decode((CodeBlob*)this, st);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid SingletonBlob::print_value_on(outputStream* st) const {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st->print_cr(name());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid DeoptimizationBlob::print_value_on(outputStream* st) const {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte st->print_cr("Deoptimization (frame not available)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte