lua-users home
lua-l archive

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


On 30 June 2017 at 16:56, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> I am looking at an optimization scenario. My goal is to allow certain
> native C functions that take one or two primitive arguments and return
> a primitive, to be called directly by the VM bypassing the normal Lua
> function call sequence. Examples of functions that can be handled this
> way are the maths functions.
>
> My plan is to enhance the CClosure structure with an additional field
> - that will encode the C function's argument types and the return
> type.
>

I am hoping to use a type such as Light C Function for the proposed
special type above. However there is no space in the value structure
where I can put the extra details I need. Although out of the 16-byte
value structure - 4 bytes are unused I think - yet I believe that
there is an assumption that apart from the value itself which takes up
8 bytes - the type field must fit into a single byte (see link below).

http://lua-users.org/lists/lua-l/2016-11/msg00301.html

I was wondering if the tt_ field in TValue should also be made a byte
field for the sake of consistency both with struct Udata and GCObject.
Anyway, it seems that I could potentially add another byte in TValue
(using the available space) and to struct Udata as well - without
actually changing the overall size of these two structures. GCObject
would not need this extra field as Light C Functions are not
GCObjects.

Just thinking aloud here - if anyone has any bright ideas of how to
pack the extra data into a value then please let me know.

Thanks and Regards
Dibyendu