www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - GNU-C features for Mercury language compiler

Quoted from the paper "The execution algorithm of Mercury, an 
efficient purely declarative logic programming language", by 
Zoltan Somogyi, Fergus Henderson and Thomas Conway:

<<
The tables show that Mercury benefits significantly from its use 
of the GNU C extensions. The most important extension is the use 
of global register variables to keep the most important abstract 
machine registers in the registers of the physical machine. The 
payoff from this is large in program size as well as execution 
time because the alternative is accessing memory, or at least the 
cache, on every reference to a virtual machine register, and 
these occur on almost every line of code. Without gcc's nonlocal 
gotos, each transfer of control costs two jump instructions (to 
the driver and to the destination) plus possibly one more back to 
the start of the unrolled loop of the driver. This cost is 
incurred even when falling through a label.

With gcc's nonlocal gotos, the costs are one jump instruction and 
zero instructions respectively. For jumps within a single C 
function, these jumps are always simple direct jumps. When not 
using assembler labels, jumps between different C functions are 
indirect jumps in which the address to jump to is fetched from a 
variable in memory (see section 3.1). The use of assembler labels 
improves performance by turning jumps between C functions into 
direct jumps as well, but a more important benefit is that it 
avoids long startup times. (Without assembler labels, every 
module of the program must be paged in at startup to initialize 
the variables used by indirect jumps.)

Bye, bearophile
Dec 19 2013