dinfuehr / dora

Dora VM
MIT License
490 stars 31 forks source link

How lazy compilation is protected in case of multiple threads? #304

Closed playXE closed 1 year ago

playXE commented 1 year ago

Hello! I am making an JITed runtime for Scheme and I was looking at your code to see how lazy compilation is implemented (although I use very different backend b3). I do not seem to find how synchronization is implemented. Runtime does not care if function was compiled multiple times?

dinfuehr commented 1 year ago

See compilation.rs which lets a second thread block until compilation of the same method/function is finished. And lazy_compilation_stub.rs is used to invoke the compiler for uncompiled methods and it also patches call-sites to directly invoke the compiled method when it gets re-executed later. Hope that helps!