Read more →
I propose to look at the internals that are behind the simple lines of initializing of the objects, calling methods, and passing parameters. And, of course, we will use this information in practice — we will subtract the stack of the calling method.
Before proceeding with the story, I strongly recommend you to read the first post about StructLayout
, there is an example that will be used in this article.
All code behind the high-level one is presented for the debug
mode, because it shows the conceptual basis. JIT optimization is a separate big topic that will not be covered here.
I would also like to warn that this article does not contain material that should be used in real projects.
First — theory
Any code eventually becomes a set of machine commands. Most understandable is their representation in the form of Assembly language instructions that directly correspond to one (or several) machine instructions.