# US 8,752,008 B2 · Lightweight service based dynamic binary rewriter framework

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

- Number: US 8,752,008 B2
- Document ID: US8752008B2
- Status: Granted
- Kind: B2
- Application number: 12/552,740
- Filed: 2009-09-02
- Published: 2011-03-03
- Granted: 2014-06-10
- Earliest claimed: 2009-09-02
- Assignees: Advanced Micro Devices, Inc.
- Applicants: Mark Herdeg; Steven T. Tye; Michael Bedy; Anton Chernoff
- Inventors: Mark Herdeg; Steven T. Tye; Michael Bedy; Anton Chernoff
- Web page: https://patentgrep.com/patent/US8752008B2

## CPC

- G06F 9/45525: {Optimisation or modification within the same instruction set architecture, e.g. HP Dynamo}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A sampling based DBR framework which leverages a separate core for program analysis. The framework includes a hardware performance monitor, a DBR service that executes as a separate process and a lightweight DBR agent that executes within a client process. The DBR service aggregates samples from the hardware performance monitor, performs region selection by deducing the program structure around hot samples, performs transformations on the selected regions (e.g. optimization), and generates replacement code. The DBR agent then patches the client process to use the replacement code.

## Claims

### Claim 1

A dynamic binary rewriter (DBR) framework comprising:
a hardware performance monitor contained within a processor, the hardware performance monitor sampling one or more client processes;
a DBR service, the DBR service executing as a separate process, the DBR service configured to:
aggregate samples from the hardware performance monitor;
perform region selection to identify a frequently executed code section in the one or more client processes;
optimize the selected region; and
generate replacement code for the selected region, wherein the replacement code is functionally equivalent to original code of the selected region; and
a DBR agent, the DBR agent executing within the one or more client processes, the DBR agent patching the one or more client processes to use the replacement code.

### Claim 2 (depends on 1)

The DBR framework of claim 1 wherein:
the hardware performance monitor uses sampling to collect a plurality of types of information regarding execution of the one or more client processes; and,
the DBR services use the plurality of types of information when performing region selection.

### Claim 3 (depends on 1)

The DBR framework of claim 1 wherein:
at startup of the one or more client processes the DBR agent is automatically loaded into a client process address space of the respective one or more client processes and is initialized; and,
the DBR agent performs patching and unpatching of replacement code and reporting necessary system library usage without imposing significant additional resource requirements on the one or more client processes.

### Claim 4 (depends on 3)

The DBR framework of claim 3 wherein:
initialization of the DBR agent creates a new thread within the one or more client processes, the DBR agent operating within the new thread.

### Claim 5 (depends on 1)

The DBR framework of claim 1 wherein:
decoupling the DBR service from the one or more client processes allows the DBR service to execute concurrently with the one or more client processes, utilizing one or more separate cores if available, while minimizing memory usage and avoiding shared libraries within the one or more client processes.

### Claim 6 (depends on 1)

The DBR framework of claim 1 wherein:
decoupling the DBR service from the one or more client processes allows the DBR service to manage multiple client processes so as to allow system resources used by the DBR to be coordinated.

### Claim 7 (depends on 1)

The DBR framework of claim 1 wherein:
decoupling the DBR service from the one or more client processes allows the DBR service to operate continuously taking snapshots of the client processes being managed and removing or creating new replacements as necessary.

### Claim 8 (depends on 1)

The DBR framework of claim 1 wherein:
the DBR service comprises a DBR control thread, with the DBR control thread managing communication with the DBR agent and coordinating aspects of the DBR service.

### Claim 9 (depends on 1)

The DBR framework of claim 1 wherein:
the DBR service comprises one or more worker threads, with each worker thread performing a region selection operation, region transformation operation and replacement code generation operation for a client process.

### Claim 10 (depends on 1)

The DBR framework of claim 1 wherein:
the DBR service and the DBR agent communicate via memory shared between the DBR service and the DBR agent.

### Claim 11

A method for providing a dynamic binary rewriter (DBR) comprising:
utilizing a hardware performance monitor, the hardware performance monitor sampling one or more client processes;
providing a DBR service, the DBR service executing as a separate process;
aggregating samples from the hardware performance monitor;
performing region selection to identify a frequently executed code section in the one or more client processes;
optimizing the selected region; and
generating replacement code for the selected region via the DBR service, wherein the replacement code is functionally equivalent to original code of the selected region;
providing a DBR agent,
executing the DBR agent within the one or more client processes;
patching the one or more client processes via the DBR agent to use the replacement code.

### Claim 12 (depends on 11)

The method of claim 11 wherein:
the hardware performance monitor uses sampling to collect a plurality of types of information regarding execution of the one or more client processes; and,
the DBR services uses the plurality of types of information when performing region selection.

### Claim 13 (depends on 11)

The method of claim 11 wherein:
at startup of the one or more client processes the DBR agent is automatically loaded into a client process address space and is initialized; and,
the DBR agent performs patching and unpatching replacement code and reporting necessary system library usage without imposing significant additional resource requirements on the one or more client processes.

### Claim 14 (depends on 13)

The method of claim 13 wherein:
initialization of the DBR agent creates a new thread within the one or more client processes, the DBR agent operating within the new thread.

### Claim 15 (depends on 11)

The method of claim 11 wherein:
decoupling the DBR service from the one or more client processes allows the DBR service to execute concurrently with the client process, utilizing one or more separate cores if available, while minimizing memory usage and avoiding shared libraries within the one or more client processes.

### Claim 16 (depends on 11)

The method of claim 11 wherein:
decoupling the DBR service from the one or more client processes allows the DBR service to manage multiple client processes so as to allow system resources used by the DBR to be coordinated.

### Claim 17 (depends on 11)

The method of claim 11 wherein:
decoupling the DBR service from the one or more client processes allows the DBR service to operate continuously taking snapshots of the client processes being managed and removing or creating new replacements as necessary.

### Claim 18 (depends on 11)

The method of claim 11 wherein:
the DBR service comprises a DBR control thread, with the DBR control thread managing communication with the DBR agent and coordinating aspects of the DBR service.

### Claim 19 (depends on 11)

The method of claim 11 wherein:
the DBR service comprises one or more worker threads, with each worker thread performing a region selection operation, region transformation operation and replacement code generation operation for a client process.

### Claim 20 (depends on 11)

The method of claim 11 wherein:
the DBR service and the DBR agent communicate via memory shared between the DBR service and the DBR agent.
