Skip to content

[lldb] Defer checking CFA memory region (#7877) #8037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kastiglione
Copy link

To support stepping in Swift async code, LLDB uses the memory region (ie stack vs heap)
of the Canonical Frame Address (CFA) to identify when an async function calls a
synchronous function.

But this has resulted in a performance regression, as determining the memory region of
the CFA is not free, and eagerly performing this query for every StackID,
particularly during backtracing/unwinding – when stepping is not yet occurring, is
wasteful.

This change proposes a solution that defers the memory region query until required to
perform stepping logic. The logic that checks heaps vs stacks was moved into
ThreadPlan, the only place that currently needs to make that determination.
Performing this check in ThreadPlan provides access to the process, allowing
stack/heap determination to happen as needed. Previously, the stack/heap determination
was made eagerly when the StackID was constructed.

rdar://117505613

(cherry-picked from commit c58c369)

To support stepping in Swift async code, LLDB uses the memory region (ie stack vs heap) 
of the Canonical Frame Address (CFA) to identify when an async function calls a 
synchronous function.

But this has resulted in a performance regression, as determining the memory region of 
the CFA is not free, and eagerly performing this query for every `StackID`, 
particularly during backtracing/unwinding – when stepping is not yet occurring, is 
wasteful.

This change proposes a solution that defers the memory region query until required to 
perform stepping logic. The logic that checks heaps vs stacks was moved into 
`ThreadPlan`, the only place that currently needs to make that determination. 
Performing this check in `ThreadPlan` provides access to the process, allowing 
stack/heap determination to happen as needed. Previously, the stack/heap determination 
was made eagerly when the `StackID` was constructed. 

rdar://117505613

(cherry-picked from commit c58c369)
@kastiglione kastiglione merged commit cb9f72f into next Jan 24, 2024
@kastiglione kastiglione deleted the dl/next/lldb-Defer-checking-CFA-memory-region-7877 branch January 24, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant