[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: PATCH: How to handle CallInfo func field safely?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 21 Apr 2021 13:54:08 -0300
> That said, now that you mention it really is a bit strange that it does a
> straight cast with clLvalue, without any checking. I wonder if it would
> make sense to have the `cl` be one of the parameters to luaV_execute. The
> places that call luaV_execute are all places that have checked the type tag
> of the function object and have the `cl` at hand.
luaV_execute is called in three places (all of them in ldo.c). It seems
that in none of them 'cl' is readly available. In two of them (when
resuming and unrolling a coroutine), Lua uses a bit in CallInfo to check
whether the function is a Lua function, with no access to 'func'. In
the other call (inside 'ccall'), there is a call to 'luaD_precall'
that does access 'cl', but I don't see a cheap way to return that.
Moreover, whe luaV_execute restarts (returning from or calling another
function), it also needs to update its 'cl'. To remove that assignment,
making 'cl' a parameter, would only spread that cast to several other
places.
-- Roberto