diff options
Diffstat (limited to 'byterun')
-rw-r--r-- | byterun/Makefile.Mac.depend | 44 | ||||
-rw-r--r-- | byterun/compact.c | 270 | ||||
-rw-r--r-- | byterun/debugger.c | 8 | ||||
-rw-r--r-- | byterun/freelist.c | 2 | ||||
-rw-r--r-- | byterun/freelist.h | 2 | ||||
-rw-r--r-- | byterun/gc.h | 8 | ||||
-rw-r--r-- | byterun/gc_ctrl.c | 60 | ||||
-rw-r--r-- | byterun/interp.a | 14 | ||||
-rw-r--r-- | byterun/interp.c | 16 | ||||
-rw-r--r-- | byterun/io.c | 10 | ||||
-rw-r--r-- | byterun/lexing.c | 6 | ||||
-rw-r--r-- | byterun/macintosh.c | 12 | ||||
-rw-r--r-- | byterun/major_gc.c | 78 | ||||
-rw-r--r-- | byterun/md5.c | 76 | ||||
-rw-r--r-- | byterun/memory.c | 4 | ||||
-rw-r--r-- | byterun/memory.h | 6 | ||||
-rw-r--r-- | byterun/minor_gc.c | 2 | ||||
-rw-r--r-- | byterun/misc.c | 34 | ||||
-rw-r--r-- | byterun/stacks.c | 4 | ||||
-rw-r--r-- | byterun/startup.c | 4 | ||||
-rw-r--r-- | byterun/sys.c | 8 | ||||
-rw-r--r-- | byterun/wincmdline.c | 6 |
22 files changed, 355 insertions, 319 deletions
diff --git a/byterun/Makefile.Mac.depend b/byterun/Makefile.Mac.depend index 5e54c11457..6beaf52463 100644 --- a/byterun/Makefile.Mac.depend +++ b/byterun/Makefile.Mac.depend @@ -41,6 +41,20 @@ fix_code.h ¶ stacks.h +"compact.c.x" Ä compact.c ¶ + config.h ¶ + ::config:sm-Mac.h ¶ + freelist.h ¶ + misc.h ¶ + mlvalues.h ¶ + gc.h ¶ + gc_ctrl.h ¶ + major_gc.h ¶ + memory.h ¶ + minor_gc.h ¶ + roots.h ¶ + weak.h + "compare.c.x" Ä compare.c ¶ fail.h ¶ misc.h ¶ @@ -150,11 +164,14 @@ config.h ¶ ::config:sm-Mac.h ¶ mlvalues.h ¶ + compact.h ¶ gc.h ¶ gc_ctrl.h ¶ major_gc.h ¶ freelist.h ¶ - minor_gc.h + minor_gc.h ¶ + stacks.h ¶ + memory.h "hash.c.x" Ä hash.c ¶ mlvalues.h ¶ @@ -273,10 +290,11 @@ signals.h "major_gc.c.x" Ä major_gc.c ¶ + compact.h ¶ config.h ¶ ::config:sm-Mac.h ¶ - fail.h ¶ misc.h ¶ + fail.h ¶ mlvalues.h ¶ freelist.h ¶ gc.h ¶ @@ -547,6 +565,20 @@ fix_code.h ¶ stacks.h +"compact.c.o" Ä compact.c ¶ + config.h ¶ + ::config:sm-Mac.h ¶ + freelist.h ¶ + misc.h ¶ + mlvalues.h ¶ + gc.h ¶ + gc_ctrl.h ¶ + major_gc.h ¶ + memory.h ¶ + minor_gc.h ¶ + roots.h ¶ + weak.h + "compare.c.o" Ä compare.c ¶ fail.h ¶ misc.h ¶ @@ -656,11 +688,14 @@ config.h ¶ ::config:sm-Mac.h ¶ mlvalues.h ¶ + compact.h ¶ gc.h ¶ gc_ctrl.h ¶ major_gc.h ¶ freelist.h ¶ - minor_gc.h + minor_gc.h ¶ + stacks.h ¶ + memory.h "hash.c.o" Ä hash.c ¶ mlvalues.h ¶ @@ -779,10 +814,11 @@ signals.h "major_gc.c.o" Ä major_gc.c ¶ + compact.h ¶ config.h ¶ ::config:sm-Mac.h ¶ - fail.h ¶ misc.h ¶ + fail.h ¶ mlvalues.h ¶ freelist.h ¶ gc.h ¶ diff --git a/byterun/compact.c b/byterun/compact.c index 91cef96673..70c31977e6 100644 --- a/byterun/compact.c +++ b/byterun/compact.c @@ -63,30 +63,30 @@ static void invert_pointer_at (p) the next infix header in this block. The last of the last list contains the original block header. */ { - /* This block as a value. */ - value val = (value) q - Infix_offset_val (q); - /* Get the block header. */ - word *hp = (word *) Hp_val (val); - while (Ecolor (*hp) == 0) hp = (word *) *hp; + /* This block as a value. */ + value val = (value) q - Infix_offset_val (q); + /* Get the block header. */ + word *hp = (word *) Hp_val (val); + while (Ecolor (*hp) == 0) hp = (word *) *hp; Assert (Ecolor (*hp) == 3); - if (Tag_ehd (*hp) == Closure_tag){ - /* This is the first infix found in this block. */ + if (Tag_ehd (*hp) == Closure_tag){ + /* This is the first infix found in this block. */ /* Save original header. */ - *p = *hp; + *p = *hp; /* Link inverted infix list. */ - Hd_val (q) = (header_t) ((word) p | 2); - /* Change block header's tag to Infix_tag, and change its size + Hd_val (q) = (header_t) ((word) p | 2); + /* Change block header's tag to Infix_tag, and change its size to point to the infix list. */ - *hp = Make_ehd (Wosize_bhsize (q - val), Infix_tag, 3); - }else{ Assert (Tag_ehd (*hp) == Infix_tag); - /* Point the last of this infix list to the current first infix + *hp = Make_ehd (Wosize_bhsize (q - val), Infix_tag, 3); + }else{ Assert (Tag_ehd (*hp) == Infix_tag); + /* Point the last of this infix list to the current first infix list of the block. */ *p = (word) &Field (val, Wosize_ehd (*hp)) | 1; - /* Point the head of this infix list to the above. */ - Hd_val (q) = (header_t) ((word) p | 2); - /* Change block header's size to point to this infix list. */ - *hp = Make_ehd (Wosize_bhsize (q - val), Infix_tag, 3); - } + /* Point the head of this infix list to the above. */ + Hd_val (q) = (header_t) ((word) p | 2); + /* Change block header's size to point to this infix list. */ + *hp = Make_ehd (Wosize_bhsize (q - val), Infix_tag, 3); + } } break; case 2: /* Inverted infix list: insert. */ @@ -122,8 +122,8 @@ static char *compact_allocate (size) char *chunk, *adr; while (Chunk_size (compact_fl) - Chunk_alloc (compact_fl) <= Bhsize_wosize (3) - && Chunk_size (Chunk_next (compact_fl)) - - Chunk_alloc (Chunk_next (compact_fl)) + && Chunk_size (Chunk_next (compact_fl)) + - Chunk_alloc (Chunk_next (compact_fl)) <= Bhsize_wosize (3)){ compact_fl = Chunk_next (compact_fl); } @@ -149,17 +149,17 @@ void compact_heap (void) chend = ch + Chunk_size (ch); while ((char *) p < chend){ - header_t hd = Hd_hp (p); - mlsize_t sz = Wosize_hd (hd); - - if (Is_blue_hd (hd)){ - /* Free object. Give it a string tag. */ - Hd_hp (p) = Make_ehd (sz, String_tag, 3); - }else{ Assert (Is_white_hd (hd)); - /* Live object. Keep its tag. */ + header_t hd = Hd_hp (p); + mlsize_t sz = Wosize_hd (hd); + + if (Is_blue_hd (hd)){ + /* Free object. Give it a string tag. */ + Hd_hp (p) = Make_ehd (sz, String_tag, 3); + }else{ Assert (Is_white_hd (hd)); + /* Live object. Keep its tag. */ Hd_hp (p) = Make_ehd (sz, Tag_hd (hd), 3); - } - p += Whsize_wosize (sz); + } + p += Whsize_wosize (sz); } ch = Chunk_next (ch); } @@ -176,28 +176,28 @@ void compact_heap (void) chend = ch + Chunk_size (ch); while ((char *) p < chend){ - word q = *p; - size_t sz, i; - tag_t t; - word *infixes; - - while (Ecolor (q) == 0) q = * (word *) q; - sz = Whsize_ehd (q); - t = Tag_ehd (q); - - if (t == Infix_tag){ - /* Get the original header of this block. */ - infixes = p + sz; - q = *infixes; - while (Ecolor (q) != 3) q = * (word *) (q & ~(unsigned long)3); - sz = Whsize_ehd (q); - t = Tag_ehd (q); - } - - if (t < No_scan_tag){ - for (i = 1; i < sz; i++) invert_pointer_at (&(p[i])); - } - p += sz; + word q = *p; + size_t sz, i; + tag_t t; + word *infixes; + + while (Ecolor (q) == 0) q = * (word *) q; + sz = Whsize_ehd (q); + t = Tag_ehd (q); + + if (t == Infix_tag){ + /* Get the original header of this block. */ + infixes = p + sz; + q = *infixes; + while (Ecolor (q) != 3) q = * (word *) (q & ~(unsigned long)3); + sz = Whsize_ehd (q); + t = Tag_ehd (q); + } + + if (t < No_scan_tag){ + for (i = 1; i < sz; i++) invert_pointer_at (&(p[i])); + } + p += sz; } ch = Chunk_next (ch); } @@ -208,13 +208,13 @@ void compact_heap (void) size_t sz, i; while (p != (value) NULL){ - q = Hd_val (p); - while (Ecolor (q) == 0) q = * (word *) q; - sz = Wosize_ehd (q); - for (i = 1; i < sz; i++){ - if (Field (p,i) != 0) invert_pointer_at (&(Field (p,i))); - } - p = Field (p, 0); + q = Hd_val (p); + while (Ecolor (q) == 0) q = * (word *) q; + sz = Wosize_ehd (q); + for (i = 1; i < sz; i++){ + if (Field (p,i) != 0) invert_pointer_at (&(Field (p,i))); + } + p = Field (p, 0); } } /* Invert roots */ @@ -232,63 +232,63 @@ void compact_heap (void) chend = ch + Chunk_size (ch); while ((char *) p < chend){ - word q = *p; - - if (Ecolor (q) == 0 || Tag_ehd (q) == Infix_tag){ - /* There were (normal or infix) pointers to this block. */ - size_t sz; - tag_t t; - char *newadr; - word *infixes = NULL; - - while (Ecolor (q) == 0) q = * (word *) q; - sz = Whsize_ehd (q); - t = Tag_ehd (q); - - if (t == Infix_tag){ - /* Get the original header of this block. */ - infixes = p + sz; - q = *infixes; Assert (Ecolor (q) == 2); - while (Ecolor (q) != 3) q = * (word *) (q & ~(unsigned long)3); - sz = Whsize_ehd (q); - t = Tag_ehd (q); - } - - newadr = compact_allocate (Bsize_wsize (sz)); - q = *p; - while (Ecolor (q) == 0){ - word next = * (word *) q; - * (word *) q = (word) Val_hp (newadr); - q = next; - } - *p = Make_header (Wosize_whsize (sz), t, White); - - if (infixes != NULL){ - /* Rebuild the infix headers and revert the infix pointers. */ - while (Ecolor ((word) infixes) != 3){ - infixes = (word *) ((word) infixes & ~(unsigned long) 3); - q = *infixes; - while (Ecolor (q) == 2){ - word next; - q = (word) q & ~(unsigned long) 3; - next = * (word *) q; - * (word *) q = (word) Val_hp ((word *) newadr + (infixes - p)); - q = next; - } Assert (Ecolor (q) == 1 || Ecolor (q) == 3); - *infixes = Make_header (infixes - p, Infix_tag, White); - infixes = (word *) q; - } - } - p += sz; - }else{ Assert (Ecolor (q) == 3); + word q = *p; + + if (Ecolor (q) == 0 || Tag_ehd (q) == Infix_tag){ + /* There were (normal or infix) pointers to this block. */ + size_t sz; + tag_t t; + char *newadr; + word *infixes = NULL; + + while (Ecolor (q) == 0) q = * (word *) q; + sz = Whsize_ehd (q); + t = Tag_ehd (q); + + if (t == Infix_tag){ + /* Get the original header of this block. */ + infixes = p + sz; + q = *infixes; Assert (Ecolor (q) == 2); + while (Ecolor (q) != 3) q = * (word *) (q & ~(unsigned long)3); + sz = Whsize_ehd (q); + t = Tag_ehd (q); + } + + newadr = compact_allocate (Bsize_wsize (sz)); + q = *p; + while (Ecolor (q) == 0){ + word next = * (word *) q; + * (word *) q = (word) Val_hp (newadr); + q = next; + } + *p = Make_header (Wosize_whsize (sz), t, White); + + if (infixes != NULL){ + /* Rebuild the infix headers and revert the infix pointers. */ + while (Ecolor ((word) infixes) != 3){ + infixes = (word *) ((word) infixes & ~(unsigned long) 3); + q = *infixes; + while (Ecolor (q) == 2){ + word next; + q = (word) q & ~(unsigned long) 3; + next = * (word *) q; + * (word *) q = (word) Val_hp ((word *) newadr + (infixes - p)); + q = next; + } Assert (Ecolor (q) == 1 || Ecolor (q) == 3); + *infixes = Make_header (infixes - p, Infix_tag, White); + infixes = (word *) q; + } + } + p += sz; + }else{ Assert (Ecolor (q) == 3); /* This is guaranteed only if compact_heap was called after a nonincremental major GC: Assert (Tag_ehd (q) == String_tag); */ - /* No pointers to the header and no infix header: - the object was free. */ - *p = Make_header (Wosize_ehd (q), Tag_ehd (q), Blue); - p += Whsize_ehd (q); - } + /* No pointers to the header and no infix header: + the object was free. */ + *p = Make_header (Wosize_ehd (q), Tag_ehd (q), Blue); + p += Whsize_ehd (q); + } } ch = Chunk_next (ch); } @@ -305,17 +305,17 @@ void compact_heap (void) chend = ch + Chunk_size (ch); while ((char *) p < chend){ - word q = *p; - if (Color_hd (q) == White){ - size_t sz = Bhsize_hd (q); - char *newadr = compact_allocate (sz); Assert (newadr <= (char *)p); - /* bcopy (source, destination, length) */ - bcopy (p, newadr, sz); - p += Wsize_bsize (sz); - }else{ - Assert (Color_hd (q) == Blue); - p += Whsize_hd (q); - } + word q = *p; + if (Color_hd (q) == White){ + size_t sz = Bhsize_hd (q); + char *newadr = compact_allocate (sz); Assert (newadr <= (char *)p); + /* bcopy (source, destination, length) */ + bcopy (p, newadr, sz); + p += Wsize_bsize (sz); + }else{ + Assert (Color_hd (q) == Blue); + p += Whsize_hd (q); + } } ch = Chunk_next (ch); } @@ -331,8 +331,8 @@ void compact_heap (void) ch = heap_start; while (ch != NULL){ if (Chunk_alloc (ch) != 0){ - live += Wsize_bsize (Chunk_alloc (ch)); - free += Wsize_bsize (Chunk_size (ch) - Chunk_alloc (ch)); + live += Wsize_bsize (Chunk_alloc (ch)); + free += Wsize_bsize (Chunk_size (ch) - Chunk_alloc (ch)); } ch = Chunk_next (ch); } @@ -345,11 +345,11 @@ void compact_heap (void) char *next_chunk = Chunk_next (ch); /* Chunk_next (ch) will be erased */ if (Chunk_alloc (ch) == 0){ - if (free < wanted){ - free += Chunk_size (ch); - }else{ - shrink_heap (ch); - } + if (free < wanted){ + free += Chunk_size (ch); + }else{ + shrink_heap (ch); + } } ch = next_chunk; } @@ -361,10 +361,10 @@ void compact_heap (void) fl_reset (); while (ch != NULL){ if (Chunk_size (ch) > Chunk_alloc (ch)){ - header_t *p = (header_t *) (ch + Chunk_alloc (ch)); - *p = Make_header (Wosize_bhsize (Chunk_size (ch) - Chunk_alloc (ch)), - 0, White); - fl_merge_block (Bp_hp (p)); + header_t *p = (header_t *) (ch + Chunk_alloc (ch)); + *p = Make_header (Wosize_bhsize (Chunk_size (ch) - Chunk_alloc (ch)), + 0, White); + fl_merge_block (Bp_hp (p)); } ch = Chunk_next (ch); } diff --git a/byterun/debugger.c b/byterun/debugger.c index c6f38d02ff..801de39ee7 100644 --- a/byterun/debugger.c +++ b/byterun/debugger.c @@ -217,11 +217,11 @@ void debugger(event) case REQ_CHECKPOINT: i = fork(); if (i == 0) { - close_connection(); /* Close parent connection. */ - open_connection(); /* Open new connection with debugger */ + close_connection(); /* Close parent connection. */ + open_connection(); /* Open new connection with debugger */ } else { - putword(dbg_out, i); - flush(dbg_out); + putword(dbg_out, i); + flush(dbg_out); } break; case REQ_GO: diff --git a/byterun/freelist.c b/byterun/freelist.c index 37322707df..63f8ca7af9 100644 --- a/byterun/freelist.c +++ b/byterun/freelist.c @@ -44,7 +44,7 @@ static char *fl_last = NULL; /* Last block in the list. Only valid char *fl_merge = Fl_head; /* Current insertion pointer. Managed jointly with [sweep_slice]. */ asize_t fl_cur_size = 0; /* How many free words were added since - the latest fl_init_merge. */ + the latest fl_init_merge. */ #define Next(b) (((block *) (b))->next_bp) diff --git a/byterun/freelist.h b/byterun/freelist.h index 2fb90ed0e3..4c5067c678 100644 --- a/byterun/freelist.h +++ b/byterun/freelist.h @@ -20,7 +20,7 @@ #include "misc.h" #include "mlvalues.h" -asize_t fl_cur_size; +extern asize_t fl_cur_size; char *fl_allocate P((mlsize_t)); void fl_init_merge P((void)); diff --git a/byterun/gc.h b/byterun/gc.h index 09e9ef1976..f98da37ed0 100644 --- a/byterun/gc.h +++ b/byterun/gc.h @@ -36,10 +36,10 @@ #define Bluehd_hd(hd) (((hd) & ~Black) | Blue) /* This depends on the layout of the header. See [mlvalues.h]. */ -#define Make_header(wosize, tag, color) \ - ((header_t) (((header_t) (wosize) << 10) \ - + (color) \ - + (tag_t) (tag))) +#define Make_header(wosize, tag, color) \ + ((header_t) (((header_t) (wosize) << 10) \ + + (color) \ + + (tag_t) (tag))) #define Color_val(val) (Color_hd (Hd_val (val))) diff --git a/byterun/gc_ctrl.c b/byterun/gc_ctrl.c index e4df55e52d..c0280ad499 100644 --- a/byterun/gc_ctrl.c +++ b/byterun/gc_ctrl.c @@ -60,36 +60,36 @@ value gc_stat(v) /* ML */ cur_hd = Hd_hp (cur_hp); switch (Color_hd (cur_hd)){ case White: - if (Wosize_hd (cur_hd) == 0){ - ++fragments; - Assert (prev_hp == NULL - || (Color_hp (prev_hp) != Blue - && Wosize_hp (prev_hp) > 0)); - Assert (Next (cur_hp) == chunk_end - || (Color_hp (Next (cur_hp)) != Blue - && Wosize_hp (Next (cur_hp)) > 0)); - break; - } - /* FALLTHROUGH */ + if (Wosize_hd (cur_hd) == 0){ + ++fragments; + Assert (prev_hp == NULL + || (Color_hp (prev_hp) != Blue + && Wosize_hp (prev_hp) > 0)); + Assert (Next (cur_hp) == chunk_end + || (Color_hp (Next (cur_hp)) != Blue + && Wosize_hp (Next (cur_hp)) > 0)); + break; + } + /* FALLTHROUGH */ case Gray: case Black: - Assert (Wosize_hd (cur_hd) > 0); - ++ live_blocks; - live_words += Whsize_hd (cur_hd); - break; + Assert (Wosize_hd (cur_hd) > 0); + ++ live_blocks; + live_words += Whsize_hd (cur_hd); + break; case Blue: - Assert (Wosize_hd (cur_hd) > 0); - ++ free_blocks; - free_words += Whsize_hd (cur_hd); - if (Whsize_hd (cur_hd) > largest_free){ - largest_free = Whsize_hd (cur_hd); - } - Assert (prev_hp == NULL - || (Color_hp (prev_hp) != Blue - && Wosize_hp (prev_hp) > 0)); - Assert (Next (cur_hp) == chunk_end - || (Color_hp (Next (cur_hp)) != Blue - && Wosize_hp (Next (cur_hp)) > 0)); - break; + Assert (Wosize_hd (cur_hd) > 0); + ++ free_blocks; + free_words += Whsize_hd (cur_hd); + if (Whsize_hd (cur_hd) > largest_free){ + largest_free = Whsize_hd (cur_hd); + } + Assert (prev_hp == NULL + || (Color_hp (prev_hp) != Blue + && Wosize_hp (prev_hp) > 0)); + Assert (Next (cur_hp) == chunk_end + || (Color_hp (Next (cur_hp)) != Blue + && Wosize_hp (Next (cur_hp)) > 0)); + break; } prev_hp = cur_hp; cur_hp = Next (cur_hp); @@ -192,7 +192,7 @@ value gc_set(v) /* ML */ if (newheapincr != major_heap_increment){ major_heap_increment = newheapincr; gc_message ("New heap increment size: %luk bytes\n", - major_heap_increment/1024); + major_heap_increment/1024); } /* Minor heap size comes last because it will trigger a minor collection @@ -263,5 +263,5 @@ void init_gc (minor_size, major_size, major_incr, percent_fr, percent_m, verb) gc_message ("Initial space overhead: %d%%\n", percent_free); gc_message ("Initial max overhead: %d%%\n", percent_max); gc_message ("Initial heap increment: %ldk bytes\n", - major_heap_increment / 1024); + major_heap_increment / 1024); } diff --git a/byterun/interp.a b/byterun/interp.a index 3c28066c5b..f2227c0da4 100644 --- a/byterun/interp.a +++ b/byterun/interp.a @@ -111,19 +111,19 @@ initial_callback_depth_ equ $00 Call_restore MOVE.L local_var_size_+4*10+$4(A7), D0 ; code - BNE.S noinit ; == NULL => init + BNE.S noinit ; == NULL => init LEA.L table(PC), A0 MOVE.L A0, (instr_table).L CLR.L (instr_base).L - MOVEQ.L #1, D0 + MOVEQ.L #1, D0 Call_setup ; 2eme copie: "lbl_1B88" LEA.L local_var_size_(A7), A7 MOVEM.L (A7)+, D3-D7/A2-A6 RTS noinit: MOVEA.L local_var_size_+4*10+$4(A7), A0 ; code - CMPI.L #124, (A0) - BHI.S nothread ; deja tresse + CMPI.L #124, (A0) + BHI.S nothread ; deja tresse MOVE.L local_var_size_+4*10+$8(A7), -(A7) ; argument 1 (size) MOVE.L local_var_size_+4*10+$8(A7), -(A7) ; argument 0 (code) @@ -156,7 +156,7 @@ nothread: LEA.L i_start(PC), A6 MOVE.L initial_local_roots_(A7), (local_roots).L MOVE.L initial_callback_depth_(A7), (callback_depth).L MOVEA.L (exn_bucket).L, accu_ - MOVEA.L (extern_sp).L, sp_ + MOVEA.L (extern_sp).L, sp_ JMP i_82-i_base(A6) ; RAISE lbl_78: LEA.L raise_buf_(A7), A0 MOVE.L A0, (external_raise).L @@ -1219,13 +1219,13 @@ lbl_mod: MOVE.L (A1), D5 ; A1 = modify_dest; D5 = _old_ BEQ i_90 TST.L (gc_phase).L BNE.S lbl_CC2 - MOVE.L A1, D3 ; A1 est caller-save + MOVE.L A1, D3 ; A1 est caller-save MOVE.L D5, -(A7) Call_setup JSR (darken).L Call_restore ADDQ.L #4 ,A7 - MOVEA.L D3, A1 ; A1 est caller-save + MOVEA.L D3, A1 ; A1 est caller-save lbl_CC2: BTST.L #0, D4 BNE i_90 CMP.L (young_start).L, D4 diff --git a/byterun/interp.c b/byterun/interp.c index 39a6b0a271..0b7e7052d6 100644 --- a/byterun/interp.c +++ b/byterun/interp.c @@ -36,11 +36,11 @@ extern int volatile have_to_interact; #endif /* Registers for the abstract machine: - pc the code pointer - sp the stack pointer (grows downward) + pc the code pointer + sp the stack pointer (grows downward) accu the accumulator env heap-allocated environment - trapsp pointer to the current trap frame + trapsp pointer to the current trap frame extra_args number of extra arguments provided by the caller sp is a local copy of the global variable extern_sp. */ @@ -419,7 +419,7 @@ value interprete(prog, prog_size) pc = (code_t)(sp[0]); env = sp[1]; extra_args = Long_val(sp[2]); - sp += 3; + sp += 3; } Next; } @@ -736,9 +736,9 @@ value interprete(prog, prog_size) process_signal: something_to_do = 0; if (force_major_slice){ - Setup_for_gc; - minor_collection (); - Restore_after_gc; + Setup_for_gc; + minor_collection (); + Restore_after_gc; } /* If a signal arrives between the following two instructions, it will be lost. */ @@ -902,7 +902,7 @@ value interprete(prog, prog_size) #define Lookup(obj, lab) \ Field (Field (Field (obj, 0), ((lab) >> 16) / sizeof (value)), \ - ((lab) / sizeof (value)) & 0xFF) + ((lab) / sizeof (value)) & 0xFF) Instruct(GETMETHOD): accu = Lookup(sp[0], accu); diff --git a/byterun/io.c b/byterun/io.c index d516739ad3..0aef48fed1 100644 --- a/byterun/io.c +++ b/byterun/io.c @@ -137,11 +137,11 @@ again: if (errno == EINTR) goto again; if (errno == EAGAIN || errno == EWOULDBLOCK) { /* We couldn't do a partial write here, probably because - n <= PIPE_BUF and POSIX says that writes of less than - PIPE_BUF characters must be atomic. - So, we force a partial write of 1 character. - This should always succeed if we've done a select - on writing just before. */ + n <= PIPE_BUF and POSIX says that writes of less than + PIPE_BUF characters must be atomic. + So, we force a partial write of 1 character. + This should always succeed if we've done a select + on writing just before. */ if (n > 1) { n = 1; goto again; } } } diff --git a/byterun/lexing.c b/byterun/lexing.c index df7fdfe987..17dc0ad993 100644 --- a/byterun/lexing.c +++ b/byterun/lexing.c @@ -75,9 +75,9 @@ value lex_engine(tbl, start_state, lexbuf) /* ML */ /* See if we need a refill */ if (lexbuf->lex_curr_pos >= lexbuf->lex_buffer_len){ if (lexbuf->lex_eof_reached == Val_bool (0)){ - return Val_int(-state - 1); + return Val_int(-state - 1); }else{ - c = 256; + c = 256; } }else{ /* Read next input char */ @@ -99,7 +99,7 @@ value lex_engine(tbl, start_state, lexbuf) /* ML */ } }else{ /* Erase the EOF condition only if the EOF pseudo-character was - consumed by the automaton (i.e. there was no backtrack above) + consumed by the automaton (i.e. there was no backtrack above) */ if (c == 256) lexbuf->lex_eof_reached = Val_bool (0); } diff --git a/byterun/macintosh.c b/byterun/macintosh.c index 61660b1a16..a1c08cbc78 100644 --- a/byterun/macintosh.c +++ b/byterun/macintosh.c @@ -70,8 +70,8 @@ int chdir (char *dir) if (result != noErr) return -1; if (prevdir != 0){ prevdir = 0; - pb.ioVRefNum = prevdir; - PBCloseWDSync (&pb); + pb.ioVRefNum = prevdir; + PBCloseWDSync (&pb); } return 0; } @@ -97,12 +97,12 @@ static char *getfullpathpb (CInfoPBPtr pb) char *result; if (pb->hFileInfo.ioFlParID == fsRtParID){ - result = malloc (1); - if (result == NULL) return NULL; - result [0] = '\0'; + result = malloc (1); + if (result == NULL) return NULL; + result [0] = '\0'; }else{ result = getfullpathid (pb->hFileInfo.ioVRefNum, pb->hFileInfo.ioFlParID); - if (result == NULL) return NULL; + if (result == NULL) return NULL; } cat_cp_str (&result, pb->hFileInfo.ioNamePtr); if (pb->hFileInfo.ioFlAttrib & (1<<4)) cat_cp_str (&result, "\p:"); diff --git a/byterun/major_gc.c b/byterun/major_gc.c index 6df677ced7..45ac6e363a 100644 --- a/byterun/major_gc.c +++ b/byterun/major_gc.c @@ -60,7 +60,7 @@ static void realloc_gray_vals () Assert (gray_vals_cur == gray_vals_end); if (gray_vals_size < stat_heap_size / 128){ gc_message ("Growing gray_vals to %luk bytes\n", - (long) gray_vals_size * sizeof (value) / 512); + (long) gray_vals_size * sizeof (value) / 512); new = (value *) realloc ((char *) gray_vals, 2 * gray_vals_size * sizeof (value)); if (new == NULL){ @@ -119,8 +119,8 @@ static void mark_slice (work) Hd_val (v) = Blackhd_hd (hd); size = Wosize_hd(hd); if (Tag_hd (hd) < No_scan_tag){ - for (i = 0; i < size; i++){ - child = Field (v, i); + for (i = 0; i < size; i++){ + child = Field (v, i); if (Is_block (child) && Is_in_heap (child)) { hd = Hd_val(child); if (Tag_hd(hd) == Infix_tag) { @@ -142,19 +142,19 @@ static void mark_slice (work) work -= Whsize_wosize(size); }else if (markhp != NULL){ if (markhp == limit){ - chunk = Chunk_next (chunk); - if (chunk == NULL){ - markhp = NULL; - }else{ - markhp = chunk; - limit = chunk + Chunk_size (chunk); - } + chunk = Chunk_next (chunk); + if (chunk == NULL){ + markhp = NULL; + }else{ + markhp = chunk; + limit = chunk + Chunk_size (chunk); + } }else{ - if (Is_gray_val (Val_hp (markhp))){ - Assert (gray_vals_ptr == gray_vals); - *gray_vals_ptr++ = Val_hp (markhp); - } - markhp += Bhsize_hp (markhp); + if (Is_gray_val (Val_hp (markhp))){ + Assert (gray_vals_ptr == gray_vals); + *gray_vals_ptr++ = Val_hp (markhp); + } + markhp += Bhsize_hp (markhp); } }else if (!heap_is_pure){ heap_is_pure = 1; @@ -199,10 +199,10 @@ static void update_weak_pointers () sz = Wosize_val (cur); for (i = 1; i < sz; i++){ - curfield = Field (cur, i); - if (curfield != 0 && Is_block (curfield) && Is_white_val (curfield)){ - Field (cur, i) = 0; - } + curfield = Field (cur, i); + if (curfield != 0 && Is_block (curfield) && Is_white_val (curfield)){ + Field (cur, i) = 0; + } } prev = &Field (cur, 0); cur = (value *) *prev; @@ -224,31 +224,31 @@ static void sweep_slice (work) gc_sweep_hp += Bhsize_hd (hd); switch (Color_hd (hd)){ case White: - if (Tag_hd (hd) == Final_tag){ - Final_fun (Val_hp (hp)) (Val_hp (hp)); - } - gc_sweep_hp = fl_merge_block (Bp_hp (hp)); - break; + if (Tag_hd (hd) == Final_tag){ + Final_fun (Val_hp (hp)) (Val_hp (hp)); + } + gc_sweep_hp = fl_merge_block (Bp_hp (hp)); + break; case Blue: - /* Only the blocks of the free-list are blue. See [freelist.c]. */ - fl_merge = Bp_hp (hp); - break; + /* Only the blocks of the free-list are blue. See [freelist.c]. */ + fl_merge = Bp_hp (hp); + break; default: /* Gray or Black */ Assert(Color_hd(hd) == Black); - Hd_hp (hp) = Whitehd_hd (hd); - break; + Hd_hp (hp) = Whitehd_hd (hd); + break; } Assert (gc_sweep_hp <= limit); }else{ chunk = Chunk_next (chunk); if (chunk == NULL){ - /* Sweeping is done. */ + /* Sweeping is done. */ ++ stat_major_collections; work = 0; gc_phase = Phase_idle; }else{ - gc_sweep_hp = chunk; - limit = chunk + Chunk_size (chunk); + gc_sweep_hp = chunk; + limit = chunk + Chunk_size (chunk); } } } @@ -273,11 +273,11 @@ void major_collection_slice () MS = MW * P MS = (100 - percent_free) * (allocated_words * 3 / percent_free / 2 - + 100 * extra_heap_memory) + + 100 * extra_heap_memory) Amount of sweeping work for this slice: SS = SW * P SS = 100 * (allocated_words * 3 / percent_free / 2 - + 100 * extra_heap_memory) + + 100 * extra_heap_memory) This slice will either mark 2*MS words or sweep 2*SS words. */ @@ -287,15 +287,15 @@ void major_collection_slice () if (gc_phase == Phase_mark){ mark_slice (2 * (100 - percent_free) - * (allocated_words * 3 / percent_free / 2 + * (allocated_words * 3 / percent_free / 2 + 100 * extra_heap_memory) - + Margin); + + Margin); gc_message ("!", 0); }else{ Assert (gc_phase == Phase_sweep); sweep_slice (200 * (allocated_words * 3 / percent_free / 2 - + 100 * extra_heap_memory) - + Margin); + + 100 * extra_heap_memory) + + Margin); gc_message ("$", 0); } @@ -345,7 +345,7 @@ void init_major_heap (heap_size) stat_heap_size = round_heap_chunk_size (heap_size); Assert (stat_heap_size % Page_size == 0); heap_start = aligned_malloc (stat_heap_size + sizeof (heap_chunk_head), - sizeof (heap_chunk_head), &block); + sizeof (heap_chunk_head), &block); if (heap_start == NULL) fatal_error ("Fatal error: not enough memory for the initial heap.\n"); heap_start += sizeof (heap_chunk_head); diff --git a/byterun/md5.c b/byterun/md5.c index bdaa9244bb..9c8b0bbc39 100644 --- a/byterun/md5.c +++ b/byterun/md5.c @@ -20,14 +20,14 @@ /* MD5 message digest */ struct MD5Context { - uint32 buf[4]; - uint32 bits[2]; - unsigned char in[64]; + uint32 buf[4]; + uint32 bits[2]; + unsigned char in[64]; }; static void MD5Init P((struct MD5Context *context)); static void MD5Update P((struct MD5Context *context, unsigned char *buf, - unsigned len)); + unsigned len)); static void MD5Final P((unsigned char digest[16], struct MD5Context *ctx)); static void MD5Transform P((uint32 buf[4], uint32 in[16])); @@ -84,7 +84,7 @@ value md5_chan(chan, len) /* ML */ */ #ifndef ARCH_BIG_ENDIAN -#define byteReverse(buf, len) /* Nothing */ +#define byteReverse(buf, len) /* Nothing */ #else void byteReverse(buf, longs) unsigned char *buf; @@ -92,10 +92,10 @@ void byteReverse(buf, longs) { uint32 t; do { - t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(uint32 *) buf = t; - buf += 4; + t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | + ((unsigned) buf[1] << 8 | buf[0]); + *(uint32 *) buf = t; + buf += 4; } while (--longs); } #endif @@ -131,35 +131,35 @@ static void MD5Update(ctx, buf, len) t = ctx->bits[0]; if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ + ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += len >> 29; - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ /* Handle any leading odd-sized chunks */ if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - buf += t; - len -= t; + unsigned char *p = (unsigned char *) ctx->in + t; + + t = 64 - t; + if (len < t) { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32 *) ctx->in); + buf += t; + len -= t; } /* Process data in 64-byte chunks */ while (len >= 64) { - memcpy(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - buf += 64; - len -= 64; + memcpy(ctx->in, buf, 64); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32 *) ctx->in); + buf += 64; + len -= 64; } /* Handle any remaining bytes of data. */ @@ -191,16 +191,16 @@ static void MD5Final(digest, ctx) /* Pad out to 56 mod 64 */ if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32 *) ctx->in); - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); + /* Now fill the next block with 56 bytes */ + memset(ctx->in, 0, 56); } else { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); + /* Pad block to 56 bytes */ + memset(p, 0, count - 8); } byteReverse(ctx->in, 14); @@ -211,7 +211,7 @@ static void MD5Final(digest, ctx) MD5Transform(ctx->buf, (uint32 *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } /* The four core functions - F1 is optimized somewhat */ @@ -224,7 +224,7 @@ static void MD5Final(digest, ctx) /* This is the central step in the MD5 algorithm. */ #define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) + ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) /* * The core of the MD5 algorithm, this alters an existing MD5 hash to diff --git a/byterun/memory.c b/byterun/memory.c index ff9eda9feb..cacceadf65 100644 --- a/byterun/memory.c +++ b/byterun/memory.c @@ -42,7 +42,7 @@ static char *expand_heap (request) malloc_request = round_heap_chunk_size (Bhsize_wosize (request)); gc_message ("Growing heap to %luk bytes\n", - (stat_heap_size + malloc_request) / 1024); + (stat_heap_size + malloc_request) / 1024); mem = aligned_malloc (malloc_request + sizeof (heap_chunk_head), sizeof (heap_chunk_head), &block); if (mem == NULL){ @@ -191,7 +191,7 @@ value alloc_shr (wosize, tag) Hd_hp (hp) = Make_header (wosize, tag, Black); }else{ Assert (gc_phase == Phase_idle - || (gc_phase == Phase_sweep && (addr)hp < (addr)gc_sweep_hp)); + || (gc_phase == Phase_sweep && (addr)hp < (addr)gc_sweep_hp)); Hd_hp (hp) = Make_header (wosize, tag, White); } allocated_words += Whsize_wosize (wosize); diff --git a/byterun/memory.h b/byterun/memory.h index 6d6d634934..9f8958afe7 100644 --- a/byterun/memory.h +++ b/byterun/memory.h @@ -29,7 +29,7 @@ void adjust_gc_speed P((mlsize_t, mlsize_t)); void modify P((value *, value)); void initialize P((value *, value)); value check_urgent_gc P((value)); -char * stat_alloc P((asize_t)); /* Size in bytes. */ +char * stat_alloc P((asize_t)); /* Size in bytes. */ void stat_free P((char *)); char * stat_resize P((char *, asize_t)); /* Size in bytes. */ @@ -64,11 +64,11 @@ char * stat_resize P((char *, asize_t)); /* Size in bytes. */ if (Is_in_heap (fp)){ \ if (gc_phase == Phase_mark) darken (_old_, NULL); \ if (Is_block (val) && Is_young (val) \ - && ! (Is_block (_old_) && Is_young (_old_))){ \ + && ! (Is_block (_old_) && Is_young (_old_))){ \ *ref_table_ptr++ = (fp); \ if (ref_table_ptr >= ref_table_limit){ \ Assert (ref_table_ptr == ref_table_limit); \ - realloc_ref_table (); \ + realloc_ref_table (); \ } \ } \ } \ diff --git a/byterun/minor_gc.c b/byterun/minor_gc.c index ea96e06201..5755bff7f1 100644 --- a/byterun/minor_gc.c +++ b/byterun/minor_gc.c @@ -56,7 +56,7 @@ void set_minor_heap_size (size) ref_table_size = minor_heap_size / sizeof (value) / 8; ref_table_reserve = 256; new_table = (value **) stat_alloc ((ref_table_size + ref_table_reserve) - * sizeof (value *)); + * sizeof (value *)); if (ref_table != NULL) stat_free ((char *) ref_table); ref_table = new_table; ref_table_ptr = ref_table; diff --git a/byterun/misc.c b/byterun/misc.c index a63c0ddc2c..01da481268 100644 --- a/byterun/misc.c +++ b/byterun/misc.c @@ -25,7 +25,7 @@ void failed_assert (expr, file, line) int line; { fprintf (stderr, "Assertion failed: %s; file %s; line %d\n", - expr, file, line); + expr, file, line); exit (100); } @@ -98,30 +98,30 @@ void memmov (dst, src, length) /* The pointers are not equal modulo sizeof (long). Copy byte by byte. */ for (; length != 0; length--){ - *dst++ = *src++; + *dst++ = *src++; } }else{ /* Copy the first few bytes. */ i = (unsigned long) dst % sizeof (long); if (i != 0){ - i = sizeof (long) - i; /* Number of bytes to copy. */ - if (i > length) i = length; /* Never copy more than length.*/ - for (; i != 0; i--){ - *dst++ = *src++; --length; - } + i = sizeof (long) - i; /* Number of bytes to copy. */ + if (i > length) i = length; /* Never copy more than length.*/ + for (; i != 0; i--){ + *dst++ = *src++; --length; + } } Assert ((unsigned long) dst % sizeof (long) == 0); Assert ((unsigned long) src % sizeof (long) == 0); /* Then copy as many entire words as possible. */ for (i = length / sizeof (long); i > 0; i--){ - *(long *) dst = *(long *) src; - dst += sizeof (long); src += sizeof (long); + *(long *) dst = *(long *) src; + dst += sizeof (long); src += sizeof (long); } /* Then copy the last few bytes. */ for (i = length % sizeof (long); i > 0; i--){ - *dst++ = *src++; + *dst++ = *src++; } } }else{ /* Copy in descending order. */ @@ -129,9 +129,9 @@ void memmov (dst, src, length) if (((unsigned long) dst - (unsigned long) src) % sizeof (long) != 0){ /* The pointers are not equal modulo sizeof (long). - Copy byte by byte. */ + Copy byte by byte. */ for (; length > 0; length--){ - *--dst = *--src; + *--dst = *--src; } }else{ @@ -139,18 +139,18 @@ void memmov (dst, src, length) i = (unsigned long) dst % sizeof (long); if (i > length) i = length; /* Never copy more than length. */ for (; i > 0; i--){ - *--dst = *--src; --length; + *--dst = *--src; --length; } /* Then copy as many entire words as possible. */ for (i = length / sizeof (long); i > 0; i--){ - dst -= sizeof (long); src -= sizeof (long); - *(long *) dst = *(long *) src; + dst -= sizeof (long); src -= sizeof (long); + *(long *) dst = *(long *) src; } /* Then copy the last few bytes. */ for (i = length % sizeof (long); i > 0; i--){ - *--dst = *--src; + *--dst = *--src; } } } @@ -169,7 +169,7 @@ char *aligned_malloc (size, modulo, block) raw_mem = (char *) malloc (size + Page_size); if (raw_mem == NULL) return NULL; *block = raw_mem; - raw_mem += modulo; /* Address to be aligned */ + raw_mem += modulo; /* Address to be aligned */ aligned_mem = (((unsigned long) raw_mem / Page_size + 1) * Page_size); return (char *) (aligned_mem - modulo); } diff --git a/byterun/stacks.c b/byterun/stacks.c index 82f7541767..b9b6cece92 100644 --- a/byterun/stacks.c +++ b/byterun/stacks.c @@ -53,7 +53,7 @@ void realloc_stack() if (size >= max_stack_size) raise_stack_overflow(); size *= 2; gc_message ("Growing stack to %luk bytes\n", - (unsigned long) size * sizeof(value) / 1024); + (unsigned long) size * sizeof(value) / 1024); new_low = (value *) stat_alloc(size * sizeof(value)); new_high = new_low + size; @@ -84,6 +84,6 @@ void change_max_stack_size (new_max_size) if (new_max_size < size) new_max_size = size; gc_message ("Changing stack limit to %luk bytes\n", - new_max_size * sizeof (value) / 1024); + new_max_size * sizeof (value) / 1024); max_stack_size = new_max_size; } diff --git a/byterun/startup.c b/byterun/startup.c index 89aa220f10..d06ace0417 100644 --- a/byterun/startup.c +++ b/byterun/startup.c @@ -188,7 +188,7 @@ static void parse_camlrunparam() if (opt != NULL){ while (*opt != '\0'){ switch (*opt++){ - case 's': scanmult (opt, &minor_heap_init); break; + case 's': scanmult (opt, &minor_heap_init); break; case 'i': scanmult (opt, &heap_chunk_init); break; case 'h': scanmult (opt, &heap_size_init); break; case 'l': scanmult (opt, &max_stack_init); break; @@ -297,7 +297,7 @@ void caml_startup_code(code, code_size, data, argv) external_raise = &raise_buf; /* Initialize the abstract machine */ init_gc (minor_heap_init, heap_size_init, heap_chunk_init, - percent_free_init, max_percent_free_init, verbose_init); + percent_free_init, max_percent_free_init, verbose_init); init_stack (max_stack_init); init_atoms(); /* Initialize the interpreter */ diff --git a/byterun/sys.c b/byterun/sys.c index 100e942ea7..e664f5b040 100644 --- a/byterun/sys.c +++ b/byterun/sys.c @@ -129,7 +129,7 @@ value sys_open(path, flags, perm) /* ML */ #if !macintosh ,Int_val(perm) #endif - ); + ); if (ret == -1) sys_error(path); return Val_long(ret); } @@ -180,7 +180,7 @@ value sys_chdir(dirname) /* ML */ return Val_unit; } -value sys_getcwd(unit) /* ML */ +value sys_getcwd(unit) /* ML */ value unit; { char buff[4096]; @@ -280,9 +280,9 @@ char * searchpath(name) /* We don't need searchpath on the Macintosh because there are no #! scripts */ char *searchpath (name) - char *name; + char *name; { - return name; + return name; } #else diff --git a/byterun/wincmdline.c b/byterun/wincmdline.c index a125fb7faf..c01658df05 100644 --- a/byterun/wincmdline.c +++ b/byterun/wincmdline.c @@ -72,8 +72,8 @@ static void expand_pattern(pat) handle = _findfirst(pat, &ffblk); if (handle == -1) { - store_argument(pat); /* a la Bourne shell */ - return; + store_argument(pat); /* a la Bourne shell */ + return; } do { store_argument(strdup(ffblk.name)); @@ -101,7 +101,7 @@ static void expand_diversion(filename) for (p = buf; p < endbuf; /*nothing*/) { /* Skip leading blanks */ while (p < endbuf && isspace(*p)) p++; - if (p >= endbuf) break; + if (p >= endbuf) break; s = p; /* Skip to next blank or end of buffer */ while (p < endbuf && !isspace(*p)) p++; |