This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ and Java CNI: Check Java references
>>>>> "Andrew" == Andrew Haley <aph@cambridge.redhat.com> writes:
Andrew> Anyway, it's just dawned on me that this solution could
Andrew> never work: the `this' pointer in C++ isn't a smart
That's because `this' should never be NULL. (Really `this' should
have reference type, not pointer type, but nobody realized this until
too late in the game.)
You'll have already checked for the non-NULLness of `this' before
calling the member function. For example, if you have:
JavaPointer<Foo> f;
f->bar();
You don't need to check `this' in `Foo::bar'; you'll have checked at
the call-site.
If you didn't get to Foo::bar via a pointer, like this:
Foo f;
f.bar();
then there's no point in checking the `this' pointer in that case
either; you called it directly on an object.
So, you magically do the right thing.
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.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com