[m-dev.] Re: pragma fact_table

David Matthew OVERTON dmo at students.cs.mu.oz.au
Wed Feb 19 13:55:04 AEDT 1997


Hi again Fergus,

Fergus Henderson wrote:
> 
> 
> > > > +	Word index;	  /* index into fact table data array 		     */
> > > > +		          /* or pointer to hash table for next argument      */
> > > > +	short type;	  /* 0 if entry empty, 1 if entry is a pointer to the*/
> > > > +			  /* data table, 2 if entry is a pointer to another  */
> > > > +			  /* hash table 				     */
> > > 
> > > It would be more efficient to use a single tagged pointer rather than
> > > two fields here.
> > > 
> > 
> > How would the tags work considering index has to be able to represent an
> > integer or a pointer?
> 
> Use 30-bit integers (or 61-bit, on a 64-bit architecture).
> 
> You'll need to use the mkbody() macro to shift the integer value
> a few bits left to make room for the tag, and when you want to get
> the integer value back, use the unmkbody() macro, which does the
> corresponding shift right.

For the case when index is a pointer, is it guaranteed to be aligned
on a word boundary (i.e. so that at least the 2 least significant bits
are 0)?  The pointer is pointing to a struct defined as a global C
variable, not to something on the Mercury heap.


David



More information about the developers mailing list