Commit Graph

20137 Commits (8e83130a18a68cf99d6b94c699eb7026e5a4fa4a)

Author SHA1 Message Date
Gabriel Scherer 8e83130a18 compute the same separability signatures in either "(no) flat float" modes
In -no-flat-float-array mode, instead of always returning
`best_msig` (the most permissive signature), we first compute the
flat-float-array separability signature -- falling back to `best_msig`
if it fails.

This discipline is conservative: it never rejects -no-flat-float-array
programs. At the same time it guarantees that, for any program that is
also accepted in -flat-float-array mode, the same separability will be
inferred in the two modes. In particular, the same .cmi files and
digests will be produced.

Before we introduced this hack, the production of different .cmi files
would break the build system of the compiler itself, when trying to
build a -no-flat-float-array system from a bootstrap compiler itself
using -flat-float-array. See #9291.
2020-06-01 12:19:08 +02:00
Gabriel Scherer 5c9d5db728
Merge pull request #9511 from gasche/parmatch-exhaust-lazy
Parmatch: make `exhaust` (exhaustivity and fragility checking) lazy
2020-05-30 19:01:38 +02:00
Gabriel Scherer d8acfa92e4 parmatch: ensure specialized submatrices are in source order
We produce exhaustivity counter-example in the order of the
specialized submatrices. Having submatrices in source order gives the
nice behavior that the clause that would naturally been inserted first
in the source is given first as a counter-example.

Consider for example:

    function
    | true, true -> true
    | false, false -> false

The two counter-examples are (true, false) and (false, true).

Before this patch, (false, true) would be shown first.
After this patch, (true, false) is shown first.
This corresponds to the following natural completion order:

    function
    | true, true -> true
    | true, false -> ?
    | false, false -> false
    | false, true -> ?

On the other hand, the ordering of the default submatrix, with respect
to the specialized submatrices, is not preserved -- it is always
ordered last.
One could intuitively expect the default submatrix to appear in the
position of the first omega row in the source. We tried this, and
it is not a good idea:
- the change is much more invasive as the interface of
  `build_specialized_submatrices` has to change
- the behavior of the result is in fact unpleasant; it is not
  intuitive to order counter-examples in this way.

For example, consider:

    function
    | _, None -> false
    | true, Some true -> false

The two exhaustivity counter-examples are (true, Some false)
and (false, Some _). The second comes from the default submatrix:
morally it is (_, Some _), with "some other constructor missing from
the column" instead of the first _. There is no reason to suppose that
the user would want to place this (_, Some _) or (false, Some _)
counter-example first in the completed code; indeed, this intuition
would suggest writing an exhaustive covering of patterns of the
form (_, foo), inserted after the first clause, but then the other
clauses below become unnecessary!

When an omega patterns appears high in the column like this, it is
usually because there is a very specific matching condition to the
rest of its row, that justifies some shortcutting behavior. The
program is typically *not* completed by adding more specific matching
conditions.
2020-05-30 17:11:54 +02:00
Gabriel Scherer f8e24bda0c Changes entry 2020-05-30 17:11:54 +02:00
Gabriel Scherer a8adec16f1 add regression tests for fragile-matching stack overflows 2020-05-30 17:10:37 +02:00
Gabriel Scherer 8f71174eb2 parmatch: make 'exhaust' lazy by returning a Seq.t
This solves exponential-blowup issue with the strict traversal and/or
strict witness computation in cases where an exponential number of
counter-examples is generated. This fixes Stack Overflow and
exponential-time issues on examples using or-patterns heavily,
including one that naturally found its way in real-world user
code (see the following testsuite commit).

We now systematically keep only one counter-example, instead of
letting the type-checker decide whether to discard
counter-examples (in Backtrack_or mode) or to preserve
them (in Refine_or mode).

Note: in the exhaustivity warning, there are sub-messages printed to
indicate that:

- the exhaustivity counter-example is related to an extensible type, or
- that a when-guarded clause does match the counter-example

