1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

* pairs.h, eval.c, eval.h, feature.c, gc.c, list.c, load.c,

ramap.c, symbols.c: Added new selectors SCM_CARLOC and SCM_CDRLOC
for obtaining the address of a car or cdr field.  Motivation:
&SCM_CXR make assumptions about the internal structure of the
SCM_CXR selectors.

* pairs.h, eval.c, gc.c, init.c, ioext.c, ports.c, ports.h,
srcprop.h, tags.h, throw.c, unif.c: Added new selectors
SCM_SETAND_CAR, SCM_SETAND_CDR, SCM_SETOR_CAR and SCM_SETOR_CDR.
Motivation: Safer use.  Some other macros are defined in terms of
these operations.  If these are defined using the SCM_SETCXR
(<e1>, SCM_CXR (<e1>) <op> <e2>) pattern a complex <e1> will lead
to inefficiency and an <e1> with side-effects could potentially
break.  Also, these particular operations are heavily utilized in
the garbage collector.  In unoptimized code there will be a
measurable speedup.

* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
This commit is contained in:
Mikael Djurfeldt 1996-10-20 03:29:01 +00:00
parent 898a256f91
commit 24e68a57b9
2 changed files with 21 additions and 13 deletions

View file

@ -350,7 +350,7 @@ scm_igc (what)
while (type_list != SCM_EOL) while (type_list != SCM_EOL)
if (SCM_VELTS (SCM_CAR (type_list))[scm_struct_i_refcnt]) if (SCM_VELTS (SCM_CAR (type_list))[scm_struct_i_refcnt])
{ {
pos = &SCM_CDR (type_list); pos = SCM_CDRLOC (type_list);
type_list = SCM_CDR (type_list); type_list = SCM_CDR (type_list);
} }
else else
@ -717,7 +717,7 @@ gc_mark_nimp:
case scm_tc_free_cell: case scm_tc_free_cell:
/* printf("found free_cell %X ", ptr); fflush(stdout); */ /* printf("found free_cell %X ", ptr); fflush(stdout); */
SCM_SETGC8MARK (ptr); SCM_SETGC8MARK (ptr);
SCM_CDR (ptr) = SCM_EOL; SCM_SETCDR (ptr, SCM_EOL);
break; break;
case scm_tcs_bignums: case scm_tcs_bignums:
case scm_tc16_flo: case scm_tc16_flo:
@ -952,7 +952,7 @@ scm_gc_sweep ()
if (SCM_GCMARKP (scmptr)) if (SCM_GCMARKP (scmptr))
{ {
if (SCM_CDR (SCM_CAR (scmptr) - 1) == (SCM)1) if (SCM_CDR (SCM_CAR (scmptr) - 1) == (SCM)1)
SCM_CDR (SCM_CAR (scmptr) - 1) = (SCM)0; SCM_SETCDR (SCM_CAR (scmptr) - 1, (SCM) 0);
goto cmrkcontinue; goto cmrkcontinue;
} }
{ {
@ -1090,7 +1090,7 @@ scm_gc_sweep ()
SCM_SETSTREAM (scmptr, 0); SCM_SETSTREAM (scmptr, 0);
scm_remove_from_port_table (scmptr); scm_remove_from_port_table (scmptr);
scm_gc_ports_collected++; scm_gc_ports_collected++;
SCM_CAR (scmptr) &= ~SCM_OPN; SCM_SETAND_CAR (scmptr, ~SCM_OPN);
} }
break; break;
case scm_tc7_smob: case scm_tc7_smob:
@ -1146,8 +1146,8 @@ scm_gc_sweep ()
if (SCM_CAR (scmptr) == (SCM) scm_tc_free_cell) if (SCM_CAR (scmptr) == (SCM) scm_tc_free_cell)
exit (2); exit (2);
#endif #endif
SCM_CAR (scmptr) = (SCM) scm_tc_free_cell; SCM_SETCAR (scmptr, (SCM) scm_tc_free_cell);
SCM_CDR (scmptr) = nfreelist; SCM_SETCDR (scmptr, nfreelist);
nfreelist = scmptr; nfreelist = scmptr;
#if 0 #if 0
if ((nfreelist < scm_heap_table[0].bounds[0]) || if ((nfreelist < scm_heap_table[0].bounds[0]) ||
@ -1227,7 +1227,7 @@ scm_gc_sweep ()
*fixup = SCM_CDR (alist); *fixup = SCM_CDR (alist);
} }
else else
fixup = &SCM_CDR (alist); fixup = SCM_CDRLOC (alist);
alist = SCM_CDR (alist); alist = SCM_CDR (alist);
} }
} }
@ -1453,8 +1453,8 @@ init_heap_seg (seg_org, size, ncells, freelistp)
#ifdef SCM_POINTERS_MUNGED #ifdef SCM_POINTERS_MUNGED
scmptr = PTR2SCM (ptr); scmptr = PTR2SCM (ptr);
#endif #endif
SCM_CAR (scmptr) = (SCM) scm_tc_free_cell; SCM_SETCAR (scmptr, (SCM) scm_tc_free_cell);
SCM_CDR (scmptr) = PTR2SCM (ptr + ncells); SCM_SETCDR (scmptr, PTR2SCM (ptr + ncells));
ptr += ncells; ptr += ncells;
} }
@ -1463,7 +1463,7 @@ init_heap_seg (seg_org, size, ncells, freelistp)
/* Patch up the last freelist pointer in the segment /* Patch up the last freelist pointer in the segment
* to join it to the input freelist. * to join it to the input freelist.
*/ */
SCM_CDR (PTR2SCM (ptr)) = *freelistp; SCM_SETCDR (PTR2SCM (ptr), *freelistp);
*freelistp = PTR2SCM (CELL_UP (seg_org)); *freelistp = PTR2SCM (CELL_UP (seg_org));
scm_heap_size += (ncells * n_new_objects); scm_heap_size += (ncells * n_new_objects);
@ -1659,7 +1659,7 @@ scm_init_storage (init_heap_size)
scm_undefineds = scm_cons (SCM_UNDEFINED, SCM_EOL); scm_undefineds = scm_cons (SCM_UNDEFINED, SCM_EOL);
SCM_CDR (scm_undefineds) = scm_undefineds; SCM_SETCDR (scm_undefineds, scm_undefineds);
scm_listofnull = scm_cons (SCM_EOL, SCM_EOL); scm_listofnull = scm_cons (SCM_EOL, SCM_EOL);
scm_nullstr = scm_makstr (0L, 0); scm_nullstr = scm_makstr (0L, 0);

