1. A method for optimizing code by progressively performing a plurality of speculations corresponding to object accesses, the method comprising: receiving, by a compiler and from an interpreter, a code section representation comprising an object allocation for creating a non-compact allocated object; performing a first speculation relating to a first level of access required for the non-compact allocated object; compiling, by the compiler and based on the first speculation, the code section representation into a first machine code comprising a first compact allocated object of the object allocation, wherein the first compact allocated object occupies less space in memory than the non-compact allocated object; encountering, during execution of the first machine code, an attempted access of the first compact allocated object that is beyond the first level of access; triggering a deoptimization in response to the attempted access of the first compact allocated object; returning, based on the deoptimization, from execution of the first machine code to execution of the code section representation by the interpreter; performing, by the interpreter responsive to the triggered deoptimization, a second speculation relating to a second level of access required for the non-compact allocated object; setting, by the interpreter, within the code section representation and based on the second speculation, a flag at a location of the attempted access, wherein the flag indicates that a second compact allocated object is required and wherein the second compact allocated object occupies more space in memory than the first compact allocated object; receiving, by the compiler and from the interpreter, the code section representation comprising the flag; compiling, by the compiler and according to the flag, the code section representation into a second machine code comprising the second compact allocated object; and executing the second machine code with the second compact allocated object, wherein execution of the second machine code corresponds to the second speculation.