Skip to content

Grouping symbols for closures and code, and closure projection substitution#164

Merged
mshinwell merged 5 commits intooxcaml:mainfrom
Keryan-dev:symbol-grouping
Mar 4, 2022
Merged

Grouping symbols for closures and code, and closure projection substitution#164
mshinwell merged 5 commits intooxcaml:mainfrom
Keryan-dev:symbol-grouping

Conversation

@Keryan-dev
Copy link
Copy Markdown
Contributor

Original PR: ocaml-flambda/ocaml#541, needs #162.

@Keryan-dev
Copy link
Copy Markdown
Contributor Author

Keryan-dev commented Nov 8, 2021

Sorry for the request, I just rebased preventively on top of my other PRs.

@Gbury
Copy link
Copy Markdown
Contributor

Gbury commented Jan 5, 2022

Is this still a draft @Keryan-dev, or is it ready for review ?

@lthls lthls force-pushed the symbol-grouping branch from 49600a4 to c206c55 Compare March 2, 2022 15:25
@Keryan-dev Keryan-dev marked this pull request as ready for review March 2, 2022 15:58
Copy link
Copy Markdown
Contributor

@lthls lthls left a comment

Choose a reason for hiding this comment

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

I'm fine with the code, though I have made a few remarks, mostly on naming.

The strongly connected components part is a bit ugly, but factorising the code with the one in Lifted_constant_state turned out to be tricky, so we're going to work on it in a separate PR.

let code =
try Code_id.Map.find code_id all_code
(fun (bound_symbols, static_consts) group_id ->
let bound_symbol, static_const =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Despite the singular used in bound_symbol, this is a Bound_symbol.Pattern.t which can include several symbols (if binding a set of closures). So despite the fact that currently we don't generate static sets of closures with more than one closure in Closure_conversion, I'd prefer if we used a different name like bound_pattern.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It can actually bind several symbols if you write some dumb code like

let rec f x = x + 1
and g y = y -1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought when looking at the code that it would generate two distinct Bound_symbols.Pattern.t, one for each function. Did I miss something ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The code never dissociates Lletrec containing several functions. It is lifted as it is as long as there is no closure variables.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, indeed. It tracks the approximations and substitutions for individual symbols, but it does lift a single set of closures.
We could actually split the set of closures into individual closures (and it might be actually helpful), but we can reconsider this later.

@lthls
Copy link
Copy Markdown
Contributor

lthls commented Mar 4, 2022

@mshinwell This PR is done, and can be merged.

@mshinwell mshinwell merged commit 0d6b831 into oxcaml:main Mar 4, 2022
mshinwell pushed a commit that referenced this pull request May 20, 2022
…tution (#164)

* lifting of statically closed functions in Lambda_to_flambda

* Ordering all code and closures symbols

* Closure projection substitution in lifted code

* Restrict lifting to classic mode

* Renaming and cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flambda2 classic mode flambda2 Prerequisite for, or part of, flambda2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants