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

Multiple GC roots per compilation unit #262

Closed
wants to merge 3 commits into from

Conversation

mshinwell
Copy link
Contributor

This patch is a subset of #178.
At present, there is a single GC root per compilation unit (corresponding to the toplevel module block), and the [caml_globals] array lists all such roots.
This patch permits there to be more than one root per compilation unit by turning the members of [caml_globals] themselves into lists.

The motivation without flambda is to be able to statically allocate mutable values.

With flambda, this patch is essential. Flambda does not use the existing "native code" compilation strategy for modules as it is not well-suited for optimization (scattered side effects, "global" table of globals, etc). Instead, the bytecode compilation strategy is used, and values required to be assigned symbols (for example, fields of a toplevel module, to avoid them appearing in closures) are lifted out. In the case where such values are non-constant they are handled by pre-allocating a one-field block (assigned to a symbol) using an "initialize symbol" construction; the block is filled in after evaluation of the (potentially side-effecting) defining expression. Such blocks must be registered with the GC; hence the need for this patch. (For those who are wondering, this method of compilation also circumvents the previously-seen problem of excessive register pressure if the bytecode strategy is applied to large modules.)

@damiendoligez
Copy link
Member

I've reviewed the patch. OK for merging.

@mshinwell
Copy link
Contributor Author

Thanks for the review. Merged to trunk (r16538).

@mshinwell mshinwell closed this Oct 23, 2015
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Feb 20, 2020
chambart pushed a commit to chambart/ocaml-1 that referenced this pull request Oct 5, 2021
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