IP Library › Granted Patent US 9,864,518
Granted Patent B2
US 9,864,518 · App. 14/536,902 · Granted Jan 9, 2018

Assigning home memory addresses to function call parameters

Inventors: Michael Karl Gschwind (Chappaqua, NY); Ulrich Weigand (Holzgerlingen, DE)
Assignee: International Business Machines Corporation
G06F3/0604G06F3/0644G06F3/0673G06F8/43G06F12/023G06F2212/1044G06F2212/251
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 9,864,518
App. No.
14/536,902
Granted
Jan 9, 2018
Kind
B2
Abstract

Embodiments are directed to assigning a home memory location for a function call parameter. A method may include determining whether a caller is configured to allocate a memory location for a parameter passed to a callee. The caller is a module that includes a function call to the callee and the callee is a function. The method may include inserting instructions in the callee to allocate a home memory location for the parameter in response to determining that the caller is not configured to allocate a memory location for the parameter. In addition, the method may include inserting instructions in the callee to set the memory location as a home location for the parameter in response to determining that the caller is configured to allocate a memory location for the parameter.

Claims (59)

1. A system, comprising:

a processor; and

a memory to store a compiler and one or more modules, the compiler being comprised of instructions that when executed by the processor, cause the processor to perform the following operations:

determining whether a caller is configured to allocate a memory location for a parameter passed to a callee, the caller being a module that includes a function call to the callee and the callee being a function;

in response to determining that the caller is not configured to allocate the memory location for the parameter; inserting instructions in the callee to allocate a home memory location for the parameter, wherein the home memory location is a parameter save area within a stack frame that is designated for function call parameters; and

in response to determining that the caller is configured to allocate the memory location for the parameter, inserting instructions in the callee to set the memory location as the home location for the parameter.

2. The system of claim 1 , wherein the determining that the caller is configured to allocate the memory location for the parameter, further comprises:

determining whether the caller is configured to save the parameter to the memory location; and

in response to determining that the caller is not configured to save the parameter to the memory location, inserting instructions in the callee to save the parameter to the memory location.

3. The system of claim 1 , wherein the determining of whether a caller is configured to allocate the memory location for a parameter passed to a callee includes:

determining that the callee only includes named parameters;

determining that the named parameters are of a number and type such that all of the named parameters are capable of being passed in registers of a processor;

in response to determining that the callee only includes named parameters and that the named parameters are of a number and type such that all of the named parameters are capable of being passed in registers of a processor, determining that the caller is not configured to allocate the memory location for the parameter; and

otherwise determining that the caller is configured to allocate the memory location for the parameter.

4. The system of claim 1 , wherein the determining of whether a caller is configured to allocate the memory location for a parameter passed to a callee includes:

determining that the callee includes at least one unnamed parameter;

in response to determining that the callee includes at least one unnamed parameter, determining that that the caller is configured to allocate the memory location for the parameter; and

otherwise determining that the caller is not configured to allocate the memory location for the parameter.

5. The system of claim 4 , wherein the inserted instructions in the callee to allocate the memory location for the parameter are instructions to allocate a parameter overflow area in the home memory location located in the stack frame of the caller.

6. The system of claim 4 , wherein the compiler further causes the processor to perform the operations of:

when a prototype of the callee function is not within a scope of the module, inserting instructions in the caller to allocate a register save area within the home memory location;

determining whether all parameters of the function can be passed in registers; and

inserting instructions in the caller to allocate a parameter overflow area in the home memory location when all parameters of the function call cannot be passed in registers.

7. The system of claim 1 , wherein:

the instructions inserted in the callee to allocate the home memory location for the parameter in response to determining that the caller is not configured to allocate the memory location for the parameter are configured to be executed in response to a request for an address of the parameter, and

the instructions inserted in the callee to set the memory location as the home location for the parameter in response to determining that the caller is configured to allocate a memory location for the parameter are configured to be executed in response to a request for an address of the parameter.

8. The system of claim 1 , wherein:

the instructions inserted in the callee to allocate the home memory location for the parameter in response to determining that the caller is not configured to allocate a memory location for the parameter are configured to be executed in response to a function call to the callee function, and

