lua-users home
lua-l archive

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


On Thu, Nov 18, 2010 at 11:01 AM, Alex Queiroz <asandroq@gmail.com> wrote:
> Hallo,
>
> On Thu, Nov 18, 2010 at 8:40 AM, Mike Pall <mikelu-1011@mike.de> wrote:
>>
>> [Case in point: 2 of the 3 leading open source JavaScript engines
>> have now switched to the 8 byte NaN-tagging value model that's
>> used by LuaJIT. Esp. Mozilla made extensive measurements before
>> going for such a major change of their code base. Having a compact
>> value representation pays off big time for dynamic languages.]
>>
>
>     Sometimes I wonder how plain Lua can be so fast sticking only to
> standard ANSI C. That's an achievement. For instance, the VM dispatch
> uses the C switch statement, which is known to be slow.
>

Hi, Alex.

I had the same impression, but analyzing the resulted assembly code I
realized that the performance of switch depends on the compiler that
you use. Lua's team always defines the values used by the switch
statements in a minimal range (excellent design). So the compiler can
create a Table Of Address to jump to the case option.

jump TOA[ option - first_option_value ]

It is very fast but, of course, depends on the compiler.

If you want to speed up a little the command loop, you could try to
comment then debug test.

-- 
Nilson