IP Library Granted Patent US 10,338,902
Granted Patent B1
US 10,338,902 · App. 16/019,524 · Granted Jul 2, 2019

Method and system for a compiler and decompiler

Inventor: Benoit Sevigny (Montréal, CA)
Assignee: Unity IPR ApS
G06F8/4435G06F8/433G06F8/436
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 10,338,902
App. No.
16/019,524
Granted
Jul 2, 2019
Kind
B1
Abstract

A method, system, and computer-readable medium including operations for optimizing computer code is disclosed. A block of mixed intermediate representation (MIR) code is received. A partially-decompiled block of computer code is generated from the MIR code. For each instruction in the block of MIR code, in reverse order, a native expression vector for the instruction is computed. A set of pattern-matching operations is repeated until no transformations occur. A fully-decompiled block of computer code is generated from the partially-decompiled block of computer code, the fully-decompiled block of computer code having a semantic level that is raised. The fully-decompiled block of computer code is provided for deployment on an architecture, the deployment including lowering the semantic of the computer code to a level that corresponds to a CPU or GPU supported by the architecture.

Claims (39)

1. A system comprising:

one or more computer processors;

one or more computer memories;

one or more instructions incorporated into the computer memories, the one or more instructions configuring the one or more computer processors to perform operations for optimizing computer code, the operations comprising:

receiving a block of mixed intermediate representation (MIR) code;

for each instruction in the block of MIR code, in reverse order, generating a partially-decompiled block of computer code, the generating of the partially-decompiled block of computer code including computing a native expression vector for the instruction and repeating a set of pattern-matching operations until no transformations occur, the set of pattern-matching operations including matching all patterns involving the instruction in the block of MIR code, performing transformations based on the matching of all of the patterns in the block of the MIR code recomputing the expression vector after each of the transformations,

for each instruction in the partially-decompiled block of MIR code, in order, computing an additional native expression vector for the instruction in the partially-decompiled block of MIR code and performing an additional set of pattern-matching operations until no additional transformations occur, the additional set of pattern-matching operations including matching all additional patterns involving the instruction in the partially-decompiled block of computer code, and recomputing the expression vector after each of the additional transformations;

generating a fully-decompiled block of computer code from the generated partially-decompiled block of computer code, the fully-decompiled block of computer code having a semantic level that is raised; and

providing the fully-decompiled block of computer code for deployment on an architecture, the deployment including lowering the semantic of the computer code to a level that corresponds to a central processing unit (CPU) or graphical processing unit (GPU) supported by the architecture.

2. The system of claim 1 , wherein the MIR code is created by creating static single assignment form for a computer source code, simulating multiple assignments for named variables within the computer source code, creating a hash-map and populating the hash-map with the last definition of every named variable.

3. The system of claim 2 , wherein the generating of the fully-decompiled block of computer code further includes, based on no transformations occurring, running a common subexpression elimination pass.

4. The system of claim 2 , wherein the generating of the fully-decompiled block of computer code further includes, based on no transformations occurring, running a vectorization pass.

5. The system of claim 1 , wherein the expression vector includes a set of bits for source fields and an additional set of bits for an opcode and wherein the matching of all patterns involving the instruction in the block of MIR code is performed on the bits corresponding to the expression vector.

6. The system of claim 1 , wherein the semantic level corresponds to a higher native semantic level in which function calls are replaced with high-level native opcodes.

7. The system of claim 6 , wherein the high-level native opcodes allow use of mathematical identities to optimize the generating of the fully-decompiled block.

8. A computer-implemented method comprising:

performing operations for optimizing computer code, the operations comprising:

receiving a block of mixed intermediate representation (MIR) code;

for each instruction in the block of MIR code, in reverse order, generating a partially-decompiled block of computer code, the generating of the partially-decompiled block of computer code including computing a native expression vector for the instruction and repeating a set of pattern-matching operations until no transformations occur, the set of pattern-matching operations including matching all patterns involving the instruction in the block of MIR code, performing transformations based on the matching of all of the patterns in the block of the MIR code recomputing the expression vector after each of the transformations,

for each instruction in the partially-decompiled block of MIR code, in order, computing an additional native expression vector for the instruction in the partially-decompiled block of MIR code and performing an additional set of pattern-matching operations until no additional transformations occur, the additional set of pattern-matching operations including matching all additional patterns involving the instruction in the partially-decompiled block of computer code, and recomputing the expression vector after each of the additional transformations;

