1. An apparatus for optimizing code comprising: a memory to hold program code; and a processor including, hardware resources adapted to support transactional execution and to provide a representation of an availability of the hardware resources; and execution logic adapted to execute the program code to cause the processor to dynamically resize a transactional region including an optimized portion of the program code based on the representation of the availability of the hardware resources.