lua-users home
lua-l archive

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


Hallo,

On Thu, Nov 18, 2010 at 12:55 PM, Paul Hudson <phudson@pobox.com> wrote:
>
> So I agree, I see nothing in C switch statements that makes them inherently
> slow.
>

     I am not very knowledgeable in CPU architectures, but AFAIK the
problem is not the quality of the code generated but its interaction
with the main loop of a virtual machine. Modern, high-pipelined CPUs
try to predict the instructions that will be executed next to fetch
them ahead of time and keep the pipeline full. If this prediction is
often wrong, the pipelines get flushed very often and the performance
penalty can be very noticeable. This happens in a traditional VM
implementation because the CPU's instruction pointer is not correlated
with the bytecode one.

Cheers,
-- 
-alex
http://www.artisancoder.com/