8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library

Reviewed-by: dnsimon, never, stefank, rehn, neliasso, dholmes, kbarrett, coleenp
This commit is contained in:
Vladimir Kozlov 2019-05-01 12:31:29 -07:00
parent f9bbbb6e27
commit e9c523ae5f
173 changed files with 12881 additions and 5297 deletions

View file

@ -51,37 +51,28 @@ class DebugInformationRecorder;
// - handler entry point array
// [Implicit Null Pointer exception table]
// - implicit null table array
// [Speculations]
// - encoded speculations array
// [JVMCINMethodData]
// - meta data for JVMCI compiled nmethod
#if INCLUDE_JVMCI
class FailedSpeculation;
class JVMCINMethodData;
#endif
class nmethod : public CompiledMethod {
friend class VMStructs;
friend class JVMCIVMStructs;
friend class NMethodSweeper;
friend class CodeCache; // scavengable oops
friend class JVMCINMethodData;
private:
// Shared fields for all nmethod's
int _entry_bci; // != InvocationEntryBci if this nmethod is an on-stack replacement method
jmethodID _jmethod_id; // Cache of method()->jmethod_id()
#if INCLUDE_JVMCI
// A weak reference to an InstalledCode object associated with
// this nmethod.
jweak _jvmci_installed_code;
// A weak reference to a SpeculationLog object associated with
// this nmethod.
jweak _speculation_log;
// Determines whether this nmethod is unloaded when the
// referent in _jvmci_installed_code is cleared. This
// will be false if the referent is initialized to a
// HotSpotNMethod object whose isDefault field is true.
// That is, installed code other than a "default"
// HotSpotNMethod causes nmethod unloading.
// This field is ignored once _jvmci_installed_code is NULL.
bool _jvmci_installed_code_triggers_invalidation;
#endif
// To support simple linked-list chaining of nmethods:
nmethod* _osr_link; // from InstanceKlass::osr_nmethods_head
@ -107,6 +98,10 @@ class nmethod : public CompiledMethod {
int _dependencies_offset;
int _handler_table_offset;
int _nul_chk_table_offset;
#if INCLUDE_JVMCI
int _speculations_offset;
int _jvmci_data_offset;
#endif
int _nmethod_end_offset;
int code_offset() const { return (address) code_begin() - header_begin(); }
@ -207,8 +202,9 @@ class nmethod : public CompiledMethod {
AbstractCompiler* compiler,
int comp_level
#if INCLUDE_JVMCI
, jweak installed_code,
jweak speculation_log
, char* speculations,
int speculations_len,
int jvmci_data_size
#endif
);
@ -251,8 +247,11 @@ class nmethod : public CompiledMethod {
AbstractCompiler* compiler,
int comp_level
#if INCLUDE_JVMCI
, jweak installed_code = NULL,
jweak speculation_log = NULL
, char* speculations = NULL,
int speculations_len = 0,
int nmethod_mirror_index = -1,
const char* nmethod_mirror_name = NULL,
FailedSpeculation** failed_speculations = NULL
#endif
);
@ -299,12 +298,24 @@ class nmethod : public CompiledMethod {
address handler_table_begin () const { return header_begin() + _handler_table_offset ; }
address handler_table_end () const { return header_begin() + _nul_chk_table_offset ; }
address nul_chk_table_begin () const { return header_begin() + _nul_chk_table_offset ; }
#if INCLUDE_JVMCI
address nul_chk_table_end () const { return header_begin() + _speculations_offset ; }
address speculations_begin () const { return header_begin() + _speculations_offset ; }
address speculations_end () const { return header_begin() + _jvmci_data_offset ; }
address jvmci_data_begin () const { return header_begin() + _jvmci_data_offset ; }
address jvmci_data_end () const { return header_begin() + _nmethod_end_offset ; }
#else
address nul_chk_table_end () const { return header_begin() + _nmethod_end_offset ; }
#endif
// Sizes
int oops_size () const { return (address) oops_end () - (address) oops_begin (); }
int metadata_size () const { return (address) metadata_end () - (address) metadata_begin (); }
int dependencies_size () const { return dependencies_end () - dependencies_begin (); }
#if INCLUDE_JVMCI
int speculations_size () const { return speculations_end () - speculations_begin (); }
int jvmci_data_size () const { return jvmci_data_end () - jvmci_data_begin (); }
#endif
int oops_count() const { assert(oops_size() % oopSize == 0, ""); return (oops_size() / oopSize) + 1; }
int metadata_count() const { assert(metadata_size() % wordSize == 0, ""); return (metadata_size() / wordSize) + 1; }
@ -446,39 +457,19 @@ public:
void set_method(Method* method) { _method = method; }
#if INCLUDE_JVMCI
// Gets the InstalledCode object associated with this nmethod
// which may be NULL if this nmethod was not compiled by JVMCI
// or the weak reference has been cleared.
oop jvmci_installed_code();
// Gets the JVMCI name of this nmethod.
const char* jvmci_name();
// Copies the value of the name field in the InstalledCode
// object (if any) associated with this nmethod into buf.
// Returns the value of buf if it was updated otherwise NULL.
char* jvmci_installed_code_name(char* buf, size_t buflen) const;
// Records the pending failed speculation in the
// JVMCI speculation log associated with this nmethod.
void update_speculation(JavaThread* thread);
// Updates the state of the InstalledCode (if any) associated with
// this nmethod based on the current value of _state.
void maybe_invalidate_installed_code();
// Deoptimizes the nmethod (if any) in the address field of a given
// InstalledCode object. The address field is zeroed upon return.
static void invalidate_installed_code(Handle installed_code, TRAPS);
// Gets the SpeculationLog object associated with this nmethod
// which may be NULL if this nmethod was not compiled by JVMCI
// or the weak reference has been cleared.
oop speculation_log();
private:
// Deletes the weak reference (if any) to the InstalledCode object
// associated with this nmethod.
void clear_jvmci_installed_code();
// Deletes the weak reference (if any) to the SpeculationLog object
// associated with this nmethod.
void clear_speculation_log();
public:
// Gets the data specific to a JVMCI compiled method.
// This returns a non-NULL value iff this nmethod was
// compiled by the JVMCI compiler.
JVMCINMethodData* jvmci_nmethod_data() const {
return jvmci_data_size() == 0 ? NULL : (JVMCINMethodData*) jvmci_data_begin();
}
#endif
public: