IP Library Granted Patent US 7,934,204
Granted Patent B2
US 7,934,204 · App. 10/802,309 · Granted Apr 26, 2011

Partitioning code in program code conversion

View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 7,934,204
App. No.
10/802,309
Granted
Apr 26, 2011
Kind
B2
Abstract

A partitioning technique utilized by a translator to divide the subject code space into regions, referred to hereafter as partitions, where each partition contains a distinct set of basic blocks of subject code and corresponding target code. The partitioning technique divides the translator's representation of subject code and subject code translations into non-overlapping regions of subject memory. In this manner, when the subject program modifies subject code, only those partitions actually affected by the self-modifying code need be discarded and all translations in unaffected partitions can be kept. This partitioning technique is advantageous in limiting the amount of target code that must be retranslated in response to self-modifying code operation. In another process, the partitioning technique allows multithreaded subject programs that also involve self-modifying code to perform code modification in a thread-safe manner.

Claims (102)

1. A method for generating a translation of subject code into target code, comprising:

identifying a block of self-modifying subject code within a block of subject code;

identifying one or more blocks of non-self-modifying code within the block of subject code;

partitioning the block of subject code, comprising:

generating a first partition in the subject code such that the first partition includes the identified block of self-modifying subject code;

generating one or more additional partitions in the subject code such that each additional partition includes one of the identified blocks of non-self-modifying subject code, respectively, wherein subject code in each of the first partition and the one or more partitions do not overlap;

translating the first partition into a first block of target code;

translating the one or more additional partitions into a corresponding number of additional blocks of target code; and

combining the first block of target code and the additional blocks of target code to produce a translated target code.

2. The method of claim 1 , further comprising:

detecting a modification in the block of self-modifying subject code;

translating the first partition, including the modification, to produce a modified block of target code; and

combining the modified block of target code and the additional blocks of target code to produce a modified translated target code.

3. The method of claim 1 , further comprising:

detecting a modification in the block of self-modifying subject code;

detecting that the modification has modified a block of code corresponding to a second partition of the one or more additional partitions;

modifying the first partition by adding the block of code corresponding to the second partition to produce a modified first partition;

modifying the second partition by removing the block of code corresponding to the second partition to produce a modified second partition;

translating the first and second modified partitions to produce a first and second modified blocks of target code, respectively; and

combing the first and second modified blocks of target code and the additional blocks of target code, but not a block of target code corresponding to the second partition, to produce a modified translated target code.

4. The method of claim 1 , further comprising:

identifying two partitions of the first and additional partitions that are stored adjacently in a memory and that have characteristics that allow them to be combined;

aggregating the two partitions into a single combined partition;

translating the combined partition to produce a modified combined block of target code; and

combining the first block of target code, the additional blocks of target code and the modified combined block of target code, without blocks of target code corresponding to the two partitions, to produce a modified translated target code.

5. The method of claim 1 , further comprising:

identifying a control flow instruction in the block of self-modifying subject code or in the one or more blocks of non-self-modifying subject code; and

inserting an exit translation structure, representative of the control flow instruction, into a block of code in which the control flow instruction was identified.

6. The method of claim 5 , further comprising:

identifying a block of code as a target of the control flow instruction; and

inserting an entry translation structure into the block of code identified as the target of the control flow instruction.

7. The method of claim 6 , further comprising:

inserting, into the block of code in which the control flow instruction was identified, a first border guard corresponding to the exit translation structure; and

inserting, into the block of code identified as the target of the control flow instruction, a second border guard corresponding to the entry translation structure.

8. A computer programming product, comprising:

a computer-readable memory, executable on a processor; and

logic, stored on the computer-readable memory and executed on the processor,

for:

identifying a block of self-modifying subject code within a block of subject code;

identifying one or more blocks of non-self-modifying code within the block of subject code;

partitioning the block of subject code, comprising:

generating a first partition in the subject code such that the first partition includes the identified block of self-modifying subject code;

generating one or more additional partitions in the subject code such that each additional partition includes one of the identified blocks of non-self-modifying subject code, respectively, wherein subject code in each of the first partition and the one or more partitions do not overlap;

translating the first partition into a first block of target code;

translating the one or more additional partitions into a corresponding number of additional blocks of target code; and

combining the first block of target code and the additional blocks of target code to produce a translated target code.

9. The computer programming product of claim 8 , the logic further comprising logic for:

detecting a modification in the block of self-modifying subject code;

translating the first partition, including the modification, to produce a modified block of target code; and

combining the modified block of target code and the additional blocks of target code to produce a modified translated target code.

10. The computer programming product of claim 8 , the logic further comprising logic for:

detecting a modification in the block of self-modifying subject code;

detecting that the modification has modified a block of code corresponding to a second partition of the one or more additional partitions;

