slides.tex (2148B)
1 Example of a simple compiler pass for each problem, which makes that problem obvious 2 3 Big passes: 4 * null as default and absent 5 * inter-dependency between pieces of code which generate certain information 6 * list of methods for a class vs. list of classes on which a method is present 7 8 Graph manipulation: 9 * fail to update a reference to an updated element 10 * specialize a method on its receiver type: object or primitive. Update method calls, dispatch for boxed primitives, but forget to update method pointer creation 11 * update methods: indicate whether their receiver can be a primitive type. Update calls to point to the new version, but forget to update the list of methods on the class. Or more devious: update the list of methods, but forget to make the method's ``declaringClass'' field point to the updated class. 12 * or issues with identity (e.g. Mono.Cecil bug) 13 * lookup of a key which does not exist anymore, because the node was deleted in the meantime. 14 * remove methods which are dead code, but fail to delete some reference to that name in a list of method names. 15 16 Unit tests: 17 * Write a test for an instruction transformation (unary negation to binary subtraction), show that it requires a class, method, main method etc. 18 19 Graph construction: 20 * languages with mutation: 21 * purely functional language: promises have to be forced, or explicit lookups 22 * argue that purely functional languages make GC easy to design, parallelize more easily, type system easier to design and more flexible (monomorphism restriction), but lazy languages are harder to debug. 23 24 Generic graph algorithms 25 * depth-first search, aggregates information from nodes of two different types: show how you have to re-write it if your data structure changes a bit 26 * or SCC (has_cycles), where some links matter but some don't 27 28 Structural constraints 29 * compute the in-memory size of a C structure: should not have any cycles 30 * off-by-one when updating the number of references to an element 31 * PHOAS 32 33 34 35 Downsides 36 * $\alpha$-renaming: problematic, since there is no declaration / use of fields anymore. 37 => IDE solution: keep track of which pass introduces which field.