# US 2014/0157291 A1 · Method and system for binding objects in dynamic programming languages using caching techniques

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

- Number: US 2014/0157291 A1
- Document ID: US20140157291A1
- Status: Published application
- Kind: A1
- Application number: 13/691,664
- Filed: 2012-11-30
- Published: 2014-06-05
- Earliest claimed: 2012-11-30
- Assignees: Facebook, Inc.
- Applicants: Facebook, Inc.
- Inventors: Keith C. Adams; Andrew John Paroski; Jason Owen Evans
- Web page: https://patentgrep.com/patent/US20140157291A1

## CPC

- G06F 9/44521: {Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading}
- G06F 8/41: Compilation
- G06F 9/449: {Object-oriented method invocation or resolution}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Disclosed are a method and system for binding a program object in a source code to one of a number of implementations of the program object, using caching techniques. Binding a program object to a particular implementation includes performing the binding process at compile time and runtime of the source code. During compilation phase, the program objects in the source code are identified, and each of the program objects is assigned a slot in a target cache. The slot is configured to store a pointer that points to a particular implementation of a program object to which the slot is assigned. During execution phase, the particular implementation of the program object is determined based on execution flow of the source code. After the particular implementation is determined, the program object is bound to the particular implementation by updating the assigned target cache slot with a pointer pointing to the particular implementation.

## Claims

### Claim 1

A method comprising:
identifying, at a computer system and during compilation of a source code of a program, a plurality of program objects in the source code, the source code conforming to a dynamic programming language;
allocating, at the computer system and during compilation of the source code, a slot in a target cache for each of the program objects, wherein the slot is configured to store a pointer to a particular implementation of a plurality of implementations of a program object to which the slot is allotted;
determining, during execution of the program and based on execution flow of the source code, the particular implementation of the program object; and
binding, during execution of the program, the program object to the particular implementation by updating the allotted slot with the pointer to the particular implementation.

### Claim 2 (depends on 1)

The method of claim 1 further comprising:
determining, during execution of the program, whether the program object is invoked;
responsive to a determination that the program object is invoked, loading the particular implementation of the program object from the allotted slot; and
executing the particular implementation of the program object.

### Claim 3 (depends on 1)

The method of claim 1, wherein allocating a slot in a target cache to each of the program objects includes
storing allocations of the slots to program objects in a data structure.

### Claim 4 (depends on 3)

The method of claim 3, wherein storing the allocations in the data structure includes
storing the allocations as key-value pairs in the data structure, a name of the program object being a key and a slot allotted to the program object being a value of a key-value pair.

### Claim 5 (depends on 3)

The method of claim 3, wherein the data structure includes at least one of a hashtable or a hashmap.

### Claim 6 (depends on 3)

The method of claim 3, wherein storing the allocations in the data structure includes
storing the allocations for a lifetime of the source code.

### Claim 7 (depends on 1)

The method of claim 1, wherein the slots in the target cache are updated with the pointers to particular implementations of the program objects as and when the particular implementations occur during the execution of the program.

### Claim 8 (depends on 1)

The method of claim 1, wherein the target cache is reset at beginning of the execution of the program.

### Claim 9 (depends on 1)

The method of claim 1, wherein the target cache is specific to a thread of the execution of the program.

### Claim 10 (depends on 1)

The method of claim 1, wherein the program objects include at least one of (i) a class, (ii) a method, (iii) a variable, or (iv) a constant.

### Claim 11 (depends on 1)

The method of claim 1, wherein a type of the program objects is dependent on programming language of the source code.

### Claim 12 (depends on 1)

The method of claim 1, wherein the dynamic programming language of the source code includes Personal Home Page/Hypertext Preprocessor (PHP).

### Claim 13

A method comprising:
determining, at a computer system and during execution of a source code, whether a program object of the source code is invoked, the program object having a plurality of implementations;
responsive to a determination that the program object is invoked, performing a look-up in a target cache of the computer system to obtain a particular implementation of the program object, the target cache having a plurality of slots, each of the slots assigned to each of a plurality of program objects of the source code, and each of the slots configured to store a pointer that points to the particular implementation of the program object to which the slot is assigned; and
executing the particular implementation of the program object.

### Claim 14 (depends on 13)

The method of claim 13, wherein assigning the slots in the target cache to the program objects includes
assigning the slots to the program objects during compilation of the source code.

### Claim 15 (depends on 13)

The method of claim 13, wherein assigning the slots in the target cache to the program objects includes
storing slot assignments in a data structure.

### Claim 16 (depends on 13)

The method of claim 13, wherein performing a look-up in a target cache includes
updating, during execution of the source code, the assigned slot with the pointer that points to the particular implementation of the program object to which the slot is assigned.

### Claim 17

An apparatus comprising:
a processor;
a memory that contains instructions to be executed by the processor;
a program object identification module that works in cooperation with the processor to identify, during compilation of a source code of a program, a plurality of program objects in the source code;
an assignment module to assign, during compilation of the source code, a slot in a target cache to each of the program objects, wherein the slot is configured to store a pointer to a particular implementation of a plurality of implementations of a program object to which the slot is assigned;
an implementation determination module to determine, during execution of the program and based on execution flow of the source code, the particular implementation of the program object; and
a binding module to bind, during execution of the program, the program object to the particular implementation by updating the assigned slot with the pointer to the particular implementation.

### Claim 18 (depends on 17)

The apparatus of claim 17 further comprising:
a compilation module to compile the source code.

### Claim 19 (depends on 17)

The apparatus of claim 17 further comprising:
a runtime module to execute the source code.

### Claim 20 (depends on 17)

The apparatus of claim 17, wherein the assignment module is further configured to create a data structure to store assignments of slots in the target cache to the program objects.
