Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/code/icBuffer.hpp
32285 views
/*1* Copyright (c) 1997, 2013, 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#ifndef SHARE_VM_CODE_ICBUFFER_HPP25#define SHARE_VM_CODE_ICBUFFER_HPP2627#include "asm/codeBuffer.hpp"28#include "code/stubs.hpp"29#include "interpreter/bytecodes.hpp"30#include "memory/allocation.hpp"3132//33// For CompiledIC's:34//35// In cases where we do not have MT-safe state transformation,36// we go to a transition state, using ICStubs. At a safepoint,37// the inline caches are transferred from the transitional code:38//39// instruction_address --> 01 set xxx_oop, Ginline_cache_klass40// 23 jump_to Gtemp, yyyy41// 4 nop4243class ICStub: public Stub {44private:45int _size; // total size of the stub incl. code46address _ic_site; // points at call instruction of owning ic-buffer47/* stub code follows here */48protected:49friend class ICStubInterface;50// This will be called only by ICStubInterface51void initialize(int size,52CodeStrings strings) { _size = size; _ic_site = NULL; }53void finalize(); // called when a method is removed5455// General info56int size() const { return _size; }57static int code_size_to_size(int code_size) { return round_to(sizeof(ICStub), CodeEntryAlignment) + code_size; }5859public:60// Creation61void set_stub(CompiledIC *ic, void* cached_value, address dest_addr);6263// Code info64address code_begin() const { return (address)this + round_to(sizeof(ICStub), CodeEntryAlignment); }65address code_end() const { return (address)this + size(); }6667// Call site info68address ic_site() const { return _ic_site; }69void clear();70bool is_empty() const { return _ic_site == NULL; }7172// stub info73address destination() const; // destination of jump instruction74void* cached_value() const; // cached_value for stub7576// Debugging77void verify() PRODUCT_RETURN;78void print() PRODUCT_RETURN;7980// Creation81friend ICStub* ICStub_from_destination_address(address destination_address);82};8384// ICStub Creation85inline ICStub* ICStub_from_destination_address(address destination_address) {86ICStub* stub = (ICStub*) (destination_address - round_to(sizeof(ICStub), CodeEntryAlignment));87#ifdef ASSERT88stub->verify();89#endif90return stub;91}9293class InlineCacheBuffer: public AllStatic {94private:95// friends96friend class ICStub;9798static int ic_stub_code_size();99100static StubQueue* _buffer;101static ICStub* _next_stub;102103static CompiledICHolder* _pending_released;104static int _pending_count;105106static StubQueue* buffer() { return _buffer; }107static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; }108static ICStub* get_next_stub() { return _next_stub; }109110static void init_next_stub();111112static ICStub* new_ic_stub();113114115// Machine-dependent implementation of ICBuffer116static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);117static address ic_buffer_entry_point (address code_begin);118static void* ic_buffer_cached_value (address code_begin);119120public:121122// Initialization; must be called before first usage123static void initialize();124125// Access126static bool contains(address instruction_address);127128// removes the ICStubs after backpatching129static void update_inline_caches();130131// for debugging132static bool is_empty();133134static void release_pending_icholders();135static void queue_for_release(CompiledICHolder* icholder);136static int pending_icholder_count() { return _pending_count; }137138// New interface139static void create_transition_stub(CompiledIC *ic, void* cached_value, address entry);140static address ic_destination_for(CompiledIC *ic);141static void* cached_value_for(CompiledIC *ic);142};143144#endif // SHARE_VM_CODE_ICBUFFER_HPP145146147