www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Null check optimization

reply deadalnix <deadalnix gmail.com> writes:
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.
Dec 04 2015
next sibling parent Jakob Bornecrantz <wallbraker gmail.com> writes:
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.
Dec 13 2015
prev sibling parent David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
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
Dec 13 2015