Skip to content

Commit 4a65595

Browse files
anmonteirosamsa1OctachronshindereMisterDA
authored
Support OCaml 5.4 (#73)
* BOOTSTRAP * Changed interface of compare_package to take packages as argument * Factor subtype_package out of subtype_rec * Changed interface of package_subtype to take packages as arguments * Factor unify_package out of unify3 * Factor moregen_package out of moregen * Factor eqtype_package out of eqtype * Changed interface of type_package to take a package as argument and return a package * Small improvement of presentation * Changed interface of modtype_of_package to take a package as argument * Introduce a new record for package types in outcometree * Changes * Renamed pack_fields to pack_cstrs in package_type for coherence * Renamed fileds of Typedtree.package_type for less ambiguity with Types.package * Refactor complete_type_list to take a package as argument * #13702 error messages: specialized error messages for non-functors (#13865) This commit adds a specialized error message for functor appearing in a context where non-functors were expected (and reciprocally) rather than using the generic error message for mismatched functor parameters. * Add reviewers to Changes entry for #13407 * gitignore: ignore macOS executable debug symbols directory When an executable is linked using the -g flag, a directory for debug symbols is created under macOS. It's only appearing for sak, and creates noise with git status. Ignore it. * Add a test showing unexpected approximated shapes when indexing modules in constructor paths. * Use `Pextra_ty` for specific shape paths and correctly index modules in these. This makes the handling of the custom cases when resolving shape paths less ad-hoc and fixes shape resolution for modules in constructor and labels paths. Suggested-by: Florian Angeletti <[email protected]> Refactor and add apply case Introduce a [scrape_extra_ty] function * Add changelog entry Changes: add reviewer * Fix C _Atomic in header incompatibility with C++ _Atomic is standard C11 but is not standard C++ (although sometimes available as a compiler extension). Use atomic_uintnat from our camlatomic.h. In file included from all-includes.h:6: /Users/antonin/Tarides/ocaml/trunk/runtime/caml/custom.h:54:12: error: '_Atomic' does not name a type; did you mean 'Atom'? 54 | CAMLextern _Atomic uintnat caml_custom_major_ratio; | ^~~~~~~ | Atom * Correct regression with `unused-type-declaration` warning * Merge pull request #13829 from clementblaudeau/recsig-substitution-cyclic-check Fix missing check of illegal recursive module when using module type substitutions * Remove quotes around \var{...} in intfc manual The quotes prevent the `\var` operator from being applied, resulting in "\var{...}" literally being displayed on the page. Signed-off-by: Stephen Sherratt <[email protected]> * Fix documentation of Array.compare regarding the ordering. (#13908) * Enforce evaluation order for generic applications in Closure (#13882) * Mark tests that actually require multicore (#13906) Some tests fail or hang on mono-core systems. In this commit, we introduce the "multicore" predicate in ocamltest, and mark the affected tests. Bug-Debian: https://bugs.debian.org/1101353 * Fix definition of Fibonacci numbers in the manual (#13912) * Apply BUILD_PATH_PREFIX_MAP to Sys.argv.(0) in cmt Cmt_format.cmt_infos.cmt_args includes a copy of Sys.argv from the compiler invocation. The user is in control of the arguments passed to a binary (Sys.argv.(1) and above) and can avoid embedding absolute paths, but Sys.argv.(0) on some platforms is converted to an absolute path, regardless of how the executable was invoked. * GHA: remove PRISTINE_PATH Should be unnecessary * GHA: bash is part of Cygwin base * GHA: tell Cygwin's bash to ignore CR line endings As suggested by the cygwin-install action. Makes much nicer looking shell scripts! https://github.com/cygwin/cygwin-install-action?tab=readme-ov-file#line-endings * GHA: revisit limits on concurrent Make jobs - When using MinGW-w64 on Linux, Make may spawn too many processes, triggering the OOM-killer, and ending the build. - Running `make test` with `-j` has no effect, the test runner is already built and is responsible of running tests in parallel. * GHA: store the Autoconf cache key in the step output Avoid using Cygwin when computing the cache key. * GHA: don't set CC as an env variable Makes a cleaner ./configure invocation. * GHA: refactor configure calls in runner.sh * GHA: typo * GHA: split configuration and build Matches the other workflows. * GHA: use a fold for config.log in GHA If configure fails, it is useful to have config.log, but the error is initially more useful, and that's often harder to spot at the end of config.log * Get rid of the @SInCE attribute for the Uchar.hash function Given that this function is present in the module since it was introduced, the convension is to not have any @SInCE attribute at the function level, since the module-level one applies. This commit reverts the addition of the attribute done in PR #13240, see commit 9585cfe. * Add Result.product and Result.Syntax (#13696) * Repr.equal is not an operator (#13914) Co-authored-by: Hazem ElMasry <[email protected]> * Add examples to the `Fun` module * Reword some paragraphs in `Fun` examples * Reword more paragraphs in `Fun` examples * Add more examples to `Fun.id` and `const` * Remove problematic examples and add descriptions * Expand the Fun.id dispatching description And make the example conform to the description * Add "advanced"/"real-world" examples These are instead of the problematic examples * Make function refs headers * Add `Fun.compose` examples And warn about too many combinators * Deindent and improve formatting * Reword some descriptions * Remove problematic `flip` examples * Replace a `compose` example with more involved one * Typos in the Uchar example * Some rewording * Replace the windows path conversion example * Add a Scanf example to id * Add example to const, remove example from compose * Indent code blocks, reorder, reformat, reword * Remove scanf and floatarray examples from id * Prevent overlong lines in code examples * Add a Changes entry * Enrich ocamltest doc about scripts (#13902) * manual: alerts: add sections, in preparation for following commits * manual: alerts: annotate code section as ocaml code For presumably marginally nicer display. * manual: alerts: document how to put alerts on all structure/signature items Personally, I had no idea it was possible to put an alert on a let binding until I saw it mentioned on a github issue, because it's undocumented. Ideally, warning 53 would teach users that write: let x = 1 [@@deprecated] to write: let x [@deprecated] = 1 instead, but I'm only changing doc here. And arguably, the first form could be interpreted as the second form, when the pattern contains a single variable (and fail otherwise), as that's how alerts works for all other binding constructs. * Makefile.dev: work around #13817 (#13818) * [refactor] runtime: auxiliary function for allocated_words update * runtime: "suspended" and "resumed" allocations affect the major GC speed This is a buildup commit, currently there is no control in the GC to suspend or resume specific allocations, so these counters are always 0. The intuition is to "suspend" allocations during ramp-up phases, and "resume" allocations during ramp-down. * runtime: simplistic support for [ramp_up], [ramp_down] During [ramp_up], the deallocation work coming from allocations is "suspended". It can be "resumed" by calling [ramp_down]. [ramp_up] does not currently count the total number of suspended allocations (this needs more domain state that is not reset on each major state), so the user would not know which value to provided to [ramp_down]. This will be added next. * runtime: count the work suspended by each ramp-up phase * runtime: support nested ramp-up phases * expose ramp_up, ramp_down as externals in stdlib/Gc * Changes entry * runtime: log ramp-up / ramp-down in SLICESIZE GC logs * Gc.ramp_up: re-raise exceptions, but ramp-down right before Suggested-by: Guillaume Munch-Maccagnoni <[email protected]> * [minor] stray fix in runtime/array.c * runtime/array.c: expose {uniform_,float}array_concat, use it in Float.Array * Rename ccomptype to ccomp_type for consistency (#13927) * Add Result.{get_ok',error_to_failure} (#13720) * Add Result.get_ok'. * Result.error_to_failure * Update changes. * Add List.singleton and Seq.singleton Set.S already has singleton, and dual of {Bytes,String,Array}.make 1 and Option.some * Fix @SInCE 5.0 annotation loss in domain.mli and effect.mli by swapping alert and header (#13934) * mystery reviewer for 13643 * Added tests for abstraction of whole module types during avoidance * Removed abstraction of whole module types when avoiding a field * Not backward compatible: code could use this behavior to create signatures with abstract module type fields, and place them in negative positions with [module type of], but it is highly unlikely intentional. There is no loss of expressivity: the desired resulting signature can still be obtained with an explicit signature constraint. * Added Change entry * Fix test weak-ephe-final/ephe_custom.ml (#13940) * [refactoring] move Matching.get_mod_field to Lambda.transl_mod_field * [refactoring] Lambda.transl_mod_field, move 'lazy' to clients * [refactor] Lambda: merge transl_mod_field and transl_prim * update .depend * Fix #13939 * Typeopt: better handling of deeply nested unboxed types * Add test * Changes * runtime: migrate caml_{alloc,update}_dummy from alloc.c to obj.c * caml_update_dummy: the [Infix_tag] case is dead code We stopped using dummies for values at a function type in OCaml 5.2, and the matching [caml_alloc_dummy_infix] function was removed in cd48dc0. * [minor] value_rec_compiler: refactor alloc/update calls * recursive values: introduce [caml_update_dummy_lazy] * regression test for lazy shortcutting in recursive values * Changes * lazy + letrec: insert indirections on lazy update to avoid concurrency issues * use a dedicated [caml_alloc_dummy] primitive Suggested-by: Vincent Laviron <[email protected]> * Improved changelog message * document [caml_domain_alone] reasoning * spawn: increment [caml_num_domains_running] earlier to ease reasoning * Changes * Pin Cygwin back to 3.6.1 until AppVeyor updates Avoids broken 3.5.5 version in the runner image. * List.sort_uniq : remove non-first duplicates. (#13862) * Move match_printer_type in order to share it between toplevel and debugger * Move find_printer to Topprinters (to be shared with the degugger) * Move debugger printers fetching logic * Debugger uses Topprinters.find_printer The behavior is purely identical. * release-info: update calendar * Use dune.3.18.0 which is compatible with trunk * Bump qcheck and multicoretests to the latest releases * Changed occur_rec in typing/ctype.ml to traverse type as a graph and not a tree * Changes * Renamed some arguments of occur_rec * Add signal definitions for SIGIO and SIGWINCH. * Add signal_to_string function * Add signal type alias and signal_to_string. * Export signal conversion functions as primitives. * Export signal conversion functions as primitives in Sys * Update documentation in Unix module * Check int and signal argument ranges for conversion functions Signal_to_string and signal_to_int call invalid_arg if presented with an unrecognised negative number. signal_of_int calls invalid_arg for all negative numbers. * Add changelog * Allow 'effect' as attribute id (#13957) * ocamltest: fix typos (cherry picked from commit 62672b75a315e52e39275dce10d87f22df73e254) * Teach ocamltest about colors As the compiler drivers and various ocaml tools, ocamltest now accepts the -color flag, and recognizes the OCAML_COLOR and NO_COLOR environment variables. It uses them to pass a corresponding --color flag to diff, if it was detected during configure that diff supports this flag. * GHA: update to macOS 15 and Xcode 16.3 * tests: native-debugger: build C test code without optimizations Fixes warnings and spurious failures in the CI. * tests: native-debugger: sanitize library path Debian and Fedora derivatives have different libpaths: -Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1". +Using host libthread_db library "/lib64/libthread_db.so.1". fixup_libthread * tests: native-debugger: fix GDB version parsing * tests: native-debugger: disable disabling ASLR This allows running the tests more easily in Docker images. The sanitization step takes care of removing artifacts of randomization anyway. * tests: native-debugger: sanitize trailing blanks * tests: native-debugger: simplify shell scripts Don't redeclare variables that ocamltest always provides in scripts. * Apply suggestions from review * Check separately in configure if DIFF supports --color * Fix hygiene check for generating `configure` (#13935) * Allow check-configure.sh to be run locally * Re-bash the autoconf test * Simplify - and correct - check-configure.sh The script contained an unused feature to be able to check PRs as one - this is never wanted, as we should always be checking that every commit has a valid committed configure script. The mechanism for checking whether commits should be tested is shifted back to the actual trawl of the log. This is both simpler (because it can be done with a simple file list) but also fixes a bug, since commits which _didn't_ update configure could reset a failure from an earlier commit. * Wrong parameter checked in check-configure.sh * Review * Added printing of presence flag in typedtree (#13963) * fix .depend * [minor] value_rec_compiler: move primitive declarations earlier * fix #13931 * Add profiling with perf chapter OCaml manual This covers the use of Linux perf to profile OCaml native code including the overlap with frame pointers and DWARF CFI information * Collapse profiling into a single chapter. * add an invariant function to check that loc_ghost is set correctly spoiler alert: it isn't * parser: partially align use of loc_ghost with what the documentation says Mostly in: - the productions for keyword%extension syntaxes - the implied 'self in `object ('self) end` * parser: refactor previous commit, by removing error prone functions * parser: regenerate parser.ml * Add test of princiaplity from polymorphic type constraints * Keep generalized structure from patterns when typing let * Add changelog entry * Renamed the flag `transparent_modules` into `no_alias_deps` * Update driver/makedepend.ml Co-authored-by: Kate <[email protected]> * Updated Changelog with pr number * Update changes * ocamlopt: pass -fPIC when compiling C files * Changes * Changes * Uniformize definition of native_cflags, bytecode_cflags * Changes * last commit before branching 5.4 * first commit on branch 5.4 * Merge pull request #13950 from OlivierNicole/bugfix-array-sub Avoid tearing in Array.sub (cherry picked from commit 331b5e64a174f47da6b37fa47bf23acdf1625399) * Merge pull request #13921 from dra27/more-cloexec Preserve `O_CLOEXEC` when converting `Unix.file_descr` to a CRT fd on Windows (cherry picked from commit 23852ccb806fbe72d8fe847ddff7a8c2add4421d) * Bump magic numbers for 5.4 * Fix memory corruption when an exception is raised during demarshaling. (#14015) (cherry picked from commit e6321cf1e3f3bfb0795108ab4d6c66c559ea9b63) * Merge pull request #13909 from OlivierNicole/dynarray-unsafe-to-iarray Add Dynarray.unsafe_to_iarray (cherry picked from commit aa7e2856ecb2f002e1fabd468638df12046a7be6) * [minor] printcmm: print atomic loads * [testsuite] test the compilation of atomic functions * [refactor] Define [caml_atomic_cas] in terms of [caml_atomic_cas_field]. * [breaking] Change the prototype of [caml_atomic_cas_field]. This is a breaking change because this function was (unfortunately) exposed outside CAML_INTERNALS, and is used by exactly one external user, you guessed it: https://github.com/ocaml-multicore/multicore-magic/blob/360c2e829c9addeca9ccaee1c71f4ad36bb14a79/src/Multicore_magic.mli#L181-L185 https://github.com/ocaml-multicore/multicore-magic/blob/360c2e829c9addeca9ccaee1c71f4ad36bb14a79/src/unboxed5/multicore_magic_atomic_array.ml#L36-L43 We chose to change the prototype to remain consistent with the naming convention for the new caml_atomic_*_field primitives, which will be added to support atomic record fields. User code can easily adapt to this new prototype we are using, but not in a way that is compatible with both old and new versions of OCaml (not without some preprocessing at least). Another option would be to expose int caml_atomic_cas_field(value obj, intnat fld, value, value) value caml_atomic_cas_field_boxed(value obj, value vfld, value, value) but no other group of primitives in the runtime uses this _boxed terminology, they instead use int caml_atomic_cas_field_unboxed(value obj, intnat fld, value, value) value caml_atomic_cas_field(value obj, value vfld, value, value) and this would again break compatiblity -- it is not easier to convert code to that two-version proposal, and not noticeably more efficient. So in this case we decided to break compatibility (of an obscure, experimental, undocumented but exposed feature) in favor of consistency and simplificity of the result. * runtime: Add atomic primitives [caml_atomic_load_field], [caml_atomic_exchange_field] and [caml_atomic_fetch_add_field]. * lambda: Add support for new atomic primitives. Uses of existing atomic primitives %atomic_foo, which act on single-field references, are now translated into %atomic_foo_field, which act on a pointer and an offset -- passed as separate arguments. In particular, note that the arity of the internal Lambda primitive Patomic_load increases by one with this patchset. (Initially we renamed it into Patomic_load_field but this creates a lot of churn for no clear benefits.) We also support primitives of the form %atomic_foo_loc, which expects a pair of a pointer and an offset (as a single argument), as we proposed in the RFC on atomic fields ocaml/RFCs#39 (but there is no language-level support for atomic record fields yet) Co-authored-by: Clément Allain <[email protected]> * Add support for atomic record fields. Requires a bootstrap. Co-authored-by: Gabriel Scherer <[email protected]> * atomic fields in ocamldoc * Bootstrap. To reproduce (see BOOTSTRAP.adoc for details): - go to the earlier commit "lambda: Add support for new atomic primitives" as a known-good state, build that one - keep the build artifacts around, come here and do `make bootstrap` * Add tests for atomic record fields. * [minor] Make test_untypeast.ml more readable. * Add predefined type ['a atomic_loc]. This type will be used for ['a Atomic.Loc.t], as proposed in the RFC ocaml/RFCs#39 We implement this here to be able to use it in the stdlib later, after a bootstrap. * [refactor] more general type for Env.mark_*_used We want to use [mark_label_used] in a context where we cannot easily find the label declaration, only the label description (from the environment). * Add extension [%atomic.loc record.field]. * Bootstrap. This bootstrap is not required by a compiler change, but it enables the use of the predefined type `'a atomic_loc` and the expression-former [%atomic.loc ...] in the standard library. * Add module [Stdlib.Atomic.Loc]. * Add tests for [Atomic.Loc]. * Reimplement [Atomic.t] using [Atomic.Loc.t]. * Forbid atomic fields in patterns. * Changes * testsuite for pattern-matching on atomic reads * allow wildcard patterns under atomic record fields Suggested-by: Olivier Nicole <[email protected]> * stdlib/Atomic: move the Loc module below in the .mli * stdlib/Atomic: minimal documentation * revert a type_approx change from labeled tuples * Merge pull request #13991 from gasche/atomic_fields_manual describe atomic record fields in the reference manual (cherry picked from commit 0c16a7c8fa15894f486e0240d47a1adf2721fe9b) * fix atomic-locs/cmm.compilers.reference * Merge pull request #13987 from OlivierNicole/fix-tsan-false-alarm Fix #13427 (cherry picked from commit e0154dc23244cc3e57f4489b9cbf27421b20c884) * Merge pull request #14032 from jmid/flexdll-0.44 Update FlexDLL to 0.44 and reenable lib-dynlink-domains test on Windows (cherry picked from commit 6cca9ffc5e1181040717f7f72a1a9468a8ff1ec0) * Merge pull request #13675 from stedolan/memprof-map-file Ensure that all Bigarray memory managed by the GC is tracked by Memprof (cherry picked from commit 820bc29b9fc801f50dbc556fd2dab1d3bb4bfb6a) * manual: move the TeX header of each language extension into the extension-specific .etex file (#14041) (cherry picked from commit 0728f6af2aae32a97c2a7a1214c25736a26a479b) * minor Changes fixes * 5.4 Changes: complete and reorder entries * No need for the stale workflow on branches * Merge pull request #14013 from dra27/more-ci-tweaks GHA: add an optional wider test matrix (Cygwin, static, minimal, etc.) (cherry picked from commit 96b56fd4c822c92b4b81ff4ac7903ae8afb16a52) * Merge pull request #14025 from gasche/orphan-shared-heap-before-STW-exit domain_terminate: orphan the shared heap before STW exit (cherry picked from commit d325f299896417c5f1d477171135acfdf402e770) * last commit before tagging 5.4.0~alpha1 * release 5.4.0~alpha1 * increment version number after tagging 5.4.0~alpha1 --------- Signed-off-by: Stephen Sherratt <[email protected]> Co-authored-by: samsa1 <[email protected]> Co-authored-by: Florian Angeletti <[email protected]> Co-authored-by: Seb Hinderer <[email protected]> Co-authored-by: Antonin Décimo <[email protected]> Co-authored-by: Ulysse Gérard <[email protected]> Co-authored-by: Gabriel Scherer <[email protected]> Co-authored-by: Clément Blaudeau <[email protected]> Co-authored-by: Stephen Sherratt <[email protected]> Co-authored-by: Guillaume Melquiond <[email protected]> Co-authored-by: Vincent Laviron <[email protected]> Co-authored-by: Stéphane Glondu <[email protected]> Co-authored-by: Jean-Christophe Filliatre <[email protected]> Co-authored-by: David Allsopp <[email protected]> Co-authored-by: Daniel Bünzli <[email protected]> Co-authored-by: Haz <[email protected]> Co-authored-by: Hazem ElMasry <[email protected]> Co-authored-by: Olivier Nicole <[email protected]> Co-authored-by: Valentin Gatien-Baron <[email protected]> Co-authored-by: Nicolás Ojeda Bär <[email protected]> Co-authored-by: Hanliang Xu <[email protected]> Co-authored-by: Blaudeau Clément <[email protected]> Co-authored-by: Benoit <[email protected]> Co-authored-by: Pierre Boutillier <[email protected]> Co-authored-by: Jan Midtgaard <[email protected]> Co-authored-by: Tim McGilchrist <[email protected]> Co-authored-by: Pieter Goetschalckx <[email protected]> Co-authored-by: Leo White <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: octachron <[email protected]> Co-authored-by: Benoît Vaugon <[email protected]> Co-authored-by: Clément <[email protected]>
2 parents e914cab + ca76bf8 commit 4a65595

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+5314
-2903
lines changed

dune

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
(dirs wrapper lib parsing utils file_formats lambda typing)
2+
23
(include_subdirs unqualified)
34

45
(library
5-
(name melange_compiler_libs)
6-
(public_name melange-compiler-libs)
7-
(flags -w -9)
8-
(libraries menhirLib melange_wrapper)
9-
(modules :standard \ melange_wrapper)
10-
(modules_without_implementation
11-
annot
12-
value_rec_types))
6+
(name melange_compiler_libs)
7+
(public_name melange-compiler-libs)
8+
(flags -w -9)
9+
(libraries menhirLib melange_wrapper)
10+
(modules :standard \ melange_wrapper)
11+
(modules_without_implementation annot value_rec_types))
1312

