Emitted Nullpointer-checks on field-access: Why?


I wanted to ask why we emit nullpointer-checks for access to Ref-fields / Elements of pointer-arrays.

An alternative approach would be to handle the segfault (nullpointer-deref) using something like http://www.gnu.org/software/libsigsegv/. An extremely naive implementation would emit the “raise exception” code into a different blob, and upon receiving a segfault look up the address of the offending instruction, restore registers and jump to the blob.

Effect: All this rarely-executed exception-handling code stops slowing down non-segfaulting code. Also “catch segfault” looks sexy :slight_smile:

Was this discussed before (where)?

Am I stupid and this is impossible for really obvious reasons?

Are there architectures / OS we want to run on that don’t support this?

Is this difficult for some subtle reason?

Or is this something that should be done in the future, but no one tried to do it so far?

(in case that this question turns out to be really stupid, I apologize; this was triggered by the discussion in https://discourse.julialang.org/t/immutables-with-reference-fields-why-boxed/7706/17)

PS for posterity: @yuyichao replied on the other thread. So this one might as well get closed? (old working code exists; needs non-ancient llvm version; integrating it appears to be non-priority, so it’s WIP in limbo).