I do not have authoritative information and I think it largely depends on the specific implementation that can change as needed.
In C # and VB.NET it's more or less easy the actual code that runs is generated at run time through JITter , so there is already a build in execution even when you will not use Edit and Continue
. Of course it's a more limited build, it just takes a bytecode and generates executable code. JITter can compile only what matters, it can even recompile something if it feels it is needed (as far as I know .NET does not do this, but could as optimize during execution when it identifies a hot path ) .
I believe that bytecode recompilation occurs only in the modified method, but this depends on the implementation.
Source recompilation in bytecode could occur only in this method, but you have a chance to be at least in the whole file of it to see if everything is right there in that source. The .NET Compiler Platform is designed to be able to compile only parts of a code, even a smaller part than a method , although this will be useful in very specific circumstances.
There is probably metadata insertion and even dead instructions ( nop
) in generating the code to facilitate recompilation .
Once the recompilation is done, JITter will use some strategy to replace the code, or putting it in the same memory area (perhaps even making a detour), most likely, or updating the references contained in every application for the method at the new address.
As you have already noted, it is only possible to change imperative code (with limitations), you can not change the data structures. But you can create new ones.
In C ++ a larger infrastructure is needed because it does not have a JITter. which means that you have to put a JITter in the application.