Skip to content
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

Add Exception::CallStack.empty #15017

Conversation

straight-shoota
Copy link
Member

This is a follow-up on #15002 which explicitly assigns a dummy callstack to RetryLookupWithLiterals for performance reasons.
CallStack.empty is intended to make this use case a bit more ergonomical. It doesn't require allocating a dummy instance with fake data. Instead, it's an explicitly empty callstack. This makes this mechanism easier to re-use in other places (ref #11658 (comment)).

@straight-shoota straight-shoota added this to the 1.14.0 milestone Sep 20, 2024
@straight-shoota straight-shoota merged commit b679b56 into crystal-lang:master Sep 21, 2024
65 checks passed
@straight-shoota straight-shoota deleted the refactor/exception_callstack.empty branch September 21, 2024 11:01
@oprypin
Copy link
Member

oprypin commented Sep 21, 2024

Worth noting that this changes the behavior. Previously the same instance was used but now a new one is created every time.

@straight-shoota
Copy link
Member Author

straight-shoota commented Sep 21, 2024

Exception::CallStack is a struct, so same instance should not have much significance. Or am I missing something...? 🤔
It's a new Array allocation, though.

@beta-ziliani
Copy link
Member

yeah it seems the empty array could be cached (and ask users of .empty to not modify it)

@straight-shoota
Copy link
Member Author

straight-shoota commented Sep 23, 2024

CallStack#@callstack is never modified. It's not even directly accessible from the public API.

I think it should better be a Slice. But unfortunately, changing this a bit tricky because it involves the compiler primitive interpreter_call_stack_unwind. Should still be doable, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants