Null pointer checks

Godmar Back gback at
Mon Apr 19 13:19:26 PDT 1999

> I went through the kaffe's code generator and I suddenly started wondering:
> Why is the MMU used to check null pointer accesses?
> In most cases, it requires to spill the registers to memory, and then the
> penalty for the test/branch should be negliable. Or does pratice show
> otherwise?

I don't have hard data, and keep in mind that Kaffe's jit is not 
state of the art, but let me say this:

When I fixed Kaffe's jit to properly spill registers, I did some 
measurements and found that the number of spills did not increase 
significantly.   This is for two reasons: for one, Kaffe already
spills so liberally it's a pain.  But secondly and more importantly, keep 
in mind that you only need to spill register if you're in a try block to 
which a catch clause exists that catches NullPointerExceptions.  There 
is no need to spill anything if you don't have to restore them.

However, if you uses checks to detect null pointer access, you'd have
to insert them everywhere.

	- Godmar

More information about the kaffe mailing list