1. A machine-readable non-transitory storage medium having instructions therein, which when executed by a machine, cause the machine to perform a method, the method comprising: executing a code compiled from a source code, the source code including an access of an untyped variable, the compiled code being speculatively optimized according to a type prediction for runtime values of the untyped variable, wherein the type prediction corresponds to a collection of possible types for the untyped variable; collecting a subset of the runtime values into a profile database during the execution; tracking failures of the type prediction during the execution, wherein each tracked failure is associated with an identified type of one of the runtime values, wherein the identified type is outside of the type prediction, and wherein the tracked failures are collected into a profile database; analyzing information stored in the profile database including the collected runtime values and the tracked failures to update a statistics of types of the runtime values, the statistics indicating a certain type of the runtime values causing the tracked failures; determining a failure rate for the type prediction based on the profile database and a runtime status; adjusting the type prediction according to the statistics for future runtime values of the untyped variable, wherein the adjusted type prediction corresponds to a separate collection of possible types for the untyped variable, and wherein adjusting the type prediction further comprises recompiling a recompiled code from the source code if the failure rate exceeds a failure threshold; and executing the recompiled code of the source code to optimize the access to the untyped variable for the future runtime values according to the adjusted type prediction.