linux-mips
[Top] [All Lists]

Re: [RFC] MIPS division by zero and libgcj...

To: David Daney <ddaney@avtrex.com>
Subject: Re: [RFC] MIPS division by zero and libgcj...
From: Andrew Haley <aph@redhat.com>
Date: Thu, 10 Jun 2004 20:58:00 +0100
Cc: gcc@gcc.gnu.org, linux-mips@linux-mips.org, java@gcc.gnu.org
In-reply-to: <40C8BAF0.9070007@avtrex.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <40C8B29B.3090501@avtrex.com> <16584.46883.332620.513805@cuddles.cambridge.redhat.com> <40C8BAF0.9070007@avtrex.com>
Sender: linux-mips-bounce@linux-mips.org
David Daney writes:
 > Andrew Haley wrote:
 > 
 > MIPS div instructions never trap.  However I think that GCC always emits 
 > things like this when it cannot determine that the divisor is non zero:
 > 
 >         div     $0,$17,$16
 >         bne     $16,$0,1f
 >         nop
 >         break   7
 > 1:
 >  
 > 

 > >No, there's no reason not to do it.  You'll have to write some hairy
 > >code to satisfy all the rules, though.
 > >
 > What are the rules?  Are they more complicated then throw an 
 > ArithmeticException when the divisor is zero?

Yes.  You also have to do

  if (dividend == (jint) 0x80000000L && divisor == -1)
    return dividend;
  
and not throw an exception.

 > > > Q3: Will using SIGTRAP in this manner make debugging programs that 
 > > > divide things by zero very difficult to debug under gdb?
 > >
 > >No.
 > >  
 > >
 > I have not tried it.  But I think gdb uses "break" and SIGTRAP for 
 > breakpoints.  Is it possible to get gdb to pass the signal to the 
 > debugee, so that it could be handled by the runtime support?

Well, gcj will generate either break or trap instructions.  You can
tell gdb to ignore either.

Andrew.



<Prev in Thread] Current Thread [Next in Thread>