This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Non-call exceptions versus cse
Geert Bosch writes:
>
> On Tuesday, Nov 19, 2002, at 11:21 America/New_York, Andrew Haley wrote:
> > As far as I can see it's never correct to CSE two instructions if the
> > first one may trap.
>
> This will severely harm performance with non-call exceptions.
> For languages such as Ada that need non-call exceptions to work for
> implementing language-defined checks, and allow such exceptions
> to be raised at an arbitrary point in a function, it should be
> possible to retain the current behavior.
The languge is quite difficult to follow, but I take it that, in the
case of Ada, when a memory trap occurs the target of a read may or may
not have been modified, and its contents must be regarded as
unpredictable.
To quote the Java specification:
"Each local variable (§14.4) and every blank final (§4.5.4) field
(§8.3.1.2) must have a definitely assigned value when any access of
its value occurs. A Java compiler must carry out a specific
conservative flow analysis to make sure that, for every access of a
local variable or blank final field f, f is definitely assigned before
the access; otherwise a compile-time error must occur." [1]
This has security ramifications: we must guarantee that object
references may only be obtained by code with appropriate permissions.
In this case, a register is uninitialized and therefore may contain
anything at all, including a reference to an object that untrusted
code is not permitted to access.
Andrew.
[1] http://java.sun.com/docs/books/jls/second_edition/html/defAssign.doc.html