Skip to content

Commit 520fb2d

Browse files
committed
Merge tag 4.03.0 into trunk.
1 parent 2c7c9b4 commit 520fb2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1506
-1045
lines changed

Changes

+23-3
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,15 @@ Runtime system:
382382
- GPR#262: Multiple GC roots per compilation unit
383383
(Pierre Chambart, Mark Shinwell, review by Damien Doligez)
384384

385-
- GPR#297: Several changes to improve the worst-case GC pause time.
386-
(Damien Doligez, with help from Leo White and Francois Bobot)
385+
* GPR#297: Several changes to improve the worst-case GC pause time.
386+
Changes Gc.control and Gc.major_slice and adds functions to the Gc module.
387+
(Damien Doligez, with help from Francois Bobot, Thomas Braibant, Leo White)
387388

388389
- GPR#325: Add v=0x400 flag to OCAMLRUNPARAM to display GC stats on exit
389390
(Louis Gesbert, review by Alain Frisch)
390391

391392
Standard library:
393+
=================
392394

393395
- PR#1460, GPR#230: Array.map2, Array.iter2
394396
(John Christopher McAlpine)
@@ -610,6 +612,10 @@ Other libraries:
610612
"end of line" means for "^" and "$" regexps.
611613
(Xavier Leroy, question by Fredrik Lindgren)
612614

615+
- PR#7209: do not run at_exit handlers in [Unix.create_process] and
616+
similar functions when the [exec] call fails in the child process
617+
(Jérémie Dimino)
618+
613619
OCamldep:
614620
=========
615621

@@ -630,6 +636,9 @@ Manual:
630636
- PR#6676: ongoing simplification of the "Language Extensions" section
631637
(Alain Frisch, John Whitington)
632638

639+
- PR#6898: Update win32 support documentation of the Unix library
640+
(Damien Doligez, report by Daniel Bünzli)
641+
633642
- PR#7092, GPR#379: Add missing documentation for new 4.03 features
634643
(Florian Angeletti)
635644

@@ -748,7 +757,7 @@ Bug fixes:
748757
- PR#6805: Duplicated expression in case of hole in a non-failing switch.
749758
(Luc Maranget)
750759

751-
- PR#6808: the parsing of OCAMLRUNPARAM is too lax
760+
* PR#6808: the parsing of OCAMLRUNPARAM is too lax
752761
(Damien Doligez)
753762

754763
- PR#6874: Inefficient code generated for module function arguments
@@ -882,9 +891,15 @@ Bug fixes:
882891
- PR#7160: Type synonym definitions can weaken gadt constructor types
883892
(Jacques Garrigue, report by Mikhail Mandrykin)
884893

894+
- PR#7181: Misleading error message with GADTs and polymorphic variants
895+
(Jacques Garrigue, report by Pierre Chambart)
896+
885897
- PR#7182: Assertion failure with recursive modules and externals
886898
(Jacques Garrigue, report by Jeremy Yallop)
887899

900+
- PR#7196: "let open" is not correctly pretty-printed to the left of a ';'
901+
(Gabriel Scherer, report by Christophe Raffalli)
902+
888903
- PR#7214: Assertion failure in Env.add_gadt_instances
889904
(Jacques Garrigue, report by Stephen Dolan)
890905

@@ -1074,6 +1089,11 @@ Features wishes:
10741089
GNU parallel tool to run tests in parallel.
10751090
(Gabriel Scherer)
10761091

1092+
- GPR#555: ensure that register typing constraints are respected at
1093+
join points in the control flow graph
1094+
(Mark Shinwell, debugging & test case by Arseniy Alekseyev and Leo White,
1095+
code review by Xavier Leroy)
1096+
10771097
Build system:
10781098
=============
10791099

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
4.04.0+dev1-2016-04-18
1+
4.04.0+dev2-2016-04-27
22

33
# The version string is the first line of this file.
44
# It must be in the format described in stdlib/sys.mli

asmcomp/cmm.ml

+50
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,56 @@ let size_component = function
3232
| Int -> Arch.size_int
3333
| Float -> Arch.size_float
3434

