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

Initial commit for negative array size check #871

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Ihromant
Copy link
Contributor

@Ihromant Ihromant commented Dec 2, 2023

Hi @konsoletyper

Here is initial implementation for negative array size check. I investigated code and assumed the place where instructions should be modified. I can see that in BoundCheckInsertion class has code that intercepts ConstructArrayInstruction in checks and then if check is correct then restores flow of the program, else throws corresponding exceptions. Still, I faced problems to solve which I added TODO comments with questions.
Also for me it's unclear how to add size check in C code. I added method and definitions as in nullCheck, but I don't understand where this method should be called.

Would be appreciated if you help and/or point me to places using which I will be able to finish this PR ( #868 depends on this feature).

Thanks in advance.

@konsoletyper
Copy link
Owner

I don't think array size check should be performed by instruction transformation. Array access is guarded by a separate instruction that can be implemented efficiently by a particular backend. Introduction of basic blocks is too heavyweight and difficult in all possible aspects. However, a new instruction should be introduced with care and with clear understanding why it's done and how it will participate in all possible flows. In case of array construction, which is itself much more heavyweight, than array access, and which occurs much more rarely, introduction of new instructions or IR transformations don't worth it. I think corresponding check can be performed just within actual methods that construct array.

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.

None yet

2 participants