Computed gotos on Reddit
Walter Bright
newshound2 at digitalmars.com
Wed Jul 25 10:19:46 PDT 2012
On 7/25/2012 4:26 AM, Dmitry Olshansky wrote:
> On 25-Jul-12 15:14, Don Clugston wrote:
>> On 25/07/12 12:11, Walter Bright wrote:
>>> On 7/25/2012 12:51 AM, Don Clugston wrote:
>>>> so that there is no lookup table, just a multiply.
>>>
>>> Rethinking your idea a bit...
>>>
>>> Suppose the switch jump_address[] array was really an array of hardcoded
>>> jmp instructions, 5 bytes each:
>>>
>>> jmp_table:
>>> jmp Lcase1;
>>> jmp Lcase2;
>>> jmp Lcase3;
>>> ...
>>>
>>> and then the switch(EBX) would be:
>>>
>>> lea EAX,jmp_table[EBX][EBX*4]
>>> jmp EAX
>>>
>>> is that kick-ass or what?
>>>
>>> (There'd be some additional complication for PIC code.)
>>
>> Very nice. The jumps in the jump table take effectively zero cycles.
>> That looks quite doable.
>
> Looks neat. I'd more then willing to test how it affects my tiny VM in std.regex.
>
Is it possible you could code it up and test it using inline asm?
More information about the Digitalmars-d
mailing list