monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] Re: MM with temporaries


From: Nathaniel Smith
Subject: Re: [Monotone-devel] Re: MM with temporaries
Date: Fri, 23 Sep 2005 18:03:00 -0700
User-agent: Mutt/1.5.9i

On Fri, Sep 23, 2005 at 08:27:20AM -0700, Steven E. Harris wrote:
> But I don't know what MM() looks like or what it does. Does it just
> create a Musing instance, which does all its magic in its constructor,
> or does it access members of the Musing instance and depend upon
> destructor behavior? I ask because we know that the temporary stays
> valid for the duration of the Musing constructor. Does it need to stay
> valid longer than that for your purposes?

Yeah, it does.  The logic is:
  -- MM(foo_obj): expands to (roughly)
         Musing<foo> unique_name_12345(foo_obj);
     i.e., creates a local effectively-anonymous temporary.
  -- the Musing<> constructor saves a 'this' pointer in a well-known
     location
  -- the Musing<> destructor removes the pointer again
  -- if an assertion is hit, then we look in that well-known location
     to get a list of currently-in-scope objects, pretty-print them,
     and dump them to the debug log (along with metadata like the name
     of the object being dumped, etc.).  This is the code that
     actually dereferences the foo_obj reference.

A critical point is that the constructor and destructor both need to
be quite cheap (so that we can pepper these even in speed-critical
code) -- all they do is save a reference and push/pop a pointer off a
global stack -- and then only when an assertion has already failed do
we spend the time to do pretty-printing, etc.

-- Nathaniel

-- 
  /* Tell the world that we're going to be the grim
   * reaper of innocent orphaned children.
   */
-- Linux kernel 2.4.5, main.c




reply via email to

[Prev in Thread] Current Thread [Next in Thread]