From ec2d5cad73da5176f73078a797326f0498af7c64 Mon Sep 17 00:00:00 2001 From: "Guillermo J. Rozas" Date: Sun, 1 Apr 1990 20:32:02 +0000 Subject: [PATCH] Fix bch system to run on machines with floating alignment. --- v7/src/microcode/bchdmp.c | 68 +++++++++++++++++++++++---------------- v7/src/microcode/bchgcc.h | 32 ++++++++++++++++-- v7/src/microcode/bchgcl.c | 12 +++---- v7/src/microcode/bchmmg.c | 26 ++++++++------- v7/src/microcode/bchpur.c | 14 ++++---- 5 files changed, 96 insertions(+), 56 deletions(-) diff --git a/v7/src/microcode/bchdmp.c b/v7/src/microcode/bchdmp.c index 4bc1663cc..0c357fe2e 100644 --- a/v7/src/microcode/bchdmp.c +++ b/v7/src/microcode/bchdmp.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchdmp.c,v 9.48 1989/12/06 05:49:28 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchdmp.c,v 9.49 1990/04/01 20:22:33 jinx Exp $ -Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology +Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -45,11 +45,6 @@ MIT in each case. */ #include "fasl.h" #include "dump.c" -#ifdef FLOATING_ALIGNMENT -/* This must be fixed. */ -#include "error: bchdmp does not handle floating alignment." -#endif - extern SCHEME_OBJECT dump_renumber_primitive(), *initialize_primitive_table(), @@ -89,6 +84,27 @@ static Boolean compiled_code_present_p; fasdump_remember_to_fix(Old, *Old); \ } +#ifdef FLOATING_ALIGNMENT + +#define fasdump_flonum_setup() \ +{ \ + Old = OBJECT_ADDRESS (Temp); \ + if (OBJECT_TYPE (*Old) == TC_BROKEN_HEART) \ + { \ + *Scan = (MAKE_OBJECT_FROM_OBJECTS (Temp, *Old)); \ + continue; \ + } \ + FLOAT_ALIGN_FREE(To_Address, To); \ + New_Address = (MAKE_BROKEN_HEART (To_Address)); \ + fasdump_remember_to_fix(Old, *Old); \ +} + +#else /* FLOATING_ALIGNMENT */ + +#define fasdump_flonum_setup() fasdump_normal_setup() + +#endif /* FLOATING_ALIGNMENT */ + #define fasdump_transport_end(length) \ { \ To_Address += (length); \ @@ -522,6 +538,9 @@ dumploop(Scan, To_ptr, To_Address_ptr) fasdump_normal_pointer(copy_quadruple(), 4); case TC_BIG_FLONUM: + fasdump_flonum_setup(); + goto Move_Vector; + case TC_COMPILED_CODE_BLOCK: case_Purify_Vector: fasdump_normal_setup(); @@ -578,7 +597,7 @@ DEFINE_PRIMITIVE ("PRIMITIVE-FASDUMP", Prim_prim_fasdump, 3, 3, 0) { Boolean success; long value, length, hlength, tlength, tsize; - SCHEME_OBJECT *dumped_object, *free_buffer; + SCHEME_OBJECT *dumped_object, *free_buffer, *dummy; SCHEME_OBJECT *table_start, *table_end, *table_top; SCHEME_OBJECT header[FASL_HEADER_LENGTH]; PRIMITIVE_HEADER (3); @@ -610,6 +629,10 @@ DEFINE_PRIMITIVE ("PRIMITIVE-FASDUMP", Prim_prim_fasdump, 3, 3, 0) free_buffer = initialize_free_buffer(); Free = ((SCHEME_OBJECT *) NULL); free_buffer += FASL_HEADER_LENGTH; + + dummy = free_buffer; + FLOAT_ALIGN_FREE(Free, dummy); + *free_buffer++ = (ARG_REF (1)); dumped_object = Free; Free += 1; @@ -685,8 +708,6 @@ DEFINE_PRIMITIVE ("DUMP-BAND", Prim_band_dump, 2, 2, 0) Band_Dump_Permitted (); CHECK_ARG (1, INTERPRETER_APPLICABLE_P); CHECK_ARG (2, STRING_P); - if (! (Open_Dump_File ((ARG_REF (2)), WRITE_FLAG))) - error_bad_range_arg (2); Primitive_GC_If_Needed (5); saved_free = Free; Combination = MAKE_POINTER_OBJECT (TC_COMBINATION_1, Free); @@ -706,10 +727,8 @@ DEFINE_PRIMITIVE ("DUMP-BAND", Prim_band_dump, 2, 2, 0) } else { -#if false - /* Aligning here confuses some of the counts computed. */ - ALIGN_FLOAT (Free); -#endif + if (! (Open_Dump_File ((ARG_REF (2)), WRITE_FLAG))) + error_bad_range_arg (2); result = Write_File((Free - 1), ((long) (Free - Heap_Bottom)), Heap_Bottom, ((long) (Free_Constant - Constant_Space)), @@ -717,19 +736,14 @@ DEFINE_PRIMITIVE ("DUMP-BAND", Prim_band_dump, 2, 2, 0) table_start, table_length, ((long) (table_end - table_start)), (compiler_utilities != SHARP_F), true); + /* The and is short-circuit, so it must be done in this order. */ + result = ((Close_Dump_File ()) && result); + if (!result) + { + result = ((OS_file_remove (STRING_ARG (2))) && result); + } } - /* The and is short-circuit, so it must be done in this order. */ - result = (Close_Dump_File() && result); - Band_Dump_Exit_Hook(); + Band_Dump_Exit_Hook (); Free = saved_free; - if (result) - { - PRIMITIVE_RETURN (SHARP_T); - } - else - { - extern int unlink(); - unlink (STRING_LOC ((ARG_REF (2)), 0)); - PRIMITIVE_RETURN (SHARP_F); - } + PRIMITIVE_RETURN (BOOLEAN_TO_OBJECT (result)); } diff --git a/v7/src/microcode/bchgcc.h b/v7/src/microcode/bchgcc.h index 824b89923..802f173cf 100644 --- a/v7/src/microcode/bchgcc.h +++ b/v7/src/microcode/bchgcc.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchgcc.h,v 9.35 1989/10/28 15:37:55 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchgcc.h,v 9.36 1990/04/01 20:24:46 jinx Exp $ -Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology +Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -185,6 +185,34 @@ extern char gc_death_message_buffer[]; relocate_normal_transport(copy_code, length); \ relocate_normal_end(); \ } + +#ifdef FLOATING_ALIGNMENT + +#define FLOAT_ALIGN_FREE(free,free_ptr) \ +do { \ + while ((((long) ((free) + 1)) & FLOATING_ALIGNMENT) != 0) \ + { \ + free += 1; \ + *free_ptr++ = (MAKE_OBJECT (TC_MANIFEST_NM_VECTOR, 0)); \ + } \ +} while (0) + +#define relocate_flonum_setup() \ +{ \ + relocate_normal_setup(); \ + FLOAT_ALIGN_FREE(To_Address, To); \ + New_Address = (MAKE_BROKEN_HEART (To_Address)); \ +} + +#else /* FLOATING_ALIGNMENT */ + +#define FLOAT_ALIGN_FREE(free,free_ptr) \ +do { \ +} while (0) + +#define relocate_flonum_setup() relocate_normal_setup() + +#endif /* FLOATING_ALIGNMENT */ /* Typeless objects (implicit types). */ diff --git a/v7/src/microcode/bchgcl.c b/v7/src/microcode/bchgcl.c index 793d16fe8..55ad21b2e 100644 --- a/v7/src/microcode/bchgcl.c +++ b/v7/src/microcode/bchgcl.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchgcl.c,v 9.39 1989/12/06 05:48:50 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchgcl.c,v 9.40 1990/04/01 20:26:39 jinx Rel $ -Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology +Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -38,11 +38,6 @@ MIT in each case. */ #include "scheme.h" #include "bchgcc.h" - -#ifdef FLOATING_ALIGNMENT -/* This must be fixed. */ -#include "error: bchgcl does not handle floating alignment." -#endif SCHEME_OBJECT * GCLoop(Scan, To_ptr, To_Address_ptr) @@ -250,6 +245,9 @@ GCLoop(Scan, To_ptr, To_Address_ptr) relocate_normal_pointer(copy_quadruple(), 4); case TC_BIG_FLONUM: + relocate_flonum_setup(); + goto Move_Vector; + case_Vector: relocate_normal_setup(); Move_Vector: diff --git a/v7/src/microcode/bchmmg.c b/v7/src/microcode/bchmmg.c index 282e66682..d50007bcf 100644 --- a/v7/src/microcode/bchmmg.c +++ b/v7/src/microcode/bchmmg.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchmmg.c,v 9.51 1990/01/23 03:00:23 gjs Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchmmg.c,v 9.52 1990/04/01 20:30:17 jinx Exp $ -Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology +Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -51,9 +51,8 @@ MIT in each case. */ Problems with this implementation right now: - Purify kills Scheme if there is not enough space in constant space for the new object. - - Floating alignment is not implemented. - It only works on Unix (or systems which support Unix i/o calls). - - Dumpworld cannot work because the file is not closed at dump time or + - Dumpworld does not work because the file is not closed at dump time or reopened at restart time. - Command line supplied gc files are not locked, so two processes can try to share them and get very confused. @@ -229,10 +228,9 @@ Setup_Memory(Our_Heap_Size, Our_Stack_Size, Our_Constant_Size) /* Allocate. The two GC buffers are not included in the valid Scheme memory. */ - Highest_Allocated_Address = - ALLOCATE_HEAP_SPACE(Real_Stack_Size + Our_Heap_Size + - Our_Constant_Size + (2 * GC_BUFFER_SPACE) + - HEAP_BUFFER_SPACE); + ALLOCATE_HEAP_SPACE(Real_Stack_Size + Our_Heap_Size + + Our_Constant_Size + (2 * GC_BUFFER_SPACE) + + (HEAP_BUFFER_SPACE + 1)); /* Consistency check 2 */ if (Heap == NULL) @@ -241,14 +239,18 @@ Setup_Memory(Our_Heap_Size, Our_Stack_Size, Our_Constant_Size) exit(1); } - /* Trim the system buffer space. */ - - Highest_Allocated_Address -= (2 * GC_BUFFER_SPACE); Heap += HEAP_BUFFER_SPACE; INITIAL_ALIGN_FLOAT(Heap); Constant_Space = Heap + Our_Heap_Size; - gc_disk_buffer_1 = Constant_Space + Our_Constant_Size + Real_Stack_Size; + ALIGN_FLOAT (Constant_Space); + + /* Trim the system buffer space. */ + + Highest_Allocated_Address = (Constant_Space + + (Our_Constant_Size + Real_Stack_Size)); + + gc_disk_buffer_1 = Highest_Allocated_Address + 1; gc_disk_buffer_2 = (gc_disk_buffer_1 + GC_BUFFER_SPACE); /* Consistency check 3 */ diff --git a/v7/src/microcode/bchpur.c b/v7/src/microcode/bchpur.c index 3de442de6..75e62c4ae 100644 --- a/v7/src/microcode/bchpur.c +++ b/v7/src/microcode/bchpur.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchpur.c,v 9.48 1989/12/06 05:49:09 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchpur.c,v 9.49 1990/04/01 20:32:02 jinx Exp $ -Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology +Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -45,11 +45,6 @@ MIT in each case. */ #include "scheme.h" #include "prims.h" #include "bchgcc.h" - -#ifdef FLOATING_ALIGNMENT -/* This must be fixed. */ -#include "error: bchpur does not handle floating alignment." -#endif /* Purify modes */ @@ -318,13 +313,16 @@ purifyloop(Scan, To_ptr, To_Address_ptr, purify_mode) case_Quadruple: relocate_normal_pointer(copy_quadruple(), 4); + case TC_BIG_FLONUM: + relocate_flonum_setup(); + goto Move_Vector; + case TC_COMPILED_CODE_BLOCK: case TC_ENVIRONMENT: if (purify_mode == PURE_COPY) break; /* Fall through */ - case TC_BIG_FLONUM: case_Purify_Vector: relocate_normal_setup(); Move_Vector: -- 2.25.1