Notes from Google IO 2012 http://www.youtube.com/watch?v=UJPdhx5zTaw
- Hidden Classes created at Runtime AS THE CODE EXECUTES
- Get your objects to use the same hidden class
- Get to know your tools d8 and its options
- Initialise all object members in constructors
- Always initialise members in the same order
- Don't use dynamic property allocation - new hidden class generated
- Numbers larger then 31-bit have to be boxed and unboxed
Always try to convey to the compiler that you want to use Fast Element instead of Dictionaries
- Use contiguous keys and start at 0 or you will be allocated a
- Don't allocate large arrays if you don't need it as if you only partially populate it will be a dictionary
- Don't delete keys in an array as this causes conversion to Dictionary
- Don't read from an uninitialised arrays
- Keep the same types in the array
- Executes code ASAP with no types but creates Inline Cache
- Always pass consistent types (monomorphic over polymorphic) otherwise Inline-Cache is invalidated
- Recompiles hot functions with optimised code using Inlining
- try{} catch(){} cannot be optimised move the function outside try catch