summaryrefslogtreecommitdiff
path: root/byterun
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2015-07-17 14:31:05 +0000
committerDamien Doligez <damien.doligez-inria.fr>2015-07-17 14:31:05 +0000
commit860c670848440f791d1b9c68a1ace8fb629da234 (patch)
tree6b856e6a04cf876221c6740e8df75a8778a3b8b7 /byterun
parent7fdba8f53360d9355dc96953a0d8225e111ab722 (diff)
downloadocaml-860c670848440f791d1b9c68a1ace8fb629da234.tar.gz
merge branch 4.02 from 4.02.1 (rev 15540) to a few fixes after 4.02.2 (rev 16205)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16214 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun')
-rw-r--r--byterun/Makefile2
-rw-r--r--byterun/Makefile.common8
-rw-r--r--byterun/Makefile.nt4
-rw-r--r--byterun/alloc.c4
-rw-r--r--byterun/backtrace.c16
-rw-r--r--byterun/callback.c11
-rw-r--r--byterun/caml/callback.h2
-rw-r--r--byterun/caml/hash.h10
-rw-r--r--byterun/caml/misc.h15
-rw-r--r--byterun/caml/mlvalues.h4
-rw-r--r--byterun/fix_code.c66
-rw-r--r--byterun/floats.c4
-rw-r--r--byterun/major_gc.c29
-rw-r--r--byterun/md5.c14
-rw-r--r--byterun/minor_gc.c16
-rw-r--r--byterun/misc.c7
-rw-r--r--byterun/sys.c2
-rw-r--r--byterun/unix.c8
18 files changed, 158 insertions, 64 deletions
diff --git a/byterun/Makefile b/byterun/Makefile
index 6872fe612b..ae57e2a7aa 100644
--- a/byterun/Makefile
+++ b/byterun/Makefile
@@ -13,7 +13,7 @@
include Makefile.common
-CFLAGS=-DCAML_NAME_SPACE -O $(BYTECCCOMPOPTS) $(IFLEXDIR)
+CFLAGS=-DCAML_NAME_SPACE $(BYTECCCOMPOPTS) $(IFLEXDIR)
DFLAGS=-DCAML_NAME_SPACE -g -DDEBUG $(BYTECCCOMPOPTS) $(IFLEXDIR)
OBJS=$(COMMONOBJS) $(UNIX_OR_WIN32).o main.o
diff --git a/byterun/Makefile.common b/byterun/Makefile.common
index d942251491..36e93325a7 100644
--- a/byterun/Makefile.common
+++ b/byterun/Makefile.common
@@ -12,6 +12,8 @@
#########################################################################
include ../config/Makefile
+CAMLRUN ?= ../boot/ocamlrun
+CAMLYACC ?= ../boot/ocamlyacc
CC=$(BYTECC)
@@ -57,7 +59,7 @@ INSTALL_LIBDIR=$(DESTDIR)$(LIBDIR)
install::
- cp ocamlrun$(EXE) $(INSTALL_BINDIR)/ocamlrun$(EXE)
+ cp $(CAMLRUN)$(EXE) $(INSTALL_BINDIR)/ocamlrun$(EXE)
cp libcamlrun.$(A) $(INSTALL_LIBDIR)/libcamlrun.$(A)
cd $(INSTALL_LIBDIR); $(RANLIB) libcamlrun.$(A)
if test -d $(INSTALL_LIBDIR)/caml; then : ; \
@@ -73,6 +75,10 @@ install:: install-$(RUNTIMED)
install-noruntimed:
.PHONY: install-noruntimed
+# TODO: when cross-compiling, do not install ocamlrund
+# it doesn't hurt to install it, but it's useless and might be confusing
+# because it's an executable for the target machine, while we're installing
+# binaries for the host.
install-runtimed:
cp ocamlrund$(EXE) $(INSTALL_BINDIR)/ocamlrund$(EXE)
cp libcamlrund.$(A) $(INSTALL_LIBDIR)/libcamlrund.$(A)
diff --git a/byterun/Makefile.nt b/byterun/Makefile.nt
index 5043d45617..257e364416 100644
--- a/byterun/Makefile.nt
+++ b/byterun/Makefile.nt
@@ -24,7 +24,7 @@ ocamlrun$(EXE): libcamlrun.$(A) prims.$(O)
$(EXTRALIBS) libcamlrun.$(A)
ocamlrund$(EXE): libcamlrund.$(A) prims.$(O) main.$(O)
- $(MKEXE) -o ocamlrun$(EXE) $(BYTECCDBGCOMPOPTS) prims.$(O) \
+ $(MKEXE) -o ocamlrund$(EXE) $(BYTECCDBGCOMPOPTS) prims.$(O) \
$(call SYSLIB,ws2_32) $(EXTRALIBS) libcamlrund.$(A)
libcamlrun.$(A): $(OBJS)
@@ -34,7 +34,7 @@ libcamlrund.$(A): $(DOBJS)
$(call MKLIB,libcamlrund.$(A),$(DOBJS))
%.$(O): %.c
- $(CC) $(CFLAGS) $(BYTECCCOMPOPTS) -c -o $@ $<
+ $(CC) $(CFLAGS) $(BYTECCCOMPOPTS) -c $<
%.$(DBGO): %.c
$(CC) $(CFLAGS) $(BYTECCDBGCOMPOPTS) -c -o $@ $<
diff --git a/byterun/alloc.c b/byterun/alloc.c
index 96a21bf1f5..8afc5b7859 100644
--- a/byterun/alloc.c
+++ b/byterun/alloc.c
@@ -198,3 +198,7 @@ CAMLprim value caml_update_dummy(value dummy, value newval)
}
return Val_unit;
}
+
+
+
+
diff --git a/byterun/backtrace.c b/byterun/backtrace.c
index de658891d9..82a3eed30c 100644
--- a/byterun/backtrace.c
+++ b/byterun/backtrace.c
@@ -306,15 +306,15 @@ void caml_stash_backtrace(value exn, code_t pc, value * sp, int reraise)
#define Codet_Val(v) ((code_t)(Long_val(v)<<1))
/* returns the next frame pointer (or NULL if none is available);
- updates *sp to point to the following one, and *trapsp to the next
+ updates *sp to point to the following one, and *trsp to the next
trap frame, which we will skip when we reach it */
-code_t caml_next_frame_pointer(value ** sp, value ** trapsp)
+code_t caml_next_frame_pointer(value ** sp, value ** trsp)
{
while (*sp < caml_stack_high) {
code_t *p = (code_t*) (*sp)++;
- if(&Trap_pc(*trapsp) == p) {
- *trapsp = Trap_link(*trapsp);
+ if(&Trap_pc(*trsp) == p) {
+ *trsp = Trap_link(*trsp);
continue;
}
@@ -343,10 +343,10 @@ CAMLprim value caml_get_current_callstack(value max_frames_value) {
/* first compute the size of the trace */
{
value * sp = caml_extern_sp;
- value * trapsp = caml_trapsp;
+ value * trsp = caml_trapsp;
for (trace_size = 0; trace_size < max_frames; trace_size++) {
- code_t p = caml_next_frame_pointer(&sp, &trapsp);
+ code_t p = caml_next_frame_pointer(&sp, &trsp);
if (p == NULL) break;
}
}
@@ -356,11 +356,11 @@ CAMLprim value caml_get_current_callstack(value max_frames_value) {
/* then collect the trace */
{
value * sp = caml_extern_sp;
- value * trapsp = caml_trapsp;
+ value * trsp = caml_trapsp;
uintnat trace_pos;
for (trace_pos = 0; trace_pos < trace_size; trace_pos++) {
- code_t p = caml_next_frame_pointer(&sp, &trapsp);
+ code_t p = caml_next_frame_pointer(&sp, &trsp);
Assert(p != NULL);
Field(trace, trace_pos) = Val_Codet(p);
}
diff --git a/byterun/callback.c b/byterun/callback.c
index bb149d7019..3010985162 100644
--- a/byterun/callback.c
+++ b/byterun/callback.c
@@ -245,3 +245,14 @@ CAMLexport value * caml_named_value(char const *name)
}
return NULL;
}
+
+CAMLexport void caml_iterate_named_values(caml_named_action f)
+{
+ int i;
+ for(i = 0; i < Named_value_size; i++){
+ struct named_value * nv;
+ for (nv = named_value_table[i]; nv != NULL; nv = nv->next) {
+ f( &nv->val, nv->name );
+ }
+ }
+}
diff --git a/byterun/caml/callback.h b/byterun/caml/callback.h
index ded0b9801c..ef50945cfc 100644
--- a/byterun/caml/callback.h
+++ b/byterun/caml/callback.h
@@ -42,6 +42,8 @@ CAMLextern value caml_callbackN_exn (value closure, int narg, value args[]);
#define Extract_exception(v) ((v) & ~3)
CAMLextern value * caml_named_value (char const * name);
+typedef void (*caml_named_action) (value*, char *);
+CAMLextern void caml_iterate_named_values(caml_named_action f);
CAMLextern void caml_main (char ** argv);
CAMLextern void caml_startup (char ** argv);
diff --git a/byterun/caml/hash.h b/byterun/caml/hash.h
index 65613975b8..d130068c48 100644
--- a/byterun/caml/hash.h
+++ b/byterun/caml/hash.h
@@ -18,6 +18,10 @@
#include "mlvalues.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
CAMLextern uint32_t caml_hash_mix_uint32(uint32_t h, uint32_t d);
CAMLextern uint32_t caml_hash_mix_intnat(uint32_t h, intnat d);
CAMLextern uint32_t caml_hash_mix_int64(uint32_t h, int64_t d);
@@ -25,5 +29,9 @@ CAMLextern uint32_t caml_hash_mix_double(uint32_t h, double d);
CAMLextern uint32_t caml_hash_mix_float(uint32_t h, float d);
CAMLextern uint32_t caml_hash_mix_string(uint32_t h, value s);
-
+#ifdef __cplusplus
+extern "C" {
#endif
+
+
+#endif /* CAML_HASH_H */
diff --git a/byterun/caml/misc.h b/byterun/caml/misc.h
index b2d44252aa..a7441dbc94 100644
--- a/byterun/caml/misc.h
+++ b/byterun/caml/misc.h
@@ -59,6 +59,17 @@ typedef char * addr;
#define CAMLweakdef
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* GC timing hooks. These can be assigned by the user. The hook functions
+ must not allocate or change the heap in any way. */
+typedef void (*caml_timing_hook) (void);
+extern caml_timing_hook caml_major_slice_begin_hook, caml_major_slice_end_hook;
+extern caml_timing_hook caml_minor_gc_begin_hook, caml_minor_gc_end_hook;
+extern caml_timing_hook caml_finalise_begin_hook, caml_finalise_end_hook;
+
/* Assertions */
#ifdef DEBUG
@@ -156,4 +167,8 @@ extern int caml_snprintf(char * buf, size_t size, const char * format, ...);
/* </private> */
+#ifdef __cplusplus
+}
+#endif
+
#endif /* CAML_MISC_H */
diff --git a/byterun/caml/mlvalues.h b/byterun/caml/mlvalues.h
index 96c18aae3d..3b94d010c6 100644
--- a/byterun/caml/mlvalues.h
+++ b/byterun/caml/mlvalues.h
@@ -296,10 +296,10 @@ CAMLextern header_t caml_atom_table[];
extern value caml_global_data;
+CAMLextern value caml_set_oo_id(value obj);
+
#ifdef __cplusplus
}
#endif
-CAMLextern value caml_set_oo_id(value obj);
-
#endif /* CAML_MLVALUES_H */
diff --git a/byterun/fix_code.c b/byterun/fix_code.c
index 1efb7b15ed..e605290615 100644
--- a/byterun/fix_code.c
+++ b/byterun/fix_code.c
@@ -95,33 +95,44 @@ void caml_fixup_endianness(code_t code, asize_t len)
char ** caml_instr_table;
char * caml_instr_base;
-void caml_thread_code (code_t code, asize_t len)
+static int* opcode_nargs = NULL;
+int* caml_init_opcode_nargs()
{
- code_t p;
- int l [FIRST_UNIMPLEMENTED_OP];
- int i;
+ if( opcode_nargs == NULL ){
+ int* l = (int*)caml_stat_alloc(sizeof(int) * FIRST_UNIMPLEMENTED_OP);
+ int i;
- for (i = 0; i < FIRST_UNIMPLEMENTED_OP; i++) {
- l [i] = 0;
+ for (i = 0; i < FIRST_UNIMPLEMENTED_OP; i++) {
+ l [i] = 0;
+ }
+ /* Instructions with one operand */
+ l[PUSHACC] = l[ACC] = l[POP] = l[ASSIGN] =
+ l[PUSHENVACC] = l[ENVACC] = l[PUSH_RETADDR] = l[APPLY] =
+ l[APPTERM1] = l[APPTERM2] = l[APPTERM3] = l[RETURN] =
+ l[GRAB] = l[PUSHGETGLOBAL] = l[GETGLOBAL] = l[SETGLOBAL] =
+ l[PUSHATOM] = l[ATOM] = l[MAKEBLOCK1] = l[MAKEBLOCK2] =
+ l[MAKEBLOCK3] = l[MAKEFLOATBLOCK] = l[GETFIELD] =
+ l[GETFLOATFIELD] = l[SETFIELD] = l[SETFLOATFIELD] =
+ l[BRANCH] = l[BRANCHIF] = l[BRANCHIFNOT] = l[PUSHTRAP] =
+ l[C_CALL1] = l[C_CALL2] = l[C_CALL3] = l[C_CALL4] = l[C_CALL5] =
+ l[CONSTINT] = l[PUSHCONSTINT] = l[OFFSETINT] =
+ l[OFFSETREF] = l[OFFSETCLOSURE] = l[PUSHOFFSETCLOSURE] = 1;
+
+ /* Instructions with two operands */
+ l[APPTERM] = l[CLOSURE] = l[PUSHGETGLOBALFIELD] =
+ l[GETGLOBALFIELD] = l[MAKEBLOCK] = l[C_CALLN] =
+ l[BEQ] = l[BNEQ] = l[BLTINT] = l[BLEINT] = l[BGTINT] = l[BGEINT] =
+ l[BULTINT] = l[BUGEINT] = l[GETPUBMET] = 2;
+
+ opcode_nargs = l;
}
- /* Instructions with one operand */
- l[PUSHACC] = l[ACC] = l[POP] = l[ASSIGN] =
- l[PUSHENVACC] = l[ENVACC] = l[PUSH_RETADDR] = l[APPLY] =
- l[APPTERM1] = l[APPTERM2] = l[APPTERM3] = l[RETURN] =
- l[GRAB] = l[PUSHGETGLOBAL] = l[GETGLOBAL] = l[SETGLOBAL] =
- l[PUSHATOM] = l[ATOM] = l[MAKEBLOCK1] = l[MAKEBLOCK2] =
- l[MAKEBLOCK3] = l[MAKEFLOATBLOCK] = l[GETFIELD] =
- l[GETFLOATFIELD] = l[SETFIELD] = l[SETFLOATFIELD] =
- l[BRANCH] = l[BRANCHIF] = l[BRANCHIFNOT] = l[PUSHTRAP] =
- l[C_CALL1] = l[C_CALL2] = l[C_CALL3] = l[C_CALL4] = l[C_CALL5] =
- l[CONSTINT] = l[PUSHCONSTINT] = l[OFFSETINT] =
- l[OFFSETREF] = l[OFFSETCLOSURE] = l[PUSHOFFSETCLOSURE] = 1;
-
- /* Instructions with two operands */
- l[APPTERM] = l[CLOSURE] = l[PUSHGETGLOBALFIELD] =
- l[GETGLOBALFIELD] = l[MAKEBLOCK] = l[C_CALLN] =
- l[BEQ] = l[BNEQ] = l[BLTINT] = l[BLEINT] = l[BGTINT] = l[BGEINT] =
- l[BULTINT] = l[BUGEINT] = l[GETPUBMET] = 2;
+ return opcode_nargs;
+}
+
+void caml_thread_code (code_t code, asize_t len)
+{
+ code_t p;
+ int* l = caml_init_opcode_nargs();
len /= sizeof(opcode_t);
for (p = code; p < code + len; /*nothing*/) {
opcode_t instr = *p;
@@ -149,6 +160,13 @@ void caml_thread_code (code_t code, asize_t len)
Assert(p == code + len);
}
+#else
+
+int* caml_init_opcode_nargs()
+{
+ return NULL;
+}
+
#endif /* THREADED_CODE */
void caml_set_instruction(code_t pos, opcode_t instr)
diff --git a/byterun/floats.c b/byterun/floats.c
index 69c5328510..544dc06efd 100644
--- a/byterun/floats.c
+++ b/byterun/floats.c
@@ -150,6 +150,7 @@ CAMLprim value caml_float_of_string(value vs)
error:
if (buf != parse_buffer) caml_stat_free(buf);
caml_failwith("float_of_string");
+ return Val_unit; /* not reached */
}
CAMLprim value caml_int_of_float(value f)
@@ -452,7 +453,8 @@ enum { FP_normal, FP_subnormal, FP_zero, FP_infinite, FP_nan };
CAMLprim value caml_classify_float(value vd)
{
/* Cygwin 1.3 has problems with fpclassify (PR#1293), so don't use it */
-#if defined(fpclassify) && !defined(__CYGWIN32__) && !defined(__MINGW32__)
+ /* FIXME Cygwin 1.3 is ancient! Revisit this decision. */
+#if defined(fpclassify) && !defined(__CYGWIN__) && !defined(__MINGW32__)
switch (fpclassify(Double_val(vd))) {
case FP_NAN:
return Val_int(FP_nan);
diff --git a/byterun/major_gc.c b/byterun/major_gc.c
index 5c50c8980d..41eb4215db 100644
--- a/byterun/major_gc.c
+++ b/byterun/major_gc.c
@@ -59,6 +59,8 @@ static value *weak_prev;
static unsigned long major_gc_counter = 0;
#endif
+void (*caml_major_gc_hook)(void) = NULL;
+
static void realloc_gray_vals (void)
{
value *new;
@@ -90,13 +92,6 @@ void caml_darken (value v, value *p /* not used */)
{
#ifdef NATIVE_CODE_AND_NO_NAKED_POINTERS
if (Is_block (v) && Wosize_val (v) > 0) {
- /* We insist that naked pointers to outside the heap point to things that
- look like values with headers coloured black. This isn't always
- strictly necessary but is essential in certain cases---in particular
- when the value is allocated in a read-only section. (For the values
- where it would be safe it is a performance improvement since we avoid
- putting them on the grey list.) */
- CAMLassert (Is_in_heap (v) || Is_black_hd (Hd_val (v)));
#else
if (Is_block (v) && Is_in_heap (v)) {
#endif
@@ -107,6 +102,15 @@ void caml_darken (value v, value *p /* not used */)
h = Hd_val (v);
t = Tag_hd (h);
}
+#ifdef NATIVE_CODE_AND_NO_NAKED_POINTERS
+ /* We insist that naked pointers to outside the heap point to things that
+ look like values with headers coloured black. This isn't always
+ strictly necessary but is essential in certain cases---in particular
+ when the value is allocated in a read-only section. (For the values
+ where it would be safe it is a performance improvement since we avoid
+ putting them on the grey list.) */
+ CAMLassert (Is_in_heap (v) || Is_black_hd (h));
+#endif
CAMLassert (!Is_blue_hd (h));
if (Is_white_hd (h)){
if (t < No_scan_tag){
@@ -145,6 +149,7 @@ static void mark_slice (intnat work)
int marking_closure = 0;
#endif
+ if (caml_major_slice_begin_hook != NULL) (*caml_major_slice_begin_hook) ();
caml_gc_message (0x40, "Marking %ld words\n", work);
caml_gc_message (0x40, "Subphase = %ld\n", caml_gc_subphase);
gray_vals_ptr = gray_vals_cur;
@@ -169,8 +174,6 @@ static void mark_slice (intnat work)
be reliably determined, so we always use the page table when
marking such values. */
&& (!marking_closure || Is_in_heap (child))) {
- /* See [caml_darken] for a description of this assertion. */
- CAMLassert (Is_in_heap (child) || Is_black_hd (Hd_val (child)));
#else
if (Is_block (child) && Is_in_heap (child)) {
#endif
@@ -189,6 +192,10 @@ static void mark_slice (intnat work)
child -= Infix_offset_val(child);
hd = Hd_val(child);
}
+#ifdef NATIVE_CODE_AND_NO_NAKED_POINTERS
+ /* See [caml_darken] for a description of this assertion. */
+ CAMLassert (Is_in_heap (child) || Is_black_hd (hd));
+#endif
if (Is_white_hd (hd)){
Hd_val (child) = Grayhd_hd (hd);
*gray_vals_ptr++ = child;
@@ -307,6 +314,7 @@ static void mark_slice (intnat work)
limit = chunk + Chunk_size (chunk);
work = 0;
caml_fl_wsz_at_phase_change = caml_fl_cur_wsz;
+ if (caml_major_gc_hook) (*caml_major_gc_hook)();
}
break;
default: Assert (0);
@@ -314,6 +322,7 @@ static void mark_slice (intnat work)
}
}
gray_vals_cur = gray_vals_ptr;
+ if (caml_major_slice_end_hook != NULL) (*caml_major_slice_end_hook) ();
}
static void sweep_slice (intnat work)
@@ -321,6 +330,7 @@ static void sweep_slice (intnat work)
char *hp;
header_t hd;
+ if (caml_major_slice_begin_hook != NULL) (*caml_major_slice_begin_hook) ();
caml_gc_message (0x40, "Sweeping %ld words\n", work);
while (work > 0){
if (caml_gc_sweep_hp < limit){
@@ -359,6 +369,7 @@ static void sweep_slice (intnat work)
}
}
}
+ if (caml_major_slice_end_hook != NULL) (*caml_major_slice_end_hook) ();
}
/* The main entry point for the GC. Called after each minor GC.
diff --git a/byterun/md5.c b/byterun/md5.c
index cc6d31a0c3..7a996b6b9f 100644
--- a/byterun/md5.c
+++ b/byterun/md5.c
@@ -33,18 +33,16 @@ CAMLprim value caml_md5_string(value str, value ofs, value len)
return res;
}
-CAMLprim value caml_md5_chan(value vchan, value len)
+CAMLexport value caml_md5_channel(struct channel *chan, intnat toread)
{
- CAMLparam2 (vchan, len);
- struct channel * chan = Channel(vchan);
+ CAMLparam0();
struct MD5Context ctx;
value res;
- intnat toread, read;
+ intnat read;
char buffer[4096];
Lock(chan);
caml_MD5Init(&ctx);
- toread = Long_val(len);
if (toread < 0){
while (1){
read = caml_getblock (chan, buffer, sizeof(buffer));
@@ -66,6 +64,12 @@ CAMLprim value caml_md5_chan(value vchan, value len)
CAMLreturn (res);
}
+CAMLprim value caml_md5_chan(value vchan, value len)
+{
+ CAMLparam2 (vchan, len);
+ CAMLreturn (caml_md5_channel(Channel(vchan), Long_val(len)));
+}
+
CAMLexport void caml_md5_block(unsigned char digest[16],
void * data, uintnat len)
{
diff --git a/byterun/minor_gc.c b/byterun/minor_gc.c
index ec468560e1..079e686683 100644
--- a/byterun/minor_gc.c
+++ b/byterun/minor_gc.c
@@ -227,8 +227,11 @@ void caml_oldify_mopup (void)
void caml_empty_minor_heap (void)
{
value **r;
+ uintnat prev_alloc_words;
if (caml_young_ptr != caml_young_end){
+ if (caml_minor_gc_begin_hook != NULL) (*caml_minor_gc_begin_hook) ();
+ prev_alloc_words = caml_allocated_words;
caml_in_minor_collection = 1;
caml_gc_message (0x02, "<", 0);
caml_oldify_local_roots();
@@ -253,8 +256,13 @@ void caml_empty_minor_heap (void)
clear_table (&caml_weak_ref_table);
caml_gc_message (0x02, ">", 0);
caml_in_minor_collection = 0;
+ caml_stat_promoted_words += caml_allocated_words - prev_alloc_words;
+ ++ caml_stat_minor_collections;
+ caml_final_empty_young ();
+ if (caml_minor_gc_end_hook != NULL) (*caml_minor_gc_end_hook) ();
+ }else{
+ caml_final_empty_young ();
}
- caml_final_empty_young ();
#ifdef DEBUG
{
value *p;
@@ -272,16 +280,14 @@ void caml_empty_minor_heap (void)
*/
CAMLexport void caml_minor_collection (void)
{
- intnat prev_alloc_words = caml_allocated_words;
-
caml_empty_minor_heap ();
- caml_stat_promoted_words += caml_allocated_words - prev_alloc_words;
- ++ caml_stat_minor_collections;
caml_major_collection_slice (0);
caml_force_major_slice = 0;
+ if (caml_finalise_begin_hook != NULL) (*caml_finalise_begin_hook) ();
caml_final_do_calls ();
+ if (caml_finalise_end_hook != NULL) (*caml_finalise_end_hook) ();
caml_empty_minor_heap ();
}
diff --git a/byterun/misc.c b/byterun/misc.c
index 03e5f57d1e..09b2d85dbb 100644
--- a/byterun/misc.c
+++ b/byterun/misc.c
@@ -18,6 +18,13 @@
#include "caml/misc.h"
#include "caml/memory.h"
+caml_timing_hook caml_major_slice_begin_hook = NULL;
+caml_timing_hook caml_major_slice_end_hook = NULL;
+caml_timing_hook caml_minor_gc_begin_hook = NULL;
+caml_timing_hook caml_minor_gc_end_hook = NULL;
+caml_timing_hook caml_finalise_begin_hook = NULL;
+caml_timing_hook caml_finalise_end_hook = NULL;
+
#ifdef DEBUG
int caml_failed_assert (char * expr, char * file, int line)
diff --git a/byterun/sys.c b/byterun/sys.c
index f54c92ab10..97c576dd59 100644
--- a/byterun/sys.c
+++ b/byterun/sys.c
@@ -280,7 +280,7 @@ CAMLprim value caml_sys_getenv(value var)
}
char * caml_exe_name;
-static char ** caml_main_argv;
+char ** caml_main_argv;
CAMLprim value caml_sys_get_argv(value unit)
{
diff --git a/byterun/unix.c b/byterun/unix.c
index a76ab22f72..38ddee0056 100644
--- a/byterun/unix.c
+++ b/byterun/unix.c
@@ -24,7 +24,7 @@
#include <fcntl.h>
#include "caml/config.h"
#ifdef SUPPORT_DYNAMIC_LINKING
-#ifdef __CYGWIN32__
+#ifdef __CYGWIN__
#include "flexdll.h"
#else
#include <dlfcn.h>
@@ -86,7 +86,7 @@ char * caml_search_in_path(struct ext_table * path, char * name)
return caml_strdup(name);
}
-#ifdef __CYGWIN32__
+#ifdef __CYGWIN__
/* Cygwin needs special treatment because of the implicit ".exe" at the
end of executable file names */
@@ -137,7 +137,7 @@ char * caml_search_exe_in_path(char * name)
caml_ext_table_init(&path, 8);
tofree = caml_decompose_path(&path, getenv("PATH"));
-#ifndef __CYGWIN32__
+#ifndef __CYGWIN__
res = caml_search_in_path(&path, name);
#else
res = cygwin_search_exe_in_path(&path, name);
@@ -159,7 +159,7 @@ char * caml_search_dll_in_path(struct ext_table * path, char * name)
}
#ifdef SUPPORT_DYNAMIC_LINKING
-#ifdef __CYGWIN32__
+#ifdef __CYGWIN__
/* Use flexdll */
void * caml_dlopen(char * libname, int for_execution, int global)