In both cases the warning is there to explain the counter-example(s)
shown (not a property of all counter-examples); keeping at most one
valid counter-example means that they will be printed less often, but
it is the correct/intended behavior in that case.
2020-05-30 17:10:37 +02:00
Etienne Millon 71e91123c2
Attach package type attributes to core_type (#9615) 2020-05-29 14:29:10 +02:00
Manuel Hornung 2b6f49e874
Add new flag for non-elevated symbolic links and test for Developer Mode on Windows (#9593)
Support symbolic links in developer mode on Windows 10
2020-05-29 07:39:59 +01:00
Gabriel Scherer a8d06b2010 Changes: backport the caml_*_compare fix to 4.11 2020-05-28 13:51:50 +02:00
Gabriel Scherer 62dcc6e50d
Merge pull request #9613 from gretay-js/fix_compare
Bind arguments of integer and float compare in cmmgen
2020-05-28 13:47:18 +02:00
Gabriel Scherer 4088367fbc
Merge pull request #9609 from gasche/unboxed-abstract-with-manifest
separability and with-constraints: fix for bug #9607
2020-05-28 08:46:22 +02:00
Gabriel Scherer 957f10b3fd
Merge pull request #9604 from gasche/ocamltest_refactor_1
Fewer ocamltest cleanups
2020-05-27 23:19:08 +02:00
Gabriel Scherer ec74335158 typedecl: prevent the mistake of not updating transl_with_constraint 2020-05-27 22:18:06 +02:00
Gabriel Scherer 9b1bfc3b7c typedecl: correct update separability in transl_with_constraint
fixes #9607
2020-05-27 21:32:36 +02:00
Nicolás Ojeda Bär e439fea68d Changes entry 2020-05-27 19:19:22 +02:00
Nicolás Ojeda Bär b4ba61d73d Typos 2020-05-27 19:19:22 +02:00
Nicolás Ojeda Bär 105ac40bd6 Hide references in Options implementation 2020-05-27 19:19:22 +02:00
Nicolás Ojeda Bär 13e96a1bcf Remove unneeded Sys.chdir 2020-05-27 19:19:22 +02:00
Nicolás Ojeda Bär 73aa6126a7 Use with_{input,output}_file 2020-05-27 19:19:22 +02:00
Nicolás Ojeda Bär b77b13d812 Use Sys.{win32,...} instead Sys.os_type 2020-05-27 19:19:22 +02:00
Nicolás Ojeda Bär 3eebf1ab8c Use Filename.quote_command 2020-05-27 19:19:22 +02:00
Nicolás Ojeda Bär 6c311f3007 stop passing the constant ocamlsrcdir to each function 2020-05-27 19:19:22 +02:00
Greta Yorsh 21f04a4019 Update Changes 2020-05-27 17:01:20 +01:00
Greta Yorsh 4c25ffcce9 Add a test 2020-05-27 16:59:45 +01:00
Greta Yorsh 6cb283b1d8 Move float compare from cmmgen to cmm_helpers 2020-05-27 16:59:15 +01:00
Greta Yorsh 8fce17d902 Bind arguments of integer and float compare in cmmgen 2020-05-27 14:49:35 +01:00
Gabriel Scherer 463f1e1b9f add a testsuite case for an [@@unboxed] bug (#9607) reported by Stephen Dolan
Currently the test fails while it should work.
2020-05-27 10:38:09 +02:00
Gabriel Scherer 0c60f27978 remove an unused test reference file 2020-05-27 10:38:09 +02:00
Gabriel Scherer e68b75eb82
Merge pull request #9599 from trefis/rematch-complete-constrs
pattern-matching refactoring: refine the type of `complete_constrs`
2020-05-27 09:26:29 +02:00
David Allsopp 4f363aa9cb
Merge pull request #9601 from dra27/win32unix-EPERM
Map ERROR_PRIVILEGE_NOT_HELD to EPERM in win32unix
2020-05-26 14:48:41 +01:00
Gabriel Scherer bf95a24739 Matching: propagate constructor descriptions in complete_pats_constrs
This simplifies this particular interface boundary between Matching
and Parmatch.

(Suggested by Florian Angeletti)
2020-05-26 15:47:41 +02:00
Jacques-Henri Jourdan 4c24dca92a
Memprof: Fix duplicate declaration of static variable rand_pos (#9598) 2020-05-25 19:16:27 +02:00
Jacques Garrigue 1bb388bd15
Fix PR#7817: Unsound inclusion check for polymorphic variant (#9546) 2020-05-25 19:12:09 +02:00
David Allsopp 643d1af004 Map ERROR_PRIVILEGE_NOT_HELD to EPERM 2020-05-25 16:55:50 +01:00
Gabriel Scherer d333ac83ec matching: use constructor descriptions instead of tags as matching keys
This loses no information (descriptions contain the tag), but it will
make it easier to obtain the descriptions inside `combine_constructor`
without doing a dynamic check on the patterns. This will in turn help
simplify the interaction with `Parmatch.complete_constrs`.

Note: after this patch we use `Types.equal_tag` instead of `( = )` to
compare tags during pattern-matching compilation. This is better code,
and we believe that it does not change the behavior: `Types.equal_tag`
is mostly similar to a type-specialized version of `( = )`, except
that it calls `Ident.same` that just compares the stamps and ignore
the names, which (assuming well-formedness of idents) is equivalent
and slightly faster.
2020-05-25 17:06:31 +02:00
Gabriel Scherer 8150e47525
Merge pull request #9563 from trefis/rematch-standalone-patterns
pattern-matching refactoring: move pattern types to a new module typing/Patterns
2020-05-25 17:06:01 +02:00
Stephen Dolan 9e09fde735
Avoid creating ill-formed blocks in Cmm letrec (#9577)
Use "1" (integer 0) as filler value instead of "0" (null pointer).

Fixes: 7718
2020-05-25 10:11:45 +02:00
Jacques-Henri Jourdan 3d63a106b6
Memprof: optimize random sampling (#9466)
Instead of using the stdlib logf function for computing logarithms, we
use a faster polynomial-based approximation.

We use the xoshiro PRNG instead of the Mersenne Twister.  xoshiro is
simpler and faster.

We generate samples by batches so that compilers can vectorize the
generation loops using SIMD instructions when possible.
2020-05-25 09:51:15 +02:00
Xavier Leroy b2f467abc0 Improve -with-bootstrap mode
- coreboot + opt.opt gives a faster build than bootstrap + opt.opt
- Restore the original bootstrap compilers on exit, so that
  other-configs works (it performs several builds in sequence).
2020-05-21 17:05:40 +02:00
Xavier Leroy f82a84f3e8 Force a bootstrap for the --disable-flat-float-array test
The default build procedure is broken in --disable-flat-float-array mode
since PR#2188 was merged.  This commit unblocks temporarily the situation
by using a build with bootstrap for --disable-float-float-array-mode.
2020-05-21 15:40:18 +02:00
Xavier Leroy ad804d1c4a Add option "-with-bootstrap"
This option forces a bootstrap of the bytecode compiler before the
whole system is built and tested.
2020-05-21 15:40:13 +02:00
Gabriel Scherer 1ee6ee4194 fixup! matching: use pattern views in Parmatch as well 2020-05-21 09:51:30 +02:00
Nicolás Ojeda Bär 9b748843bb
Use List.find_map (#9589) 2020-05-21 08:51:16 +02:00
Nicolás Ojeda Bär a151e9187b
When bytecode linking fails due to a missing module, show which module requires it (#9583) 2020-05-21 05:37:09 +02:00
Xavier Leroy 89beb4c7f0 Use Sys.command instead of Unix.system to call 'cmp'
Clang's thread sanitizer TSAN reports a (false?) alarm on Unix.system
in multithreaded programs now that Unix.system is implemented
on top of posix_spawn.

This commit replaces Unix.system with Sys.command, which might work
better with TSAN, based on preliminary experiments.

Note that this test is about file I/O, not Unix.system, so the replacement
is acceptable.  In parallel, we need to understand what's happening
with TSAN and posix_spawn.
2020-05-20 19:49:36 +02:00
Stephen Dolan ff6ae43184
Merge pull request #9458 from jhjourdan/memprof_fatal_error_thread_exit
Memprof: fatal error if thread is stopped from a callback.
2020-05-20 16:58:10 +01:00
Xavier Leroy a364988ba8
Update link options for PowerPC 32 bits Linux (#9572)
On PowerPC 32 bits Linux, recent versions of GCC produce "secure PLT"
relocatable code by default, while ocamlopt still generates "BSS PLT"
relocatable code.  This causes a warning at link-time when "BSS PLT"
object files (produced by ocamlopt) are being linked.

This PR makes sure that "-mbss-plt" is added to the OC_LDFLAGS and
MKSHAREDLIB variables on PowerPC 32 bits Linux.
2020-05-20 15:12:41 +02:00
Xavier Leroy 41548a7359
Merge pull request #9573 from xavierleroy/posix-spawn
Reimplement Unix.create_process and related functions without Unix.fork
2020-05-19 19:23:54 +02:00
Xavier Leroy 2fe16774cb Add Changes entry 2020-05-19 19:21:18 +02:00
Xavier Leroy 3e8272fe7c Reimplement Unix.command like Unix.create_process
Avoid calling Unix.fork and use the new "spawn" primitive, for efficiency
and for improved compatibility with threads and Multicore OCaml.
2020-05-19 19:21:18 +02:00