14-
(library
15-
(name melange_wrapper)
16-
(public_name melange-compiler-libs.wrapper)
17-
(libraries compiler-libs.common)
18-
(modules melange_wrapper)
19-
(modules_without_implementation melange_wrapper))
13+
(library
14+
(name melange_wrapper)
15+
(public_name melange-compiler-libs.wrapper)
16+
(libraries compiler-libs.common)
17+
(modules melange_wrapper)
18+
(modules_without_implementation melange_wrapper))

file_formats/cmt_format.ml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,21 @@ let iter_on_occurrences
153153
let path_in_type typ name =
154154
match Types.get_desc typ with
155155
| Tconstr (type_path, _, _) ->
156-
Some (Path.Pdot (type_path, name))
156+
Some (Path.Pextra_ty(type_path, Pcstr_ty name))
157157
| _ -> None
158158
in
159159
let add_constructor_description env lid =
160160
function
161-
| { Types.cstr_tag = Cstr_extension {path; _}; _ } ->
161+
| { Data_types.cstr_tag = Cstr_extension {path; _}; _ } ->
162162
f ~namespace:Extension_constructor env path lid
163-
| { Types.cstr_uid = Predef name; _} ->
163+
| { Data_types.cstr_uid = Predef name; _} ->
164164
let id = List.assoc name Predef.builtin_idents in
165165
f ~namespace:Constructor env (Pident id) lid
166-
| { Types.cstr_res; cstr_name; _ } ->
166+
| { Data_types.cstr_res; cstr_name; _ } ->
167167
let path = path_in_type cstr_res cstr_name in
168168
Option.iter (fun path -> f ~namespace:Constructor env path lid) path
169169
in
170-
let add_label env lid { Types.lbl_name; lbl_res; _ } =
170+
let add_label env lid { Data_types.lbl_name; lbl_res; _ } =
171171
let path = path_in_type lbl_res lbl_name in
172172
Option.iter (fun path -> f ~namespace:Label env path lid) path
173173
in
@@ -186,7 +186,8 @@ let iter_on_occurrences
186186
| Texp_construct (lid, constr_desc, _) ->
187187
add_constructor_description exp_env lid constr_desc
188188
| Texp_field (_, lid, label_desc)
189-
| Texp_setfield (_, lid, label_desc, _) ->
189+
| Texp_setfield (_, lid, label_desc, _)
190+
| Texp_atomic_loc (_, lid, label_desc) ->
190191
add_label exp_env lid label_desc
191192
| Texp_new (path, lid, _) ->
192193
f ~namespace:Class exp_env path lid
@@ -235,8 +236,8 @@ let iter_on_occurrences
235236
(match ctyp_desc with
236237
| Ttyp_constr (path, lid, _ctyps) ->
237238
f ~namespace:Type ctyp_env path lid
238-
| Ttyp_package {pack_path; pack_txt} ->
239-
f ~namespace:Module_type ctyp_env pack_path pack_txt
239+
| Ttyp_package {tpt_path; tpt_txt} ->
240+
f ~namespace:Module_type ctyp_env tpt_path tpt_txt
240241
| Ttyp_class (path, lid, _typs) ->
241242
(* Deprecated syntax to extend a polymorphic variant *)
242243
f ~namespace:Type ctyp_env path lid
@@ -367,13 +368,31 @@ let index_occurrences binary_annots =
367368
in
368369
let f ~namespace env path lid =
369370
let not_ghost { Location.loc = { loc_ghost; _ }; _ } = not loc_ghost in
370-
if not_ghost lid then
371+
let reduce_and_store ~namespace lid path = if not_ghost lid then
371372
match Env.shape_of_path ~namespace env path with
372373
| exception Not_found -> ()
373374
| { uid = Some (Predef _); _ } -> ()
374375
| path_shape ->
375376
let result = Shape_reduce.local_reduce_for_uid env path_shape in
376377
index := (lid, result) :: !index
378+
in
379+
(* Shape reduction can be expensive, but the persistent memoization tables
380+
should make these successive reductions fast. *)
381+
let rec index_components namespace lid path =
382+
let module_ = Shape.Sig_component_kind.Module in
383+
let scraped_path = Path.scrape_extra_ty path in
384+
match lid.Location.txt, scraped_path with
385+
| Longident.Ldot (lid', _), Path.Pdot (path', _) ->
386+
reduce_and_store ~namespace lid path;
387+
index_components module_ lid' path'
388+
| Longident.Lapply (lid', lid''), Path.Papply (path', path'') ->
389+
index_components module_ lid'' path'';
390+
index_components module_ lid' path'
391+
| Longident.Lident _, _ ->
392+
reduce_and_store ~namespace lid path;
393+
| _, _ -> ()
394+
in
395+
index_components namespace lid path
377396
in
378397
iter_on_annots (iter_on_occurrences ~f) binary_annots;
379398
!index
@@ -460,12 +479,16 @@ let save_cmt target binary_annots initial_env cmi shape =
460479
let cmt_annots = clear_env binary_annots in
461480
let cmt_uid_to_decl = index_declarations cmt_annots in
462481
let source_digest = Option.map Digest.file sourcefile in
482+
let cmt_args =
483+
let cmt_args = Array.copy Sys.argv in
484+
cmt_args.(0) <- Location.rewrite_absolute_path Sys.argv.(0);
485+
cmt_args in
463486
let cmt = {
464487
cmt_modname = Unit_info.Artifact.modname target;
465488
cmt_annots;
466489
cmt_declaration_dependencies = !uids_deps;
467490
cmt_comments = Lexer.comments ();
468-
cmt_args = Sys.argv;
491+
cmt_args;
469492
cmt_sourcefile = sourcefile;
470493
cmt_builddir = Location.rewrite_absolute_path (Sys.getcwd ());
471494
cmt_loadpath = Load_path.get_paths ();

file_formats/cmt_format.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ type cmt_infos = {
5757
cmt_declaration_dependencies : (dependency_kind * Uid.t * Uid.t) list;
5858
cmt_comments : (string * Location.t) list;
5959
cmt_args : string array;
60+
(** {!Sys.argv} from the compiler invocation which created the file.
61+
[Sys.argv.(0)] is rewritten using [BUILD_PATH_PREFIX_MAP]. *)
6062
cmt_sourcefile : string option;
6163
cmt_builddir : string;
6264
cmt_loadpath : Load_path.paths;

lambda/lambda.ml

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,20 @@ type tag_info =
5050
; attributes: Parsetree.attributes
5151
}
5252
| Blk_record_ext of { fields: string array; exn: bool }
53-
| Blk_lazy_general
5453
| Blk_class (* Ocaml style class*)
5554

5655
let default_tag_info : tag_info = Blk_na ""
5756
let blk_record = ref (fun fields ->
58-
let all_labels_info = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in
57+
let all_labels_info = fields |> Array.map (fun (x,_) -> x.Data_types.lbl_name) in
5958
Blk_record all_labels_info
6059
)
6160

6261
let blk_record_ext = ref (fun ~is_exn fields ->
63-
let all_labels_info = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in
62+
let all_labels_info = fields |> Array.map (fun (x,_) -> x.Data_types.lbl_name) in
6463
Blk_record_ext { fields = all_labels_info; exn = is_exn })
6564

6665
let blk_record_inlined = ref (fun fields name num_nonconst attributes ->
67-
let fields = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in
66+
let fields = fields |> Array.map (fun (x,_) -> x.Data_types.lbl_name) in
6867
Blk_record_inlined {fields; name; num_nonconst; attributes }
6968
)
7069

@@ -84,13 +83,13 @@ type field_dbg_info =
8483
| Fld_cons
8584
| Fld_array
8685

87-
let fld_record = ref (fun (lbl : Types.label_description) ->
86+
let fld_record = ref (fun (lbl : Data_types.label_description) ->
8887
Fld_record {name = lbl.lbl_name; mutable_flag = Mutable})
8988

90-
let fld_record_inline = ref (fun (lbl : Types.label_description) ->
89+
let fld_record_inline = ref (fun (lbl : Data_types.label_description) ->
9190
Fld_record_inline {name = lbl.lbl_name})
9291

93-
let fld_record_extension = ref (fun (lbl : Types.label_description) ->
92+
let fld_record_extension = ref (fun (lbl : Data_types.label_description) ->
9493
Fld_record_extension {name = lbl.lbl_name})
9594

9695
let ref_field_info : field_dbg_info =
@@ -105,11 +104,11 @@ type set_field_dbg_info =
105104
| Fld_record_extension_set of string
106105

107106
let ref_field_set_info : set_field_dbg_info = Fld_record_set "contents"
108-
let fld_record_set = ref ( fun (lbl : Types.label_description) ->
107+
let fld_record_set = ref ( fun (lbl : Data_types.label_description) ->
109108
Fld_record_set lbl.lbl_name )
110-
let fld_record_inline_set = ref ( fun (lbl : Types.label_description) ->
109+
let fld_record_inline_set = ref ( fun (lbl : Data_types.label_description) ->
111110
Fld_record_inline_set lbl.lbl_name )
112-
let fld_record_extension_set = ref ( fun (lbl : Types.label_description) ->
111+
let fld_record_extension_set = ref ( fun (lbl : Data_types.label_description) ->
113112
Fld_record_extension_set lbl.lbl_name )
114113

115114
type immediate_or_pointer =
@@ -125,6 +124,14 @@ type is_safe =
125124
| Safe
126125
| Unsafe
127126

127+
type lazy_block_tag =
128+
| Lazy_tag
129+
| Forward_tag
130+
131+
let tag_of_lazy_tag = function
132+
| Lazy_tag -> Config.lazy_tag
133+
| Forward_tag -> Obj.forward_tag
134+
128135
type primitive =
129136
| Pbytes_to_string
130137
| Pbytes_of_string
@@ -134,6 +141,7 @@ type primitive =
134141
| Psetglobal of Ident.t
135142
(* Operations on heap blocks *)
136143
| Pmakeblock of int * tag_info * mutable_flag * block_shape
144+
| Pmakelazyblock of lazy_block_tag
137145
| Pfield of int * immediate_or_pointer * mutable_flag * field_dbg_info
138146
| Pfield_computed
139147
| Psetfield of int * immediate_or_pointer * initialization_or_assignment * set_field_dbg_info
@@ -229,10 +237,7 @@ type primitive =
229237
(* Integer to external pointer *)
230238
| Pint_as_pointer
231239
(* Atomic operations *)
232-
| Patomic_load of {immediate_or_pointer : immediate_or_pointer}
233-
| Patomic_exchange
234-
| Patomic_cas
235-
| Patomic_fetch_add
240+
| Patomic_load
236241
(* Inhibition of optimisation *)
237242
| Popaque
238243
(* Fetching domain-local state *)
@@ -878,14 +883,18 @@ let transl_extension_path loc env path =
878883
let transl_class_path loc env path =
879884
transl_path Env.find_class_address loc env path
880885

881-
let transl_prim mod_name name =
882-
let pers = Ident.create_persistent mod_name in
883-
let env = Env.add_persistent_structure pers Env.empty in
884-
let lid = Longident.Ldot (Longident.Lident mod_name, name) in
885-
match Env.find_value_by_name lid env with
886-
| path, _ -> transl_value_path Loc_unknown env path
887-
| exception Not_found ->
888-
fatal_error ("Primitive " ^ name ^ " not found.")
886+
let transl_prim modname field =
887+
let mod_ident = Ident.create_persistent modname in
888+
let env = Env.add_persistent_structure mod_ident Env.initial in
889+
match Env.open_pers_signature modname env with
890+
| Error `Not_found ->
891+
fatal_errorf "Module %s unavailable." modname
892+
| Ok env -> (
893+
match Env.find_value_by_name (Longident.Lident field) env with
894+
| exception Not_found ->
895+
fatal_errorf "Primitive %s.%s not found." modname field
896+
| path, _ -> transl_value_path Loc_unknown env path
897+
)
889898

890899
(* Compile a sequence of expressions *)
891900

lambda/lambda.mli

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,24 @@ type tag_info =
6161
; attributes: Parsetree.attributes
6262
}
6363
| Blk_record_ext of { fields: string array; exn: bool }
64-
| Blk_lazy_general
6564
| Blk_class (* ocaml style class *)
6665

6766
val blk_record :
6867
(
69-
(Types.label_description * Typedtree.record_label_definition) array ->
68+
(Data_types.label_description * Typedtree.record_label_definition) array ->
7069
tag_info
7170
) ref
7271

7372
val blk_record_ext :
7473
(
7574
is_exn:bool ->
76-
(Types.label_description * Typedtree.record_label_definition) array ->
75+
(Data_types.label_description * Typedtree.record_label_definition) array ->
7776
tag_info
7877
) ref
7978

8079
val blk_record_inlined :
8180
(
82-
(Types.label_description* Typedtree.record_label_definition) array ->
81+
(Data_types.label_description* Typedtree.record_label_definition) array ->
8382
string ->
8483
int ->
8584
Parsetree.attributes ->
@@ -105,15 +104,15 @@ type field_dbg_info =
105104
| Fld_array
106105

107106
val fld_record :
108-
(Types.label_description ->
107+
(Data_types.label_description ->
109108
field_dbg_info) ref
110109

111110
val fld_record_inline :
112-
(Types.label_description ->
111+
(Data_types.label_description ->
113112
field_dbg_info) ref
114113

115114
val fld_record_extension :
116-
(Types.label_description ->
115+
(Data_types.label_description ->
117116
field_dbg_info) ref
118117

119118
val ref_field_info : field_dbg_info
@@ -129,20 +128,22 @@ type set_field_dbg_info =
129128
val ref_field_set_info : set_field_dbg_info
130129

131130
val fld_record_set :
132-
(Types.label_description ->
131+
(Data_types.label_description ->
133132
set_field_dbg_info) ref
134133

135134
val fld_record_inline_set :
136-
(Types.label_description ->
135+
(Data_types.label_description ->
137136
set_field_dbg_info) ref
138137

139138
val fld_record_extension_set :
140-
(Types.label_description ->
139+
(Data_types.label_description ->
141140
set_field_dbg_info) ref
142141

143142
type immediate_or_pointer =
144143
| Immediate
144+
(* The value must be immediate. *)
145145
| Pointer
146+
(* The value may be a pointer or an immediate. *)
146147

147148
type initialization_or_assignment =
148149
| Assignment
@@ -175,6 +176,10 @@ type pointer_info =
175176
| Pt_assertfalse
176177
| Pt_na
177178

179+
type lazy_block_tag =
180+
| Lazy_tag
181+
| Forward_tag
182+
178183
type primitive =
179184
| Pbytes_to_string
180185
| Pbytes_of_string
@@ -184,6 +189,7 @@ type primitive =
184189
| Psetglobal of Ident.t
185190
(* Operations on heap blocks *)
186191
| Pmakeblock of int * tag_info * mutable_flag * block_shape
192+
| Pmakelazyblock of lazy_block_tag
187193
| Pfield of int * immediate_or_pointer * mutable_flag * field_dbg_info
188194
| Pfield_computed
189195
| Psetfield of int * immediate_or_pointer * initialization_or_assignment * set_field_dbg_info
@@ -283,10 +289,7 @@ type primitive =
283289
(* Integer to external pointer *)
284290
| Pint_as_pointer
285291
(* Atomic operations *)
286-
| Patomic_load of {immediate_or_pointer : immediate_or_pointer}
287-
| Patomic_exchange
288-
| Patomic_cas
289-
| Patomic_fetch_add
292+
| Patomic_load
290293
(* Inhibition of optimisation *)
291294
| Popaque
292295
(* Fetching domain-local state *)
@@ -583,7 +586,7 @@ val transl_prim: string -> string -> lambda
583586
(** Translate a value from a persistent module. For instance:
584587
585588
{[
586-
transl_internal_value "CamlinternalLazy" "force"
589+
transl_prim "CamlinternalLazy" "force"
587590
]}
588591
*)
589592

@@ -657,6 +660,8 @@ val max_arity : unit -> int
657660
This is unlimited ([max_int]) for bytecode, but limited
658661
(currently to 126) for native code. *)
659662

663+
val tag_of_lazy_tag : lazy_block_tag -> int
664+
660665
(***********************)
661666
(* For static failures *)
662667
(***********************)

0 commit comments

Comments
 (0)