Commit Graph

19810 Commits (d0bab08f15c768c07bc88547043e26237b69085e)

Author SHA1 Message Date
David Allsopp d0bab08f15 Don't ever call stop_user_input in line_loop
The caller is now always responsible for calling stop_user_input, rather
than only responsible for calling it on error.
2019-10-19 11:47:07 +01:00
David Allsopp 37acb3bf24 Remove use of Printexc.catch from debugger
Allow the runtime to display details of any uncaught exception (with
backtraces, if enabled). Unix.handle_unix_error is still used to convert
errors from system calls to a less unmeaningful form.
2019-10-19 10:38:48 +01:00
David Allsopp e2f278c7a4 Preserve backtraces in debugger
Add Primitives.cleanup which allows handlers for unexpected exceptions
to cleanup and reraise the exception with its backtrace.
2019-10-19 10:38:48 +01:00
David Allsopp dce967139c
Merge pull request #8639 from dra27/autoconf-tweak
autoconf tweaks
2020-04-17 07:43:28 +01:00
Xavier Leroy 67ada54ce3
Reimplement output_value using a hash table to detect sharing (#9353)
The previous implementation was doing temporary in-place modifications
of the OCaml value being marshaled.  This is incompatible with
Multicore OCaml.
2020-04-16 17:56:28 +02:00
Gabriel Scherer 9f95355acb
Merge pull request #9447 from trefis/rematch-more-heads
pattern-matching refactoring: keep going
2020-04-16 14:32:00 +02:00
Gabriel Scherer 761383d597 Changes 2020-04-15 17:33:38 +02:00
Gabriel Scherer 6ceba91930 matching: minor code factorization of compile_* functions 2020-04-15 17:33:27 +02:00
Gabriel Scherer b2a2c94211 matching: factorize compile_match and compile_match_nonempty 2020-04-15 17:32:42 +02:00
Gabriel Scherer d67a091fb0 matching: inline split_and_precompile* to clarify compile_* 2020-04-15 17:30:59 +02:00
Gabriel Scherer 2d9aafce62 matching: what_is_cases returns a head 2020-04-14 09:58:34 +02:00
Guillaume Munch-Maccagnoni b1fdc44547
Install a pretty printer for the Fun.Finally_raised exception (#9266) 2020-04-13 19:09:47 +02:00
Stephen Dolan 2208a4cbe6
Fix tail-call optimisation with a mutable ref (#9443)
Fix tail-call optimisation with a mutable ref
(Clet_mutable was not recognized properly in tail position.)

Add a test for tail-call optimisation with a mutable ref
2020-04-13 18:20:56 +02:00
Xavier Leroy 88a1bceb1b
configure: use cc as assembler with clang and for all FreeBSD platforms (#9437)
In recent FreeBSD, `cc` is Clang and `ld` is LLD, the LLVM linker, but
`as` is still GNU binutils.  Moreover, Clang contains its own
assembler and does not call `as`.  Consequently, object files produced
by invoking `as` directly are slightly different from those produced
by `cc`.

This can cause obscure errors such as issue #9068: `ld -r` fails when
combining objects produced by `as` and objects produced by `cc`.

The workaround is to use `cc` as the assembler.  We already did that
for the ARM and ARM64 targets, but #9068 shows that it is necessary
for AMD64 too.  Just use `cc` as assembler for all FreeBSD targets.

Similar issues were reported under Linux when clang and LLD are used
instead of GCC and binutils.  We already used clang as the preprocessed
assembler in this case.  Also use clang as the assembler in this case.

Closes: #9068
2020-04-11 11:17:11 +02:00
Xavier Leroy 6040bcfdae
Merge pull request #9426 from xavierleroy/configure-mingw
Configure: improve selection of GCC options
2020-04-08 19:54:27 +02:00
Xavier Leroy 286d4d6390 Update Changes for PR#9426 2020-04-08 19:17:36 +02:00
Xavier Leroy e35babe426 configure: use m4_normalize to reformat long messages 2020-04-08 19:17:11 +02:00
Xavier Leroy 797698d8b0 configure: quote [] inside cases of AS_CASE construct
Patterns such as `gcc-[012]-*` are expanded as `gcc-012-*`.
An extra quoting is needed: `gcc-[[012]]-*` is expanded as `gcc-[012]-*`.
2020-04-08 19:17:11 +02:00
Xavier Leroy c5afa9303d configure: add GCC option -fexcess-precision=standard
This option forces GCC to follow the ISO C standards concerning
rounding of intermediate FP results.  It avoids some FP issues
with the x86 32 bits ports of OCaml, which can run into
excess precision problems due to the x87 FP unit.

Closes: #7917
2020-04-08 19:17:11 +02:00
Xavier Leroy 743ca1baff configure for mingw: GCC optimization options
Require GCC >= 5.0 and use the same GCC optimization options as for
the other ports.
2020-04-08 19:17:11 +02:00
Jacques Garrigue d67c704c4d
In `{expr with ...}`, always evaluate `expr` even if all labels are redefined (#9432)
This commit reverts c1a7ace (originally c545e04), which was a
temporary fix that is no longer needed because it was superseded by
#6608.

The temporary fix caused `{expr with lbl1 = e1; ... }` to not evaluate
`expr` if all labels of its type are overriden.  As reported in #7696
this is not desirable.  Reverting the temporary fix causes `expr` to
be evaluated always.

As a consequence, a corner case of value "let rec" is no longer accepted.
The corresponding test was updated.

Closes: #7696
2020-04-08 18:58:43 +02:00
Xavier Leroy 8ff2f34b05
Merge pull request #9420 from xavierleroy/output-value-fixes
Minor fixes to the marshaler (output_value)
2020-04-08 10:17:40 +02:00
Xavier Leroy 3d4564c54b Update Changes 2020-04-08 10:13:19 +02:00
Xavier Leroy 13fbd2ab78 caml_output_value_to_malloc: revise freeing of output buffer
This commit changes caml_output_value_to_malloc to use the same
pattern as caml_output_val and caml_output_value_to_bytes:
the blocks of output are freed in the same loop that copies
them to the final destination.

Originally, caml_output_value_to_malloc calls free_extern_output
to free the blocks of output.  This is correct too, but causes
extern_free_stack to be called twice, once at the end of extern_value
and once in free_extern_output.  This is OK because extern_free_stack
is protected against double free errors.

Still, I find it more elegant, more consistent with the rest of the
code, and less error-prone w.r.t. double free errors to not call
free_extern_output at the end of caml_output_value_to_malloc.

Later, free_extern_output could be renamed to e.g. extern_finalize
to emphasize that it is to be called when something goes wrong and
we are about to raise an exception.
2020-04-08 10:10:20 +02:00
Xavier Leroy 4d11d1da04 extern.c: make sure extern_free_stack() is always called on an exception
In the original code, if `caml_output_value_to_block` raises an exception,
`free_extern_output` does not call `extern_free_stack` because
of the early return on `extern_userprovided_output != NULL`.
2020-04-08 10:09:37 +02:00
Julien Rousé 61a2be4844
Fix documentation comment for struct large_free_block (#9399)
Fix the name of the field `isnode` in the struct `large_free_block` in the comment documenting it (was `node` before).

Replace "son" by "child" in the documentation of the struct "large_free_block".
2020-04-07 19:20:48 +02:00
Xavier Leroy d235f167fa
PowerPC, System Z: do not reset backtrace_pos in caml_raise_exception (#9428)
* PowerPC, System Z: do not reset backtrace_pos in caml_raise_exception
* Add Changes entry
2020-04-07 15:47:55 +02:00
Gabriel Scherer 2e82c0e843 Changes entry for the refactoring of the pattern-matching compiler 2020-04-07 15:25:06 +02:00
Gabriel Scherer 7bc2663a0e
Merge pull request #9422 from Anukriti12/gcd
replaced fib example with gcd in coreexample.etex
2020-04-07 15:08:58 +02:00
Gabriel Scherer 7612a6d9b1 [minor] fix a Makefile warning by defining undefined variables
Report by Xavier Leroy:
  https://github.com/ocaml/ocaml/pull/9414#issuecomment-610231289
2020-04-07 15:06:12 +02:00
Gabriel Scherer 019cd43ef1
Merge pull request #9417 from trefis/rematch-can_group-simplif
matching: simplify can_group
2020-04-07 08:42:35 +02:00
Gabriel Scherer d05f86e13b [minor] matching: rename `group_var` into `simple_omega_like`
(Report from Florian Angeletti)
2020-04-07 06:41:20 +02:00
Thomas Refis acd44f90af [REVIEW REQUIRED] matching: simplify can_group
review of can_group factorization by @gasche:

> I reviewed the change to `can_group` and believe it is correct.
> (I knew it would be nicer as a binary operation!)
>
> The different treatments of Lazy and Tuple/Record does look a bit odd,
> but I believe that it is actually the right thing to write.
>
> In the Tuple or Record case, the idea is that we can group Any heads
> with the Tuple/Record case and just explode all of them (including the
> Any cases) according to the tuple/record arity.
>
> In the Lazy case, the corresponding choice would be to add Any values
> to the Lazy group, and force all the elements of the group. This is
> not so nice, because intuitively we shouldn't force Lazy values unless
> we have to.
>
> One may expect that in general the argument of the pattern will be
> forced anyway, as long as there is at least one Lazy pattern above in
> the matrix, so it doesn't really matter whether we include the Any
> patterns in the forced group or not. I would argue that (1) even if
> that was true, it would be semantically dubious to handle Any that way
> (see a more precise criterion below), (2) I am not actually sure that
> this is true, what if the first group gets found unreachable by
> splits in following columns?
>
>     # type void = | ;;
>     # match (lazy (print_endline "foo"), (None : void option)) with
>       | lazy (), Some _ -> .
>       | _, None -> false;;
>     - : bool = false
>
> This gives the following decision tree for whether Any is included in
> the group:
>
> - Can the absence of Any be used to generate nice/efficient tests for
>   the heads of the group? In that case, don't include Any.
>   (Not included: all the Constant cases, Array (discriminate on size),
>    String, etc.)
>
> - Is Any always exactly equivalent to a more-defined head for values
>   of this type? In that case, do include Any, otherwise do not.
>   (Included: Variant, Record)
>   (Not included: Lazy)
2020-04-07 06:41:20 +02:00
Florian Angeletti abda688b03
Merge pull request #1706 from Octachron/extension_disambiguated_bis
Spellchecker hints and type-directed disambiguation for extensible variants: bis
2020-04-06 11:28:37 +02:00
Florian Angeletti fec3379c8a
Merge pull request #9423 from avsm/readme-new-site
README: update link to manual pages and reference inbox.ocaml.org
2020-04-06 11:09:56 +02:00
Anukriti12 97b9bed89e replaced fib example with gcd in coreexample.etex 2020-04-05 16:54:36 +05:30
Anil Madhavapeddy 6dd7b42eda README: update link to manual pages and reference inbox.ocaml.org 2020-04-05 11:00:00 +01:00
octachron 4f9f41e73a disambiguation for extension constructors
This commit exposes all extension constructors when looking up for
a construction with a given type in the environment.

This makes constructor disambiguation work for extension constructors.

Going one step further, when the name of an extension constructors
is misspelled, we cannot rely on the type to find all possible
names. However, since we are in an error path, we have some
path at hand.
Thus, this commit alters the "lookup_from_type" function in the
Constructor module to make it scan the whole environment for
extension constructors with the right type.

This commit should not change anything for labels and standard constructors.
2020-04-03 16:05:23 +02:00
Gabriel Scherer 1d76e2ca91
Merge pull request #9365 from gasche/Set-Map-filter_map
Map.filter_map and Set.filter_map
2020-04-02 17:59:51 +02:00
Gabriel Scherer b97f817c01
Merge pull request #9414 from gasche/testsuite-drop-passed-artefacts
ocamltest+testsuite: by default, only keep test data on failure
2020-04-02 17:59:15 +02:00
Gabriel Scherer 86066c8a59 Changes -- and justification.
On my machine, running the whole testsuite generates 1.5Gio of test
data. I have 11 workdirs for the OCaml repository (versions from 4.08
to trunk, plus several experimental workdirs); at any point in time
there can be more than a dozen gibibytes of test data on my disk, and
this is too much.

I use the test data saved by ocamltest when a test fails, to diagnose
the failure. I don't remember ever looking at the test data of
a succesful test.

The present patchset changes ocamltest to, by default, discard the
test directory of succesful tests -- the test artefacts are kept only
when there is a failure.

If one wishes to preserve the test data of succesful tests, one should
explicitly pass the -keep-test-dir-on-success flag. The
testsuite/Makefile is then changed to pass this flag if the user set
the KEEP_TEST_DIR_ON_SUCCESS variable to a non-empty value.
2020-04-02 16:19:56 +02:00
Gabriel Scherer 45697b3583 testsuite/Makefile: allow users to explicit set KEEP_TEST_DIR_ON_SUCCESS=1 2020-04-02 16:19:36 +02:00
Gabriel Scherer a86943c889 ocamltest: opt-in -keep-test-dir-on-success to keep test data on success 2020-04-02 16:12:21 +02:00
Gabriel Scherer 9eadd76ed1 ocamltest: collect 'summary' information on whether a failure happened 2020-04-02 16:07:48 +02:00
Gabriel Scherer 89b41c3219 testsuite/Makefile: refactor the -promote ocamltest logic
The existing approach requires to set all ocamltest flags at once on
recursive calls. This is very inconvenient if we want to set more than
one flag -- we wish to support choosing both -promote
and -keep-test-dir-on-success.
2020-04-02 16:07:20 +02:00
Gabriel Scherer 017d4a3ead
Merge pull request #9254 from gasche/memprof-record
Gc.Memprof.start: take a record instead of 5 optional parameters
2020-04-02 02:27:55 +02:00
Gabriel Scherer d440079a3e memprof runtime: keep tracker callbacks in a single value 2020-04-01 16:38:39 +02:00
Gabriel Scherer 14a4510cb7 memprof: remove caml_unused memprof_start_byt and then bootstrap
Build steps for this commit (from a valid core build for the previous commit):

    make coreall
    make coreboot

(Note: `make core` would not work as we remove a primitive.)
2020-04-01 16:38:39 +02:00
Gabriel Scherer ff6b20098f Gc.Memprof.start: take a record instead of 5 optional parameters
The Gc.Memprof module provides a low-level API, that will hopefully be
paired with user libraries that provide high-level instrumentation
choices.

A natural question is: how are the higher-level API going to expose
their choice of instrumentation to their users? With the current
Memprof.start API (before this patch), they would have to either
provide their own `start` function wrapping Memprof.start, or provide
a tuple of callbacks for to their users to pass to Memprof.start
themselves.

    val start : params -> unit
    (* or *)
    val callback : params ->
      ((allocation -> foo option) * (allocation -> bar option) * ... )

With an explicit record, it is easier for libraries to expose an
instrumentation choice (possibility parametrized over
user-provided settings):

    val tracker : params -> (foo, bar) Gc.Memprof.tracker

In addition, providing a record instead of optional parameters makes
it much easier to provide "default settings" (helper functions) that
instantiates the types `'minor` and `'ḿajor`, see for example
`simple_tracker` in this patch (which stores the same information for
the minor and major heap, and does not observe promotion), or to later
define checking predicates that can verify that a given choice of
callbacks is sensible (for example: providing a major-dealloc callback
but no promotion callback (dropping all tracked value on promotion) is
probably not a good idea).

Bootstrap: to avoid requiring an awkward bootstrap, this commit keeps
the (now unused) function caml_memprof_start_byt unchanged -- it is
used in the bootstrap binaries, so removing it would break the
build. The intention is to remove it in the following commit.
2020-04-01 16:37:28 +02:00
Jeremie Dimino 05c209f5c9 Move changelog entry for #9344's fix in 4.10 section
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2020-04-01 14:41:28 +01:00