https://kotlinlang.org logo
k

Kroppeb

07/16/2023, 8:33 PM
Hi, is there somewhere some documentation on how suspend functions are compiled down to bytecode? Looking at the decompiled code and relying on my experience with such concepts, I feel like I mostly understand it, but I'd still like to cover all the bases.
Context, I want to make Vineflower (used to be called Quiltflower, a fork of Fernflower) be able to decompile the suspend functions properly.
k

Kroppeb

07/17/2023, 4:47 PM
tysm
l

Liam

07/18/2023, 1:01 PM
I crated this gist once when I was trying to understand how coroutines are compiled myself, perhaps it helps you 🙂 https://gist.github.com/fxshlein/49704a5999fef8721a454bb5255b28ea I cleaned up coroutines code I decompiled using the decompiler in IntelliJ (so also Fernflower), and turned it into standalone java code that actually works, and can be pasted into a scratch file in IntelliJ, and you can run/debug it. Its mostly uncommented, and I don't know how accurate it is these days, but perhaps it might still be useful
5 Views