generating a fully-decompiled block of computer code from the generated partially-decompiled block of computer code, the fully-decompiled block of computer code having a semantic level that is raised; and

providing the fully-decompiled block of computer code for deployment on an architecture, the deployment including lowering the semantic of the computer code to a level that corresponds to a central processing unit (CPU) or graphical processing unit (GPU) supported by the architecture.

9. The computer-implemented method of claim 8 , wherein the MIR code is created by creating static single assignment form for a computer source code, simulating multiple assignments for named variables within the computer source code, creating a hash-map, and populating the hash-map with the last definition of every named variable.

10. The computer-implemented method of claim 8 , wherein the generating of the fully-decompiled block of computer code further includes, based on no transformations occurring, running a common subexpression elimination pass.

11. The computer-implemented method of claim 8 , wherein the generating of the fully-decompiled block of computer code further includes, based on no transformations occurring, running a vectorization pass.

12. The computer-implemented method of claim 8 , wherein the expression vector includes a set of bits for source fields and an additional set of bits for an opcode and wherein the matching of all patterns involving the instruction in the block of MIR code is performed on the bits corresponding to the expression vector.

13. The computer-implemented method of claim 8 , wherein the semantic level corresponds to a higher native semantic level in which function calls are replaced with high-level native opcodes.

14. The computer-implemented method of claim 13 , wherein the high-level native opcodes allow use of mathematical identities to optimize the generating of the fully-decompiled block.

15. A non-transitory computer-readable medium comprising a set of instructions, the set of instructions causing one or more computer processors to perform operations for optimizing computer code, the operations comprising:

receiving a block of mixed intermediate representation (MIR) code;

for each instruction in the block of MIR code, in reverse order, generating a partially-decompiled block of computer code, the generating of the partially-decompiled block of computer code including computing a native expression vector for the instruction and repeating a set of pattern-matching operations until no transformations occur, the set of pattern-matching operations including matching all patterns involving the instruction in the block of MIR code, performing transformations based on the matching of all of the patterns in the block of the MIR code recomputing the expression vector after each of the transformations,

for each instruction in the partially-decompiled block of MIR code, in order, computing an additional native expression vector for the instruction in the partially-decompiled block of MIR code and performing an additional set of pattern-matching operations until no additional transformations occur, the additional set of pattern-matching operations including matching all additional patterns involving the instruction in the partially-decompiled block of computer code, and recomputing the expression vector after each of the additional transformations;

generating a fully-decompiled block of computer code from the generated partially-decompiled block of computer code, the fully-decompiled block of computer code having a semantic level that is raised; and

providing the fully-decompiled block of computer code for deployment on an architecture, the deployment including lowering the semantic of the computer code to a level that corresponds to a central processing unit (CPU) or graphical processing unit (GPU) supported by the architecture.

16. The non-transitory computer-readable medium of claim 15 , wherein the MIR code is created by creating static single assignment form for a computer source code, simulating multiple assignments for named variables within the computer source code, creating a hash-map, and populating the hash-map with the last definition of every named variable.

17. The non-transitory computer-readable medium of claim 15 , wherein the generating of the fully-decompiled block of computer code further includes, based on no transformations occurring, running a common subexpression elimination pass.

18. The non-transitory computer-readable medium of claim 15 , wherein the generating of the fully-decompiled block of computer code further includes, based on no transformations occurring, running a vectorization pass.

19. The non-transitory computer-readable medium of claim 15 , wherein the expression vector includes a set of bits for source fields and an additional set of bits for an opcode and wherein the matching of all patterns involving the instruction in the block of MIR code is performed on the bits corresponding to the expression vector.

20. The non-transitory computer-readable medium of claim 15 , wherein the semantic level corresponds to a higher native semantic level in which function calls are replaced with high-level native opcodes.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 23, 2025
From: UNITY IPR APS
To: UNITY TECHNOLOGIES APS
Reel/Frame 072926/0322 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 6, 2018
From: SEVIGNY, BENOIT
To: UNITY IPR APS
Reel/Frame 046798/0623 →
Continuity (1)
Provisional Application 62525101 · Jun 26, 2017
Cited By (6)
US 12,379,908 US 12,386,603 US 12,468,514 US 12,498,915 US 12,524,217 US 12,717,766