2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2018-12-07 13:15:35 +01:00
|
|
|
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#ifndef SHARE_VM_CODE_ICBUFFER_HPP
|
|
|
|
#define SHARE_VM_CODE_ICBUFFER_HPP
|
|
|
|
|
2012-09-24 10:30:14 -07:00
|
|
|
#include "asm/codeBuffer.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "code/stubs.hpp"
|
|
|
|
#include "interpreter/bytecodes.hpp"
|
|
|
|
#include "memory/allocation.hpp"
|
2018-12-07 13:15:35 +01:00
|
|
|
#include "runtime/safepointVerifiers.hpp"
|
2017-07-05 11:33:17 +02:00
|
|
|
#include "utilities/align.hpp"
|
2018-12-07 13:15:35 +01:00
|
|
|
#include "utilities/debug.hpp"
|
2018-12-05 15:57:26 +01:00
|
|
|
#include "utilities/macros.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
//
|
|
|
|
// For CompiledIC's:
|
|
|
|
//
|
|
|
|
// In cases where we do not have MT-safe state transformation,
|
|
|
|
// we go to a transition state, using ICStubs. At a safepoint,
|
|
|
|
// the inline caches are transferred from the transitional code:
|
|
|
|
//
|
|
|
|
// instruction_address --> 01 set xxx_oop, Ginline_cache_klass
|
|
|
|
// 23 jump_to Gtemp, yyyy
|
|
|
|
// 4 nop
|
|
|
|
|
|
|
|
class ICStub: public Stub {
|
|
|
|
private:
|
|
|
|
int _size; // total size of the stub incl. code
|
|
|
|
address _ic_site; // points at call instruction of owning ic-buffer
|
|
|
|
/* stub code follows here */
|
|
|
|
protected:
|
|
|
|
friend class ICStubInterface;
|
|
|
|
// This will be called only by ICStubInterface
|
2012-09-24 10:30:14 -07:00
|
|
|
void initialize(int size,
|
2013-03-18 13:19:06 +01:00
|
|
|
CodeStrings strings) { _size = size; _ic_site = NULL; }
|
2007-12-01 00:00:00 +00:00
|
|
|
void finalize(); // called when a method is removed
|
|
|
|
|
|
|
|
// General info
|
|
|
|
int size() const { return _size; }
|
2017-04-13 09:57:51 +02:00
|
|
|
static int code_size_to_size(int code_size) { return align_up((int)sizeof(ICStub), CodeEntryAlignment) + code_size; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Creation
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void set_stub(CompiledIC *ic, void* cached_value, address dest_addr);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Code info
|
2017-04-13 09:57:51 +02:00
|
|
|
address code_begin() const { return (address)this + align_up(sizeof(ICStub), CodeEntryAlignment); }
|
2007-12-01 00:00:00 +00:00
|
|
|
address code_end() const { return (address)this + size(); }
|
|
|
|
|
|
|
|
// Call site info
|
|
|
|
address ic_site() const { return _ic_site; }
|
|
|
|
void clear();
|
|
|
|
bool is_empty() const { return _ic_site == NULL; }
|
|
|
|
|
|
|
|
// stub info
|
|
|
|
address destination() const; // destination of jump instruction
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void* cached_value() const; // cached_value for stub
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Debugging
|
|
|
|
void verify() PRODUCT_RETURN;
|
|
|
|
void print() PRODUCT_RETURN;
|
|
|
|
|
|
|
|
// Creation
|
|
|
|
friend ICStub* ICStub_from_destination_address(address destination_address);
|
|
|
|
};
|
|
|
|
|
|
|
|
// ICStub Creation
|
|
|
|
inline ICStub* ICStub_from_destination_address(address destination_address) {
|
2017-04-13 09:57:51 +02:00
|
|
|
ICStub* stub = (ICStub*) (destination_address - align_up(sizeof(ICStub), CodeEntryAlignment));
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifdef ASSERT
|
|
|
|
stub->verify();
|
|
|
|
#endif
|
|
|
|
return stub;
|
|
|
|
}
|
|
|
|
|
2018-12-07 13:15:35 +01:00
|
|
|
#ifdef ASSERT
|
|
|
|
// The ICRefillVerifier class is a stack allocated RAII object used to
|
|
|
|
// detect if a failed IC transition that required IC stub refilling has
|
|
|
|
// been accidentally missed. It is up to the caller to in that case
|
|
|
|
// refill IC stubs.
|
|
|
|
class ICRefillVerifier: StackObj {
|
|
|
|
bool _refill_requested;
|
|
|
|
bool _refill_remembered;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ICRefillVerifier();
|
|
|
|
~ICRefillVerifier();
|
|
|
|
|
|
|
|
void request_refill() { _refill_requested = true; }
|
|
|
|
void request_remembered() { _refill_remembered = true; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// The ICRefillVerifierMark is used to set the thread's current
|
|
|
|
// ICRefillVerifier to a provided one. This is useful in particular
|
|
|
|
// when transitioning IC stubs in parallel and refilling from the
|
|
|
|
// master thread invoking the IC stub transitioning code.
|
|
|
|
class ICRefillVerifierMark: StackObj {
|
|
|
|
public:
|
|
|
|
ICRefillVerifierMark(ICRefillVerifier* verifier);
|
|
|
|
~ICRefillVerifierMark();
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
class ICRefillVerifier: StackObj {
|
|
|
|
public:
|
|
|
|
ICRefillVerifier() {}
|
|
|
|
};
|
|
|
|
class ICRefillVerifierMark: StackObj {
|
|
|
|
public:
|
|
|
|
ICRefillVerifierMark(ICRefillVerifier* verifier) {}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
class InlineCacheBuffer: public AllStatic {
|
|
|
|
private:
|
|
|
|
// friends
|
|
|
|
friend class ICStub;
|
|
|
|
|
|
|
|
static int ic_stub_code_size();
|
|
|
|
|
|
|
|
static StubQueue* _buffer;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
static CompiledICHolder* _pending_released;
|
|
|
|
static int _pending_count;
|
|
|
|
|
2018-12-05 15:57:26 +01:00
|
|
|
static StubQueue* buffer() { return _buffer; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
static ICStub* new_ic_stub();
|
|
|
|
|
|
|
|
// Machine-dependent implementation of ICBuffer
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);
|
2007-12-01 00:00:00 +00:00
|
|
|
static address ic_buffer_entry_point (address code_begin);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
static void* ic_buffer_cached_value (address code_begin);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Initialization; must be called before first usage
|
|
|
|
static void initialize();
|
|
|
|
|
|
|
|
// Access
|
|
|
|
static bool contains(address instruction_address);
|
|
|
|
|
|
|
|
// removes the ICStubs after backpatching
|
|
|
|
static void update_inline_caches();
|
2018-12-05 15:57:26 +01:00
|
|
|
static void refill_ic_stubs();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// for debugging
|
|
|
|
static bool is_empty();
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
static void release_pending_icholders();
|
|
|
|
static void queue_for_release(CompiledICHolder* icholder);
|
|
|
|
static int pending_icholder_count() { return _pending_count; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// New interface
|
2018-12-05 15:57:26 +01:00
|
|
|
static bool create_transition_stub(CompiledIC *ic, void* cached_value, address entry);
|
2007-12-01 00:00:00 +00:00
|
|
|
static address ic_destination_for(CompiledIC *ic);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
static void* cached_value_for(CompiledIC *ic);
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
2010-11-23 13:22:55 -08:00
|
|
|
|
|
|
|
#endif // SHARE_VM_CODE_ICBUFFER_HPP
|