JDK-8014013 : CallInfo structure no longer accurately reports the result of a LinkResolver operation
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs23,hs24,hs25,7u40,8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2013-05-06
  • Updated: 2023-09-12
  • Resolved: 2013-09-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 Other
8Fixed hs25Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
The CallInfo structure is used to return a multi-component result from a request for method linkage, via the LinkResolver API.

For example, the result of resolving an invokevirtual call placed (as needed) a v-table index into the CallInfo, so that the caller could "see" how to make the call.  Meanwhile, an invokespecial resolution would put a neutral (negative) v-table index in, to ensure that callers would not mistake this for a virtual call.

Th CallInfo structure has always suffered from a slight defect, in that it did not record the i-table index for an interface call.  But that was reasonable given the fact that interfaces could not accept "special" or "static" calls.  So it was correct when downstream code from a CallInfo would notice an interface and then compute the i-table index.

JVM support for concrete interface methods was added in JDK-8006267.  Now interfaces and classes are more similar (to the JVM) than they are different, and it is necessary to distinction static from virtual from special calls to interface methods, just as for class methods.

This means that CallInfo needs not only a _vtable_index member but also a _itable_index member, which needs to be filled it (or left negative) as appropriate, in substantially the same way that _vtable index is processed.

(Note that the two members cannot be merged into a single index, because interface calls can degrade to virtual or even special calls.  This is a little-known corner case in the JVM which must be supported.)

The is_statically_bound query needs to check both of the index members for negative sentinel values.

There are a few places where logic post-processes the result of a LinkResolver call (which produces a CallInfo) in the case of an interface.  The post processing calls klassItable::compute_itable_index to supply data missing from the CallInfo result.  Notably, there is such code at the end of InterpreterRuntime::resolve_invoke, where the complexity is directly due to the original flaw in CallInfo.  This logic needs to be consolidated into LinkResolver, so that there is one place where all such queries are computed.  There is also duplicate logic in methodHandles.cpp which needs a similar cleanup.

This post-processing of interfaces is error-prone, since it distributes the interface-related special cases among clients of the LinkResolver API, instead of inside LinkResolver.  This has led directly to complexity and bugs.  For example, in methodHandles.cpp, the client code attempts to perform classification that should have been completed by LinkResolver, and gets it wrong (in a way hard to locate and debug) in the case of new method types inside interfaces.

Finally, certain LinkResolver queries which are used only from the compiler interface (e.g., resolve_virtual_vtable_index) need to be recast to use the CallInfo mechanism to report results, again so that there is just one place for queries and no risk of duplicate logic.
Comments
Does this issue affect 7u40 and hs23, hs24? Is so, why it is not backported there?
14-02-2015

URL: http://hg.openjdk.java.net/hsx/hsx25/hotspot/rev/b2e698d2276c User: amurillo Date: 2013-09-20 22:11:15 +0000
20-09-2013

URL: http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/b2e698d2276c User: jrose Date: 2013-09-18 06:21:46 +0000
18-09-2013

Dup JDK-7191363 has affected versions hs23, hs24. Added here.
13-08-2013

Looks like it also affects regression test: api/java_lang/Iterable/ForEach_ForEach
22-07-2013

Sending it David Chase's way as he is working on this.
18-07-2013

The proposed fix for JDK-8014013 also fixes JDK-7087658.
13-06-2013

update of patch; includes itable simplification
13-06-2013

updated version of patch passes MethodHandlesTest and fixes JDK-7087658
13-06-2013

Bug JDK-7087658 should be fixed by this refactoring.
11-06-2013