The fact that safe language implementations have to think hard about how to handle null pointer exceptions safely should have been a warning sign that null pointers are a bad thing to have in a language. Sadly nearly always unheeded.
-
-
Replying to @pcwalton @RichFelker
Are NPEs harder to handle safely, compared to other exception types?
2 replies 0 retweets 0 likes -
Replying to @ridiculous_fish @RichFelker
Yes. When you dereference a pointer you have to make sure that something safe happens if that pointer is null. It’s not as simple as making sure that the zero page is unmapped and catching SIGSEGV because you might overshoot the page if it’s e.g. an array.
2 replies 0 retweets 4 likes -
Even worse, what do you do when you catch the SIGSEGV? You probably want to unwind the stack, but doing that efficiently requires that your faulting address have a landing pad. So you have to generate landing pads at every pointer load…
1 reply 0 retweets 2 likes -
I don’t think LLVM even supports generation of landing pads at anything but call instructions. So then you can’t use load instructions for pointers anymore. You will probably need to write an LLVM intrinsic that you invoke.
1 reply 0 retweets 1 like -
Even if you do that, those landing pads have a code size cost. Every pointer load has to have a nontrivial amount of metadata, in case it faults.
1 reply 0 retweets 1 like -
And even THEN, you added a whole ton of extra control flow edges, for the null-pointer-exception cases. This inhibits optimizations because it generates a whole slew of extra basic blocks. Control flow soup.
1 reply 0 retweets 1 like -
I agree with you that null pointers are bad but "it's hard to do with LLVM" is really more of an indictment of LLVM in this case. Null handling in the JVM isn't that big of a deal.
2 replies 0 retweets 1 like
Is it hard in LLVM because LLVM is bad, or because the problem is just hard? :) I think efficient null pointer handling is annoying no matter what you do.
-
-
It's extra hard to do well with AOT compilation and if you're not adding read barriers for GC anyway
0 replies 0 retweets 2 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.