This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: C++ and Java CNI: Check Java references


Mark Mitchell writes:
 >   
 >   JavaPointer<Foo> f;
 > 
 >   f->bar();
 > 
 > You don't need to check `this' in `Foo::bar'; you'll have checked at
 > the call-site.

Okay, I guess that's true as long as we enforce this same rule in the
Java compiler: that is, whenever we call a method, even if that method
can be resolved without going via a vtable, we check that the object
is non-NULL.  Problem solved.

 > I think this shows that there will be a huge efficiency win over the
 > patch as posted: you'll not check all the references through `this'
 > because `this' is always known to be non-NULL.

Hmm.  I'm skeptical about huge: even though the initial tree code
contains checks for `this' every an instance variable is accessed, the
optimizer should be able to determine that it is non-NULL after the
start.  I've had a look at the code for a few examples and I haven't
seen any spurious multiple checks.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]