os::current_frame does not return the "current" frame (not for the caller and not for the callee). It turns the frame of the caller's caller. Thus the name is misleading. We may want to make it return the caller's frame, and leave it up to the caller to apply the logic to go up one frame further. Either that or come up with a better name, but any name we pick is bound to be somewhat awkward.
Even with the change to return the caller's frame, the name is still a bit confusing, because you could argue that the "current" frame is the one that is current while in os::current_frame(), although it probably makes more sense to think of "current" as being from the POV of the caller.
As part of this cleanup, it might also make sense to manually inline _get_previous_fp() on the platforms that use it. This way we no longer need extra logic to decide if _get_previous_fp() was not inlined and needs to be skipped.
Also related to all this is the following RFE:
JDK-8163899 NMT frame skipping code is fragile
If it is addressed, then the need for os::current_frame() might go away.
Even with the change to return the caller's frame, the name is still a bit confusing, because you could argue that the "current" frame is the one that is current while in os::current_frame(), although it probably makes more sense to think of "current" as being from the POV of the caller.
As part of this cleanup, it might also make sense to manually inline _get_previous_fp() on the platforms that use it. This way we no longer need extra logic to decide if _get_previous_fp() was not inlined and needs to be skipped.
Also related to all this is the following RFE:
If it is addressed, then the need for os::current_frame() might go away.
- relates to
-
JDK-8133740 NMT for Linux/x86/x64 and bsd/x64 slowdebug builds includes NativeCallStack::NativeCallStack() frame in backtrace
-
- Resolved
-
-
JDK-8074075 invalid assert in oop::register_oop()
-
- Closed
-
-
JDK-8163899 NMT frame skipping code is fragile
-
- Closed
-