Loading ...
Sorry, an error occurred while loading the content.

Re: [langsmiths] Trampoline Callbacks

Expand Messages
  • James McCartney
    hmm, no response. another approach, which seems like it would be a better fit for Io with its actors model support would be to do as Erlang does and treat OS
    Message 1 of 33 , Mar 7, 2005
    • 0 Attachment
      hmm, no response.

      another approach, which seems like it would be a better fit for Io with
      its actors model support would be to do as Erlang does and treat OS
      services as async processes and message to their ports. You then have
      the option of waiting synchronously (the !! operator in Erlang) or
      proceeding asynchronously.

      On Feb 25, 2005, at 2:07 PM, James McCartney wrote:

      >
      > thoughts about trampolining in general or specifically to avoid
      > blocking system calls?
      > I first read about trampolining in "Implementing lazy functional
      > languages on stock hardware" by Simon Peyton Jones, section 6.2.2
      >
      >
      > On Feb 25, 2005, at 6:49 AM, Steve Dekorte wrote:
      >
      >>
      >>
      >> http://www.vlerq.org/vqo/47
      >>
      >> Thoughts?
    • spcmanspiff
      For what it s worth, I think there are two completely unrelated definitions floating around: * One that s used in JIT compilers. This one typically is emitting
      Message 33 of 33 , Mar 10, 2005
      • 0 Attachment
        For what it's worth, I think there are two completely unrelated
        definitions floating around:

        * One that's used in JIT compilers. This one typically is emitting
        special machine code to implement non-compiled functions that, once
        called, they branch back to the JIT so the missing code can be compiled,
        then called in place -- so from the calling function's point of view,
        nothing needs to be done.

        * Another that seems to be used to eliminate tail call overhead in some
        types of interpreters. (I had never seen this usage before until
        googling a bit based on the mails floating around.)

        A quote from
        http://docs.msdnaa.net/ark_new/Webfiles/WhitePapers/Babel01/bab12.pdf
        ("Tail call elimination on the Java Virtual Machine"):

        > A popular technique is to use a trampoline [9]. A trampoline is an
        > outer function which repeatedly calls an inner function. Each time the
        > inner function wishes to tail call another function, it does not call
        > it directly but simply returns its identity (e.g. as a closure) to the
        > trampoline, which then does the call itself. Unlimited stack growth is
        > thus avoided, but some performance is inevitably lost, mostly because
        > all the calls made by the trampoline are calls to statically unknown
        > functions.

        I think almost all the discussion & questions going back and forth here
        come from conflating the two different meanings of the word.

        -- dan

        On Thu, 2005-03-10 at 12:26 -0800, James McCartney wrote:
        >
        > I don't think being dynamically generated is what makes something a
        > trampoline.
        > A trampoline is a function that returns the next function to call --
        > dynamically generated or not.
        > Whoever wrote that definition probably didn't understand it.
        >
        > On Mar 10, 2005, at 6:48 AM, Steven Shaw wrote:
        >
        > > 2. the trampoline as dynamically generated machine code (with no RET
        > > statement)
        > > that does some kind of complicated stack fix-up and then JMPs to
        > > the
        > > actually function to be called (now that the stack's all fine and
        > > dandy).
        > >
        > > I understand (1) and I clearly don't understand (2) or whether they're
        > > perhaps related techniques...
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.