Commit Graph

2207 Commits (master)

Author SHA1 Message Date
Sébastien Hinderer bdd9ca391e Add the $(EXE) suffix to all programs at build rather than install time
This commit touches neither boot/ocamlc nor boot/ocamllex

It has the side-effect of fixing the cleanup rules which did not use the
$(EXE) extension when removing a file although it was produced with the
$(EXE) extension.
2020-06-18 11:16:55 +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
Gabriel Scherer f333db8b0f
Merge pull request #9662 from gadmm/fix-dune-build
Fix dune build after using Atomic in Stdlib
2020-06-11 21:43:09 +02:00
Sébastien Hinderer b94a3776a0
Remove temporary installation hacks (#9659)
* Remove temporary hack related to the Num library

This is a follow-up to commit 3de0115bfe

* Also do some cleanup in stdlib/Makefiile
2020-06-10 16:42:53 +02:00
Xavier Leroy ec33006c0a Add type Obj.raw_data and functions Obj.raw_field, Obj.set_raw_field
Some OCaml objects contain data that cannot be safely represented
as an OCaml value (type Obj.t).  For example, in no-naked-pointers mode,
this is the case for code pointers inside closures, and for the
"custom operations" pointers inside custom blocks.

This PR introduces a type Obj.raw_data (an alias for nativeint)
to encapsulate this data, and functions
Obj.raw_field / Obj.set_raw_field to read and write the "raw" contents
of fields of blocks.

Note: just like it is wrong to access code pointers and custom operations
using Obj.field / Obj.set_field, it is wrong to access regular fields
possibly containing pointers into the OCaml heap using
Obj.raw_field / Obj.set_raw_field.  The OCaml heap block can be
reclaimed or moved after its address was captured by Obj.raw_field.
Symmetrically, Obj.set_raw_field on a regular field bypasses the
write barrier of the GC.
2020-06-10 16:29:37 +02:00
Guillaume Munch-Maccagnoni 3a1901d873 Fix dune build
Introduce CamlinternalAtomic since Stdlib cannot refer to
Stdlib__-prefixed modules without breaking the dune build.

No change entry needed.
2020-06-10 14:29:21 +02:00
octachron 8875357638 review and change entry for #9618 2020-06-08 08:59:01 +02:00
octachron 99f0910081 format: document structural box quirk 2020-06-08 08:58:25 +02:00
octachron b6ba1823c0 format: comment max indent induced line splits 2020-06-08 08:47:39 +02:00
octachron 982d4a378e Format: margin documentation precision 2020-06-08 08:47:39 +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
Xavier Leroy 5890df0ad1 Update documentation of Digest module
State more clearly that MD5 is not cryptographically secure.
2020-05-18 11:33:06 +02:00
Guillaume Munch-Maccagnoni 1e4eea19ef Make at_exit forward-compatible with multicore 2020-05-16 22:58:07 +02:00
Guillaume Munch-Maccagnoni a469b4d0af Implement at_exit with Atomics
Atomic becomes a dependency of Stdlib
2020-05-16 22:58:07 +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
Nicolás Ojeda Bär 4a44bf1767 Expose %loc_FUNCTION as __FUNCTION__ 2020-05-13 20:57:21 +02:00
Christophe Troestler c920ea142b
Fix comment about NaN propagation (#9536)
Fix documentation comment about NaN propagation

Closes: #7891

Co-authored-by: David Allsopp <david.allsopp@metastack.com>
2020-05-12 15:35:04 +02:00
Florian Angeletti c86a5d8d11
#9189: avoid one-letter make variables (#9281) 2020-05-11 12:21:59 +02:00
Gabriel Scherer fd789b5cec [minor] stdlib/Makefile: remove redundant clean action
There is already a more precise

    clean::
            rm -f $(CAMLHEADERS)

rule above.

(Change suggested by David Allsopp.)
2020-05-06 12:10:02 +02:00
Gabriel Scherer fab58a938a makefiles: move the inclusion of Makefile.build_config in Makefile.common 2020-05-06 12:10:02 +02: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
Josh Berdine a282c170f9
Update stdlib/ephemeron.mli
Co-authored-by: David Allsopp <david.allsopp@metastack.com>
2020-05-03 00:25:54 +01:00
Josh Berdine 5e2b28decc Fix ephemeron documentation typos
Signed-off-by: Josh Berdine <josh@berdine.net>
2020-05-02 22:46:48 +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
Edwin Török f66e395c70 Fix docs: runtime warnings are not enabled by default
The docs on this are out of date: they say runtime warnings are enabled by
default, but the source code has a commit 6c90da4 pointing to
https://github.com/ocaml/ocaml/pull/210 that disables them by default.

It seems like enabling runtime warnings by default never made its way into a
release and the docs could just be updated to say that runtime warnings are
disabled by default.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
2020-04-27 21:38:58 +01:00
Stephen Dolan 0040c5d783 Print function names (derived from Lambda.scoped_location) in backtraces
Function names now appear in backtraces and are available via Printexc.
2020-04-27 12:58:53 +01: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
Greta Yorsh b823c8d8fc Remove stray newlines 2020-04-20 13:56:53 +01:00
Greta Yorsh 7271919a47 Check FLAMBDA in Makefile.common.in to update OPTCOMPFLAGS 2020-04-20 13:56:53 +01:00
Greta Yorsh 44af4aea7c Check FUNCTION_SECTIONS in Makefile.common.in to update OPTCOMPFLAGS 2020-04-20 13:56:53 +01:00
Greta Yorsh 7465e9f2c7 Define OPTCOMPFLAGS in Makefile.common.in 2020-04-20 13:56:53 +01:00
David Allsopp 3a40b2fd94 Introduce Makefile.build_config.in
This moves the configure-generated parts of Makefile.common to a
separate (generated) Makefile, allowing Makefile.common to be a normal
Makefile.

OCaml's build system Makefile's now include Makefile.build_config (which
itself includes Makefile.config) but Makefile.config is still installed
as before. This allows configure to generate variables which are
specific to the build process and are not intended to be exported to the
installation.
2020-04-17 13:53:49 +01:00
David Allsopp 13786d7d12 Ensure make distclean works on an unconfigured tree 2019-10-15 11:46:36 +01:00
David Allsopp d4a566573f Allow make to be invoked before configure
This should be improved to give better warnings for when Makefile.config
and Makefile.common are required.
2018-12-04 10:28:36 +00:00
Guillaume Munch-Maccagnoni b1fdc44547
Install a pretty printer for the Fun.Finally_raised exception (#9266) 2020-04-13 19:09:47 +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 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
Gabriel Scherer 1cd6e4451f Map.filter_map and Set.filter_map 2020-03-31 15:01:41 +02:00
muskangarg21 4019c33aaa
Stdlib: added Printf.ikbprintf, Printf.ibprintf (#9364) 2020-03-26 14:28:00 +01:00
David Allsopp e4f3aa8c81 Don't assume . in AWKPATH
Ensure all script invocations explicitly refer to a directory.
2020-03-20 09:38:33 +00:00
zapashcanon 75bc37d4d9
fix doc comment for seq type 2020-03-19 21:39:06 +01:00
zapashcanon a8a3c55b18
fix doc comment for unit type 2020-03-18 20:22:08 +01:00
Sébastien Briais cc4a075e9b
Define Seq.cons and Seq.append. (#9077)
* Define Seq.cons and Seq.append.
2020-03-06 09:26:38 +01:00
Glenn Slotte 4823934182
Document base case of List.for_all and List.exists (#9325)
* Document the base case (`[ ]`) of List.for_all and List.exists
2020-02-26 09:51:01 +01:00
Gabriel Scherer b237282e97 Merge pull request #9270 from gadmm/doc_stack_overflow
Documentation: Stack_overflow is reliable, Out_of_memory is not.
(cherry picked from commit 84f62eee5d26efb936cde0e799b7aaa39e46c010)
2020-01-29 11:08:57 +01:00
Raphael Sousa Santos c9d7cc7da4 Add Printexc.default_uncaught_exception_handler (issue #9248)
Printexc.uncaught_exception_handler ceases to be an option ref and becomes
a ref to the handler function initialized to
Printexc.default_uncaught_exception_handler.
2020-01-26 12:00:27 +01:00
Gabriel Scherer 82d7971b4f
Merge pull request #9237 from gasche/format-update-geometry
Format.pp_update_geometry: formatter -> (geometry -> geometry) -> unit
2020-01-15 22:37:37 +01:00
Jeremy Yallop 73a37d45f8 Add Seq.unfold. 2020-01-15 15:38:46 +00:00
Armaël Guéneau 390d4e3ce5
Merge pull request #9227 from yallop/bool-identity
Make Bool.to_int primitive.
2020-01-15 13:27:29 +01:00
Gabriel Scherer bc574f542e [minor] Format: factorize check_geometry to avoid invariant duplication 2020-01-14 16:26:21 +01:00
Gabriel Scherer c41b282899 Format.pp_update_geometry: formatter -> (geometry -> geometry) -> unit
This lets users write code that is robust to the addition of new
geometry fields.

    Format.(pp_update_geometry ppf (fun geo -> {geo with ...}))

Today the only way to set the geometry is

    Format.pp_set_geometry ppf ~margin ~max_indent

we cannot add optional parameters after the [ppf] argument, and adding
new labeled parameters would break user code.

(Also: it's often convenient to work with the record directly, for
example to reset a previous geometry saved with [pp_get_geometry];
this is indirectly provided by [pp_update_geometry].)
2020-01-14 16:26:21 +01:00
Gabriel Scherer 87b027d9ec [minor] fix an indentation mistake in Format.pp_set_geometry 2020-01-14 16:23:18 +01:00
Jacques-Henri Jourdan e1a22e80fb Memprof API: cannot be start if already running, cannot be stopped if not already running. 2020-01-14 10:42:16 +01:00
Jeremy Yallop 38eb6d5f64
Add Array.for_all2 and Array.exists2 (#9235)
* Partially revert "Removed for_all2, exists2 and find again."

This partially reverts commit 83dcf62ebf.

(Restore for_all2 and exists2.)

* Partially revert "Fixed typos and changed exists2 and for_all2."

This partially reverts commit 7a082785be.

* Array.(for_all2,exists2): simplify documentation; add @since annotations

* Changes: remove trailing whitespace
2020-01-13 13:52:39 +00:00
Jacques-Henri Jourdan 0c8416478c Drop support for tags in memprof.
They are somewhat difficult to handle for native allocations, and it is not clear how useful they are. Moreover, they are easy to add back since [Gc.Memprof.allocation] is a private record.
2020-01-11 13:19:10 +01:00
Jeremy Yallop 37a6919ae2 Make Bool.to_int primitive. 2020-01-07 09:32:29 +00:00
hhugo 475df06021 stdlib: cleanup in Char.ml by using char range patterns (#9221)
stdlib/char.ml: [minor] use range patterns for {lowercase,uppercase} functions
2020-01-04 15:15:52 +01:00
Nicolás Ojeda Bär 55d286505c Merge pull request #9217 from kit-ty-kate/fix-doc-filename-null
Add missing since annotation for Filename.null

(cherry picked from commit bb62942ed5c3081d295e0b78a1c16cfb9061b613)
2019-12-30 05:22:21 +01:00
Jacques-Henri Jourdan 7dbbfce890 New ephemeron-free API for Memprof.
The user can register several callbacks, which are called for various
events during the block's lifetime. We need to maintain a data
structure for tracked blocks in the runtime. When using threads,
callbacks can be called concurrently in a reentrant way, so the
functions manipulating this data structure need to be reentrant.
2019-12-21 10:21:48 +01:00
Florian Angeletti 0921138b69 fix Stdlib.Lexing documentation 2019-12-12 14:42:21 +01:00
Gabriel Scherer 238e483eb8 better documentation for the best-fit allocation policy 2019-12-10 21:40:50 +01:00
Brian Wignall 2cd1db7ae9 Fix some spelling typos 2019-11-29 10:17:38 -05:00
Konstantin Romanov a9b0ca44d2 Add set_position and set_filename to Lexing. 2019-11-16 22:14:16 +00:00
Bernhard Schommer e5ebec7058 Fold map function for List (#8894)
The fold_map function is quite common combination of fold and map
which allow it to pass an accumulator through map.
2019-11-07 14:12:58 +01:00
zapashcanon c0e4096eaa add List.filteri to the stdlib (#9059) 2019-10-29 09:45:19 +01:00
Guillaume Munch-Maccagnoni 1220986b72 [minor] typo 2019-10-16 14:22:49 +02:00
Florian Angeletti 7c7f77cf98
Merge pull request #9024 from foocraft/fix_arraylabels_docs
Fixes to ArrayLabels documentation
2019-10-15 22:50:50 +02:00
Damien Doligez 01bdd5bbc4
best-fit allocator (#8809) 2019-10-15 13:52:16 +02:00
El-Hassan Wanas 8a614d79de Comment fixes
Co-Authored-By: David Allsopp <david.allsopp@metastack.com>
2019-10-15 14:14:31 +03:00
ElHassan Wanas e271e8fa4d Updated documentation for StringLabels, ArrayLabels, ListLabels and BytesLabels to show StdLabels usage 2019-10-15 12:44:44 +03:00
ElHassan Wanas fd8094e99a - Removal of all references to either Array or ArrayLabels from the
ArrayLabels documentation
- Only references remaining are for the warnings, and they refer to
  Array rather than ArrayLabels
2019-10-15 12:44:44 +03:00
El-Hassan Wanas b19f13768f Replaced old exception documentation in ArrayLabels with `@raise`
Deprecated warnings should point to `Array` alternatives rather than
those in `ArrayLabels`
Removed module references from function docs to avoid confusing between
StdLabels, Array and ArrayLabels

No change entry needed
2019-10-15 12:44:44 +03:00
El-Hassan Wanas f35ee6b458 Fixes to ArrayLabels documentation
- Removal of string arguments from exceptions in docs
- Changed references to ArrayLabels instead of Array whenever
  a labeled argument is present
- Fixes to code examples using the wrong argument(wrong name, or missing label)

No change entry needed
2019-10-15 12:44:44 +03:00
Gabriel Scherer cc1a05b055
Merge pull request #8651 from proux01/printf-h
Add printf '%#F' to output floats in hexadecimal OCaml constants
2019-10-14 11:43:01 +02:00
Jacques-Henri Jourdan 23e5bfa3bb Better stack backtraces for C calls in bytecode (#8641)
The previous mechanism worked for C calls that raise an exception, but not for C calls that call back into OCaml code which raises an exception.

This commit addresses the issue by saving the PC in the interpreter stack before a C call, so that the backtrace mechanism always sees it.

However, if an external is declared in the .ml file and exposed in the .mli file as a val, then ocamlc generates a wrapper that adds a spurious entry in the stack frame. In this PR, this change in behavior results in the re-declaration of Printexc.get_callstack as an external instead of a val, so that the spurious stack frame does not appear in call stacks obtained from Printexc.get_callstack.
2019-10-12 18:25:58 +02:00
David Allsopp fb6f58ea69
Merge pull request #8951 from shindere/make-default-target
Let make's default target build the compiler
2019-10-04 14:23:27 +01:00
Nicolás Ojeda Bär 46ca15365a
Merge pull request #8971 from nojb/filename_nul
Add Filename.null
2019-10-03 18:05:52 +02:00
Guillaume Munch-Maccagnoni b304042b29 Fix missing Caml_state (#8940)
* Fix free identifiers in spacetime

* Fix free identifiers in tools/gdb-macros

* [minor] Fix Caml_state fields in comments, and other comment updates

* Changes
2019-10-03 16:27:32 +02:00
Nicolás Ojeda Bär f1c4c6a1c1 Add Filename.null 2019-10-03 13:55:22 +02:00
Gabriel Scherer ba90da42ac List.concat_map : ('a -> 'b list) -> 'a list -> 'b list (#8760) 2019-10-01 15:53:14 +01:00
Nicolás Ojeda Bär 9c41f700c1
Merge pull request #9000 from nojb/option_join_micro
Tidy-up Option.join
2019-10-01 11:02:06 +02:00
Sébastien Hinderer 987b0814d7 Let make's default target build the compiler
This commit makes it possible to build the OCaml compiler according to
its configuration by simply runnning make. There is no need to specify
neither world nor world.opt explicitly, although the two targets
remain available.

This commit also introduces (and starts making use of) the
NATIVE_COMPILER build variable whosse value is true when the native
compiler is enabled and false otherwise.
2019-09-30 16:01:29 +02:00
Nicolás Ojeda Bär b5feac6b8c (Micro-)optimize Option.join 2019-09-30 14:29:08 +02:00
Nicolás Ojeda Bär 467395babb Update stdlib/HACKING.adoc 2019-09-30 13:56:48 +02:00
Nicolás Ojeda Bär dd30bd9786 Share list of modules in StdlibModules 2019-09-29 11:07:50 +02:00
Pierre Roux 1e3cd41fe7 Add printf `%#F` to output floats in hexadecimal OCaml constants 2019-09-26 15:55:32 +02:00
Jeremie Dimino 2d31ebfc8b Add support for [@@immediate64]
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2019-09-24 07:56:15 +01:00
Gabriel Scherer 5c7c619d4d List.find_map : ('a -> 'b option) -> 'a list -> 'b option (#8832) 2019-09-13 17:58:01 +02:00
Sébastien Hinderer 5ec649f0cb
Build system: share rules to compile C files (#8930)
This commit deduplicates some of the Makefile rules used to compile C files.

Rather than having one such rule per Makefile for each directory
containing C files, the relevant rules are moved to Makefile.common.in.
2019-09-11 09:16:15 +02:00
Thomas Blanc fe9f2ad6ec Fix typos in Bytes documentation 2019-09-06 16:16:41 +02:00
Jacques-Henri Jourdan 90073e96e5 Memprof tracking of interned data. 2019-08-27 19:14:56 +02:00
Gabriel Scherer 4c303cc88a Merge pull request #8826 from glondu/4.08-spelling-errors
Fix spelling errors reported by Lintian

(cherry picked from commit c808ce7068f3e31975594bcd5e6a41dceab3a80e)
2019-07-29 08:36:53 +02:00
Gabriel Scherer 1837dee56e
Merge pull request #8530 from gadmm/sort
List.sort: avoid duplicate work by chop
2019-07-26 06:48:08 +02:00
Guillaume Munch-Maccagnoni a1c05e3157 List.sort: avoid duplicate work by chop
David Allsopp: Remove unrelated reformatting
2019-07-25 22:31:39 +02:00
David Allsopp 94c5cbfb8d Refactor stdlib/hashtbl.ml
No code changes - move the definitions to ensure that the functorial
interface doesn't accidentally rely on polymorphic hash function.
2019-07-19 13:17:52 +01:00
Gabriel Scherer 364d07589b
Merge pull request #8526 from gretay-js/function-sections
Function sections
2019-07-16 13:39:55 +02:00
Alain Frisch 430c20bb78
A new runtime primitive for Array.fill (#8716) 2019-07-16 09:21:23 +02:00
Greta Yorsh 351edb49bb Add compile-time option -function-sections 2019-07-15 10:25:26 +01:00
Leo White 74e1a85b72 Update depends 2019-07-10 19:23:21 +01:00
David Allsopp 7c2284eda3 Rename references to Pervasives to Stdlib 2019-06-26 18:11:58 +01:00
Guillaume Munch-Maccagnoni 6a6f34e483 Fix typographic issues in the doc of new modules (#8744)
* Fix typographic issues in the doc of new modules

No change entry needed
2019-06-26 19:03:15 +02:00
Xavier Leroy a8daa89500 Add Filename.quote_command function (#1492)
MPR#7672: add a Filename.quote_command function

This function takes care of quoting the command and its arguments
so that they are correctly parsed by the system shell
(/bin/sh for Unix, cmd.exe for Win32).

Redirections for std input (< file) and std output (> file) and
std error (2> file) can also be specified as optional arguments.
A 2>&1 redirection is used if stdout and stderr are redirected to the
same file.

The result is a string that can be passed directly to Sys.command or
to the Unix functions that expect shell command lines.
2019-06-25 14:21:58 +02:00
Thibault Suzanne 7bba7b8e5c Fix Option.bind doc comment 2019-06-15 16:03:43 +02:00
Stephen Dolan 0cdb711f35
Merge pull request #8691 from jhjourdan/no_callback_c_alloc
Guarantee that allocation functions do no trigger callbacks when called from C
2019-06-11 09:50:34 +01:00
Damien Doligez 9a9223098c Fix the installation of the camlheader[di] files. They were installed under
the wrong names, which made -runtime-variant fail for bytecode.
2019-06-10 11:17:54 +01:00
Gabriel Scherer a9be9a4dba camlinternalFormat: fix the Formatting_gen case in fmt_of_string
Two bugs were present before the patch:

- Formatting_gen would always be printed as "@{",
  so for example "@[foo@]" would be reprinted as "@{foo@]"

- The Formatting_gen payload would be printed as a string literal,
  escaping '%', while it is a raw string representation of a format;
  so for example "@[<%d>" would be reprinted as "@[<%%d>"

  (This second bug was spotted by Florian Angeletti)
2019-06-06 12:50:22 +02:00
Gabriel Scherer bd6ef8413e Camlinternalformat: remove faulty check_open_box function
- Currently the check is a no-op, because the "emit a warning if the
  check fails" was never implemented. (It would actually require some
  work to pass a source location there to emit a warning, so it's not
  trivial.)

- The check is implemented by calling `open_box_of_string` and
  catching the `Failure _` exception if that function fails. This is
  just wrong: `Failure _` should be reserved to fatal program errors,
  and should not be caught for control-flow.

- The current implement is buggy (it fails all the time, but we don't
  notice because no warning is emitted):
  CamlinternalFormat.open_box_of_string expects a string of the form
  "v 3", but check_open_box would pass a string of the form "<v 3>"
  (or an empty string), which is the payload of the format value. So
  the check always fails.

- The idea of the check is wrong: "@[<x>foo@]" is an incorrect format
  string to pass to Format (the box indication does not make sense),
  but it is a perfectly fine format string to pass to Printf, where it
  just prints "@[<x>foo@]" on the output. So we cannot complain to the
  user at type-checking time, when we don't know how the format string
  will be used, whether the boxes will be interpreted as actual boxes
  or string literals.
2019-06-06 12:43:27 +02:00
Jacques-Henri Jourdan 0ca84f52cd Refactor the postponed blocks machinery in memprof.c
This makes sure that:
- Callbacks are never called when another is running
- The postponed queue is purged when setting memprof parameters

We now use a FIFO implemented as a circular buffer for remembering of
postponed blocks.
2019-06-05 14:25:33 +02:00
Stephen Dolan 16611aacc1
Merge branch 'trunk' into memprof_binomial 2019-05-27 11:32:07 +01:00
Gabriel Scherer e973cde5a4
Merge pull request #8685 from Fourchaux/trunk
Fixing misspellings
2019-05-24 06:58:30 +02:00
Jacques-Henri Jourdan b838e48c39 Memprof: Instead of a Poisson process, use a binomial distribution.
The workaround used for ignoring samples in the minor heap in native
mode now makes allocation very slow (or non-terminating) when the
sampling rate is not small enough. This will be fixed when sampling in
the minor heap in native mode will be implemented.
2019-05-21 17:10:16 +02:00
Damien Doligez 1d7740f624 additional fixes for #8634 2019-05-21 12:44:10 +02:00
JPR 6dc59549ce Fixing misspellings 2019-05-21 10:23:27 +02:00
Damien Doligez 1aeb9b2301 typos in comments 2019-05-20 16:49:40 +02:00
Jacques-Henri Jourdan cea1ff7534 Memprof sampling for blocks in the minor heap, allocated by C code.
Allocations ignored by this version
- Marshalling
- In the minor heap by natively-compiled OCaml code

Allocations potentially sampled
- In the major heap
- In the minor heap by C code and OCaml code in bytecode mode
2019-05-20 13:04:28 +02:00
Jacques-Henri Jourdan 052a950dea Statistical memory profiling of blocks allocated in the major heap. 2019-05-09 16:40:45 +02:00
Nicolás Ojeda Bär 89b1ab4aca
Merge pull request #8605 from alainfrisch/fix_hashtbl_to_seq_XXX_doc
Improve doc for Hashtbl.to_seq*
2019-05-09 11:00:05 +02:00
Stephen Dolan c24e5b5c8a Ensure that Gc.minor_words remains accurate after a GC (#8619)
If an allocation fails, the decrement of young_ptr should be undone
before the GC is entered. This happened correctly on bytecode but not
on native code.

This commit (squash of pull request #8619) fixes it for all the
platforms supported by ocamlopt.

amd64: add alternate entry points caml_call_gc{1,2,3} for code size
optimisation.

powerpc: introduce one GC call point per allocation size per function.
Each call point corrects the allocation pointer r31 before calling
caml_call_gc.

i386, arm, arm64, s390x: update the allocation pointer after the
conditional branch to the GC, not before.

arm64: simplify the code generator: Ialloc can assume that less than
0x1_0000 bytes are allocated, since the max allocation size for the
minor heap is less than that.

This is a partial cherry-pick of commit 8ceec on multicore.
2019-05-04 10:01:23 +02:00
David Allsopp 8838dc7527 Don't generate #! headers over 127 characters
A #! line should not exceed 128 characters (including the \0
terminator). This adds a test - both to the generation of the camlheader
files and also to the -use-runtime flag which falls back to #!/bin/sh
and uses exec to invoke the the interpreter.
2019-05-02 20:29:49 +02:00
Gabriel Scherer c107e00ce5 Fix the string.mli documentation of unsafe-string (#8653)
unsafe-string is no longer the default since 4.06.
2019-05-02 19:24:53 +02:00
Sébastien Hinderer cf8d6fd803 Fix build of standard library
There were a few buggy rules in stdlib/Makefile, fix them.
2019-04-20 14:28:57 +01:00
Gabriel Scherer f138e1be40 buffer: more detailed explanation of the [resize] reasoning 2019-04-16 17:29:26 +02:00
Gabriel Scherer 52a5c3fae8 refine the [resize] post-condition
See https://github.com/ocaml/ocaml/pull/8596#issuecomment-480812433
2019-04-16 10:05:54 +02:00
Gabriel Scherer 91daa22489 Buffer: actually enforce the invariant that (b.position <= b.length)
See https://github.com/ocaml/ocaml/pull/8596#issuecomment-480760172
and the rest of the conversation.
2019-04-16 10:05:54 +02:00
Gabriel Scherer b4cda227ae clarify the add_channel logic 2019-04-16 10:05:54 +02:00
Andrew Litteken d4ef2eecea Custom Exception Handlers at toplevel (#8594)
fixes #7156 

Two new functions exposed:

```ocaml
val to_string_default: exn -> string
(** [Printexc.to_string_default e] returns a string representation of the
    exception [e], ignoring all registered exception printers.
    @since 4.09
*)

val use_printers: exn -> string option
(** [Printexc.use_printers e] returns [None] if there are no registered
    printers and [Some s] with else as the resulting string otherwise.
    @since 4.09
*)
```
2019-04-14 15:38:27 +02:00
Sébastien Hinderer 49ce3b0611 Revert "Get rid of the stdlib/Compflags script (#8601)"
This reverts commit 0dec0ce9d6.
2019-04-11 15:52:41 +02:00
Sébastien Hinderer f7ba9367ec Revert "Fix typo in stdlib/Makefile"
This reverts commit b29e8979ec.
2019-04-11 15:52:03 +02:00
Nicolás Ojeda Bär 8897fe60cc make clean: do not remove emacs backups 2019-04-10 14:18:04 +02:00
alainfrisch e122acc1e7 Stronger spec for Hashtbl.to_seq w.r.t. multiple bindings on the same key 2019-04-10 13:20:46 +02:00
alainfrisch 8e695e3fbe Fix doc for Hashtbl.to_seq_keys, to_seq_values 2019-04-10 12:59:36 +02:00
Sébastien Hinderer b29e8979ec Fix typo in stdlib/Makefile 2019-04-10 12:09:19 +02:00
Sébastien Hinderer 0dec0ce9d6
Get rid of the stdlib/Compflags script (#8601)
This script was used to provide module-specific compiler flags.
Now that we use GNU make, these flags can be handled by make itslef.
2019-04-10 10:57:05 +02:00
David Allsopp 278e5abbc0 Merge the generation of stdlib/camlheader* (#2267)
Windows and Unix build instructions for the program versions of the
header stubs unified. For Cygwin, this also fixes the parallel build.
2019-04-10 00:52:48 +02:00
Damien Doligez 4e59ae10dd add assertion and comments suggested by @gasche 2019-04-08 14:16:26 +02:00
Damien Doligez ee1c8b4082 optimize more functions 2019-04-08 11:47:43 +02:00
Damien Doligez c7c44e13b0 add labels to Bytes.unsafe_blit_string 2019-04-08 11:41:29 +02:00
Damien Doligez 2085db3c3c #6148: optimize some buffer operations 2019-04-08 11:10:39 +02:00
Stephen Dolan 466d3bcc84 Deprecate Obj.truncate and bootstrap. 2019-04-01 14:17:39 +01:00
Stephen Dolan 18edce3b5f Remove use of Obj.truncate from toplevel.
When running a script with "ocaml foo.ml", the toplevel needs to
run foo.ml with a different Sys.argv than the initial value, since
foo.ml must not see the initial "ocaml" argument.

Previously, this was done with Obj.truncate to shorten the Sys.argv
array. This patch changes it by introducing a primitive %sys_argv.
Uses of this primitive expand to a call to a new C primitive, which
returns the argv array (and can be modified by the toplevel).
2019-04-01 14:14:00 +01:00
Stephen Dolan 501bd0bb36 Remove use of Obj.truncate from CamlinternalMod.
CamlinternalMod contains an optimisation for the initialisation
of recursive modules containing closures, where dummy closures
are updated in-place. This optimisation was buggy on bytecode,
since the bytecode interpreter relies on the lengths of blocks
containing closures (see #4008).

This commit disables the optimisation for bytecode (where it
had much less effect than on native code, and where performance
is of less concern anyway). The optimisation is still applied
on native-code, but without the use of Obj.truncate.

Also adds a test for #4008 (which introduced the truncate).
2019-04-01 14:10:12 +01:00
Stephen Dolan faab2a81ce Remove a use of Obj.truncate in weak.ml 2019-04-01 14:03:38 +01:00
David Allsopp 947486007e Fix Hashtbl.Make.of_seq creating randomized tables
Book-keeping error only - although it does potentially initialise the PRNG
unnecessarily.
2019-03-29 11:11:41 +01:00
David Allsopp fc8be501aa Fix Hashtbl.MakeSeeded.{add,replace,of}_seq
Hashtbl.MakeSeeded.{add,replace}_seq were not using the hash function
provided by the functor (Hashtbl.MakeSeeded.of_seq uses replace_seq and
so also has to be redefined locally).
2019-03-29 11:11:41 +01:00
Stephen Dolan f495bfb7cb
Merge pull request #8514 from stedolan/boot-ocamlc-opt
Use boot/ocamlc.opt for building, if available.
2019-03-22 12:22:14 +00:00
Stephen Dolan 46c427f519 Use boot/ocamlc.opt for building, if available. 2019-03-20 10:31:46 +00:00
Nicolás Ojeda Bär 74c94835b3 Add Unit to stdlib.ml{,i} 2019-03-19 12:29:20 +01:00