Path: blob/master/src/hotspot/share/code/codeBlob.cpp
40930 views
/*1* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "jvm.h"26#include "code/codeBlob.hpp"27#include "code/codeCache.hpp"28#include "code/icBuffer.hpp"29#include "code/relocInfo.hpp"30#include "code/vtableStubs.hpp"31#include "compiler/disassembler.hpp"32#include "compiler/oopMap.hpp"33#include "interpreter/bytecode.hpp"34#include "interpreter/interpreter.hpp"35#include "memory/allocation.inline.hpp"36#include "memory/heap.hpp"37#include "memory/resourceArea.hpp"38#include "oops/oop.inline.hpp"39#include "prims/forte.hpp"40#include "prims/jvmtiExport.hpp"41#include "runtime/handles.inline.hpp"42#include "runtime/interfaceSupport.inline.hpp"43#include "runtime/mutexLocker.hpp"44#include "runtime/safepoint.hpp"45#include "runtime/sharedRuntime.hpp"46#include "runtime/stubCodeGenerator.hpp"47#include "runtime/stubRoutines.hpp"48#include "runtime/vframe.hpp"49#include "services/memoryService.hpp"50#include "utilities/align.hpp"51#ifdef COMPILER152#include "c1/c1_Runtime1.hpp"53#endif5455const char* CodeBlob::compiler_name() const {56return compilertype2name(_type);57}5859unsigned int CodeBlob::align_code_offset(int offset) {60// align the size to CodeEntryAlignment61int header_size = (int)CodeHeap::header_size();62return align_up(offset + header_size, CodeEntryAlignment) - header_size;63}646566// This must be consistent with the CodeBlob constructor's layout actions.67unsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) {68unsigned int size = header_size;69size += align_up(cb->total_relocation_size(), oopSize);70// align the size to CodeEntryAlignment71size = align_code_offset(size);72size += align_up(cb->total_content_size(), oopSize);73size += align_up(cb->total_oop_size(), oopSize);74size += align_up(cb->total_metadata_size(), oopSize);75return size;76}7778CodeBlob::CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments) :79_type(type),80_size(layout.size()),81_header_size(layout.header_size()),82_frame_complete_offset(frame_complete_offset),83_data_offset(layout.data_offset()),84_frame_size(frame_size),85_code_begin(layout.code_begin()),86_code_end(layout.code_end()),87_content_begin(layout.content_begin()),88_data_end(layout.data_end()),89_relocation_begin(layout.relocation_begin()),90_relocation_end(layout.relocation_end()),91_oop_maps(oop_maps),92_caller_must_gc_arguments(caller_must_gc_arguments),93_name(name)94NOT_PRODUCT(COMMA _strings(CodeStrings()))95{96assert(is_aligned(layout.size(), oopSize), "unaligned size");97assert(is_aligned(layout.header_size(), oopSize), "unaligned size");98assert(is_aligned(layout.relocation_size(), oopSize), "unaligned size");99assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");100#ifdef COMPILER1101// probably wrong for tiered102assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");103#endif // COMPILER1104S390_ONLY(_ctable_offset = 0;) // avoid uninitialized fields105}106107CodeBlob::CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) :108_type(type),109_size(layout.size()),110_header_size(layout.header_size()),111_frame_complete_offset(frame_complete_offset),112_data_offset(layout.data_offset()),113_frame_size(frame_size),114_code_begin(layout.code_begin()),115_code_end(layout.code_end()),116_content_begin(layout.content_begin()),117_data_end(layout.data_end()),118_relocation_begin(layout.relocation_begin()),119_relocation_end(layout.relocation_end()),120_caller_must_gc_arguments(caller_must_gc_arguments),121_name(name)122NOT_PRODUCT(COMMA _strings(CodeStrings()))123{124assert(is_aligned(_size, oopSize), "unaligned size");125assert(is_aligned(_header_size, oopSize), "unaligned size");126assert(_data_offset <= _size, "codeBlob is too small");127assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");128129set_oop_maps(oop_maps);130#ifdef COMPILER1131// probably wrong for tiered132assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");133#endif // COMPILER1134S390_ONLY(_ctable_offset = 0;) // avoid uninitialized fields135}136137138// Creates a simple CodeBlob. Sets up the size of the different regions.139RuntimeBlob::RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size)140: CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */)141{142assert(is_aligned(locs_size, oopSize), "unaligned size");143}144145146// Creates a RuntimeBlob from a CodeBuffer147// and copy code and relocation info.148RuntimeBlob::RuntimeBlob(149const char* name,150CodeBuffer* cb,151int header_size,152int size,153int frame_complete,154int frame_size,155OopMapSet* oop_maps,156bool caller_must_gc_arguments157) : CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete, frame_size, oop_maps, caller_must_gc_arguments) {158cb->copy_code_and_locs_to(this);159}160161void CodeBlob::flush() {162FREE_C_HEAP_ARRAY(unsigned char, _oop_maps);163_oop_maps = NULL;164NOT_PRODUCT(_strings.free();)165}166167void CodeBlob::set_oop_maps(OopMapSet* p) {168// Danger Will Robinson! This method allocates a big169// chunk of memory, its your job to free it.170if (p != NULL) {171_oop_maps = ImmutableOopMapSet::build_from(p);172} else {173_oop_maps = NULL;174}175}176177178void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const char* name2) {179// Do not hold the CodeCache lock during name formatting.180assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub");181182if (stub != NULL) {183char stub_id[256];184assert(strlen(name1) + strlen(name2) < sizeof(stub_id), "");185jio_snprintf(stub_id, sizeof(stub_id), "%s%s", name1, name2);186if (PrintStubCode) {187ttyLocker ttyl;188tty->print_cr("- - - [BEGIN] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");189tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, (intptr_t) stub);190Disassembler::decode(stub->code_begin(), stub->code_end(), tty);191if ((stub->oop_maps() != NULL) && AbstractDisassembler::show_structs()) {192tty->print_cr("- - - [OOP MAPS]- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");193stub->oop_maps()->print();194}195tty->print_cr("- - - [END] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");196tty->cr();197}198Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());199200if (JvmtiExport::should_post_dynamic_code_generated()) {201const char* stub_name = name2;202if (name2[0] == '\0') stub_name = name1;203JvmtiExport::post_dynamic_code_generated(stub_name, stub->code_begin(), stub->code_end());204}205}206207// Track memory usage statistic after releasing CodeCache_lock208MemoryService::track_code_cache_memory_usage();209}210211const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) {212assert(_oop_maps != NULL, "nope");213return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());214}215216void CodeBlob::print_code() {217ResourceMark m;218Disassembler::decode(this, tty);219}220221//----------------------------------------------------------------------------------------------------222// Implementation of BufferBlob223224225BufferBlob::BufferBlob(const char* name, int size)226: RuntimeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0)227{}228229BufferBlob* BufferBlob::create(const char* name, int buffer_size) {230ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock231232BufferBlob* blob = NULL;233unsigned int size = sizeof(BufferBlob);234// align the size to CodeEntryAlignment235size = CodeBlob::align_code_offset(size);236size += align_up(buffer_size, oopSize);237assert(name != NULL, "must provide a name");238{239MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);240blob = new (size) BufferBlob(name, size);241}242// Track memory usage statistic after releasing CodeCache_lock243MemoryService::track_code_cache_memory_usage();244245return blob;246}247248249BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb)250: RuntimeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL)251{}252253BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) {254ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock255256BufferBlob* blob = NULL;257unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferBlob));258assert(name != NULL, "must provide a name");259{260MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);261blob = new (size) BufferBlob(name, size, cb);262}263// Track memory usage statistic after releasing CodeCache_lock264MemoryService::track_code_cache_memory_usage();265266return blob;267}268269void* BufferBlob::operator new(size_t s, unsigned size) throw() {270return CodeCache::allocate(size, CodeBlobType::NonNMethod);271}272273void BufferBlob::free(BufferBlob *blob) {274assert(blob != NULL, "caller must check for NULL");275ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock276blob->flush();277{278MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);279CodeCache::free((RuntimeBlob*)blob);280}281// Track memory usage statistic after releasing CodeCache_lock282MemoryService::track_code_cache_memory_usage();283}284285286//----------------------------------------------------------------------------------------------------287// Implementation of AdapterBlob288289AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) :290BufferBlob("I2C/C2I adapters", size, cb) {291CodeCache::commit(this);292}293294AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {295ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock296297AdapterBlob* blob = NULL;298unsigned int size = CodeBlob::allocation_size(cb, sizeof(AdapterBlob));299{300MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);301blob = new (size) AdapterBlob(size, cb);302}303// Track memory usage statistic after releasing CodeCache_lock304MemoryService::track_code_cache_memory_usage();305306return blob;307}308309void* VtableBlob::operator new(size_t s, unsigned size) throw() {310// Handling of allocation failure stops compilation and prints a bunch of311// stuff, which requires unlocking the CodeCache_lock, so that the Compile_lock312// can be locked, and then re-locking the CodeCache_lock. That is not safe in313// this context as we hold the CompiledICLocker. So we just don't handle code314// cache exhaustion here; we leave that for a later allocation that does not315// hold the CompiledICLocker.316return CodeCache::allocate(size, CodeBlobType::NonNMethod, false /* handle_alloc_failure */);317}318319VtableBlob::VtableBlob(const char* name, int size) :320BufferBlob(name, size) {321}322323VtableBlob* VtableBlob::create(const char* name, int buffer_size) {324assert(JavaThread::current()->thread_state() == _thread_in_vm, "called with the wrong state");325326VtableBlob* blob = NULL;327unsigned int size = sizeof(VtableBlob);328// align the size to CodeEntryAlignment329size = align_code_offset(size);330size += align_up(buffer_size, oopSize);331assert(name != NULL, "must provide a name");332{333if (!CodeCache_lock->try_lock()) {334// If we can't take the CodeCache_lock, then this is a bad time to perform the ongoing335// IC transition to megamorphic, for which this stub will be needed. It is better to336// bail out the transition, and wait for a more opportune moment. Not only is it not337// worth waiting for the lock blockingly for the megamorphic transition, it might338// also result in a deadlock to blockingly wait, when concurrent class unloading is339// performed. At this point in time, the CompiledICLocker is taken, so we are not340// allowed to blockingly wait for the CodeCache_lock, as these two locks are otherwise341// consistently taken in the opposite order. Bailing out results in an IC transition to342// the clean state instead, which will cause subsequent calls to retry the transitioning343// eventually.344return NULL;345}346blob = new (size) VtableBlob(name, size);347CodeCache_lock->unlock();348}349// Track memory usage statistic after releasing CodeCache_lock350MemoryService::track_code_cache_memory_usage();351352return blob;353}354355//----------------------------------------------------------------------------------------------------356// Implementation of MethodHandlesAdapterBlob357358MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) {359ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock360361MethodHandlesAdapterBlob* blob = NULL;362unsigned int size = sizeof(MethodHandlesAdapterBlob);363// align the size to CodeEntryAlignment364size = CodeBlob::align_code_offset(size);365size += align_up(buffer_size, oopSize);366{367MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);368blob = new (size) MethodHandlesAdapterBlob(size);369if (blob == NULL) {370vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for method handle adapter blob");371}372}373// Track memory usage statistic after releasing CodeCache_lock374MemoryService::track_code_cache_memory_usage();375376return blob;377}378379//----------------------------------------------------------------------------------------------------380// Implementation of RuntimeStub381382RuntimeStub::RuntimeStub(383const char* name,384CodeBuffer* cb,385int size,386int frame_complete,387int frame_size,388OopMapSet* oop_maps,389bool caller_must_gc_arguments390)391: RuntimeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments)392{393}394395RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,396CodeBuffer* cb,397int frame_complete,398int frame_size,399OopMapSet* oop_maps,400bool caller_must_gc_arguments)401{402RuntimeStub* stub = NULL;403ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock404{405MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);406unsigned int size = CodeBlob::allocation_size(cb, sizeof(RuntimeStub));407stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments);408}409410trace_new_stub(stub, "RuntimeStub - ", stub_name);411412return stub;413}414415416void* RuntimeStub::operator new(size_t s, unsigned size) throw() {417void* p = CodeCache::allocate(size, CodeBlobType::NonNMethod);418if (!p) fatal("Initial size of CodeCache is too small");419return p;420}421422// operator new shared by all singletons:423void* SingletonBlob::operator new(size_t s, unsigned size) throw() {424void* p = CodeCache::allocate(size, CodeBlobType::NonNMethod);425if (!p) fatal("Initial size of CodeCache is too small");426return p;427}428429430//----------------------------------------------------------------------------------------------------431// Implementation of DeoptimizationBlob432433DeoptimizationBlob::DeoptimizationBlob(434CodeBuffer* cb,435int size,436OopMapSet* oop_maps,437int unpack_offset,438int unpack_with_exception_offset,439int unpack_with_reexecution_offset,440int frame_size441)442: SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps)443{444_unpack_offset = unpack_offset;445_unpack_with_exception = unpack_with_exception_offset;446_unpack_with_reexecution = unpack_with_reexecution_offset;447#ifdef COMPILER1448_unpack_with_exception_in_tls = -1;449#endif450}451452453DeoptimizationBlob* DeoptimizationBlob::create(454CodeBuffer* cb,455OopMapSet* oop_maps,456int unpack_offset,457int unpack_with_exception_offset,458int unpack_with_reexecution_offset,459int frame_size)460{461DeoptimizationBlob* blob = NULL;462ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock463{464MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);465unsigned int size = CodeBlob::allocation_size(cb, sizeof(DeoptimizationBlob));466blob = new (size) DeoptimizationBlob(cb,467size,468oop_maps,469unpack_offset,470unpack_with_exception_offset,471unpack_with_reexecution_offset,472frame_size);473}474475trace_new_stub(blob, "DeoptimizationBlob");476477return blob;478}479480481//----------------------------------------------------------------------------------------------------482// Implementation of UncommonTrapBlob483484#ifdef COMPILER2485UncommonTrapBlob::UncommonTrapBlob(486CodeBuffer* cb,487int size,488OopMapSet* oop_maps,489int frame_size490)491: SingletonBlob("UncommonTrapBlob", cb, sizeof(UncommonTrapBlob), size, frame_size, oop_maps)492{}493494495UncommonTrapBlob* UncommonTrapBlob::create(496CodeBuffer* cb,497OopMapSet* oop_maps,498int frame_size)499{500UncommonTrapBlob* blob = NULL;501ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock502{503MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);504unsigned int size = CodeBlob::allocation_size(cb, sizeof(UncommonTrapBlob));505blob = new (size) UncommonTrapBlob(cb, size, oop_maps, frame_size);506}507508trace_new_stub(blob, "UncommonTrapBlob");509510return blob;511}512513514#endif // COMPILER2515516517//----------------------------------------------------------------------------------------------------518// Implementation of ExceptionBlob519520#ifdef COMPILER2521ExceptionBlob::ExceptionBlob(522CodeBuffer* cb,523int size,524OopMapSet* oop_maps,525int frame_size526)527: SingletonBlob("ExceptionBlob", cb, sizeof(ExceptionBlob), size, frame_size, oop_maps)528{}529530531ExceptionBlob* ExceptionBlob::create(532CodeBuffer* cb,533OopMapSet* oop_maps,534int frame_size)535{536ExceptionBlob* blob = NULL;537ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock538{539MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);540unsigned int size = CodeBlob::allocation_size(cb, sizeof(ExceptionBlob));541blob = new (size) ExceptionBlob(cb, size, oop_maps, frame_size);542}543544trace_new_stub(blob, "ExceptionBlob");545546return blob;547}548549550#endif // COMPILER2551552553//----------------------------------------------------------------------------------------------------554// Implementation of SafepointBlob555556SafepointBlob::SafepointBlob(557CodeBuffer* cb,558int size,559OopMapSet* oop_maps,560int frame_size561)562: SingletonBlob("SafepointBlob", cb, sizeof(SafepointBlob), size, frame_size, oop_maps)563{}564565566SafepointBlob* SafepointBlob::create(567CodeBuffer* cb,568OopMapSet* oop_maps,569int frame_size)570{571SafepointBlob* blob = NULL;572ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock573{574MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);575unsigned int size = CodeBlob::allocation_size(cb, sizeof(SafepointBlob));576blob = new (size) SafepointBlob(cb, size, oop_maps, frame_size);577}578579trace_new_stub(blob, "SafepointBlob");580581return blob;582}583584585//----------------------------------------------------------------------------------------------------586// Verification and printing587588void CodeBlob::print_on(outputStream* st) const {589st->print_cr("[CodeBlob (" INTPTR_FORMAT ")]", p2i(this));590st->print_cr("Framesize: %d", _frame_size);591}592593void CodeBlob::print() const { print_on(tty); }594595void CodeBlob::print_value_on(outputStream* st) const {596st->print_cr("[CodeBlob]");597}598599void CodeBlob::dump_for_addr(address addr, outputStream* st, bool verbose) const {600if (is_buffer_blob()) {601// the interpreter is generated into a buffer blob602InterpreterCodelet* i = Interpreter::codelet_containing(addr);603if (i != NULL) {604st->print_cr(INTPTR_FORMAT " is at code_begin+%d in an Interpreter codelet", p2i(addr), (int)(addr - i->code_begin()));605i->print_on(st);606return;607}608if (Interpreter::contains(addr)) {609st->print_cr(INTPTR_FORMAT " is pointing into interpreter code"610" (not bytecode specific)", p2i(addr));611return;612}613//614if (AdapterHandlerLibrary::contains(this)) {615st->print_cr(INTPTR_FORMAT " is at code_begin+%d in an AdapterHandler", p2i(addr), (int)(addr - code_begin()));616AdapterHandlerLibrary::print_handler_on(st, this);617}618// the stubroutines are generated into a buffer blob619StubCodeDesc* d = StubCodeDesc::desc_for(addr);620if (d != NULL) {621st->print_cr(INTPTR_FORMAT " is at begin+%d in a stub", p2i(addr), (int)(addr - d->begin()));622d->print_on(st);623st->cr();624return;625}626if (StubRoutines::contains(addr)) {627st->print_cr(INTPTR_FORMAT " is pointing to an (unnamed) stub routine", p2i(addr));628return;629}630// the InlineCacheBuffer is using stubs generated into a buffer blob631if (InlineCacheBuffer::contains(addr)) {632st->print_cr(INTPTR_FORMAT " is pointing into InlineCacheBuffer", p2i(addr));633return;634}635VtableStub* v = VtableStubs::stub_containing(addr);636if (v != NULL) {637st->print_cr(INTPTR_FORMAT " is at entry_point+%d in a vtable stub", p2i(addr), (int)(addr - v->entry_point()));638v->print_on(st);639st->cr();640return;641}642}643if (is_nmethod()) {644nmethod* nm = (nmethod*)this;645ResourceMark rm;646st->print(INTPTR_FORMAT " is at entry_point+%d in (nmethod*)" INTPTR_FORMAT,647p2i(addr), (int)(addr - nm->entry_point()), p2i(nm));648if (verbose) {649st->print(" for ");650nm->method()->print_value_on(st);651}652st->cr();653nm->print_nmethod(verbose);654return;655}656st->print_cr(INTPTR_FORMAT " is at code_begin+%d in ", p2i(addr), (int)(addr - code_begin()));657print_on(st);658}659660void RuntimeBlob::verify() {661ShouldNotReachHere();662}663664void BufferBlob::verify() {665// unimplemented666}667668void BufferBlob::print_on(outputStream* st) const {669RuntimeBlob::print_on(st);670print_value_on(st);671}672673void BufferBlob::print_value_on(outputStream* st) const {674st->print_cr("BufferBlob (" INTPTR_FORMAT ") used for %s", p2i(this), name());675}676677void RuntimeStub::verify() {678// unimplemented679}680681void RuntimeStub::print_on(outputStream* st) const {682ttyLocker ttyl;683RuntimeBlob::print_on(st);684st->print("Runtime Stub (" INTPTR_FORMAT "): ", p2i(this));685st->print_cr("%s", name());686Disassembler::decode((RuntimeBlob*)this, st);687}688689void RuntimeStub::print_value_on(outputStream* st) const {690st->print("RuntimeStub (" INTPTR_FORMAT "): ", p2i(this)); st->print("%s", name());691}692693void SingletonBlob::verify() {694// unimplemented695}696697void SingletonBlob::print_on(outputStream* st) const {698ttyLocker ttyl;699RuntimeBlob::print_on(st);700st->print_cr("%s", name());701Disassembler::decode((RuntimeBlob*)this, st);702}703704void SingletonBlob::print_value_on(outputStream* st) const {705st->print_cr("%s", name());706}707708void DeoptimizationBlob::print_value_on(outputStream* st) const {709st->print_cr("Deoptimization (frame not available)");710}711712// Implementation of OptimizedEntryBlob713714OptimizedEntryBlob::OptimizedEntryBlob(const char* name, int size, CodeBuffer* cb, intptr_t exception_handler_offset,715jobject receiver, ByteSize jfa_sp_offset) :716BufferBlob(name, size, cb),717_exception_handler_offset(exception_handler_offset),718_receiver(receiver),719_jfa_sp_offset(jfa_sp_offset) {720CodeCache::commit(this);721}722723OptimizedEntryBlob* OptimizedEntryBlob::create(const char* name, CodeBuffer* cb, intptr_t exception_handler_offset,724jobject receiver, ByteSize jfa_sp_offset) {725ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock726727OptimizedEntryBlob* blob = nullptr;728unsigned int size = CodeBlob::allocation_size(cb, sizeof(OptimizedEntryBlob));729{730MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);731blob = new (size) OptimizedEntryBlob(name, size, cb, exception_handler_offset, receiver, jfa_sp_offset);732}733// Track memory usage statistic after releasing CodeCache_lock734MemoryService::track_code_cache_memory_usage();735736return blob;737}738739740