All Your Base Are Belong To Us

January 16, 2011

You may be asking yourself: …who cares? Well, first of all it’s good to know. I haven’t noticed a public service announcement to the above. It is an implementation detail, however—CLR assemblies are not even guaranteed to be implemented using files, not to mention DLL files in a specific format that are loaded using the LoadLibrary Win32 API. However, there are several tools and scenarios which have come to rely on the fact the CLR loads assemblies using LoadLibrary. For example, up to CLR 4, if you wanted to know which .NET assemblies were loaded in your process,...

January 13, 2011

Diagnosing memory leaks by taking multiple dumps, analyzing them with SOS commands like !DumpHeap and !GCRoot, and maybe exporting a heap graph to CLR Profiler with !TraverseHeap is a very ungrateful experience albeit one I had to go through many many times. If you’re doing postmortem diagnostics or can’t possibly afford to do live work on the problematic machine, there’s no other choice but to stick to dumps. Fortunately, in some cases you can afford to reproduce a memory leak locally and in a live scenario. In these cases, a memory profiler is an invaluable tool and can...

January 2, 2011

After having discussed in some detail the lexical analysis and parsing phases, it’s time to get our hands dirty with actual code generation. Theoretically speaking, our parser emits an intermediate representation of the parsed program—the code-generator interface, shown below, can be used to construct an actual tree depicting the structure of the program. For the practical purpose of translating a Jack program to C or assembly language, there’s no need to maintain in memory a real parse tree. By using the symbol state and a small set of auxiliary data structures, we can implement a code generator that...