[Mono-devel-list] Re: proposal for a different JIT

Emanuele Ruffaldi pit at sssup.it
Fri Oct 17 05:05:23 EDT 2003

On Wed, Oct 15, 2003 at 12:49:41PM +0200, Paolo Molaro wrote:

>> Another issue may be the need to constrain the optimizations gcc
>> performs to keep the semantics of code correct: I don't know if the gcc
>> backend provides any facilities to encode such constraints. Exanples
>> are:
>> *) some operations may have side effects unknown to gcc (like the
>> raising of an exception with a division by 0)
>> *) code reordering and hoisting needs to be constrained to keep
>> the order of possibly implicit exceptions constant

I've investigated in the way the GCC manages this kind of exceptions. There 
is a global flag -ftrapv that checks the overflow of all the arithmetic operations,
it implemented using a set of functions in the libgcc. For example in the case
of a plus expression it calls the __addvsi3 that check the overflow in a portable way
(no conditional jump on x86) and then calls the abort function. 

So to generate the code for the add.ovf it's only needed to replace the add expression with 
a call to the __addvsi3. (the ftrapv flag should not be used because it has global effect)

	 (plux EXP1 EXP2) => (call __addvsi3 EXP1 EXP2)

The reference to the abort function call can be easly replaced to a custom
function that raises an exception.

> Isn't it much like in java? 

Yes the GCJ does a lot of similar work except for the check of overflows. 


More information about the Mono-devel-list mailing list