User:Pedro Oval/Mono code memory usage/CIL

From Second Life Wiki
< User:Pedro Oval‎ | Mono code memory usage
Revision as of 14:35, 30 May 2014 by Pedro Oval (talk | contribs) (Created page. More additions coming.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here's the CIL code generated by certain code snippets, which gives some insight of what's happening under the hood. Conventions: x and y are local integer variables; f and g are local floats; v is a local vector; a is a local list.

LSL return;
CIL
2A                            ret
LSL x; or (x) or (integer)x
CIL
11 00                         ldloc.s 0
26                            pop
Note: ldloc.s 0 is probably contracted to ldloc.0 (opcode 06) at assembly time, resulting in a length of 2. Or possibly the server-side compiler added an optimization of this (!). This is confirmed by the fact that x; takes 2 bytes if it's one of the first four variables (there are 1-byte opcodes for ldloc.0 through ldloc.3), and 3 bytes otherwise. This caveat applies to most appearances of this opcode.
LSL (float)x;
CIL
11 00                         ldloc.s 0
6C                            conv.r8
26                            pop