主权项 |
1. A method for processing software code, comprising:
while analyzing a high-level code, determining programmatically that:
variables of a first function are required to be available for use by a second function subsequent to a return of the first function, andvariables of a third function are not required to be available for use by the second function subsequent to a return of the third function,wherein the determining comprises identifying that the second function continues to reference the variables of the first function, but not the variables of the third function, subsequent to the return of the first function; and when compiling the high-level code into machine code:
generating automatically for the first function a first segment of machine code that, when executed, is configured to:
copy values of the variables of the first function from a storage location in a stack memory to temporary objects stored in a heap memory prior to the values of the variables of the first function being removed from the stack memory in response to the return of the first function, wherein:
during execution of the first function, the temporary objects store pointers to the storage location in the stack memory, and,subsequent to the return of the first function, and during execution of the second function, the temporary objects store the copied values instead of the pointers; andgenerating automatically for the third function a second segment of machine code that, when executed, is configured to cause values of the variables of the third function to be removed from the stack memory when the third function returns. |