is RITE stack based or register based VM?

Discussion in 'Ruby' started by rolo, Apr 4, 2004.

  1. rolo

    rolo Guest

    Hi

    RITE is a stack based VM like JVM or Register based like Parrot?

    regards,
    rolo
     
    rolo, Apr 4, 2004
    #1
    1. Advertising

  2. Hi,

    In message "is RITE stack based or register based VM?"
    on 04/04/05, "rolo" <> writes:

    |RITE is a stack based VM like JVM or Register based like Parrot?

    Stack based, as I believe.

    matz.
     
    Yukihiro Matsumoto, Apr 5, 2004
    #2
    1. Advertising

  3. Le 4 avr. 04, à 20:00, Yukihiro Matsumoto a écrit :

    > Hi,
    >
    > In message "is RITE stack based or register based VM?"
    > on 04/04/05, "rolo" <> writes:
    >
    > |RITE is a stack based VM like JVM or Register based like Parrot?
    >
    > Stack based, as I believe.


    Do you mean 'I believe RITE is stack based' or 'RITE is stack based, as
    it is the technology I believe in'?

    > matz.
    >
     
    Guillaume Marcais, Apr 5, 2004
    #3
  4. Hi,

    In message "Re: is RITE stack based or register based VM?"
    on 04/04/05, Guillaume Marcais <> writes:

    |> Stack based, as I believe.
    |
    |Do you mean 'I believe RITE is stack based' or 'RITE is stack based, as
    |it is the technology I believe in'?

    Hmm, ambiguity in the English language is interesting. I meant the
    former, but I'd say "both".

    matz.
     
    Yukihiro Matsumoto, Apr 5, 2004
    #4
  5. Hi,

    Skip this msg unless theory about interpreters implementations matters to you.

    Stack based... to what extend (speculations about RITE) ?

    Two things:
    1) I guess we are not talking of the micro-processor's stack (SP) here.
    Stack "less" interpreters are considered easier/better approach.
    See stackless Python. Anyway, Continuations make it tricky to use the
    processor's stack. You need a SpaghettiStack.
    2) Regarding the "expression evaluation stack". That is a different matter.
    Probably the one involved when talking about "stack based vs register
    based".

    For this case, I may point out that sometimes the compiler can get some
    knowledge about "how deep" that stack most probably needs to be (I
    suppose it
    can never actually know the max depth, due to
    Continuation/Blocks/eval()).

    However, for the cases where the compiler knows about the stack depth,
    it is faster to perform absolute addressing instead of relative
    addressing
    with some SP (you avoid the ++SP/--SP house keeping, among others).

    Example 1: Stack based imaginary VM. c = a + b
    push b # Alloc stack slot, link to previous, put b's value in it
    push a # Alloc stack slot, link to previous, put a's value in it
    meth +, 2 # Invoke method, dealloc 1 stack slot
    pop c # Mov top-of-stack to c, dealloc 1 stack slot.

    Example 2: Precomputed stack accesses
    stack 2 # Alloc stack slots, done once when
    ActivationRecord is created.
    mov b, 0 # put b's value in first slot
    mov a, 1 # put a's value in second slot
    meth +, 0, 2 # Invoke method, args in first & second slots
    mov 0, c # Mov first slot's value to c

    Benefit:
    - Speed ! One allocation only
    Drawback:
    - Compiler must compute @stackDepth of each method definition.
    - Efficient allocation of stacks requires some pool management for
    most frequent stack sizes.

    Considering that Rite's main purpose is speed, stack management probably
    deserve to be as efficient as possible.

    I don't know wether the result should be called stack based or register
    based, because there still is a variable depth stack yet you most of the
    time use it as an array of registers.

    Yours,

    Jean-Hugues Robert

    See also:
    http://www.c2.com/cgi/wiki?ActivationRecord
    http://www.c2.com/cgi/wiki?StacklessPython
    http://www.c2.com/cgi/wiki?ContinuationExplanation
    http://www.c2.com/cgi/wiki?SpaghettiStack


    At 09:00 05/04/2004 +0900, you wrote:
    >Hi,
    >
    >In message "is RITE stack based or register based VM?"
    > on 04/04/05, "rolo" <> writes:
    >
    >|RITE is a stack based VM like JVM or Register based like Parrot?
    >
    >Stack based, as I believe.
    >
    > matz.
    >E is a stack based VM like JVM or Register based like Parrot?
    >
    >Stack based, as I believe.
    >
    > matz.


    -------------------------------------------------------------------------
    Web: http://hdl.handle.net/1030.37/1.1
    Phone: +33 (0) 4 92 27 74 17
     
    Jean-Hugues ROBERT, Apr 5, 2004
    #5
  6. Hi,

    At 02:48 06/04/2004 +0900, you wrote:
    > For this case, I may point out that sometimes the compiler can get some
    > knowledge about "how deep" that stack most probably needs to be (I
    >suppose it
    > can never actually know the max depth, due to
    >Continuation/Blocks/eval()).
    >
    >[rolo] Do you mean that based on the information that max depth is
    >unknown, a stack based RITE would not be as efficient as it can be using
    >registers?


    I don't know about that. What I do know is that when the
    evaluation stack max depth can be determined by the compiler,
    it is more efficient to allocate that stack once (per ActivationRecord)
    and use the stack as an array with absolute indexes, instead of
    computing some SP at runtime.
    I would have to investigate more about what "register" means in modern
    interpretor, because the understanding I have is based on some work
    done by C compilers twenty years ago ;-) I may do that to see if the
    optimization I did implement in an interpretor a while ago is related
    in anyway to "registers", even thought at this point I think it is
    not and is more like an optimized stack based scheme.

    When the stack size cannot be pre-determined, I guess that the only
    solution is to allocate more chunks of stack slots as needed (kind
    of catching stack-overflow as is done by some OS). The only optimization
    I can think of here is to allocate bigger chuncks versus one slot at
    the time.

    Yours,

    Jean-Hugues


    -------------------------------------------------------------------------
    Web: http://hdl.handle.net/1030.37/1.1
    Phone: +33 (0) 4 92 27 74 17
     
    Jean-Hugues ROBERT, Apr 5, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John
    Replies:
    5
    Views:
    385
    Tina - AffordableHOST.com
    Dec 24, 2003
  2. Simon Strandgaard

    matz thoughts on Rite ?

    Simon Strandgaard, Jul 21, 2003, in forum: Ruby
    Replies:
    22
    Views:
    252
    Rasputin
    Jul 22, 2003
  3. Austin Ziegler

    Ruby => Rite, AST => Bytecode?

    Austin Ziegler, Jul 30, 2003, in forum: Ruby
    Replies:
    2
    Views:
    120
    Phil Tomson
    Jul 30, 2003
  4. Guest
    Replies:
    34
    Views:
    385
    Jim Freeze
    Aug 28, 2003
  5. Michael Neumann

    [Rite] Byte-Code Compiler in Ruby

    Michael Neumann, Nov 16, 2003, in forum: Ruby
    Replies:
    2
    Views:
    139
    George Marrows
    Nov 17, 2003
Loading...

Share This Page