# US 2015/0178051 A1 · Execution guards in dynamic programming

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

- Number: US 2015/0178051 A1
- Document ID: US20150178051A1
- Status: Published application
- Kind: A1
- Application number: 14/137,356
- Filed: 2013-12-20
- Published: 2015-06-25
- Earliest claimed: 2013-12-20
- Assignees: Microsoft Corporation
- Applicants: Microsoft Corporation
- Inventors: Jedrzej Miadowicz; Curtis Cheng-Cheng Man; Louis Lafreniere
- Web page: https://patentgrep.com/patent/US20150178051A1

## CPC

- G06F 8/31: {Programming languages or programming paradigms}
- G06F 8/41: Compilation
- G06F 9/4491: {Optimising based on receiver type}
- G06F 9/45504: {Abstract machines for program code execution, e.g. Java virtual machine [JVM], interpreters or emulators}
- G06F 9/4552: {Involving translation to a different instruction set architecture, e.g. just-in-time translation in a JVM}
- G06F 9/45529: {Embedded in an application, e.g. JavaScript in a Web browser}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for executing a machine code based on a dynamic language is disclosed. An execution guard is created as a value stored in a data structure. The value is representative of an expected condition or a set of conditions for a reusable portion of the machine code. The value representative of the expected condition(s) is compared to an actual value encountered later during execution of a portion of the machine code. The reusable machine code is executed if the actual value corresponds with the value representative of the expected condition(s). The execution guard is invalidated if any of the expected conditions changes.

## Claims

### Claim 1

A processor-implemented method for executing a machine code based on a dynamic language, including:
creating a guard as a value stored in a data structure and representative of an expected condition for a reusable portion of the machine code with the processor;
comparing the value representative of the expected condition to an actual value encountered later during execution of a portion of the machine code;
executing the machine code if the actual value corresponds with the value representative of the expected condition; and
invalidating the guard if the expected condition changes as a result of executing the machine code.

### Claim 2 (depends on 1)

The method of claim 1 wherein creating the guard includes allocating an object to be the guard in memory.

### Claim 3 (depends on 2)

The method of claim 2 wherein predetermined slot of the object is used as the guard.

### Claim 4 (depends on 3)

The method of claim 3 wherein remaining object contents are irrelevant in the comparing of the value representative of the expected condition to an actual value encountered later during execution of a portion of the machine code.

### Claim 5 (depends on 1)

The method of claim 1 wherein the comparing of the value representative of the expected condition to an actual value encountered during execution of a portion of the machine code permits simultaneous verification of multiple expectations.

### Claim 6 (depends on 1)

The method of claim 1 wherein invalidation of the guard occurs if one or more of a plurality of expected conditions changes.

### Claim 7 (depends on 1)

The method of claim 1 wherein invalidating of the guard includes selectively invalidating the guard.

### Claim 8 (depends on 7)

The method of claim 7 wherein the invalidating of the guard occurs when the prototype of a constructor changes.

### Claim 9 (depends on 1)

The method of claim 1 wherein an invalidated guard is never revalidated.

### Claim 10 (depends on 8)

The method of claim 8 wherein no newly generated machine code refers to a guard once it has been invalidated.

### Claim 11 (depends on 1)

The method of claim 1 wherein the invalidated guard remains in place for existing code still using the guard.

### Claim 12 (depends on 11)

The method of claim 11 where existing code still using the invalidated guard is on a call stack.

### Claim 13 (depends on 11)

The method of claim 11 wherein machine code encountering the invalidated guard bails out to a handler routine.

### Claim 14

A computer readable storage medium storing computer executable instructions for controlling a computing device to perform a method comprising:
creating a guard as a value stored in a data structure and representative of an expected condition for a portion of a machine code being compiled from a dynamic language;
comparing the value representative of the expected condition to an actual value encountered during execution of a portion of the machine code;
executing the machine code if the actual value corresponds with the value representative of the expected condition; and
invalidating the guard if an expected condition changes as a result of executing the machine code.

### Claim 15 (depends on 14)

The computer readable storage medium of claim 14 wherein the machine code is compiled from a byte code with a just in time compiler.

### Claim 16 (depends on 14)

The computer readable storage medium of claim 14 wherein creating the guard includes allocating, with a recycler, an object to be the guard in memory.

### Claim 17 (depends on 14)

The computer readable storage medium of claim 14 including discarding the invalidated guard from memory when the invalidated guard is no longer reference by actively executing code or code that may still be executed.

### Claim 18 (depends on 14)

The computer readable storage medium of claim 14 wherein the invalidated guard remains in place for existing code corresponding with the guard.

### Claim 19

A computer readable storage medium storing computer executable instructions for controlling a computing device to perform a method comprising:
creating a guard as a value stored in a data structure and representative of a set of expected conditions for a reusable portion of a machine code being compiled from a dynamic language;
comparing the value representative of the expected conditions to an actual value encountered later during execution of a portion of the machine code;
executing the machine code if the actual value corresponds with the value representative of the expected condition;
invalidating the guard if the expected condition changes as a result of executing the machine code; and
discarding the invalidated guard for newly combined code wherein the invalidated guard remains in place for existing code corresponding with the guard.

### Claim 20 (depends on 19)

The computer readable storage medium of claim 19 wherein the set of expected conditions includes one or more of an expected type of an object and one or more of an expected attributes of an object property.
