COMPILER OPTIMIZATION OF COROUTINES
First Claim
1. A method for implementing a resumable function, comprising:
- a compiler determining at compile time whether the resumable function has a lifespan that will not extend beyond a call to the resumable function made by a caller in a computing system;
when the compiler determines that the resumable function lifespan will not extend beyond the call, the compiler generating code which upon execution will allocate an activation frame of the resumable function from a local stack memory of the caller in the computing system; and
when the compiler determines that the resumable function lifespan can extend beyond the call, the compiler generating code which upon execution will allocate the activation frame from a heap memory in the computing system.
1 Assignment
0 Petitions
Accused Products
Abstract
As a memory usage optimization, a compiler identifies coroutines whose activation frames can be allocated on a caller'"'"'s stack instead of allocating the frame on the heap. For example, when the compiler determines that a coroutine C'"'"'s life cannot extend beyond the life of the routine R that first calls the coroutine C, the compiler generates code to allocate the activation frame for C on the stack of R, instead of generating code to allocate C'"'"'s frame from heap memory. In some cases, as another optimization, code for coroutine C is also inlined with code for the routine R that calls C. Coroutine activation frame content variations and layout variations are also described.
-
Citations
20 Claims
-
1. A method for implementing a resumable function, comprising:
-
a compiler determining at compile time whether the resumable function has a lifespan that will not extend beyond a call to the resumable function made by a caller in a computing system; when the compiler determines that the resumable function lifespan will not extend beyond the call, the compiler generating code which upon execution will allocate an activation frame of the resumable function from a local stack memory of the caller in the computing system; and when the compiler determines that the resumable function lifespan can extend beyond the call, the compiler generating code which upon execution will allocate the activation frame from a heap memory in the computing system. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9)
-
-
10. A computer-readable storage medium configured with data and with instructions that upon execution by at least one processor in a compilation computing system will cause the at least one processor to perform a technical process for coroutine compilation, the process comprising:
-
determining at compile time whether a coroutine has a lifespan that will not extend beyond a call to the coroutine that will be made by a caller in a target computing system; when the coroutine lifespan will not extend beyond the call, generating code which upon execution by a processor in the target computing system allocates an activation frame of the coroutine from a local stack memory of the caller in the target computing system; when the coroutine lifespan can extend beyond the call, generating code which upon execution in the target computing system allocates the activation frame from a heap memory in the target computing system; and generating code which upon execution in the target computing system places a resumption address in the activation frame, the resumption address being the address of a resumable portion of the coroutine. - View Dependent Claims (11, 12, 13)
-
-
14. A computer system comprising:
-
a compilation processor; a memory in operable communication with the compilation processor; program source code residing in the memory, the program source code including a call to a coroutine by a caller; a static single assignment use-definition chain residing in the memory and based on a definition of the coroutine in the program source code and also based on at least one use of the coroutine in the program source code; a compiler residing in the memory and having coroutine compilation code, the coroutine compilation code interacting with the compilation processor and memory to perform, upon execution, a process which includes (a) determining with an analysis of the static single assignment use-definition chain whether the coroutine has a lifespan that will not extend beyond the call when the call is executed by a target processor, (b) when the coroutine lifespan will not extend beyond the call, the compilation processor generating code which upon execution by the target processor allocates an activation frame of the coroutine from a local stack memory of the caller, and (c) when the coroutine lifespan can extend beyond the call, the compilation processor generating code which upon execution by the target processor allocates the activation frame from a heap memory. - View Dependent Claims (15, 16, 17, 18, 19, 20)
-
Specification