lua-users home
lua-l archive

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

On 12/08/2014 10:49 PM, Dong Feng wrote:

2014-12-08 13:40 GMT-08:00 Coda Highland <>:
On Mon, Dec 8, 2014 at 1:15 PM, Rena <> wrote:
> On Mon, Dec 8, 2014 at 2:05 PM, Dong Feng <> wrote:
>> I'm trying to understand the following function.
>> void luaV_finishOp (lua_State *L)
>> The comments say it is to resume an instruction interrupted by a previous
>> yield. In its implementation, there is a switch-case for a varieties of
>> instruction types (ADD, SUB, etc.).
>> To my very limited understanding, I see only one possible code path being
>> hit, that is, the OP_CALL. Because an execution is always interrupted by a
>> call to coroutine.yield(). How come there are so many handling paths?
>> I think my understanding is quite limited so I must miss many things here.
>> Just don't know what I missed. Thank you in advance.
>> Dong
> Just a hunch: they might also be interrupted by debug hooks?

I was thinking metamethods -- I don't think those get processed through OP_CALL.

/s/ Adam

I had not thought along that direction. However, I see luaV_finishOp() is not a heavily reused function. It seems only be hit through

lua_resume -> resume -> unroll -> luaV_finishOp

So I'm not sure whether the case about meta-table or debug-hook is really applied. Seems unlikely. Maybe I'm wrong.


My dubugger works like this. The hook yields from any line, when you resume the program it may call lua_resume on a lua_state standing at any possible instruction.

I also have the metamethod case, as I have some callable objects which yield on call.