[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua return
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 23 Oct 2003 08:21:21 -0200
>can you or Roberto explain how is the "calling" convention and what's
>the params to RETURN (010,020)?
Use the source , Luke! In this case, it's even commented!
OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
This means: call the function in register A, using B-1 args starting at A+1,
and store C-1 return values starting at A.
OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
This means: return B-1 values starting at A; if B is 0, return everything
on the stack.
> Well, Why you guys don't make this?:
> When encounter a return (in source code), do:
> PUSH the values to the stack,
> PUSH the number of values to return,
> JUMP to the end of function, if necessary (if it's already at end),
The code generated by this scheme has an extra instruction for each return.
The current scheme has at most a single extra instruction. Why worry about
a harmless RETURN at the end??