摘要 |
A system, method, and computer program product for optimizing thread stack memory allocation is disclosed. The method includes the steps of receiving source code for a program, translating the source code into an intermediate representation, analyzing the intermediate representation to identify at least two objects that could use a first allocated memory space in a thread stack memory, and modifying the intermediate representation by replacing references to a first object of the at least two objects with a reference to a second object of the at least two objects. |
主权项 |
1. A method comprising:
receiving, at a processing unit, source code for a program; translating, by the processing unit, the source code into an intermediate representation (IR); analyzing, by the processing unit, the IR to identify at least two objects that could use a first allocated memory space in a thread stack memory, wherein the at least two objects comprise data structures of a plurality of sizes; and modifying, by the processing unit, the IR by replacing references to a first object of the at least two objects with a reference to a second object of the at least two objects, wherein the first object is smaller than the second object, wherein analyzing the IR comprises:
identifying a plurality of stack allocated objects in the IR,for each stack allocated object in the plurality of stack allocated objects, identifying all variables that have access to the stack allocated object,determining which stack allocated objects are live at the same point in the IR, anddetermining which stack allocated objects can be allocated to the first allocated memory space. |