Dynamic loading and unloading for processing unit
Methods and apparatus are provided for enhanced instruction handling in processing environments. A program reference may be associated with one or more program modules. The program modules may be loaded into local memory and information, such as code or data, may be obtained from the program modules based on the program reference. New program modules can be formed based on existing program modules. Generating direct references within a program module and avoiding indirect references between program modules can optimize the new program modules. A program module may be preloaded in the local memory based upon an insertion point. The insertion point can be determined statistically. The invention is particularly beneficial for multiprocessor systems having limited amounts of memory.
1 . A processing system comprising a compiler implemented on a processing device, the processing device being operatively coupled to a local memory that is capable of storing program modules having code and data, the compiler being operable to perform a management function comprising:
analyzing the code and data of a given program module to determine references between code functions and groups of the data of the given program module, including identifying a number of original external references and a number of original internal references of the given program module; and
repartitioning the program module to produce one or more new program modules based on the analysis so that a number of new external references of the one or more new program modules is less than the number of original external references and a number of new internal references of the one or more new program modules is greater than the number of original internal references;
wherein the compiler selects the one or more new program modules as a best fit combination based on at least one of a size of the local memory and a data transfer size.
2 . The processing system of claim 1 , wherein the compiler determines at least one insertion point for the one or more new program modules to be inserted into a program.
3 . The processing system of claim 1 , wherein the one or more new program modules are further selected as the best fit combination by the compiler based on alignment.
4 . The processing system of claim 1 , wherein the management function of the compiler further identifies a plurality potential module groupings, compares the potential groupings against one another to maximize the number of new internal references and to minimize the number of new external references, and selects a best fit from the plurality of potential module groupings to obtain a best fit combination.
5 . The processing system of claim 1 , wherein the compiler utilizes the analysis to preload or unload the one or more new program modules in the local memory prior to execution.
6 . The processing system of claim 5 , wherein the compiler preloads a selected one of the one or more new program modules in the local memory if there is at least about a 75% probability that the selected program module is to be used.
7 . The processing system of claim 5 , wherein the compiler minimizes the preloading or unloading for the one or more new program modules which are loaded at runtime.
8 . The processing system of claim 5 , wherein the compiler chooses arbitrary load locations for selected ones of the one or more new program modules which do not have further calls.
9 . The processing system of claim 1 , wherein the compiler assigns at least one weighting factor to quantify the best fit combination.
10 . The processing system of claim 9 , wherein the at least one weighting factor includes weighting functional references with frequencies of calls, a number of times a given new program module is called and the size of the given new program module.
11 . The processing system of claim 9 , wherein the compiler reduces or sets the weighting factor to zero for a call in a given new program module if the call is a local reference.
12 . The processing system of claim 1 , wherein the compiler repartitions the program module into the one or more new program modules so that caller and callee modules fit into the local memory together.