1. A method of dynamically optimizing code, comprising: simultaneously optimizing and executing application code on a machine, the optimizing comprising: determining if a portion of the application code has a shared variable and a loop, the shared variable being a variable that, upon execution of the portion, is accessed by two or more threads, processes or processors; responsive to determining the portion does not have the shared variable and the loop, selecting the portion of the application code; determining whether to apply one or more optimizations to the portion, the determining based, at least in part, on whether an execution performance of the portion benefits from the one or more optimizations, wherein the one or more of a group of optimizations is selected from a group consisting of reordering load instructions within the portion, removing dead code within the portion, and reordering a load instruction in a location where it precedes a store instruction of the portion to a location in the code portion where it is subsequent to the store instruction; and responsive to determining to apply the one or more optimizations to the portion, converting the portion to a transaction and applying the of one or more optimizations to the portion, the transaction having a property, that when the transaction is executed, the transaction is either atomically committed or atomically aborted.