35+
(** [machtype_component]s are partially ordered as follows:
36+
37+
Addr Float
38+
^
39+
|
40+
Val
41+
^
42+
|
43+
Int
44+
45+
In particular, [Addr] must be above [Val], to ensure that if there is
46+
a join point between a code path yielding [Addr] and one yielding [Val]
47+
then the result is treated as a derived pointer into the heap (i.e. [Addr]).
48+
(Such a result may not be live across any call site or a fatal compiler
49+
error will result.)
50+
*)
51+
52+
let lub_component comp1 comp2 =
53+
match comp1, comp2 with
54+
| Int, Int -> Int
55+
| Int, Val -> Val
56+
| Int, Addr -> Addr
57+
| Val, Int -> Val
58+
| Val, Val -> Val
59+
| Val, Addr -> Addr
60+
| Addr, Int -> Addr
61+
| Addr, Addr -> Addr
62+
| Addr, Val -> Addr
63+
| Float, Float -> Float
64+
| (Int | Addr | Val), Float
65+
| Float, (Int | Addr | Val) ->
66+
(* Float unboxing code must be sure to avoid this case. *)
67+
assert false
68+
69+
let ge_component comp1 comp2 =
70+
match comp1, comp2 with
71+
| Int, Int -> true
72+
| Int, Addr -> false
73+
| Int, Val -> false
74+
| Val, Int -> true
75+
| Val, Val -> true
76+
| Val, Addr -> false
77+
| Addr, Int -> true
78+
| Addr, Addr -> true
79+
| Addr, Val -> true
80+
| Float, Float -> true
81+
| (Int | Addr | Val), Float
82+
| Float, (Int | Addr | Val) ->
83+
assert false
84+
3585
let size_machtype mty =
3686
let size = ref 0 in
3787
for i = 0 to Array.length mty - 1 do

asmcomp/cmm.mli

+14
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ val typ_int: machtype
5656
val typ_float: machtype
5757

5858
val size_component: machtype_component -> int
59+
60+
(** Least upper bound of two [machtype_component]s. *)
61+
val lub_component
62+
: machtype_component
63+
-> machtype_component
64+
-> machtype_component
65+
66+
(** Returns [true] iff the first supplied [machtype_component] is greater than
67+
or equal to the second under the relation used by [lub_component]. *)
68+
val ge_component
69+
: machtype_component
70+
-> machtype_component
71+
-> bool
72+
5973
val size_machtype: machtype -> int
6074

6175
type comparison =

asmcomp/selectgen.ml

+8-3
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,19 @@ let join opt_r1 seq1 opt_r2 seq2 =
117117
assert (l1 = Array.length r2);
118118
let r = Array.make l1 Reg.dummy in
119119
for i = 0 to l1-1 do
120-
if Reg.anonymous r1.(i) then begin
120+
if Reg.anonymous r1.(i)
121+
&& Cmm.ge_component r1.(i).typ r2.(i).typ
122+
then begin
121123
r.(i) <- r1.(i);
122124
seq2#insert_move r2.(i) r1.(i)
123-
end else if Reg.anonymous r2.(i) then begin
125+
end else if Reg.anonymous r2.(i)
126+
&& Cmm.ge_component r2.(i).typ r1.(i).typ
127+
then begin
124128
r.(i) <- r2.(i);
125129
seq1#insert_move r1.(i) r2.(i)
126130
end else begin
127-
r.(i) <- Reg.create r1.(i).typ;
131+
let typ = Cmm.lub_component r1.(i).typ r2.(i).typ in
132+
r.(i) <- Reg.create typ;
128133
seq1#insert_move r1.(i) r.(i);
129134
seq2#insert_move r2.(i) r.(i)
130135
end

bytecomp/translmod.ml

+12-7
Original file line numberDiff line numberDiff line change
@@ -557,21 +557,26 @@ let scan_used_globals lam =
557557
in
558558
scan lam; !globals
559559

