1 ==============================
2 FaultMaps and implicit checks
3 ==============================
12 Code generated by managed language runtimes tend to have checks that
13 are required for safety but never fail in practice. In such cases, it
14 is profitable to make the non-failing case cheaper even if it makes
15 the failing case significantly more expensive. This asymmetry can be
16 exploited by folding such safety checks into operations that can be
17 made to fault reliably if the check would have failed, and recovering
18 from such a fault by using a signal handler.
20 For example, Java requires null checks on objects before they are read
21 from or written to. If the object is ``null`` then a
22 ``NullPointerException`` has to be thrown, interrupting normal
23 execution. In practice, however, dereferencing a ``null`` pointer is
24 extremely rare in well-behaved Java programs, and typically the null
25 check can be folded into a nearby memory operation that operates on
26 the same memory location.
31 Information about implicit checks generated by LLVM are put in a
32 special "fault map" section. On Darwin this section is named
35 The format of this section is
40 uint8 : Fault Map Version (current version is 1)
41 uint8 : Reserved (expected to be 0)
42 uint16 : Reserved (expected to be 0)
45 FunctionInfo[NumFunctions] {
46 uint64 : FunctionAddress
47 uint32 : NumFaultingPCs
48 uint32 : Reserved (expected to be 0)
49 FunctionFaultInfo[NumFaultingPCs] {
50 uint32 : FaultKind = FaultMaps::FaultingLoad (only legal value currently)
51 uint32 : FaultingPCOffset
52 uint32 : handlerPCOffset