8289094: [JVMCI] reduce JNI overhead and other VM rounds trips in JVMCI

Reviewed-by: kvn, dlong
This commit is contained in:
Doug Simon 2022-06-29 16:14:55 +00:00
parent 0709a6a1fb
commit ba670ecbb9
53 changed files with 3501 additions and 2001 deletions

View File

@ -34,7 +34,7 @@
#include "runtime/sharedRuntime.hpp"
#include "vmreg_aarch64.inline.hpp"
jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMCIObject method, JVMCI_TRAPS) {
jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMCI_TRAPS) {
if (inst->is_call() || inst->is_jump() || inst->is_blr()) {
return pc_offset + NativeCall::instruction_size;
} else if (inst->is_general_jump()) {
@ -47,12 +47,12 @@ jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMC
}
}
void CodeInstaller::pd_patch_OopConstant(int pc_offset, JVMCIObject constant, JVMCI_TRAPS) {
void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& obj, bool compressed, JVMCI_TRAPS) {
address pc = _instructions->start() + pc_offset;
#ifdef ASSERT
{
NativeInstruction *insn = nativeInstruction_at(pc);
if (jvmci_env()->get_HotSpotObjectConstantImpl_compressed(constant)) {
if (compressed) {
// Mov narrow constant: movz n << 16, movk
assert(Instruction_aarch64::extract(insn->encoding(), 31, 21) == 0b11010010101 &&
nativeInstruction_at(pc+4)->is_movk(), "wrong insn in patch");
@ -63,7 +63,6 @@ void CodeInstaller::pd_patch_OopConstant(int pc_offset, JVMCIObject constant, JV
}
}
#endif // ASSERT
Handle obj = jvmci_env()->asConstant(constant, JVMCI_CHECK);
jobject value = JNIHandles::make_local(obj());
MacroAssembler::patch_oop(pc, cast_from_oop<address>(obj()));
int oop_index = _oop_recorder->find_index(value);
@ -71,15 +70,15 @@ void CodeInstaller::pd_patch_OopConstant(int pc_offset, JVMCIObject constant, JV
_instructions->relocate(pc, rspec);
}
void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, JVMCIObject constant, JVMCI_TRAPS) {
void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) {
address pc = _instructions->start() + pc_offset;
if (jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed(constant)) {
narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, JVMCI_CHECK);
if (tag == PATCH_NARROW_KLASS) {
narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, stream, tag, JVMCI_CHECK);
MacroAssembler::patch_narrow_klass(pc, narrowOop);
JVMCI_event_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop);
} else {
NativeMovConstReg* move = nativeMovConstReg_at(pc);
void* reference = record_metadata_reference(_instructions, pc, constant, JVMCI_CHECK);
void* reference = record_metadata_reference(_instructions, pc, stream, tag, JVMCI_CHECK);
move->set_data((intptr_t) reference);
JVMCI_event_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
}
@ -122,34 +121,27 @@ void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong forei
JVMCI_event_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst));
}
void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &cbuf, JVMCIObject hotspot_method, jint pc_offset, JVMCI_TRAPS) {
#ifdef ASSERT
Method* method = NULL;
// we need to check, this might also be an unresolved method
if (JVMCIENV->isa_HotSpotResolvedJavaMethodImpl(hotspot_method)) {
method = JVMCIENV->asMethod(hotspot_method);
}
#endif
void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &cbuf, methodHandle& method, jint pc_offset, JVMCI_TRAPS) {
switch (_next_call_type) {
case INLINE_INVOKE:
break;
case INVOKEVIRTUAL:
case INVOKEINTERFACE: {
assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
assert(!method->is_static(), "cannot call static method with invokeinterface");
NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
_instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc));
call->trampoline_jump(cbuf, SharedRuntime::get_resolve_virtual_call_stub());
break;
}
case INVOKESTATIC: {
assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
assert(method->is_static(), "cannot call non-static method with invokestatic");
NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
_instructions->relocate(call->instruction_address(), relocInfo::static_call_type);
call->trampoline_jump(cbuf, SharedRuntime::get_resolve_static_call_stub());
break;
}
case INVOKESPECIAL: {
assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
assert(!method->is_static(), "cannot call static method with invokespecial");
NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
_instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type);
call->trampoline_jump(cbuf, SharedRuntime::get_resolve_opt_virtual_call_stub());

View File

