Skip to content

feature: Unbox var interning in the IR #320

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
merged 2 commits into from
Apr 13, 2025

Conversation

stmonty
Copy link
Contributor

@stmonty stmonty commented Apr 5, 2025

This PR creates a new c_api function jank_var_intern_c used for interning vars just with c strings.

[monty@nixos:~/repos/jank/compiler+runtime]$ ./build/jank compile clojure.core | wc -l
162070

{
auto const ns_string{ native_persistent_string(ns) };
__rt_ctx->intern_ns(ns_string);
auto const name_string{ native_persistent_string(name) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for lines 100 or 102. They're costing us two extra allocations!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you saying that it will implicitly call the constructor to turn the c-string into a persistent string when we pass the parameter? If so, isn't that the same amount of allocations as it is passed by reference into intern_ns and intern_var?

@jeaye jeaye merged commit 74c8487 into jank-lang:main Apr 13, 2025
7 checks passed
@jeaye
Copy link
Member

jeaye commented Apr 13, 2025

Nice work, Monty!

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.

2 participants