View file

@ -101,8 +101,16 @@ typedef SCM huge *SCMPTR;
#define SCM_CAR(x) (((scm_cell *)(SCM2PTR(x)))->car) #define SCM_CAR(x) (((scm_cell *)(SCM2PTR(x)))->car)
#define SCM_CDR(x) (((scm_cell *)(SCM2PTR(x)))->cdr) #define SCM_CDR(x) (((scm_cell *)(SCM2PTR(x)))->cdr)
#define SCM_GCCDR(x) (~1L & SCM_CDR(x)) #define SCM_GCCDR(x) (~1L & SCM_CDR(x))
#define SCM_SETCDR(x, v) SCM_CDR(x) = (SCM)(v) #define SCM_SETCAR(x, v) (SCM_CAR(x) = (SCM)(v))
#define SCM_SETCAR(x, v) SCM_CAR(x) = (SCM)(v) #define SCM_SETCDR(x, v) (SCM_CDR(x) = (SCM)(v))
#define SCM_CARLOC(x) (&SCM_CAR (x))
#define SCM_CDRLOC(x) (&SCM_CDR (x))
#define SCM_SETAND_CAR(x, y) (SCM_CAR (x) &= (y))
#define SCM_SETAND_CDR(x, y) (SCM_CDR (x) &= (y))
#define SCM_SETOR_CAR(x, y) (SCM_CAR (x) |= (y))
#define SCM_SETOR_CDR(x, y) (SCM_CDR (x) |= (y))
#define SCM_CAAR(OBJ) SCM_CAR (SCM_CAR (OBJ)) #define SCM_CAAR(OBJ) SCM_CAR (SCM_CAR (OBJ))
#define SCM_CDAR(OBJ) SCM_CDR (SCM_CAR (OBJ)) #define SCM_CDAR(OBJ) SCM_CDR (SCM_CAR (OBJ))