# US 2023/0057055 A1 · Modeling foreign functions using executable references

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2023/0057055 A1
- Document ID: US20230057055A1
- Status: Published application
- Kind: A1
- Application number: 17/980,437
- Filed: 2022-11-03
- Published: 2023-02-23
- Earliest claimed: 2020-03-19
- Assignees: Oracle International Corporation
- Applicants: Oracle International Corporation
- Inventors: Maurizio Cimadamore; James Malcolm Laskey; Jorn Bender Vernee; Vladimir Vitalyevich Ivanov
- Web page: https://patentgrep.com/patent/US20230057055A1

## CPC

- G06F 8/44: {Encoding}
- G06F 9/44557: {Code layout in executable memory}
- G06F 12/0223: {User address space allocation, e.g. contiguous or non contiguous base addressing}
- G06F 8/443: {Optimisation}
- G06F 9/4488: {Object-oriented}
- G06F 9/45504: {Abstract machines for program code execution, e.g. Java virtual machine [JVM], interpreters or emulators}
- G06F 2212/7202: Allocation control and policies
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Techniques for representing a native function using an executable reference are disclosed. The system receives an instruction to create an executable reference for a native function, including a method type comprising a method signature corresponding to the executable reference, and a function description including (a) a memory layout corresponding to data returned by the function and (b) memory layouts corresponding to parameters required by the function. The system selects an application binary interface (ABI). The system generates code that, for each parameter, of the one or more parameters required by the function, converts the parameter from a value formatted for use by a Java Virtual machine to a value formatted for use in the native function, based on the selected ABI. Responsive to invocation of the executable reference, the generated code and the native function may be executed.

## Claims

### Claim 1

One or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause performance of operations comprising:
encountering, during execution of instructions written in a first coding language, an instruction to invoke a native function written in a second coding language that is different from the first coding language, wherein the instruction comprises an argument to the native function;
determining an execution plan that is associated with the native function and comprises instructions for preprocessing the argument to the native function;
based at least on the execution plan, storing a value of the argument in a first storage location used by the native function;
after storing the value of the argument in the first storage location, causing execution of the native function using the value of the argument in the first storage location.

### Claim 2 (depends on 1)

The one or more non-transitory computer-readable media of claim 1, the operations further comprising:
obtaining, from a second storage location used by the native function, a return value generated by the native function;
based at least on the execution plan, converting the return value to a format used by the instructions written in the first coding language.

### Claim 3 (depends on 1)

The one or more non-transitory computer-readable media of claim 1, wherein the execution plan comprises:
a function descriptor that indicates an expected format of the argument to the native function;
one or more criteria for storing the value of the argument in the first storage location so that the value of the argument is usable by the native function.

### Claim 4 (depends on 1)

The one or more non-transitory computer-readable media of claim 1, wherein storing the value of the argument in the first storage location comprises:
storing the value of the argument in an intermediate buffer;
invoking a native routine that moves the value of the argument from the intermediate buffer to the first storage location.

### Claim 5

A system comprising:
at least one device comprising one or more hardware processors,
the system being configured to perform operations comprising:
encountering, during execution of instructions written in a first coding language, an instruction to invoke a native function written in a second coding language that is different from the first coding language, wherein the instruction comprises an argument to the native function;
determining an execution plan that is associated with the native function and comprises instructions for preprocessing the argument to the native function;
based at least on the execution plan, storing a value of the argument in a first storage location used by the native function;
after storing the value of the argument in the first storage location, causing execution of the native function using the value of the argument in the first storage location.

### Claim 6 (depends on 5)

The system of claim 5, the operations further comprising:
obtaining, from a second storage location used by the native function, a return value generated by the native function;
based at least on the execution plan, converting the return value to a format used by the instructions written in the first coding language.

### Claim 7 (depends on 5)

The system of claim 5, wherein the execution plan comprises:
a function descriptor that indicates an expected format of the argument to the native function;
one or more criteria for storing the value of the argument in the first storage location so that the value of the argument is usable by the native function.

### Claim 8

A method comprising:
encountering, during execution of instructions written in a first coding language, an instruction to invoke a native function written in a second coding language that is different from the first coding language, wherein the instruction comprises an argument to the native function;
determining an execution plan that is associated with the native function and comprises instructions for preprocessing the argument to the native function;
based at least on the execution plan, storing a value of the argument in a first storage location used by the native function;
after storing the value of the argument in the first storage location, causing execution of the native function using the value of the argument in the first storage location;
wherein the method is performed by at least device comprising one or more hardware processors.

