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
Using emit_parts_list does not make sense for any
operation except Ialloc, where we can delay the
computation of simple expression until the allocation
is done. So we try to avoid using emit_parts_list for
regular operations, where the special treatment of
non simple expression conflicts with our special
instruction selection on arm (and arm64). For example
we cannot merge the add and shift operation required
for tagging as soon as there is at least one non
simple expression involved, even though both Cadd
and Clsl do not care at all whether its arguments are
simple or not.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14292 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
(Patch by Adrien Nader!)
Jacques Garrigue has reported that the testsuite would try to run with a
non-existing opt compiler and that the error wasn't clear.
Now, instead of trying to run:
-c -I some_dir/ foo.ml
anything that tries to run ocamlopt before it's available will run:
no-opt-compiler-available -c -I some_dir/ foo.ml
which should hopefully be clearer.
I'm not yet sure why the testsuite didn't abort earlier, noticing that
there was no opt compiler. One possibility is that using "test -e"
without argument (which happens if variables are empty and not quoted
inside shell scripts) succeeds. This will have to be checked.
v2: don't remove the bytecode entry (bad copy-paste)
build: make CAMLOPT_BIN default to "no-opt-compiler-available".
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14278 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
(Patch by Adrien Nader!)
This is a partial revert of revision 14168 which caused issues when
bootstrapping the compiler. Since these directories don't take long to
build, we can always use a byte-compiled compiler.
Bootstrapping and more generally working on the compiler itself does not
play nice with trying to use the most recent compiler as soon as
possible: imagine you've just modified the compiler but in a way that
breaks it at runtime in a non-obvious way; all the files that are
subsequently built will have been built with your the compiler you will
be debugging.
v2: always build tools/ with boot/ocamlc since most executables link
against compiler libs.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14277 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
(Patch by Adrien Nader!)
The recent change that replaced ocamlcomp*.sh made apparent an old bug
where ocamlbuild could use ocamlc.opt even though ocamlc was newer.
As far as I understand, Unix is not usable in this file because it can be
used for bootstrap. Instead, shell out "test ocamlc.opt -nt ocamlc" in
order to check which one to use.
This has also made me notice another issue in this file: it was checking
that "stdlib.cm*xa*" existed when building with the *byte* compiler.
Note that shelling out may have a fairly high build-time cost on
Windows. We'll see with the Jenkins results.
myocamlbuild.ml: only build with .opt compilers if they're more recent.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14276 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
As notified by Nicolas Trangez, the following program behaves in an
unexpected way by returning 0 instead of failing with an out-of-bound
exception:
external get16 : string -> int -> int = "%caml_string_get16"
let test = get16 "" 0
caml_string_get16(str, idx) will access indices (idx) and (idx+1). The
bound-checking code is currently implemented as:
if (idx < 0 || idx >= caml_string_length(str) - 1) caml_array_bound_error();
This is wrong as caml_string_length returns an mlsize_t which is
unsigned, so substracting 1 gets buggy when the size is 0. The test
should be written as follow:
if (idx < 0 || idx + 1 >= caml_string_length(str)) caml_array_bound_error();
Note 1: we can exploit this bug to make out-of-bound access to
a string, but I think get16 examples will run into the padding
characters of OCaml strings and behave in a not-too-wrong way. It may
also be the case of get32, but get64 will access 7 bytes, so access
memory outside the string:
# external set64: string -> int -> int -> unit = "%caml_string_get64";;
external set64 : string -> int -> int -> unit = "%caml_string_get64"
# set64 "" 0 0;;
Segmentation fault
Note 2: this first commit only fixes the C code in byterun/str.c. Only
ocamlc actually uses these functions when the compiler primitive is
used ("%caml_string_get16" instead of "caml_string_get16"). ocamlopt
generates ocaml code directly, and this part has yet to be fixed in
a following commit.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14267 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Given integer constants x and n:
1. If n + x does not overflow, then (x - c) + n is compiled
to (x + n) - c.
2. If n - x does not overflow, then (c - x) + n is compiled
to c + (n - x).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14266 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Recognize negation by multiplication with -1 and generate
subtraction in this case.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14264 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02