Eliminating locks on objects that our Containment Analysis has identified to be local as long we stay in the trace is simple. Each trace in the tree is just a linear sequence of instructions, and we can use a slightly beefed up Common Subexpression Elimination pass to eliminate redundant lock/unlock pairs. For side exits we have to keep track whether at the side exit point the object is locked or unlocked. If its locked, the lock has to be taken in the side exit path.
As long we stay in the tree, no locks will ever be needed, only side exits might require to lock the object, because it might “go global” behind the side exits, and the interpreted code might rely on the object be already locked (if the code in the loop was supposed to do that before we eliminated the lock path).