The Spacetime memory profiler is not going to be supported in Multicore OCaml, and is already broken by some of the related changes in OCaml 4.12. The core development team decided to remove Spacetime support from OCaml 4.12.
Introduce the type Cmm.exttype to precisely describe arguments to
external C functions, especially unboxed numerical arguments.
Annotate Cmm.Cextcall with the types of the arguments (Cmm.exttype list).
An empty list means "all arguments have default type XInt".
Annotate Mach.Iextcall with the type of the result (Cmm.machtype)
and the types of the arguments (Cmm.exttype list).
Change (slightly) the API for describing calling conventions in Proc:
- loc_external_arguments now takes a Cmm.exttype list,
in order to know more precisely the types of the arguments.
- loc_arguments, loc_parameters, loc_results, loc_external_results
now take a Cmm.machype instead of an array of pseudoregisters.
(Only the types of the pseudoregisters mattered anyway.)
Update the implementations of module Proc accordingly, in every port.
Introduce a new overridable method in Selectgen, insert_move_extcall_arg,
to produce the code that moves an argument of an external C function
to the locations returned by Proc.loc_external_arguments.
Revise the selection of external calls accordingly
(method emit_extcall_args in Selectgen).
Since #9316 was merged, Cconst_pointer is compiled in exactly the same way as Cconst_int. This commit removes the now-redundant Cconst_pointer and Cconst_natpointer.
Since we cannot access backtrace position in cmmgen.ml anymore,
Cmm.raise_kind in removed. Instead, we use Lambda.raise_kind. When
assembly code is generated, we reset the backtrace position to 0 in the
case of regular raise. Importantly, the semantics remains the same.
Following on from GPR#851 and GPR#873, this pull request further enhances debugging information in Cmm terms. This was driven both by manually examining the debugger's behaviour and also by a report received from a user regarding substandard DWARF location information.
Summary
-------
This patch adds explicit type annotations for Ccatch payloads in the CMM
IR, thus supporting payloads which are not of type `val`.
Rationale
---------
While CMM generated from OCaml source will always generate payloads of type
`val`, this is not the case when targeting CMM to compile from a different
language. As a concrete example, I am currently targeting the CMM backend for
compilation of WebAssembly, and require `float` payloads. Additionally, @mshinwell
has noted that such an extension will be useful for flambda2. As a result, this
patch will increase the applicability of the CMM IR as a compilation target.
Updates
-------
25/06/2018: Incorporate review comments by @xclerc
Design
------
The design of the patch is as follows:
1. Add explicit type annotations to Ccatch handlers. Specifically,
```Ccatch (int * (Ident.t list) * expression)```
becomes
```Ccatch (int * (Ident.t * machtype) list * expression)```
2. By default, in `cmmgen`, select `typ_val` as the `machtype`
3. Select an appropriate register using the type annotation in `selectgen`,
instead of defaulting to `typ_val`
4. Test updates:
- Update the CMM parser and pretty-printer to require annotations on Ccatch
handlers
- Update the existing CMM tests to add the required annotations
- Add new tests which require the use of floating-point registers, for
which the compiler would generate invalid ASM prior to this patch
Since all OCaml code will use `typ_val` as before in `cmmgen` and therefore
`selectgen`, compilation for OCaml programs will be identical.
since the semantic changed. There is no need to check Clflags.debug
anymore Raise_withtrace, means that traces must be computed (if the
runtime boolean is true).
- Register type "Addr" is split into
. "Val" (well-formed OCaml values, appropriate as GC roots)
. "Addr" (derived pointers within the heap, must not survive a GC)
- memory_chunk "Word" is split into
. "Word_val" (OCaml value)
. "Word_int" (native-sized integer, not a pointer into the heap)
Cmmgen was updated to use Word_val or Word_int as appropriate.
Application #1: fail at compile-time if a derived pointer within the heap
survives a GC point (cf. PR#6484).
Application #2: CSE can do a better job across allocation points
(keep factoring expressions of type Int, Val, Float, but not Addr).
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/cmm-mach-types@15568 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Constant propagation for floats can be turned off with option
-no-float-const-prop, for codes that change FP rounding modes at
run-time.
- Clambda / C-- / Mach: represent float constants as FP numbers of type
float rather than literals of type string.
- Tested for AMD64; other archs need testing.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14673 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
This way we can avoid having to duplicate the same functionality for
every backend, and we may also benefit from other optimizations performed
during C-- generation.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14303 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02