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

Load frametables of dynlink'd modules in batch #11935

Merged
merged 6 commits into from Jan 27, 2023

Conversation

stedolan
Copy link
Contributor

Each Dynlinked cmxs file may contain many modules, all with their own frametables. Currently, each module is registered and initialised one at a time, rebuilding the frame table each time. This patch changes it to register all of the frame tables in bulk, and then initialise all of the modules.

I also added some more error checking - currently, Dynlink silently ignores missing frametables, which seems bad. It turns out that the gc_roots symbol was always missing for shared_startup blocks (where it's not necessary), so I changed asmlink to unconditionally include an empty gc_roots block in this case, as that seems cleaner than having this special case.

Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

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

LGTM, modulo a possible code comment and a make promote is needed in the testsuite

@@ -235,7 +235,9 @@ let make_startup_file ~ppf_dump units_list ~crc_interfaces =
List.flatten (List.map (fun (info,_,_) -> info.ui_defines) units_list) in
compile_phrase (Cmm_helpers.entry_point name_list);
let units = List.map (fun (info,_,_) -> info) units_list in
List.iter compile_phrase (Cmm_helpers.generic_functions false units);
List.iter compile_phrase
(Cmm_helpers.emit_preallocated_blocks []
Copy link
Member

Choose a reason for hiding this comment

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

Although the testsuite will guard against this actually regressing, I think it's worth adding a comment as to why the call to emit_preallocated_blocks is made?

Copy link
Contributor

@gadmm gadmm left a comment

Choose a reason for hiding this comment

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

This looks good to me. (I cannot comment on the changes to asmlink.ml though, which look unrelated.)

@stedolan
Copy link
Contributor Author

The changes to asmlink are the bit that ensures all modules have a (possibly empty) gc_roots section, instead of having a special case for startup files.

@gadmm
Copy link
Contributor

gadmm commented Jan 26, 2023

I was unclear with my comment. Only for this bit I did not look deeper on the change because I am less familiar with this part of the compiler, but this still looks good to me, thanks to your helpful explanation in the PR description.

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

3 participants