Continuing the series, today we’ll dive into local functions, fixed
-size buffers, fixed
blocks on arbitrary types with GetPinnableReference
, and stackalloc
initializers to see how they’re all implemented in C++ and what assembly code ends up actually running on the CPU.
Posts Tagged stackalloc
C# has some powerful features like fixed
-size buffers, pointers, and unmanaged local variable arrays courtesy of stackalloc
. These are deemed “unsafe” since they all deal with unmanaged memory. We should know what we’re ultimately instructing the CPU to execute when we use these features, so today we’ll take a look at the C++ output from IL2CPP and the assembly output from the C++ compiler to find out just that.
The series is nearing an end! In today’s article we’ll cover so-called “unsafe” code that gives you unprecedented access to system memory. You can use this to optimize your app or integrate with native (e.g. C, C++) code and APIs. Read on to learn more about this powerful C# tool!