1. A method for utilizing a hardware performance monitor for improving performance of an application comprising a plurality of instructions while the application is executing on a hardware, the method comprising the steps of: (a) creating a machine internal representation (MIR) for the plurality of instructions or a subset thereof for the hardware and generating an executable (EXE) from the MIR for execution on the hardware; (b) determining hardware performance monitor (HPM) information for an event associated with a resource of the hardware during execution of the EXE to identify one or more instructions of the application that affect the execution of the application on the hardware; (c) re-computing the MIR according to the HPM information; and (d) re-generating the EXE from the re-computed MIR for execution on the hardware if the MIR and the re-computed MIR are different, thereby improving utilization of the resource by the application.