8307190: Refactor ref_at methods in Constant Pool
Reviewed-by: coleenp, iklam
This commit is contained in:
parent
491bdeaa90
commit
3f4cfbdd36
@ -794,15 +794,15 @@ ciConstant ciEnv::get_constant_by_index(const constantPoolHandle& cpool,
|
||||
// Implementation note: the results of field lookups are cached
|
||||
// in the accessor klass.
|
||||
ciField* ciEnv::get_field_by_index_impl(ciInstanceKlass* accessor,
|
||||
int index) {
|
||||
int index, Bytecodes::Code bc) {
|
||||
ciConstantPoolCache* cache = accessor->field_cache();
|
||||
if (cache == nullptr) {
|
||||
ciField* field = new (arena()) ciField(accessor, index);
|
||||
ciField* field = new (arena()) ciField(accessor, index, bc);
|
||||
return field;
|
||||
} else {
|
||||
ciField* field = (ciField*)cache->get(index);
|
||||
if (field == nullptr) {
|
||||
field = new (arena()) ciField(accessor, index);
|
||||
field = new (arena()) ciField(accessor, index, bc);
|
||||
cache->insert(index, field);
|
||||
}
|
||||
return field;
|
||||
@ -814,8 +814,8 @@ ciField* ciEnv::get_field_by_index_impl(ciInstanceKlass* accessor,
|
||||
//
|
||||
// Get a field by index from a klass's constant pool.
|
||||
ciField* ciEnv::get_field_by_index(ciInstanceKlass* accessor,
|
||||
int index) {
|
||||
GUARDED_VM_ENTRY(return get_field_by_index_impl(accessor, index);)
|
||||
int index, Bytecodes::Code bc) {
|
||||
GUARDED_VM_ENTRY(return get_field_by_index_impl(accessor, index, bc);)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
@ -882,16 +882,16 @@ ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
|
||||
// Fake a method that is equivalent to a declared method.
|
||||
ciInstanceKlass* holder = get_instance_klass(vmClasses::MethodHandle_klass());
|
||||
ciSymbol* name = ciSymbols::invokeBasic_name();
|
||||
ciSymbol* signature = get_symbol(cpool->signature_ref_at(index));
|
||||
ciSymbol* signature = get_symbol(cpool->signature_ref_at(index, bc));
|
||||
return get_unloaded_method(holder, name, signature, accessor);
|
||||
} else {
|
||||
const int holder_index = cpool->klass_ref_index_at(index);
|
||||
const int holder_index = cpool->klass_ref_index_at(index, bc);
|
||||
bool holder_is_accessible;
|
||||
ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
|
||||
|
||||
// Get the method's name and signature.
|
||||
Symbol* name_sym = cpool->name_ref_at(index);
|
||||
Symbol* sig_sym = cpool->signature_ref_at(index);
|
||||
Symbol* name_sym = cpool->name_ref_at(index, bc);
|
||||
Symbol* sig_sym = cpool->signature_ref_at(index, bc);
|
||||
|
||||
if (cpool->has_preresolution()
|
||||
|| ((holder == ciEnv::MethodHandle_klass() || holder == ciEnv::VarHandle_klass()) &&
|
||||
@ -917,7 +917,7 @@ ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
|
||||
}
|
||||
|
||||
if (holder_is_accessible) { // Our declared holder is loaded.
|
||||
constantTag tag = cpool->tag_ref_at(index);
|
||||
constantTag tag = cpool->tag_ref_at(index, bc);
|
||||
assert(accessor->get_instanceKlass() == cpool->pool_holder(), "not the pool holder?");
|
||||
Method* m = lookup_method(accessor, holder, name_sym, sig_sym, bc, tag);
|
||||
if (m != nullptr &&
|
||||
@ -1533,12 +1533,12 @@ void ciEnv::process_invokedynamic(const constantPoolHandle &cp, int indy_index,
|
||||
|
||||
// Process an invokehandle call site and record any dynamic locations.
|
||||
void ciEnv::process_invokehandle(const constantPoolHandle &cp, int index, JavaThread* thread) {
|
||||
const int holder_index = cp->klass_ref_index_at(index);
|
||||
const int holder_index = cp->klass_ref_index_at(index, Bytecodes::_invokehandle);
|
||||
if (!cp->tag_at(holder_index).is_klass()) {
|
||||
return; // not resolved
|
||||
}
|
||||
Klass* holder = ConstantPool::klass_at_if_loaded(cp, holder_index);
|
||||
Symbol* name = cp->name_ref_at(index);
|
||||
Symbol* name = cp->name_ref_at(index, Bytecodes::_invokehandle);
|
||||
if (MethodHandles::is_signature_polymorphic_name(holder, name)) {
|
||||
ConstantPoolCacheEntry* cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index));
|
||||
if (cp_cache_entry->is_resolved(Bytecodes::_invokehandle)) {
|
||||
|
@ -131,7 +131,7 @@ private:
|
||||
int pool_index, int cache_index,
|
||||
ciInstanceKlass* accessor);
|
||||
ciField* get_field_by_index(ciInstanceKlass* loading_klass,
|
||||
int field_index);
|
||||
int field_index, Bytecodes::Code bc);
|
||||
ciMethod* get_method_by_index(const constantPoolHandle& cpool,
|
||||
int method_index, Bytecodes::Code bc,
|
||||
ciInstanceKlass* loading_klass);
|
||||
@ -149,7 +149,7 @@ private:
|
||||
int pool_index, int cache_index,
|
||||
ciInstanceKlass* loading_klass);
|
||||
ciField* get_field_by_index_impl(ciInstanceKlass* loading_klass,
|
||||
int field_index);
|
||||
int field_index, Bytecodes::Code bc);
|
||||
ciMethod* get_method_by_index_impl(const constantPoolHandle& cpool,
|
||||
int method_index, Bytecodes::Code bc,
|
||||
ciInstanceKlass* loading_klass);
|
||||
|
@ -70,7 +70,7 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ciField::ciField
|
||||
ciField::ciField(ciInstanceKlass* klass, int index) :
|
||||
ciField::ciField(ciInstanceKlass* klass, int index, Bytecodes::Code bc) :
|
||||
_known_to_link_with_put(nullptr), _known_to_link_with_get(nullptr) {
|
||||
ASSERT_IN_VM;
|
||||
CompilerThread *THREAD = CompilerThread::current();
|
||||
@ -82,10 +82,10 @@ ciField::ciField(ciInstanceKlass* klass, int index) :
|
||||
constantPoolHandle cpool(THREAD, klass->get_instanceKlass()->constants());
|
||||
|
||||
// Get the field's name, signature, and type.
|
||||
Symbol* name = cpool->name_ref_at(index);
|
||||
Symbol* name = cpool->name_ref_at(index, bc);
|
||||
_name = ciEnv::current(THREAD)->get_symbol(name);
|
||||
|
||||
int nt_index = cpool->name_and_type_ref_index_at(index);
|
||||
int nt_index = cpool->name_and_type_ref_index_at(index, bc);
|
||||
int sig_index = cpool->signature_ref_index_at(nt_index);
|
||||
Symbol* signature = cpool->symbol_at(sig_index);
|
||||
_signature = ciEnv::current(THREAD)->get_symbol(signature);
|
||||
@ -109,7 +109,7 @@ ciField::ciField(ciInstanceKlass* klass, int index) :
|
||||
//
|
||||
// Note: we actually create a ciInstanceKlass for this klass,
|
||||
// even though we may not need to.
|
||||
int holder_index = cpool->klass_ref_index_at(index);
|
||||
int holder_index = cpool->klass_ref_index_at(index, bc);
|
||||
bool holder_is_accessible;
|
||||
|
||||
ciKlass* generic_declared_holder = ciEnv::current(THREAD)->get_klass_by_index(cpool, holder_index,
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
ciType* compute_type();
|
||||
ciType* compute_type_impl();
|
||||
|
||||
ciField(ciInstanceKlass* klass, int index);
|
||||
ciField(ciInstanceKlass* klass, int index, Bytecodes::Code bc);
|
||||
ciField(fieldDescriptor* fd);
|
||||
|
||||
// shared constructor code
|
||||
|
@ -1178,9 +1178,9 @@ bool ciMethod::has_unloaded_classes_in_signature() {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// ciMethod::is_klass_loaded
|
||||
bool ciMethod::is_klass_loaded(int refinfo_index, bool must_be_resolved) const {
|
||||
bool ciMethod::is_klass_loaded(int refinfo_index, Bytecodes::Code bc, bool must_be_resolved) const {
|
||||
VM_ENTRY_MARK;
|
||||
return get_Method()->is_klass_loaded(refinfo_index, must_be_resolved);
|
||||
return get_Method()->is_klass_loaded(refinfo_index, bc, must_be_resolved);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
@ -311,7 +311,7 @@ class ciMethod : public ciMetadata {
|
||||
bool is_not_reached(int bci);
|
||||
bool was_executed_more_than(int times);
|
||||
bool has_unloaded_classes_in_signature();
|
||||
bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const;
|
||||
bool is_klass_loaded(int refinfo_index, Bytecodes::Code bc, bool must_be_resolved) const;
|
||||
bool check_call(int refinfo_index, bool is_static) const;
|
||||
bool ensure_method_data(); // make sure it exists in the VM also
|
||||
MethodCounters* ensure_method_counters();
|
||||
|
@ -428,8 +428,8 @@ class CompileReplay : public StackObj {
|
||||
pool_index = cp->resolved_indy_entry_at(index)->constant_pool_index();
|
||||
} else if (bytecode.is_invokehandle()) {
|
||||
#ifdef ASSERT
|
||||
Klass* holder = cp->klass_ref_at(index, CHECK_NULL);
|
||||
Symbol* name = cp->name_ref_at(index);
|
||||
Klass* holder = cp->klass_ref_at(index, bytecode.code(), CHECK_NULL);
|
||||
Symbol* name = cp->name_ref_at(index, bytecode.code());
|
||||
assert(MethodHandles::is_signature_polymorphic_name(holder, name), "");
|
||||
#endif
|
||||
cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index));
|
||||
|
@ -308,7 +308,7 @@ int ciBytecodeStream::get_field_index() {
|
||||
// If this bytecode is one of get_field, get_static, put_field,
|
||||
// or put_static, get the referenced field.
|
||||
ciField* ciBytecodeStream::get_field(bool& will_link) {
|
||||
ciField* f = CURRENT_ENV->get_field_by_index(_holder, get_field_index());
|
||||
ciField* f = CURRENT_ENV->get_field_by_index(_holder, get_field_index(), _bc);
|
||||
will_link = f->will_link(_method, _bc);
|
||||
return f;
|
||||
}
|
||||
@ -343,7 +343,7 @@ ciInstanceKlass* ciBytecodeStream::get_declared_field_holder() {
|
||||
int ciBytecodeStream::get_field_holder_index() {
|
||||
GUARDED_VM_ENTRY(
|
||||
ConstantPool* cpool = _holder->get_instanceKlass()->constants();
|
||||
return cpool->klass_ref_index_at(get_field_index());
|
||||
return cpool->klass_ref_index_at(get_field_index(), _bc);
|
||||
)
|
||||
}
|
||||
|
||||
@ -527,7 +527,7 @@ ciKlass* ciBytecodeStream::get_declared_method_holder() {
|
||||
// deoptimization information.
|
||||
int ciBytecodeStream::get_method_holder_index() {
|
||||
ConstantPool* cpool = _method->get_Method()->constants();
|
||||
return cpool->klass_ref_index_at(get_method_index());
|
||||
return cpool->klass_ref_index_at(get_method_index(), _bc);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
@ -539,7 +539,7 @@ int ciBytecodeStream::get_method_holder_index() {
|
||||
int ciBytecodeStream::get_method_signature_index(const constantPoolHandle& cpool) {
|
||||
GUARDED_VM_ENTRY(
|
||||
const int method_index = get_method_index();
|
||||
const int name_and_type_index = cpool->name_and_type_ref_index_at(method_index);
|
||||
const int name_and_type_index = cpool->name_and_type_ref_index_at(method_index, _bc);
|
||||
return cpool->signature_ref_index_at(name_and_type_index);
|
||||
)
|
||||
}
|
||||
|
@ -131,17 +131,17 @@ int Bytecode_invoke::size_of_parameters() const {
|
||||
|
||||
|
||||
Symbol* Bytecode_member_ref::klass() const {
|
||||
return constants()->klass_ref_at_noresolve(index());
|
||||
return constants()->klass_ref_at_noresolve(index(), _code);
|
||||
}
|
||||
|
||||
|
||||
Symbol* Bytecode_member_ref::name() const {
|
||||
return constants()->name_ref_at(index());
|
||||
return constants()->name_ref_at(index(), _code);
|
||||
}
|
||||
|
||||
|
||||
Symbol* Bytecode_member_ref::signature() const {
|
||||
return constants()->signature_ref_at(index());
|
||||
return constants()->signature_ref_at(index(), _code);
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,12 +271,12 @@ static void print_klass_name(outputStream *os, Symbol *klass) {
|
||||
|
||||
// Prints the name of the method that is described at constant pool
|
||||
// index cp_index in the constant pool of method 'method'.
|
||||
static void print_method_name(outputStream *os, Method* method, int cp_index) {
|
||||
static void print_method_name(outputStream *os, Method* method, int cp_index, Bytecodes::Code bc) {
|
||||
ResourceMark rm;
|
||||
ConstantPool* cp = method->constants();
|
||||
Symbol* klass = cp->klass_ref_at_noresolve(cp_index);
|
||||
Symbol* name = cp->name_ref_at(cp_index);
|
||||
Symbol* signature = cp->signature_ref_at(cp_index);
|
||||
Symbol* klass = cp->klass_ref_at_noresolve(cp_index, bc);
|
||||
Symbol* name = cp->name_ref_at(cp_index, bc);
|
||||
Symbol* signature = cp->signature_ref_at(cp_index, bc);
|
||||
|
||||
print_klass_name(os, klass);
|
||||
os->print(".%s(", name->as_C_string());
|
||||
@ -287,19 +287,19 @@ static void print_method_name(outputStream *os, Method* method, int cp_index) {
|
||||
|
||||
// Prints the name of the field that is described at constant pool
|
||||
// index cp_index in the constant pool of method 'method'.
|
||||
static void print_field_and_class(outputStream *os, Method* method, int cp_index) {
|
||||
static void print_field_and_class(outputStream *os, Method* method, int cp_index, Bytecodes::Code bc) {
|
||||
ResourceMark rm;
|
||||
ConstantPool* cp = method->constants();
|
||||
Symbol* klass = cp->klass_ref_at_noresolve(cp_index);
|
||||
Symbol *name = cp->name_ref_at(cp_index);
|
||||
Symbol* klass = cp->klass_ref_at_noresolve(cp_index, bc);
|
||||
Symbol *name = cp->name_ref_at(cp_index, bc);
|
||||
print_klass_name(os, klass);
|
||||
os->print(".%s", name->as_C_string());
|
||||
}
|
||||
|
||||
// Returns the name of the field that is described at constant pool
|
||||
// index cp_index in the constant pool of method 'method'.
|
||||
static char const* get_field_name(Method* method, int cp_index) {
|
||||
Symbol* name = method->constants()->name_ref_at(cp_index);
|
||||
static char const* get_field_name(Method* method, int cp_index, Bytecodes::Code bc) {
|
||||
Symbol* name = method->constants()->name_ref_at(cp_index, bc);
|
||||
return name->as_C_string();
|
||||
}
|
||||
|
||||
@ -970,7 +970,7 @@ int ExceptionMessageBuilder::do_instruction(int bci) {
|
||||
// Find out the type of the field accessed.
|
||||
int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
|
||||
ConstantPool* cp = _method->constants();
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index, code);
|
||||
int type_index = cp->signature_ref_index_at(name_and_type_index);
|
||||
Symbol* signature = cp->symbol_at(type_index);
|
||||
// Simulate the bytecode: pop the address, push the 'value' loaded
|
||||
@ -984,7 +984,7 @@ int ExceptionMessageBuilder::do_instruction(int bci) {
|
||||
case Bytecodes::_putfield: {
|
||||
int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
|
||||
ConstantPool* cp = _method->constants();
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index, code);
|
||||
int type_index = cp->signature_ref_index_at(name_and_type_index);
|
||||
Symbol* signature = cp->symbol_at(type_index);
|
||||
BasicType bt = Signature::basic_type(signature);
|
||||
@ -1006,7 +1006,7 @@ int ExceptionMessageBuilder::do_instruction(int bci) {
|
||||
cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
|
||||
}
|
||||
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index, code);
|
||||
int type_index = cp->signature_ref_index_at(name_and_type_index);
|
||||
Symbol* signature = cp->symbol_at(type_index);
|
||||
|
||||
@ -1134,7 +1134,7 @@ int ExceptionMessageBuilder::get_NPE_null_slot(int bci) {
|
||||
case Bytecodes::_putfield: {
|
||||
int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
|
||||
ConstantPool* cp = _method->constants();
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index, code);
|
||||
int type_index = cp->signature_ref_index_at(name_and_type_index);
|
||||
Symbol* signature = cp->symbol_at(type_index);
|
||||
BasicType bt = Signature::basic_type(signature);
|
||||
@ -1145,7 +1145,7 @@ int ExceptionMessageBuilder::get_NPE_null_slot(int bci) {
|
||||
case Bytecodes::_invokeinterface: {
|
||||
int cp_index = Bytes::get_native_u2(code_base+ pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
|
||||
ConstantPool* cp = _method->constants();
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index, code);
|
||||
int name_index = cp->name_ref_index_at(name_and_type_index);
|
||||
Symbol* name = cp->symbol_at(name_index);
|
||||
|
||||
@ -1327,7 +1327,7 @@ bool ExceptionMessageBuilder::print_NPE_cause0(outputStream* os, int bci, int sl
|
||||
|
||||
case Bytecodes::_getstatic: {
|
||||
int cp_index = Bytes::get_native_u2(code_base + pos) + ConstantPool::CPCACHE_INDEX_TAG;
|
||||
print_field_and_class(os, _method, cp_index);
|
||||
print_field_and_class(os, _method, cp_index, code);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1338,7 +1338,7 @@ bool ExceptionMessageBuilder::print_NPE_cause0(outputStream* os, int bci, int sl
|
||||
os->print(".");
|
||||
}
|
||||
int cp_index = Bytes::get_native_u2(code_base + pos) + ConstantPool::CPCACHE_INDEX_TAG;
|
||||
os->print("%s", get_field_name(_method, cp_index));
|
||||
os->print("%s", get_field_name(_method, cp_index, code));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1350,7 +1350,7 @@ bool ExceptionMessageBuilder::print_NPE_cause0(outputStream* os, int bci, int sl
|
||||
if (max_detail == _max_cause_detail && !inner_expr) {
|
||||
os->print(" because the return value of \"");
|
||||
}
|
||||
print_method_name(os, _method, cp_index);
|
||||
print_method_name(os, _method, cp_index, code);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1416,21 +1416,21 @@ void ExceptionMessageBuilder::print_NPE_failed_action(outputStream *os, int bci)
|
||||
case Bytecodes::_getfield: {
|
||||
int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
|
||||
ConstantPool* cp = _method->constants();
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
|
||||
int name_and_type_index = cp->name_and_type_ref_index_at(cp_index, code);
|
||||
int name_index = cp->name_ref_index_at(name_and_type_index);
|
||||
Symbol* name = cp->symbol_at(name_index);
|
||||
os->print("Cannot read field \"%s\"", name->as_C_string());
|
||||
} break;
|
||||
case Bytecodes::_putfield: {
|
||||
int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
|
||||
os->print("Cannot assign field \"%s\"", get_field_name(_method, cp_index));
|
||||
os->print("Cannot assign field \"%s\"", get_field_name(_method, cp_index, code));
|
||||
} break;
|
||||
case Bytecodes::_invokevirtual:
|
||||
case Bytecodes::_invokespecial:
|
||||
case Bytecodes::_invokeinterface: {
|
||||
int cp_index = Bytes::get_native_u2(code_base+ pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
|
||||
os->print("Cannot invoke \"");
|
||||
print_method_name(os, _method, cp_index);
|
||||
print_method_name(os, _method, cp_index, code);
|
||||
os->print("\"");
|
||||
} break;
|
||||
|
||||
|
@ -1505,8 +1505,8 @@ JRT_ENTRY(void, InterpreterRuntime::member_name_arg_or_null(JavaThread* current,
|
||||
}
|
||||
ConstantPool* cpool = method->constants();
|
||||
int cp_index = Bytes::get_native_u2(bcp + 1) + ConstantPool::CPCACHE_INDEX_TAG;
|
||||
Symbol* cname = cpool->klass_name_at(cpool->klass_ref_index_at(cp_index));
|
||||
Symbol* mname = cpool->name_ref_at(cp_index);
|
||||
Symbol* cname = cpool->klass_name_at(cpool->klass_ref_index_at(cp_index, code));
|
||||
Symbol* mname = cpool->name_ref_at(cp_index, code);
|
||||
|
||||
if (MethodHandles::has_member_arg(cname, mname)) {
|
||||
oop member_name_oop = cast_to_oop(member_name);
|
||||
|
@ -228,14 +228,14 @@ void CallInfo::print() {
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
// Implementation of LinkInfo
|
||||
|
||||
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, TRAPS) {
|
||||
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, Bytecodes::Code code, TRAPS) {
|
||||
// resolve klass
|
||||
_resolved_klass = pool->klass_ref_at(index, CHECK);
|
||||
_resolved_klass = pool->klass_ref_at(index, code, CHECK);
|
||||
|
||||
// Get name, signature, and static klass
|
||||
_name = pool->name_ref_at(index);
|
||||
_signature = pool->signature_ref_at(index);
|
||||
_tag = pool->tag_ref_at(index);
|
||||
_name = pool->name_ref_at(index, code);
|
||||
_signature = pool->signature_ref_at(index, code);
|
||||
_tag = pool->tag_ref_at(index, code);
|
||||
_current_klass = pool->pool_holder();
|
||||
_current_method = current_method;
|
||||
|
||||
@ -244,14 +244,14 @@ LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, const methodHandle
|
||||
_check_loader_constraints = true;
|
||||
}
|
||||
|
||||
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) {
|
||||
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, Bytecodes::Code code, TRAPS) {
|
||||
// resolve klass
|
||||
_resolved_klass = pool->klass_ref_at(index, CHECK);
|
||||
_resolved_klass = pool->klass_ref_at(index, code, CHECK);
|
||||
|
||||
// Get name, signature, and static klass
|
||||
_name = pool->name_ref_at(index);
|
||||
_signature = pool->signature_ref_at(index);
|
||||
_tag = pool->tag_ref_at(index);
|
||||
_name = pool->name_ref_at(index, code);
|
||||
_signature = pool->signature_ref_at(index, code);
|
||||
_tag = pool->tag_ref_at(index, code);
|
||||
_current_klass = pool->pool_holder();
|
||||
_current_method = methodHandle();
|
||||
|
||||
@ -618,13 +618,13 @@ Method* LinkResolver::resolve_method_statically(Bytecodes::Code code,
|
||||
if (code == Bytecodes::_invokedynamic) {
|
||||
Klass* resolved_klass = vmClasses::MethodHandle_klass();
|
||||
Symbol* method_name = vmSymbols::invoke_name();
|
||||
Symbol* method_signature = pool->signature_ref_at(index);
|
||||
Symbol* method_signature = pool->signature_ref_at(index, code);
|
||||
Klass* current_klass = pool->pool_holder();
|
||||
LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass);
|
||||
return resolve_method(link_info, code, THREAD);
|
||||
}
|
||||
|
||||
LinkInfo link_info(pool, index, methodHandle(), CHECK_NULL);
|
||||
LinkInfo link_info(pool, index, methodHandle(), code, CHECK_NULL);
|
||||
Klass* resolved_klass = link_info.resolved_klass();
|
||||
|
||||
if (pool->has_preresolution()
|
||||
@ -950,7 +950,7 @@ void LinkResolver::check_field_accessability(Klass* ref_klass,
|
||||
}
|
||||
|
||||
void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, const methodHandle& method, Bytecodes::Code byte, TRAPS) {
|
||||
LinkInfo link_info(pool, index, method, CHECK);
|
||||
LinkInfo link_info(pool, index, method, byte, CHECK);
|
||||
resolve_field(fd, link_info, byte, true, CHECK);
|
||||
}
|
||||
|
||||
@ -1668,14 +1668,14 @@ void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv,
|
||||
}
|
||||
|
||||
void LinkResolver::resolve_invokestatic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) {
|
||||
LinkInfo link_info(pool, index, CHECK);
|
||||
LinkInfo link_info(pool, index, Bytecodes::_invokestatic, CHECK);
|
||||
resolve_static_call(result, link_info, /*initialize_class*/true, CHECK);
|
||||
}
|
||||
|
||||
|
||||
void LinkResolver::resolve_invokespecial(CallInfo& result, Handle recv,
|
||||
const constantPoolHandle& pool, int index, TRAPS) {
|
||||
LinkInfo link_info(pool, index, CHECK);
|
||||
LinkInfo link_info(pool, index, Bytecodes::_invokespecial, CHECK);
|
||||
resolve_special_call(result, recv, link_info, CHECK);
|
||||
}
|
||||
|
||||
@ -1684,14 +1684,14 @@ void LinkResolver::resolve_invokevirtual(CallInfo& result, Handle recv,
|
||||
const constantPoolHandle& pool, int index,
|
||||
TRAPS) {
|
||||
|
||||
LinkInfo link_info(pool, index, CHECK);
|
||||
LinkInfo link_info(pool, index, Bytecodes::_invokevirtual, CHECK);
|
||||
Klass* recvrKlass = recv.is_null() ? (Klass*)nullptr : recv->klass();
|
||||
resolve_virtual_call(result, recv, recvrKlass, link_info, /*check_null_or_abstract*/true, CHECK);
|
||||
}
|
||||
|
||||
|
||||
void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, TRAPS) {
|
||||
LinkInfo link_info(pool, index, CHECK);
|
||||
LinkInfo link_info(pool, index, Bytecodes::_invokeinterface, CHECK);
|
||||
Klass* recvrKlass = recv.is_null() ? (Klass*)nullptr : recv->klass();
|
||||
resolve_interface_call(result, recv, recvrKlass, link_info, true, CHECK);
|
||||
}
|
||||
@ -1712,7 +1712,7 @@ bool LinkResolver::resolve_previously_linked_invokehandle(CallInfo& result, cons
|
||||
}
|
||||
|
||||
void LinkResolver::resolve_invokehandle(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) {
|
||||
LinkInfo link_info(pool, index, CHECK);
|
||||
LinkInfo link_info(pool, index, Bytecodes::_invokehandle, CHECK);
|
||||
if (log_is_enabled(Info, methodhandles)) {
|
||||
ResourceMark rm(THREAD);
|
||||
log_info(methodhandles)("resolve_invokehandle %s %s", link_info.name()->as_C_string(),
|
||||
|
@ -146,8 +146,8 @@ class LinkInfo : public StackObj {
|
||||
enum class AccessCheck { required, skip };
|
||||
enum class LoaderConstraintCheck { required, skip };
|
||||
|
||||
LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, TRAPS);
|
||||
LinkInfo(const constantPoolHandle& pool, int index, TRAPS);
|
||||
LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, Bytecodes::Code code, TRAPS);
|
||||
LinkInfo(const constantPoolHandle& pool, int index, Bytecodes::Code code, TRAPS);
|
||||
|
||||
// Condensed information from other call sites within the vm.
|
||||
LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, Klass* current_klass,
|
||||
|
@ -814,26 +814,26 @@ C2V_VMENTRY_NULL(jobjectArray, resolveBootstrapMethod, (JNIEnv* env, jobject, AR
|
||||
return JVMCIENV->get_jobjectArray(bsmi);
|
||||
C2V_END
|
||||
|
||||
C2V_VMENTRY_0(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index))
|
||||
C2V_VMENTRY_0(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index, jint opcode))
|
||||
constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp));
|
||||
return cp->name_and_type_ref_index_at(index);
|
||||
return cp->name_and_type_ref_index_at(index, (Bytecodes::Code)opcode);
|
||||
C2V_END
|
||||
|
||||
C2V_VMENTRY_NULL(jobject, lookupNameInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint which))
|
||||
C2V_VMENTRY_NULL(jobject, lookupNameInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint which, jint opcode))
|
||||
constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp));
|
||||
JVMCIObject sym = JVMCIENV->create_string(cp->name_ref_at(which), JVMCI_CHECK_NULL);
|
||||
JVMCIObject sym = JVMCIENV->create_string(cp->name_ref_at(which, (Bytecodes::Code)opcode), JVMCI_CHECK_NULL);
|
||||
return JVMCIENV->get_jobject(sym);
|
||||
C2V_END
|
||||
|
||||
C2V_VMENTRY_NULL(jobject, lookupSignatureInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint which))
|
||||
C2V_VMENTRY_NULL(jobject, lookupSignatureInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint which, jint opcode))
|
||||
constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp));
|
||||
JVMCIObject sym = JVMCIENV->create_string(cp->signature_ref_at(which), JVMCI_CHECK_NULL);
|
||||
JVMCIObject sym = JVMCIENV->create_string(cp->signature_ref_at(which, (Bytecodes::Code)opcode), JVMCI_CHECK_NULL);
|
||||
return JVMCIENV->get_jobject(sym);
|
||||
C2V_END
|
||||
|
||||
C2V_VMENTRY_0(jint, lookupKlassRefIndexInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index))
|
||||
C2V_VMENTRY_0(jint, lookupKlassRefIndexInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index, jint opcode))
|
||||
constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp));
|
||||
return cp->klass_ref_index_at(index);
|
||||
return cp->klass_ref_index_at(index, (Bytecodes::Code)opcode);
|
||||
C2V_END
|
||||
|
||||
C2V_VMENTRY_NULL(jobject, resolveTypeInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index))
|
||||
@ -906,7 +906,7 @@ C2V_VMENTRY_NULL(jobject, resolveFieldInPool, (JNIEnv* env, jobject, ARGUMENT_PA
|
||||
Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF);
|
||||
fieldDescriptor fd;
|
||||
methodHandle mh(THREAD, UNPACK_PAIR(Method, method));
|
||||
LinkInfo link_info(cp, index, mh, CHECK_NULL);
|
||||
LinkInfo link_info(cp, index, mh, code, CHECK_NULL);
|
||||
LinkResolver::resolve_field(fd, link_info, Bytecodes::java_code(code), false, CHECK_NULL);
|
||||
JVMCIPrimitiveArray info = JVMCIENV->wrap(info_handle);
|
||||
if (info.is_null() || JVMCIENV->get_length(info) != 4) {
|
||||
@ -1592,8 +1592,8 @@ C2V_END
|
||||
|
||||
C2V_VMENTRY(void, resolveInvokeHandleInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index))
|
||||
constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp));
|
||||
Klass* holder = cp->klass_ref_at(index, CHECK);
|
||||
Symbol* name = cp->name_ref_at(index);
|
||||
Klass* holder = cp->klass_ref_at(index, Bytecodes::_invokehandle, CHECK);
|
||||
Symbol* name = cp->name_ref_at(index, Bytecodes::_invokehandle);
|
||||
if (MethodHandles::is_signature_polymorphic_name(holder, name)) {
|
||||
CallInfo callInfo;
|
||||
LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK);
|
||||
@ -1609,11 +1609,11 @@ C2V_VMENTRY_0(jint, isResolvedInvokeHandleInPool, (JNIEnv* env, jobject, ARGUMEN
|
||||
// MethodHandle.invoke* --> LambdaForm?
|
||||
ResourceMark rm;
|
||||
|
||||
LinkInfo link_info(cp, index, CATCH);
|
||||
LinkInfo link_info(cp, index, Bytecodes::_invokehandle, CATCH);
|
||||
|
||||
Klass* resolved_klass = link_info.resolved_klass();
|
||||
|
||||
Symbol* name_sym = cp->name_ref_at(index);
|
||||
Symbol* name_sym = cp->name_ref_at(index, Bytecodes::_invokehandle);
|
||||
|
||||
vmassert(MethodHandles::is_method_handle_invoke_name(resolved_klass, name_sym), "!");
|
||||
vmassert(MethodHandles::is_signature_polymorphic_name(resolved_klass, name_sym), "!");
|
||||
@ -3085,10 +3085,10 @@ JNINativeMethod CompilerToVM::methods[] = {
|
||||
{CC "lookupJClass", CC "(J)" HS_RESOLVED_TYPE, FN_PTR(lookupJClass)},
|
||||
{CC "getArrayType", CC "(C" HS_KLASS2 ")" HS_KLASS, FN_PTR(getArrayType)},
|
||||
{CC "lookupClass", CC "(" CLASS ")" HS_RESOLVED_TYPE, FN_PTR(lookupClass)},
|
||||
{CC "lookupNameInPool", CC "(" HS_CONSTANT_POOL2 "I)" STRING, FN_PTR(lookupNameInPool)},
|
||||
{CC "lookupNameAndTypeRefIndexInPool", CC "(" HS_CONSTANT_POOL2 "I)I", FN_PTR(lookupNameAndTypeRefIndexInPool)},
|
||||
{CC "lookupSignatureInPool", CC "(" HS_CONSTANT_POOL2 "I)" STRING, FN_PTR(lookupSignatureInPool)},
|
||||
{CC "lookupKlassRefIndexInPool", CC "(" HS_CONSTANT_POOL2 "I)I", FN_PTR(lookupKlassRefIndexInPool)},
|
||||
{CC "lookupNameInPool", CC "(" HS_CONSTANT_POOL2 "II)" STRING, FN_PTR(lookupNameInPool)},
|
||||
{CC "lookupNameAndTypeRefIndexInPool", CC "(" HS_CONSTANT_POOL2 "II)I", FN_PTR(lookupNameAndTypeRefIndexInPool)},
|
||||
{CC "lookupSignatureInPool", CC "(" HS_CONSTANT_POOL2 "II)" STRING, FN_PTR(lookupSignatureInPool)},
|
||||
{CC "lookupKlassRefIndexInPool", CC "(" HS_CONSTANT_POOL2 "II)I", FN_PTR(lookupKlassRefIndexInPool)},
|
||||
{CC "lookupKlassInPool", CC "(" HS_CONSTANT_POOL2 "I)Ljava/lang/Object;", FN_PTR(lookupKlassInPool)},
|
||||
{CC "lookupAppendixInPool", CC "(" HS_CONSTANT_POOL2 "I)" OBJECTCONSTANT, FN_PTR(lookupAppendixInPool)},
|
||||
{CC "lookupMethodInPool", CC "(" HS_CONSTANT_POOL2 "IB" HS_METHOD2 ")" HS_METHOD, FN_PTR(lookupMethodInPool)},
|
||||
|
@ -1798,7 +1798,7 @@ Klass* JVMCIRuntime::get_klass_by_index(const constantPoolHandle& cpool,
|
||||
// Implementation note: the results of field lookups are cached
|
||||
// in the accessor klass.
|
||||
void JVMCIRuntime::get_field_by_index_impl(InstanceKlass* klass, fieldDescriptor& field_desc,
|
||||
int index) {
|
||||
int index, Bytecodes::Code bc) {
|
||||
JVMCI_EXCEPTION_CONTEXT;
|
||||
|
||||
assert(klass->is_linked(), "must be linked before using its constant-pool");
|
||||
@ -1806,14 +1806,14 @@ void JVMCIRuntime::get_field_by_index_impl(InstanceKlass* klass, fieldDescriptor
|
||||
constantPoolHandle cpool(thread, klass->constants());
|
||||
|
||||
// Get the field's name, signature, and type.
|
||||
Symbol* name = cpool->name_ref_at(index);
|
||||
Symbol* name = cpool->name_ref_at(index, bc);
|
||||
|
||||
int nt_index = cpool->name_and_type_ref_index_at(index);
|
||||
int nt_index = cpool->name_and_type_ref_index_at(index, bc);
|
||||
int sig_index = cpool->signature_ref_index_at(nt_index);
|
||||
Symbol* signature = cpool->symbol_at(sig_index);
|
||||
|
||||
// Get the field's declared holder.
|
||||
int holder_index = cpool->klass_ref_index_at(index);
|
||||
int holder_index = cpool->klass_ref_index_at(index, bc);
|
||||
bool holder_is_accessible;
|
||||
Klass* declared_holder = get_klass_by_index(cpool, holder_index,
|
||||
holder_is_accessible,
|
||||
@ -1838,9 +1838,9 @@ void JVMCIRuntime::get_field_by_index_impl(InstanceKlass* klass, fieldDescriptor
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Get a field by index from a klass's constant pool.
|
||||
void JVMCIRuntime::get_field_by_index(InstanceKlass* accessor, fieldDescriptor& fd, int index) {
|
||||
void JVMCIRuntime::get_field_by_index(InstanceKlass* accessor, fieldDescriptor& fd, int index, Bytecodes::Code bc) {
|
||||
ResourceMark rm;
|
||||
return get_field_by_index_impl(accessor, fd, index);
|
||||
return get_field_by_index_impl(accessor, fd, index, bc);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
@ -1888,13 +1888,13 @@ Method* JVMCIRuntime::get_method_by_index_impl(const constantPoolHandle& cpool,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int holder_index = cpool->klass_ref_index_at(index);
|
||||
int holder_index = cpool->klass_ref_index_at(index, bc);
|
||||
bool holder_is_accessible;
|
||||
Klass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
|
||||
|
||||
// Get the method's name and signature.
|
||||
Symbol* name_sym = cpool->name_ref_at(index);
|
||||
Symbol* sig_sym = cpool->signature_ref_at(index);
|
||||
Symbol* name_sym = cpool->name_ref_at(index, bc);
|
||||
Symbol* sig_sym = cpool->signature_ref_at(index, bc);
|
||||
|
||||
if (cpool->has_preresolution()
|
||||
|| ((holder == vmClasses::MethodHandle_klass() || holder == vmClasses::VarHandle_klass()) &&
|
||||
@ -1920,7 +1920,7 @@ Method* JVMCIRuntime::get_method_by_index_impl(const constantPoolHandle& cpool,
|
||||
}
|
||||
|
||||
if (holder_is_accessible) { // Our declared holder is loaded.
|
||||
constantTag tag = cpool->tag_ref_at(index);
|
||||
constantTag tag = cpool->tag_ref_at(index, bc);
|
||||
Method* m = lookup_method(accessor, holder, name_sym, sig_sym, bc, tag);
|
||||
if (m != nullptr) {
|
||||
// We found the method.
|
||||
|
@ -232,7 +232,7 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
|
||||
bool& is_accessible,
|
||||
Klass* loading_klass);
|
||||
static void get_field_by_index_impl(InstanceKlass* loading_klass, fieldDescriptor& fd,
|
||||
int field_index);
|
||||
int field_index, Bytecodes::Code bc);
|
||||
static Method* get_method_by_index_impl(const constantPoolHandle& cpool,
|
||||
int method_index, Bytecodes::Code bc,
|
||||
InstanceKlass* loading_klass);
|
||||
@ -413,7 +413,7 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
|
||||
bool& is_accessible,
|
||||
Klass* loading_klass);
|
||||
static void get_field_by_index(InstanceKlass* loading_klass, fieldDescriptor& fd,
|
||||
int field_index);
|
||||
int field_index, Bytecodes::Code bc);
|
||||
static Method* get_method_by_index(const constantPoolHandle& cpool,
|
||||
int method_index, Bytecodes::Code bc,
|
||||
InstanceKlass* loading_klass);
|
||||
|
@ -675,72 +675,67 @@ bool ConstantPool::has_local_signature_at_if_loaded(const constantPoolHandle& cp
|
||||
}
|
||||
}
|
||||
|
||||
Symbol* ConstantPool::impl_name_ref_at(int which, bool uncached) {
|
||||
int name_index = name_ref_index_at(impl_name_and_type_ref_index_at(which, uncached));
|
||||
return symbol_at(name_index);
|
||||
}
|
||||
|
||||
|
||||
Symbol* ConstantPool::impl_signature_ref_at(int which, bool uncached) {
|
||||
int signature_index = signature_ref_index_at(impl_name_and_type_ref_index_at(which, uncached));
|
||||
return symbol_at(signature_index);
|
||||
}
|
||||
|
||||
int ConstantPool::impl_name_and_type_ref_index_at(int which, bool uncached) {
|
||||
int i = which;
|
||||
if (!uncached) {
|
||||
assert(cache() != nullptr, "'which' is a rewritten index so this class must have been rewritten");
|
||||
if (ConstantPool::is_invokedynamic_index(which)) {
|
||||
// Invokedynamic index is index into the resolved indy array in the constant pool cache
|
||||
int pool_index = invokedynamic_bootstrap_ref_index_at(which);
|
||||
pool_index = bootstrap_name_and_type_ref_index_at(pool_index);
|
||||
assert(tag_at(pool_index).is_name_and_type(), "");
|
||||
return pool_index;
|
||||
}
|
||||
// change byte-ordering and go via cache
|
||||
i = remap_instruction_operand_from_cache(which);
|
||||
} else {
|
||||
if (tag_at(which).has_bootstrap()) {
|
||||
int pool_index = bootstrap_name_and_type_ref_index_at(which);
|
||||
assert(tag_at(pool_index).is_name_and_type(), "");
|
||||
return pool_index;
|
||||
}
|
||||
// Translate index, which could be CPCache index or Indy index, to a constant pool index
|
||||
int ConstantPool::to_cp_index(int index, Bytecodes::Code code) {
|
||||
assert(cache() != nullptr, "'index' is a rewritten index so this class must have been rewritten");
|
||||
switch(code) {
|
||||
case Bytecodes::_invokedynamic:
|
||||
return invokedynamic_bootstrap_ref_index_at(index);
|
||||
case Bytecodes::_getfield:
|
||||
case Bytecodes::_getstatic:
|
||||
case Bytecodes::_putfield:
|
||||
case Bytecodes::_putstatic:
|
||||
// TODO: handle resolved field entries with new structure
|
||||
// i = ....
|
||||
case Bytecodes::_invokeinterface:
|
||||
case Bytecodes::_invokehandle:
|
||||
case Bytecodes::_invokespecial:
|
||||
case Bytecodes::_invokestatic:
|
||||
case Bytecodes::_invokevirtual:
|
||||
// TODO: handle resolved method entries with new structure
|
||||
default:
|
||||
// change byte-ordering and go via cache
|
||||
return remap_instruction_operand_from_cache(index);
|
||||
}
|
||||
assert(tag_at(i).is_field_or_method(), "Corrupted constant pool");
|
||||
assert(!tag_at(i).has_bootstrap(), "Must be handled above");
|
||||
jint ref_index = *int_at_addr(i);
|
||||
}
|
||||
|
||||
int ConstantPool::uncached_name_and_type_ref_index_at(int cp_index) {
|
||||
if (tag_at(cp_index).has_bootstrap()) {
|
||||
int pool_index = bootstrap_name_and_type_ref_index_at(cp_index);
|
||||
assert(tag_at(pool_index).is_name_and_type(), "");
|
||||
return pool_index;
|
||||
}
|
||||
assert(tag_at(cp_index).is_field_or_method(), "Corrupted constant pool");
|
||||
assert(!tag_at(cp_index).has_bootstrap(), "Must be handled above");
|
||||
jint ref_index = *int_at_addr(cp_index);
|
||||
return extract_high_short_from_int(ref_index);
|
||||
}
|
||||
|
||||
constantTag ConstantPool::impl_tag_ref_at(int which, bool uncached) {
|
||||
int ConstantPool::name_and_type_ref_index_at(int index, Bytecodes::Code code) {
|
||||
return uncached_name_and_type_ref_index_at(to_cp_index(index, code));
|
||||
}
|
||||
|
||||
constantTag ConstantPool::tag_ref_at(int which, Bytecodes::Code code) {
|
||||
// which may be either a Constant Pool index or a rewritten index
|
||||
int pool_index = which;
|
||||
if (!uncached) {
|
||||
assert(cache() != nullptr, "'which' is a rewritten index so this class must have been rewritten");
|
||||
if (ConstantPool::is_invokedynamic_index(which)) {
|
||||
// Invokedynamic index is index into resolved_references
|
||||
pool_index = invokedynamic_bootstrap_ref_index_at(which);
|
||||
} else {
|
||||
// change byte-ordering and go via cache
|
||||
pool_index = remap_instruction_operand_from_cache(which);
|
||||
}
|
||||
}
|
||||
assert(cache() != nullptr, "'index' is a rewritten index so this class must have been rewritten");
|
||||
pool_index = to_cp_index(which, code);
|
||||
return tag_at(pool_index);
|
||||
}
|
||||
|
||||
int ConstantPool::impl_klass_ref_index_at(int which, bool uncached) {
|
||||
guarantee(!ConstantPool::is_invokedynamic_index(which),
|
||||
"an invokedynamic instruction does not have a klass");
|
||||
int i = which;
|
||||
if (!uncached) {
|
||||
assert(cache() != nullptr, "'which' is a rewritten index so this class must have been rewritten");
|
||||
// change byte-ordering and go via cache
|
||||
i = remap_instruction_operand_from_cache(which);
|
||||
}
|
||||
assert(tag_at(i).is_field_or_method(), "Corrupted constant pool");
|
||||
jint ref_index = *int_at_addr(i);
|
||||
int ConstantPool::uncached_klass_ref_index_at(int cp_index) {
|
||||
assert(tag_at(cp_index).is_field_or_method(), "Corrupted constant pool");
|
||||
jint ref_index = *int_at_addr(cp_index);
|
||||
return extract_low_short_from_int(ref_index);
|
||||
}
|
||||
|
||||
int ConstantPool::klass_ref_index_at(int index, Bytecodes::Code code) {
|
||||
guarantee(!ConstantPool::is_invokedynamic_index(index),
|
||||
"an invokedynamic instruction does not have a klass");
|
||||
assert(code != Bytecodes::_invokedynamic,
|
||||
"an invokedynamic instruction does not have a klass");
|
||||
return uncached_klass_ref_index_at(to_cp_index(index, code));
|
||||
}
|
||||
|
||||
|
||||
int ConstantPool::remap_instruction_operand_from_cache(int operand) {
|
||||
@ -773,16 +768,16 @@ int ConstantPool::signature_ref_index_at(int which_nt) {
|
||||
}
|
||||
|
||||
|
||||
Klass* ConstantPool::klass_ref_at(int which, TRAPS) {
|
||||
return klass_at(klass_ref_index_at(which), THREAD);
|
||||
Klass* ConstantPool::klass_ref_at(int which, Bytecodes::Code code, TRAPS) {
|
||||
return klass_at(klass_ref_index_at(which, code), THREAD);
|
||||
}
|
||||
|
||||
Symbol* ConstantPool::klass_name_at(int which) const {
|
||||
return symbol_at(klass_slot_at(which).name_index());
|
||||
}
|
||||
|
||||
Symbol* ConstantPool::klass_ref_at_noresolve(int which) {
|
||||
jint ref_index = klass_ref_index_at(which);
|
||||
Symbol* ConstantPool::klass_ref_at_noresolve(int which, Bytecodes::Code code) {
|
||||
jint ref_index = klass_ref_index_at(which, code);
|
||||
return klass_at_noresolve(ref_index);
|
||||
}
|
||||
|
||||
|
@ -501,15 +501,15 @@ class ConstantPool : public Metadata {
|
||||
// Derived queries:
|
||||
Symbol* method_handle_name_ref_at(int which) {
|
||||
int member = method_handle_index_at(which);
|
||||
return impl_name_ref_at(member, true);
|
||||
return uncached_name_ref_at(member);
|
||||
}
|
||||
Symbol* method_handle_signature_ref_at(int which) {
|
||||
int member = method_handle_index_at(which);
|
||||
return impl_signature_ref_at(member, true);
|
||||
return uncached_signature_ref_at(member);
|
||||
}
|
||||
int method_handle_klass_index_at(int which) {
|
||||
int member = method_handle_index_at(which);
|
||||
return impl_klass_ref_index_at(member, true);
|
||||
return uncached_klass_ref_index_at(member);
|
||||
}
|
||||
Symbol* method_type_signature_at(int which) {
|
||||
int sym = method_type_index_at(which);
|
||||
@ -657,17 +657,25 @@ class ConstantPool : public Metadata {
|
||||
// FIXME: Remove the dynamic check, and adjust all callers to specify the correct mode.
|
||||
|
||||
// Lookup for entries consisting of (klass_index, name_and_type index)
|
||||
Klass* klass_ref_at(int which, TRAPS);
|
||||
Symbol* klass_ref_at_noresolve(int which);
|
||||
Symbol* name_ref_at(int which) { return impl_name_ref_at(which, false); }
|
||||
Symbol* signature_ref_at(int which) { return impl_signature_ref_at(which, false); }
|
||||
Klass* klass_ref_at(int which, Bytecodes::Code code, TRAPS);
|
||||
Symbol* klass_ref_at_noresolve(int which, Bytecodes::Code code);
|
||||
Symbol* name_ref_at(int which, Bytecodes::Code code) {
|
||||
int name_index = name_ref_index_at(name_and_type_ref_index_at(which, code));
|
||||
return symbol_at(name_index);
|
||||
}
|
||||
Symbol* signature_ref_at(int which, Bytecodes::Code code) {
|
||||
int signature_index = signature_ref_index_at(name_and_type_ref_index_at(which, code));
|
||||
return symbol_at(signature_index);
|
||||
}
|
||||
|
||||
int klass_ref_index_at(int which) { return impl_klass_ref_index_at(which, false); }
|
||||
int name_and_type_ref_index_at(int which) { return impl_name_and_type_ref_index_at(which, false); }
|
||||
int klass_ref_index_at(int which, Bytecodes::Code code);
|
||||
int name_and_type_ref_index_at(int which, Bytecodes::Code code);
|
||||
|
||||
int remap_instruction_operand_from_cache(int operand); // operand must be biased by CPCACHE_INDEX_TAG
|
||||
|
||||
constantTag tag_ref_at(int cp_cache_index) { return impl_tag_ref_at(cp_cache_index, false); }
|
||||
constantTag tag_ref_at(int cp_cache_index, Bytecodes::Code code);
|
||||
|
||||
int to_cp_index(int which, Bytecodes::Code code);
|
||||
|
||||
// Lookup for entries consisting of (name_index, signature_index)
|
||||
int name_ref_index_at(int which_nt); // == low-order jshort of name_and_type_at(which_nt)
|
||||
@ -769,11 +777,17 @@ class ConstantPool : public Metadata {
|
||||
// Routines currently used for annotations (only called by jvm.cpp) but which might be used in the
|
||||
// future by other Java code. These take constant pool indices rather than
|
||||
// constant pool cache indices as do the peer methods above.
|
||||
Symbol* uncached_klass_ref_at_noresolve(int which);
|
||||
Symbol* uncached_name_ref_at(int which) { return impl_name_ref_at(which, true); }
|
||||
Symbol* uncached_signature_ref_at(int which) { return impl_signature_ref_at(which, true); }
|
||||
int uncached_klass_ref_index_at(int which) { return impl_klass_ref_index_at(which, true); }
|
||||
int uncached_name_and_type_ref_index_at(int which) { return impl_name_and_type_ref_index_at(which, true); }
|
||||
Symbol* uncached_klass_ref_at_noresolve(int cp_index);
|
||||
Symbol* uncached_name_ref_at(int cp_index) {
|
||||
int name_index = name_ref_index_at(uncached_name_and_type_ref_index_at(cp_index));
|
||||
return symbol_at(name_index);
|
||||
}
|
||||
Symbol* uncached_signature_ref_at(int cp_index) {
|
||||
int signature_index = signature_ref_index_at(uncached_name_and_type_ref_index_at(cp_index));
|
||||
return symbol_at(signature_index);
|
||||
}
|
||||
int uncached_klass_ref_index_at(int cp_index);
|
||||
int uncached_name_and_type_ref_index_at(int cp_index);
|
||||
|
||||
// Sharing
|
||||
int pre_resolve_shared_klasses(TRAPS);
|
||||
@ -800,13 +814,6 @@ class ConstantPool : public Metadata {
|
||||
Array<u2>* reference_map() const { return (_cache == nullptr) ? nullptr : _cache->reference_map(); }
|
||||
void set_reference_map(Array<u2>* o) { _cache->set_reference_map(o); }
|
||||
|
||||
Symbol* impl_name_ref_at(int which, bool uncached);
|
||||
Symbol* impl_signature_ref_at(int which, bool uncached);
|
||||
|
||||
int impl_klass_ref_index_at(int which, bool uncached);
|
||||
int impl_name_and_type_ref_index_at(int which, bool uncached);
|
||||
constantTag impl_tag_ref_at(int which, bool uncached);
|
||||
|
||||
// Used while constructing constant pool (only by ClassFileParser)
|
||||
jint klass_index_at(int which) {
|
||||
assert(tag_at(which).is_klass_index(), "Corrupted constant pool");
|
||||
|
@ -1320,7 +1320,7 @@ void GenerateOopMap::print_current_state(outputStream *os,
|
||||
case Bytecodes::_invokeinterface: {
|
||||
int idx = currentBC->has_index_u4() ? currentBC->get_index_u4() : currentBC->get_index_u2_cpcache();
|
||||
ConstantPool* cp = method()->constants();
|
||||
int nameAndTypeIdx = cp->name_and_type_ref_index_at(idx);
|
||||
int nameAndTypeIdx = cp->name_and_type_ref_index_at(idx, currentBC->code());
|
||||
int signatureIdx = cp->signature_ref_index_at(nameAndTypeIdx);
|
||||
Symbol* signature = cp->symbol_at(signatureIdx);
|
||||
os->print("%s", signature->as_C_string());
|
||||
@ -1597,16 +1597,16 @@ void GenerateOopMap::interp1(BytecodeStream *itr) {
|
||||
case Bytecodes::_jsr: do_jsr(itr->dest()); break;
|
||||
case Bytecodes::_jsr_w: do_jsr(itr->dest_w()); break;
|
||||
|
||||
case Bytecodes::_getstatic: do_field(true, true, itr->get_index_u2_cpcache(), itr->bci()); break;
|
||||
case Bytecodes::_putstatic: do_field(false, true, itr->get_index_u2_cpcache(), itr->bci()); break;
|
||||
case Bytecodes::_getfield: do_field(true, false, itr->get_index_u2_cpcache(), itr->bci()); break;
|
||||
case Bytecodes::_putfield: do_field(false, false, itr->get_index_u2_cpcache(), itr->bci()); break;
|
||||
case Bytecodes::_getstatic: do_field(true, true, itr->get_index_u2_cpcache(), itr->bci(), itr->code()); break;
|
||||
case Bytecodes::_putstatic: do_field(false, true, itr->get_index_u2_cpcache(), itr->bci(), itr->code()); break;
|
||||
case Bytecodes::_getfield: do_field(true, false, itr->get_index_u2_cpcache(), itr->bci(), itr->code()); break;
|
||||
case Bytecodes::_putfield: do_field(false, false, itr->get_index_u2_cpcache(), itr->bci(), itr->code()); break;
|
||||
|
||||
case Bytecodes::_invokevirtual:
|
||||
case Bytecodes::_invokespecial: do_method(false, false, itr->get_index_u2_cpcache(), itr->bci()); break;
|
||||
case Bytecodes::_invokestatic: do_method(true, false, itr->get_index_u2_cpcache(), itr->bci()); break;
|
||||
case Bytecodes::_invokedynamic: do_method(true, false, itr->get_index_u4(), itr->bci()); break;
|
||||
case Bytecodes::_invokeinterface: do_method(false, true, itr->get_index_u2_cpcache(), itr->bci()); break;
|
||||
case Bytecodes::_invokespecial: do_method(false, false, itr->get_index_u2_cpcache(), itr->bci(), itr->code()); break;
|
||||
case Bytecodes::_invokestatic: do_method(true, false, itr->get_index_u2_cpcache(), itr->bci(), itr->code()); break;
|
||||
case Bytecodes::_invokedynamic: do_method(true, false, itr->get_index_u4(), itr->bci(), itr->code()); break;
|
||||
case Bytecodes::_invokeinterface: do_method(false, true, itr->get_index_u2_cpcache(), itr->bci(), itr->code()); break;
|
||||
case Bytecodes::_newarray:
|
||||
case Bytecodes::_anewarray: pp_new_ref(vCTS, itr->bci()); break;
|
||||
case Bytecodes::_checkcast: do_checkcast(); break;
|
||||
@ -1931,10 +1931,10 @@ int GenerateOopMap::copy_cts(CellTypeState *dst, CellTypeState *src) {
|
||||
return idx;
|
||||
}
|
||||
|
||||
void GenerateOopMap::do_field(int is_get, int is_static, int idx, int bci) {
|
||||
void GenerateOopMap::do_field(int is_get, int is_static, int idx, int bci, Bytecodes::Code bc) {
|
||||
// Dig up signature for field in constant pool
|
||||
ConstantPool* cp = method()->constants();
|
||||
int nameAndTypeIdx = cp->name_and_type_ref_index_at(idx);
|
||||
int nameAndTypeIdx = cp->name_and_type_ref_index_at(idx, bc);
|
||||
int signatureIdx = cp->signature_ref_index_at(nameAndTypeIdx);
|
||||
Symbol* signature = cp->symbol_at(signatureIdx);
|
||||
|
||||
@ -1957,10 +1957,10 @@ void GenerateOopMap::do_field(int is_get, int is_static, int idx, int bci) {
|
||||
pp(in, out);
|
||||
}
|
||||
|
||||
void GenerateOopMap::do_method(int is_static, int is_interface, int idx, int bci) {
|
||||
void GenerateOopMap::do_method(int is_static, int is_interface, int idx, int bci, Bytecodes::Code bc) {
|
||||
// Dig up signature for field in constant pool
|
||||
ConstantPool* cp = _method->constants();
|
||||
Symbol* signature = cp->signature_ref_at(idx);
|
||||
Symbol* signature = cp->signature_ref_at(idx, bc);
|
||||
|
||||
// Parse method signature
|
||||
CellTypeState out[4];
|
||||
|
@ -396,8 +396,8 @@ class GenerateOopMap {
|
||||
void do_ldc (int bci);
|
||||
void do_astore (int idx);
|
||||
void do_jsr (int delta);
|
||||
void do_field (int is_get, int is_static, int idx, int bci);
|
||||
void do_method (int is_static, int is_interface, int idx, int bci);
|
||||
void do_field (int is_get, int is_static, int idx, int bci, Bytecodes::Code bc);
|
||||
void do_method (int is_static, int is_interface, int idx, int bci, Bytecodes::Code bc);
|
||||
void do_multianewarray (int dims, int bci);
|
||||
void do_monitorenter (int bci);
|
||||
void do_monitorexit (int bci);
|
||||
|
@ -978,8 +978,8 @@ bool Method::is_klass_loaded_by_klass_index(int klass_index) const {
|
||||
}
|
||||
|
||||
|
||||
bool Method::is_klass_loaded(int refinfo_index, bool must_be_resolved) const {
|
||||
int klass_index = constants()->klass_ref_index_at(refinfo_index);
|
||||
bool Method::is_klass_loaded(int refinfo_index, Bytecodes::Code bc, bool must_be_resolved) const {
|
||||
int klass_index = constants()->klass_ref_index_at(refinfo_index, bc);
|
||||
if (must_be_resolved) {
|
||||
// Make sure klass is resolved in constantpool.
|
||||
if (constants()->tag_at(klass_index).is_unresolved_klass()) return false;
|
||||
|
@ -841,7 +841,7 @@ public:
|
||||
|
||||
// Find if klass for method is loaded
|
||||
bool is_klass_loaded_by_klass_index(int klass_index) const;
|
||||
bool is_klass_loaded(int refinfo_index, bool must_be_resolved = false) const;
|
||||
bool is_klass_loaded(int refinfo_index, Bytecodes::Code bc, bool must_be_resolved = false) const;
|
||||
|
||||
// Indicates whether compilation failed earlier for this method, or
|
||||
// whether it is not compilable for another reason like having a
|
||||
|
@ -509,7 +509,7 @@ bool InlineTree::pass_initial_checks(ciMethod* caller_method, int caller_bci, ci
|
||||
// An invokedynamic instruction does not have a klass.
|
||||
if (call_bc != Bytecodes::_invokedynamic) {
|
||||
int index = iter.get_index_u2_cpcache();
|
||||
if (!caller_method->is_klass_loaded(index, true)) {
|
||||
if (!caller_method->is_klass_loaded(index, call_bc, true)) {
|
||||
return false;
|
||||
}
|
||||
// Try to do constant pool resolution if running Xcomp
|
||||
|
@ -96,9 +96,9 @@ bool MethodComparator::args_same(Bytecodes::Code const c_old, Bytecodes::Code c
|
||||
// Check if the names of classes, field/method names and signatures at these indexes
|
||||
// are the same. Indices which are really into constantpool cache (rather than constant
|
||||
// pool itself) are accepted by the constantpool query routines below.
|
||||
if ((old_cp->klass_ref_at_noresolve(cpci_old) != new_cp->klass_ref_at_noresolve(cpci_new)) ||
|
||||
(old_cp->name_ref_at(cpci_old) != new_cp->name_ref_at(cpci_new)) ||
|
||||
(old_cp->signature_ref_at(cpci_old) != new_cp->signature_ref_at(cpci_new)))
|
||||
if ((old_cp->klass_ref_at_noresolve(cpci_old, c_old) != new_cp->klass_ref_at_noresolve(cpci_new, c_old)) ||
|
||||
(old_cp->name_ref_at(cpci_old, c_old) != new_cp->name_ref_at(cpci_new, c_old)) ||
|
||||
(old_cp->signature_ref_at(cpci_old, c_old) != new_cp->signature_ref_at(cpci_new, c_old)))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
@ -114,8 +114,8 @@ bool MethodComparator::args_same(Bytecodes::Code const c_old, Bytecodes::Code c
|
||||
// are the same. Indices which are really into constantpool cache (rather than constant
|
||||
// pool itself) are accepted by the constantpool query routines below.
|
||||
// Currently needs encoded indy_index
|
||||
if ((old_cp->name_ref_at(index_old) != new_cp->name_ref_at(index_new)) ||
|
||||
(old_cp->signature_ref_at(index_old) != new_cp->signature_ref_at(index_new)))
|
||||
if ((old_cp->name_ref_at(index_old, c_old) != new_cp->name_ref_at(index_new, c_old)) ||
|
||||
(old_cp->signature_ref_at(index_old, c_old) != new_cp->signature_ref_at(index_new, c_old)))
|
||||
return false;
|
||||
|
||||
int cpi_old = old_cp->cache()->resolved_indy_entry_at(indy_index_old)->constant_pool_index();
|
||||
|
@ -1282,14 +1282,14 @@ JVM_ENTRY(void, MHN_copyOutBootstrapArguments(JNIEnv* env, jobject igcls,
|
||||
}
|
||||
case -3: // name
|
||||
{
|
||||
Symbol* name = caller->constants()->name_ref_at(bss_index_in_pool);
|
||||
Symbol* name = caller->constants()->name_ref_at(bss_index_in_pool, Bytecodes::_invokedynamic);
|
||||
Handle str = java_lang_String::create_from_symbol(name, CHECK);
|
||||
pseudo_arg = str();
|
||||
break;
|
||||
}
|
||||
case -2: // type
|
||||
{
|
||||
Symbol* type = caller->constants()->signature_ref_at(bss_index_in_pool);
|
||||
Symbol* type = caller->constants()->signature_ref_at(bss_index_in_pool, Bytecodes::_invokedynamic);
|
||||
Handle th;
|
||||
if (type->char_at(0) == JVM_SIGNATURE_FUNC) {
|
||||
th = SystemDictionary::find_method_handle_type(type, caller, CHECK);
|
||||
|
@ -1222,7 +1222,7 @@ Handle SharedRuntime::find_callee_info_helper(vframeStream& vfst, Bytecodes::Cod
|
||||
} else {
|
||||
// Klass is already loaded.
|
||||
constantPoolHandle constants(current, caller->constants());
|
||||
rk = constants->klass_ref_at(bytecode_index, CHECK_NH);
|
||||
rk = constants->klass_ref_at(bytecode_index, bc, CHECK_NH);
|
||||
}
|
||||
Klass* static_receiver_klass = rk;
|
||||
assert(receiver_klass->is_subtype_of(static_receiver_klass),
|
||||
|
@ -286,56 +286,63 @@ final class CompilerToVM {
|
||||
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
|
||||
* {@code constantPool}.
|
||||
* Gets the {@code JVM_CONSTANT_NameAndType} index referenced by the {@code rawIndex}.
|
||||
* The meaning of {@code rawIndex} is dependent on the given {@opcode}.
|
||||
*
|
||||
* The behavior of this method is undefined if {@code cpi} does not denote an entry containing a
|
||||
* {@code JVM_CONSTANT_NameAndType} index.
|
||||
* The behavior of this method is undefined if the class holding the {@code constantPool}
|
||||
* has not yet been rewritten, or {@code rawIndex} is not a valid index for
|
||||
* this class for the given {@code opcode}
|
||||
*/
|
||||
int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int cpi) {
|
||||
return lookupNameAndTypeRefIndexInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
|
||||
int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int rawIndex, int opcode) {
|
||||
return lookupNameAndTypeRefIndexInPool(constantPool, constantPool.getConstantPoolPointer(), rawIndex, opcode);
|
||||
}
|
||||
|
||||
private native int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
|
||||
private native int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int rawIndex, int opcode);
|
||||
|
||||
/**
|
||||
* Gets the name of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry
|
||||
* denoted by {@code which} in {@code constantPool}.
|
||||
* Gets the name of the {@code JVM_CONSTANT_NameAndType} entry in {@code constantPool}
|
||||
* referenced by the {@code rawIndex}. The meaning of {@code rawIndex} is dependent
|
||||
* on the given {@opcode}.
|
||||
*
|
||||
* The behavior of this method is undefined if {@code which} does not denote a entry that
|
||||
* references a {@code JVM_CONSTANT_NameAndType} entry.
|
||||
* The behavior of this method is undefined if the class holding the {@code constantPool}
|
||||
* has not yet been rewritten, or {@code rawIndex} is not a valid index for
|
||||
* this class for the given {@code opcode}
|
||||
*/
|
||||
String lookupNameInPool(HotSpotConstantPool constantPool, int which) {
|
||||
return lookupNameInPool(constantPool, constantPool.getConstantPoolPointer(), which);
|
||||
String lookupNameInPool(HotSpotConstantPool constantPool, int rawIndex, int opcode) {
|
||||
return lookupNameInPool(constantPool, constantPool.getConstantPoolPointer(), rawIndex, opcode);
|
||||
}
|
||||
|
||||
private native String lookupNameInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int which);
|
||||
private native String lookupNameInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int rawIndex, int opcode);
|
||||
|
||||
/**
|
||||
* Gets the signature of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry
|
||||
* denoted by {@code which} in {@code constantPool}.
|
||||
* Gets the signature of the {@code JVM_CONSTANT_NameAndType} entry in {@code constantPool}
|
||||
* referenced by the {@code rawIndex}. The meaning of {@code rawIndex} is dependent
|
||||
* on the given {@opcode}.
|
||||
*
|
||||
* The behavior of this method is undefined if {@code which} does not denote a entry that
|
||||
* references a {@code JVM_CONSTANT_NameAndType} entry.
|
||||
* The behavior of this method is undefined if the class holding the {@code constantPool}
|
||||
* has not yet been rewritten, or {@code rawIndex} is not a valid index for
|
||||
* this class for the given {@code opcode}
|
||||
*/
|
||||
String lookupSignatureInPool(HotSpotConstantPool constantPool, int which) {
|
||||
return lookupSignatureInPool(constantPool, constantPool.getConstantPoolPointer(), which);
|
||||
String lookupSignatureInPool(HotSpotConstantPool constantPool, int rawIndex, int opcode) {
|
||||
return lookupSignatureInPool(constantPool, constantPool.getConstantPoolPointer(), rawIndex, opcode);
|
||||
}
|
||||
|
||||
private native String lookupSignatureInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int which);
|
||||
private native String lookupSignatureInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int rawIndex, int opcode);
|
||||
|
||||
/**
|
||||
* Gets the {@code JVM_CONSTANT_Class} index from the entry at index {@code cpi} in
|
||||
* {@code constantPool}.
|
||||
* Gets the {@code JVM_CONSTANT_Class} index from the entry in {@code constantPool}
|
||||
* referenced by the {@code rawIndex}. The meaning of {@code rawIndex} is dependent
|
||||
* on the given {@opcode}.
|
||||
*
|
||||
* The behavior of this method is undefined if {@code cpi} does not denote an entry containing a
|
||||
* {@code JVM_CONSTANT_Class} index.
|
||||
* The behavior of this method is undefined if the class holding the {@code constantPool}
|
||||
* has not yet been rewritten, or {@code rawIndex} is not a valid index for
|
||||
* this class for the given {@code opcode}
|
||||
*/
|
||||
int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int cpi) {
|
||||
return lookupKlassRefIndexInPool(constantPool, constantPool.getConstantPoolPointer(), cpi);
|
||||
int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int rawIndex, int opcode) {
|
||||
return lookupKlassRefIndexInPool(constantPool, constantPool.getConstantPoolPointer(), rawIndex, opcode);
|
||||
}
|
||||
|
||||
private native int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi);
|
||||
private native int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int rawIndex, int opcode);
|
||||
|
||||
/**
|
||||
* Looks up a class denoted by the {@code JVM_CONSTANT_Class} entry at index {@code cpi} in
|
||||
|
@ -389,22 +389,24 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
|
||||
* Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index
|
||||
* {@code index}.
|
||||
*
|
||||
* @param index constant pool index
|
||||
* @param rawIndex rewritten index in the bytecode stream
|
||||
* @param opcode the opcode of the instruction for which the lookup is being performed
|
||||
* @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry
|
||||
*/
|
||||
private int getNameAndTypeRefIndexAt(int index) {
|
||||
return compilerToVM().lookupNameAndTypeRefIndexInPool(this, index);
|
||||
private int getNameAndTypeRefIndexAt(int rawIndex, int opcode) {
|
||||
return compilerToVM().lookupNameAndTypeRefIndexInPool(this, rawIndex, opcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry referenced by another
|
||||
* entry denoted by {@code which}.
|
||||
*
|
||||
* @param which constant pool index or constant pool cache index
|
||||
* @param rawIndex rewritten index in the bytecode stream
|
||||
* @param opcode the opcode of the instruction for which the lookup is being performed
|
||||
* @return name as {@link String}
|
||||
*/
|
||||
private String getNameOf(int which) {
|
||||
return compilerToVM().lookupNameInPool(this, which);
|
||||
private String getNameOf(int rawIndex, int opcode) {
|
||||
return compilerToVM().lookupNameInPool(this, rawIndex, opcode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -424,11 +426,12 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
|
||||
* Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry referenced by
|
||||
* another entry denoted by {@code which}.
|
||||
*
|
||||
* @param which constant pool index or constant pool cache index
|
||||
* @param rawIndex rewritten index in the bytecode stream
|
||||
* @param opcode the opcode of the instruction for which the lookup is being performed
|
||||
* @return signature as {@link String}
|
||||
*/
|
||||
private String getSignatureOf(int which) {
|
||||
return compilerToVM().lookupSignatureInPool(this, which);
|
||||
private String getSignatureOf(int rawIndex, int opcode) {
|
||||
return compilerToVM().lookupSignatureInPool(this, rawIndex, opcode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -447,11 +450,12 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
|
||||
/**
|
||||
* Gets the klass reference index constant pool entry at index {@code index}.
|
||||
*
|
||||
* @param index constant pool index
|
||||
* @param rawIndex rewritten index in the bytecode stream
|
||||
* @param opcode the opcode of the instruction for which the lookup is being performed
|
||||
* @return klass reference index
|
||||
*/
|
||||
private int getKlassRefIndexAt(int index) {
|
||||
return compilerToVM().lookupKlassRefIndexInPool(this, index);
|
||||
private int getKlassRefIndexAt(int rawIndex, int opcode) {
|
||||
return compilerToVM().lookupKlassRefIndexInPool(this, rawIndex, opcode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -710,12 +714,12 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
|
||||
return method;
|
||||
} else {
|
||||
// Get the method's name and signature.
|
||||
String name = getNameOf(index);
|
||||
HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureOf(index));
|
||||
String name = getNameOf(index, opcode);
|
||||
HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureOf(index, opcode));
|
||||
if (opcode == Bytecodes.INVOKEDYNAMIC) {
|
||||
return new UnresolvedJavaMethod(name, signature, runtime().getMethodHandleClass());
|
||||
} else {
|
||||
final int klassIndex = getKlassRefIndexAt(index);
|
||||
final int klassIndex = getKlassRefIndexAt(index, opcode);
|
||||
final Object type = compilerToVM().lookupKlassInPool(this, klassIndex);
|
||||
return new UnresolvedJavaMethod(name, signature, getJavaType(type));
|
||||
}
|
||||
@ -760,7 +764,7 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
|
||||
case Bytecodes.INVOKESTATIC:
|
||||
case Bytecodes.INVOKEINTERFACE: {
|
||||
index = rawIndexToConstantPoolCacheIndex(cpi, opcode);
|
||||
index = getKlassRefIndexAt(index);
|
||||
index = getKlassRefIndexAt(index, opcode);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -773,12 +777,12 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
|
||||
@Override
|
||||
public JavaField lookupField(int cpi, ResolvedJavaMethod method, int opcode) {
|
||||
final int index = rawIndexToConstantPoolCacheIndex(cpi, opcode);
|
||||
final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index);
|
||||
final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index, opcode);
|
||||
final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex);
|
||||
String typeName = lookupUtf8(typeIndex);
|
||||
JavaType type = runtime().lookupType(typeName, getHolder(), false);
|
||||
|
||||
final int holderIndex = getKlassRefIndexAt(index);
|
||||
final int holderIndex = getKlassRefIndexAt(index, opcode);
|
||||
JavaType fieldHolder = lookupType(holderIndex, opcode);
|
||||
|
||||
if (fieldHolder instanceof HotSpotResolvedObjectTypeImpl) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, 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
|
||||
@ -106,20 +106,20 @@ public class CompilerToVMHelper {
|
||||
return obj.object;
|
||||
}
|
||||
|
||||
public static int lookupNameAndTypeRefIndexInPool(ConstantPool constantPool, int cpi) {
|
||||
return CTVM.lookupNameAndTypeRefIndexInPool((HotSpotConstantPool) constantPool, cpi);
|
||||
public static int lookupNameAndTypeRefIndexInPool(ConstantPool constantPool, int rawIndex, int opcode) {
|
||||
return CTVM.lookupNameAndTypeRefIndexInPool((HotSpotConstantPool) constantPool, rawIndex, opcode);
|
||||
}
|
||||
|
||||
public static String lookupNameInPool(ConstantPool constantPool, int cpi) {
|
||||
return CTVM.lookupNameInPool((HotSpotConstantPool) constantPool, cpi);
|
||||
public static String lookupNameInPool(ConstantPool constantPool, int rawIndex, int opcode) {
|
||||
return CTVM.lookupNameInPool((HotSpotConstantPool) constantPool, rawIndex, opcode);
|
||||
}
|
||||
|
||||
public static String lookupSignatureInPool(ConstantPool constantPool, int cpi) {
|
||||
return CTVM.lookupSignatureInPool((HotSpotConstantPool) constantPool, cpi);
|
||||
public static String lookupSignatureInPool(ConstantPool constantPool, int rawIndex, int opcode) {
|
||||
return CTVM.lookupSignatureInPool((HotSpotConstantPool) constantPool, rawIndex, opcode);
|
||||
}
|
||||
|
||||
public static int lookupKlassRefIndexInPool(ConstantPool constantPool, int cpi) {
|
||||
return CTVM.lookupKlassRefIndexInPool((HotSpotConstantPool) constantPool, cpi);
|
||||
public static int lookupKlassRefIndexInPool(ConstantPool constantPool, int rawIndex, int opcode) {
|
||||
return CTVM.lookupKlassRefIndexInPool((HotSpotConstantPool) constantPool, rawIndex, opcode);
|
||||
}
|
||||
|
||||
public static Object lookupKlassInPool(ConstantPool constantPool, int cpi) {
|
||||
|
@ -32,6 +32,7 @@ import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.org.objectweb.asm.Opcodes;
|
||||
import jdk.internal.reflect.ConstantPool;
|
||||
import jdk.internal.reflect.ConstantPool.Tag;
|
||||
import jdk.vm.ci.hotspot.HotSpotConstantPool.Bytecodes;
|
||||
import jdk.vm.ci.meta.MetaAccessProvider;
|
||||
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
import jdk.vm.ci.meta.ResolvedJavaType;
|
||||
@ -97,6 +98,29 @@ public class ConstantPoolTestsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cpType Constant type from the Constant pool
|
||||
* @return a bytecode that's suitable for passing to the following functions for the given cpType:
|
||||
* - CompilerToVMHelper.lookupNameAndTypeRefIndexInPool()
|
||||
* - CompilerToVMHelper.lookupNameInPool()
|
||||
* - CompilerToVMHelper.lookupSignatureInPool()
|
||||
* - CompilerToVMHelper.lookupKlassRefIndexInPool()
|
||||
*/
|
||||
public static int getDummyOpcode(ConstantTypes cpType) {
|
||||
switch (cpType) {
|
||||
case CONSTANT_FIELDREF:
|
||||
return Bytecodes.GETFIELD;
|
||||
case CONSTANT_METHODREF:
|
||||
return Bytecodes.INVOKEVIRTUAL;
|
||||
case CONSTANT_INTERFACEMETHODREF:
|
||||
return Bytecodes.INVOKEINTERFACE;
|
||||
case CONSTANT_INVOKEDYNAMIC:
|
||||
return Bytecodes.INVOKEDYNAMIC;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unexpected constant pool entry type");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Obtain a resolved Java method declared by a given type.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, 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
|
||||
@ -93,19 +93,13 @@ public class LookupKlassRefIndexInPoolTest {
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
int index = cpi;
|
||||
String cached = "";
|
||||
int cpci = dummyClass.getCPCacheIndex(cpi);
|
||||
if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
|
||||
index = cpci;
|
||||
cached = "cached ";
|
||||
}
|
||||
int indexToVerify = CompilerToVMHelper.lookupKlassRefIndexInPool(constantPoolCTVM, index);
|
||||
int opcode = ConstantPoolTestsHelper.getDummyOpcode(cpType);
|
||||
int index = dummyClass.getCPCacheIndex(cpi);
|
||||
Asserts.assertTrue(index != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT, "the class must have been rewritten");
|
||||
int indexToVerify = CompilerToVMHelper.lookupKlassRefIndexInPool(constantPoolCTVM, index, opcode);
|
||||
int indexToRefer = dummyClass.constantPoolSS.getClassRefIndexAt(cpi);
|
||||
String msg = String.format("Wrong class index returned by lookupKlassRefIndexInPool method "
|
||||
+ "applied to %sconstant pool index %d",
|
||||
cached,
|
||||
index);
|
||||
+ "applied to cached constant pool index %d", index);
|
||||
Asserts.assertEQ(indexToRefer, indexToVerify, msg);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, 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
|
||||
@ -95,19 +95,13 @@ public class LookupNameAndTypeRefIndexInPoolTest {
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
int index = cpi;
|
||||
String cached = "";
|
||||
int cpci = dummyClass.getCPCacheIndex(cpi);
|
||||
if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
|
||||
index = cpci;
|
||||
cached = "cached ";
|
||||
}
|
||||
int indexToVerify = CompilerToVMHelper.lookupNameAndTypeRefIndexInPool(constantPoolCTVM, index);
|
||||
int opcode = ConstantPoolTestsHelper.getDummyOpcode(cpType);
|
||||
int index = dummyClass.getCPCacheIndex(cpi);
|
||||
Asserts.assertTrue(index != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT, "the class must have been rewritten");
|
||||
int indexToVerify = CompilerToVMHelper.lookupNameAndTypeRefIndexInPool(constantPoolCTVM, index, opcode);
|
||||
int indexToRefer = dummyClass.constantPoolSS.getNameAndTypeRefIndexAt(cpi);
|
||||
String msg = String.format("Wrong nameAndType index returned by lookupNameAndTypeRefIndexInPool"
|
||||
+ " method applied to %sconstant pool index %d",
|
||||
cached,
|
||||
index);
|
||||
+ " method applied to cached constant pool index %d", index);
|
||||
Asserts.assertEQ(indexToRefer, indexToVerify, msg);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, 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
|
||||
@ -96,16 +96,12 @@ public class LookupNameInPoolTest {
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
int index = cpi;
|
||||
String cached = "";
|
||||
int cpci = dummyClass.getCPCacheIndex(cpi);
|
||||
if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
|
||||
index = cpci;
|
||||
cached = "cached ";
|
||||
}
|
||||
String nameToVerify = CompilerToVMHelper.lookupNameInPool(constantPoolCTVM, index);
|
||||
int opcode = ConstantPoolTestsHelper.getDummyOpcode(cpType);
|
||||
int index = dummyClass.getCPCacheIndex(cpi);
|
||||
Asserts.assertTrue(index != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT, "the class must have been rewritten");
|
||||
String nameToVerify = CompilerToVMHelper.lookupNameInPool(constantPoolCTVM, index, opcode);
|
||||
String nameToRefer = entry.name;
|
||||
String msg = String.format("Wrong name accessed by %sconstant pool index %d", cached, index);
|
||||
String msg = String.format("Wrong name accessed by cached constant pool index %d", index);
|
||||
Asserts.assertEQ(nameToVerify, nameToRefer, msg);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, 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
|
||||
@ -96,18 +96,12 @@ public class LookupSignatureInPoolTest {
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
int index = cpi;
|
||||
String cached = "";
|
||||
int cpci = dummyClass.getCPCacheIndex(cpi);
|
||||
if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
|
||||
index = cpci;
|
||||
cached = "cached ";
|
||||
}
|
||||
String sigToVerify = CompilerToVMHelper.lookupSignatureInPool(constantPoolCTVM, index);
|
||||
int opcode = ConstantPoolTestsHelper.getDummyOpcode(cpType);
|
||||
int index = dummyClass.getCPCacheIndex(cpi);
|
||||
Asserts.assertTrue(index != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT, "the class must have been rewritten");
|
||||
String sigToVerify = CompilerToVMHelper.lookupSignatureInPool(constantPoolCTVM, index, opcode);
|
||||
String sigToRefer = entry.type;
|
||||
String msg = String.format("Wrong signature accessed by %sconstant pool index %d",
|
||||
cached,
|
||||
index);
|
||||
String msg = String.format("Wrong signature accessed by cached constant pool index %d", index);
|
||||
Asserts.assertEQ(sigToVerify, sigToRefer, msg);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user