1. A method for executing code, comprising: detecting an event in an emulated environment having a current state; generating first code block identification information for code associated with the event, the first code block identification information is based on one or more guest virtual memory addresses; determining that compiled code associated with the event is not stored in a code cache; determining that compiled code that is associated with the event and that corresponds to a previous state of the emulated environment that matches the current state is stored in a secondary storage, wherein said step of determining includes matching the first code block identification information with an entry in table that stores code block identification information associated with previously compiled code that is stored on the secondary storage; accessing said compiled code from said secondary storage based on said entry; and executing the accessed compiled code.