Hi,

On 6/3/19 11:36 AM, Nick Gasson wrote:
> 
>> We need to know what it's used for to know which solution is right. I'm
>> guessing the primary use case is asynchronous runtime stack probes, used
>> by debugging tools.
>>
> 
> Yes, we also have os::stack_shadow_pages_available() which uses it to 
> calculate how much space there is between the current SP and the end of 
> the stack. In this case I think it's ok as long as we don't return a 
> value that's *above* the actual stack pointer. And os::current_frame(), 
> which constructs a `frame' object using the FP of the caller, but the SP 
> will point into the frame of os::current_frame(), so it seems it's 
> already inaccurate.

Eww.

> There's also a comment in os_linux.cpp that says "Don't use 
> os::current_stack_pointer(), as its result can be slightly below current
> stack pointer". So I'm wondering if we can simplify this a lot and use 
> __builtin_frame_address(0) which will give us the FP in 
> os::current_stack_pointer (ought to be the caller's SP - 16). Zero does 
> this currently. And maybe we can replace _get_previous_fp() with 
> __builtin_frame_address(1)?

Let's make os::current_stack_pointer() noinline, then make it return
__builtin_frame_address(0).

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671

Reply via email to