RFR: 8318383: Remove duplicated checks in os::get_native_stack() in posix implementation

Thomas Stuefe stuefe at openjdk.org
Thu Oct 19 06:35:33 UTC 2023


On Wed, 18 Oct 2023 15:04:01 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:

>> Hi Zhengyu,
>> 
>> This is not trivial :)
>> 
>> let
>> A=> fp == null
>> B=> cb != null
>> C=> sender-pc == null
>> D=> is_first_frame
>> 
>> Old:
>> if (A || B || C || D) break;
>> if (!C && !D) get_sender_for...;
>> 
>> New:
>> if (A || B || C || D) break;
>> get_sender...
>> 
>> Not sure if that is correct, but it is at least not equivalent, so not a simple cleanup.
>> 
>> (note that I support any cleanup, the old code is terrible).
>
>> Hi Zhengyu,
>> 
>> This is not trivial :)
>> 
>> let A=> fp == null B=> cb != null C=> sender-pc == null D=> is_first_frame
>> 
>> Old: if (A || B || C || D) break; if (!C && !D) get_sender_for...;
>> 
>> New: if (A || B || C || D) break; get_sender...
>> 
>> Not sure if that is correct, but it is at least not equivalent, so not a simple cleanup.
>> 
>> (note that I support any cleanup, the old code is terrible).
> 
> I agree it is confusing, I stared at it for quite a long while. I think I copied it from somewhere.
> 
> In the old code, when it arrives to the second check, it must have:
> 
> `fr.send_pc() != nullptr` and `os::is_first_C_frame(&fr) == false`
> 
> so `if (fr.sender_pc() && !os::is_first_C_frame(&fr))` check is always `true`, no?
> 
> For `if (A || B || C || D) break;` not to break out, it must have `C == false` and `D == false`, then `!C && !D` should always be `true`.

@zhengyu123 @dholmes-ora Okay, I think you are right.

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

PR Comment: https://git.openjdk.org/jdk/pull/16232#issuecomment-1770134266


More information about the hotspot-runtime-dev mailing list