RFR: 8269592: [JVMCI] Optimize c2v_iterateFrames

Vladimir Kozlov kvn at openjdk.java.net
Thu Jul 8 22:59:48 UTC 2021


On Tue, 29 Jun 2021 17:26:58 GMT, Andreas Woess <aw at openjdk.org> wrote:

> Several smaller optimizations and cleanups to JVMCI's iterateFrames:
> * Restructure the iterateFrames method for better readability and maintenance, with some parts extracted to helper functions.
> * Use vframeStream as the iterator for faster iteration in case not every vframe matches the method filter, so we can avoid creating javaVFrames for skipped vframes. We use vframeStream::asJavaVFrame() to get the current javaVFrame.
> * Extended vframeStream::asJavaVFrame() to also work with native frames, so that it works with all java frames returned by vframeStream. This way, native compiledVFrames will just work and do not need extra handling.
> Test coverage is provided via a newly added iterateFrames jtreg test that includes a JNI call on the stack.
> * Added two trivial getters to vframeStream: vframe_id() and decode_offset().
> These are used together with compiledVFrame::at_scope() to avoid going through vframeStream::asJavaVFrame() and recreating the scope objects for every matched inlined vframe of a compiled frame which would be more expensive than using javaVFrame::sender() (that shares the scope object pool).
> * Only resolve the callback interface method once per iterateFrames call.
> * Only resolve the Method* of the ResolvedJavaMethods to be matched once per iterateFrames call.
> * Only allocate localIsVirtual array if at least one local is virtual (the Java part already expects this).
> * Use matched ResolvedJavaMethod instances instead of going through JVMCIEnv::get_jvmci_method, if possible.

My concern comes from fact that we don't treat `native` frame as as `java` frame: [frame.cpp#L183](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/frame.cpp#L183). And `frame::is_compiled_frame()` specifically checks that compiled method is Java method.

On other hand we create `compiledVFrame` for native calls wrappers - we check only that it is compiled code: [vframe.cpp#L81](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/vframe.cpp#L81). And `compiledVFrame` is subclass of `javaVFrame`. Which is conflicting for me but it is not related to these changes.

Okay, if Tom and Dean think it is safe change for `asJavaVFrame()` code I will approve changes.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4625


More information about the hotspot-dev mailing list