LLVM Garbage Collector support #298
Replies: 4 comments 6 replies
-
Here I have attached the stack map with a brief explanation of each filed. __LLVM_StackMaps: .byte 3 ; LLVM stackmap version 3 .byte 0 .short 0 .long 2 ; number of functions where GC is enables ---- (A) .long 0 .long 2 ; total number of method calls that have statepoints .quad bar ; 1st function address in (A) .quad 24 ; stack size of the function .quad 1 ; number of function calls that have statepoints .quad main ; 2nd function address in (A) .quad 24 ; stack size of the function .quad 1 ; number of function calls that have statepoints .quad 2882400000 .long .Ltmp0-bar .short 0 .short 3 ; num of locations (live heap references) .byte 4 ; location of 1st live reference (Register | Direct | Indirect | Constant | ConstantIndex) .byte 0 ; location size .short 8 .short 0 .short 0 .long 0 ; offset .byte 4 .byte 0 .short 8 .short 0 .short 0 .long 0 .byte 4 .byte 0 .short 8 .short 0 .short 0 .long 0 .p2align 3 .short 0 .short 0 .p2align 3 .quad 2882400000 .long .Ltmp1-main .short 0 .short 3 .byte 4 .byte 0 .short 8 .short 0 .short 0 .long 0 .byte 4 .byte 0 .short 8 .short 0 .short 0 .long 0 .byte 4 .byte 0 .short 8 .short 0 .short 0 .long 0 .p2align 3 .short 0 .short 0 .p2align 3 |
Beta Was this translation helpful? Give feedback.
-
Hi All, please follow that https://github.com/KavinduZoysa/test-GCs/tree/master/statepoints. It contains the instructions to read the LLVM StackMap |
Beta Was this translation helpful? Give feedback.
-
Please consider this diagram. It shows the generated stack for https://github.com/KavinduZoysa/test-GCs/blob/master/statepoints/main.c when it calls from main() to bar(). Assume we are going to read the LLVM stack map, after bar() calls foo() and foo() returns. We have heap references in both main()(h1) and bar()(h2). By reading the LLVM stackmap, we can get those locations with respect to rsp. At this moment we can get the h2 without any issue because we know the rsp of the stack(red arrow in diagram). But for h1, rsp should be taken with respect to main() function's stackframe. So my suggestion to get the h1 is, h1 = rsp + size of the stackframe of bar() + 16 Please add your suggestions on this. |
Beta Was this translation helpful? Give feedback.
-
This commit https://github.com/KavinduZoysa/test-GCs/tree/2a92abbe5f2e116427c5cce4834f6ef633627a0a/statepoints contains the test code to read heap references programmatically. |
Beta Was this translation helpful? Give feedback.
-
This discussion was initiated to evaluate the LLVM support for garbage collectors.
LLVM does not provide garbage collectors, instead, it provides a framework that helps users to implement GCs. That framework provides the requirements for the GC. Before we discuss more about it, we have to figure out couple of terms.
At the initial phase what I have done is add the safepoints for a given LLVM IR and generate the stack map. Please follow https://github.com/KavinduZoysa/test-GCs/tree/master/statepoints for source codes.
A C code is written in order to generate the LLVM IR and the basic structure is that main function calls bar, bar calls foo(main -> bar -> foo). Then GC is enabled to main and bar. Now the llvm automatically identified where to put safe points. In this case, those are method calls.
Based on this IR we can generate stack map at safepoints and it is visible in assembly code.
Beta Was this translation helpful? Give feedback.
All reactions