modifying the first partition by adding the block of code corresponding to the second partition to produce a modified first partition;

modifying the second partition by removing the block of code corresponding to the second partition to produce a modified second partition;

translating the first and second modified partitions to produce a first and second modified blocks of target code, respectively; and

combing the first and second modified blocks of target code and the additional blocks of target code, but not a block of target code corresponding to the second partition, to produce a modified translated target code.

11. The computer programming product of claim 8 , the logic further comprising logic for:

identifying two partitions of the first and additional partitions that are stored adjacently in a memory and that have characteristics that allow them to be combined;

aggregating the two partitions into a single combined partition;

translating the combined partition to produce a modified combined block of target code; and

combining the first block of target code, the additional blocks of target code and the modified combined block of target code, without blocks of target code corresponding to the two partitions, to produce a modified translated target code.

12. The computer programming product of claim 8 , the logic further comprising logic for:

identifying a control flow instruction in the block of self-modifying subject code or in the one or more blocks of non-self-modifying subject code; and

inserting an exit translation structure, representative of the control flow instruction, into a block of code in which the control flow instruction was identified.

13. The computer programming product of claim 12 , the logic further comprising logic for:

identifying a block of code as a target of the control flow instruction; and

inserting an entry translation structure into the block of code identified as the target of the control flow instruction.

14. An apparatus, comprising:

a processor;

a computer-readable memory coupled to the processor; and

logic, stored on the computer-readable memory and executed on the processor, for:

identifying a block of self-modifying subject code within a block of subject code;

identifying one or more blocks of non-self-modifying code within the block of subject code;

partitioning the block of subject code, comprising:

generating a first partition in the subject code such that the first partition includes the identified block of self-modifying subject code;

generating one or more additional partitions in the subject code such that each additional partition includes one of the identified blocks of non-self-modifying subject code, respectively, wherein subject code in each of the first partition and the one or more partitions do not overlap;

translating the first partition into a first block of target code;

translating the one or more additional partitions into a corresponding number of additional blocks of target code; and

combining the first block of target code and the additional blocks of target code to produce a translated target code.

15. The apparatus of claim 14 , the logic further comprising logic for:

detecting a modification in the block of self-modifying subject code;

translating the first partition, including the modification, to produce a modified block of target code; and

combining the modified block of target code and the additional blocks of target code to produce a modified translated target code.

16. The apparatus of claim 14 , the logic further comprising logic for:

detecting a modification in the block of self-modifying subject code;

detecting that the modification has modified a block of code corresponding to a second partition of the one or more additional partitions;

modifying the first partition by adding the block of code corresponding to the second partition to produce a modified first partition;

modifying the second partition by removing the block of code corresponding to the second partition to produce a modified second partition;

translating the first and second modified partitions to produce a first and second modified blocks of target code, respectively; and

combing the first and second modified blocks of target code and the additional blocks of target code, but not a block of target code corresponding to the second partition, to produce a modified translated target code.

17. The apparatus of claim 14 , the logic further comprising logic for:

identifying two partitions of the first and additional partitions that are stored adjacently in a memory and that have characteristics that allow them to be combined;

aggregating the two partitions into a single combined partition;

translating the combined partition to produce a modified combined block of target code; and

combining the first block of target code, the additional blocks of target code and the modified combined block of target code, without blocks of target code corresponding to the two partitions, to produce a modified translated target code.

18. The apparatus of claim 14 , the logic further comprising logic for:

identifying a control flow instruction in the block of self-modifying subject code or in the one or more blocks of non-self-modifying subject code; and

inserting an exit translation structure, representative of the control flow instruction, into a block of code in which the control flow instruction was identified.

19. The apparatus of claim 18 , the logic further comprising logic for:

identifying a block of code as a target of the control flow instruction; and

inserting an entry translation structure into the block of code identified as the target of the control flow instruction.

Assignments (4)
CORRECTIVE ASSIGNMENT TO CORRECT THE ASSIGNEE NAME PREVIOUSLY RECORDED ON REEL 022928 FRAME 0190. ASSIGNOR(S) HEREBY CONFIRMS THE RECEIVING PARTY. Recorded Aug 26, 2013
From: IBM UNITED KINGDOM LIMITED
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 031085/0824 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jul 7, 2009
From: IBM UNITED KINGDOM LIMITED
To: IBM CORPORATION
Reel/Frame 022928/0190 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jun 16, 2009
From: TRANSITIVE LIMITED
To: IBM UNITED KINGDOM LIMITED
Reel/Frame 022824/0715 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jun 21, 2004
From: BROWN, ALEX; KNOWLES, PAUL THOMAS; NORTH, GERAINT
To: TRANSITIVE LIMITED
Reel/Frame 015481/0045 →