Computed gotos on Reddit

Walter Bright newshound2 at digitalmars.com
Wed Jul 25 15:46:11 PDT 2012


On 7/25/2012 2:55 PM, Dmitry Olshansky wrote:
>>>>> std\regex.d(5118): Error: undefined identifier 'L_jumptable'
>>>>>
>>>>
>>>> I was afraid of that. You may have to approximate it by loading the
>>>> address of L_jumptable into a register and adding it in instead of using
>>>> the addressing mode.
>
> I failed to load it in any register or interact with it in any way.
> I think I've stalled. There has to be a way to get label address somehow, I got
> tired of guess and shot :(
>
> BTW that would allow us to do computed gotos but only in inline asm.
>

How to get an address:

      call jump_table
L1:

      ...
jump_table:
      pop EAX
      jmp L1
      .. the rest of the jump table ...

Yes, it's awful, but we're just trying to take some measurements here, so it 
doesn't matter.

What I meant was add these extra instructions in to the switch version as 
dummies in order to make the extra time they take irrelevant to looking at the 
difference.



More information about the Digitalmars-d mailing list