Can't seem to find a good answer for these questions.
Here are what I think I know and what I'm fuzzy on.
- An Evaluation Stack is a memory buffer like a C style stack (is it a stack of native int / size_t)?
- Evaluation Stack elements can be either 32 or 64 bits (how are these mixed in a single stack?)
- Ldloc_0 stores the local variable on the evaluation stack BUT how if its larger than 64bits?
- Does Ldloc_0 just store ptrs to local variables on the evaluation stack?
- Are objects stored on the evaluation stack always either pointers or primitive values?
- If .maxsize is 8 does that mean (8 * size_t)? If so how if I read docs stating its either 32 or 64bit
Take the example below. Does this local variable get stored on the evaluation stack by a ptr reference?
public struct MyStruct
{
public long x, y, z;
public static MyStruct Foo()
{
MyStruct c;
c.x = 1;
c.y = 2;
c.z = 3;
return c;
}
}
"ldloc.0" clearly stored the struct onto the evaluation stack BUT its also much larger than 64bits. Is the reference stored instead?
.class public sequential ansi sealed beforefieldinit MyStruct
extends [mscorlib]System.ValueType
{
// Fields
.field public int64 x
.field public int64 y
.field public int64 z
// Methods
.method public hidebysig static
valuetype MyStruct Foo () cil managed
{
// Method begins at RVA 0x2050
// Code size 34 (0x22)
.maxstack 2
.locals init (
[0] valuetype MyStruct,
[1] valuetype MyStruct
)
IL_0000: nop
IL_0001: ldloca.s 0
IL_0003: ldc.i4.1
IL_0004: conv.i8
IL_0005: stfld int64 MyStruct::x
IL_000a: ldloca.s 0
IL_000c: ldc.i4.2
IL_000d: conv.i8
IL_000e: stfld int64 MyStruct::y
IL_0013: ldloca.s 0
IL_0015: ldc.i4.3
IL_0016: conv.i8
IL_0017: stfld int64 MyStruct::z
IL_001c: ldloc.0// What is actually stored here?
IL_001d: stloc.1
IL_001e: br.s IL_0020
IL_0020: ldloc.1
IL_0021: ret
} // end of method MyStruct::Foo
} // end of class MyStruct