Linker optimization for compiled object oriented programs

Data processing: software development – installation – and managem – Software program development tool – Translation of code

Reexamination Certificate

Rate now

  [ 0.00 ] – not rated yet Voters 0   Comments 0

Details

C717S152000

Reexamination Certificate

active

06182283

ABSTRACT:

FIELD OF THE INVENTION
The present invention is directed to an optimization method performed during program compilation and linking for removing unused program components prior to linking the program executable.
BACKGROUND OF THE INVENTION
An object-oriented program is a program used to control the execution of a digital computer, where the program is created using a set of language tools, abstractions and constructs that support a particular form of user-defined types, called “classes”. Each such type associates a collection of declared data with a set of operations on that data. Variables, or instances, of such types in the running programs are called objects.
Classes can be related to one another by inheritance. The properties, behaviours, data, and operations of a parent, or “base”, class may be inherited without modification by some child, or “derived” class, or the behaviours, properties, and operations may be selectively refined under control of the programmer. When defining a derived class, one may start by building on an existing base class which is similar to the one to be created. The derived class inherits the implementation and behaviour of the base class, except as modified by amendments detailed in the derived class definition. Several classes can inherit the behaviours of a common parent, and a derived class may inherit from more than one base class. As examples, squares can inherit from rectangles, circles from ellipses, and stacks and queues from collections.
A member function is a function or operation defined as a behaviour of some user-defined type where that type participates in a hierarchy of other types. A virtual function is a member function with the added property that the specific identity of the virtual function, when invoked by name, is to be determined at execution time as a function of the type of the object with which it is associated. This is in contrast to member functions that are not virtual functions, whose specific identity, when invoked by name, is determined at compilation time as a function of the declared type of the variable used to access the object.
Each of several types in an inheritance hierarchy may contain its own definition of a member function where the name is common to all such types. If the function is a virtual function, as determined by and under the control of the programmer, then the function that is invoked at execution time will be determined from the type of the object which is the primary operand of the function instead of from the type of declared name that designates the object on which the function is to operate. Calls to virtual functions can be implemented as indirect calls through a table, called a virtual function table. Virtual function tables are created by the compiler for each user-defined type or class whose implementation requires such tables.
In the C++ language, the compiler defines an object data structure for each class. If a class introduces a virtual function or has an overriding function, then the compiler allocates a virtual function table for the class. In the C++ language, an override function is a member function of a class that has the same name, same number and same types of parameters as a member function declared with the virtual keyword in a base class of the class. The class object data structure contains the layout of the data members and a virtual function table pointer. The virtual function table pointer is initialized during run time to point to the virtual function table associated with the class.
A virtual function table for a class contains addresses of the virtual function members that are to be invoked at execution time when the class is the type of the object that is the primary operand of the function. The compiler and linker are jointly responsible for initializing a virtual function table with the addresses appropriate for its class. The virtual function table is used at run time to invoke the virtual functions indirectly. Each base class with a virtual function member has an associated virtual function table. Derived classes may have more than one virtual function table, since one may be associated with each base class, and their object data structures may, therefore, contain more that one virtual function table pointer. After memory for an object is allocated, the virtual function table pointers are initialized with the addresses of the associated virtual function table. Thus, all objects of the same class type point to the same virtual function tables. To implement the invoking of a virtual function, the compiler generates code to access the virtual function member through the virtual function table.
The C++ object oriented programming language, in particular, provides a powerful and popular virtual function feature. One virtual function overrides another function in accordance with specific rules that are language dependent. Under certain circumstances, the use of the virtual function feature can cause very large executable files to be generated for what should be relatively simple programs. This results in an unnecessary use of disk space for storing the program, and memory for executing it.
This situation commonly results from the established practice of using virtual function tables, pointed to by virtual function pointers embedded in the objects, in the runtime dispatching of virtual functions. These tables typically contain references to all virtual functions that might conceivably be dispatched in any application containing the object. In some applications this may result in unnecessarily linking in definitions for virtual functions that will never be called, and it is this redundancy that the present invention is directed to eliminating.
U.S. Pat. No. 5,247,678 issued Sep. 21, 1993 to Texas Instruments Inc. describes a multiprocessor system that links extended functions. The patent describes a dynamic linker that determines whether there are any functions loaded in the active memory which are not needed by the application program and, if so, discards them from the active memory. However, this patent does not teach a process where inactive functions are removed from the program itself as in the present invention.
U.S. Pat. No. 5,297,284 issued Mar. 22, 1994 to Microsoft Corp. describes a method simply for implementing virtual functions and virtual base classes in a compiler for an object-oriented programming language. This patent also does not consider the problem created by maintaining references to uncallable virtual functions in the compiled and linked program which of the present invention addresses.
U.S. Pat. No. 5,327,562 issued Jul. 5, 1994 to Microsoft Corp. describes a method for implementing virtual functions in a compiler for an object-oriented programming language. The patent does not describe any mechanism for removing references to uncallable virtual functions in the compiled and linked program.
By contrast, a primary purpose of the present invention is to remove uncallable virtual functions from a compiled and linked program.
A secondary purpose of the present invention is to avoid maintaining calls to virtual functions in a compiled and linked program when it can be determined that those virtual functions are uncallable.
To achieve this and other objects, the present invention provides means to reduce the negative impact of using virtual functions in the C++ language by identifying and removing references to unused virtual functions from the executable code. This is achieved by tagging the definitions and uses of virtual functions during compilation in such a manner that the linker can identify those functions which cannot be called in the application and so can ignore or exclude the definitions of those virtual functions.
Accordingly, in a computing environment having compiler means for compiling an object oriented source program into object modules and linker means for linking the object modules into an executable file provided with means including means for initializing virtual function tables for invoki

LandOfFree

Say what you really think

Search LandOfFree.com for the USA inventors and patents. Rate them and share your experience with other people.

Rating

Linker optimization for compiled object oriented programs does not yet have a rating. At this time, there are no reviews or comments for this patent.

If you have personal experience with Linker optimization for compiled object oriented programs, we encourage you to share that experience with our LandOfFree.com community. Your opinion is very important and Linker optimization for compiled object oriented programs will most certainly appreciate the feedback.

Rate now

     

Profile ID: LFUS-PAI-O-2536088

  Search
All data on this website is collected from public sources. Our data reflects the most accurate information available at the time of publication.