[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaJIT FFI __gc metamethod?
- From: Mike Pall <mikelu-1102@...>
- Date: Wed, 23 Feb 2011 01:06:10 +0100
Josh Haberman wrote:
> Here is a more specific description of the two options I am
> considering. My question is whether my explicit table lookup
> in option #1 is somehow harder to optimize than then the
> automatic __index table lookup in option #2.
The compiler has no difficulties with either approach. To compare
the complexity: The __newindex variant requires 11 conditionals
for dispatch, the accessor function requires 9 conditionals.
All of these can usually be hoisted in loops, i.e. the overhead is
zero for both variants. In cases where they cannot be hoisted, the
machine code for the__newindex variant needs about 2 extra cycles.
I.e. this is a difference of ~0.6 nanoseconds per dispatch for the
non-hoistable case. I'm not sure you'll be able to notice in
practice ... :-)