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

Constify C constructors and flags tables #12223

Merged
merged 1 commit into from
May 8, 2023

Conversation

MisterDA
Copy link
Contributor

@MisterDA MisterDA commented May 5, 2023

There's little value to this considering the constructors tables are static, used very locally, but this serves nonetheless as an indication to the programmer that the tables are not to be modified.

Copy link
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

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

Nice touch. Now these tables will go in the readonly segment, where they belong.

@xavierleroy
Copy link
Contributor

Can you add a Changes entry? Then I'll merge.

@avsm
Copy link
Member

avsm commented May 8, 2023

There's also another opportunity for the same treatment for static int posix_signals[] in runtime/sys.c, in case you want to constify that too.

@MisterDA
Copy link
Contributor Author

MisterDA commented May 8, 2023

Done and done!
While grepping, I've also found this:

output_string outchan "static int caml_code[] = {\n";

maybe the generated caml_code could be made const too, if it's not self-modifying, or no changes are made to the array?

@xavierleroy
Copy link
Contributor

maybe the generated caml_code could be made const too, if it's not self-modifying, or no changes are made to the array?

If memory serves, the bytecode can be modified before execution to replace opcodes by code pointers into the interpreter (the so-called indirect threaded code technique).

@xavierleroy xavierleroy merged commit d7ced7e into ocaml:trunk May 8, 2023
9 checks passed
@MisterDA MisterDA deleted the const-cst-flags-tables branch May 8, 2023 17:48
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

4 participants