Multi level virtual function tables
AssigneeMicrosoft Corporation
InventorDavid J. Hiniker
Life of this patent
Estimating the term…
Abstract
A multi level virtual function table uses a hierarchy of chunks or segments of virtual function tables to identify methods for a particular class. At least one level of indirection pointers may point to individual virtual function table chunks, which may be shared by multiple classes. In some embodiments, fixed size chunks of virtual function tables may be used, other embodiments may use variable sized chunks of virtual function tables. In just in time compiled code, virtual function tables may be limited to sharing across parent and child classes, while in pre-compiled code, more complex sharing may be used.
Claims20
A computer storage memory storing computer-executable instructions that when executed perform actions comprising:
- compiling source code to create object code, the source code comprising a plurality of classes, each of the classes having references to at least one method;
- for each of the classes, creating a temporary virtual function table, the temporary virtual function table including pointers to methods called within the classes;
- analyzing the temporary virtual function tables to identify portions of virtual function tables that may be shared by two or more of the classes;
- creating chunks of virtual function tables, each of the chunks of virtual function tables including a plurality of pointers, each of the pointers being a pointer to one of the methods;
- for each of the classes, creating a second level virtual function table having indirection pointers, each of the indirection pointers being a pointer to one of the chunks of virtual function tables;
- and
- for each method call within the object code, creating a first instruction to retrieve a chunk from the second level virtual function table, and creating a second instruction to retrieve a pointer to one of the methods from the chunk.
A system comprising:
- a processor configured to:
- compile source code to create object code, the source code comprising a plurality of classes, each of the classes having references to at least one method;
- for each of the classes, create a temporary virtual function table, the temporary virtual function table including pointers to methods called within the classes;
- analyze the temporary virtual function tables to identify portions of virtual function tables that may be shared by two or more of the classes;
- create chunks of virtual function tables, each of the chunks of virtual function tables including a plurality of pointers, each of the pointers being a pointer to one of the methods;
- for each of the classes, create a second level virtual function table having indirection pointers, each of the indirection pointers being a pointer to one of the chunks of virtual function tables;
- and
- for each method call within the object code, create a first instruction to retrieve a chunk from the second level virtual function table, and
- create a second instruction to retrieve a pointer to one of the methods from the chunk.
A system comprising:
- a processor configured to provide a compiler, the compiler comprising:
- a code generator configured to receive source code and create a first object code;
- and
- a code optimizer configured to optimize said first object code and create optimized object code, said code optimizer configured to perform a method comprising:
- for each class defined in said source code, creating a temporary virtual function table, said temporary virtual function table comprising pointers to methods called within said class;
- analyzing said temporary virtual function tables to identify chunks of virtual function tables that may be shared by two or more of said classes;
- creating chunks of virtual function tables, each of said chunks of virtual function tables comprising a plurality of said pointers;
- for each of said classes, creating a second level virtual function table having indirection pointers, each of said indirection pointers being a pointer to one of said chunks of virtual function tables;
- and
- creating said optimized object code by a method comprising:
- for each method call within said first object code, creating a first instruction to retrieve a chunk from said second level virtual function table, and creating a second instruction to retrieve a pointer to one of said methods from said chunk.
Dependencies are inferred from the claim text.