[gclist] Re: gclist-digest V3 #83
William D Clinger
will@ccs.neu.edu
Sat, 17 Jun 2000 11:39:04 -0400
Douglas Atique asked how precise garbage collectors can distinguish
pointers from non-pointers, writing:
> I have also seen systems that implement garbage collection by tagging values,
> i.e., marking some bits to indicate a pointer, an integer, a float or a char.
> That is not very desirable in my opinion because it restricts the range of
> values one can have and makes those values' meaning dependent on knowing such
> conventions.
These bits do not have to restrict the range of values. In a type-safe
language such as Java, these bits can go into the representation of each
class, not in the representation of each object. Every block of storage
represents an object and contains a pointer to that object's class, so
the garbage collector can get to these tag bits with a couple of load
instructions.
Besides, the meaning of a value always depends upon the conventions used
to represent it. This is as true in unsafe languages as in safe languages,
but unsafe languages may allow programmers to devise novel meanings based
on novel conventions.
Will