Re: Bugs at my web site
From: glen herrmannsfeldt (gah_at_ugcs.caltech.edu)
Date: 01/21/04
- Next message: Dr Ivan D. Reid: "Re: Using old Fortran code (Was "Re: Bugs at my web site")"
- Previous message: Jan C. Vorbrüggen: "Re: Bugs at my web site"
- In reply to: Dr Chaos: "Re: Bugs at my web site"
- Next in thread: Charles Russell: "Re: Bugs at my web site"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 21 Jan 2004 09:06:05 GMT
Dr Chaos wrote:
(snip about bounds checking)
> But in Java you can catch the exception caused by the
> array bounds violation---and legally continue execution.
Continue somewhere else, but you can't fixup the failed
subscript and continue. Compare/contrast with the PL/I ON unit,
where you can change variables and return to the cause of the
error.
> This means that an evil subroutine might use this intentionally, and
> in a legal program you would have to expect that all the processing
> right up to that point where the exception was thrown was done and all
> mutable data properly stored.
Yes, you could do that.
> So seeing ahead of time (before entering a loop) if
> an array bounds violation has occured and breaking if it has isn't
> good enough.
> I guess you could conceivably generate double code for every loop, but
> that seems insane.
The only question is for JIT compilers. At least for Java/JVM
the bounds checking is done at run time by the JVM, not by the
Java compiler. Compiling two loops isn't so hard in that case.
It may be able to figure out that bounds cannot be violated.
Consider a constant loop, or a loop with the limit equal to the
array size. That can be tested at JIT time, and the appropriate
code compiled.
> What if you have multiple nested loops whose inner array bounds
> are computed by some formula each time?
Then they get checked the old fashioned way.
> I think Java made a huge blunder by having the bounds
> exception be guaranteed to be catchable.
Java was not meant for number crunching, though with JIT it
is usually fast enough. The slow part of object oriented
programming is memory allocation/deallocation. Number crunching
programs don't do much of that.
> I think that as a violated precondition it is an 'a priori' error and
> shouldn't usually be catchable except in the context of a development
> environment.
The JIT compiler can also test for a try/catch block and only generate
the special two loop code in that case. Without it, bounds violation
is a fatal error. With JIT on, you don't get location information.
-- glen
- Next message: Dr Ivan D. Reid: "Re: Using old Fortran code (Was "Re: Bugs at my web site")"
- Previous message: Jan C. Vorbrüggen: "Re: Bugs at my web site"
- In reply to: Dr Chaos: "Re: Bugs at my web site"
- Next in thread: Charles Russell: "Re: Bugs at my web site"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|