Patent ID: 7873952

Claim:
A method for transforming code comprising: identifying, utilizing at least one processing unit, at least one portion of a code that implements constant loading by analyzing information from control flow analysis, data flow analysis, and binary representation and configuration analysis of the code, the code comprising a binary file stored in a machine-readable media, wherein said identifying further comprises analyzing the information from the binary representation and configuration analysis of the code to identify that the at least one portion of the code accesses read-only areas of an address space of the code; comparing, utilizing the at least one processing unit, a reduction in reduced execution time from converting at least one of a memory access operation of the at least one portion of the code that loads a constant from memory to one or more operations that directly set the constant or a memory access operation of the at least one portion of the code that loads an address of the constant from the memory to one or more operations that directly set the address of the constant to an increase in execution time from the converting; eliminating one or more operations that compute an address representation for at least one of the memory access operation that loads the constant from the memory or the memory access operation that loads the address of the constant from the memory, wherein the comparing is based, at least in part, on at least one of an execution frequency of the memory access operation that loads the constant from the memory, an execution frequency of the memory access operation that loads the address of the constant from the memory, the constant and number of operations to set the constant, capability to propagate the constant, an execution frequency of the one or more operations that compute the address representation, and proportion of the address representation computing operations that can be eliminated; and if the reduction exceeds the increase, converting, utilizing the at least one processing unit, the at least one of the memory access operation that loads the constant from the memory to the one or more operations that directly set the constant or the memory access operation that loads the address of the constant from memory to the one or more operations that directly set the address of the constant and directly setting the address of the constant avoids latency incurring access of the memory, wherein converting further comprises converting the memory access operation to one or more register operations and propagating the constant to at least one other portion of the code.