560-
let wrap_globals body =
560+
let wrap_globals ~flambda body =
561561
let globals = scan_used_globals body in
562562
let add_global id req =
563-
if IdentSet.mem id globals then req else IdentSet.add id req in
563+
if not flambda && IdentSet.mem id globals then
564+
req
565+
else
566+
IdentSet.add id req
567+
in
564568
let required =
565-
Hashtbl.fold (fun path _ -> add_global (Path.head path))
566-
used_primitives IdentSet.empty
569+
Hashtbl.fold
570+
(fun path _ -> add_global (Path.head path)) used_primitives
571+
(if flambda then globals else IdentSet.empty)
567572
in
568573
let required =
569574
List.fold_right add_global (Env.get_required_globals ()) required
570575
in
571576
Env.reset_required_globals ();
572577
Hashtbl.clear used_primitives;
573578
IdentSet.fold
574-
(fun id expr -> Lsequence(Lprim(Pgetglobal id, []), expr))
579+
(fun id expr -> Lsequence(Lprim(Popaque, [Lprim(Pgetglobal id, [])]), expr))
575580
required body
576581
(* Location.prerr_warning loc
577582
(Warnings.Nonrequired_global (Ident.name (Path.head path),
@@ -589,7 +594,7 @@ let transl_implementation_flambda module_name (str, cc) =
589594
Translobj.transl_label_init
590595
(fun () -> transl_struct [] cc (global_path module_id) str)
591596
in
592-
(module_id, size), wrap_globals body
597+
(module_id, size), wrap_globals ~flambda:true body
593598

594599
let transl_implementation module_name (str, cc) =
595600
let (module_id, _size), module_initializer =
@@ -944,7 +949,7 @@ let transl_store_implementation module_name (str, restr) =
944949
let (i, r) = transl_store_gen module_name (str, restr) false in
945950
transl_store_subst := s;
946951
{ Lambda.main_module_block_size = i;
947-
code = wrap_globals r; }
952+
code = wrap_globals ~flambda:false r; }
948953

949954
(* Compile a toplevel phrase *)
950955

byterun/caml/minor_gc.h

+27-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extern int caml_in_minor_collection;
3838
}
3939

4040
struct caml_ref_table CAML_TABLE_STRUCT(value *);
41-
CAMLextern struct caml_ref_table caml_ref_table, caml_finalize_table;
41+
CAMLextern struct caml_ref_table caml_ref_table;
4242

4343
struct caml_ephe_ref_elt {
4444
value ephe; /* an ephemeron in major heap */
@@ -48,6 +48,15 @@ struct caml_ephe_ref_elt {
4848
struct caml_ephe_ref_table CAML_TABLE_STRUCT(struct caml_ephe_ref_elt);
4949
CAMLextern struct caml_ephe_ref_table caml_ephe_ref_table;
5050

51+
struct caml_custom_elt {
52+
value block; /* The finalized block in the minor heap. */
53+
mlsize_t mem; /* The parameters for adjusting GC speed. */
54+
mlsize_t max;
55+
};
56+
57+
struct caml_custom_table CAML_TABLE_STRUCT(struct caml_custom_elt);
58+
CAMLextern struct caml_custom_table caml_custom_table;
59+
5160
extern void caml_set_minor_heap_size (asize_t); /* size in bytes */
5261
extern void caml_empty_minor_heap (void);
5362
CAMLextern void caml_gc_dispatch (void);
@@ -57,6 +66,9 @@ extern void caml_alloc_table (struct caml_ref_table *, asize_t, asize_t);
5766
extern void caml_realloc_ephe_ref_table (struct caml_ephe_ref_table *);
5867
extern void caml_alloc_ephe_table (struct caml_ephe_ref_table *,
5968
asize_t, asize_t);
69+
extern void caml_realloc_custom_table (struct caml_custom_table *);
70+
extern void caml_alloc_custom_table (struct caml_custom_table *,
71+
asize_t, asize_t);
6072
extern void caml_oldify_one (value, value *);
6173
extern void caml_oldify_mopup (void);
6274

@@ -90,4 +102,18 @@ static inline void add_to_ephe_ref_table (struct caml_ephe_ref_table *tbl,
90102
Assert(ephe_ref->offset < Wosize_val(ephe_ref->ephe));
91103
}
92104

105+
static inline void add_to_custom_table (struct caml_custom_table *tbl, value v,
106+
mlsize_t mem, mlsize_t max)
107+
{
108+
struct caml_custom_elt *elt;
109+
if (tbl->ptr >= tbl->limit){
110+
CAMLassert (tbl->ptr == tbl->limit);
111+
caml_realloc_custom_table (tbl);
112+
}
113+
elt = tbl->ptr++;
114+
elt->block = v;
115+
elt->mem = mem;
116+
elt->max = max;
117+
}
118+
93119
#endif /* CAML_MINOR_GC_H */

byterun/compact.c

+1
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ void caml_compact_heap (void)
405405
CAMLassert (caml_young_ptr == caml_young_alloc_end);
406406
CAMLassert (caml_ref_table.ptr == caml_ref_table.base);
407407
CAMLassert (caml_ephe_ref_table.ptr == caml_ephe_ref_table.base);
408+
CAMLassert (caml_custom_table.ptr == caml_custom_table.base);
408409

409410
do_compaction ();
410411
CAML_INSTR_TIME (tmr, "compact/main");

byterun/custom.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,9 @@ CAMLexport value caml_alloc_custom(struct custom_operations * ops,
3434
if (wosize <= Max_young_wosize) {
3535
result = caml_alloc_small(wosize, Custom_tag);
3636
Custom_ops_val(result) = ops;
37-
if (ops->finalize != NULL) {
38-
/* Remembered that the block has a finalizer */
39-
if (caml_finalize_table.ptr >= caml_finalize_table.limit){
40-
CAMLassert (caml_finalize_table.ptr == caml_finalize_table.limit);
41-
caml_realloc_ref_table (&caml_finalize_table);
42-
}
43-
*caml_finalize_table.ptr++ = (value *)result;
37+
if (ops->finalize != NULL || mem != 0) {
38+
/* Remember that the block needs processing after minor GC. */
39+
add_to_custom_table (&caml_custom_table, result, mem, max);
4440
}
4541
} else {
4642
result = caml_alloc_shr(wosize, Custom_tag);

byterun/gc_ctrl.c

-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ CAMLprim value caml_gc_major_slice (value v)
501501
{
502502
CAML_INSTR_SETUP (tmr, "");
503503
Assert (Is_long (v));
504-
caml_empty_minor_heap ();
505504
caml_major_collection_slice (Long_val (v));
506505
CAML_INSTR_TIME (tmr, "explicit/gc_major_slice");
507506
return Val_long (0);

byterun/intern.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,8 @@ static void intern_rec(value *dest)
531531
Custom_ops_val(v) = ops;
532532

533533
if (ops->finalize != NULL && Is_young(v)) {
534-
/* Remembered that the block has a finalizer */
535-
if (caml_finalize_table.ptr >= caml_finalize_table.limit){
536-
CAMLassert (caml_finalize_table.ptr == caml_finalize_table.limit);
537-
caml_realloc_ref_table (&caml_finalize_table);
538-
}
539-
*caml_finalize_table.ptr++ = (value *)v;
534+
/* Remember that the block has a finalizer. */
535+
add_to_custom_table (&caml_custom_table, v, 0, 1);
540536
}
541537

542538
intern_dest += 1 + size;

byterun/major_gc.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "caml/misc.h"
2929
#include "caml/mlvalues.h"
3030
#include "caml/roots.h"
31+
#include "caml/signals.h"
3132
#include "caml/weak.h"
3233

3334
#if defined (NATIVE_CODE) && defined (NO_NAKED_POINTERS)
@@ -568,6 +569,7 @@ static void sweep_slice (intnat work)
568569
++ caml_stat_major_collections;
569570
work = 0;
570571
caml_gc_phase = Phase_idle;
572+
caml_request_minor_gc ();
571573
}else{
572574
caml_gc_sweep_hp = chunk;
573575
limit = chunk + Chunk_size (chunk);
@@ -753,7 +755,7 @@ void caml_major_collection_slice (intnat howmuch)
753755
}
754756

755757
if (caml_gc_phase == Phase_mark || caml_gc_phase == Phase_clean){
756-
computed_work = (intnat) (p * (caml_stat_heap_wsz * 250
758+
computed_work = (intnat) (p * ((double) caml_stat_heap_wsz * 250
757759
/ (100 + caml_percent_free)
758760
+ caml_incremental_roots_count));
759761
}else{

0 commit comments

Comments
 (0)