@ -39,7 +39,7 @@
#include "code/vmreg.hpp"
#include "vmreg_x86.inline.hpp"
jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMCIObject method, JVMCI_TRAPS) {
jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMCI_TRAPS) {
if (inst->is_call() || inst->is_jump()) {
assert(NativeCall::instruction_size == (int)NativeJump::instruction_size, "unexpected size");
return (pc_offset + NativeCall::instruction_size);
@ -56,7 +56,6 @@ jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMC
return (offset);
} else if (inst->is_call_reg()) {
// the inlined vtable stub contains a "call register" instruction
assert(method.is_non_null(), "only valid for virtual calls");
return (pc_offset + ((NativeCallReg *) inst)->next_instruction_offset());
} else if (inst->is_cond_jump()) {
address pc = (address) (inst);
@ -66,11 +65,10 @@ jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMC
}
}
void CodeInstaller::pd_patch_OopConstant(int pc_offset, JVMCIObject constant, JVMCI_TRAPS) {
void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& obj, bool compressed, JVMCI_TRAPS) {
address pc = _instructions->start() + pc_offset;
Handle obj = jvmci_env()->asConstant(constant, JVMCI_CHECK);
jobject value = JNIHandles::make_local(obj());
if (jvmci_env()->get_HotSpotObjectConstantImpl_compressed(constant)) {
if (compressed) {
#ifdef _LP64
address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand);
int oop_index = _oop_recorder->find_index(value);
@ -87,19 +85,19 @@ void CodeInstaller::pd_patch_OopConstant(int pc_offset, JVMCIObject constant, JV
}
}
void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, JVMCIObject constant, JVMCI_TRAPS) {
void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) {
address pc = _instructions->start() + pc_offset;
if (jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed(constant)) {
if (tag == PATCH_NARROW_KLASS) {
#ifdef _LP64
address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand);
*((narrowKlass*) operand) = record_narrow_metadata_reference(_instructions, operand, constant, JVMCI_CHECK);
*((narrowKlass*) operand) = record_narrow_metadata_reference(_instructions, operand, stream, tag, JVMCI_CHECK);
JVMCI_event_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand));
#else
JVMCI_ERROR("compressed Klass* on 32bit");
#endif
} else {
address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
*((void**) operand) = record_metadata_reference(_instructions, operand, constant, JVMCI_CHECK);
*((void**) operand) = record_metadata_reference(_instructions, operand, stream, tag, JVMCI_CHECK);
JVMCI_event_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand));
}
}
@ -147,21 +145,14 @@ void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong forei
JVMCI_event_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst));
}
void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &, JVMCIObject hotspot_method, jint pc_offset, JVMCI_TRAPS) {
#ifdef ASSERT
Method* method = NULL;
// we need to check, this might also be an unresolved method
if (JVMCIENV->isa_HotSpotResolvedJavaMethodImpl(hotspot_method)) {
method = JVMCIENV->asMethod(hotspot_method);
}
#endif
void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &, methodHandle& method, jint pc_offset, JVMCI_TRAPS) {
NativeCall* call = NULL;
switch (_next_call_type) {
case INLINE_INVOKE:
return;
case INVOKEVIRTUAL:
case INVOKEINTERFACE: {
assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
assert(!method->is_static(), "cannot call static method with invokeinterface");
call = nativeCall_at(_instructions->start() + pc_offset);
call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
@ -171,7 +162,7 @@ void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &, JVMCIObject hotspot_met
break;
}
case INVOKESTATIC: {
assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
assert(method->is_static(), "cannot call non-static method with invokestatic");
call = nativeCall_at(_instructions->start() + pc_offset);
call->set_destination(SharedRuntime::get_resolve_static_call_stub());
@ -180,7 +171,7 @@ void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &, JVMCIObject hotspot_met
break;
}
case INVOKESPECIAL: {
assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
assert(!method->is_static(), "cannot call static method with invokespecial");
call = nativeCall_at(_instructions->start() + pc_offset);
call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
_instructions->relocate(call->instruction_address(),

View File

@ -41,6 +41,7 @@
// - ConstantValue describes a constant
class ConstantOopReadValue;
class ConstantOopWriteValue;
class LocationValue;
class ObjectValue;
@ -62,6 +63,11 @@ class ScopeValue: public ResourceObj {
return (ConstantOopReadValue*) this;
}
ConstantOopWriteValue* as_ConstantOopWriteValue() {
assert(is_constant_oop(), "must be");
return (ConstantOopWriteValue*) this;
}
ObjectValue* as_ObjectValue() {
assert(is_object(), "must be");
return (ObjectValue*)this;

View File

@ -2735,8 +2735,11 @@ void CompileBroker::print_times(bool per_compiler, bool aggregate) {
}
#if INCLUDE_JVMCI
if (EnableJVMCI) {
tty->cr();
JVMCICompiler::print_hosted_timers();
JVMCICompiler *jvmci_comp = JVMCICompiler::instance(false, JavaThread::current_or_null());
if (jvmci_comp != nullptr && jvmci_comp != comp) {
tty->cr();
jvmci_comp->print_timers();
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -24,61 +24,123 @@
#ifndef SHARE_JVMCI_JVMCICODEINSTALLER_HPP
#define SHARE_JVMCI_JVMCICODEINSTALLER_HPP
#include "classfile/classFileStream.hpp"
#include "code/debugInfoRec.hpp"
#include "code/exceptionHandlerTable.hpp"
#include "code/nativeInst.hpp"
#include "jvmci/jvmci.hpp"
#include "jvmci/jvmciEnv.hpp"
class CodeMetadata {
public:
CodeMetadata() {}
// Object for decoding a serialized HotSpotCompiledCode object.
// Encoding is done by jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.
class HotSpotCompiledCodeStream : public ResourceObj {
private:
class Chunk {
private:
Chunk* _next;
u4 _size;
CodeBlob* get_code_blob() const { return _cb; }
public:
u4 size() const { return _size; }
const u1* data() const { return ((const u1*)this) + HEADER; }
const u1* data_end() const { return data() + _size; }
Chunk* next() const { return _next; }
};
PcDesc* get_pc_desc() const { return _pc_desc; }
int get_nr_pc_desc() const { return _nr_pc_desc; }
// Mirrors jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.HEADER
static const int HEADER = sizeof(Chunk*) + sizeof(u4);
u_char* get_scopes_desc() const { return _scopes_desc; }
int get_scopes_size() const { return _nr_scopes_desc; }
Chunk* _head; // First chunk in buffer
Chunk* _chunk; // Chunk currently being read
mutable const u1* _pos; // Read position in _chunk
const bool _with_type_info;
objArrayHandle _object_pool; // Pool for objects in Java heap (ignored if libjvmci)
JavaThread* _thread; // Current thread
ExceptionHandlerTable* get_exception_table() { return _exception_table; }
// Virtual objects in DebugInfo currently being decoded
GrowableArray<ScopeValue*>* _virtual_objects;
ImplicitExceptionTable* get_implicit_exception_table() { return _implicit_exception_table; }
// HotSpotCompiledCode.name or HotSpotCompiledNmethod.method
const char* _code_desc;
void set_pc_desc(PcDesc* desc, int count) {
_pc_desc = desc;
_nr_pc_desc = count;
#define checked_read(value, name, type) do { \
if (_with_type_info) { check_data(sizeof(type), name); } \
return (type) value; \
} while (0)
void before_read(u1 size);
u1 get_u1() { before_read(1); u1 res = *_pos; _pos += 1; return res; }
u2 get_u2() { before_read(2); u2 res = *((u2*) _pos); _pos += 2; return res; }
u4 get_u4() { before_read(4); u4 res = *((u4*) _pos); _pos += 4; return res; }
u8 get_u8() { before_read(8); u8 res = *((u8*) _pos); _pos += 8; return res; }
void check_data(u2 expect_size, const char *expect_name);
public:
HotSpotCompiledCodeStream(JavaThread* thread, const u1* buffer, bool with_type_info, objArrayHandle& object_pool) :
_head((Chunk*) buffer),
_chunk((Chunk*) buffer),
_pos(_chunk->data()),
_with_type_info(with_type_info),
_object_pool(object_pool),
_thread(thread),
_virtual_objects(nullptr),
_code_desc("<unknown>")
{}
// Dump complete buffer to `st`.
void dump_buffer(outputStream* st=tty) const;
// Dump last `len` bytes of current buffer chunk to `st`
void dump_buffer_tail(int len, outputStream* st=tty) const;
// Gets a string containing code_desc() followed by a hexdump
// of about 100 bytes in the stream up to the current read position.
const char* context() const;
// Gets HotSpotCompiledCode.name or HotSpotCompiledNmethod.method.name_and_sig_as_C_string().
const char* code_desc() const { return _code_desc; }
void set_code_desc(const char* name, methodHandle& method) {
if (name != nullptr) {
_code_desc = name;
} else if (!method.is_null()) {
_code_desc = method->name_and_sig_as_C_string();
}
}
void set_scopes(u_char* scopes, int size) {
_scopes_desc = scopes;
_nr_scopes_desc = size;
}
// Current read address.
address pos() const { return (address) _pos; }
void set_exception_table(ExceptionHandlerTable* table) {
_exception_table = table;
}
// Offset of current read position from start of buffer.
u4 offset() const;
void set_implicit_exception_table(ImplicitExceptionTable* table) {
_implicit_exception_table = table;
}
// Gets the number of remaining bytes in the stream.
bool available() const;
private:
CodeBlob* _cb;
PcDesc* _pc_desc;
int _nr_pc_desc;
oop get_oop(int id, JVMCI_TRAPS) const;
JavaThread* thread() const { return _thread; }
u_char* _scopes_desc;
int _nr_scopes_desc;
void set_virtual_objects(GrowableArray<ScopeValue*>* objs) { _virtual_objects = objs; }
ScopeValue* virtual_object_at(int id, JVMCI_TRAPS) const;
ExceptionHandlerTable* _exception_table;
ImplicitExceptionTable* _implicit_exception_table;
u1 read_u1(const char* name) { checked_read(get_u1(), name, u1); }
u2 read_u2(const char* name) { checked_read(get_u2(), name, u2); }
u4 read_u4(const char* name) { checked_read(get_u4(), name, u4); }
u8 read_u8(const char* name) { checked_read(get_u8(), name, u8); }
s2 read_s2(const char* name) { checked_read(get_u2(), name, s2); }
s4 read_s4(const char* name) { checked_read(get_u4(), name, s4); }
s8 read_s8(const char* name) { checked_read(get_u8(), name, s8); }
bool read_bool(const char* name) { checked_read((get_u1() != 0), name, bool); }
Method* read_method(const char* name);
Klass* read_klass(const char* name);
const char* read_utf8(const char* name, JVMCI_TRAPS);
#undef checked_read
};
/*
* This class handles the conversion from a InstalledCode to a CodeBlob or an nmethod.
*/
// Converts a HotSpotCompiledCode to a CodeBlob or an nmethod.
class CodeInstaller : public StackObj {
friend class JVMCIVMStructs;
private:
@ -113,20 +175,100 @@ private:
VERIFY_OOP_BITS,
VERIFY_OOP_MASK,
VERIFY_OOP_COUNT_ADDRESS,
INVOKE_INVALID = -1
INVOKE_INVALID = -1
};
// Mirrors jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag
enum Tag {
ILLEGAL,
REGISTER_PRIMITIVE,
REGISTER_OOP,
REGISTER_NARROW_OOP,
STACK_SLOT_PRIMITIVE,
STACK_SLOT_OOP,
STACK_SLOT_NARROW_OOP,
VIRTUAL_OBJECT_ID,
VIRTUAL_OBJECT_ID2,
NULL_CONSTANT,
RAW_CONSTANT,
PRIMITIVE_0,
PRIMITIVE4,
PRIMITIVE8,
JOBJECT,
OBJECT_ID,
OBJECT_ID2,
NO_FINALIZABLE_SUBCLASS,
CONCRETE_SUBTYPE,
LEAF_TYPE,
CONCRETE_METHOD,
CALLSITE_TARGET_VALUE,
PATCH_OBJECT_ID,
PATCH_OBJECT_ID2,
PATCH_NARROW_OBJECT_ID,
PATCH_NARROW_OBJECT_ID2,
PATCH_JOBJECT,
PATCH_NARROW_JOBJECT,
PATCH_KLASS,
PATCH_NARROW_KLASS,
PATCH_METHOD,
PATCH_DATA_SECTION_REFERENCE,
SITE_CALL,
SITE_FOREIGN_CALL,
SITE_FOREIGN_CALL_NO_DEBUG_INFO,
SITE_SAFEPOINT,
SITE_INFOPOINT,
SITE_IMPLICIT_EXCEPTION,
SITE_IMPLICIT_EXCEPTION_DISPATCH,
SITE_MARK,
SITE_DATA_PATCH,
SITE_EXCEPTION_HANDLER,
};
// Mirrors constants from jdk.vm.ci.code.BytecodeFrame.
enum BytecodeFrameBCI {
UNWIND_BCI = -1,
BEFORE_BCI = -2,
AFTER_BCI = -3,
AFTER_EXCEPTION_BCI = -4,
UNKNOWN_BCI = -5,
INVALID_FRAMESTATE_BCI = -6
};
// Mirrors HotSpotCompiledCode flags from jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.
enum HotSpotCompiledCodeFlags {
HCC_IS_NMETHOD = 0x01,
HCC_HAS_ASSUMPTIONS = 0x02,
HCC_HAS_METHODS = 0x04,
HCC_HAS_DEOPT_RESCUE_SLOT = 0x08,
HCC_HAS_COMMENTS = 0x10
};
// Mirrors DebugInfo flags from jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.
enum DebugInfoFlags {
DI_HAS_REFERENCE_MAP = 0x01,
DI_HAS_CALLEE_SAVE_INFO = 0x02,
DI_HAS_FRAMES = 0x04
};
// Mirrors BytecodeFrame flags from jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.
enum DebugInfoFrameFlags {
DIF_HAS_LOCALS = 0x01,
DIF_HAS_STACK = 0x02,
DIF_HAS_LOCKS = 0x04,
DIF_DURING_CALL = 0x08,
DIF_RETHROW_EXCEPTION = 0x10
};
// Sentinel value in a DebugInfo stream denoting no register.
static const int NO_REGISTER = 0xFFFF;
Arena _arena;
JVMCIEnv* _jvmci_env;
JVMCIPrimitiveArray _data_section_handle;
JVMCIObjectArray _data_section_patches_handle;
JVMCIObjectArray _sites_handle;
#ifndef PRODUCT
JVMCIObjectArray _comments_handle;
#endif
JVMCIPrimitiveArray _code_handle;
JVMCIObject _word_kind_handle;
jint _sites_count;
CodeOffsets _offsets;
@ -160,33 +302,31 @@ private:
static LocationValue* _illegal_value;
static MarkerValue* _virtual_byte_array_marker;
jint pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMCIObject method, JVMCI_TRAPS);
void pd_patch_OopConstant(int pc_offset, JVMCIObject constant, JVMCI_TRAPS);
void pd_patch_MetaspaceConstant(int pc_offset, JVMCIObject constant, JVMCI_TRAPS);
jint pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMCI_TRAPS);
void pd_patch_OopConstant(int pc_offset, Handle& obj, bool compressed, JVMCI_TRAPS);
void pd_patch_MetaspaceConstant(int pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS);
void pd_patch_DataSectionReference(int pc_offset, int data_offset, JVMCI_TRAPS);
void pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, JVMCI_TRAPS);
void pd_relocate_JavaMethod(CodeBuffer &cbuf, JVMCIObject method, jint pc_offset, JVMCI_TRAPS);
void pd_relocate_JavaMethod(CodeBuffer &cbuf, methodHandle& method, jint pc_offset, JVMCI_TRAPS);
void pd_relocate_poll(address pc, jint mark, JVMCI_TRAPS);
JVMCIObjectArray sites() { return _sites_handle; }
JVMCIPrimitiveArray code() { return _code_handle; }
JVMCIPrimitiveArray data_section() { return _data_section_handle; }
JVMCIObjectArray data_section_patches() { return _data_section_patches_handle; }
#ifndef PRODUCT
JVMCIObjectArray comments() { return _comments_handle; }
#endif
JVMCIObject word_kind() { return _word_kind_handle; }
public:
#ifndef PRODUCT
// Verifies the enum mirroring BCI constants in BytecodeFrame is in sync.
static void verify_bci_constants(JVMCIEnv* env);
#endif
CodeInstaller(JVMCIEnv* jvmci_env) :
_arena(mtJVMCI),
_jvmci_env(jvmci_env),
_has_auto_box(false) {}
JVMCI::CodeInstallResult install(JVMCICompiler* compiler,
JVMCIObject target,
jlong compiled_code_buffer,
bool with_type_info,
JVMCIObject compiled_code,
objArrayHandle object_pool,
CodeBlob*& cb,
nmethodLocker& nmethod_handle,
JVMCIObject installed_code,
@ -201,65 +341,59 @@ public:
static address runtime_call_target_address(oop runtime_call);
static VMReg get_hotspot_reg(jint jvmciRegisterNumber, JVMCI_TRAPS);
static bool is_general_purpose_reg(VMReg hotspotRegister);
static ScopeValue* to_primitive_value(HotSpotCompiledCodeStream* stream, jlong raw, BasicType type, ScopeValue* &second, JVMCI_TRAPS);
const OopMapSet* oopMapSet() const { return _debug_recorder->_oopmaps; }
protected:
Location::Type get_oop_type(JVMCIObject value);
ScopeValue* get_scope_value(JVMCIObject value, BasicType type, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, JVMCI_TRAPS);
MonitorValue* get_monitor_value(JVMCIObject value, GrowableArray<ScopeValue*>* objects, JVMCI_TRAPS);
// Gets the tag to be used with `read_oop()` corresponding to `patch_object_tag`.
static u1 as_read_oop_tag(HotSpotCompiledCodeStream* stream, u1 patch_object_tag, JVMCI_TRAPS);
void* record_metadata_reference(CodeSection* section, address dest, JVMCIObject constant, JVMCI_TRAPS);
protected:
Handle read_oop(HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS);
ScopeValue* get_scope_value(HotSpotCompiledCodeStream* stream, u1 tag, BasicType type, ScopeValue* &second, JVMCI_TRAPS);
GrowableArray<ScopeValue*>* read_local_or_stack_values(HotSpotCompiledCodeStream* stream, u1 frame_flags, bool is_locals, JVMCI_TRAPS);
void* record_metadata_reference(CodeSection* section, address dest, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS);
#ifdef _LP64
narrowKlass record_narrow_metadata_reference(CodeSection* section, address dest, JVMCIObject constant, JVMCI_TRAPS);
narrowKlass record_narrow_metadata_reference(CodeSection* section, address dest, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS);
#endif
GrowableArray<MonitorValue*>* read_monitor_values(HotSpotCompiledCodeStream* stream, u1 frame_flags, JVMCI_TRAPS);
// extract the fields of the HotSpotCompiledCode
void initialize_fields(JVMCIObject target, JVMCIObject compiled_code, JVMCI_TRAPS);
void initialize_dependencies(JVMCIObject compiled_code, OopRecorder* oop_recorder, JVMCI_TRAPS);
void initialize_fields(HotSpotCompiledCodeStream* stream, u1 code_flags, methodHandle& method, JVMCI_TRAPS);
void initialize_dependencies(HotSpotCompiledCodeStream* stream, u1 code_flags, OopRecorder* oop_recorder, JVMCI_TRAPS);
int estimate_stubs_size(JVMCI_TRAPS);
int estimate_stubs_size(HotSpotCompiledCodeStream* stream, JVMCI_TRAPS);
// perform data and call relocation on the CodeBuffer
JVMCI::CodeInstallResult initialize_buffer(CodeBuffer& buffer, bool check_size, JVMCI_TRAPS);
JVMCI::CodeInstallResult initialize_buffer(JVMCIObject compiled_code, CodeBuffer& buffer, HotSpotCompiledCodeStream* stream, u1 code_flags, JVMCI_TRAPS);
void assumption_NoFinalizableSubclass(JVMCIObject assumption);
void assumption_ConcreteSubtype(JVMCIObject assumption);
void assumption_LeafType(JVMCIObject assumption);
void assumption_ConcreteMethod(JVMCIObject assumption);
void assumption_CallSiteTargetValue(JVMCIObject assumption, JVMCI_TRAPS);
void site_Safepoint(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS);
void site_Infopoint(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS);
void site_Call(CodeBuffer& buffer, u1 tag, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS);
void site_DataPatch(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS);
void site_Mark(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS);
void site_ExceptionHandler(jint pc_offset, HotSpotCompiledCodeStream* stream);
void site_Safepoint(CodeBuffer& buffer, jint pc_offset, JVMCIObject site, JVMCI_TRAPS);
void site_Infopoint(CodeBuffer& buffer, jint pc_offset, JVMCIObject site, JVMCI_TRAPS);
void site_Call(CodeBuffer& buffer, jint pc_offset, JVMCIObject site, JVMCI_TRAPS);
void site_DataPatch(CodeBuffer& buffer, jint pc_offset, JVMCIObject site, JVMCI_TRAPS);
void site_Mark(CodeBuffer& buffer, jint pc_offset, JVMCIObject site, JVMCI_TRAPS);
void site_ExceptionHandler(jint pc_offset, JVMCIObject site);
OopMap* create_oop_map(HotSpotCompiledCodeStream* stream, u1 debug_info_flags, JVMCI_TRAPS);
OopMap* create_oop_map(JVMCIObject debug_info, JVMCI_TRAPS);
VMReg getVMRegFromLocation(JVMCIObject location, int total_frame_size, JVMCI_TRAPS);
/**
* Specifies the level of detail to record for a scope.
*/
enum ScopeMode {
// Only record a method and BCI
BytecodePosition,
// Record a method, bci and JVM frame state
FullFrame
};
VMReg getVMRegFromLocation(HotSpotCompiledCodeStream* stream, int total_frame_size, JVMCI_TRAPS);
int map_jvmci_bci(int bci);
void record_scope(jint pc_offset, JVMCIObject debug_info, ScopeMode scope_mode, bool is_mh_invoke, bool return_oop, JVMCI_TRAPS);
void record_scope(jint pc_offset, JVMCIObject debug_info, ScopeMode scope_mode, JVMCI_TRAPS) {
record_scope(pc_offset, debug_info, scope_mode, false /* is_mh_invoke */, false /* return_oop */, JVMCIENV);
}
void record_scope(jint pc_offset, JVMCIObject position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, bool is_mh_invoke, bool return_oop, JVMCI_TRAPS);
void record_object_value(ObjectValue* sv, JVMCIObject value, GrowableArray<ScopeValue*>* objects, JVMCI_TRAPS);
void record_oop_patch(HotSpotCompiledCodeStream* stream, address dest, u1 read_tag, bool narrow, JVMCI_TRAPS);
GrowableArray<ScopeValue*>* record_virtual_objects(JVMCIObject debug_info, JVMCI_TRAPS);
// full_info: if false, only BytecodePosition is in stream otherwise all DebugInfo is in stream
void record_scope(jint pc_offset, HotSpotCompiledCodeStream* stream, u1 debug_info_flags, bool full_info, bool is_mh_invoke, bool return_oop, JVMCI_TRAPS);
void record_scope(jint pc_offset, HotSpotCompiledCodeStream* stream, u1 debug_info_flags, bool full_info, JVMCI_TRAPS) {
record_scope(pc_offset, stream, debug_info_flags, full_info, false /* is_mh_invoke */, false /* return_oop */, JVMCIENV);
}
void record_object_value(ObjectValue* sv, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS);
void read_virtual_objects(HotSpotCompiledCodeStream* stream, JVMCI_TRAPS);
int estimateStubSpace(int static_call_stubs);
};

View File

@ -33,8 +33,6 @@
#include "runtime/handles.inline.hpp"
JVMCICompiler* JVMCICompiler::_instance = NULL;
elapsedTimer JVMCICompiler::_codeInstallTimer;
elapsedTimer JVMCICompiler::_hostedCodeInstallTimer;
JVMCICompiler::JVMCICompiler() : AbstractCompiler(compiler_jvmci) {
_bootstrapping = false;
@ -183,19 +181,26 @@ void JVMCICompiler::on_empty_queue(CompileQueue* queue, CompilerThread* thread)
}
}
// Print CompileBroker compilation timers
// Print compilation timers
void JVMCICompiler::print_timers() {
double code_install_time = _codeInstallTimer.seconds();
tty->print_cr(" JVMCI CompileBroker Time:");
tty->print_cr(" Compile: %7.3f s", stats()->total_time());
tty->print_cr(" Install Code: %7.3f s", code_install_time);
_jit_code_installs.print_on(tty, " Install Code: ");
tty->cr();
tty->print_cr(" JVMCI Hosted Time:");
_hosted_code_installs.print_on(tty, " Install Code: ");
}
// Print non-CompileBroker compilation timers
void JVMCICompiler::print_hosted_timers() {
double code_install_time = _hostedCodeInstallTimer.seconds();
tty->print_cr(" JVMCI Hosted Time:");
tty->print_cr(" Install Code: %7.3f s", code_install_time);
void JVMCICompiler::CodeInstallStats::print_on(outputStream* st, const char* prefix) const {
double time = _timer.seconds();
st->print_cr("%s%7.3f s (installs: %d, CodeBlob total size: %d, CodeBlob code size: %d)",
prefix, time, _count, _codeBlobs_size, _codeBlobs_code_size);
}
void JVMCICompiler::CodeInstallStats::on_install(CodeBlob* cb) {
Atomic::inc(&_count);
Atomic::add(&_codeBlobs_size, cb->size());
Atomic::add(&_codeBlobs_code_size, cb->code_size());
}
void JVMCICompiler::inc_methods_compiled() {

View File

@ -29,7 +29,30 @@
#include "runtime/atomic.hpp"
class JVMCICompiler : public AbstractCompiler {
private:
public:
// Code installation specific statistics.
class CodeInstallStats {
private:
elapsedTimer _timer;
volatile int _count;
volatile int _codeBlobs_size;
volatile int _codeBlobs_code_size;
public:
CodeInstallStats() :
_count(0),
_codeBlobs_size(0),
_codeBlobs_code_size(0)
{}
elapsedTimer* timer() { return &_timer; }
void print_on(outputStream* st, const char* prefix) const;
// Notifies this object that `cb` has just been
// installed in the code cache.
void on_install(CodeBlob* cb);
};
private:
bool _bootstrapping;
/**
@ -49,11 +72,8 @@ private:
static JVMCICompiler* _instance;
// Code installation timer for CompileBroker compilations
static elapsedTimer _codeInstallTimer;
// Code installation timer for non-CompileBroker compilations
static elapsedTimer _hostedCodeInstallTimer;
CodeInstallStats _jit_code_installs; // CompileBroker compilations
CodeInstallStats _hosted_code_installs; // Non-CompileBroker compilations
/**
* Exits the VM due to an unexpected exception.
@ -112,14 +132,11 @@ public:
int global_compilation_ticks() const { return _global_compilation_ticks; }
void inc_global_compilation_ticks();
// Print timers related to non-CompileBroker compilations
static void print_hosted_timers();
static elapsedTimer* codeInstallTimer(bool hosted) {
CodeInstallStats* code_install_stats(bool hosted) {
if (!hosted) {
return &_codeInstallTimer;
return &_jit_code_installs;
} else {
return &_hostedCodeInstallTimer;
return &_hosted_code_installs;
}
}
};

File diff suppressed because it is too large Load Diff

View File

@ -925,11 +925,11 @@ void JVMCIEnv::call_HotSpotJVMCIRuntime_postTranslation(JVMCIObject object, JVMC
}
}
JVMCIObject JVMCIEnv::call_JavaConstant_forPrimitive(JVMCIObject kind, jlong value, JVMCI_TRAPS) {
JVMCIObject JVMCIEnv::call_JavaConstant_forPrimitive(jchar type_char, jlong value, JVMCI_TRAPS) {
JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros.
if (is_hotspot()) {
JavaCallArguments jargs;
jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(kind)));
jargs.push_int(type_char);
jargs.push_long(value);
JavaValue result(T_OBJECT);
JavaCalls::call_static(&result,
@ -941,7 +941,7 @@ JVMCIObject JVMCIEnv::call_JavaConstant_forPrimitive(JVMCIObject kind, jlong val
JNIAccessMark jni(this, THREAD);
jobject result = (jstring) jni()->CallStaticObjectMethod(JNIJVMCI::JavaConstant::clazz(),
JNIJVMCI::JavaConstant::forPrimitive_method(),
kind.as_jobject(), value);
type_char, value);
if (jni()->ExceptionCheck()) {
return JVMCIObject();
}
@ -1142,7 +1142,7 @@ JVMCIObject JVMCIEnv::get_jvmci_method(const methodHandle& method, JVMCI_TRAPS)
}
assert(asMethod(method_object) == method(), "must be");
if (get_HotSpotResolvedJavaMethodImpl_metadataHandle(method_object) != (jlong) handle) {
if (get_HotSpotResolvedJavaMethodImpl_methodHandle(method_object) != (jlong) handle) {
_runtime->release_handle(handle);
}
assert(!method_object.is_null(), "must be");
@ -1157,13 +1157,11 @@ JVMCIObject JVMCIEnv::get_jvmci_type(const JVMCIKlassHandle& klass, JVMCI_TRAPS)
jlong pointer = (jlong) klass();
JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros.
JVMCIObject signature = create_string(klass->signature_name(), JVMCI_CHECK_(JVMCIObject()));
jboolean exception = false;
if (is_hotspot()) {
JavaValue result(T_OBJECT);
JavaCallArguments args;
args.push_long(pointer);
args.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(signature)));
JavaCalls::call_static(&result,
HotSpotJVMCI::HotSpotResolvedObjectTypeImpl::klass(),
vmSymbols::fromMetaspace_name(),
@ -1180,7 +1178,7 @@ JVMCIObject JVMCIEnv::get_jvmci_type(const JVMCIKlassHandle& klass, JVMCI_TRAPS)
HandleMark hm(THREAD);
type = JNIJVMCI::wrap(jni()->CallStaticObjectMethod(JNIJVMCI::HotSpotResolvedObjectTypeImpl::clazz(),
JNIJVMCI::HotSpotResolvedObjectTypeImpl_fromMetaspace_method(),
pointer, signature.as_jstring()));
pointer));
exception = jni()->ExceptionCheck();
}
if (exception) {
@ -1224,7 +1222,7 @@ JVMCIObject JVMCIEnv::get_jvmci_constant_pool(const constantPoolHandle& cp, JVMC
assert(!cp_object.is_null(), "must be");
// Constant pools aren't cached so this is always a newly created object using the handle
assert(get_HotSpotConstantPool_metadataHandle(cp_object) == (jlong) handle, "must use same handle");
assert(get_HotSpotConstantPool_constantPoolHandle(cp_object) == (jlong) handle, "must use same handle");
return cp_object;
}
@ -1461,11 +1459,7 @@ bool JVMCIEnv::equals(JVMCIObject a, JVMCIObject b) {
}
}
BasicType JVMCIEnv::kindToBasicType(JVMCIObject kind, JVMCI_TRAPS) {
if (kind.is_null()) {
JVMCI_THROW_(NullPointerException, T_ILLEGAL);
}
jchar ch = get_JavaKind_typeChar(kind);
BasicType JVMCIEnv::typeCharToBasicType(jchar ch, JVMCI_TRAPS) {
switch(ch) {
case 'Z': return T_BOOLEAN;
case 'B': return T_BYTE;
@ -1478,10 +1472,19 @@ BasicType JVMCIEnv::kindToBasicType(JVMCIObject kind, JVMCI_TRAPS) {
case 'A': return T_OBJECT;
case '-': return T_ILLEGAL;
default:
JVMCI_ERROR_(T_ILLEGAL, "unexpected Kind: %c", ch);
JVMCI_ERROR_(T_ILLEGAL, "unexpected type char: %c", ch);
}
}
BasicType JVMCIEnv::kindToBasicType(JVMCIObject kind, JVMCI_TRAPS) {
if (kind.is_null()) {
JVMCI_THROW_(NullPointerException, T_ILLEGAL);
}
jchar ch = get_JavaKind_typeChar(kind);
BasicType bt = typeCharToBasicType(ch, JVMCI_CHECK_(T_ILLEGAL));
return bt;
}
void JVMCIEnv::initialize_installed_code(JVMCIObject installed_code, CodeBlob* cb, JVMCI_TRAPS) {
// Ensure that all updates to the InstalledCode fields are consistent.
if (get_InstalledCode_address(installed_code) != 0) {
@ -1542,17 +1545,17 @@ void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, JVMCI_TRAPS) {
}
Klass* JVMCIEnv::asKlass(JVMCIObject obj) {
return (Klass*) get_HotSpotResolvedObjectTypeImpl_metadataPointer(obj);
return (Klass*) get_HotSpotResolvedObjectTypeImpl_klassPointer(obj);
}
Method* JVMCIEnv::asMethod(JVMCIObject obj) {
Method** metadataHandle = (Method**) get_HotSpotResolvedJavaMethodImpl_metadataHandle(obj);
return *metadataHandle;
Method** methodHandle = (Method**) get_HotSpotResolvedJavaMethodImpl_methodHandle(obj);
return *methodHandle;
}
ConstantPool* JVMCIEnv::asConstantPool(JVMCIObject obj) {
ConstantPool** metadataHandle = (ConstantPool**) get_HotSpotConstantPool_metadataHandle(obj);
return *metadataHandle;
ConstantPool** constantPoolHandle = (ConstantPool**) get_HotSpotConstantPool_constantPoolHandle(obj);
return *constantPoolHandle;
}
CodeBlob* JVMCIEnv::get_code_blob(JVMCIObject obj, nmethodLocker& locker) {

View File

@ -147,7 +147,6 @@ class JVMCICompileState : public ResourceObj {
void inc_compilation_ticks();
};
// This class is a top level wrapper around interactions between HotSpot
// and the JVMCI Java code. It supports both a HotSpot heap based
// runtime with HotSpot oop based accessors as well as a shared library
@ -316,12 +315,16 @@ public:
JVMCIObject call_HotSpotJVMCIRuntime_callToString(JVMCIObject object, JVMCI_TRAPS);
JVMCIObject call_JavaConstant_forPrimitive(JVMCIObject kind, jlong value, JVMCI_TRAPS);
JVMCIObject call_JavaConstant_forPrimitive(jchar type_char, jlong value, JVMCI_TRAPS);
jboolean call_HotSpotJVMCIRuntime_isGCSupported(JVMCIObject runtime, jint gcIdentifier);
void call_HotSpotJVMCIRuntime_postTranslation(JVMCIObject object, JVMCI_TRAPS);
// Converts the JavaKind.typeChar value in `ch` to a BasicType
BasicType typeCharToBasicType(jchar ch, JVMCI_TRAPS);
// Converts the JavaKind value in `kind` to a BasicType
BasicType kindToBasicType(JVMCIObject kind, JVMCI_TRAPS);
#define DO_THROW(name) \
@ -349,19 +352,13 @@ public:
// nmethodLocker is required to keep the nmethod alive.
nmethod* get_nmethod(JVMCIObject code, nmethodLocker& locker);
MethodData* asMethodData(jlong metaspaceMethodData) {
return (MethodData*) (address) metaspaceMethodData;
}
const char* klass_name(JVMCIObject object);
// Unpack an instance of HotSpotResolvedJavaMethodImpl into the original Method*
Method* asMethod(JVMCIObject jvmci_method);
Method* asMethod(jobject jvmci_method) { return asMethod(wrap(jvmci_method)); }
// Unpack an instance of HotSpotResolvedObjectTypeImpl into the original Klass*
Klass* asKlass(JVMCIObject jvmci_type);
Klass* asKlass(jobject jvmci_type) { return asKlass(wrap(jvmci_type)); }
JVMCIObject get_jvmci_method(const methodHandle& method, JVMCI_TRAPS);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -62,11 +62,8 @@
start_class(Architecture, jdk_vm_ci_code_Architecture) \
object_field(Architecture, wordKind, "Ljdk/vm/ci/meta/PlatformKind;") \
end_class \
start_class(TargetDescription, jdk_vm_ci_code_TargetDescription) \
object_field(TargetDescription, arch, "Ljdk/vm/ci/code/Architecture;") \
end_class \
start_class(HotSpotResolvedObjectTypeImpl, jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl) \
long_field(HotSpotResolvedObjectTypeImpl, metadataPointer) \
long_field(HotSpotResolvedObjectTypeImpl, klassPointer) \
end_class \
start_class(HotSpotResolvedPrimitiveType, jdk_vm_ci_hotspot_HotSpotResolvedPrimitiveType) \
object_field(HotSpotResolvedPrimitiveType, mirror, "Ljdk/vm/ci/hotspot/HotSpotObjectConstantImpl;") \
@ -80,7 +77,7 @@
int_field(HotSpotResolvedJavaFieldImpl, modifiers) \
end_class \
start_class(HotSpotResolvedJavaMethodImpl, jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) \
long_field(HotSpotResolvedJavaMethodImpl, metadataHandle) \
long_field(HotSpotResolvedJavaMethodImpl, methodHandle) \
end_class \
start_class(InstalledCode, jdk_vm_ci_code_InstalledCode) \
long_field(InstalledCode, address) \
@ -100,34 +97,12 @@
jvmci_constructor(HotSpotNmethod, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;Ljava/lang/String;ZJ)V") \
end_class \
start_class(HotSpotCompiledCode, jdk_vm_ci_hotspot_HotSpotCompiledCode) \
object_field(HotSpotCompiledCode, name, "Ljava/lang/String;") \
primarray_field(HotSpotCompiledCode, targetCode, "[B") \
int_field(HotSpotCompiledCode, targetCodeSize) \
objectarray_field(HotSpotCompiledCode, sites, "[Ljdk/vm/ci/code/site/Site;") \
objectarray_field(HotSpotCompiledCode, assumptions, "[Ljdk/vm/ci/meta/Assumptions$Assumption;") \
objectarray_field(HotSpotCompiledCode, methods, "[Ljdk/vm/ci/meta/ResolvedJavaMethod;") \
objectarray_field(HotSpotCompiledCode, comments, "[Ljdk/vm/ci/hotspot/HotSpotCompiledCode$Comment;") \
primarray_field(HotSpotCompiledCode, dataSection, "[B") \
int_field(HotSpotCompiledCode, dataSectionAlignment) \
objectarray_field(HotSpotCompiledCode, dataSectionPatches, "[Ljdk/vm/ci/code/site/DataPatch;") \
boolean_field(HotSpotCompiledCode, isImmutablePIC) \
int_field(HotSpotCompiledCode, totalFrameSize) \
object_field(HotSpotCompiledCode, deoptRescueSlot, "Ljdk/vm/ci/code/StackSlot;") \
end_class \
start_class(HotSpotCompiledCode_Comment, jdk_vm_ci_hotspot_HotSpotCompiledCode_Comment) \
object_field(HotSpotCompiledCode_Comment, text, "Ljava/lang/String;") \
int_field(HotSpotCompiledCode_Comment, pcOffset) \
end_class \
start_class(HotSpotCompiledNmethod, jdk_vm_ci_hotspot_HotSpotCompiledNmethod) \
object_field(HotSpotCompiledNmethod, method, "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;") \
object_field(HotSpotCompiledNmethod, installationFailureMessage, "Ljava/lang/String;") \
int_field(HotSpotCompiledNmethod, entryBCI) \
int_field(HotSpotCompiledNmethod, id) \
long_field(HotSpotCompiledNmethod, compileState) \
boolean_field(HotSpotCompiledNmethod, hasUnsafeAccess) \
end_class \
start_class(HotSpotForeignCallTarget, jdk_vm_ci_hotspot_HotSpotForeignCallTarget) \
long_field(HotSpotForeignCallTarget, address) \
end_class \
start_class(VMField, jdk_vm_ci_hotspot_VMField) \
object_field(VMField, name, "Ljava/lang/String;") \
@ -150,88 +125,15 @@
int_field(VMIntrinsicMethod, id) \
jvmci_constructor(VMIntrinsicMethod, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V") \
end_class \
start_class(Assumptions_NoFinalizableSubclass, jdk_vm_ci_meta_Assumptions_NoFinalizableSubclass) \
object_field(Assumptions_NoFinalizableSubclass, receiverType, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
end_class \
start_class(Assumptions_ConcreteSubtype, jdk_vm_ci_meta_Assumptions_ConcreteSubtype) \
object_field(Assumptions_ConcreteSubtype, context, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
object_field(Assumptions_ConcreteSubtype, subtype, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
end_class \
start_class(Assumptions_LeafType, jdk_vm_ci_meta_Assumptions_LeafType) \
object_field(Assumptions_LeafType, context, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
end_class \
start_class(Assumptions_ConcreteMethod, jdk_vm_ci_meta_Assumptions_ConcreteMethod) \
object_field(Assumptions_ConcreteMethod, method, "Ljdk/vm/ci/meta/ResolvedJavaMethod;") \
object_field(Assumptions_ConcreteMethod, context, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
object_field(Assumptions_ConcreteMethod, impl, "Ljdk/vm/ci/meta/ResolvedJavaMethod;") \
end_class \
start_class(Assumptions_CallSiteTargetValue, jdk_vm_ci_meta_Assumptions_CallSiteTargetValue) \
object_field(Assumptions_CallSiteTargetValue, callSite, "Ljdk/vm/ci/meta/JavaConstant;") \
object_field(Assumptions_CallSiteTargetValue, methodHandle, "Ljdk/vm/ci/meta/JavaConstant;") \
end_class \
start_class(site_Site, jdk_vm_ci_code_site_Site) \
int_field(site_Site, pcOffset) \
end_class \
start_class(site_Call, jdk_vm_ci_code_site_Call) \
object_field(site_Call, target, "Ljdk/vm/ci/meta/InvokeTarget;") \
boolean_field(site_Call, direct) \
end_class \
start_class(site_ImplicitExceptionDispatch, jdk_vm_ci_code_site_ImplicitExceptionDispatch) \
int_field(site_ImplicitExceptionDispatch, dispatchOffset) \
end_class \
start_class(site_DataPatch, jdk_vm_ci_code_site_DataPatch) \
object_field(site_DataPatch, reference, "Ljdk/vm/ci/code/site/Reference;") \
end_class \
start_class(site_ConstantReference, jdk_vm_ci_code_site_ConstantReference) \
object_field(site_ConstantReference, constant, "Ljdk/vm/ci/meta/VMConstant;") \
end_class \
start_class(site_DataSectionReference, jdk_vm_ci_code_site_DataSectionReference) \
int_field(site_DataSectionReference, offset) \
end_class \
start_class(site_InfopointReason, jdk_vm_ci_code_site_InfopointReason) \
static_object_field(site_InfopointReason, SAFEPOINT, "Ljdk/vm/ci/code/site/InfopointReason;") \
static_object_field(site_InfopointReason, CALL, "Ljdk/vm/ci/code/site/InfopointReason;") \
static_object_field(site_InfopointReason, IMPLICIT_EXCEPTION, "Ljdk/vm/ci/code/site/InfopointReason;") \
end_class \
start_class(site_Infopoint, jdk_vm_ci_code_site_Infopoint) \
object_field(site_Infopoint, debugInfo, "Ljdk/vm/ci/code/DebugInfo;") \
object_field(site_Infopoint, reason, "Ljdk/vm/ci/code/site/InfopointReason;") \
end_class \
start_class(site_ExceptionHandler, jdk_vm_ci_code_site_ExceptionHandler) \
int_field(site_ExceptionHandler, handlerPos) \
end_class \
start_class(site_Mark, jdk_vm_ci_code_site_Mark) \
object_field(site_Mark, id, "Ljava/lang/Object;") \
end_class \
start_class(HotSpotCompilationRequestResult, jdk_vm_ci_hotspot_HotSpotCompilationRequestResult) \
object_field(HotSpotCompilationRequestResult, failureMessage, "Ljava/lang/String;") \
boolean_field(HotSpotCompilationRequestResult, retry) \
int_field(HotSpotCompilationRequestResult, inlinedBytecodes) \
end_class \
start_class(DebugInfo, jdk_vm_ci_code_DebugInfo) \
object_field(DebugInfo, bytecodePosition, "Ljdk/vm/ci/code/BytecodePosition;") \
object_field(DebugInfo, referenceMap, "Ljdk/vm/ci/code/ReferenceMap;") \
object_field(DebugInfo, calleeSaveInfo, "Ljdk/vm/ci/code/RegisterSaveLayout;") \
objectarray_field(DebugInfo, virtualObjectMapping, "[Ljdk/vm/ci/code/VirtualObject;") \
end_class \
start_class(HotSpotReferenceMap, jdk_vm_ci_hotspot_HotSpotReferenceMap) \
objectarray_field(HotSpotReferenceMap, objects, "[Ljdk/vm/ci/code/Location;") \
objectarray_field(HotSpotReferenceMap, derivedBase, "[Ljdk/vm/ci/code/Location;") \
primarray_field(HotSpotReferenceMap, sizeInBytes, "[I") \
int_field(HotSpotReferenceMap, maxRegisterSize) \
end_class \
start_class(RegisterSaveLayout, jdk_vm_ci_code_RegisterSaveLayout) \
objectarray_field(RegisterSaveLayout, registers, "[Ljdk/vm/ci/code/Register;") \
primarray_field(RegisterSaveLayout, slots, "[I") \
end_class \
start_class(BytecodeFrame, jdk_vm_ci_code_BytecodeFrame) \
objectarray_field(BytecodeFrame, values, "[Ljdk/vm/ci/meta/JavaValue;") \
objectarray_field(BytecodeFrame, slotKinds, "[Ljdk/vm/ci/meta/JavaKind;") \
int_field(BytecodeFrame, numLocals) \
int_field(BytecodeFrame, numStack) \
int_field(BytecodeFrame, numLocks) \
boolean_field(BytecodeFrame, rethrowException) \
boolean_field(BytecodeFrame, duringCall) \
static_int_field(BytecodeFrame, UNKNOWN_BCI) \
static_int_field(BytecodeFrame, UNWIND_BCI) \
static_int_field(BytecodeFrame, BEFORE_BCI) \
@ -255,12 +157,6 @@
object_field(PrimitiveConstant, kind, "Ljdk/vm/ci/meta/JavaKind;") \
long_field(PrimitiveConstant, primitive) \
end_class \
start_class(RawConstant, jdk_vm_ci_meta_RawConstant) \
end_class \
start_class(NullConstant, jdk_vm_ci_meta_NullConstant) \
end_class \
start_class(HotSpotCompressedNullConstant, jdk_vm_ci_hotspot_HotSpotCompressedNullConstant) \
end_class \
start_class(HotSpotObjectConstantImpl, jdk_vm_ci_hotspot_HotSpotObjectConstantImpl) \
boolean_field(HotSpotObjectConstantImpl, compressed) \
end_class \
@ -272,57 +168,12 @@
long_field(IndirectHotSpotObjectConstantImpl, objectHandle) \
jvmci_constructor(IndirectHotSpotObjectConstantImpl, "(JZZ)V") \
end_class \
start_class(HotSpotMetaspaceConstantImpl, jdk_vm_ci_hotspot_HotSpotMetaspaceConstantImpl) \
object_field(HotSpotMetaspaceConstantImpl, metaspaceObject, "Ljdk/vm/ci/hotspot/MetaspaceObject;") \
boolean_field(HotSpotMetaspaceConstantImpl, compressed) \
end_class \
start_class(HotSpotSentinelConstant, jdk_vm_ci_hotspot_HotSpotSentinelConstant) \
end_class \
start_class(JavaKind, jdk_vm_ci_meta_JavaKind) \
char_field(JavaKind, typeChar) \
static_object_field(JavaKind, Boolean, "Ljdk/vm/ci/meta/JavaKind;") \
static_object_field(JavaKind, Byte, "Ljdk/vm/ci/meta/JavaKind;") \
static_object_field(JavaKind, Char, "Ljdk/vm/ci/meta/JavaKind;") \
static_object_field(JavaKind, Short, "Ljdk/vm/ci/meta/JavaKind;") \
static_object_field(JavaKind, Int, "Ljdk/vm/ci/meta/JavaKind;") \
static_object_field(JavaKind, Float, "Ljdk/vm/ci/meta/JavaKind;") \
static_object_field(JavaKind, Long, "Ljdk/vm/ci/meta/JavaKind;") \
static_object_field(JavaKind, Double, "Ljdk/vm/ci/meta/JavaKind;") \
end_class \
start_class(ValueKind, jdk_vm_ci_meta_ValueKind) \
object_field(ValueKind, platformKind, "Ljdk/vm/ci/meta/PlatformKind;") \
end_class \
start_class(Value, jdk_vm_ci_meta_Value) \
object_field(Value, valueKind, "Ljdk/vm/ci/meta/ValueKind;") \
static_object_field(Value, ILLEGAL, "Ljdk/vm/ci/meta/AllocatableValue;") \
end_class \
start_class(RegisterValue, jdk_vm_ci_code_RegisterValue) \
object_field(RegisterValue, reg, "Ljdk/vm/ci/code/Register;") \
end_class \
start_class(code_Location, jdk_vm_ci_code_Location) \
object_field(code_Location, reg, "Ljdk/vm/ci/code/Register;") \
int_field(code_Location, offset) \
end_class \
start_class(code_Register, jdk_vm_ci_code_Register) \
int_field(code_Register, number) \
int_field(code_Register, encoding) \
end_class \
start_class(StackSlot, jdk_vm_ci_code_StackSlot) \
int_field(StackSlot, offset) \
boolean_field(StackSlot, addFrameSize) \
end_class \
start_class(VirtualObject, jdk_vm_ci_code_VirtualObject) \
int_field(VirtualObject, id) \
boolean_field(VirtualObject, isAutoBox) \
object_field(VirtualObject, type, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
objectarray_field(VirtualObject, values, "[Ljdk/vm/ci/meta/JavaValue;") \
objectarray_field(VirtualObject, slotKinds, "[Ljdk/vm/ci/meta/JavaKind;") \
end_class \
start_class(StackLockValue, jdk_vm_ci_code_StackLockValue) \
object_field(StackLockValue, owner, "Ljdk/vm/ci/meta/JavaValue;") \
object_field(StackLockValue, slot, "Ljdk/vm/ci/meta/AllocatableValue;") \
boolean_field(StackLockValue, eliminated) \
end_class \
start_class(HotSpotStackFrameReference, jdk_vm_ci_hotspot_HotSpotStackFrameReference) \
object_field(HotSpotStackFrameReference, compilerToVM, "Ljdk/vm/ci/hotspot/CompilerToVM;") \
boolean_field(HotSpotStackFrameReference, objectsMaterialized) \
@ -334,7 +185,7 @@
primarray_field(HotSpotStackFrameReference, localIsVirtual, "[Z") \
end_class \
start_class(HotSpotConstantPool, jdk_vm_ci_hotspot_HotSpotConstantPool) \
long_field(HotSpotConstantPool, metadataHandle) \
long_field(HotSpotConstantPool, constantPoolHandle) \
end_class \
start_class(HotSpotJVMCIRuntime, jdk_vm_ci_hotspot_HotSpotJVMCIRuntime) \
objectarray_field(HotSpotJVMCIRuntime, excludeFromJVMCICompilation, "[Ljava/lang/Module;") \
@ -517,13 +368,10 @@ class HotSpotJVMCI {
static JVMCIObject wrap(oop obj);
static inline Method* asMethod(JVMCIEnv* env, oop jvmci_method) {
return *(Method**) HotSpotResolvedJavaMethodImpl::metadataHandle(env, jvmci_method);
return *(Method**) HotSpotResolvedJavaMethodImpl::methodHandle(env, jvmci_method);
}
static inline ConstantPool* asConstantPool(JVMCIEnv* env, oop jvmci_constant_pool) {
return *(ConstantPool**) HotSpotConstantPool::metadataHandle(env, jvmci_constant_pool);
}
static inline Klass* asKlass(JVMCIEnv* env, oop jvmci_type) {
return (Klass*) HotSpotResolvedObjectTypeImpl::metadataPointer(env, jvmci_type);
return *(ConstantPool**) HotSpotConstantPool::constantPoolHandle(env, jvmci_constant_pool);
}
static void compute_offsets(TRAPS);

View File

@ -31,6 +31,7 @@
#include "gc/shared/oopStorage.inline.hpp"
#include "jvmci/jniAccessMark.inline.hpp"
#include "jvmci/jvmciCompilerToVM.hpp"
#include "jvmci/jvmciCodeInstaller.hpp"
#include "jvmci/jvmciRuntime.hpp"
#include "jvmci/metadataHandles.hpp"
#include "logging/log.hpp"
@ -1414,6 +1415,8 @@ void JVMCIRuntime::initialize(JVMCIEnv* JVMCIENV) {
create_jvmci_primitive_type(T_DOUBLE, JVMCI_CHECK_EXIT_((void)0));
create_jvmci_primitive_type(T_VOID, JVMCI_CHECK_EXIT_((void)0));
DEBUG_ONLY(CodeInstaller::verify_bci_constants(JVMCIENV);)
if (!JVMCIENV->is_hotspot()) {
JVMCIENV->copy_saved_properties();
}

View File

@ -493,6 +493,70 @@
declare_constant(CodeInstaller::VERIFY_OOP_MASK) \
declare_constant(CodeInstaller::INVOKE_INVALID) \
\
declare_constant(CodeInstaller::ILLEGAL) \
declare_constant(CodeInstaller::REGISTER_PRIMITIVE) \
declare_constant(CodeInstaller::REGISTER_OOP) \
declare_constant(CodeInstaller::REGISTER_NARROW_OOP) \
declare_constant(CodeInstaller::STACK_SLOT_PRIMITIVE) \
declare_constant(CodeInstaller::STACK_SLOT_OOP) \
declare_constant(CodeInstaller::STACK_SLOT_NARROW_OOP) \
declare_constant(CodeInstaller::VIRTUAL_OBJECT_ID) \
declare_constant(CodeInstaller::VIRTUAL_OBJECT_ID2) \
declare_constant(CodeInstaller::NULL_CONSTANT) \
declare_constant(CodeInstaller::RAW_CONSTANT) \
declare_constant(CodeInstaller::PRIMITIVE_0) \
declare_constant(CodeInstaller::PRIMITIVE4) \
declare_constant(CodeInstaller::PRIMITIVE8) \
declare_constant(CodeInstaller::JOBJECT) \
declare_constant(CodeInstaller::OBJECT_ID) \
declare_constant(CodeInstaller::OBJECT_ID2) \
\
declare_constant(CodeInstaller::NO_FINALIZABLE_SUBCLASS) \
declare_constant(CodeInstaller::CONCRETE_SUBTYPE) \
declare_constant(CodeInstaller::LEAF_TYPE) \
declare_constant(CodeInstaller::CONCRETE_METHOD) \
declare_constant(CodeInstaller::CALLSITE_TARGET_VALUE) \
\
declare_constant(CodeInstaller::PATCH_OBJECT_ID) \
declare_constant(CodeInstaller::PATCH_OBJECT_ID2) \
declare_constant(CodeInstaller::PATCH_NARROW_OBJECT_ID) \
declare_constant(CodeInstaller::PATCH_NARROW_OBJECT_ID2) \
declare_constant(CodeInstaller::PATCH_JOBJECT) \
declare_constant(CodeInstaller::PATCH_NARROW_JOBJECT) \
declare_constant(CodeInstaller::PATCH_KLASS) \
declare_constant(CodeInstaller::PATCH_NARROW_KLASS) \
declare_constant(CodeInstaller::PATCH_METHOD) \
declare_constant(CodeInstaller::PATCH_DATA_SECTION_REFERENCE) \
\
declare_constant(CodeInstaller::SITE_CALL) \
declare_constant(CodeInstaller::SITE_FOREIGN_CALL) \
declare_constant(CodeInstaller::SITE_FOREIGN_CALL_NO_DEBUG_INFO) \
declare_constant(CodeInstaller::SITE_SAFEPOINT) \
declare_constant(CodeInstaller::SITE_INFOPOINT) \
declare_constant(CodeInstaller::SITE_IMPLICIT_EXCEPTION) \
declare_constant(CodeInstaller::SITE_IMPLICIT_EXCEPTION_DISPATCH) \
declare_constant(CodeInstaller::SITE_MARK) \
declare_constant(CodeInstaller::SITE_DATA_PATCH) \
declare_constant(CodeInstaller::SITE_EXCEPTION_HANDLER) \
\
declare_constant(CodeInstaller::DI_HAS_REFERENCE_MAP) \
declare_constant(CodeInstaller::DI_HAS_CALLEE_SAVE_INFO) \
declare_constant(CodeInstaller::DI_HAS_FRAMES) \
\
declare_constant(CodeInstaller::DIF_HAS_LOCALS) \
declare_constant(CodeInstaller::DIF_HAS_STACK) \
declare_constant(CodeInstaller::DIF_HAS_LOCKS) \
declare_constant(CodeInstaller::DIF_DURING_CALL) \
declare_constant(CodeInstaller::DIF_RETHROW_EXCEPTION) \
\
declare_constant(CodeInstaller::HCC_IS_NMETHOD) \
declare_constant(CodeInstaller::HCC_HAS_ASSUMPTIONS) \
declare_constant(CodeInstaller::HCC_HAS_METHODS) \
declare_constant(CodeInstaller::HCC_HAS_DEOPT_RESCUE_SLOT) \
declare_constant(CodeInstaller::HCC_HAS_COMMENTS) \
\
declare_constant(CodeInstaller::NO_REGISTER) \
\
declare_constant(CollectedHeap::None) \
declare_constant(CollectedHeap::Serial) \
declare_constant(CollectedHeap::Parallel) \

View File

@ -32,10 +32,7 @@
template(jdk_vm_ci_services_Services, "jdk/vm/ci/services/Services") \
template(jdk_vm_ci_runtime_JVMCI, "jdk/vm/ci/runtime/JVMCI") \
template(jdk_vm_ci_hotspot_HotSpotCompiledCode, "jdk/vm/ci/hotspot/HotSpotCompiledCode") \
template(jdk_vm_ci_hotspot_HotSpotCompiledCode_Comment, "jdk/vm/ci/hotspot/HotSpotCompiledCode$Comment") \
template(jdk_vm_ci_hotspot_HotSpotCompiledNmethod, "jdk/vm/ci/hotspot/HotSpotCompiledNmethod") \
template(jdk_vm_ci_hotspot_HotSpotForeignCallTarget, "jdk/vm/ci/hotspot/HotSpotForeignCallTarget") \
template(jdk_vm_ci_hotspot_HotSpotReferenceMap, "jdk/vm/ci/hotspot/HotSpotReferenceMap") \
template(jdk_vm_ci_hotspot_CompilerToVM, "jdk/vm/ci/hotspot/CompilerToVM") \
template(jdk_vm_ci_hotspot_HotSpotInstalledCode, "jdk/vm/ci/hotspot/HotSpotInstalledCode") \
template(jdk_vm_ci_hotspot_HotSpotNmethod, "jdk/vm/ci/hotspot/HotSpotNmethod") \
@ -47,8 +44,6 @@
template(jdk_vm_ci_hotspot_HotSpotObjectConstantImpl, "jdk/vm/ci/hotspot/HotSpotObjectConstantImpl") \
template(jdk_vm_ci_hotspot_DirectHotSpotObjectConstantImpl, "jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl") \
template(jdk_vm_ci_hotspot_IndirectHotSpotObjectConstantImpl, "jdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl") \
template(jdk_vm_ci_hotspot_HotSpotMetaspaceConstantImpl, "jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl") \
template(jdk_vm_ci_hotspot_HotSpotSentinelConstant, "jdk/vm/ci/hotspot/HotSpotSentinelConstant") \
template(jdk_vm_ci_hotspot_HotSpotStackFrameReference, "jdk/vm/ci/hotspot/HotSpotStackFrameReference") \
template(jdk_vm_ci_hotspot_HotSpotConstantPool, "jdk/vm/ci/hotspot/HotSpotConstantPool") \
template(jdk_vm_ci_hotspot_HotSpotJVMCIRuntime, "jdk/vm/ci/hotspot/HotSpotJVMCIRuntime") \
@ -74,28 +69,9 @@
template(jdk_vm_ci_code_Architecture, "jdk/vm/ci/code/Architecture") \
template(jdk_vm_ci_code_BytecodeFrame, "jdk/vm/ci/code/BytecodeFrame") \
template(jdk_vm_ci_code_BytecodePosition, "jdk/vm/ci/code/BytecodePosition") \
template(jdk_vm_ci_code_DebugInfo, "jdk/vm/ci/code/DebugInfo") \
template(jdk_vm_ci_code_InstalledCode, "jdk/vm/ci/code/InstalledCode") \
template(jdk_vm_ci_code_Location, "jdk/vm/ci/code/Location") \
template(jdk_vm_ci_code_Register, "jdk/vm/ci/code/Register") \
template(jdk_vm_ci_code_RegisterValue, "jdk/vm/ci/code/RegisterValue") \
template(jdk_vm_ci_code_StackSlot, "jdk/vm/ci/code/StackSlot") \
template(jdk_vm_ci_code_StackLockValue, "jdk/vm/ci/code/StackLockValue") \
template(jdk_vm_ci_code_TargetDescription, "jdk/vm/ci/code/TargetDescription") \
template(jdk_vm_ci_code_VirtualObject, "jdk/vm/ci/code/VirtualObject") \
template(jdk_vm_ci_code_RegisterSaveLayout, "jdk/vm/ci/code/RegisterSaveLayout") \
template(jdk_vm_ci_code_InvalidInstalledCodeException, "jdk/vm/ci/code/InvalidInstalledCodeException") \
template(jdk_vm_ci_code_site_Call, "jdk/vm/ci/code/site/Call") \
template(jdk_vm_ci_code_site_ConstantReference, "jdk/vm/ci/code/site/ConstantReference") \
template(jdk_vm_ci_code_site_DataPatch, "jdk/vm/ci/code/site/DataPatch") \
template(jdk_vm_ci_code_site_DataSectionReference, "jdk/vm/ci/code/site/DataSectionReference") \
template(jdk_vm_ci_code_site_ExceptionHandler, "jdk/vm/ci/code/site/ExceptionHandler") \
template(jdk_vm_ci_code_site_Mark, "jdk/vm/ci/code/site/Mark") \
template(jdk_vm_ci_code_site_ImplicitExceptionDispatch, "jdk/vm/ci/code/site/ImplicitExceptionDispatch") \
template(jdk_vm_ci_code_site_Infopoint, "jdk/vm/ci/code/site/Infopoint") \
template(jdk_vm_ci_code_stack_InspectedFrameVisitor, "jdk/vm/ci/code/stack/InspectedFrameVisitor") \
template(jdk_vm_ci_code_site_Site, "jdk/vm/ci/code/site/Site") \
template(jdk_vm_ci_code_site_InfopointReason, "jdk/vm/ci/code/site/InfopointReason") \
template(jdk_vm_ci_common_JVMCIError, "jdk/vm/ci/common/JVMCIError") \
\
template(visitFrame_name, "visitFrame") \
@ -109,7 +85,7 @@
template(fromMetaspace_name, "fromMetaspace") \
template(method_fromMetaspace_signature, "(J)Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;") \
template(constantPool_fromMetaspace_signature, "(J)Ljdk/vm/ci/hotspot/HotSpotConstantPool;") \
template(klass_fromMetaspace_signature, "(JLjava/lang/String;)Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;") \
template(klass_fromMetaspace_signature, "(J)Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;") \
template(primitive_fromMetaspace_signature, "(Ljdk/vm/ci/hotspot/HotSpotObjectConstantImpl;C)Ljdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType;") \
template(getRuntime_name, "getRuntime") \
template(getRuntime_signature, "()Ljdk/vm/ci/runtime/JVMCIRuntime;") \
@ -125,7 +101,7 @@
template(getName_name, "getName") \
template(bootstrapFinished_name, "bootstrapFinished") \
template(forPrimitive_name, "forPrimitive") \
template(forPrimitive_signature, "(Ljdk/vm/ci/meta/JavaKind;J)Ljdk/vm/ci/meta/PrimitiveConstant;") \
template(forPrimitive_signature, "(CJ)Ljdk/vm/ci/meta/PrimitiveConstant;") \
template(method_string_bool_long_signature, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;Ljava/lang/String;ZJ)V") \
template(initializeSavedProperties_name, "initializeSavedProperties") \

View File

@ -52,6 +52,11 @@ void elapsedTimer::add(elapsedTimer t) {
_counter += t._counter;
}
void elapsedTimer::add_nanoseconds(jlong ns) {
jlong freq = os::elapsed_frequency() / NANOUNITS;
_counter += ns * freq;
}
void elapsedTimer::start() {
if (!_active) {
_active = true;

View File

@ -38,6 +38,7 @@ class elapsedTimer {
public:
elapsedTimer() { _active = false; reset(); }
void add(elapsedTimer t);
void add_nanoseconds(jlong ns);
void start();
void stop();
void reset() { _counter = 0; }

View File

@ -281,11 +281,15 @@ void outputStream::print_julong(julong value) {
*
* indent is applied to each line. Ends with a CR.
*/
void outputStream::print_data(void* data, size_t len, bool with_ascii) {
void outputStream::print_data(void* data, size_t len, bool with_ascii, bool rel_addr) {
size_t limit = (len + 16) / 16 * 16;
for (size_t i = 0; i < limit; ++i) {
if (i % 16 == 0) {
indent().print(INTPTR_FORMAT_W(07) ":", i);
if (rel_addr) {
indent().print(INTPTR_FORMAT_W(07) ":", i);
} else {
indent().print(INTPTR_FORMAT ":", p2i((unsigned char*)data + i));
}
}
if (i % 2 == 0) {
print(" ");

View File

@ -100,7 +100,7 @@ class outputStream : public ResourceObj {
void print_raw(const char* str, size_t len) { write(str, len); }
void print_raw_cr(const char* str) { write(str, strlen(str)); cr(); }
void print_raw_cr(const char* str, size_t len){ write(str, len); cr(); }
void print_data(void* data, size_t len, bool with_ascii);
void print_data(void* data, size_t len, bool with_ascii, bool rel_addr=true);
void put(char ch);
void sp(int count = 1);
void cr();

View File

@ -25,6 +25,7 @@ package jdk.vm.ci.code;
import java.util.Arrays;
import java.util.Objects;
import jdk.vm.ci.common.JVMCIError;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.JavaValue;
import jdk.vm.ci.meta.ResolvedJavaMethod;
@ -176,14 +177,28 @@ public final class BytecodeFrame extends BytecodePosition {
}
/**
* Creates a new frame object.
* Creates a new frame object. A well formed frame has the following invariants:
* <ul>
* <li>{@code values != null}</li>
* <li>{@code slotKinds != null}</li>
* <li>{@code numLocals + numStack + numLocks == values.length}</li>
* <li>{@code numLocals + numStack + numLocks == values.length}</li>
* <li>{@code numLocals + numStack == slotKinds.length}</li>
* <li>all entries in {@code values} starting at index {@code numLocals + numStack} must be of
* type {@link StackLockValue}</li>
* <li>for each index {@code i} between 0 (inclusive) and {@code numLocals + numStack}
* (exclusive), if {@code slotKinds[i].needsTwoSlots()} then
* {@code values[i + 1] == Value.ILLEGAL}.</li>
* </ul>
*
* These invariants are not checked in this constructor but by {@link #verifyInvariants()}.
*
* @param caller the caller frame (which may be {@code null})
* @param method the method
* @param bci a BCI within the method
* @param rethrowException specifies if the VM should re-throw the pending exception when
* deopt'ing using this frame
* @param values the frame state {@link #values}.
* @param values the frame state {@link #values}
* @param slotKinds the kinds in {@code values}. This array is now owned by this object and must
* not be mutated by the caller.
* @param numLocals the number of local variables
@ -191,7 +206,15 @@ public final class BytecodeFrame extends BytecodePosition {
* @param numLocks the number of locked objects
*/
@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `slotKinds`")
public BytecodeFrame(BytecodeFrame caller, ResolvedJavaMethod method, int bci, boolean rethrowException, boolean duringCall, JavaValue[] values, JavaKind[] slotKinds, int numLocals, int numStack,
public BytecodeFrame(BytecodeFrame caller,
ResolvedJavaMethod method,
int bci,
boolean rethrowException,
boolean duringCall,
JavaValue[] values,
JavaKind[] slotKinds,
int numLocals,
int numStack,
int numLocks) {
super(caller, method, bci);
assert values != null;
@ -205,6 +228,38 @@ public final class BytecodeFrame extends BytecodePosition {
assert !rethrowException || numStack == 1 : "must have exception on top of the stack";
}
/**
* Checks the invariants described in {@link #BytecodeFrame}.
*
* @throws NullPointerException if {@code values == null || slotKinds == null} or any of the
* entries in {@code values} is null
* @throws JVMCIError if any of the other invariants are violated
*/
public void verifyInvariants() {
if (values.length != numLocals + numStack + numLocks) {
throw new JVMCIError("unexpected values length %d in frame (%d locals, %d stack slots, %d locks)", values.length, numLocals, numStack, numLocks);
}
if (slotKinds.length != numLocals + numStack) {
throw new JVMCIError("unexpected slotKinds length %d in frame (%d locals, %d stack slots)", values.length, numLocals, numStack);
}
for (int i = 0; i < slotKinds.length; i++) {
Objects.requireNonNull(values[i]);
JavaKind kind = slotKinds[i];
if (kind.needsTwoSlots()) {
if (i + 1 >= values.length || values[i + 1] != Value.ILLEGAL) {
throw new JVMCIError("2 slot value at index %d not followed by Value.ILLEGAL", i);
}
}
}
for (int i = slotKinds.length; i < values.length; i++) {
JavaValue lock = values[i];
Objects.requireNonNull(lock);
if (!(lock instanceof StackLockValue)) {
throw new JVMCIError("Lock at %d must be of type StackLockValue, got %s", i, lock.getClass().getName());
}
}
}
/**
* Ensure that the frame state is formatted as expected by the JVM, with null or Illegal in the
* slot following a double word item. This should really be checked in FrameState itself but

View File

@ -59,6 +59,13 @@ public final class RegisterSaveLayout {
assert new HashSet<>(registersToSlots(false).values()).size() == slots.length : "non-unqiue slots";
}
/**
* Gets the number of entries in this map.
*/
public int size() {
return registers.length;
}
/**
* Gets the frame slot index for a given register.
*

View File

@ -49,7 +49,7 @@ public final class StackLockValue implements JavaValue {
this.owner = newOwner;
}
public Value getSlot() {
public AllocatableValue getSlot() {
return slot;
}

View File

@ -45,6 +45,7 @@ public class Infopoint extends Site implements Comparable<Infopoint> {
super(pcOffset);
this.debugInfo = debugInfo;
this.reason = reason;
assert reason != InfopointReason.CALL || this instanceof Call : getClass();
}
@Override

View File

@ -32,10 +32,10 @@ import java.lang.reflect.Field;
import jdk.vm.ci.code.BytecodeFrame;
import jdk.vm.ci.code.InstalledCode;
import jdk.vm.ci.code.InvalidInstalledCodeException;
import jdk.vm.ci.code.TargetDescription;
import jdk.vm.ci.code.stack.InspectedFrameVisitor;
import jdk.vm.ci.common.InitTimer;
import jdk.vm.ci.common.JVMCIError;
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
import jdk.vm.ci.meta.Constant;
import jdk.vm.ci.meta.ConstantReflectionProvider;
import jdk.vm.ci.meta.JavaConstant;
@ -84,30 +84,30 @@ final class CompilerToVM {
CompilerToVM() {
try (InitTimer t = timer("CompilerToVM.registerNatives")) {
registerNatives();
ARRAY_BOOLEAN_BASE_OFFSET = arrayBaseOffset(JavaKind.Boolean);
ARRAY_BYTE_BASE_OFFSET = arrayBaseOffset(JavaKind.Byte);
ARRAY_SHORT_BASE_OFFSET = arrayBaseOffset(JavaKind.Short);
ARRAY_CHAR_BASE_OFFSET = arrayBaseOffset(JavaKind.Char);
ARRAY_INT_BASE_OFFSET = arrayBaseOffset(JavaKind.Int);
ARRAY_LONG_BASE_OFFSET = arrayBaseOffset(JavaKind.Long);
ARRAY_FLOAT_BASE_OFFSET = arrayBaseOffset(JavaKind.Float);
ARRAY_DOUBLE_BASE_OFFSET = arrayBaseOffset(JavaKind.Double);
ARRAY_OBJECT_BASE_OFFSET = arrayBaseOffset(JavaKind.Object);
ARRAY_BOOLEAN_INDEX_SCALE = arrayIndexScale(JavaKind.Boolean);
ARRAY_BYTE_INDEX_SCALE = arrayIndexScale(JavaKind.Byte);
ARRAY_SHORT_INDEX_SCALE = arrayIndexScale(JavaKind.Short);
ARRAY_CHAR_INDEX_SCALE = arrayIndexScale(JavaKind.Char);
ARRAY_INT_INDEX_SCALE = arrayIndexScale(JavaKind.Int);
ARRAY_LONG_INDEX_SCALE = arrayIndexScale(JavaKind.Long);
ARRAY_FLOAT_INDEX_SCALE = arrayIndexScale(JavaKind.Float);
ARRAY_DOUBLE_INDEX_SCALE = arrayIndexScale(JavaKind.Double);
ARRAY_OBJECT_INDEX_SCALE = arrayIndexScale(JavaKind.Object);
ARRAY_BOOLEAN_BASE_OFFSET = arrayBaseOffset(JavaKind.Boolean.getTypeChar());
ARRAY_BYTE_BASE_OFFSET = arrayBaseOffset(JavaKind.Byte.getTypeChar());
ARRAY_SHORT_BASE_OFFSET = arrayBaseOffset(JavaKind.Short.getTypeChar());
ARRAY_CHAR_BASE_OFFSET = arrayBaseOffset(JavaKind.Char.getTypeChar());
ARRAY_INT_BASE_OFFSET = arrayBaseOffset(JavaKind.Int.getTypeChar());
ARRAY_LONG_BASE_OFFSET = arrayBaseOffset(JavaKind.Long.getTypeChar());
ARRAY_FLOAT_BASE_OFFSET = arrayBaseOffset(JavaKind.Float.getTypeChar());
ARRAY_DOUBLE_BASE_OFFSET = arrayBaseOffset(JavaKind.Double.getTypeChar());
ARRAY_OBJECT_BASE_OFFSET = arrayBaseOffset(JavaKind.Object.getTypeChar());
ARRAY_BOOLEAN_INDEX_SCALE = arrayIndexScale(JavaKind.Boolean.getTypeChar());
ARRAY_BYTE_INDEX_SCALE = arrayIndexScale(JavaKind.Byte.getTypeChar());
ARRAY_SHORT_INDEX_SCALE = arrayIndexScale(JavaKind.Short.getTypeChar());
ARRAY_CHAR_INDEX_SCALE = arrayIndexScale(JavaKind.Char.getTypeChar());
ARRAY_INT_INDEX_SCALE = arrayIndexScale(JavaKind.Int.getTypeChar());
ARRAY_LONG_INDEX_SCALE = arrayIndexScale(JavaKind.Long.getTypeChar());
ARRAY_FLOAT_INDEX_SCALE = arrayIndexScale(JavaKind.Float.getTypeChar());
ARRAY_DOUBLE_INDEX_SCALE = arrayIndexScale(JavaKind.Double.getTypeChar());
ARRAY_OBJECT_INDEX_SCALE = arrayIndexScale(JavaKind.Object.getTypeChar());
}
}
native int arrayBaseOffset(JavaKind kind);
native int arrayBaseOffset(char typeChar);
native int arrayIndexScale(JavaKind kind);
native int arrayIndexScale(char typeChar);
/**
* Gets the {@link CompilerToVM} instance associated with the singleton
@ -122,13 +122,21 @@ final class CompilerToVM {
*
* @return a new byte array containing the original bytecode of {@code method}
*/
native byte[] getBytecode(HotSpotResolvedJavaMethodImpl method);
byte[] getBytecode(HotSpotResolvedJavaMethodImpl method) {
return getBytecode(method, method.getMethodPointer());
}
private native byte[] getBytecode(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Gets the number of entries in {@code method}'s exception handler table or 0 if it has no
* exception handler table.
*/
native int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method);
int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method) {
return getExceptionTableLength(method, method.getMethodPointer());
}
private native int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Gets the address of the first entry in {@code method}'s exception handler table.
@ -146,7 +154,11 @@ final class CompilerToVM {
* @return 0 if {@code method} has no exception handlers (i.e.
* {@code getExceptionTableLength(method) == 0})
*/
native long getExceptionTableStart(HotSpotResolvedJavaMethodImpl method);
long getExceptionTableStart(HotSpotResolvedJavaMethodImpl method) {
return getExceptionTableStart(method, method.getMethodPointer());
}
private native long getExceptionTableStart(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Determines whether {@code method} is currently compilable by the JVMCI compiler being used by
@ -154,14 +166,22 @@ final class CompilerToVM {
* breakpoint is currently set in {@code method} or {@code method} contains other bytecode
* features that require special handling by the VM.
*/
native boolean isCompilable(HotSpotResolvedJavaMethodImpl method);
boolean isCompilable(HotSpotResolvedJavaMethodImpl method) {
return isCompilable(method, method.getMethodPointer());
}
private native boolean isCompilable(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Determines if {@code method} is targeted by a VM directive (e.g.,
* {@code -XX:CompileCommand=dontinline,<pattern>}) or annotation (e.g.,
* {@code jdk.internal.vm.annotation.DontInline}) that specifies it should not be inlined.
*/
native boolean hasNeverInlineDirective(HotSpotResolvedJavaMethodImpl method);
boolean hasNeverInlineDirective(HotSpotResolvedJavaMethodImpl method) {
return hasNeverInlineDirective(method, method.getMethodPointer());
}
private native boolean hasNeverInlineDirective(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Determines if {@code method} should be inlined at any cost. This could be because:
@ -170,16 +190,24 @@ final class CompilerToVM {
* <li>an annotation forces inlining of this method</li>
* </ul>
*/
native boolean shouldInlineMethod(HotSpotResolvedJavaMethodImpl method);
boolean shouldInlineMethod(HotSpotResolvedJavaMethodImpl method) {
return shouldInlineMethod(method, method.getMethodPointer());
}
private native boolean shouldInlineMethod(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Used to implement {@link ResolvedJavaType#findUniqueConcreteMethod(ResolvedJavaMethod)}.
*
* @param method the method on which to base the search
* @param actualHolderType the best known type of receiver
* @param method the method on which to base the search
* @return the method result or 0 is there is no unique concrete method for {@code method}
*/
native HotSpotResolvedJavaMethodImpl findUniqueConcreteMethod(HotSpotResolvedObjectTypeImpl actualHolderType, HotSpotResolvedJavaMethodImpl method);
HotSpotResolvedJavaMethodImpl findUniqueConcreteMethod(HotSpotResolvedObjectTypeImpl actualHolderType, HotSpotResolvedJavaMethodImpl method) {
return findUniqueConcreteMethod(actualHolderType, actualHolderType.getKlassPointer(), method, method.getMetaspacePointer());
}
private native HotSpotResolvedJavaMethodImpl findUniqueConcreteMethod(HotSpotResolvedObjectTypeImpl klass, long klassPointer, HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Gets the implementor for the interface class {@code type}.
@ -188,25 +216,38 @@ final class CompilerToVM {
* implementor, or {@code type} itself if there is more than one implementor
* @throws IllegalArgumentException if type is not an interface type
*/
native HotSpotResolvedObjectTypeImpl getImplementor(HotSpotResolvedObjectTypeImpl type);
HotSpotResolvedObjectTypeImpl getImplementor(HotSpotResolvedObjectTypeImpl type) {
return getImplementor(type, type.getKlassPointer());
}
private native HotSpotResolvedObjectTypeImpl getImplementor(HotSpotResolvedObjectTypeImpl type, long klassPointer);
/**
* Determines if {@code method} is ignored by security stack walks.
*/
native boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethodImpl method);
boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethodImpl method) {
return methodIsIgnoredBySecurityStackWalk(method, method.getMetaspacePointer());
}
private native boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Converts a name to a type.
*
* @param name a well formed Java type in {@linkplain JavaType#getName() internal} format
* @param accessingClass the context of resolution. A value of {@code null} implies that the
* class should be resolved with the class loader.
* class should be resolved with the {@linkplain ClassLoader#getSystemClassLoader()
* system class loader}.
* @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will
* either return a {@link ResolvedJavaType} or throw an exception
* @return the type for {@code name} or 0 if resolution failed and {@code resolve == false}
* @throws ClassNotFoundException if {@code resolve == true} and the resolution failed
*/
native HotSpotResolvedJavaType lookupType(String name, HotSpotResolvedObjectTypeImpl accessingClass, boolean resolve) throws ClassNotFoundException;
HotSpotResolvedJavaType lookupType(String name, HotSpotResolvedObjectTypeImpl accessingClass, boolean resolve) throws ClassNotFoundException {
return lookupType(name, accessingClass, accessingClass != null ? accessingClass.getKlassPointer() : 0L, resolve);
}
private native HotSpotResolvedJavaType lookupType(String name, HotSpotResolvedObjectTypeImpl accessingClass, long klassPointer, boolean resolve) throws ClassNotFoundException;
native HotSpotResolvedJavaType lookupClass(Class<?> javaClass);
@ -219,7 +260,11 @@ final class CompilerToVM {
* {@code JVM_CONSTANT_MethodHandle}, {@code JVM_CONSTANT_MethodHandleInError},
* {@code JVM_CONSTANT_MethodType} and {@code JVM_CONSTANT_MethodTypeInError}.
*/
native JavaConstant resolvePossiblyCachedConstantInPool(HotSpotConstantPool constantPool, int cpi);
JavaConstant resolvePossiblyCachedConstantInPool(HotSpotConstantPool constantPool, int cpi) {
return resolvePossiblyCachedConstantInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
}
private native JavaConstant resolvePossiblyCachedConstantInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
/**
* Gets the {@code JVM_CONSTANT_NameAndType} index from the entry at index {@code cpi} in
@ -228,7 +273,11 @@ final class CompilerToVM {
* The behavior of this method is undefined if {@code cpi} does not denote an entry containing a
* {@code JVM_CONSTANT_NameAndType} index.
*/
native int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int cpi);
int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int cpi) {
return lookupNameAndTypeRefIndexInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
}
private native int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
/**
* Gets the name of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry
@ -237,7 +286,11 @@ final class CompilerToVM {
* The behavior of this method is undefined if {@code which} does not denote a entry that
* references a {@code JVM_CONSTANT_NameAndType} entry.
*/
native String lookupNameInPool(HotSpotConstantPool constantPool, int which);
String lookupNameInPool(HotSpotConstantPool constantPool, int which) {
return lookupNameInPool(constantPool, constantPool.getConstantPoolPointer(), which);
}
private native String lookupNameInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int which);
/**
* Gets the signature of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry
@ -246,7 +299,11 @@ final class CompilerToVM {
* The behavior of this method is undefined if {@code which} does not denote a entry that
* references a {@code JVM_CONSTANT_NameAndType} entry.
*/
native String lookupSignatureInPool(HotSpotConstantPool constantPool, int which);
String lookupSignatureInPool(HotSpotConstantPool constantPool, int which) {
return lookupSignatureInPool(constantPool, constantPool.getConstantPoolPointer(), which);
}
private native String lookupSignatureInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int which);
/**
* Gets the {@code JVM_CONSTANT_Class} index from the entry at index {@code cpi} in
@ -255,7 +312,11 @@ final class CompilerToVM {
* The behavior of this method is undefined if {@code cpi} does not denote an entry containing a
* {@code JVM_CONSTANT_Class} index.
*/
native int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int cpi);
int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int cpi) {
return lookupKlassRefIndexInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
}
private native int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
/**
* Looks up a class denoted by the {@code JVM_CONSTANT_Class} entry at index {@code cpi} in
@ -266,7 +327,11 @@ final class CompilerToVM {
*
* @return the resolved class entry or a String otherwise
*/
native Object lookupKlassInPool(HotSpotConstantPool constantPool, int cpi);
Object lookupKlassInPool(HotSpotConstantPool constantPool, int cpi) {
return lookupKlassInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
}
private native Object lookupKlassInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
/**
* Looks up a method denoted by the entry at index {@code cpi} in {@code constantPool}. This
@ -281,7 +346,11 @@ final class CompilerToVM {
* checks fail, 0 is returned.
* @return the resolved method entry, 0 otherwise
*/
native HotSpotResolvedJavaMethodImpl lookupMethodInPool(HotSpotConstantPool constantPool, int cpi, byte opcode);
HotSpotResolvedJavaMethodImpl lookupMethodInPool(HotSpotConstantPool constantPool, int cpi, byte opcode) {
return lookupMethodInPool(constantPool, constantPool.getConstantPoolPointer(), cpi, opcode);
}
private native HotSpotResolvedJavaMethodImpl lookupMethodInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi, byte opcode);
/**
* Ensures that the type referenced by the specified {@code JVM_CONSTANT_InvokeDynamic} entry at
@ -290,7 +359,11 @@ final class CompilerToVM {
* The behavior of this method is undefined if {@code cpi} does not denote a
* {@code JVM_CONSTANT_InvokeDynamic} entry.
*/
native void resolveInvokeDynamicInPool(HotSpotConstantPool constantPool, int cpi);
void resolveInvokeDynamicInPool(HotSpotConstantPool constantPool, int cpi) {
resolveInvokeDynamicInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
}
private native void resolveInvokeDynamicInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
/**
* Resolves the details for invoking the bootstrap method associated with the
@ -314,14 +387,22 @@ final class CompilerToVM {
*
* @return bootstrap method invocation details as encoded above
*/
native Object[] resolveBootstrapMethod(HotSpotConstantPool constantPool, int cpi);
Object[] resolveBootstrapMethod(HotSpotConstantPool constantPool, int cpi) {
return resolveBootstrapMethod(constantPool, constantPool.getConstantPoolPointer(), cpi);
}
private native Object[] resolveBootstrapMethod(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
/**
* If {@code cpi} denotes an entry representing a signature polymorphic method ({@jvms 2.9}),
* this method ensures that the type referenced by the entry is loaded and initialized. It
* {@code cpi} does not denote a signature polymorphic method, this method does nothing.
*/
native void resolveInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi);
void resolveInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi) {
resolveInvokeHandleInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
}
private native void resolveInvokeHandleInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
/**
* If {@code cpi} denotes an entry representing a resolved dynamic adapter (see
@ -329,7 +410,11 @@ final class CompilerToVM {
* opcode of the instruction for which the resolution was performed ({@code invokedynamic} or
* {@code invokevirtual}), or {@code -1} otherwise.
*/
native int isResolvedInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi);
int isResolvedInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi) {
return isResolvedInvokeHandleInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
}
private native int isResolvedInvokeHandleInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
/**
* Gets the list of type names (in the format of {@link JavaType#getName()}) denoting the
@ -345,7 +430,11 @@ final class CompilerToVM {
*
* @throws LinkageError if resolution failed
*/
native HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool, int cpi) throws LinkageError;
HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool, int cpi) throws LinkageError {
return resolveTypeInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
}
private native HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi) throws LinkageError;
/**
* Looks up and attempts to resolve the {@code JVM_CONSTANT_Field} entry for at index
@ -364,31 +453,45 @@ final class CompilerToVM {
* {@code JVM_CONSTANT_Field} entry.
*
* @param info an array in which the details of the field are returned
* @return the type defining the field if resolution is successful, 0 otherwise
* @return the type defining the field if resolution is successful, null otherwise
*/
native HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, int cpi, HotSpotResolvedJavaMethodImpl method, byte opcode, int[] info);
HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, int cpi, HotSpotResolvedJavaMethodImpl method, byte opcode, int[] info) {
long methodPointer = method != null ? method.getMethodPointer() : 0L;
return resolveFieldInPool(constantPool, constantPool.getConstantPoolPointer(), cpi, method, methodPointer, opcode, info);
}
private native HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, long constantPoolPointer,
int cpi, HotSpotResolvedJavaMethodImpl method, long methodPointer, byte opcode, int[] info);
/**
* Converts {@code cpci} from an index into the cache for {@code constantPool} to an index
* directly into {@code constantPool}.
*
* The behavior of this method is undefined if {@code ccpi} is an invalid constant pool cache
* The behavior of this method is undefined if {@code cpci} is an invalid constant pool cache
* index.
*/
native int constantPoolRemapInstructionOperandFromCache(HotSpotConstantPool constantPool, int cpci);
int constantPoolRemapInstructionOperandFromCache(HotSpotConstantPool constantPool, int cpci) {
return constantPoolRemapInstructionOperandFromCache(constantPool, constantPool.getConstantPoolPointer(), cpci);
}
private native int constantPoolRemapInstructionOperandFromCache(HotSpotConstantPool constantPool, long constantPoolPointer, int cpci);
/**
* Gets the appendix object (if any) associated with the entry at index {@code cpi} in
* {@code constantPool}.
*/
native HotSpotObjectConstantImpl lookupAppendixInPool(HotSpotConstantPool constantPool, int cpi);
HotSpotObjectConstantImpl lookupAppendixInPool(HotSpotConstantPool constantPool, int cpi) {
return lookupAppendixInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
}
private native HotSpotObjectConstantImpl lookupAppendixInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
/**
* Installs the result of a compilation into the code cache.
*
* @param target the target where this code should be installed
* @param compiledCode the result of a compilation
* @param code the details of the installed CodeBlob are written to this object
*
* @return the outcome of the installation which will be one of
* {@link HotSpotVMConfig#codeInstallResultOk},
* {@link HotSpotVMConfig#codeInstallResultCacheFull},
@ -397,7 +500,43 @@ final class CompilerToVM {
* @throws JVMCIError if there is something wrong with the compiled code or the associated
* metadata.
*/
native int installCode(TargetDescription target, HotSpotCompiledCode compiledCode, InstalledCode code, long failedSpeculationsAddress, byte[] speculations);
int installCode(HotSpotCompiledCode compiledCode, InstalledCode code, long failedSpeculationsAddress, byte[] speculations) {
int codeInstallFlags = getInstallCodeFlags();
boolean withComments = (codeInstallFlags & 0x0001) != 0;
boolean withMethods = (codeInstallFlags & 0x0002) != 0;
boolean withTypeInfo;
if ((codeInstallFlags & 0x0004) != 0 && HotSpotJVMCIRuntime.Option.CodeSerializationTypeInfo.isDefault) {
withTypeInfo = true;
} else {
withTypeInfo = HotSpotJVMCIRuntime.Option.CodeSerializationTypeInfo.getBoolean();
}
try (HotSpotCompiledCodeStream stream = new HotSpotCompiledCodeStream(compiledCode, withTypeInfo, withComments, withMethods)) {
return installCode0(stream.headChunk, stream.timeNS, withTypeInfo, compiledCode, stream.objectPool, code, failedSpeculationsAddress, speculations);
}
}
native int installCode0(long compiledCodeBuffer,
long serializationNS,
boolean withTypeInfo,
HotSpotCompiledCode compiledCode,
Object[] objectPool,
InstalledCode code,
long failedSpeculationsAddress,
byte[] speculations);
/**
* Gets flags specifying optional parts of code info. Only if a flag is set, will the
* corresponding code info being included in the {@linkplain HotSpotCompiledCodeStream
* serialized code stream}.
*
* <ul>
* <li>0x0001: code comments ({@link HotSpotCompiledCode#comments})</li>
* <li>0x0002: methods ({@link HotSpotCompiledCode#methods})</li>
* <li>0x0004: enable {@link Option#CodeSerializationTypeInfo} if it not explicitly specified
* (i.e., {@link Option#isDefault} is {@code true})</li>
* </ul>
*/
private native int getInstallCodeFlags();
/**
* Resets all compilation statistics.
@ -428,24 +567,39 @@ final class CompilerToVM {
* type {@code exactReceiver}. This resolution process only searches "up" the class hierarchy of
* {@code exactReceiver}.
*
* @param exactReceiver the exact receiver type
* @param caller the caller or context type used to perform access checks
* @return the link-time resolved method (might be abstract) or {@code null} if it is either a
* signature polymorphic method or can not be linked.
*/
native HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, HotSpotResolvedJavaMethodImpl method, HotSpotResolvedObjectTypeImpl caller);
HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, HotSpotResolvedJavaMethodImpl method, HotSpotResolvedObjectTypeImpl caller) {
return resolveMethod(exactReceiver, exactReceiver.getKlassPointer(), method, method.getMethodPointer(), caller, caller.getKlassPointer());
}
private native HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, long exactReceiverKlass,
HotSpotResolvedJavaMethodImpl method, long methodPointer,
HotSpotResolvedObjectTypeImpl caller, long callerKlass);
/**
* Gets the static initializer of {@code type}.
*
* @return {@code null} if {@code type} has no static initializer
*/
native HotSpotResolvedJavaMethodImpl getClassInitializer(HotSpotResolvedObjectTypeImpl type);
HotSpotResolvedJavaMethodImpl getClassInitializer(HotSpotResolvedObjectTypeImpl type) {
return getClassInitializer(type, type.getKlassPointer());
}
private native HotSpotResolvedJavaMethodImpl getClassInitializer(HotSpotResolvedObjectTypeImpl type, long klassPointer);
/**
* Determines if {@code type} or any of its currently loaded subclasses overrides
* {@code Object.finalize()}.
*/
native boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type);
boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type) {
return hasFinalizableSubclass(type, type.getKlassPointer());
}
private native boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type, long klassPointer);
/**
* Gets the method corresponding to {@code executable}.
@ -473,7 +627,11 @@ final class CompilerToVM {
/**
* Gets a stack trace element for {@code method} at bytecode index {@code bci}.
*/
native StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, int bci);
StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, int bci) {
return getStackTraceElement(method, method.getMethodPointer(), bci);
}
private native StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, long methodPointer, int bci);
/**
* Executes some {@code installedCode} with arguments {@code args}.
@ -489,14 +647,22 @@ final class CompilerToVM {
*
* @return the line number table for {@code method} or null if it doesn't have one
*/
native long[] getLineNumberTable(HotSpotResolvedJavaMethodImpl method);
long[] getLineNumberTable(HotSpotResolvedJavaMethodImpl method) {
return getLineNumberTable(method, method.getMethodPointer());
}
private native long[] getLineNumberTable(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Gets the number of entries in the local variable table for {@code method}.
*
* @return the number of entries in the local variable table for {@code method}
*/
native int getLocalVariableTableLength(HotSpotResolvedJavaMethodImpl method);
int getLocalVariableTableLength(HotSpotResolvedJavaMethodImpl method) {
return getLocalVariableTableLength(method, method.getMethodPointer());
}
private native int getLocalVariableTableLength(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Gets the address of the first entry in the local variable table for {@code method}.
@ -514,19 +680,31 @@ final class CompilerToVM {
*
* @return 0 if {@code method} does not have a local variable table
*/
native long getLocalVariableTableStart(HotSpotResolvedJavaMethodImpl method);
long getLocalVariableTableStart(HotSpotResolvedJavaMethodImpl method) {
return getLocalVariableTableStart(method, method.getMetaspacePointer());
}
private native long getLocalVariableTableStart(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Sets flags on {@code method} indicating that it should never be inlined or compiled by the
* VM.
*/
native void setNotInlinableOrCompilable(HotSpotResolvedJavaMethodImpl method);
void setNotInlinableOrCompilable(HotSpotResolvedJavaMethodImpl method) {
setNotInlinableOrCompilable(method, method.getMethodPointer());
}
private native void setNotInlinableOrCompilable(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Invalidates the profiling information for {@code method} and (re)initializes it such that
* profiling restarts upon its next invocation.
*/
native void reprofile(HotSpotResolvedJavaMethodImpl method);
void reprofile(HotSpotResolvedJavaMethodImpl method) {
reprofile(method, method.getMethodPointer());
}
private native void reprofile(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Invalidates {@code nmethodMirror} such that {@link InvalidInstalledCodeException} will be
@ -554,25 +732,44 @@ final class CompilerToVM {
native boolean setCountersSize(int newSize);
/**
* Determines if {@code metaspaceMethodData} is mature.
* Determines if {@code methodData} is mature.
*
* @param methodData a {@code MethodData*} value
*/
native boolean isMature(long metaspaceMethodData);
native boolean isMature(long methodData);
/**
* Generate a unique id to identify the result of the compile.
*/
native int allocateCompileId(HotSpotResolvedJavaMethodImpl method, int entryBCI);
int allocateCompileId(HotSpotResolvedJavaMethodImpl method, int entryBCI) {
return allocateCompileId(method, method.getMethodPointer(), entryBCI);
}
private native int allocateCompileId(HotSpotResolvedJavaMethodImpl method, long methodPointer, int entryBCI);
/**
* Determines if {@code method} has OSR compiled code identified by {@code entryBCI} for
* compilation level {@code level}.
*/
native boolean hasCompiledCodeForOSR(HotSpotResolvedJavaMethodImpl method, int entryBCI, int level);
boolean hasCompiledCodeForOSR(HotSpotResolvedJavaMethodImpl method, int entryBCI, int level) {
return hasCompiledCodeForOSR(method, method.getMethodPointer(), entryBCI, level);
}
private native boolean hasCompiledCodeForOSR(HotSpotResolvedJavaMethodImpl method, long methodPoiner, int entryBCI, int level);
/**
* Gets the value of {@code metaspaceSymbol} as a String.
* Gets the value of {@code symbol} as a String.
*
* @param symbol a {@code Symbol*} value
*/
native String getSymbol(long metaspaceSymbol);
native String getSymbol(long symbol);
/**
* Gets the name for a {@code klass} as it would appear in a signature.
*
* @param klass a {@code Klass*} value
*/
native String getSignatureName(long klass);
/**
* @see jdk.vm.ci.code.stack.StackIntrospection#iterateFrames
@ -596,7 +793,11 @@ final class CompilerToVM {
* interface, {@code type} does not implement the interface defining {@code method}
* or class represented by {@code type} is not initialized
*/
native int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method);
int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method) {
return getVtableIndexForInterfaceMethod(type, type.getKlassPointer(), method, method.getMethodPointer());
}
private native int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, long klassPointer, HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Determines if debug info should also be emitted at non-safepoint locations.
@ -619,10 +820,10 @@ final class CompilerToVM {
native void flushDebugOutput();
/**
* Read a HotSpot Method* value from the memory location described by {@code base} plus
* Read a HotSpot {@code Method*} value from the memory location described by {@code base} plus
* {@code displacement} and return the {@link HotSpotResolvedJavaMethodImpl} wrapping it. This
* method does no checking that the memory location actually contains a valid pointer and may
* crash the VM if an invalid location is provided. If the {@code base} is null then
* crash the VM if an invalid location is provided. If {@code base == null} is null then
* {@code displacement} is used by itself. If {@code base} is a
* {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or
* {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object
@ -647,10 +848,14 @@ final class CompilerToVM {
* @throws IllegalArgumentException if {@code object} is neither a
* {@link HotSpotResolvedJavaMethodImpl} nor a {@link HotSpotResolvedObjectTypeImpl}
*/
native HotSpotConstantPool getConstantPool(MetaspaceObject object);
HotSpotConstantPool getConstantPool(MetaspaceObject object) {
return getConstantPool(object, object.getMetaspacePointer(), object instanceof HotSpotResolvedJavaType);
}
native HotSpotConstantPool getConstantPool(Object object, long klassOrMethod, boolean isKlass);
/**
* Read a HotSpot Klass* value from the memory location described by {@code base} plus
* Read a {@code Klass*} value from the memory location described by {@code base} plus
* {@code displacement} and return the {@link HotSpotResolvedObjectTypeImpl} wrapping it. This
* method does no checking that the memory location actually contains a valid pointer and may
* crash the VM if an invalid location is provided. If the {@code base} is null then
@ -722,28 +927,55 @@ final class CompilerToVM {
/**
* @see ResolvedJavaType#getInterfaces()
*/
native HotSpotResolvedObjectTypeImpl[] getInterfaces(HotSpotResolvedObjectTypeImpl type);
HotSpotResolvedObjectTypeImpl[] getInterfaces(HotSpotResolvedObjectTypeImpl klass) {
return getInterfaces(klass, klass.getKlassPointer());
}
native HotSpotResolvedObjectTypeImpl[] getInterfaces(HotSpotResolvedObjectTypeImpl klass, long klassPointer);
/**
* @see ResolvedJavaType#getComponentType()
*/
native HotSpotResolvedJavaType getComponentType(HotSpotResolvedObjectTypeImpl type);
HotSpotResolvedJavaType getComponentType(HotSpotResolvedObjectTypeImpl klass) {
return getComponentType(klass, klass.getKlassPointer());
}
native HotSpotResolvedJavaType getComponentType(HotSpotResolvedObjectTypeImpl klass, long klassPointer);
/**
* Get the array class for {@code type}. This can't be done symbolically since hidden classes
* can't be looked up by name.
* Get the array class for the primitive type represented by the {@link JavaKind#getTypeChar()}
* value in {@code typeChar} or the non-primitive type represented by {@code nonPrimitiveKlass}.
* This can't be done symbolically since hidden classes can't be looked up by name.
*
* Exactly one of {@code primitiveTypeChar} or {@code nonPrimitiveKlass} must be non-zero.
*
* @param primitiveTypeChar a {@link JavaKind#getTypeChar()} value for a primitive type
* @param nonPrimitiveKlass a non-primitive type
*/
native HotSpotResolvedObjectTypeImpl getArrayType(HotSpotResolvedJavaType type);
HotSpotResolvedObjectTypeImpl getArrayType(char primitiveTypeChar, HotSpotResolvedObjectTypeImpl nonPrimitiveKlass) {
long nonPrimitiveKlassPointer = nonPrimitiveKlass != null ? nonPrimitiveKlass.getKlassPointer() : 0L;
return getArrayType(primitiveTypeChar, nonPrimitiveKlass, nonPrimitiveKlassPointer);
}
native HotSpotResolvedObjectTypeImpl getArrayType(char typeChar, HotSpotResolvedObjectTypeImpl klass, long klassPointer);
/**
* Forces initialization of {@code type}.
* Forces initialization of {@code klass}.
*/
native void ensureInitialized(HotSpotResolvedObjectTypeImpl type);
void ensureInitialized(HotSpotResolvedObjectTypeImpl klass) {
ensureInitialized(klass, klass.getKlassPointer());
}
native void ensureInitialized(HotSpotResolvedObjectTypeImpl klass, long klassPointer);
/**
* Forces linking of {@code type}.
* Forces linking of {@code klass}.
*/
native void ensureLinked(HotSpotResolvedObjectTypeImpl type);
void ensureLinked(HotSpotResolvedObjectTypeImpl klass) {
ensureLinked(klass, klass.getKlassPointer());
}
native void ensureLinked(HotSpotResolvedObjectTypeImpl klass, long klassPointer);
/**
* Checks if {@code object} is a String and is an interned string value.
@ -767,43 +999,72 @@ final class CompilerToVM {
native HotSpotObjectConstantImpl boxPrimitive(Object source);
/**
* Gets the {@link ResolvedJavaMethod}s for all the constructors of the type {@code holder}.
* Gets the {@link ResolvedJavaMethod}s for all the constructors of {@code klass}.
*/
native ResolvedJavaMethod[] getDeclaredConstructors(HotSpotResolvedObjectTypeImpl holder);
ResolvedJavaMethod[] getDeclaredConstructors(HotSpotResolvedObjectTypeImpl klass) {
return getDeclaredConstructors(klass, klass.getKlassPointer());
}
native ResolvedJavaMethod[] getDeclaredConstructors(HotSpotResolvedObjectTypeImpl klass, long klassPointer);
/**
* Gets the {@link ResolvedJavaMethod}s for all the non-constructor methods of the type
* {@code holder}.
* Gets the {@link ResolvedJavaMethod}s for all the non-constructor methods of {@code klass}.
*/
native ResolvedJavaMethod[] getDeclaredMethods(HotSpotResolvedObjectTypeImpl holder);
ResolvedJavaMethod[] getDeclaredMethods(HotSpotResolvedObjectTypeImpl klass) {
return getDeclaredMethods(klass, klass.getKlassPointer());
}
native ResolvedJavaMethod[] getDeclaredMethods(HotSpotResolvedObjectTypeImpl klass, long klassPointer);
/**
* Reads the current value of a static field. If {@code expectedType} is non-null, then the
* object is expected to be a subtype of {@code expectedType} and extra sanity checking is
* Reads the current value of a static field of {@code declaringKlass}. Extra sanity checking is
* performed on the offset and kind of the read being performed.
*
* @param declaringKlass the type in which the static field is declared
* @param offset the offset of the field in the {@link Class} mirror of {@code declaringKlass}
* @throws IllegalArgumentException if any of the sanity checks fail
*/
native JavaConstant readFieldValue(HotSpotResolvedObjectTypeImpl object, HotSpotResolvedObjectTypeImpl expectedType, long offset, JavaKind kind);
JavaConstant readStaticFieldValue(HotSpotResolvedObjectTypeImpl declaringKlass, long offset, char typeChar) {
return readStaticFieldValue(declaringKlass, declaringKlass.getKlassPointer(), offset, typeChar);
}
native JavaConstant readStaticFieldValue(HotSpotResolvedObjectTypeImpl declaringKlass, long declaringKlassPointer, long offset, char typeChar);
/**
* Reads the current value of an instance field. If {@code expectedType} is non-null, then the
* object is expected to be a subtype of {@code expectedType} and extra sanity checking is
* Reads the current value of an instance field. If {@code expectedType} is non-null, then
* {@code object} is expected to be a subtype of {@code expectedType}. Extra sanity checking is
* performed on the offset and kind of the read being performed.
*
* @param object the object from which the field is to be read. If {@code object} is of type
* {@link Class} and {@code offset} is >= the offset of the static field storage in a
* {@link Class} instance, then this operation is a static field read.
* @param expectedType the expected type of {@code object}
* @throws IllegalArgumentException if any of the sanity checks fail
*/
native JavaConstant readFieldValue(HotSpotObjectConstantImpl object, HotSpotResolvedObjectTypeImpl expectedType, long offset, JavaKind kind);
JavaConstant readFieldValue(HotSpotObjectConstantImpl object, HotSpotResolvedObjectTypeImpl expectedType, long offset, char typeChar) {
long expectedTypePointer = expectedType != null ? expectedType.getKlassPointer() : 0L;
return readFieldValue(object, expectedType, expectedTypePointer, offset, typeChar);
}
native JavaConstant readFieldValue(HotSpotObjectConstantImpl object, HotSpotResolvedObjectTypeImpl expectedType, long expectedTypePointer, long offset, char typeChar);
/**
* @see ResolvedJavaType#isInstance(JavaConstant)
*/
native boolean isInstance(HotSpotResolvedObjectTypeImpl holder, HotSpotObjectConstantImpl object);
boolean isInstance(HotSpotResolvedObjectTypeImpl klass, HotSpotObjectConstantImpl object) {
return isInstance(klass, klass.getKlassPointer(), object);
}
native boolean isInstance(HotSpotResolvedObjectTypeImpl klass, long klassPointer, HotSpotObjectConstantImpl object);
/**
* @see ResolvedJavaType#isAssignableFrom(ResolvedJavaType)
*/
native boolean isAssignableFrom(HotSpotResolvedObjectTypeImpl holder, HotSpotResolvedObjectTypeImpl otherType);
boolean isAssignableFrom(HotSpotResolvedObjectTypeImpl klass, HotSpotResolvedObjectTypeImpl subklass) {
return isAssignableFrom(klass, klass.getKlassPointer(), subklass, subklass.getKlassPointer());
}
native boolean isAssignableFrom(HotSpotResolvedObjectTypeImpl klass, long klassPointer, HotSpotResolvedObjectTypeImpl subklass, long subklassPointer);
/**
* @see ConstantReflectionProvider#asJavaType(Constant)
@ -821,9 +1082,13 @@ final class CompilerToVM {
native boolean equals(HotSpotObjectConstantImpl x, long xHandle, HotSpotObjectConstantImpl y, long yHandle);
/**
* Gets a {@link JavaConstant} wrapping the {@link java.lang.Class} mirror for {@code type}.
* Gets a {@link JavaConstant} wrapping the {@link java.lang.Class} mirror for {@code klass}.
*/
native HotSpotObjectConstantImpl getJavaMirror(HotSpotResolvedJavaType type);
HotSpotObjectConstantImpl getJavaMirror(HotSpotResolvedObjectTypeImpl klass) {
return getJavaMirror(klass, klass.getKlassPointer());
}
native HotSpotObjectConstantImpl getJavaMirror(HotSpotResolvedObjectTypeImpl type, long klassPointer);
/**
* Returns the length of the array if {@code object} represents an array or -1 otherwise.
@ -867,7 +1132,11 @@ final class CompilerToVM {
/**
* Gets a {@link Executable} corresponding to {@code method}.
*/
native Executable asReflectionExecutable(HotSpotResolvedJavaMethodImpl method);
Executable asReflectionExecutable(HotSpotResolvedJavaMethodImpl method) {
return asReflectionExecutable(method, method.getMethodPointer());
}
native Executable asReflectionExecutable(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Gets a {@link Field} denoted by {@code holder} and {@code index}.
@ -875,12 +1144,20 @@ final class CompilerToVM {
* @param holder the class in which the requested field is declared
* @param fieldIndex the {@code fieldDescriptor::index()} denoting the field
*/
native Field asReflectionField(HotSpotResolvedObjectTypeImpl holder, int fieldIndex);
Field asReflectionField(HotSpotResolvedObjectTypeImpl holder, int fieldIndex) {
return asReflectionField(holder, holder.getKlassPointer(), fieldIndex);
}
native Field asReflectionField(HotSpotResolvedObjectTypeImpl holder, long holderPointer, int fieldIndex);
/**
* @see HotSpotJVMCIRuntime#getIntrinsificationTrustPredicate(Class...)
*/
native boolean isTrustedForIntrinsics(HotSpotResolvedObjectTypeImpl type);
boolean isTrustedForIntrinsics(HotSpotResolvedObjectTypeImpl klass) {
return isTrustedForIntrinsics(klass, klass.getKlassPointer());
}
native boolean isTrustedForIntrinsics(HotSpotResolvedObjectTypeImpl klass, long klassPointer);
/**
* Releases the resources backing the global JNI {@code handle}. This is equivalent to the
@ -902,7 +1179,11 @@ final class CompilerToVM {
* {@code MethodData} associated with {@code method}. This will create and install the
* {@code MethodData} if it didn't already exist.
*/
native long getFailedSpeculationsAddress(HotSpotResolvedJavaMethodImpl method);
long getFailedSpeculationsAddress(HotSpotResolvedJavaMethodImpl method) {
return getFailedSpeculationsAddress(method, method.getMethodPointer());
}
native long getFailedSpeculationsAddress(HotSpotResolvedJavaMethodImpl method, long methodPointer);
/**
* Frees the failed speculations pointed to by {@code *failedSpeculationsAddress}.
@ -983,6 +1264,10 @@ final class CompilerToVM {
/**
* @see JFR.CompilerInliningEvent#write
*/
native void notifyCompilerInliningEvent(int compileId, HotSpotResolvedJavaMethodImpl caller, HotSpotResolvedJavaMethodImpl callee, boolean succeeded, String message, int bci);
void notifyCompilerInliningEvent(int compileId, HotSpotResolvedJavaMethodImpl caller, HotSpotResolvedJavaMethodImpl callee, boolean succeeded, String message, int bci) {
notifyCompilerInliningEvent(compileId, caller, caller.getMethodPointer(), callee, callee.getMethodPointer(), succeeded, message, bci);
}
native void notifyCompilerInliningEvent(int compileId, HotSpotResolvedJavaMethodImpl caller, long callerPointer,
HotSpotResolvedJavaMethodImpl callee, long calleePointer, boolean succeeded, String message, int bci);
}

View File

@ -136,7 +136,7 @@ public class HotSpotCodeCacheProvider implements CodeCacheProvider {
resultInstalledCode = nmethod;
}
int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, failedSpeculationsAddress, speculations);
int result = runtime.getCompilerToVM().installCode(hsCompiledCode, resultInstalledCode, failedSpeculationsAddress, speculations);
if (result != config.codeInstallResultOk) {
String resultDesc = config.getCodeInstallResultDescription(result);
if (hsCompiledNmethod != null) {

View File

@ -118,8 +118,19 @@ public class HotSpotCompiledCode implements CompiledCode {
}
@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `sites`, `targetCode`, `comments`, `methods`, `dataSection`, `dataSectionPatches` and `assumptions`")
public HotSpotCompiledCode(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection,
int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot) {
public HotSpotCompiledCode(String name,
byte[] targetCode,
int targetCodeSize,
Site[] sites,
Assumption[] assumptions,
ResolvedJavaMethod[] methods,
Comment[] comments,
byte[] dataSection,
int dataSectionAlignment,
DataPatch[] dataSectionPatches,
boolean isImmutablePIC,
int totalFrameSize,
StackSlot deoptRescueSlot) {
this.name = name;
this.targetCode = targetCode;
this.targetCodeSize = targetCodeSize;

View File

@ -54,10 +54,37 @@ public final class HotSpotCompiledNmethod extends HotSpotCompiledCode {
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "set by the VM") private String installationFailureMessage;
public HotSpotCompiledNmethod(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection,
int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot, HotSpotResolvedJavaMethod method, int entryBCI,
int id, long compileState, boolean hasUnsafeAccess) {
super(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, deoptRescueSlot);
public HotSpotCompiledNmethod(String name,
byte[] targetCode,
int targetCodeSize,
Site[] sites,
Assumption[] assumptions,
ResolvedJavaMethod[] methods,
Comment[] comments,
byte[] dataSection,
int dataSectionAlignment,
DataPatch[] dataSectionPatches,
boolean isImmutablePIC,
int totalFrameSize,
StackSlot deoptRescueSlot,
HotSpotResolvedJavaMethod method,
int entryBCI,
int id,
long compileState,
boolean hasUnsafeAccess) {
super(name,
targetCode,
targetCodeSize,
sites,
assumptions,
methods,
comments,
dataSection,
dataSectionAlignment,
dataSectionPatches,
isImmutablePIC,
totalFrameSize,
deoptRescueSlot);
this.method = method;
this.entryBCI = entryBCI;
this.id = id;

View File

@ -28,7 +28,6 @@ import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -198,34 +197,38 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
}
/**
* Handle to the {@code ConstantPool} VM object. The handle is in
* {@code JVMCI::_metadata_handles}.
* A {@code jmetadata} value that is a handle to {@code ConstantPool*} value.
*/
private final long metadataHandle;
private final long constantPoolHandle;
private volatile LookupTypeCacheElement lastLookupType;
private final JvmConstants constants;
/**
* Gets the JVMCI mirror from a HotSpot constant pool.The VM is responsible for ensuring that
* Cache for {@link #getHolder()}.
*/
private HotSpotResolvedObjectTypeImpl holder;
/**
* Gets the JVMCI mirror from a HotSpot constant pool. The VM is responsible for ensuring that
* the ConstantPool is kept alive for the duration of this call and the
* {@link HotSpotJVMCIRuntime} keeps it alive after that.
*
* Called from the VM.
*
* @param metaspaceConstantPool a metaspace ConstantPool object
* @return the {@link HotSpotConstantPool} corresponding to {@code metaspaceConstantPool}
* @param constantPoolHandle a {@code jmetaspace} handle to a raw {@code ConstantPool*} value
* @return the {@link HotSpotConstantPool} corresponding to {@code constantPoolHandle}
*/
@SuppressWarnings("unused")
@VMEntryPoint
private static HotSpotConstantPool fromMetaspace(long metaspaceConstantPool) {
return new HotSpotConstantPool(metaspaceConstantPool);
private static HotSpotConstantPool fromMetaspace(long constantPoolHandle) {
return new HotSpotConstantPool(constantPoolHandle);
}
private HotSpotConstantPool(long metadataHandle) {
this.metadataHandle = metadataHandle;
private HotSpotConstantPool(long constantPoolHandle) {
this.constantPoolHandle = constantPoolHandle;
this.constants = JvmConstants.instance();
HandleCleaner.create(this, metadataHandle);
HandleCleaner.create(this, constantPoolHandle);
}
/**
@ -234,7 +237,10 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
* @return holder for this constant pool
*/
private HotSpotResolvedObjectType getHolder() {
return compilerToVM().getResolvedJavaType(this, config().constantPoolHolderOffset, false);
if (holder == null) {
holder = compilerToVM().getResolvedJavaType(this, config().constantPoolHolderOffset, false);
}
return holder;
}
/**
@ -290,13 +296,16 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
return ~i;
}
long getMetaspaceConstantPool() {
/**
* Gets the raw {@code ConstantPool*} value for the this constant pool.
*/
long getConstantPoolPointer() {
return getMetaspacePointer();
}
@Override
public long getMetadataHandle() {
return metadataHandle;
return constantPoolHandle;
}
/**
@ -308,7 +317,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
private JvmConstant getTagAt(int index) {
assert checkBounds(index);
HotSpotVMConfig config = config();
final long metaspaceConstantPoolTags = UNSAFE.getAddress(getMetaspaceConstantPool() + config.constantPoolTagsOffset);
final long metaspaceConstantPoolTags = UNSAFE.getAddress(getConstantPoolPointer() + config.constantPoolTagsOffset);
final int tag = UNSAFE.getByteVolatile(null, metaspaceConstantPoolTags + config.arrayU1DataOffset + index);
if (tag == 0) {
return null;
@ -325,7 +334,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
long getEntryAt(int index) {
assert checkBounds(index);
int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
return UNSAFE.getAddress(getMetaspaceConstantPool() + config().constantPoolSize + offset);
return UNSAFE.getAddress(getConstantPoolPointer() + config().constantPoolSize + offset);
}
/**
@ -337,7 +346,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
private int getIntAt(int index) {
assert checkTag(index, constants.jvmInteger);
int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + offset);
return UNSAFE.getInt(getConstantPoolPointer() + config().constantPoolSize + offset);
}
/**
@ -349,7 +358,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
private long getLongAt(int index) {
assert checkTag(index, constants.jvmLong);
int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
return UNSAFE.getLong(getMetaspaceConstantPool() + config().constantPoolSize + offset);
return UNSAFE.getLong(getConstantPoolPointer() + config().constantPoolSize + offset);
}
/**
@ -361,7 +370,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
private float getFloatAt(int index) {
assert checkTag(index, constants.jvmFloat);
int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
return UNSAFE.getFloat(getMetaspaceConstantPool() + config().constantPoolSize + offset);
return UNSAFE.getFloat(getConstantPoolPointer() + config().constantPoolSize + offset);
}
/**
@ -373,7 +382,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
private double getDoubleAt(int index) {
assert checkTag(index, constants.jvmDouble);
int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
return UNSAFE.getDouble(getMetaspaceConstantPool() + config().constantPoolSize + offset);
return UNSAFE.getDouble(getConstantPoolPointer() + config().constantPoolSize + offset);
}
/**
@ -385,7 +394,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
private int getNameAndTypeAt(int index) {
assert checkTag(index, constants.jvmNameAndType);
int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + offset);
return UNSAFE.getInt(getConstantPoolPointer() + config().constantPoolSize + offset);
}
/**
@ -467,7 +476,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
private int getUncachedKlassRefIndexAt(int index) {
assert checkTagIsFieldOrMethod(index);
int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
final int refIndex = UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + offset);
final int refIndex = UNSAFE.getInt(getConstantPoolPointer() + config().constantPoolSize + offset);
// klass ref index is in the low 16-bits.
return refIndex & 0xFFFF;
}
@ -512,7 +521,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
@Override
public int length() {
return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolLengthOffset);
return UNSAFE.getInt(getConstantPoolPointer() + config().constantPoolLengthOffset);
}
public boolean hasDynamicConstant() {
@ -520,7 +529,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
}
private int flags() {
return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolFlagsOffset);
return UNSAFE.getInt(getConstantPoolPointer() + config().constantPoolFlagsOffset);
}
static class BootstrapMethodInvocationImpl implements BootstrapMethodInvocation {
@ -690,13 +699,11 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
String name = getNameOf(index);
HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureOf(index));
if (opcode == Bytecodes.INVOKEDYNAMIC) {
HotSpotResolvedObjectType holder = runtime().getMethodHandleClass();
return new UnresolvedJavaMethod(name, signature, holder);
return new UnresolvedJavaMethod(name, signature, runtime().getMethodHandleClass());
} else {
final int klassIndex = getKlassRefIndexAt(index);
final Object type = compilerToVM().lookupKlassInPool(this, klassIndex);
JavaType holder = getJavaType(type);
return new UnresolvedJavaMethod(name, signature, holder);
return new UnresolvedJavaMethod(name, signature, getJavaType(type));
}
}
}
@ -758,9 +765,9 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
JavaType type = runtime().lookupType(typeName, getHolder(), false);
final int holderIndex = getKlassRefIndexAt(index);
JavaType holder = lookupType(holderIndex, opcode);
JavaType fieldHolder = lookupType(holderIndex, opcode);
if (holder instanceof HotSpotResolvedObjectTypeImpl) {
if (fieldHolder instanceof HotSpotResolvedObjectTypeImpl) {
int[] info = new int[3];
HotSpotResolvedObjectTypeImpl resolvedHolder;
try {
@ -770,7 +777,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
* If there was an exception resolving the field we give up and return an unresolved
* field.
*/
return new UnresolvedJavaField(holder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
return new UnresolvedJavaField(fieldHolder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
}
final int flags = info[0];
final int offset = info[1];
@ -778,7 +785,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
HotSpotResolvedJavaField result = resolvedHolder.createField(type, offset, flags, fieldIndex);
return result;
} else {
return new UnresolvedJavaField(holder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
return new UnresolvedJavaField(fieldHolder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
}
}
@ -929,7 +936,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
}
public String getSourceFileName() {
final int sourceFileNameIndex = UNSAFE.getChar(getMetaspaceConstantPool() + config().constantPoolSourceFileNameIndexOffset);
final int sourceFileNameIndex = UNSAFE.getChar(getConstantPoolPointer() + config().constantPoolSourceFileNameIndexOffset);
if (sourceFileNameIndex == 0) {
return null;
}
@ -938,7 +945,6 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
@Override
public String toString() {
HotSpotResolvedObjectType holder = getHolder();
return "HotSpotConstantPool<" + holder.toJavaName() + ">";
return "HotSpotConstantPool<" + getHolder().toJavaName() + ">";
}
}

View File

@ -1,125 +0,0 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* 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.
*
* 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.
*/
package jdk.vm.ci.hotspot;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
/**
* Represents a constant that was retrieved from a constant pool. Used to keep track of the constant
* pool slot for the constant.
*/
public final class HotSpotConstantPoolObject implements JavaConstant {
public static JavaConstant forObject(HotSpotResolvedObjectType type, int cpi, JavaConstant object) {
return new HotSpotConstantPoolObject(type, cpi, object);
}
private final JavaConstant constant;
private final HotSpotResolvedObjectType type;
private final int cpi;
public HotSpotResolvedObjectType getCpType() {
return type;
}
public int getCpi() {
return cpi;
}
HotSpotConstantPoolObject(HotSpotResolvedObjectType type, int cpi, JavaConstant constant) {
this.type = type;
this.cpi = cpi;
this.constant = constant;
}
@Override
public boolean equals(Object o) {
if (o instanceof HotSpotConstantPoolObject) {
HotSpotConstantPoolObject other = (HotSpotConstantPoolObject) o;
return type.equals(other.type) && cpi == other.cpi && constant.equals(other.constant);
}
return false;
}
@Override
public int hashCode() {
return constant.hashCode() + cpi + type.hashCode();
}
@Override
public JavaKind getJavaKind() {
return constant.getJavaKind();
}
@Override
public boolean isNull() {
return constant.isNull();
}
@Override
public boolean isDefaultForKind() {
return constant.isDefaultForKind();
}
@Override
public Object asBoxedPrimitive() {
return constant.asBoxedPrimitive();
}
@Override
public int asInt() {
return constant.asInt();
}
@Override
public boolean asBoolean() {
return constant.asBoolean();
}
@Override
public long asLong() {
return constant.asLong();
}
@Override
public float asFloat() {
return constant.asFloat();
}
@Override
public double asDouble() {
return 0;
}
@Override
public String toValueString() {
return getCpType().getName() + getCpi();
}
@Override
public String toString() {
return super.toString() + "@" + toValueString();
}
}

View File

@ -164,10 +164,10 @@ public class HotSpotConstantReflectionProvider implements ConstantReflectionProv
public JavaConstant readFieldValue(ResolvedJavaField field, JavaConstant receiver) {
HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field;
if (hotspotField.isStatic()) {
HotSpotResolvedObjectTypeImpl holder = (HotSpotResolvedObjectTypeImpl) hotspotField.getDeclaringClass();
if (holder.isInitialized()) {
return runtime().compilerToVm.readFieldValue(holder, (HotSpotResolvedObjectTypeImpl) hotspotField.getDeclaringClass(), hotspotField.getOffset(),
hotspotField.getType().getJavaKind());
HotSpotResolvedObjectTypeImpl declaringType = (HotSpotResolvedObjectTypeImpl) hotspotField.getDeclaringClass();
if (declaringType.isInitialized()) {
return runtime().compilerToVm.readStaticFieldValue(declaringType, hotspotField.getOffset(),
hotspotField.getType().getJavaKind().getTypeChar());
}
} else if (receiver instanceof HotSpotObjectConstantImpl) {
return ((HotSpotObjectConstantImpl) receiver).readFieldValue(hotspotField);

View File

@ -333,4 +333,3 @@ final class HotSpotJDKReflection extends HotSpotJVMCIReflection {
}
}
}

View File

@ -264,6 +264,11 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
// Note: The following one is not used (see InitTimer.ENABLED). It is added here
// so that -XX:+JVMCIPrintProperties shows the option.
InitTimer(Boolean.class, false, "Specifies if initialization timing is enabled."),
CodeSerializationTypeInfo(Boolean.class, false, "Prepend the size and label of each element to the stream when " +
"serializing HotSpotCompiledCode to verify both ends of the protocol agree on the format. " +
"Defaults to true in non-product builds."),
DumpSerializedCode(String.class, null, "Dump serialized code during code installation for code whose simple " +
"name (a stub) or fully qualified name (an nmethod) contains this option's value as a substring."),
ForceTranslateFailure(String.class, null, "Forces HotSpotJVMCIRuntime.translate to throw an exception in the context " +
"of the peer runtime. The value is a filter that can restrict the forced failure to matching translated " +
"objects. See HotSpotJVMCIRuntime.postTranslation for more details. This option exists soley to test " +
@ -291,7 +296,7 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
private final Class<?> type;
@NativeImageReinitialize private Object value;
private final Object defaultValue;
private boolean isDefault = true;
boolean isDefault = true;
private final String[] helpLines;
Option(Class<?> type, Object defaultValue, String... helpLines) {
@ -701,7 +706,7 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
return fromClass0(javaClass);
}
synchronized HotSpotResolvedObjectTypeImpl fromMetaspace(long klassPointer, String signature) {
synchronized HotSpotResolvedObjectTypeImpl fromMetaspace(long klassPointer) {
if (resolvedJavaTypes == null) {
resolvedJavaTypes = new HashMap<>();
}
@ -712,7 +717,8 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
javaType = (HotSpotResolvedObjectTypeImpl) klassReference.get();
}
if (javaType == null) {
javaType = new HotSpotResolvedObjectTypeImpl(klassPointer, signature);
String name = compilerToVm.getSignatureName(klassPointer);
javaType = new HotSpotResolvedObjectTypeImpl(klassPointer, name);
resolvedJavaTypes.put(klassPointer, new WeakReference<>(javaType));
}
return javaType;

View File

@ -78,7 +78,7 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider {
}
}
HotSpotObjectConstantImpl baseObject = (HotSpotObjectConstantImpl) baseConstant;
JavaConstant result = runtime().compilerToVm.readFieldValue(baseObject, null, initialDisplacement, readKind);
JavaConstant result = runtime().compilerToVm.readFieldValue(baseObject, null, initialDisplacement, readKind.getTypeChar());
if (result != null && kind != readKind) {
return JavaConstant.forPrimitive(kind, result.asLong());
}
@ -109,7 +109,8 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider {
@Override
public JavaConstant readObjectConstant(Constant base, long displacement) {
if (base instanceof HotSpotObjectConstantImpl) {
return runtime.getCompilerToVM().readFieldValue((HotSpotObjectConstantImpl) base, null, displacement, JavaKind.Object);
HotSpotObjectConstantImpl hsBase = (HotSpotObjectConstantImpl) base;
return runtime.getCompilerToVM().readFieldValue(hsBase, null, displacement, JavaKind.Object.getTypeChar());
}
if (base instanceof HotSpotMetaspaceConstant) {
MetaspaceObject metaspaceObject = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base);
@ -131,7 +132,8 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider {
public JavaConstant readNarrowOopConstant(Constant base, long displacement) {
if (base instanceof HotSpotObjectConstantImpl) {
assert runtime.getConfig().useCompressedOops;
JavaConstant res = runtime.getCompilerToVM().readFieldValue((HotSpotObjectConstantImpl) base, null, displacement, JavaKind.Object);
HotSpotObjectConstantImpl hsBase = (HotSpotObjectConstantImpl) base;
JavaConstant res = runtime.getCompilerToVM().readFieldValue(hsBase, null, displacement, JavaKind.Object.getTypeChar());
if (res != null) {
return JavaConstant.NULL_POINTER.equals(res) ? HotSpotCompressedNullConstant.COMPRESSED_NULL : ((HotSpotObjectConstant) res).compress();
}

View File

@ -162,14 +162,14 @@ final class HotSpotMethodData {
}
/**
* Reference to the C++ MethodData object.
* A {@code MethodData*} value.
*/
final long metaspaceMethodData;
final long methodDataPointer;
private final HotSpotResolvedJavaMethodImpl method;
private final VMState state;
HotSpotMethodData(long metaspaceMethodData, HotSpotResolvedJavaMethodImpl method) {
this.metaspaceMethodData = metaspaceMethodData;
HotSpotMethodData(long methodDataPointer, HotSpotResolvedJavaMethodImpl method) {
this.methodDataPointer = methodDataPointer;
this.method = method;
this.state = VMState.instance();
}
@ -178,7 +178,7 @@ final class HotSpotMethodData {
* @return value of the MethodData::_data_size field
*/
private int normalDataSize() {
return UNSAFE.getInt(metaspaceMethodData + state.config.methodDataDataSize);
return UNSAFE.getInt(methodDataPointer + state.config.methodDataDataSize);
}
/**
@ -189,7 +189,7 @@ final class HotSpotMethodData {
*/
private int extraDataSize() {
final int extraDataBase = state.config.methodDataOopDataOffset + normalDataSize();
final int extraDataLimit = UNSAFE.getInt(metaspaceMethodData + state.config.methodDataSize);
final int extraDataLimit = UNSAFE.getInt(methodDataPointer + state.config.methodDataSize);
return extraDataLimit - extraDataBase;
}
@ -212,25 +212,25 @@ final class HotSpotMethodData {
public int getDeoptimizationCount(DeoptimizationReason reason) {
HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) runtime().getHostJVMCIBackend().getMetaAccess();
int reasonIndex = metaAccess.convertDeoptReason(reason);
return UNSAFE.getByte(metaspaceMethodData + state.config.methodDataOopTrapHistoryOffset + reasonIndex) & 0xFF;
return UNSAFE.getByte(methodDataPointer + state.config.methodDataOopTrapHistoryOffset + reasonIndex) & 0xFF;
}
public int getOSRDeoptimizationCount(DeoptimizationReason reason) {
HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) runtime().getHostJVMCIBackend().getMetaAccess();
int reasonIndex = metaAccess.convertDeoptReason(reason);
return UNSAFE.getByte(metaspaceMethodData + state.config.methodDataOopTrapHistoryOffset + state.config.deoptReasonOSROffset + reasonIndex) & 0xFF;
return UNSAFE.getByte(methodDataPointer + state.config.methodDataOopTrapHistoryOffset + state.config.deoptReasonOSROffset + reasonIndex) & 0xFF;
}
public int getDecompileCount() {
return UNSAFE.getInt(metaspaceMethodData + state.config.methodDataDecompiles);
return UNSAFE.getInt(methodDataPointer + state.config.methodDataDecompiles);
}
public int getOverflowRecompileCount() {
return UNSAFE.getInt(metaspaceMethodData + state.config.methodDataOverflowRecompiles);
return UNSAFE.getInt(methodDataPointer + state.config.methodDataOverflowRecompiles);
}
public int getOverflowTrapCount() {
return UNSAFE.getInt(metaspaceMethodData + state.config.methodDataOverflowTraps);
return UNSAFE.getInt(methodDataPointer + state.config.methodDataOverflowTraps);
}
public HotSpotMethodDataAccessor getNormalData(int position) {
@ -270,12 +270,12 @@ final class HotSpotMethodData {
int readUnsignedByte(int position, int offsetInBytes) {
long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes);
return UNSAFE.getByte(metaspaceMethodData + fullOffsetInBytes) & 0xFF;
return UNSAFE.getByte(methodDataPointer + fullOffsetInBytes) & 0xFF;
}
int readUnsignedShort(int position, int offsetInBytes) {
long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes);
return UNSAFE.getShort(metaspaceMethodData + fullOffsetInBytes) & 0xFFFF;
return UNSAFE.getShort(methodDataPointer + fullOffsetInBytes) & 0xFFFF;
}
/**
@ -284,7 +284,7 @@ final class HotSpotMethodData {
*/
private long readUnsignedInt(int position, int offsetInBytes) {
long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes);
return UNSAFE.getAddress(metaspaceMethodData + fullOffsetInBytes) & 0xFFFFFFFFL;
return UNSAFE.getAddress(methodDataPointer + fullOffsetInBytes) & 0xFFFFFFFFL;
}
private int readUnsignedIntAsSignedInt(int position, int offsetInBytes) {
@ -298,17 +298,21 @@ final class HotSpotMethodData {
*/
private int readInt(int position, int offsetInBytes) {
long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes);
return (int) UNSAFE.getAddress(metaspaceMethodData + fullOffsetInBytes);
return (int) UNSAFE.getAddress(methodDataPointer + fullOffsetInBytes);
}
private HotSpotResolvedJavaMethod readMethod(int position, int offsetInBytes) {
long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes);
return compilerToVM().getResolvedJavaMethod(null, metaspaceMethodData + fullOffsetInBytes);
return compilerToVM().getResolvedJavaMethod(null, methodDataPointer + fullOffsetInBytes);
}
private HotSpotResolvedObjectTypeImpl readKlass(int position, int offsetInBytes) {
long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes);
return compilerToVM().getResolvedJavaType(metaspaceMethodData + fullOffsetInBytes, false);
long klassPointer = UNSAFE.getAddress(methodDataPointer + fullOffsetInBytes);
if (klassPointer == 0) {
return null;
}
return runtime().fromMetaspace(klassPointer);
}
/**
@ -316,7 +320,7 @@ final class HotSpotMethodData {
* informational data will still be valid even if the profile isn't mature.
*/
public boolean isProfileMature() {
return runtime().getCompilerToVM().isMature(metaspaceMethodData);
return runtime().getCompilerToVM().isMature(methodDataPointer);
}
@Override
@ -713,7 +717,7 @@ final class HotSpotMethodData {
@Override
protected int getDynamicSize(HotSpotMethodData data, int position) {
assert staticSize == 0;
return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position);
return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.methodDataPointer, position);
}
}
@ -870,7 +874,7 @@ final class HotSpotMethodData {
@Override
protected int getDynamicSize(HotSpotMethodData data, int position) {
assert staticSize == 0;
return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position);
return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.methodDataPointer, position);
}
@Override
@ -881,10 +885,10 @@ final class HotSpotMethodData {
}
public void setCompiledIRSize(int size) {
UNSAFE.putInt(metaspaceMethodData + state.config.methodDataIRSizeOffset, size);
UNSAFE.putInt(methodDataPointer + state.config.methodDataIRSizeOffset, size);
}
public int getCompiledIRSize() {
return UNSAFE.getInt(metaspaceMethodData + state.config.methodDataIRSizeOffset);
return UNSAFE.getInt(methodDataPointer + state.config.methodDataIRSizeOffset);
}
}

View File

@ -78,7 +78,7 @@ abstract class HotSpotMethodDataAccessor {
final int getSize(HotSpotMethodData data, int position) {
int size = staticSize + getDynamicSize(data, position);
// Sanity check against VM
int vmSize = HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position);
int vmSize = HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.methodDataPointer, position);
assert size == vmSize : size + " != " + vmSize;
return size;
}

View File

@ -193,7 +193,9 @@ abstract class HotSpotObjectConstantImpl implements HotSpotObjectConstant {
if (field.isStatic()) {
return null;
}
return runtime().compilerToVm.readFieldValue(this, (HotSpotResolvedObjectTypeImpl) field.getDeclaringClass(), field.getOffset(), field.getType().getJavaKind());
HotSpotResolvedObjectTypeImpl declaringClass = (HotSpotResolvedObjectTypeImpl) field.getDeclaringClass();
char typeChar = field.getType().getJavaKind().getTypeChar();
return runtime().compilerToVm.readFieldValue(this, declaringClass, field.getOffset(), typeChar);
}
public ResolvedJavaType asJavaType() {

View File

@ -32,10 +32,10 @@ import jdk.vm.ci.code.ReferenceMap;
*/
public final class HotSpotReferenceMap extends ReferenceMap {
private final Location[] objects;
private final Location[] derivedBase;
private final int[] sizeInBytes;
private final int maxRegisterSize;
final Location[] objects;
final Location[] derivedBase;
final int[] sizeInBytes;
final int maxRegisterSize;
/**
*

View File

@ -179,7 +179,7 @@ class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField {
private boolean hasAnnotations() {
if (!isInternal()) {
HotSpotVMConfig config = config();
final long metaspaceAnnotations = UNSAFE.getAddress(holder.getMetaspaceKlass() + config.instanceKlassAnnotationsOffset);
final long metaspaceAnnotations = UNSAFE.getAddress(holder.getKlassPointer() + config.instanceKlassAnnotationsOffset);
if (metaspaceAnnotations != 0) {
long fieldsAnnotations = UNSAFE.getAddress(metaspaceAnnotations + config.annotationsFieldAnnotationsOffset);
if (fieldsAnnotations != 0) {

View File

@ -59,10 +59,9 @@ import jdk.vm.ci.meta.TriState;
final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSpotResolvedJavaMethod, MetaspaceHandleObject {
/**
* Handle to the metaspace {@code Method} object. The handle is in
* {@code JVMCI::_metadata_handles}.
* A {@code jmetadata} value that is a handle to {@code Method*} value.
*/
private final long metadataHandle;
private final long methodHandle;
private final HotSpotResolvedObjectTypeImpl holder;
private final HotSpotConstantPool constantPool;
@ -94,9 +93,8 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
assert metaspaceMethod != 0 : metaspaceHandle;
final long metaspaceConstMethod = UNSAFE.getAddress(metaspaceMethod + config.methodConstMethodOffset);
final long metaspaceConstantPool = UNSAFE.getAddress(metaspaceConstMethod + config.constMethodConstantsOffset);
HotSpotResolvedObjectTypeImpl result = compilerToVM().getResolvedJavaType(metaspaceConstantPool + config.constantPoolHolderOffset, false);
assert result != null;
return result;
long klassPointer = UNSAFE.getAddress(metaspaceConstantPool + config.constantPoolHolderOffset);
return runtime().fromMetaspace(klassPointer);
}
/**
@ -117,7 +115,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
}
HotSpotResolvedJavaMethodImpl(HotSpotResolvedObjectTypeImpl holder, long metaspaceHandle) {
this.metadataHandle = metaspaceHandle;
this.methodHandle = metaspaceHandle;
this.holder = holder;
HotSpotVMConfig config = config();
@ -129,7 +127,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
* one from their holder.
*/
final long metaspaceConstantPool = UNSAFE.getAddress(constMethod + config.constMethodConstantsOffset);
if (metaspaceConstantPool == holder.getConstantPool().getMetaspaceConstantPool()) {
if (metaspaceConstantPool == holder.getConstantPool().getConstantPoolPointer()) {
this.constantPool = holder.getConstantPool();
} else {
this.constantPool = compilerToVM().getConstantPool(this);
@ -149,7 +147,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
* @return pointer to this method's ConstMethod
*/
private long getConstMethod() {
return UNSAFE.getAddress(getMetaspaceMethod() + config().methodConstMethodOffset);
return UNSAFE.getAddress(getMethodPointer() + config().methodConstMethodOffset);
}
@Override
@ -168,14 +166,14 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
}
if (obj instanceof HotSpotResolvedJavaMethodImpl) {
HotSpotResolvedJavaMethodImpl that = (HotSpotResolvedJavaMethodImpl) obj;
return that.getMetaspaceMethod() == getMetaspaceMethod();
return getMethodPointer() == getMethodPointer();
}
return false;
}
@Override
public int hashCode() {
return Long.hashCode(getMetaspaceMethod());
return Long.hashCode(getMethodPointer());
}
/**
@ -184,7 +182,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
* @return flags of this method
*/
private int getFlags() {
return UNSAFE.getShort(getMetaspaceMethod() + config().methodFlagsOffset);
return UNSAFE.getShort(getMethodPointer() + config().methodFlagsOffset);
}
/**
@ -204,11 +202,11 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
/**
* Gets the address of the C++ Method object for this method.
*/
public Constant getMetaspaceMethodConstant() {
private Constant getMetaspaceMethodConstant() {
return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false);
}
long getMetaspaceMethod() {
long getMethodPointer() {
long metaspacePointer = getMetaspacePointer();
if (metaspacePointer == 0) {
throw new NullPointerException("Method* is null");
@ -218,7 +216,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
@Override
public long getMetadataHandle() {
return metadataHandle;
return methodHandle;
}
@Override
@ -231,7 +229,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
* modifiers as well as the HotSpot internal modifiers.
*/
public int getAllModifiers() {
return UNSAFE.getInt(getMetaspaceMethod() + config().methodAccessFlagsOffset);
return UNSAFE.getInt(getMethodPointer() + config().methodAccessFlagsOffset);
}
@Override
@ -424,7 +422,8 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
// CHA for default methods doesn't work and may crash the VM
return null;
}
return compilerToVM().findUniqueConcreteMethod(((HotSpotResolvedObjectTypeImpl) receiver), this);
HotSpotResolvedObjectTypeImpl hsReceiver = (HotSpotResolvedObjectTypeImpl) receiver;
return compilerToVM().findUniqueConcreteMethod(hsReceiver, this);
}
@Override
@ -439,7 +438,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
*/
private long getCompiledCode() {
HotSpotVMConfig config = config();
return UNSAFE.getAddress(getMetaspaceMethod() + config.methodCodeOffset);
return UNSAFE.getAddress(getMethodPointer() + config.methodCodeOffset);
}
/**
@ -470,9 +469,9 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
ProfilingInfo info;
if (Option.UseProfilingInformation.getBoolean() && methodData == null) {
long metaspaceMethodData = UNSAFE.getAddress(getMetaspaceMethod() + config().methodDataOffset);
if (metaspaceMethodData != 0) {
methodData = new HotSpotMethodData(metaspaceMethodData, this);
long methodDataPointer = UNSAFE.getAddress(getMethodPointer() + config().methodDataOffset);
if (methodDataPointer != 0) {
methodData = new HotSpotMethodData(methodDataPointer, this);
String methodDataFilter = Option.TraceMethodDataFilter.getString();
if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) {
String line = methodData.toString() + System.lineSeparator();
@ -696,7 +695,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
private int getVtableIndex() {
assert !holder.isInterface();
HotSpotVMConfig config = config();
int result = UNSAFE.getInt(getMetaspaceMethod() + config.methodVtableIndexOffset);
int result = UNSAFE.getInt(getMethodPointer() + config.methodVtableIndexOffset);
assert result >= config.nonvirtualVtableIndex : "must be linked";
return result;
}
@ -715,7 +714,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
@Override
public int intrinsicId() {
HotSpotVMConfig config = config();
return UNSAFE.getChar(getMetaspaceMethod() + config.methodIntrinsicIdOffset);
return UNSAFE.getChar(getMethodPointer() + config.methodIntrinsicIdOffset);
}
@Override

View File

@ -22,8 +22,6 @@
*/
package jdk.vm.ci.hotspot;
import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.ResolvedJavaType;
@ -45,10 +43,12 @@ public abstract class HotSpotResolvedJavaType extends HotSpotJavaType implements
abstract JavaConstant getJavaMirror();
abstract HotSpotResolvedObjectTypeImpl getArrayType();
@Override
public HotSpotResolvedObjectType getArrayClass() {
public final HotSpotResolvedObjectType getArrayClass() {
if (arrayOfType == null) {
arrayOfType = runtime().compilerToVm.getArrayType(this);
arrayOfType = getArrayType();
}
return arrayOfType;
}

View File

@ -66,9 +66,9 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
private static final SortByOffset fieldSortingMethod = new SortByOffset();
/**
* The Java class this type represents.
* The {@code Klass*} of this type.
*/
private final long metadataPointer;
private final long klassPointer;
private HotSpotResolvedJavaMethodImpl[] methodCacheArray;
private HashMap<Long, HotSpotResolvedJavaMethodImpl> methodCacheHashMap;
@ -77,6 +77,11 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
private HotSpotConstantPool constantPool;
private final JavaConstant mirror;
private HotSpotResolvedObjectTypeImpl superClass;
/**
* Lazily initialized cache for {@link #getComponentType()}. Set to {@code this}, if this has no
* component type (i.e., this is an non-array type).
*/
private HotSpotResolvedJavaType componentType;
/**
@ -98,8 +103,8 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
*/
@SuppressWarnings("unused")
@VMEntryPoint
private static HotSpotResolvedObjectTypeImpl fromMetaspace(long klassPointer, String signature) {
return runtime().fromMetaspace(klassPointer, signature);
private static HotSpotResolvedObjectTypeImpl fromMetaspace(long klassPointer) {
return runtime().fromMetaspace(klassPointer);
}
/**
@ -109,13 +114,13 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
* {@link Class} type.
* </p>
*
* @param metadataPointer the Klass* to create the mirror for
* @param klass the {@code Klass*} for the type
*/
@SuppressWarnings("try")
HotSpotResolvedObjectTypeImpl(long metadataPointer, String name) {
HotSpotResolvedObjectTypeImpl(long klass, String name) {
super(name);
assert metadataPointer != 0;
this.metadataPointer = metadataPointer;
assert klass != 0;
this.klassPointer = klass;
// The mirror object must be in the global scope since
// this object will be cached in HotSpotJVMCIRuntime.resolvedJavaTypes
@ -127,9 +132,9 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
}
/**
* Gets the metaspace Klass for this type.
* Gets the {@code Klass*} for this type.
*/
long getMetaspaceKlass() {
long getKlassPointer() {
long metaspacePointer = getMetaspacePointer();
if (metaspacePointer == 0) {
throw new NullPointerException("Klass* is null");
@ -139,7 +144,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
@Override
public long getMetaspacePointer() {
return metadataPointer;
return klassPointer;
}
@Override
@ -153,7 +158,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
public int getAccessFlags() {
HotSpotVMConfig config = config();
return UNSAFE.getInt(getMetaspaceKlass() + config.klassAccessFlagsOffset);
return UNSAFE.getInt(getKlassPointer() + config.klassAccessFlagsOffset);
}
@Override
@ -216,7 +221,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
HotSpotResolvedObjectTypeImpl type = this;
while (type.isAbstract()) {
HotSpotResolvedObjectTypeImpl subklass = type.getSubklass();
if (subklass == null || UNSAFE.getAddress(subklass.getMetaspaceKlass() + config.nextSiblingOffset) != 0) {
if (subklass == null || UNSAFE.getAddress(subklass.getKlassPointer() + config.nextSiblingOffset) != 0) {
return null;
}
type = subklass;
@ -248,7 +253,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
* @return true if the type is a leaf class
*/
private boolean isLeafClass() {
return UNSAFE.getLong(this.getMetaspaceKlass() + config().subklassOffset) == 0;
return UNSAFE.getLong(this.getKlassPointer() + config().subklassOffset) == 0;
}
/**
@ -390,14 +395,14 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
@Override
public boolean hasDefaultMethods() {
HotSpotVMConfig config = config();
int miscFlags = UNSAFE.getChar(getMetaspaceKlass() + config.instanceKlassMiscFlagsOffset);
int miscFlags = UNSAFE.getChar(getKlassPointer() + config.instanceKlassMiscFlagsOffset);
return (miscFlags & config.jvmMiscFlagsHasDefaultMethods) != 0;
}
@Override
public boolean declaresDefaultMethods() {
HotSpotVMConfig config = config();
int miscFlags = UNSAFE.getChar(getMetaspaceKlass() + config.instanceKlassMiscFlagsOffset);
int miscFlags = UNSAFE.getChar(getKlassPointer() + config.instanceKlassMiscFlagsOffset);
return (miscFlags & config.jvmMiscFlagsDeclaresDefaultMethods) != 0;
}
@ -409,7 +414,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
*/
private int getInitState() {
assert !isArray() : "_init_state only exists in InstanceKlass";
return UNSAFE.getByte(getMetaspaceKlass() + config().instanceKlassInitStateOffset) & 0xFF;
return UNSAFE.getByte(getKlassPointer() + config().instanceKlassInitStateOffset) & 0xFF;
}
@Override
@ -483,7 +488,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
@Override
public HotSpotConstantPool getConstantPool() {
if (constantPool == null || !isArray() && UNSAFE.getAddress(getMetaspaceKlass() + config().instanceKlassConstantsOffset) != constantPool.getMetaspaceConstantPool()) {
if (constantPool == null || !isArray() && UNSAFE.getAddress(getKlassPointer() + config().instanceKlassConstantsOffset) != constantPool.getConstantPoolPointer()) {
/*
* If the pointer to the ConstantPool has changed since this was last read refresh the
* HotSpotConstantPool wrapper object. This ensures that uses of the constant pool are
@ -521,8 +526,8 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
@Override
public int layoutHelper() {
HotSpotVMConfig config = config();
assert getMetaspaceKlass() != 0 : getName();
return UNSAFE.getInt(getMetaspaceKlass() + config.klassLayoutHelperOffset);
assert getKlassPointer() != 0 : getName();
return UNSAFE.getInt(getKlassPointer() + config.klassLayoutHelperOffset);
}
synchronized HotSpotResolvedJavaMethod createMethod(long metaspaceHandle) {
@ -539,7 +544,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
HotSpotResolvedJavaMethodImpl newMethod = new HotSpotResolvedJavaMethodImpl(this, metaspaceHandle);
methodCacheArray[i] = newMethod;
return newMethod;
} else if (curMethod.getMetaspaceMethod() == metaspaceMethod) {
} else if (curMethod.getMethodPointer() == metaspaceMethod) {
return curMethod;
}
}
@ -566,8 +571,8 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
/* Everything has the core vtable of java.lang.Object */
return config.baseVtableLength();
}
int result = UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize);
assert result >= config.baseVtableLength() : UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) + " " + config.vtableEntrySize;
int result = UNSAFE.getInt(getKlassPointer() + config.klassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize);
assert result >= config.baseVtableLength() : UNSAFE.getInt(getKlassPointer() + config.klassVtableLengthOffset) + " " + config.vtableEntrySize;
return result;
}
@ -635,7 +640,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
return false;
}
HotSpotResolvedObjectTypeImpl that = (HotSpotResolvedObjectTypeImpl) obj;
return getMetaspaceKlass() == that.getMetaspaceKlass();
return getKlassPointer() == that.getKlassPointer();
}
@Override
@ -643,6 +648,11 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
return mirror;
}
@Override
HotSpotResolvedObjectTypeImpl getArrayType() {
return runtime().compilerToVm.getArrayType((char) 0, this);
}
/**
* This class represents the field information for one field contained in the fields array of an
* {@code InstanceKlass}. The implementation is similar to the native {@code FieldInfo} class.
@ -661,7 +671,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
FieldInfo(int index) {
HotSpotVMConfig config = config();
// Get Klass::_fields
final long metaspaceFields = UNSAFE.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset);
final long metaspaceFields = UNSAFE.getAddress(getKlassPointer() + config.instanceKlassFieldsOffset);
assert config.fieldInfoFieldSlots == 6 : "revisit the field parsing code";
int offset = config.fieldInfoFieldSlots * Short.BYTES * index;
metaspaceData = metaspaceFields + config.arrayU2DataOffset + offset;
@ -793,7 +803,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
*/
private HotSpotResolvedJavaField[] getFields(boolean retrieveStaticFields, HotSpotResolvedJavaField[] prepend) {
HotSpotVMConfig config = config();
final long metaspaceFields = UNSAFE.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset);
final long metaspaceFields = UNSAFE.getAddress(getKlassPointer() + config.instanceKlassFieldsOffset);
int metaspaceFieldsLength = UNSAFE.getInt(metaspaceFields + config.arrayU1LengthOffset);
int resultCount = 0;
int index = 0;
@ -883,8 +893,8 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
}
private boolean hasSameClassLoader(HotSpotResolvedObjectTypeImpl otherMirror) {
return UnsafeAccess.UNSAFE.getAddress(getMetaspaceKlass() + config().classLoaderDataOffset) == UnsafeAccess.UNSAFE.getAddress(
otherMirror.getMetaspaceKlass() + config().classLoaderDataOffset);
return UnsafeAccess.UNSAFE.getAddress(getKlassPointer() + config().classLoaderDataOffset) == UnsafeAccess.UNSAFE.getAddress(
otherMirror.getKlassPointer() + config().classLoaderDataOffset);
}
@Override
@ -912,7 +922,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
@Override
public int superCheckOffset() {
HotSpotVMConfig config = config();
return UNSAFE.getInt(getMetaspaceKlass() + config.superCheckOffsetOffset);
return UNSAFE.getInt(getKlassPointer() + config.superCheckOffsetOffset);
}
@Override
@ -1018,9 +1028,4 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
public boolean isCloneableWithAllocation() {
return (getAccessFlags() & config().jvmAccIsCloneableFast) != 0;
}
private int getMiscFlags() {
return UNSAFE.getInt(getMetaspaceKlass() + config().instanceKlassMiscFlagsOffset);
}
}

View File

@ -23,6 +23,7 @@
package jdk.vm.ci.hotspot;
import static java.util.Objects.requireNonNull;
import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
import java.lang.annotation.Annotation;
import java.lang.reflect.Modifier;
@ -81,11 +82,11 @@ public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType
}
@Override
public HotSpotResolvedObjectType getArrayClass() {
HotSpotResolvedObjectTypeImpl getArrayType() {
if (kind == JavaKind.Void) {
return null;
}
return super.getArrayClass();
return runtime().compilerToVm.getArrayType(getJavaKind().getTypeChar(), null);
}
@Override

View File

@ -1,104 +0,0 @@
/*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* 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.
*
* 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.
*/
package jdk.vm.ci.hotspot;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.VMConstant;
import jdk.vm.ci.meta.Value;
import jdk.vm.ci.meta.ValueKind;
public final class HotSpotSentinelConstant extends Value implements JavaConstant, VMConstant {
private final JavaKind javaKind;
public HotSpotSentinelConstant(ValueKind<?> valueKind, JavaKind javaKind) {
super(valueKind);
this.javaKind = javaKind;
}
@Override
public JavaKind getJavaKind() {
return javaKind;
}
@Override
public boolean isNull() {
return true;
}
@Override
public boolean isDefaultForKind() {
return true;
}
@Override
public Object asBoxedPrimitive() {
throw new IllegalArgumentException();
}
@Override
public int asInt() {
throw new IllegalArgumentException();
}
@Override
public boolean asBoolean() {
throw new IllegalArgumentException();
}
@Override
public long asLong() {
throw new IllegalArgumentException();
}
@Override
public float asFloat() {
throw new IllegalArgumentException();
}
@Override
public double asDouble() {
throw new IllegalArgumentException();
}
@Override
public String toString() {
return JavaConstant.toString(this);
}
@Override
public String toValueString() {
return "sentinel";
}
@Override
public int hashCode() {
return 13;
}
@Override
public boolean equals(Object o) {
return o instanceof HotSpotSentinelConstant;
}
}

View File

@ -99,7 +99,7 @@ final class HotSpotSpeculationEncoding extends ByteArrayOutputStream implements
checkOpen();
if (method instanceof HotSpotResolvedJavaMethodImpl) {
try {
dos.writeLong(((HotSpotResolvedJavaMethodImpl) method).getMetaspaceMethod());
dos.writeLong(((HotSpotResolvedJavaMethodImpl) method).getMethodPointer());
} catch (IOException e) {
throw new InternalError(e);
}
@ -115,7 +115,7 @@ final class HotSpotSpeculationEncoding extends ByteArrayOutputStream implements
checkOpen();
if (type instanceof HotSpotResolvedObjectTypeImpl) {
try {
dos.writeLong(((HotSpotResolvedObjectTypeImpl) type).getMetaspaceKlass());
dos.writeLong(((HotSpotResolvedObjectTypeImpl) type).getKlassPointer());
} catch (IOException e) {
throw new InternalError(e);
}

View File

@ -25,8 +25,6 @@ package jdk.vm.ci.hotspot;
import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import jdk.vm.ci.meta.ResolvedJavaMethod;
@ -52,8 +50,8 @@ public final class JFR {
}
/**
* Helper methods for managing JFR CompilerPhase events.
* The events are defined in {see @code src/share/jfr/metadata/metadata.xml}.
* Helper methods for managing JFR CompilerPhase events. The events are defined in {see @code
* src/share/jfr/metadata/metadata.xml}.
*/
public static final class CompilerPhaseEvent {

View File

@ -23,8 +23,14 @@
package jdk.vm.ci.hotspot;
/**
* The marker interface for an object which wraps HotSpot Metadata.
* The marker interface for an object which wraps a HotSpot Metaspace object.
*/
interface MetaspaceObject {
/**
* Gets the raw pointer to the {@code Metaspace} object.
*
* @return a {@code Klass*}, {@code Method*} or {@code ConstantPool*} value
*/
long getMetaspacePointer();
}

View File

@ -95,6 +95,11 @@ public final class Assumptions implements Iterable<Assumptions.Assumption> {
}
}
}
@Override
public String toString() {
return String.format("AssumptionResult<%s, assumptions=%s>", result, Arrays.toString(assumptions));
}
}
/**
@ -102,7 +107,7 @@ public final class Assumptions implements Iterable<Assumptions.Assumption> {
*/
public static final class NoFinalizableSubclass extends Assumption {
private ResolvedJavaType receiverType;
public final ResolvedJavaType receiverType;
public NoFinalizableSubclass(ResolvedJavaType receiverType) {
this.receiverType = receiverType;

View File

@ -301,6 +301,10 @@ public interface JavaConstant extends Constant, JavaValue {
}
}
static PrimitiveConstant forPrimitive(char typeChar, long rawValue) {
return forPrimitive(JavaKind.fromPrimitiveOrVoidTypeChar(typeChar), rawValue);
}
static PrimitiveConstant forPrimitive(JavaKind kind, long rawValue) {
switch (kind) {
case Boolean:

View File

@ -50,6 +50,10 @@ public class PrimitiveConstant implements JavaConstant, SerializableConstant {
return JavaConstant.forIntegerKind(JavaKind.fromPrimitiveOrVoidTypeChar(kind), i);
}
public long getRawValue() {
return primitive;
}
@Override
public JavaKind getJavaKind() {
return kind;

View File

@ -172,7 +172,7 @@ public class CompilerToVMHelper {
speculations = new byte[0];
failedSpeculationsAddress = 0L;
}
return CTVM.installCode(target, compiledCode, code, failedSpeculationsAddress, speculations);
return CTVM.installCode(compiledCode, code, failedSpeculationsAddress, speculations);
}
public static void resetCompilationStatistics() {

View File

@ -122,7 +122,7 @@ public class TestInvalidCompilationResult extends CodeInstallerTest {
installEmptyCode(new Site[0], new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[]{new DataPatch(0, ref)}, null);
}
@Test(expected = NullPointerException.class)
@Test(expected = JVMCIError.class)
public void testNullConstantInDataSection() {
ConstantReference ref = new ConstantReference(null);
installEmptyCode(new Site[0], new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[]{new DataPatch(0, ref)}, null);
@ -134,12 +134,12 @@ public class TestInvalidCompilationResult extends CodeInstallerTest {
installEmptyCode(new Site[0], new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[]{new DataPatch(0, ref)}, null);
}
@Test(expected = NullPointerException.class)
@Test(expected = JVMCIError.class)
public void testNullReferenceInCode() {
installEmptyCode(new Site[]{new DataPatch(0, null)}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null);
}
@Test(expected = NullPointerException.class)
@Test(expected = JVMCIError.class)
public void testNullConstantInCode() {
ConstantReference ref = new ConstantReference(null);
installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null);

View File

@ -70,12 +70,12 @@ public class TestInvalidOopMap extends CodeInstallerTest {
installEmptyCode(new Site[]{new Infopoint(0, info, InfopointReason.SAFEPOINT)}, new Assumption[0], new Comment[0], 8, new DataPatch[0], StackSlot.get(null, 0, true));
}
@Test(expected = NullPointerException.class)
@Test(expected = JVMCIError.class)
public void testMissingReferenceMap() {
test(null);
}
@Test(expected = JVMCIError.class)
@Test(expected = ClassCastException.class)
public void testInvalidReferenceMap() {
test(new InvalidReferenceMap());
}