# US 8,578,352 B1 · Optimizing object oriented programs using limited customization

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

- Number: US 8,578,352 B1
- Document ID: US8578352B1
- Status: Granted
- Kind: B1
- Application number: 13/077,566
- Filed: 2011-03-31
- Granted: 2013-11-05
- Earliest claimed: 2011-03-31
- Assignees: Google Inc.
- Applicants: Srdjan Mitrovic; Lars Bak
- Inventors: Srdjan Mitrovic; Lars Bak
- Web page: https://patentgrep.com/patent/US8578352B1

## CPC

- G06F 9/4552: {Involving translation to a different instruction set architecture, e.g. just-in-time translation in a JVM}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A capability for limited customization that utilizes existing virtual dispatch table technology and allows selective customization is provided. Such a capability combines the usage of virtual dispatch tables with both customized and non-customized code to reduce, or even eliminate over-customization. Further, such a capability may employ a runtime system that decides what methods to customize based on several factors including, but not limited to the size of a class hierarchy, the amount of available space for compiled code, and the amount of available time for compilation.

## Claims

### Claim 1

A computer-implemented method for optimizing object oriented programs using limited customization comprising:
determining whether a virtual function is compiled for a first receiver class associated with the virtual function;
if it is determined that the virtual function is not already compiled for the first receiver class, determining whether to customize the virtual function having the associated first receiver class;
generating, if it is determined to customize the virtual function, a customized version of the virtual function having one or more devirtualized function calls of the virtual function;
storing an entry for the customized version of the virtual function in a virtual table associated with the first receiver class, wherein the virtual table stores an entry point of the virtual function that is not customized; and
executing the customized version of the virtual function for an object of the first receiver class based on the stored entry in the virtual table associated with the first receiver class,
wherein the determining, the generating, the storing, and the executing are performed using one or more computing devices.

### Claim 2 (depends on 1)

The method of claim 1, wherein the generating, the storing, and the executing are performed dynamically during runtime.

### Claim 3 (depends on 1)

The method of claim 1, wherein the determining, the generating, the storing, and the executing are performed statically prior to runtime.

### Claim 4 (depends on 1)

The method of claim 1, wherein the determining further comprises:
determining whether the virtual function is customized based on a size of class hierarchy associated with the virtual function.

### Claim 5 (depends on 4)

The method of claim 4, wherein the determining further comprises determining whether the virtual function is customized based on an amount of available memory space for compiled code.

### Claim 6 (depends on 5)

The method of claim 5, wherein the determining further comprises determining whether the virtual function is customized based on an amount of available time for compilation.

### Claim 7 (depends on 6)

The method of claim 6, wherein the generating further comprises:
customizing the virtual function to a first receiver type corresponding to the first receiver class based on the determining.

### Claim 8 (depends on 7)

The method of claim 7, wherein the customizing the virtual function to the first receiver type comprises:
determining whether a first virtual call in the one or more virtual calls of the virtual function has a same receiver class as the first receiver class associated with the virtual function;
identifying a first target of the first virtual call based on the determining for the first virtual call; and
devirtualizing the first virtual call for the first receiver type based on the identifying.

### Claim 9 (depends on 8)

The method of claim 8, further comprising:
customizing the virtual function to a second receiver type corresponding to a second receiver class associated with the virtual function based on the determining whether to customize the virtual function.

### Claim 10 (depends on 9)

The method of claim 9, wherein the customizing the virtual function to the second receiver type comprises:
determining whether a second virtual call in the one or more virtual calls of the virtual function has the same receiver class as the second receiver class associated with the virtual function;
identifying a second target of the second virtual call based on the determining for the second virtual call; and
devirtualizing the second virtual call for the second receiver type based on the identifying of the second target.

### Claim 11

A system for optimizing object oriented programs using limited customization comprising:
at least one processor;
a virtual function analyzer configured to determine whether a virtual function is compiled for a first receiver class associated with the virtual function and determine whether to customize the virtual function having the associated first receiver class, if it is determined that the virtual function is not already compiled for the first receiver class;
a virtual function customizer configured to:
generate, based on the determination of the virtual function analyzer that it is determined to customize the virtual function, a customized version of the virtual function having one or more devirtualized function calls of the virtual function,
compile the virtual function for the first receiver class, and
store an entry for the customized version of the virtual function in a virtual table associated with the first receiver class, wherein the virtual table stores an entry point of the virtual function that is not customized; and
an execution unit configured to execute on the at least one processor the customized version of the virtual function for an object of the first receiver class based on the stored entry in the virtual table associated with the first receiver class.

### Claim 12 (depends on 11)

The system of claim 11, wherein the virtual function analyzer, the virtual function customizer, and the execution unit perform operations dynamically during runtime.

### Claim 13 (depends on 11)

The system of claim 11, wherein the virtual function analyzer, the virtual function customizer, and the execution unit perform operations statically prior to runtime.

### Claim 14 (depends on 11)

The system of claim 11, wherein the virtual function analyzer is further configured to determine whether the virtual function is customized based on a size of class hierarchy associated with the virtual function.

### Claim 15 (depends on 14)

The system of claim 14, wherein the virtual function analyzer is further configured to determine whether the virtual function is customized based on an amount of available memory space for compiled code.

### Claim 16 (depends on 15)

The system of claim 15, wherein the virtual function analyzer is further configured to determine whether the virtual function is customized based on an amount of available time for compilation.

### Claim 17 (depends on 16)

The system of claim 16, wherein the virtual function customizer is further configured to customize the virtual function to a first receiver type corresponding to the first receiver class based on the determination of the virtual function analyzer.

### Claim 18 (depends on 17)

The system of claim 17, wherein the virtual function customizer is configured to determine whether a first virtual call in the one or more virtual calls of the virtual function has a same receiver class as the first receiver class associated with the virtual function, to identify a first target of the first virtual call based on the determination, and to devirtualize the first virtual call for the first receiver type based on the identification.

### Claim 19 (depends on 18)

The system of claim 18, wherein the virtual function customizer is further configured to customize the virtual function to a second receiver type corresponding to a second receiver class associated with the virtual function based on the determining.

### Claim 20 (depends on 19)

The system of claim 19, wherein the virtual function customizer is further configured to determine whether a second virtual call in the one or more virtual calls of the virtual function has the same receiver class as the second receiver class associated with the virtual function, to identify a second target of the second virtual call based on the determination for the second virtual call, and to devirtualize the second virtual call for the second receiver type based on the identification of the second target.

### Claim 21

A non-transitory computer readable storage device having instructions stored thereon that, when executed by a computing device, cause the computing device to perform operations comprising:
determining whether a virtual function is compiled for a first receiver class associated with the virtual function;
if it is determined that the virtual function is not already compiled for the first receiver class, determining whether to customize the virtual function having the associated first receiver class;
generating, if it is determined to customize the virtual function, a customized version of the virtual function having one or more devirtualized function of the virtual function;
storing an entry for the customized version of the virtual function in a virtual table associated with the first receiver class, wherein the virtual table stores an entry point of the virtual function that is not customized; and
executing the customized version of the virtual function for an object of the first receiver class based on the stored entry in the virtual table associated with the first receiver class,
wherein the determining, the generating, the storing, and the executing are performed using one or more computing devices.
