Computed gotos on Reddit

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Jul 22 20:47:07 PDT 2012


On 23-Jul-12 07:05, deadalnix wrote:
> On 23/07/2012 01:35, bearophile wrote:
>> A discussion appeared few days ago on Reddit, about computed gotos:
>>
>> http://www.reddit.com/r/programming/comments/wld04/eli_benderskys_website_computed_goto_for/
>>
>>
>>
>> http://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables/
>>
>>
>
>
> The presented example is insanely unsafe. By giving invalid input, you
> can basically branch randomly.
>
> The check added by the switch is what is required to make it safe, so it
> isn't faster at the end.
>
> The case in the article isn't very strong.

The  trick is to check the whole bytecode first then execute. The bulk 
of time is spent in loops anyway.
But yes it's not particularly safe.

 > The case in the article isn't very strong.

 From a glance it's a well known case of threaded code interpreters. 
That is the only fast *portable* interpreters as of now.

So the case is strong but hardly anything new ;)

P.S. sorry for mailing you directly, updated firefox changed interface 
*again* :)

-- 
Dmitry Olshansky


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list