Re: Implemenation of Global Variables



bart demoen wrote:
#define noye_trail(loc,bh,trreg,newval) \
if (loc >= bh) \
*loc = newval; \
else \
{ if (!is_ref(*loc) || (*loc) < bh)) \
{ *trreg++ = *loc; /* old value */ \
*trreg++ = loc; /* location */ \
} \
*loc = hreg; \
*hreg = newval; \
hreg++; \
}
If newval is already at a location >= bh, you don't need
to create the extra indirection.

True. But my deref doesn't remember the location: it is pure tag on
pointer WAM style, so there there is no a need to remember the
location in the common circumstances. Variable shunting will get rid of
the unnecessary indirection at some point :-)

I was thinking of the case where newval is a list,
structure, boxed constant on the heap etc.

-- Joachim
.



Relevant Pages

  • Re: Implemenation of Global Variables
    ... I don't know about any papers describing Noye trailing - Jacques' thesis ... *loc = newval; \ ... *hreg = newval; \ ... to create the extra indirection. ...
    (comp.lang.prolog)
  • Re: Implemenation of Global Variables
    ... You need to sacrifice a heap word each time an update is ... B-Prolog adopts the naive trailing scheme. ... *loc = newval; \ ... *hreg = newval; \ ...
    (comp.lang.prolog)
  • Re: Implemenation of Global Variables
    ... here is the hProlog macro ... iomplementing it - it should be self-explaining, ... *loc = newval; \ ... *hreg = newval; \ ...
    (comp.lang.prolog)
  • Re: Implemenation of Global Variables
    ... here is the hProlog macro ... is not clear (I have removed some irrelevant overflow checking and type ... *loc = newval; \ ... *hreg = newval; \ ...
    (comp.lang.prolog)