%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.
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.
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.
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>
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>
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.
* 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)