Replace startup code block with loop to call all entry stubs.#13217
Open
tmcgilchrist wants to merge 1 commit intoocaml:trunkfrom
Open
Replace startup code block with loop to call all entry stubs.#13217tmcgilchrist wants to merge 1 commit intoocaml:trunkfrom
tmcgilchrist wants to merge 1 commit intoocaml:trunkfrom
Conversation
694053a to
11d20eb
Compare
Contributor
|
Thanks a lot for the nice PR description!
Out of curiosity: did you check that the change also works when frame
pointers are enabled?
|
Contributor
Author
|
Good idea @shindere I have not as yet, but I will do so. |
Contributor
|
Tim McGilchrist (2024/06/05 00:18 -0700):
Good idea @shindere I have not as yet, but I will do so.
Thanks! I'll wait for you to post here to proceed, although I am likely
not the most well suited to review this.
|
13f36fb to
4b94477
Compare
4b94477 to
0fee7f0
Compare
Contributor
Author
|
@shindere testing with frame-pointers on macOS and Linux is passing. |
Contributor
|
Tim McGilchrist (2024/06/18 08:08 -0700):
@shindere testing with frame-pointers on macOS and Linux is passing.
Okay, thanks!
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a small improvement to rewrite the entry_point code generated by
cmm_helpers.mlto be data driven.When starting a native OCaml program the call stack goes through C functions (caml_main, caml_startup_common and caml_startup_common, in
startup_nat.cbefore jumping to the processor specific assembly inruntime/arm64.s(or whatever architecture you have) starting atcaml_start_program. Before it jumps tocaml_programwhich calls the module.entrypoint for the modules included in an executable. At this point currently OCaml generates a block of assembly code for each module entry point that needs to be called, 35 for a minimal program that just relies on the Stdlib (potentially more?). This change re-writes this code to be a loop equivalent to this C code:{ int id = 0; while (true) { if (id == len_caml_globals_entry_functions) goto out; caml_globals_entry_functions[id](); caml_globals_inited += 1; id += 1; } out: return 1; }What is gained by making this change? More compact assembly code that is data driven using a loop and lookup table of symbols. Possibly faster startup but I have no data to back this up. The work was done original in PR oxcaml/oxcaml#1425 by @poechsel, I have only cherry picked it here after noticing the repeated assembly code blocks.
@poechsel please correct any attribution as you see fit.