the instructions inserted in the callee to set the memory location as the home memory location for the parameter in response to determining that the caller is configured to allocate the memory location for the parameter are configured to be executed in response to a function call to the callee function.

9. The system of claim 1 , wherein:

the instructions to allocate the home memory location for the parameter in response to determining that that the caller is not configured to allocate the memory location for the parameter include an instruction to allocate memory locations for all parameters of the callee; and

the instructions to set the memory location as the home location for the parameter in response to determining that the caller is configured to allocate the memory location for the parameter include an instruction to set memory locations allocated by the caller as home memory locations for all parameters of the callee.

10. A computer program product comprising a non-transitory computer readable storage medium having program instructions embodied therewith, the program instructions readable by a processor circuit to cause the processor to:

determining whether a caller is configured to allocate a memory location for a parameter passed to a callee, the caller being a module that includes a function call to the callee and the callee being a function;

in response to determining that the caller is not configured to allocate the memory location for the parameter, inserting instructions in the callee to allocate a home memory location for the parameter, wherein the home memory location is a parameter save area within a stack frame that is designated for function call parameters; and

in response to determining that the caller is configured to allocate the memory location for the parameter, inserting instructions in the callee to set the memory location as the home location for the parameter.

11. The computer program product of claim 10 , wherein the determining that the caller is configured to allocate the memory location for the parameter, further comprises:

determining whether the caller is configured to save the parameter to the memory location; and

in response to determining that the caller is not configured to save the parameter to the memory location, inserting instructions in the callee to save the parameter to the memory location.

12. The computer program product of claim 10 , wherein the determining of whether a caller is configured to allocate the memory location for a parameter passed to a callee includes:

determining that the callee only includes named parameters;

determining that the named parameters are of a number and type such that all of the named parameters are capable of being passed in registers of a processor;

in response to determining that the callee only includes named parameters and that the named parameters are of a number and type such that all of the named parameters are capable of being passed in registers of a processor, determining that the caller is not configured to allocate the memory location for the parameter; and

otherwise determining that the caller is configured to allocate the memory location for the parameter.

13. The computer program product of claim 10 , wherein the determining of whether a caller is configured to allocate the memory location for a parameter passed to a callee includes:

determining that the callee includes at least one unnamed parameter;

in response to determining that the callee includes at least one unnamed parameter, determining that that the caller is configured to allocate the memory location for the parameter; and

otherwise determining that the caller is not configured to allocate the memory location for the parameter.

14. The computer program product of claim 13 , wherein the inserted instructions in the callee to allocate the memory location for the parameter are instructions to allocate a parameter overflow area in the home memory location located in the stack frame of the caller.

15. The computer program product of claim 10 , wherein:

the instructions inserted in the callee to allocate the home memory location for the parameter in response to determining that the caller is not configured to allocate a the memory location for the parameter are configured to be executed in response to a request for an address of the parameter, and

the instructions inserted in the callee to set the memory location as the home location for the parameter in response to determining that the caller is configured to allocate the memory location for the parameter are configured to be executed in response to a request for an address of the parameter.

16. The computer program product of claim 10 , wherein:

the instructions inserted in the callee to allocate the home memory location for the parameter in response to determining that the caller is not configured to allocate a the memory location for the parameter are configured to be executed in response to a function call to the callee function, and

the instructions inserted in the callee to set the memory location as the home location for the parameter in response to determining that the caller is configured to allocate the memory location for the parameter are configured to be executed in response to a function call to the callee function.

17. The computer program product of claim 10 , wherein the program instructions readable by the processor circuit further cause the processor to:

insert instructions in the caller to allocate a register save area within the home memory when a prototype of the callee function is not within a scope of the module;

determine whether all parameters of the function can be passed in registers; and

insert instructions in the caller to allocate a parameter overflow area in the home memory location when all parameters of the function call cannot be passed in registers.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Nov 10, 2014
From: GSCHWIND, MICHAEL KARL; WEIGAND, ULRICH
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 034134/0476 →
Continuity (1)
Related Publication 20160132245A1 · May 12, 2016