1. A method for optimizing code, comprising: receiving, by a compiler and from an interpreter, a code section representation comprising an object allocation; compiling, by the compiler, the code section representation into a first machine code comprising a first compact allocated object of the object allocation; triggering a deoptimization in response to an attempted access of the first compact allocated object, wherein the deoptimization returns execution to the interpreter; setting, within the code section representation, a flag at a location of the attempted access, wherein the flag indicates that a second compact allocated object is required; receiving, by the compiler, 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.