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

Improve and use unreachable #630

Merged
merged 5 commits into from
Jun 29, 2023
Merged

Conversation

privat
Copy link
Contributor

@privat privat commented Jun 27, 2023

unreachable is a hint to the developer and the compiler that the code is not reachable.

A VMClass>>unreachable method exists but 1. was not used that much, 2. was not a noop on production.
Lot of places used a comment "NOTREACHED" to indicate the same thing, but such comments are not checked at runtime in debug mode and they do not provide opportunities for optimizations.

So the PR improve unreachable and use it instead of "NOTREACHED" comments.

The only one that remain is in RegisterAllocatingCogit >> genJumpIf:to: and is inside a statement list, and that's weird.

A future improvement will be to pass the information to the C compiler (e.g. __builtin_unreachable in GCC, or unreachable in C23). But I'm still not sure about the best portable way to do that.

@guillep
Copy link
Member

guillep commented Jun 29, 2023

I like it!!!

CI was green on mac and windows, there was an issue in linux but not related.

Copy link
Member

@guillep guillep left a comment

Choose a reason for hiding this comment

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

Thanks! Why did you choose to use an assertion instead of an error?

@guillep guillep merged commit 60cb494 into pharo-project:pharo-12 Jun 29, 2023
@privat
Copy link
Contributor Author

privat commented Jun 29, 2023

Thanks! Why did you choose to use an assertion instead of an error?

error generate code in release mode, assertion generate nothing so the C compiler can have better optimization (unlikely to be noticeable but I might be pessimistic)

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