Commit Graph

3269 Commits (3d6dc0fa645b2421f3cf16dcda6ec9cac2b3b76b)

Author SHA1 Message Date
Damien Doligez 85e4563b72 The best-fit allocator must prepare the heap for compaction. Fixes #9736 2020-07-15 11:53:46 +02:00
Xavier Leroy 0802bacf4b
Merge pull request #9551 from nojb/microbfd
Implement (in utils/binutils.ml) a simple parser for ELF, Mach-O and PE shared object files.  Use it to get rid of libbfd in ocamlobjinfo and to improve the checking of external primitives during linking in ocamlc.
2020-07-14 10:47:12 +02:00
Xavier Leroy 8948dabfc2 Add Changes entry for PR #9551 2020-07-14 10:43:35 +02:00
Stephen Dolan 523fba919b
Extend Printexc API for raw backtrace entries (#9663) 2020-07-13 11:13:12 +01:00
Damien Doligez 601819f923
Simplified compaction without page table (#9728)
Taking advantage of the new closure representation, this PR simplifies the compaction algorithm (3 passes instead of 4) and remove the use of the page table in no-naked-pointers mode.
2020-07-13 10:59:05 +02:00
Thomas Refis 4edc4b9928
pattern aliases do not ignore type constraints (#1655) 2020-07-09 12:20:37 +02:00
Gabriel Scherer fdf86ad403 matching: a first-order representation for match-failure handling 2020-07-08 22:38:47 +02:00
Florian Angeletti 3d45b6c280 Changes: instrumented runtime doc is in 4.11 2020-07-08 18:46:05 +02:00
Florian Angeletti f879c052b1
Merge pull request #9541 from Engil/instrumented_runtime_manual
Add a chapter for the instrumented runtime
2020-07-08 18:29:44 +02:00
John Whitington 0f2954b263 Fixes per travis check-typo and travis changes 2020-07-08 14:13:08 +01:00
Thomas Refis 167e66e15d
type_cases: rely on levels to enforce principality (#1931)
Instead of the erasure scheme that was used up to now, where we
considered that the type was always principal.

Note: the erasure still happens when polymorphic variants appear in the
patterns, and the type of the scrutinee contains a Reither.
2020-07-08 10:35:40 +02:00
Enguerrand Decorne cfb62e32fc update Changes entry for the instrumented runtime manual page 2020-07-08 03:13:56 +02:00
Enguerrand Decorne f3ee9e3beb add manual page for the instrumented runtime 2020-07-08 03:13:56 +02:00
Jacques Garrigue 46cec117a4
Fix #9721: Injectivity and recursive modules (#9727) 2020-07-07 09:04:23 +02:00
Stephen Dolan 088fa01b3e
Merge pull request #9688 from stedolan/main-compiler-libs
Expose the main entrypoint in compilerlibs
2020-07-06 13:03:02 +01:00
Jacques-Henri Jourdan 0616261642
Get rid of dead code that was introduced for an hypothetical JIT (#9710)
That code was never used and some of it is outdated.
2020-07-05 19:41:45 +02:00
David Allsopp bdb471287f
Merge pull request #9724 from MisterDA/fix-domain-state
Fix #9714 "Compilation failure in domain_state.h"
2020-07-03 13:38:57 +01:00
Florian Angeletti 75aa1ee0bc
Merge pull request #9712 from Octachron/version_format
New format for the OCaml version string
2020-07-03 10:20:20 +02:00
Gabriel Scherer 50806ced7f
Merge pull request #9216 from gasche/lambda-duplicate
extend Lambda.subst on bound variables, add Lambda.duplicate
2020-07-02 22:55:49 +02:00
octachron cd813bc1b0 Update version format 2020-07-02 16:47:03 +02:00
Leo White cbf58daf98 Add Changes entry 2020-07-02 13:20:47 +01:00
Antonin Décimo cb3af25721 Changes 2020-07-02 09:35:15 +02:00
Et7f3 c4851b0ff0
Consistently use @raise tags in Stdlib docs (#8644) 2020-06-30 14:06:45 +01:00
Stephen Dolan 34ead63bf7 Changes 2020-06-30 10:58:17 +01:00
Florian Angeletti 33b9b16dd7 Changes bookkeeping: 9556 is not in 4.11 2020-06-29 11:50:23 +02:00
Jacques Garrigue e0ec63ae21
Fix #8747: incorrect principality warning on functional updates of records (#9709) 2020-06-28 23:20:12 +02:00
octachron b212928e74 Fix Changes after backporting #9163 and #9537 2020-06-26 19:22:54 +02:00
Leo White 083fa6624b Add Changes entry 2020-06-26 12:37:07 +01:00
Leo White 6302b1e0cc
Merge pull request #9670 from lpw25/stat-full-major-collections
Report full major collections in Gc stats
2020-06-26 12:31:47 +01:00
Leo White 368eb16ee8
Treat loops properly in un_anf (#9163) 2020-06-26 09:51:30 +02:00
Florian Angeletti 7d3a3f8c24
Merge pull request #9416 from lpw25/fix-warning-58-flambda-ocamlnat
Avoid warning 58 in flambda ocamlnat
2020-06-26 09:37:41 +02:00
Florian Angeletti 1fb6a464a8
Merge pull request #9244 from lpw25/fix-usage-warnings
Fix usage warnings
2020-06-25 18:21:04 +02:00
Florian Angeletti 457304d075
Merge pull request #9673 from xvw/attempt-to-fix-6633
Add Hint when a module is used in place of a module type
2020-06-25 17:00:37 +02:00
Leo White 5e214047e0 Add Changes entry 2020-06-25 14:45:45 +01:00
Leo White 0734368f55 Add Changes entry 2020-06-25 14:24:41 +01:00
Thomas Refis 2d3bc0eb22
HACKING.adoc: using dune to get merlin's support (#9468)
Co-authored-by: Gabriel Scherer <gabriel.scherer@gmail.com>
2020-06-25 14:11:21 +02:00
Leo White fd2572289c Add Changes entry 2020-06-25 11:35:00 +01:00
Leo White 1f9be49f02
Merge pull request #9385 from lpw25/fix-copy-scope-bugs
Fix copy scope bugs
2020-06-25 10:59:59 +01:00
Nicolás Ojeda Bär 34dbc549b8
Merge pull request #9533 from bschommer/string-suffix-prefix
String suffix and prefix functions.
2020-06-24 17:39:32 +02:00
xvw 50848feb10 Add Hint when a module is used in place of a module type
Add hint when a module is used instead of a module type or when a
module type is used instead of a module or when a class type is
used instead of a class.
2020-06-24 14:37:03 +02:00
Gabriel Scherer 038fb85bac
Merge pull request #9702 from garrigue/fix9695
Fix #9695: no error when opening an alias to a missing module
2020-06-24 13:23:18 +02:00
David Allsopp 9be2c0111d Adjust Changes for #9011 2020-06-24 11:15:28 +01:00
David Allsopp 7b6098aa5f
Merge pull request #9011 from dra27/fix-msvc-empty-cmxa
Allow linking empty .cmxa files on MSVC
2020-06-24 11:06:52 +01:00
Bernhard Schommer e00d7f3a42
Added String prefix and suffix tests.
The functions test if the second argument is a prefix or suffix of the
first argument.
2020-06-24 12:01:55 +02:00
David Allsopp 20a9c4319a
Merge pull request #9558 from dra27/cross-ld
Always permit triplet-prefixed ld in PACKLD
2020-06-23 21:04:27 +01:00
Nicolás Ojeda Bär 7f0dbd4e65
ocamltest: show failing logs (#9696) 2020-06-23 20:47:38 +02:00
Jacques Garrigue ab83af0322 add example without -no-alias-deps 2020-06-23 18:37:37 +02:00
Jacques Garrigue 6ccab9b9b0 Fix #9695: no error when opening an alias to a missing module 2020-06-23 15:31:45 +02:00
Xavier Leroy 7e4ef62285 Changes entry for #9678 2020-06-22 19:38:02 +02:00
Xavier Leroy b18ac65d89
Remove Is_in_code_area and registration of code in page table (#9697)
Previously, code areas from native-code DLLs were registered in the page
table and could be queried with the Is_in_code_area macros.

Following commit e4bf109d1 (PR#9682), the runtime system no longer
queries the page table for code areas (it uses the table of code fragments
instead).

A grep through OPAM package sources shows no uses of Is_in_code_area macro
or the In_code_area flag for pages.

This commit simply removes the Is_in_code_area macro and the registration
of code areas in the page table.
2020-06-22 10:07:28 +02:00
Gabriel Scherer bdbf5c30fd
Update camlinternalMod and Obj.new_block for new closure representation (#9691)
* camlinternalMod: use closure metadata for copying a closure over another

This change is careful to avoid writing a value into what was
previously a raw field or conversely, clearing fields that change
category first.

We also clear the end of the block, to make it easier to reason about
lifetime of values that could have been referenced there. (We don't
expect this to make a different in practice.)

* Obj: new submodule Closure giving basic access to closure metadata

* Ensure that Obj.new_block returns a sensible uninitialized closure

* Changes
2020-06-19 17:41:08 +02:00
Xavier Leroy 0d1f7b208e
Generic hashing for the new closure representation (#9648, #9689)
This commit revises the generic hash functions to take advantage of
the new closure representation: code pointers are directly mixed
into the hash rather than having to be detected using Is_in_value_area.

Currently the new code for closures is activated only in no-naked-pointers
mode, even though it is sound in naked-pointers mode too.

Closes: #2168
2020-06-16 19:05:37 +02:00
Florian Angeletti cc647674d7 Changes: RISC-V has been backported to 4.11.0 2020-06-16 14:43:55 +02:00
Gabriel Scherer 58b3efda09
classify_addr.h: explain the no_naked_pointers value model (#9684)
We are planning to support two configurations (with or without
naked pointers) in the runtime for at least a couple years, so I think
it is useful to explain their value models and corresponding runtime
functions/macros. This should help runtime developers reason about the
code written to support both modes.
2020-06-16 11:16:02 +02:00
Jacques Garrigue 603506aa34
Add injectivity annotations (#9500) 2020-06-15 13:51:50 +02:00
Jacques Garrigue 24d087325c
Fix #7902: Type-checker infers a recursive type, even though -rectype… (#9556) 2020-06-15 10:26:26 +02:00
Xavier Leroy 400fe3f3a2
Merge pull request #9675 from xavierleroy/no-static-alloc
Remove the caml_static_{alloc,free,resize} primitives, which are unused and incompatible with no-naked-pointers mode.
2020-06-14 11:48:20 +02:00
Xavier Leroy 2ad3a038bb Changes entry for #9675 2020-06-14 11:46:43 +02:00
Xavier Leroy 791fe017df
Merge pull request #9655 from xavierleroy/obj-bits
Introduce type Obj.raw_data and functions Obj.raw_field, Obj.set_raw_field to manipulate out-of-heap pointers in no-naked-pointers mode, and more generally  all other data that is not a well-formed OCaml value
2020-06-14 11:44:04 +02:00
Xavier Leroy 0a2dacbd42 Changes entry for #9655 2020-06-14 11:42:26 +02:00
Nicolás Ojeda Bär 33416d11db
Merge pull request #9469 from lpw25/fix-lazy-backtraces
Better backtraces for lazy values
2020-06-14 11:34:04 +02:00
Leo White a15b97bc96 Add Changes entry 2020-06-14 08:30:34 +01:00
Leo White faa56c1934 Add Changes entry 2020-06-14 07:57:39 +01:00
Xavier Leroy 919803e09c Changes entry for #9649 2020-06-11 10:59:54 +02:00
Xavier Leroy 08e58c836e
More efficient management of code fragments (#9654)
* Introducing codefrag: a new runtime module to work with code fragments

This module collects all the operations on code fragments performed in
various places of the runtime systems.  Applies both to bytecode and
to native code.

The implementation is based on skiplists, so that "lookup fragment by
PC" and "lookup fragment by number" are efficient (logarithmic in the
number of code fragments).  "Lookup fragment by digest" remains
linear-time.

The new module also improves the handling of digests: now it is
possible to mark a code fragment as "no digest" i.e. not marshal-able.

* Use the new "codefrag" runtime module for marshaling and for the
  debugger interface

Replace the previous handling of code fragments with calls to the
functions provided by the "codefrag" runtime module.
2020-06-11 10:39:19 +02:00
Jacques-Henri Jourdan 7aad86fec4
Memprof: disable sampling when memprof is suspended. (#9628)
* Memprof: disable sampling when memprof is suspended.

* Changes.
2020-06-10 13:25:11 +01:00
Gabriel Scherer b7509ca82f
Merge pull request #9442 from gasche/tailcall-attribute-refactoring
[minor] refactoring the datatype for the [@tailcall] attribute
2020-06-10 10:18:12 +02:00
Florian Angeletti a1e3b966ea
Merge pull request #9618 from Octachron/format_documentation_precision
Document few Format quirks
2020-06-09 13:42:23 +02:00
Gabriel Scherer cc7d557b55 extend Lambda.subst on bound variables, add Lambda.duplicate
It is invalid to reuse a Lambda.t term twice, because bound variables
may be used non-uniquely. If we want to perform a code transformation
may duplicate subterms in some cases, we have to refresh all bound
variables of the copied subterm.

The present PR implements a function

    Lambda.duplicate : lambda -> lambda

that does exactly this. It is implemented by making Lambda.subst
parametrized over a transformation on bound variables.
2020-06-09 09:38:26 +02:00
Gabriel Scherer d260a79416 [refactoring] gives tailcall attributes a more standard structure
We want to start allowing more information in the payload of
[@tailcall] attributes (currently no payload is supported), for
example we could consider using [@tailcall false] to ask the code
generator to disable a tail call.

A first required step in this direction is to use a custom datatype to
represent the tail-call attribute, instead of a boolean. This is
consistent with the other application-site
attributes (inline_attribute, specialise_attribute, local_attribute),
so it makes the code more regular -- but the change itself is
boilerplate-y.
2020-06-08 15:39:50 +02:00
Xavier Leroy c61fc39caa
Merge pull request #9635 from xavierleroy/skiplists
Introduce a library of skip lists and use them to fix a performance issue in the debugger (issue #9606)
2020-06-08 15:19:29 +02:00
Xavier Leroy 4ce3b7ceba Add Changes for #9635 2020-06-08 14:12:53 +02:00
Nicolás Ojeda Bär 990bc3c892
Merge pull request #9633 from nojb/ocamltest_env_fix
ocamltest: do not overwrite user-defined variables
2020-06-08 13:17:38 +02:00
octachron 8875357638 review and change entry for #9618 2020-06-08 08:59:01 +02:00
Gabriel Scherer a3b66f1b32 Parmatch.exhaust: single-row optimization
(See testsuite and code comments for an explanation.)
2020-06-07 08:03:57 +02:00
Gabriel Scherer 06cabea1df
Merge pull request #9608 from trefis/rematch-flattening
pattern-matching refactoring: clarify usage of the Cannot_flatten exception
2020-06-06 21:58:33 +02:00
Gabriel Scherer f8bf8c3f6e Changes 2020-06-06 18:46:34 +02:00
Gabriel Scherer 63eb3dad0d Arg: a new Rest_all spec, similar to Rest, that passes all arguments at once
In particular this allow to detect a Rest_all keyword followed by no
arguments at all (an empty list).
2020-06-05 22:06:21 +02:00
Gabriel Scherer 357d624992
Merge pull request #9642 from garrigue/fix9640
Fix #9640: regression introduced by #9623
2020-06-05 21:10:55 +02:00
Xavier Leroy 4aa90e9784
Limit the number of parameters for an uncurried or untupled function (#9620)
This commit introduces a quantity Lambda.max_arity that is the maximal
number of parameters that a Lambda function can have.

Uncurrying is throttled so that, for example, assuming the limit is 10,
a 15-argument curried function fun x1 ... x15 -> e
becomes a 10-argument function (x1...x10) that returns a 5-argument
function (x11...x15).

Concerning untupling, a function that takes a N-tuple of arguments,
where N is above the limit, remains a function that takes a single
argument that is a tuple.

Currently, max_arity is set to 126 in native-code, to match the new
representation of closures implemented by #9619.  A signed 8-bit field
is used to store the arity.  126 instead of 127 to account for the
extra "environment" argument.

In bytecode the limit is infinity (max_int) because there are no needs
yet for a limit on the number of parameters.
2020-06-05 18:45:38 +02:00
Xavier Leroy 59da2292b1 Changes entry for #9619 2020-06-05 17:52:42 +02:00
Jacques Garrigue 6a47e31dcb update PR number 2020-06-05 15:00:08 +02:00
Jacques Garrigue a96a610a95 Fix #9640: regression introduced by #9623 2020-06-05 14:56:51 +02:00
Florian Angeletti ae5eb6b471
Merge pull request #9610 from xavierleroy/manual-intf-c
FFI documentation: naked pointers are obsolete
2020-06-05 07:57:52 +02:00
octachron 635cc46dc4 Change entry for #9610 2020-06-05 07:55:52 +02:00
Nicolás Ojeda Bär b7656007a8 Changes 2020-06-05 07:48:17 +02:00
Gabriel Scherer a8a2a7b757
Merge pull request #9634 from nojb/ocamlrunparam_comma_fix
Allow ',' at the start of OCAMLRUNPARAM
2020-06-05 07:12:40 +02:00
Gabriel Scherer 42b64a7dc7 minor Changes fix 2020-06-04 18:38:05 +02:00
Gabriel Scherer 84c87bb8f1
Merge pull request #9623 from gasche/unboxed-merge-constraint
fix an environment problem in merge_constraint
2020-06-04 13:16:27 +02:00
Nicolás Ojeda Bär 9ea385d917 Changes 2020-06-04 09:37:31 +02:00
Jacques Garrigue abb8db459d
Fix #7520: Odd behaviour of refutation cases with polymorphic variants (#9547) 2020-06-03 17:47:12 +02:00
Jacques Garrigue 97c3be20c7 add PR number for #7741 2020-06-03 17:33:49 +02:00
Jacques Garrigue 13a081b04e
Fix #7741: Failure to report escaping type variable (#9545) 2020-06-03 17:31:38 +02:00
Gabriel Scherer 7068266b32 Typemod.merge_constraint: be careful about the typing environments
This PR fixes an old bug in the interaction between [merge_constraint]
and [Typedecl.transl_with_constraint], where
variance (and now separability) are recomputed in an invalid type
environment. See #9624 and the new tests.
2020-06-03 14:33:50 +02:00
Nicolás Ojeda Bär 836d62470b
Fix load path ordering (#9611) 2020-06-03 00:10:38 +02:00
Jacques Garrigue ee20f5e648
Fix the polymorphic recursion problem of #9603 (#9617) 2020-06-02 22:05:30 +02:00
Stephen Dolan fd1bb255e1 More partial application warnings 2020-06-02 12:11:41 +01:00
Stephen Dolan a8e2f2b170
Unbox result of Unix.gettimeofday in unix and win32unix (#9561)
This patch makes Unix.time and Unix.gettimeofday be unboxed and @noalloc, which makes them about 20% faster (as measured by a stupid benchmark that does them many times in a loop).

This removes the fallback and error-handling paths from gettimeofday.  Neither is needed according to Single Unix Specification and POSIX.

Fixes: #7446
2020-06-02 11:05:57 +02:00
Florian Angeletti 180a91f5d5
Merge pull request #9580 from stedolan/stdlib-doc-fix
Ensure stdlib documentation index refers to Stdlib
2020-06-02 11:01:17 +02:00
Nicolás Ojeda Bär 973eeb1867
Add Val_some,Val_none,Some_val, Is_none, Is_some, Tag_some (#9569)
Closes: #5154
2020-06-01 19:31:47 +02:00
Xavier Leroy 4bf7a79137
Turn debugger off in programs launched by the program being debugged (#9594)
* Undefine the CAML_DEBUG_SOCKET variable early

So that if the debugged program creates or executes another program
that happens to be an OCaml bytecode executable, said program does
not try to connect to the debugger at beginning of execution.

Fixes: #8678

* Check availability of setenv() and unsetenv()

And guard the use of unsetenv() in runtime/debugger.c.
2020-06-01 19:10:12 +02:00
Stephen Dolan 9b6e6203c1 changes entry 2020-06-01 14:57:44 +01:00
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 f8e24bda0c Changes entry 2020-05-30 17:11:54 +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 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
Greta Yorsh 21f04a4019 Update Changes 2020-05-27 17:01:20 +01: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
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
David Allsopp 643d1af004 Map ERROR_PRIVILEGE_NOT_HELD to EPERM 2020-05-25 16:55:50 +01:00
Jacques Garrigue 1bb388bd15
Fix PR#7817: Unsound inclusion check for polymorphic variant (#9546) 2020-05-25 19:12:09 +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
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
Gabriel Scherer 229df94da5 Changes 2020-05-14 10:28:42 +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
David Allsopp 9c0412f41a Always permit triplet-prefixed ld in PACKLD
Fixes #7121
2020-05-13 10:21:46 +01: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
Gabriel Scherer 4943a373f3
Merge pull request #9464 from gasche/rematch-exceptionless-matcher
pattern-matching refactoring: simplify `Default_env.specialize_matrix` by avoiding exceptions
2020-04-23 12:18:13 +02:00
Leo White 00a0c5a975 Add Changes entry 2020-04-23 10:51:44 +01:00
Thomas Refis 9f49a71e90
Add forgotten substitution when compiling anonymous modules (#9477)
Fixes #9375
2020-04-23 10:55:40 +02:00
Gabriel Scherer 6e153b1e71 matching: remove the OrPat exception by handling Tpat_or on the caller side
(This commit is more tricky than the previous ones in the patchset
and requires a careful review.)

This refactoring clarifies and simplifies the specialize_matrix logic
by getting rid of the OrPat exception used in a higher-order
way (or sometimes not used in certain matchers, when it is possible to
"push" the or-pattern down in the pattern). Instead it uses an
arity-based criterion to implement the or-pattern-related logic once
in the specializer, instead of having to implement it in each
matcher. As a result, the compiler improves a bit as it will push
or-patterns down during specialization in valid situations that were
not implemented before -- probably because they are not terribly
important in practice: all constant and arity-1 constructs benefit
from optimized or-pattern handling, in particular the following are
new:
- lazy patterns
- non-constant polymorphic variants
- size-one records and arrays
2020-04-22 21:32:38 +02:00
Damien Doligez ea4542d819 first commit after branching 4.11.0 2020-04-22 17:33:19 +02:00
Damien Doligez e92d13c986 last commit before branching 4.11 2020-04-22 17:28:08 +02:00
David Allsopp e6ab329541 Don't call the archiver/librarian for empty .cmxa 2020-04-22 14:56:02 +01:00
Xavier Leroy 83598da1ab
Merge pull request #9392 from stedolan/visit-once
Visit registers at most once in Coloring.iter_preferred.
2020-04-22 09:38:08 +02:00
David Allsopp a7dbb977de
Merge pull request #8631 from dra27/unify--c
Use same cflags and cppflags for ocamlc -c and ocamlopt -c (#7678)
2020-04-21 14:15:54 +01:00
Stephen Dolan d5dadae8ed
Make Cconst_symbol have typ_int to fix no-naked-pointers mode (#9282) 2020-04-21 12:06:19 +01:00
David Allsopp f4dc3003d5
Merge pull request #9457 from dra27/fix-mod_use
Fix #mod_use in toplevel
2020-04-20 16:13:26 +01:00
David Allsopp 515030352a Move Changes entry 2020-04-20 15:29:49 +01:00
Greta Yorsh 0ba942cb29 Add an entry to Changes 2020-04-20 13:59:09 +01:00
Florian Angeletti c5a1f91900
Merge pull request #9345 from Octachron/reproducible_env
Reproducible env summaries
2020-04-20 14:20:57 +02:00
Gabriel Scherer 702e34fbe5
Merge pull request #9463 from lthls/fix_int64_cmm_typ
Fix Cmm type of unboxed integers in Clet_mut
2020-04-20 11:34:15 +02:00
Florian Angeletti c041b0389e env summary: don't record implicit cmi files
We don't want to record the state of the file system at the start
of the compilation in the compiled files.
Consequently, we only add persistent modules to the env summary
if they have an observable action on the initial environment.
This is only the case if they shadow a non-persistent module of the
initially opened library (which can only be Stdlib currently).
2020-04-20 10:13:20 +02:00
Thomas Refis 0d92d18e61
Merge pull request #9411 from trefis/type_args-merge-sargs
forbid optional arguments reordering with -nolabels
2020-04-18 13:01:51 +02:00
Gabriel Scherer 5c0e138bb4 Changes entry 2020-04-18 11:43:09 +02:00
Xavier Leroy da12974492
Turn off PIE for musl-based Linux on platforms other than amd64 and s390x (#9456)
Alpine Linux and perhaps other musl-based Linux distributions produce
position-independent executables (PIEs) by default.  If non-PIC object
files are given to the linker, it silently produces a wrong executable
that crashes when run.  This is the case for ocamlopt-generated code,
which by default is not PIC except on amd64 (x86_64) and s390x (Z systems).

Closes: #7562
2020-04-18 11:16:23 +02:00
Thomas Refis a321395fca Further Changes 2020-04-18 11:09:32 +02:00
Thomas Refis 73a3f9083e Changes 2020-04-18 11:02:09 +02:00
Leo White a40889d6d9
Merge pull request #9393 from lpw25/improve-recmodule-usage-warnings
Improve recursive module usage warnings
2020-04-18 09:11:22 +01:00
Leo White 2c8f99e0ba Add Changes entry 2020-04-18 08:10:52 +01:00
Leo White 6dcb77077a Add Changes entry 2020-04-18 07:56:44 +01:00
Leo White adc354c167
Merge pull request #9452 from lpw25/add-locations-to-docstring-attributes
Add locations to docstring attributes
2020-04-17 22:30:36 +01:00
David Allsopp 5abff44a3f Fix #mod_use in toplevel
Regression from #9283.

Fixes #9455
2020-04-17 16:14:01 +01:00
Gabriel Scherer 9568154248
Merge pull request #9389 from Anukriti12/trunk
call_linker now returns exit_code for better user response on linking_error, fixes #7141
2020-04-17 17:05:56 +02:00
Florian Angeletti 9108648867
Merge pull request #9409 from Octachron/yet_another_implicit_deps_error
packed modtype lookup can fail due to missing cmi
2020-04-17 16:28:19 +02:00
David Allsopp c29450548a
Merge pull request #9057 from dra27/debugging-the-debugger
Aid debugging the debugger
2020-04-17 12:15:34 +01:00
Leo White a5da4162b1 Add Changes entry 2020-04-17 11:20:10 +01:00