Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,17 @@ 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));

Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF);
int holder_index = cp->klass_ref_index_at(index, bc);
if (!cp->tag_at(holder_index).is_klass() && !THREAD->can_call_java()) {
// If the holder is not resolved in the constant pool and the current
// thread cannot call Java, return null. This avoids a Java call
// in LinkInfo to load the holder.
Symbol* klass_name = cp->klass_ref_at_noresolve(index, bc);
return nullptr;
}

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);
Expand Down
51 changes: 0 additions & 51 deletions src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1819,57 +1819,6 @@ Klass* JVMCIRuntime::get_klass_by_index(const constantPoolHandle& cpool,
return result;
}

// ------------------------------------------------------------------
// Implementation of get_field_by_index.
//
// 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, Bytecodes::Code bc) {
JVMCI_EXCEPTION_CONTEXT;

assert(klass->is_linked(), "must be linked before using its constant-pool");

constantPoolHandle cpool(thread, klass->constants());

// Get the field's name, signature, and type.
Symbol* name = cpool->name_ref_at(index, bc);

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, bc);
bool holder_is_accessible;
Klass* declared_holder = get_klass_by_index(cpool, holder_index,
holder_is_accessible,
klass);

// The declared holder of this field may not have been loaded.
// Bail out with partial field information.
if (!holder_is_accessible) {
return;
}


// Perform the field lookup.
Klass* canonical_holder =
InstanceKlass::cast(declared_holder)->find_field(name, signature, &field_desc);
if (canonical_holder == nullptr) {
return;
}

assert(canonical_holder == field_desc.field_holder(), "just checking");
}

// ------------------------------------------------------------------
// Get a field by index from a klass's constant pool.
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, bc);
}

// ------------------------------------------------------------------
// Perform an appropriate method lookup based on accessor, holder,
// name, signature, and bytecode.
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/share/jvmci/jvmciRuntime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
int klass_index,
bool& is_accessible,
Klass* loading_klass);
static void get_field_by_index_impl(InstanceKlass* loading_klass, fieldDescriptor& fd,
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);
Expand Down Expand Up @@ -417,8 +415,6 @@ class JVMCIRuntime: public CHeapObj<mtJVMCI> {
int klass_index,
bool& is_accessible,
Klass* loading_klass);
static void get_field_by_index(InstanceKlass* loading_klass, fieldDescriptor& fd,
int field_index, Bytecodes::Code bc);
static Method* get_method_by_index(const constantPoolHandle& cpool,
int method_index, Bytecodes::Code bc,
InstanceKlass* loading_klass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool
* The behavior of this method is undefined if {@code rawIndex} is invalid.
*
* @param info an array in which the details of the field are returned
* @return the type defining the field if resolution is successful, null otherwise
* @return the type defining the field if resolution is successful, null if the type cannot be resolved
* @throws LinkageError if there were other problems resolving the field
*/
HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, int rawIndex, HotSpotResolvedJavaMethodImpl method, byte opcode, int[] info) {
long methodPointer = method != null ? method.getMethodPointer() : 0L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,16 +841,16 @@ public JavaField lookupField(int rawIndex, ResolvedJavaMethod method, int opcode
final int holderIndex = getKlassRefIndexAt(rawIndex, opcode);
JavaType fieldHolder = lookupType(holderIndex, opcode);

if (fieldHolder instanceof HotSpotResolvedObjectTypeImpl) {
if (fieldHolder instanceof HotSpotResolvedObjectTypeImpl) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (fieldHolder instanceof HotSpotResolvedObjectTypeImpl) {
if (fieldHolder instanceof HotSpotResolvedObjectTypeImpl) {

int[] info = new int[4];
HotSpotResolvedObjectTypeImpl resolvedHolder;
try {
resolvedHolder = compilerToVM().resolveFieldInPool(this, rawIndex, (HotSpotResolvedJavaMethodImpl) method, (byte) opcode, info);
} catch (Throwable t) {
/*
* If there was an exception resolving the field we give up and return an unresolved
* field.
*/
resolvedHolder = null;
}
if (resolvedHolder == null) {
// There was an exception resolving the field or it returned null so return an unresolved field.
return new UnresolvedJavaField(fieldHolder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
}
final int flags = info[0];
Expand Down