### Claim 9 (depends on 8)

The method of claim 8, further comprising:
obtaining, from a second storage location used by the native function, a return value generated by the native function;
based at least on the execution plan, converting the return value to a format used by the instructions written in the first coding language.

### Claim 10 (depends on 8)

The method of claim 8, wherein the execution plan comprises:
a function descriptor that indicates an expected format of the argument to the native function;
one or more criteria for storing the value of the argument in the first storage location so that the value of the argument is usable by the native function.

### Claim 11

One or more non-transitory machine-readable media storing instructions that, when executed by one or more processors, cause performance of operations comprising:
encountering, while executing native instructions written in a first coding language, an instruction to invoke a non-native function written in a second coding language that is different from the first coding language, wherein the instruction comprises an argument to the non-native function;
determining a reverse execution plan that is associated with the non-native function and comprises instructions for preprocessing the argument to the non-native function;
based at least on the reverse execution plan, storing a value of the argument in a first storage location used by the non-native function;
after storing the value of the argument in the first storage location, causing execution of the non-native function using the value of the argument in the first storage location.

### Claim 12 (depends on 11)

The one or more non-transitory computer-readable media of claim 11, the operations further comprising:
obtaining a return value generated by the non-native function;
based at least on the execution plan, converting the return value to a format used by the instructions written in the first coding language;
storing the return value in a second storage location used by the native instructions.

### Claim 13 (depends on 12)

The one or more non-transitory computer-readable media of claim 12, wherein storing the return value in the second storage location comprises:
storing the return value in an intermediate buffer;
invoking a native routine that moves the return value from the intermediate buffer to the second storage location.

### Claim 14 (depends on 11)

The one or more non-transitory computer-readable media of claim 11, wherein the reverse execution plan comprises:
a function descriptor that indicates an expected format of the argument to the non-native function;
one or more criteria for storing the value of the argument in the first storage location so that the value of the argument is usable by the non-native function.

### Claim 15

A system comprising:
at least one device comprising one or more hardware processors, the system being configured to perform operations comprising:
encountering, while executing native instructions written in a first coding language, an instruction to invoke a non-native function written in a second coding language, wherein the instruction comprises an argument to the non-native function;
determining a reverse execution plan that is associated with the non-native function and comprises instructions for preprocessing the argument to the non-native function;
based at least on the reverse execution plan, storing a value of the argument in a first storage location used by the non-native function;
after storing the value of the argument in the first storage location, causing execution of the non-native function using the value of the argument in the first storage location.

### Claim 16 (depends on 15)

The system of claim 15, the operations further comprising:
obtaining a return value generated by the non-native function;
based at least on the execution plan, converting the return value to a format used by the instructions written in the first coding language;
storing the return value in a second storage location used by the native instructions.

### Claim 17 (depends on 15)

The system of claim 15, wherein the reverse execution plan comprises:
a function descriptor that indicates an expected format of the argument to the non-native function;
one or more criteria for storing the value of the argument in the first storage location so that the value of the argument is usable by the non-native function.

### Claim 18

A method comprising:
encountering, while executing native instructions written in a first coding language, an instruction to invoke a non-native function written in a second coding language, wherein the instruction comprises an argument to the non-native function;
determining a reverse execution plan that is associated with the non-native function and comprises instructions for preprocessing the argument to the non-native function;
based at least on the reverse execution plan, storing a value of the argument in a first storage location used by the non-native function;
after storing the value of the argument in the first storage location, causing execution of the non-native function using the value of the argument in the first storage location;
wherein the method is performed by at least device comprising one or more hardware processors.

### Claim 19 (depends on 18)

The method of claim 18, further comprising:
obtaining a return value generated by the non-native function;
based at least on the execution plan, converting the return value to a format used by the instructions written in the first coding language;
storing the return value in a second storage location used by the native instructions.

### Claim 20 (depends on 18)

The method of claim 18, wherein the reverse execution plan comprises:
a function descriptor that indicates an expected format of the argument to the non-native function;
one or more criteria for storing the value of the argument in the first storage location so that the value of the argument is usable by the non-native function.
