Symbol tables (and symbols themselves) are mutable in Nashorn at the moment. They're the last mutable piece of AST. We should make them immutable; this would allow moving SYMBOL_ASSIGNMENT_PHASE and compilation phases into COMPILE_UPTO_SERIALIZABLE phase group, before SERIALIZE_SPLIT_PHASE. That in turn would allow us to keep ASTs weakly reachable and reuse them in optimistic recompilations as only OPTIMISTIC_TYPE_ASSIGNMENT_PHASE and LOCAL_VARIABLE_TYPE_CALCULATION_PHASE would need to be re-run. That could cut down on compilation cost significantly as we would need to reparse much less frequently while doing deoptimizing recompilation.