>>>>> "David" == David Daney <[EMAIL PROTECTED]> writes:
David> The Java Language Specification requires that NullPointerExceptions David> are thrown when calling a method via a null 'this'. But since a David> method call does not usually involve dereferencing 'this', an explicit David> check for null must be made when it cannot be proven that 'this' is David> not null. Note that on ports where we rely on SEGV generation on a null pointer dereference, we actually only emit these explicit checks for calls to final methods (and methods in final classes). That's because plain old virtual calls do require a dereference. (This is all detailed at length in the PR for this issue..) David> Which leads me to the (unrelated) thought that inserting an David> instruction that dereferences the pointer may be more efficient (from David> a code size point of view) than an explicit check for null and then David> branching around the code that creates and throws the exception. I remember writing a patch that did this, a long time ago. But I don't recall why we didn't do it. Note that the branch in this question should always be marked 'unlikely' by GCC, as it is a branch to an exception handler. And, we ordinarily must load the value anyway since we're going to pass it as 'this' to the method call... so perhaps the cost is low. On MMU-less ports the situation is different. There, we emit a lot of null pointer checks. Tom