Commit Graph

20269 Commits (e4bf109d1e7f64aa21a3edc00af4036c029604a6)

Author SHA1 Message Date
Xavier Leroy e4bf109d1e
Signal handling in native code without the page table (#9682)
Signal handlers sometimes need to know whether the signal occurred
in ocamlopt-generated code, as opposed to runtime or C library code.

Today this determination uses a page table lookup to keep track
of dynamically-loaded modules, plus ad-hoc tests for the main program.

This PR uses the code fragment table instead.  That's more reliable,
less ad-hoc, and independent of the page table.

i386nt.asm: add caml_system__code_{begin,end}, ,like in the other ports.
2020-06-15 14:17:42 +02:00
Jacques Garrigue 603506aa34
Add injectivity annotations (#9500) 2020-06-15 13:51:50 +02:00
Xavier Leroy 5a9c5dd5b0
globroots.c: adapt to no-naked-pointers mode (#9683)
Global roots management has a special case for out-of-heap pointers.
This is not compatible with a future removal of the page table.
However, this is just an optimization that can safely be turned off.

This PR treats out-of-heap pointers like major-heap pointers in
no-naked-pointers mode.
2020-06-15 13:39:35 +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
Sadiq Jaffer b8a415f724
Add closure-info field when reifying bytecode (#9681)
The closure built by caml_reify_bytecode was not using the new closure format.
2020-06-14 19:22:01 +02:00
Nicolás Ojeda Bär 13155d81ee
Typo 2020-06-14 18:37:44 +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 faa56c1934 Add Changes entry 2020-06-14 07:57:39 +01:00
Leo White a02707c610 Better backtraces for lazy values 2020-06-14 07:57:35 +01:00
Leo White 9895b28d25 Add tests for backtraces from forcing lazy values 2020-06-14 07:51:31 +01:00
Xavier Leroy 0a11f73c8b Bootstrap after removal of caml_static_{alloc,free_resize} primitives
Follow-up to d6f949608
2020-06-13 18:27:00 +02:00
Xavier Leroy d6f949608d Remove the primitive functions caml_static_{alloc,free,resize}
These primitives are dangerous because they produce naked pointers
outside the OCaml heap, with a risk of "GC pointer confusion".
(After caml_free and a heap extension, the freed memory area can be
reallocated as part of the OCaml heap, causing the naked pointer to
become a bad heap pointer).

These primitives are not used anywhere in the core OCaml system
(in particular they are not exposed via the Obj module).
An OPAM-wide grep shows no uses there either.
2020-06-13 18:23:08 +02:00
Gabriel Scherer cba5a765a2
Merge pull request #9653 from jhjourdan/memprof_no_shutdown
Memprof: getting rid of caml_memprof_shutdown
2020-06-13 13:53:04 +02:00
Xavier Leroy b0cd12d1c4 Test intext.ml: do not use the caml_static_alloc primitive
This primitive (from runtime/obj.c) is being phased out because
it returns a naked pointer outside the OCaml heap.

Instead, for the test, use a statically-allocated buffer
that is never visible from OCaml.
2020-06-13 11:39:02 +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
Xavier Leroy fe4b06b990 extern.c: #ifdef-protect a static function
Follow-up to c18409446.  Under macOS an unused static function triggers
a warning.
2020-06-11 20:21:31 +02:00
Xavier Leroy 38d2f5a92a
Merge pull request #9649 from xavierleroy/marshal-new-closure-repr
Marshaling for the new closure representation
2020-06-11 19:56:30 +02:00
Xavier Leroy 919803e09c Changes entry for #9649 2020-06-11 10:59:54 +02:00
Xavier Leroy c18409446e extern.c: use new closure representation to marshal closures
We know where the code pointers, closure info words and infix headers are,
and can output them directly.

Currently activated in no-naked-pointers mode only, but would work in
the other mode as well.
2020-06-11 10:52:13 +02:00
Xavier Leroy 21ce6b02e2 extern.c: refactor the code using auxiliary functions
This makes the core function `extern_rec` easier to read, and will
avoid code duplication in later changes.
2020-06-11 10:51:46 +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 bee3679aab Memprof: getting rid of caml_memprof_shutdown
This function is not needed since there is no requirement that the OCaml runtime be able to restart once shut down.
2020-06-10 19:18:48 +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
Stephen Dolan 5946b93a85
Refactor skiplist to avoid UB casts (#9660)
This patch removes casts between struct skiplist * and struct skipcell *, and removes the "layout compatibility" fields in skiplist that were there to enable these casts.

The only algorithmic difference is that caml_skiplist_find is now "stop-at" (see discussion here), as this was slightly easier to write in the no-cast style.
2020-06-10 16:40:51 +02:00
Xavier Leroy c2db3288c1 Use type Obj.raw_data to represent code pointers in the REPL trace facility
Using Obj.t is incorrect in no-naked-pointer mode, as it exposes
code pointers as OCaml values.
2020-06-10 16:30:43 +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
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 c24198550a
Merge pull request #9612 from garrigue/pr6744ex
fix number and add examples for #6744
2020-06-10 14:05:31 +02:00
Gabriel Scherer 6ea0fbdddb
Merge pull request #9602 from garrigue/document-variance-flags
add explanation for variance flags
2020-06-10 13:53:03 +02:00
David Allsopp 2f38a52086
Merge pull request #9625 from dra27/warn-error
--enable-warn-error configure option
2020-06-10 11:32:13 +01:00
Sébastien Hinderer 325a0ff718
Merge pull request #9661 from shindere/ocamldoc-remove-debug-support
ocamldoc: remove debugging facility
2020-06-10 11:00:35 +02: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
Gabriel Scherer 56f7500f5c
Merge pull request #9646 from gasche/rematch-simplify-unused
matching: refactor the local control flow of the Unused exception
2020-06-10 09:50:18 +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
Sébastien Hinderer 433485b8b5 ocamldoc: remove debugging facility 2020-06-09 12:30:44 +02:00
Sébastien Hinderer 2e4d1ecc12
Remove two oldish scripts (#9656) 2020-06-09 10:49:58 +02:00
Sébastien Hinderer d8f3273292
Merge pull request #9285 from dra27/simplify-mkexe
Eliminate MKEXE_ANSI from build system
2020-06-08 17:13:05 +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
Gabriel Scherer 792deb120f [minor] printlambda: print the 'tailcall' attribute in the same style as others 2020-06-08 15:39:20 +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
Xavier Leroy 8fd7894b2a Use the skip list library to manage overwritten instructions in the debugger
This avoids the quadratic behaviors of the previous array-based
implementation.

Closes: #9606
2020-06-08 14:13:08 +02:00
Xavier Leroy 40824de87f Use the skip list library for global GC root management
Instead of the specialized skip list implementation that was local to
this file.
2020-06-08 14:12:53 +02:00
Xavier Leroy 9a5f3b1967 Add skip lists as a reusable data structure
The implementation is taken from globroots.c, but made reusable elsewhere.
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