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

mirpasses: implement string COW handling with MIR pass #1287

Merged
merged 2 commits into from
Apr 27, 2024

Conversation

zerbina
Copy link
Collaborator

@zerbina zerbina commented Apr 27, 2024

Summary

Perform the injection of runtime procedure calls for handling copy-on-
write strings with an MIR pass, instead of doing it in the C code
generator, removing another responsibility from the latter.

Details

The new MIR pass does the equivalent of what cgen previously did,
that is, injecting nimPrepareStrMutationV2 calls wherever a string's
underlying storage might be modified.

The injection logic, together with the lfPrepareForMutation flag, is
removed from cgen.

@zerbina zerbina added refactor Implementation refactor compiler/backend Related to backend system of the compiler labels Apr 27, 2024
@zerbina zerbina added this to the C backend rework milestone Apr 27, 2024
Use a MIR pass to inject the calls to `nimPrepareStrMutationV2`. Same
as what `cgen` did, the pass looks for all possible modification of a
string's storage and emits a string preparation prior to the
modification.
The added MIR pass fully takes care of it, no code generator support is
needed.
@saem
Copy link
Collaborator

saem commented Apr 27, 2024

/merge

Copy link

Merge requested by: @saem

Contents after the first section break of the PR description has been removed and preserved below:


Notes for Reviewers

  • a preparation for lowering string operations with MIR passes

@chore-runner chore-runner bot added this pull request to the merge queue Apr 27, 2024
Merged via the queue into nim-works:devel with commit 05e3db8 Apr 27, 2024
31 checks passed
@zerbina zerbina deleted the cgen-cow-strings-via-mir-pass branch April 28, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/backend Related to backend system of the compiler refactor Implementation refactor
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants