Thread overview
Null check optimization
Dec 04, 2015
deadalnix
Dec 13, 2015
Jakob Bornecrantz
Dec 13, 2015
David Nadlinger
December 04, 2015
Hi all,

I was at the LLVM meetup yesterday and talked with a contributor that use LLVM to run java code. One on the very interesting that came up is a way to use segfault in order to do null cheks. It is explained here:

http://llvm.org/docs/FaultMaps.html#make-implicit-metadata

I know that ldc generate null checks when calling various functions. It may be a good idea, considering this is unexpected, ot use the same mechanism in LDC.
December 13, 2015
On Friday, 4 December 2015 at 23:33:01 UTC, deadalnix wrote:
> Hi all,
>
> I was at the LLVM meetup yesterday and talked with a contributor that use LLVM to run java code. One on the very interesting that came up is a way to use segfault in order to do null cheks. It is explained here:
>
> http://llvm.org/docs/FaultMaps.html#make-implicit-metadata
>
> I know that ldc generate null checks when calling various functions. It may be a good idea, considering this is unexpected, ot use the same mechanism in LDC.

Very intreresting, once support has been added to the druntime
other backends should be able to do the same optimization.

Cheers, Jakob.
December 13, 2015
On 5 Dec 2015, at 0:33, deadalnix via digitalmars-d-ldc wrote:
> I was at the LLVM meetup yesterday and talked with a contributor that use LLVM to run java code. One on the very interesting that came up is a way to use segfault in order to do null cheks. It is explained here:
>
> http://llvm.org/docs/FaultMaps.html#make-implicit-metadata
>
> I know that ldc generate null checks when calling various functions. It may be a good idea, considering this is unexpected, ot use the same mechanism in LDC.

It's certainly an interesting approach. I supposed we would need to look into which checks actually make it to the hot patch of optimized builds, though, as the comparatively small performance gain probably wouldn't be worth it in debug builds.

 — David