1. A method of executing an application and associated application code on a virtual machine, including: receiving at a processor an indication of a synchronized block indicating that a block of the application code should be atomically executed such that intermediate states that represent partial execution of the block of application code by a thread are not observable by other threads; determining whether to speculatively execute the block of application code based at least in part on whether a lock associated with the block of application code has been previously contended, wherein the determination comprises: in the event that the lock has not been previously contended: executing the block of application code without speculation; and in the event that the lock has been previously contended: determining whether to speculatively execute the block of application code based at least in part on dynamic information associated with an object associated with a synchronized block; and executing the block of application code speculatively; and attempting to execute the block of application code again upon failure of speculation; wherein: the application code does not indicate that the block of application code should be speculatively executed; and the lock associated with the block of application code having been previously contended includes at least one attempt to acquire the lock during previous executions of the block of application code by a previous thread.