* Fix duplicates in Cmmgen when handling switches with no default and not all cases
* Improve handling of incomplete Lambda switches in Flambda
* Add test (for reference) and changes
* Fix nitpick
* Cleanup: split the switch stores to reflect usage
* Improve compilation of incomplete switches with flambda
* Split switch stores into context-aware and -unaware versions
* Credit reviewers
* Go back to a single Switch.t_store type
* Treat genarray creation as nonrec in bytecode size computations.
* Add tests for generic array creation in let rec bindings.
* Bring the Pgenarray clauses together in code size computations.
ocamlc complained that the temporary files it just created existed.
since ed60dece81575305b5f1f7394cdda652b65b037a and
19d3bccf48fee6e5e91e65e9f8a5d07c49d2afd4
* Complier: -compat-32 flag when building cmo/cma.
Compiler: refactor -compat-32 support
Update Changes
Complier: more -compat-32 checks in emitcode.
* add tests for the -compat-32 flag
With this commit, "ocamlc -c -linkall" or "ocamlopt -c -linkall" produce object files that have the "force link" flag set. Once put in library files (.cma/.cmxa), these object files will always be linked when the library is linked, even if no definition from the object file is referenced. However, other object files in the library can still be removed if none of their definitions are referenced.
In this respect, we get finer-grained control on which object files should always be linked, typically because they contain important initialization code.
To break the circular dependency between Bigarray and Unix, a CamlinternalBigarray module was added to the stdlib. This module defines all the types used by the compiler to produce optimized code for bigarrays.
Thanks to David Allsopp for fixing Windows tests.
* Improve compilation time for toplevel include(struct ... end : sig ... end)
This is intended to fix MPR#7357, which uses the natural way
of specifying an inline signature for a unit without using an external
.mli file.
The trick is similar than the one applied for compiling
module X = (struct ... end : sig ... end)
Identifiers of the inner structure are "lifted" as extra fields
to the top-level structure.
* Changelog.
* Check that all the required modules are provided
Also remove provided cmo from the required globals
* Remove required globals from packs when provided
* Remove provided globals after adding required ones
Pack modules can require globals they provide.
* Dumpobj tool can print relocation information
* Avoid checking twice if divisor is zero
The flambda branch before merging assumed that Pdivint and Pmodint where
already checked when entering Cmmgen. This was not the case anymore
after merging and this change was lost. This fix this overlook by adding
an annotation to the Pdivint and Pmodint primitive telling whether the
division by zero was already checked.
The reason to move the test generation to Closure_conversion in the
flambda branch was to allow the division primitive to be considered as
pure without needing to check for the effective value of the
divisor. This simplified Semantics_of_primitives a lot.
* Bigarray div and mod also carry safety information
* Handle bigint div and mod like int div and mod in closure_conversion
* Update Changes
* Test for divisions by zero
* Turn Pdivbint and Pmodbint argument into an inline record
The logic for arrays was more clever than the one for compiling 'lazy
x' without a forward block. In particular, it knows that concrete
data types (records, variants, open variants) cannot be floats (they
cannot be lazy either). This commits reuses this logic for deciding
if 'lazy x' must introduce a forward block. Now, the only difference
between the two cases is the abstract built-in type 'lazy_t'.
This commits also robustifies the classification logic to explicitly
deal with all kinds of types; and it removes an unused function.
This commits reuses the machinery introduced for [@@immediate] in
order to improve the detection of cases where the forward block is not
needed for compiling `lazy x`. This detects some new cases such as
closed polymorphic variants with only constant constructors, or
abstract types marked with [@@immediate].
This commits reuses the machinery introduced for [@@immediate] in
order to improve the detection of the Pintarray case. This detects
some new cases such as closed polymorphic variants with only constant
constructors, or abstract types marked with [@@immediate].
An expression `lazy x` (where x is a value identifier) can be compiled
either as a simple reference to x or to the construction
of a forward block pointing to that value. The simple scheme is used
when x cannot be a float or a lazy value. This is determined based on
the type of the sub-expression x. There was a missing Ctype.repr, which
has the effect that the compiler
let f g =
(lazy g), (g ())
would miss the fact that g has a function type; it would thus build a
forward block, whereas swapping the tuple components avoided that block.
Adds the required_globals information to bytecode compilation units.
This patch also bootstrap ocamlc. The cmo format is changed by this
commit, there is no way around bootstraping here. Note that ocamldep and
ocamllex does not rely on the cmo format, so they are not present in
this commit.
Changes in tests:
* Update test/transprim/comparison_table.ml.reference:
The (opaque (global List!)) expression is not present anymore
* Update tests/no-alias-deps/aliases.cmo.reference
The output of objinfo changed
Pierre Chambart luckily caught an error in the code of PR#538 with
a condition in the wrong order -- which de-optimizes instead of
optimizing as it should. The wrong change was in 4f824bf.
This option was broken, as can be seen by using it to compile the
following helloworld.ml program:
let _ = Printf.printf "Hello, world!\n%!"
Then from OCaml's toplevel source directory, compile as follows:
./ocamlc.opt -use-runtime ${HOME}/src/ocaml/byterun/ocamlrun \
-nostdlib -I stdlib -o helloworld.byte helloworld.ml
And do:
head -1 helloworld.byte
See the double #! at the beginning of the line.
The first one comes from the "header" file which is included and is
correct (it would be a different header on Windows).
The second one is hard-coded and should be removed, this is what
this patch does.
When translating into Lambda we treat the case of exception
handlers in match forms in the same way as exception handler in
try .. with in order to preserve backtraces.
A small test is included as well.
This prevents some type annotations to be propagated to the middle-end,
but this is not really important as those only concern constants which
already provide all the usefull information about their shape.
This debugging event provides information regarding the structure items.
It is ignored by the OCaml debugger but is used by Js_of_ocaml to
preserve variable names for debugging purpose.
This reverts commit 02b1696cc2.
Problems with -pack appear while compiling Camlp4. Temporarily reverting this commit so that Camlp4 compiles again. To be investigated further.
Attempting to see if this commit is the source of the problem.
This week we merged several changes from Thomas Refis, to allow the
use of exception patterns under or-patterns, to write code such as
match foo x with
| None | exception Not_found -> ...
| Some -> ...
Unfortunately, I failed to properly assess the impact of this change,
and in particular to make sure that Luc Maranget had properly reviewed
this code -- any change to the pattern-matching machinery should be
reviewed by Luc.
The problem that I had not foreseen and that he would have immediately
realized is that, while adapting the pattern-matching *compiler* is
relatively easy (Thomas inserted a transformation at the right place
to separate exception patterns from the others and handle them
separately, using the staticraise construct used by the
pattern-matching compiler to avoid duplicating the
right-hand-side branch), adapting the pattern-matching warnings
machinery is both more subtle and easier to overlook (it may fail
silently and nobody notices, unlike wrong code production). This part
of the compiler is subtle and best understood by Luc, but he does not
have the time to do a proper review of those changes in the timeframe
for the 4.03 feature freeze (mid-December).
I believe the right move in this case, implemented in the present
commit, is to revert the change from trunk (this is not a feature that
we must *imperatively* have in 4.03), do a proper job of understanding
the changes, and integrate the change when we are confident it is
ready. I hope to do this in 2016, together with Luc Maranget and
Thomas Refis -- hopefully this would allow Thomas and I to be more
confident when changing the pattern-matching machinery in the future.
Revert "Merge pull request #343 from trefis/pr7083"
This reverts commit 22681b8d2a, reversing
changes made to a24e4edf0a.
Revert "Merge pull request #341 from trefis/or-exception"
This reverts commit f8f68bd329, reversing
changes made to 1534fe8082.
Revert "Merge pull request #305 from trefis/or-exception"
This reverts commit cfeda89396, reversing
changes made to 77cf36cf82.
This form used to produce Pstr_eval instead of Pstr_let. This would
probably come as a suprise for people matching on the Parsetree (e.g.
for a ppx). This special case is now removed.
To avoid a (probably harmless) regression in bytecode, the compilation
of "let _ = ..." bindings (including local ones) is optimized to remove
a useless introduction of a variable (which would occupy a stack slot
otherwise).
The source code printer (-dsource) now prints Pstr_eval as ";;expr",
which should always be ok. One could avoid ";;" at the beginning of
the structure, but since it is allowed, it is probably not worth adding
complexity here.
Translate [%ocaml.extension_constructor <path>] to the
runtime-representation of the extension constructor denoted by
<path>. This allows one to get the extension constructor without
having to create a dummy value.
From comments in typedtree.mli:
When introduced in 2000, this [type] enabled a more efficient code
generation for optional arguments. However, today the information is
redundant as labels are passed to [transl_apply] too. Could be cleaned
up.
- float
- int32
- int64
- nativeint
Not for int because the comparison is done directly on the untagged version.
Useful mainly for floats since they can be stored unboxed in records or arrays.