Computed gotos on Reddit
Don Clugston
dac at nospam.com
Thu Jul 26 00:56:59 PDT 2012
On 26/07/12 00:46, Walter Bright wrote:
> 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.
But doing that screws up the CPU"s stack prediction so badly that it
will dominate the timing
At least do something like:
jump_table:
move EAX, [ESP]
ret
More information about the Digitalmars-d
mailing list