Commit Graph

2997 Commits (3d63a106b678f54c47698f11db7d810d91d442ec)

Author SHA1 Message Date
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
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
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 2fe16774cb Add Changes entry 2020-05-19 19:21:18 +02:00
Jeremy Yallop 8ce5231e3b Fix Changes formatting (tabs, line length). 2020-05-19 10:17:35 +01:00
KC Sivaramakrishnan bd1b4b7a41
Add a header macro for out-of-heap blocks (#9564)
It can be used to construct statically-allocated, out-of-heap blocks that the GC will not traverse.
2020-05-19 11:07:26 +02:00
Nicolás Ojeda Bär 7bf6a78427 Changes 2020-05-18 09:33:15 +02:00
Guillaume Munch-Maccagnoni abe982165b Fix data race in at_exit and Printexc.register_printer with systhreads 2020-05-16 22:57:34 +02:00
Gabriel Scherer 04d9c425f3 stdlib: provide a sequential interface of the Atomic module from OCaml Multicore
This module provides a purely sequential implementation of the
concurrent atomic references provided by the Multicore OCaml
standard library:

https://github.com/ocaml-multicore/ocaml-multicore/blob/parallel_minor_gc/stdlib/atomic.mli

This sequential implementation is provided in the interest of
compatibility: when people will start writing code to run on
Multicore, it would be nice if their use of Atomic was
backward-compatible with older versions of OCaml without having to
import additional compatibility layers. *)
2020-05-16 17:51:54 +02:00
Sébastien Briais f52fdc2068
Define to_rev_seq in Set and Map module (#9075) 2020-05-15 17:38:45 +02:00
Xavier Leroy 914dd057b5
win32unix: quote the arguments to the Unix.exec* functions (#9550)
Otherwise, arguments get split at spaces.
This is the same quoting that the Win32 implementation of
Unix.create_process does.

A test was added.

Fixes: 9320
2020-05-14 18:15:10 +02:00
Florian Angeletti 1a8a4dfd85
Merge pull request #9552 from Octachron/forgotten_ocamloptp
Restore ocamloptp
2020-05-14 16:10:05 +02:00
octachron 0963b0c6b6 Restore ocamloptp 2020-05-14 10:11:42 +02:00
Gabriel Scherer b3434751e2
Merge pull request #9520 from trefis/rematch-make_matching-cleanup
pattern-matching refactoring: refactor the `make_<foo>_matching` functions
2020-05-14 09:21:07 +02:00
Nicolás Ojeda Bär ea835ee45e Changes 2020-05-13 20:57:21 +02:00
Xavier Leroy c17f6c2956
Protect against bad rounding of mtime / atime / ctime stats (#9505)
Some file systems maintain time stamps with sub-second resolution, up
to nanosecond resolution.  When converting from a "(seconds, nanoseconds)"
timestamp to a floating-point timestamp, rounding to nearest can produce
"seconds + 1" as a result, i.e. the integer part of the FP timestamp
is not equal to "seconds".  As described in #9490, this is a problem
in some cases.

This commit implements a more careful conversion of "(seconds,
nanoseconds)" pairs to FP timestamps so that the integer part of the
FP result is always "seconds".

Both the otherlibs/unix and the otherlibs/win32unix implementations are affected
and corrected.

Closes: #9490
2020-05-13 18:43:46 +02:00
David Allsopp b6c8b35e2d
Make -flarge-toc the default for PowerPC (#9557)
Introduce -fsmall-toc in order to access the previous behaviour and
document both options in the manual and ocamlopt manpage.
2020-05-13 18:23:37 +02:00
Gabriel Scherer 065139617f matching: factorize the make_*_matching functions
Before, each head construction had a `make_<foo>_matching` construct that
was responsible for three things:
- consuming the argument from the argument list
  (the "argument" is a piece of lambda code to access
   the value of the current scrutinee)
- building arguments for the subpatterns of the scrutinee
  and pushing them to the argument list
- building a `cell` structure out of this, representing a head group
  during compilation

Only the second point is really specific to each construction.

This refactoring turns this second point into a construct-specific
`get_expr_args_<foo>` function (similarly to `get_pat_args_<foo>`),
and moves the first and third point to a generic `make_matching`
function.

Note: this commit contains a minor improvement to the location used to
force (lazy ..) arguments.
2020-05-13 17:18:08 +02:00
Xavier Leroy 3a408ff3e8
Modernize signal handling on Linux i386, PowerPC64, and s390x (#9543)
OCaml's signal handlers need to know the state of the processor when the signal was received. The approach standardized by the Single Unix specification is to use 3-argument signal handing functions and the SA_SIGINFO flag to sigaction. However, as the Linux man page for sigaction says,

Undocumented:
Before the introduction of SA_SIGINFO, it was also possible to get some
additional information, namely by using a sa_handler with a second
argument of type struct sigcontext. See the relevant Linux kernel
sources for details. This use is obsolete now.

For historical reasons, the i386, PowerPC and s390x Linux ports of OCaml still use the undocumented, obsolete approach, while the other Linux ports use the modern SA_SIGINFO approach. 

For consistency and future-proofing, this PR updates the i386, PowerPC64, and s390x Linux ports to use the modern approach to signal handling.  PowerPC32 was left as before because of technical subtleties and lack of hardware to test changes.

The new code for PowerPC 64 bits includes the trick proposed in PR#1795 to support Musl in addition to Glibc on ppc64le.
2020-05-13 11:15:13 +02:00
Jacques-Henri Jourdan aa64e70bc1 Changes 2020-05-11 15:56:13 +02:00
Florian Angeletti c86a5d8d11
#9189: avoid one-letter make variables (#9281) 2020-05-11 12:21:59 +02:00
Gabriel Scherer 3a43b84e8a compare: correctly compare a Closure_tag with an Infix_tag 2020-05-06 22:29:01 +02:00
Gabriel Scherer ffbea08d02 Changes entry 2020-05-06 12:10:02 +02:00
Xavier Leroy f2587c1fb1
Merge pull request #9529 from dra27/macos-gnu-make
Further C dependency fixes
2020-05-06 09:53:45 +02:00
octachron 273f2f8c7d Changes: move 9228 to 4.11.0 section 2020-05-05 15:12:42 +02:00
David Allsopp d4009ac4e3 Move 9437 to 4.10 2020-05-05 10:13:23 +01:00
David Allsopp 21654fcbf2 Move Changes entry for 9531 to 4.10 2020-05-04 14:28:48 +01:00
Hannes Mehnert 3f7e56c40d
configure: support bfd on FreeBSD (#9531)
On FreeBSD, libbfd is - similarly to OpenBSD - not installed by default, but
can be added via the devel/libbfd port. This will install libbfd into the
/usr/local prefix, thus configure needs to look there for include and library
2020-05-04 14:26:32 +01:00
Florian Angeletti 24806a0223
Merge pull request #9228 from yallop/map-documentation
Fix some issues in the Map documentation
2020-05-04 09:49:53 +02:00
David Allsopp 312ec987b6 Update Changes 2020-05-03 17:07:17 +01:00
KC Sivaramakrishnan 9355b4e8f5
Initialise in caml_obj_block / Obj.new_block only when necessary (#9513)
caml_alloc returns initialised blocks for tag < No_scan_tag. Otherwise,
initialise the blocks as necessary.

For Abtract_tag, Double_tag and Double_array_tag, the initial contents
are irrelevant.

Uninitialised Custom_tag objects are difficult to use correctly. Hence,
reject custom block allocations through Obj.new_block.

For String_tag, the last byte encodes the string length. Hence, reject
zero-length string objects. Initialise the last byte which encodes the
length to ensure non-negative lengths for uninitialised strings.
2020-05-02 18:47:16 +02:00
Gabriel Scherer 876af2567e
Merge pull request #9493 from trefis/rematch-matcher-unification
pattern-matching refactoring: merge the two matchers
2020-05-02 08:46:50 +02:00
Gabriel Scherer ae4621c03c Changes 2020-05-01 21:56:15 +02:00
David Allsopp c8dcbac5c9 Update Changes entry 2020-05-01 11:19:26 +01:00
Jeremy Yallop afe681cc16 Fix some issues in the Map documentation:
- Add the key argument in the description of 'merge'
  - Note that the keys of 'union f m1 m2' are a subset of the
    input keys, not all the keys, since

        bindings (union (fun _ _ _ -> None) m m) = []

  - Fix grammar in the descriptions of 'filter', 'union', 'merge'
  - Fix mismatched variable name in the description of 'partition'
  - Note that 'find' and 'find_opt' return values, not bindings
2020-04-30 16:10:00 +01:00
Enguerrand Decorne b7f0494df5 Rewrite the instrumented runtime to store traces in the CTF format.
The instrumentation code in the instrumented runtime was replaced
with new APIs to gather runtime statistics and output them in a new format
(Common Trace Format).
This commit also exposes new functions in the Gc module to pause or resume
instrumentation during a program execution (Gc.eventlog_pause and
Gc.eventlog_resume).
2020-04-30 10:32:01 +02:00
Jeremy Yallop 2e30946419
Support marshalling of bigarrays with dimensions that don't fit in 4 bytes (#8791)
Use a variable-length encoding (suggested by @stedolan) for dimensions that supports dimensions up to 2^64-1 each.

Change the marshalling identifier for bigarrays:_bigarray ~> _bigarr02
The identifier change reflects a change in the bigarray marshalling format.
2020-04-29 18:51:01 +02:00
Hannes Mehnert ec24f98bec
remove caml_init_ieee_floats() (#9506)
This used to call fpsetmask(0) on FreeBSD systems (< 4). FreeBSD 4 is not
anymore supported since 2007, it is safe to remove this code now.
2020-04-28 16:19:23 +02:00
Leo White f6e5592965
Merge pull request #9246 from lpw25/avoid-rechecking-functor-applications
Avoid rechecking functor applications
2020-04-28 12:04:47 +01:00
Stephen Dolan fa037cb0d6 Changes 2020-04-27 12:58:53 +01:00
Anarchos abfd5d87bb
Compiling for Haiku OS: network functions reside in libnetwork (#9486)
Compiling for Haiku : network functions reside in libnetwork
2020-04-27 10:36:28 +01:00
Xavier Leroy 080ac7421c
Update documentation for the Thread module and deprecate some functions (#9419)
- Deprecate Thread.kill, Thread.wait_read, Thread.wait_write
  for reasons explained in the documentation comments.
- Update documentation comments for Thread functions.
- Deprecate ThreadUnix module, documented as deprecated since 2002
  (commit 0a47a75d56).
- In the manual, remove leftover mentions of the VM threads
  implementation; focus on the system threads implementation.
- In the manual, remove the documentation of ThreadUnix.

Closes: #9206
2020-04-25 19:13:34 +02:00
Xavier Leroy 68c6f89409
Use diversion when calling external tools with a very long argument list (#9492)
It's not just on Windows that the length of the command passed to Sys.command
can exceed system limits:
- On Linux there is a per-argument limit of 2^17 bytes
  (the whole command is a single argument to /bin/sh)
- On macOS with default parameters, the limit is between 70000 and 80000
- On BSDs with default parameters, the limit is around 2^18.

In parallel, response files (@file) are supported by all the C compilers
we've encountered: GCC, Clang, Intel's ICC, and even CompCert.  They all
seem to follow quoting rules similar to that of the native shell
for the contents of the response file.

This commit forces the use of a response file when the total size of
the arguments to the linker is greater than 2^16.

Arguments passed via a response file are quoted using Filename.quote
as if they were passed on the command line.

Closes: #9482
Closes: #8549
2020-04-25 19:09:35 +02:00
Nicolás Ojeda Bär 1e98c52e93
Link std_exit.cmo into binaries compiled with -output-complete-exe (#9495) 2020-04-25 13:01:03 +02:00
Mark Shinwell df20ccf838 Fix recursive module initialisation that does not terminate (#9497)
This fixes the bug reported in issue 9494 and adds a test case.

Closes: #9494 
(cherry picked from commit ff98901d11fb01ba224772c402763df20d246635)
2020-04-24 17:50:19 +02:00
Leo White fdc21de7ca Add Changes entry 2020-04-24 16:37:14 +01:00
Nicolás Ojeda Bär 1eb26aefba Move Changes entry to the right place 2020-04-24 17:28:14 +02:00
Nicolás Ojeda Bär 8f3833c4d0
Add RISC-V native-code backend (#9441)
This is a port of ocamlopt for the RISC-V processor in 64-bit mode.
2020-04-24 16:04:50 +02:00
madroach 82700678b2
Don't include stdio.h in caml/misc.h (#9483)
* Don't include stdio.h in caml/misc.h
There is no need to include stdio.h in caml/misc.h
This seems to have happened by accident in commit cddec18fde
On OpenBSD, stderr and stdout are macros defined in stdio.h
ppx_expect uses stderr and stdout as identifiers in
collector/expect_test_collector_stubs.c where caml/misc.h is included.
This confuses the C compiler, because the macro will get expanded where an identifier is expected.

* Remove fallback NULL definition in caml/misc.h

ISO C guarantees that NULL is defined in <stddef.h>

* include missing stdio in tests/compatibility/stub.c
2020-04-24 14:27:32 +02:00
Leo White 2a50fef1ae
Merge pull request #9415 from lpw25/fix-open-struct-in-flambda-toplevel
Treat `open struct` as `include struct` in toplevel
2020-04-23 14:00:24 +01:00