summaryrefslogtreecommitdiff
path: root/src/inc/cfi.h
AgeCommit message (Collapse)AuthorFilesLines
2016-01-28Support for CFI unwind infoKyungwoo Lee1-0/+33
For Unix targeting CoreRT, this will provide platform specific unwind info which is a dwarf format. Unlike window’s UNWIND_INFO, we won’t encode the format within RyuJit since it is not only complex/error-prone but also needs to be adjusted depending on platforms. Instead, CFI (call frame information) pseudo instructions are encoded, which will be passed to CoreRT/ObjectWriter which will translate them to directly emit CFI directives to LLVM MC stream to establish frames and layout eh_frame section. A jit flag is used to dynamically dispatch either Windows’s unwind blob or this CFI instruction table. No JIT/EE interface change is needed since the API already expects an opaque blob. Initially when I looked at what Clang does, the prologue and the sequence of CFI emissions are a bit different than Windows. Since we will emit the same sequence of code with the same runtime that we define, I assume this is unnecessary – I’ve verified the CFI sequence here can work correctly with libunwind. Basically we need only 3 operations – push reg is a combination of 1 and 2 below. 1. Allocation – increase stack frame. Normally subtract esp in x64. 2. Store – Copy a (callee save) register to stack (memory) 3. SaveFP – Set frame pointer register Since Windows operation is based on the relative value (all offsets, etc are computed from the current point), I also use the similar form of CFI instructions. So, mostly one window’s code corresponds to two CFIs – we might optimize this by aggregating allocation, but I’d like to keep the current syntax/semantic same as Windows. This results in a very simple transformation on par with Windows.