From a C++/JS benchmark

Don nospam at nospam.com
Fri Aug 5 00:23:53 PDT 2011


Adam Ruppe wrote:
>> But what's the purpose of those callq? They seem to call the
>> successive asm instruct
> 
> I find AT&T syntax to be almost impossible to read, but it looks
> like they are comparing the instruction pointer for some reason.
> 
> call works by pushing the instruction pointer on the stack, then
> jumping to the new address. By calling the next thing, you can
> then pop the instruction pointer off the stack and continue on where
> you left off.

They do that to implement Position Independent Code: you need to know 
the instruction pointer, to be able to access your data. Actually it has 
a terrible effect on performance, because it destroys the processor's 
return prediction mechanism (it guarantees multiple mispredictions). But 
it seems to be unavoidable -- I don't think it's possible to generate 
decent code for PIC on x86-32. But there should never be more than one 
call in a function.

> I don't know why they want this though. That AT&T syntax really
> messes with my brain...


More information about the Digitalmars-d mailing list