70 Commits

Author SHA1 Message Date
David Allsopp
f47a07e36c Add %standard_library_default
%standard_library_default allows Config.standard_library_default to be
converted to a compile-time derived value, as with existing compile-time
constants such as %backend_type, etc. This paves the way for allowing
Config.standard_library_default to be changed at link-time, rather than
fixed when the Config module itself is compiled.
2025-12-05 10:58:32 +00:00
Vincent Laviron
5eefdf28fc Remove Lambda.Const_base indirection 2025-09-23 16:20:13 +02:00
Vincent Laviron
59ae1d7942 Introduce Lambda.constant type
This is a copy of Asttypes.constant minus the string case.
It ensures that there is a single way to represent constant strings,
and allows to remove a few pieces of duplicated code.
2025-09-23 16:20:13 +02:00
Vincent Laviron
60e044e1bf Introduce Lambda.lambda_of_const
This helper function ensures that constant strings are always
represented using Const_immstring and not Const_base (Const_string _)
2025-09-23 16:10:53 +02:00
Stephen Dolan
be625238bb Allow strings to be shared by Lambda.make_key
Strings have been immutable for a while now
2025-09-23 13:19:50 +01:00
Gabriel Scherer
6edeb97b97 [refactor] Lambda: merge transl_mod_field and transl_prim 2025-04-08 11:50:15 +02:00
Gabriel Scherer
1e6da84197 [refactoring] Lambda.transl_mod_field, move 'lazy' to clients 2025-04-08 11:50:15 +02:00
Gabriel Scherer
5270d8b5af [refactoring] move Matching.get_mod_field to Lambda.transl_mod_field 2025-04-08 11:50:15 +02:00
Vincent Laviron
979ce41050
Use a dedicated primitive for Lazy blocks (#13867)
Lazy blocks are very special, in that a value bound to a lazy block may,
at any moment, completely change its shape (it could become an immediate,
or any other kind of value).
By splitting these blocks from the regular blocks, we allow the middle-end
to assume that any Pmakeblock behaves as a normal block, making all
related optimisations safer.

In passing, this also fixes an issue with Forward blocks in recursive definitions.
2025-03-19 21:38:16 +01:00
Ulysse Gérard
0c5ae452e4 Attach new locs to Ldot and Lapply nodes
instead of `Lident` nodes.

Parser changes.
Requires bootstrap.

Co-authored-by: Jules Aguillon <jules@j3s.fr>
Suggested-by: Florian Angeletti <florian.angeletti@inria.fr>
2025-02-20 13:30:06 +01:00
Gabriel Scherer
11dcf188b2 [refactoring] simplify the Patomic_load primitive by dropping immediate info
The Patomic_load primitive represents atomic loads (Atomic.get), and
it tracks whether the load type only contains immediate values, or
whether it contains both immediates and pointers. This comes at a
small cost in complexity in the compiler source, but is in fact
completely useless for two reasons:

1. We made a mistake in atomic.mli, which results in the information
   *never* being upgraded to Immediate: we declare
   `val get : 'a t -> 'a` instead of `external get : ...`,
   and as a consequence the compiler never specializes this primitive.

   (You can test this by compiling
     `let f (n : int Atomic.t) = Atomic.get n`
    and looking at the lambda or cmm output.)

2. The backend does not in fact depend on whether the value is
   immediate or not: even if we did track this information correctly,
   there would be no change in the generated code.
   (We checked this by reviewing atomic-load code production in all
   emit.mlp backends.)

This simplification will help (modestly) simplify the code of an
upcoming PR on atomic record fields.

Co-authored-by: Clément Allain <clef-men@orange.fr>
Reviewed-by: KC Sivaramakrishnan <kc@kcsrk.info>
2024-08-27 17:01:04 +02:00
Gabriel Scherer
5c888e797f [refactor] simplify the definition of atomic functions
In trunk, all atomic functions exposed in the runtime are also exposed
as language primitives in our intermediate representations (lambda,
clambda). But except for `Patomic_load`, which benefits from
dedicated code generation, they are all transformed into C calls
on all backends.

The present PR simplifies the code noticeably by removing the
intermediate primitives, by producing C calls directly in
lambda/translprim.ml.

This reduces the amount of boilerplate to modify to implement
atomic record fields (https://github.com/ocaml/RFCs/pull/39).

Co-authored-by: Clément Allain <clef-men@orange.fr>
2024-08-24 17:55:20 +02:00
KC Sivaramakrishnan
38972e8831 Move is_evaluated to lambda 2024-05-07 14:08:16 +05:30
Nick Barnes
0ddab1ba00 Add a "%poll" primitive, which does a GC poll (and therefore runs any
pending runtime actions).
2024-04-10 13:26:26 +01:00
Vincent Laviron
d6b7459a48
Compile recursive bindings in Lambda (#12596) 2024-01-29 23:03:01 +01:00
Vincent Laviron
100558ca56 Refactoring:
- Add Value_rec_types modules
- Rename Rec_check to Value_rec_check
2023-11-24 14:16:28 +01:00
Nick Roberts
84daf9e092 Turn off arity fusion for [fun] and [function] 2023-10-16 17:24:05 +01:00
Vincent Laviron
04e0e5dcbe
Propagate the classification from Rec_check (#12551) 2023-09-25 17:53:02 +02:00
Anton Yabchinskiy
08276afddb Support 16-bit floating-point numbers as elements of bigarrays (#10775) 2023-06-19 14:36:02 +02:00
Nick Roberts
c46f38908a Remove Lev_module_definition 2023-03-13 14:29:04 +00:00
Stephen Dolan
4a89198f75 Make Lambda.lfunction private 2022-02-12 15:16:19 +01:00
Tom Kelly
9fd98fc226 Merge commit 'edf0075888ec27a50c4f50f76dba46f730797651' into 5.00_rebase_to_pr 2021-12-20 16:38:51 +00:00
Tom Kelly
6ded93883a Merge commit '2bcef4bc172f476217f253d24cb3311eaca504bf' into 5.00_rebase_to_pr 2021-12-20 15:43:01 +00:00
Sadiq Jaffer
edf0075888
Add [@poll error] attribute (#10462) 2021-11-09 09:56:29 +00:00
Gabriel Scherer
1daea333b6 [refactoring] move Simplif.exact_application to Lambda
We need to use this logic in lambda/tmc.ml to support tupled functions.
2021-11-02 15:42:55 +01:00
Frédéric Bour
a84b25b222 prepare for TMC (tail modulo cons) transformation 2021-11-02 15:42:55 +01:00
Tom Kelly
7cffbd64a0 remove multicore nop debugging (reverts ocaml-multicore#384) 2021-10-08 15:31:53 +01:00
Tom Kelly
23852f7800 Merge commit 'cdc32182aed4ab327084aeb3090e529f6cec4b46' into 5.00 2021-10-04 13:16:04 +01:00
Tom Kelly
0ffeac19d7 Merge commit '1037341d8cbd533209c2898e0743757189ce8f1e' into parallel_minor_gc_4_13 2021-10-01 15:54:48 +01:00
Tom Kelly
d85f4d8efd Merge commit '099b86a046e304fe15e2bb37557bffc6aafaab15' into parallel_minor_gc_4_13 2021-10-01 12:19:35 +01:00
Tom Kelly
67e3095546 Merge commit 'd0f80077066105e1429ef8728b8362b8d698e298' into parallel_minor_gc_4_13 2021-09-29 15:16:38 +01:00
Sadiq Jaffer
1290ad7f93 add polling at mach layer 2021-09-06 15:25:08 +01:00
Gabriel Scherer
ff86950c25 [minor] make Lambda.Not_simple local to its only user 2021-07-15 22:12:56 +02:00
KC Sivaramakrishnan
34540fd116 Add primitive for fetching dls state 2021-06-10 17:02:29 +05:30
Vincent Laviron
dc08b85b16 Remove primitives Pdirapply and Prevapply 2021-05-25 18:21:31 +02:00
Vincent Laviron
2bc428664f Remove the Pidentity primitive 2021-05-25 18:18:50 +02:00
Antal Spector-Zabusky
e87be39194 Maintain more structural information in type-checking errors
This commit refactors the types that make up type-checking errors to
maintain more structural information.  Most significantly, we split
out the errors we get from unification, moregen, and type equality in
`Ctype` into three distinct exceptions, and retain the sorts of
information we keep during unification in the other two cases as well
(no more `Unify []`).  We also maintain more information in
`Includecore` about mismatches of primitives, manifests, and private
objects and variants

This commit doesn't make a lot of changes to the user-visible error
messages yet, only what's necessary to support the type changes, but
it enables a forthcoming patch where we use this improvement to
produce more informative error messages.

This commit includes existing work by Mekhrubon Tuarev, who did all
the early development.  I (Antal Spector-Zabusky) came and built the
layer of types on top.
2021-05-06 20:46:01 -04:00
Tom Kelly
aceef8b97c Merge commit '426b10c6a8497dfa0af6858075828c24e2d9570b' into parallel_minor_gc_4_12 2021-03-09 13:28:38 +00:00
Tom Kelly
79d5f2f1f2 Merge commit '06162616426d8689f868ec9b150c6b6a9ba7fdb9' into parallel_minor_gc_4_12 2021-03-04 13:42:33 +00:00
Tom Kelly
86fbc7e8d5 Merge commit 'b7509ca82f9bd647c1cb7e810b6bb152e145e3fb' into parallel_minor_gc_4_12 2021-03-03 15:28:59 +00:00
Tom Kelly
701bbb9b00 Merge commit 'e717512a54349bce4bbbb9590d4fe5a2c671c4e9' into parallel_minor_gc_4_12 2021-03-03 13:30:53 +00:00
Tom Kelly
29f4177a4e Merge commit '0ca651b95cbda5d58f7760f0fa1dba965d1f0828' into parallel_minor_gc_4_12 2021-03-02 16:15:55 +00:00
Tom Kelly
b84f29718a Merge commit '8f85e002b2e1f3f4ccf8fefa5ad9a137109168d1' into parallel_minor_gc_4_12 2021-03-01 21:57:28 +00:00
Tom Kelly
a2676c4083 Merge commit 'ec6690fb53b6caced797e1a7a083a787ff8bd97c' into parallel_minor_gc_4_11b 2021-03-01 19:47:21 +00:00
Tom Kelly
bd1576d22c Merge commit '017d4a3eaddbd2b25649d04ed576258e4ddf60cc' into parallel_minor_gc_4_11b 2021-03-01 17:30:56 +00:00
Keryan Didier
28d3196ead Fixed an overlooked transformation to Lmutvar and added cautionnary comment 2021-01-07 14:58:58 +01:00
Keryan Didier
6f0765e688 added new construct Lmutlet and removed Variable attribute 2021-01-07 14:58:58 +01:00
Keryan Didier
c3511192e7 added new lambda construct Lmutvar (#9954) 2021-01-07 14:58:58 +01:00
Gabriel Scherer
82b29828d2
Allow [@tailcall true] and [@tailcall false] (#9754)
* remove the unused is_native_tail_call_heuristic forward reference

This forward-reference from Lambda to Asmcomp was used to generate
machine-specific tailcall information in -annot output; this only use
was removed in 57d329e07b50e6869875471b085541baadcb8376, so we can now
remove it to simplify the codebase.

The logic was non-trivial and might be useful again in the future.

* [minor] testsuite: convert warnings/w51.ml to an expect-test

* [minor] translattribute: refactor attribute payload deconstruction

* [@tailcall false]: warn if the call *is* a tailcall

(+ constructor renaming suggested by Nicolás during review)

* Changes

* testsuite: add an example with the 'invalid payload' exception

(suggested by Nicolás during review)
2020-10-10 13:41:39 +02:00
KC Sivaramakrishnan
afda9bcbd8 Add a primitive to insert nop instruction 2020-07-31 18:24:16 +05:30