diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2002-01-18 15:13:26 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2002-01-18 15:13:26 +0000 |
commit | 09a8c6bc78f4a84c99b68baef2a1dfb10b8c4a4e (patch) | |
tree | 5af49766e2f79faac1b5cd24b6fe7e3247ed82dc | |
parent | e0c8e458d294b4d6bfeafcaba75ebede3dc22b5a (diff) |
configure: suppression "smart preprocessing" pour MacOS X
asmrun/roots.c, byterun/alloc.c, byterun/gc_ctrl.c, byterun/minor_gc.c,
byterun/minor_gc.h, byterun/roots.c, byterun/startup.c:
derecursivation du GC mineur
byterun/config.h, stdlib/gc.mli: compactage active par defaut (300%)
otherlibs/unix/select.c: ajout include MacOS X
.cvsignore: bricoles
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4264 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | .cvsignore | 1 | ||||
-rw-r--r-- | asmcomp/.cvsignore | 5 | ||||
-rw-r--r-- | asmrun/.cvsignore | 33 | ||||
-rw-r--r-- | asmrun/roots.c | 15 | ||||
-rwxr-xr-x | boot/ocamlc | bin | 791683 -> 792324 bytes | |||
-rwxr-xr-x | boot/ocamllex | bin | 89192 -> 89224 bytes | |||
-rw-r--r-- | byterun/alloc.c | 1 | ||||
-rw-r--r-- | byterun/config.h | 7 | ||||
-rw-r--r-- | byterun/gc_ctrl.c | 4 | ||||
-rw-r--r-- | byterun/minor_gc.c | 101 | ||||
-rw-r--r-- | byterun/minor_gc.h | 10 | ||||
-rw-r--r-- | byterun/roots.c | 13 | ||||
-rw-r--r-- | byterun/startup.c | 6 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | otherlibs/threads/.cvsignore | 3 | ||||
-rw-r--r-- | otherlibs/unix/select.c | 2 | ||||
-rw-r--r-- | stdlib/.cvsignore | 3 | ||||
-rw-r--r-- | stdlib/gc.mli | 5 | ||||
-rw-r--r-- | utils/config.mlp | 4 |
19 files changed, 153 insertions, 64 deletions
diff --git a/.cvsignore b/.cvsignore index 6f1c4aba7..f3bf63a19 100644 --- a/.cvsignore +++ b/.cvsignore @@ -4,3 +4,4 @@ expunge ocaml ocamlopt ocamlopt.opt +ocamlrun diff --git a/asmcomp/.cvsignore b/asmcomp/.cvsignore index 7be3bff6e..31d00178a 100644 --- a/asmcomp/.cvsignore +++ b/asmcomp/.cvsignore @@ -1 +1,6 @@ emit.ml +arch.ml +proc.ml +selection.ml +reload.ml +scheduling.ml diff --git a/asmrun/.cvsignore b/asmrun/.cvsignore new file mode 100644 index 000000000..ee21b3599 --- /dev/null +++ b/asmrun/.cvsignore @@ -0,0 +1,33 @@ +main.c +misc.c +freelist.c +major_gc.c +minor_gc.c +memory.c +alloc.c +array.c +compare.c +ints.c +floats.c +str.c +io.c +extern.c +intern.c +hash.c +sys.c +parsing.c +gc_ctrl.c +terminfo.c +md5.c +obj.c +lexing.c +printexc.c +callback.c +weak.c +compact.c +finalise.c +custom.c +meta.c +globroots.c +unix.c +dynlink.c diff --git a/asmrun/roots.c b/asmrun/roots.c index e818e91ec..a1eb34805 100644 --- a/asmrun/roots.c +++ b/asmrun/roots.c @@ -97,7 +97,8 @@ value * caml_gc_regs; long caml_globals_inited = 0; static long caml_globals_scanned = 0; -/* Call [oldify] on (at least) all the roots that point to the minor heap. */ +/* Call [oldify_one] on (at least) all the roots that point to the minor + heap. */ void oldify_local_roots (void) { char * sp; @@ -118,7 +119,7 @@ void oldify_local_roots (void) i++) { glob = caml_globals[i]; for (j = 0; j < Wosize_val(glob); j++){ - oldify(Field(glob, j), &Field(glob, j)); + oldify_one (Field(glob, j), &Field(glob, j)); } } caml_globals_scanned = caml_globals_inited; @@ -146,7 +147,7 @@ void oldify_local_roots (void) } else { root = (value *)(sp + ofs); } - oldify(*root, root); + oldify_one (*root, root); } /* Move to next frame */ #ifndef Stack_grows_upwards @@ -178,18 +179,18 @@ void oldify_local_roots (void) for (i = 0; i < lr->ntables; i++){ for (j = 0; j < lr->nitems; j++){ root = &(lr->tables[i][j]); - oldify (*root, root); + oldify_one (*root, root); } } } /* Global C roots */ for (gr = caml_global_roots.forward[0]; gr != NULL; gr = gr->forward[0]) { - oldify(*(gr->root), gr->root); + oldify_one (*(gr->root), gr->root); } /* Finalised values */ - final_do_young_roots (&oldify); + final_do_young_roots (&oldify_one); /* Hook */ - if (scan_roots_hook != NULL) (*scan_roots_hook)(oldify); + if (scan_roots_hook != NULL) (*scan_roots_hook)(oldify_one); } /* Call [darken] on all roots */ diff --git a/boot/ocamlc b/boot/ocamlc Binary files differindex edaf9fb57..54c1fcbd2 100755 --- a/boot/ocamlc +++ b/boot/ocamlc diff --git a/boot/ocamllex b/boot/ocamllex Binary files differindex 3168356a3..480630695 100755 --- a/boot/ocamllex +++ b/boot/ocamllex diff --git a/byterun/alloc.c b/byterun/alloc.c index 41dafdc4f..97d57b977 100644 --- a/byterun/alloc.c +++ b/byterun/alloc.c @@ -35,6 +35,7 @@ CAMLexport value alloc (mlsize_t wosize, tag_t tag) mlsize_t i; Assert (tag < 256); + Assert (tag != Infix_tag); if (wosize == 0){ result = Atom (tag); }else if (wosize <= Max_young_wosize){ diff --git a/byterun/config.h b/byterun/config.h index 812ab88cc..13276a197 100644 --- a/byterun/config.h +++ b/byterun/config.h @@ -124,11 +124,12 @@ typedef uint64 int64; /* Default speed setting for the major GC. The heap will grow until the dead objects and the free list represent this percentage of the - heap size. The rest of the heap is live objects. */ + total size of live objects. */ #define Percent_free_def 42 -/* Default setting for the compacter: off */ -#define Max_percent_free_def 1000000 +/* Default setting for the compacter: 300% + (i.e. trigger the compacter when 3/4 of the heap is free) */ +#define Max_percent_free_def 300 #endif /* _config_ */ diff --git a/byterun/gc_ctrl.c b/byterun/gc_ctrl.c index 1871d8cc2..6d945359e 100644 --- a/byterun/gc_ctrl.c +++ b/byterun/gc_ctrl.c @@ -207,7 +207,7 @@ static value heap_stats (int returnstats) double majwords = stat_major_words + (double) allocated_words; long mincoll = stat_major_collections; long majcoll = stat_minor_collections; - long heapsz = stat_heap_size; + long heap_words = Wsize_bsize (stat_heap_size); long cpct = stat_compactions; res = alloc_tuple (14); @@ -216,7 +216,7 @@ static value heap_stats (int returnstats) Store_field (res, 2, copy_double (majwords)); Store_field (res, 3, Val_long (mincoll)); Store_field (res, 4, Val_long (majcoll)); - Store_field (res, 5, Val_long (heapsz)); + Store_field (res, 5, Val_long (heap_words)); Store_field (res, 6, Val_long (heap_chunks)); Store_field (res, 7, Val_long (live_words)); Store_field (res, 8, Val_long (live_blocks)); diff --git a/byterun/minor_gc.c b/byterun/minor_gc.c index 78bb8ac7f..915053c08 100644 --- a/byterun/minor_gc.c +++ b/byterun/minor_gc.c @@ -67,7 +67,9 @@ void set_minor_heap_size (asize_t size) ref_table_end = ref_table + ref_table_size + ref_table_reserve; } -void oldify (value v, value *p) +static value oldify_todo_list = NULL; + +void oldify_one (value v, value *p) { value result, field0; header_t hd; @@ -78,40 +80,38 @@ void oldify (value v, value *p) if (Is_block (v) && Is_young (v)){ Assert (Hp_val (v) >= young_ptr); hd = Hd_val (v); - if (hd == 0){ /* Already forwarded ? */ - *p = Field (v, 0); /* Then the forward pointer is the first field. */ - }else if ((tag = Tag_hd (hd)), (tag == Infix_tag)) { - mlsize_t offset = Infix_offset_hd (hd); - oldify(v - offset, p); - *p += offset; - }else if (tag >= No_scan_tag){ - sz = Wosize_hd (hd); - result = alloc_shr (sz, tag); - for (i = 0; i < sz; i++) Field(result, i) = Field(v, i); - Hd_val (v) = 0; /* Put the forward flag. */ - Field (v, 0) = result; /* And the forward pointer. */ - *p = result; + if (hd == 0){ /* If already forwarded */ + *p = Field (v, 0); /* then forward pointer is first field. */ }else{ - /* We can do recursive calls before all the fields are filled, because - we will not be calling the major GC. */ - sz = Wosize_hd (hd); - result = alloc_shr (sz, tag); - *p = result; - field0 = Field (v, 0); - Hd_val (v) = 0; /* Put the forward flag. */ - Field (v, 0) = result; /* And the forward pointer. */ - if (sz == 1) { - p = &Field (result, 0); - v = field0; - goto tail_call; - } else { - oldify (field0, &Field (result, 0)); - for (i = 1; i < sz - 1; i++){ - oldify (Field(v, i), &Field (result, i)); - } - p = &Field (result, i); - v = Field (v, i); - goto tail_call; + tag = Tag_hd (hd); + if (tag >= No_scan_tag){ + sz = Wosize_hd (hd); + result = alloc_shr (sz, tag); + for (i = 0; i < sz; i++) Field (result, i) = Field (v, i); + Hd_val (v) = 0; /* Set forward flag */ + Field (v, 0) = result; /* and forward pointer. */ + *p = result; + }else if (tag == Infix_tag){ + mlsize_t offset = Infix_offset_hd (hd); + oldify_one (v - offset, p); /* This cannot recurse deeper than 1. */ + *p += offset; + }else{ + sz = Wosize_hd (hd); + result = alloc_shr (sz, tag); + *p = result; + field0 = Field (v, 0); + Hd_val (v) = 0; /* Set forward flag */ + Field (v, 0) = result; /* and forward pointer. */ + if (sz > 1){ + Field (result, 0) = field0; + Field (result, 1) = oldify_todo_list; /* Add this block */ + oldify_todo_list = v; /* to the "to do" list. */ + }else{ + Assert (sz == 1); + p = &Field (result, 0); + v = field0; + goto tail_call; + } } } }else{ @@ -119,6 +119,36 @@ void oldify (value v, value *p) } } +/* Finish the work that was put off by oldify_one. + Note that oldify_one itself is called by oldify_mopup, so we + have to be careful to remove the first entry from the list before + oldifying its fields. */ +void oldify_mopup (void) +{ + value v, new_v, f; + mlsize_t i; + + while (oldify_todo_list != NULL){ + v = oldify_todo_list; /* Get the head. */ + Assert (Hd_val (v) == 0); /* It must be forwarded. */ + new_v = Field (v, 0); /* Follow forward pointer. */ + oldify_todo_list = Field (new_v, 1); /* Remove from list. */ + + f = Field (new_v, 0); + if (Is_block (f) && Is_young (f)){ + oldify_one (f, &Field (new_v, 0)); + } + for (i = 1; i < Wosize_val (new_v); i++){ + f = Field (v, i); + if (Is_block (f) && Is_young (f)){ + oldify_one (Field (v, i), &Field (new_v, i)); + }else{ + Field (new_v, i) = f; + } + } + } +} + /* Make sure the minor heap is empty by performing a minor collection if needed. */ @@ -130,7 +160,8 @@ void empty_minor_heap (void) in_minor_collection = 1; gc_message (0x02, "<", 0); oldify_local_roots(); - for (r = ref_table; r < ref_table_ptr; r++) oldify (**r, *r); + for (r = ref_table; r < ref_table_ptr; r++) oldify_one (**r, *r); + oldify_mopup (); if (young_ptr < young_limit) young_ptr = young_limit; stat_minor_words += Wsize_bsize (young_end - young_ptr); young_ptr = young_end; diff --git a/byterun/minor_gc.h b/byterun/minor_gc.h index 66252aeb2..d520d98c7 100644 --- a/byterun/minor_gc.h +++ b/byterun/minor_gc.h @@ -32,6 +32,14 @@ extern void empty_minor_heap (void); CAMLextern void minor_collection (void); CAMLextern void garbage_collection (void); /* for the native-code system */ extern void realloc_ref_table (void); -extern void oldify (value, value *); +extern void oldify_one (value, value *); +extern void oldify_mopup (void); + +#define Oldify(p) do{ \ + value __oldify__v__ = *p; \ + if (Is_block (__oldify__v__) && Is_young (__oldify__v__)){ \ + oldify_one (__oldify__v__, (p)); \ + } \ + }while(0) #endif /* _minor_gc_ */ diff --git a/byterun/roots.c b/byterun/roots.c index 391789c9e..6378ceffb 100644 --- a/byterun/roots.c +++ b/byterun/roots.c @@ -30,7 +30,8 @@ CAMLexport struct caml__roots_block *local_roots = NULL; void (*scan_roots_hook) (scanning_action f) = NULL; /* FIXME rename to [oldify_young_roots] and synchronise with asmrun/roots.c */ -/* Call [oldify] on (at least) all the roots that point to the minor heap. */ +/* Call [oldify_one] on (at least) all the roots that point to the minor + heap. */ void oldify_local_roots (void) { register value * sp; @@ -40,25 +41,25 @@ void oldify_local_roots (void) /* The stack */ for (sp = extern_sp; sp < stack_high; sp++) { - oldify (*sp, sp); + oldify_one (*sp, sp); } /* Local C roots */ /* FIXME do the old-frame trick ? */ for (lr = local_roots; lr != NULL; lr = lr->next) { for (i = 0; i < lr->ntables; i++){ for (j = 0; j < lr->nitems; j++){ sp = &(lr->tables[i][j]); - oldify (*sp, sp); + oldify_one (*sp, sp); } } } /* Global C roots */ for (gr = caml_global_roots.forward[0]; gr != NULL; gr = gr->forward[0]) { - oldify(*(gr->root), gr->root); + oldify_one(*(gr->root), gr->root); } /* Finalised values */ - final_do_young_roots (&oldify); + final_do_young_roots (&oldify_one); /* Hook */ - if (scan_roots_hook != NULL) (*scan_roots_hook)(&oldify); + if (scan_roots_hook != NULL) (*scan_roots_hook)(&oldify_one); } /* Call [darken] on all roots */ diff --git a/byterun/startup.c b/byterun/startup.c index db69dc5ae..a2dddd662 100644 --- a/byterun/startup.c +++ b/byterun/startup.c @@ -376,7 +376,8 @@ CAMLexport void caml_main(char **argv) close_channel(chan); /* this also closes fd */ stat_free(trail.section); /* Ensure that the globals are in the major heap. */ - oldify(global_data, &global_data); + oldify_one (global_data, &global_data); + oldify_mopup (); /* Initialize system libraries */ init_exceptions(); sys_init(argv + pos); @@ -429,7 +430,8 @@ CAMLexport void caml_startup_code(code_t code, asize_t code_size, /* Load the globals */ global_data = input_val_from_string((value)data, 0); /* Ensure that the globals are in the major heap. */ - oldify(global_data, &global_data); + oldify_one (global_data, &global_data); + oldify_mopup (); /* Run the code */ init_exceptions(); sys_init(argv); @@ -210,7 +210,7 @@ case "$bytecc,$host" in mathlib="";; *,*-*-darwin*) # Almost the same as rhapsody - bytecccompopts="-fno-defer-pop $gcc_warnings" + bytecccompopts="-fno-defer-pop -no-cpp-precomp $gcc_warnings" mathlib="";; *,*-*-beos*) bytecccompopts="-fno-defer-pop $gcc_warnings" @@ -511,7 +511,7 @@ case "$arch,$nativecc,$system,$host_type" in *,*,nextstep,*) nativecccompopts="$gcc_warnings -U__GNUC__ -posix" nativecclinkopts="-posix";; # SHRINKED_GNUC is not necessary for MacOS 10.1 (don't know about 10.0) -# (but it doesn't matter much for native code anyway) +# (but it doesn't matter for native code anyway) *,*,rhapsody,*) nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";; # *,*,rhapsody,*) nativecccompopts="$gcc_warnings";; *,gcc*,cygwin,*) nativecccompopts="$gcc_warnings -U_WIN32";; diff --git a/otherlibs/threads/.cvsignore b/otherlibs/threads/.cvsignore new file mode 100644 index 000000000..fb2df562d --- /dev/null +++ b/otherlibs/threads/.cvsignore @@ -0,0 +1,3 @@ +marshal.mli +pervasives.mli +unix.mli diff --git a/otherlibs/unix/select.c b/otherlibs/unix/select.c index 5db3341bd..674184b17 100644 --- a/otherlibs/unix/select.c +++ b/otherlibs/unix/select.c @@ -27,7 +27,7 @@ #include <sys/select.h> #endif -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) || defined(__MACH__) #include <string.h> #endif diff --git a/stdlib/.cvsignore b/stdlib/.cvsignore index 6921a35c0..556687830 100644 --- a/stdlib/.cvsignore +++ b/stdlib/.cvsignore @@ -1,3 +1,4 @@ camlheader camlheader_ur -labelled-*
\ No newline at end of file +labelled-* +caml diff --git a/stdlib/gc.mli b/stdlib/gc.mli index 26b13dabc..c70c91c77 100644 --- a/stdlib/gc.mli +++ b/stdlib/gc.mli @@ -39,7 +39,8 @@ type stat = since the program was started (including the initial allocation of the heap). *) live_words : int; - (** Number of words of live data in the major heap, including the header words.*) + (** Number of words of live data in the major heap, including the header + words. *) live_blocks : int; (** Number of live blocks in the major heap. *) free_words : int; @@ -105,7 +106,7 @@ type control = compaction is triggered at the end of each major GC cycle (this setting is intended for testing purposes only). If [max_overhead >= 1000000], compaction is never triggered. - Default: 1000000. *) + Default: 300. *) mutable stack_limit : int; (** The maximum size of the stack (in words). This is only diff --git a/utils/config.mlp b/utils/config.mlp index a44e5f3e4..051999cfc 100644 --- a/utils/config.mlp +++ b/utils/config.mlp @@ -12,7 +12,7 @@ (* $Id$ *) -let version = "3.04+1" +let version = "3.04+2 (2002-01-18)" let standard_library = try @@ -46,7 +46,7 @@ let load_path = ref ([] : string list) let interface_suffix = ref ".mli" -let max_tag = 248 +let max_tag = 246 let max_young_wosize = 256 let stack_threshold = 256 (* see byterun/config.h *) |