Use Compilation_unit.t instead of Ident.t for globals#1
Closed
lukemaurer wants to merge 2 commits intosimpler-symbolsfrom
Closed
Use Compilation_unit.t instead of Ident.t for globals#1lukemaurer wants to merge 2 commits intosimpler-symbolsfrom
Compilation_unit.t instead of Ident.t for globals#1lukemaurer wants to merge 2 commits intosimpler-symbolsfrom
Conversation
Instead of a `getglobal` primitive taking an `Ident.t`, Lambda now has a `getglobal` taking a `Compilation_unit.t` and a separate `getpredef` taking a predef `Ident.t`. (It would be sensible to define a new type `Predef.t` or something.) In order to generate the full `Compilation_unit.t` when producing Lambda, we need to know the pack prefix of each global used in the source file. In particular, it means we need the pack prefix in the `.cmi` format. This suffices even with `-no-alias-deps` (that is, when we might be missing the relevant `.cmi`), since a module that's merely aliased never produces a `getglobal` operation. In return, packing no longer requires fiddling with the `Ident.t`s in the code of the component modules - they are created correctly to begin with. These changes don't reach much into the bytecode compiler or the middle ends: the `Compilation_unit.t` gets translated into an `Ident.t` or `Symbol.t`, respectively, on the way in. Many fiddly details at the driver level are affected, however, since we've been treating `modname` and `Ident.t` as interchangeable. Finally, I've removed the `Misc.modname` type (which was simply an alias to `string`) in favor of `Compilation_unit.t` or `Compilation_unit.Name.t`, as applicable. (Indeed, making the difference explicit is a significant improvement.)
Compilation_unit.t instead of Ident.t for globals
lukemaurer
commented
Sep 23, 2022
| (* Descriptor for compilation units *) | ||
|
|
||
| type compilation_unit_descr = | ||
| { cu_name: Compilation_unit.Name.t; (* Name of compilation unit *) |
Owner
Author
There was a problem hiding this comment.
This should be cu_unit (and some variables of type compilation_unit_descr should probably be renamed from unit to unit_descr to avoid saying unit.unit; that indignity was why I didn't make this change earlier)
lukemaurer
pushed a commit
that referenced
this pull request
May 9, 2023
* Fix ghost locations in modular extension AST nodes * Add missing ghostification Thank you, Carl! * Comment update about ghostiness (+ word-wrapping) * Add ghostify function (#1) * Add `Location.ghostify` * Update the parser's `make_ghost` to save an allocation in some cases * Promote parser.ml * Mark the inner mutable arrays for iarrays as ghost * Add comment about ghostification for comprehensions * Explain that ppxlib is where the ghostiness requirement is enforced * Use `Ast_helper.default_loc` to default the generated locations * Restore propagating the location, now via `Ast_helper.default_loc` * Drop obsolete comment * Rewrite advisory comment about locations
lukemaurer
pushed a commit
that referenced
this pull request
Feb 20, 2024
* new solver * better printing * remove solver_mono from mode_intf * document solver_polarized * address some comments * address more comments * rename "constrain" to "zap" * rename constrain_legacy * make depend * make fmt * remove _intf.ml * use comonadic in env * Add Allow_Disallow, restricting types of Obj.magic * Fix type errors discovered in previous commit * Use Allow_disallow in more places * show soundness of allow_disallow * Prevent chance of forgetting the "sound" version * minor changes * Remove the Solver_polarized.morph type (#1) * adjust comments * remove address_of * more comments * make [log] non-optional * better comments * More fixes * bind temp results * add C.eq_morph * set_append_changes * compare Value with Alloc * more comments * warn about infinite lattices * Small simplification to set_obj * example of variable cycle * say "uniqueness_op" because monotonicity * rename set to lift * exhaustive match * inline unusual helper functions * fix rebase issues * Small simplification * some renaming and comments * more comment * remove un-needed assertions. * fix chamelon * make fmt * add file header comments * exhausive match * use ref for morph counting * Reorder in maybe_compose * switch from lift to map * avoid caml_curry * dedup in join and meet * better error message * fix tests * comments * inlining newvar_above/blow, and more uncurrying * remove ?logging * make sure arity is correct and avoid closure allocation * remove morphism counting * force inline to avoid caml_applyX * address comments * rename and phy eq in eq_morphvar * Small improvement to [eq_morphvar] * better comments about lattices * don't hint to use exclave when useless * fix type_argument * comments about inner_alloc_mode * magic for eq_obj and eq_morph * allow/disallow for Value.List * Add comment about actual vs expected * comment mode_argument * eq_morph doesn't take dst * Magic_equal * better comment about adjunction * abstraction in ctype * comment close_over and partial_apply * fix eta expansion bug * Alloc.Const.t is record, not tuple * Simplify interface to [close_over] * Generalize the type of close_over * fixed definition of partial adjoint * better comment about partial adjoint * even better comments * make fmt * bootstrap --------- Co-authored-by: Richard Eisenberg <reisenberg@janestreet.com> Co-authored-by: Richard Eisenberg <rae@richarde.dev>
lukemaurer
pushed a commit
that referenced
this pull request
Oct 23, 2024
…sms (oxcaml#1760) * new solver * better printing * remove solver_mono from mode_intf * document solver_polarized * address some comments * address more comments * rename "constrain" to "zap" * rename constrain_legacy * make depend * make fmt * remove _intf.ml * use comonadic in env * Add Allow_Disallow, restricting types of Obj.magic * Fix type errors discovered in previous commit * Use Allow_disallow in more places * show soundness of allow_disallow * Prevent chance of forgetting the "sound" version * minor changes * Remove the Solver_polarized.morph type (#1) * adjust comments * remove address_of * more comments * make [log] non-optional * better comments * More fixes * bind temp results * add C.eq_morph * set_append_changes * compare Value with Alloc * more comments * warn about infinite lattices * Small simplification to set_obj * example of variable cycle * say "uniqueness_op" because monotonicity * rename set to lift * exhaustive match * inline unusual helper functions * fix rebase issues * Small simplification * some renaming and comments * more comment * remove un-needed assertions. * fix chamelon * make fmt * add file header comments * exhausive match * use ref for morph counting * Reorder in maybe_compose * switch from lift to map * avoid caml_curry * dedup in join and meet * better error message * fix tests * comments * inlining newvar_above/blow, and more uncurrying * remove ?logging * make sure arity is correct and avoid closure allocation * remove morphism counting * force inline to avoid caml_applyX * address comments * rename and phy eq in eq_morphvar * Small improvement to [eq_morphvar] * better comments about lattices * don't hint to use exclave when useless * fix type_argument * comments about inner_alloc_mode * magic for eq_obj and eq_morph * allow/disallow for Value.List * Add comment about actual vs expected * comment mode_argument * eq_morph doesn't take dst * Magic_equal * better comment about adjunction * abstraction in ctype * comment close_over and partial_apply * fix eta expansion bug * Alloc.Const.t is record, not tuple * Simplify interface to [close_over] * Generalize the type of close_over * fixed definition of partial adjoint * better comment about partial adjoint * even better comments * make fmt * bootstrap --------- Co-authored-by: Richard Eisenberg <reisenberg@janestreet.com> Co-authored-by: Richard Eisenberg <rae@richarde.dev>
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.
Instead of a
getglobalprimitive taking anIdent.t, Lambda now has agetglobaltaking aCompilation_unit.tand aseparate
getpredeftaking a predefIdent.t. (It would be sensible to define a new typePredef.tor something.)In order to generate the full
Compilation_unit.twhen producing Lambda, we need to know the pack prefix of each global used in the source file. In particular, it means we need the pack prefix in the.cmiformat. This suffices even with-no-alias-deps(that is, when we might be missing the relevant.cmi), since a module that's merely aliased never produces agetglobaloperation.In return, packing no longer requires fiddling with the
Ident.ts in the code of the component modules - they are created correctly to begin with.These changes don't reach much into the bytecode compiler or the middle ends: the
Compilation_unit.tgets translated into anIdent.torSymbol.t, respectively, on the way in. Many fiddly details at the driver level are affected, however, since we've been treatingmodnameandIdent.tas interchangeable.Finally, I've removed the
Misc.modnametype (which was simply an alias tostring) in favor ofCompilation_unit.torCompilation_unit.Name.t, as applicable. (Indeed, making the difference explicit is a significant improvement.)