Embodiment
The demonstration equipment of the various new features of being discussed below being used to implement has been shown among Fig. 1.The storer 18 that Fig. 1 has described the target processor 13 that comprises destination register 15 and stored a plurality of software components 19,20,21, wherein sort memory 18 also is provided for fundamental block buffer memory 23, global register store 27 and the work of the subject code 17 that will translate storage.Software component comprises the code 21 after operating system 20, translator code 19 and the translation.Translator code 19 for example can be used as emulator, is used for the subject code of an ISA is translated into code after the translation of another ISA, perhaps as accelerator, is used for subject code is translated into code after the translation of identical ISA.
Translater 19, promptly implement version after the compiling of source code of translater, and the translation of the code 21 after the translation, the subject code 17 that promptly produced by translater 19, the 20-of binding operation system is such as the UNIX that runs on the target processor 13, typically microprocessor or other suitable computing machine-operation together.It being understood that in the structure described in Fig. 1 only be exemplary, and, for example can be by residing in the operating system or in its lower section code implementation according to software of the present invention, method and processing.Subject code, translator code, operating system and memory stores mechanism can be the known any various wide range of types of those skilled in the art.
In equipment according to Fig. 1, preferably, when the code 21 after translation is moving, in working time, dynamically executive routine code conversion.Code 21 after translater 19 and the translation as one man moves.The execution route of Translation Processing is a Control Circulation, comprises the following steps: to carry out translator code 19, and it translates into code 21 after the translation with a subject code 17, carries out the code 21 behind this block translation then; The end of the code 21 behind each block translation comprises the instruction that control is turned back to translator code 19.In other words, translation and the step of carrying out subject code then interweave, thus the part of a translation source program 17 once, and the code 21 after the translation of carrying out first fundamental block before the fundamental block of translation back.The translation elementary cell of translater 19 is fundamental blocks, this means, translater 19 is next fundamental block ground translation subject codes 17.The formal definition of fundamental block is to have just what a inlet point and the just code section of what a exit point, and it is restricted to single control path with block code.Therefore, fundamental block is the elementary cell of control stream.
In the processing of the code 21 after producing translation, by instruction sequences generation intermediate representation (" the IR ") tree of translater 19 according to subject code 17.IR tree is the abstract representation of the performed operation of the expression formula calculated and source program.Subsequently, according to the code 21 after the IR tree generation translation.For example, at title " Block Translation Optimizations for Program CodeConversion ", and the applying date is the common unsettled U.S. Patent application No.10/439 on May 16th, 2003, described the method and apparatus that is used to produce this IR tree in 966, its full content is hereby incorporated by reference.
After producing the IR tree, produce corresponding object code 21 according to the IR tree.The process that produces object code 21 according to class IR is known in the art.The end of the piece after translation inserts object code 21, so that abstract register is stored in the global register store 27.After object code 21 produced, it was performed then.
Translater 19 at first produces pieces 21 after the translation according to the theme of first fundamental block instruction 17, carries out the code after the translation that is used for first fundamental block then.At the end of first fundamental block, the code 21 after the translation returns to translater 19 with control, and translater 19 is translated second fundamental block then.Carry out the code 21 after the translation be used for second fundamental block then.At the end of carrying out second fundamental block, the code after the translation returns to translater 19 with control, and translater 19 is translated next fundamental block then, or the like.
So, have two kinds of dissimilar codes carrying out with interleaving mode at the source program of 19 times operations of translater: the code 21 after translator code 19 and the translation.Translator code 19 is implemented to produce according to the high-level source code of translater 19 before working time by compiler.Code 21 after the translation is produced according to the subject code 17 of the program that just is being translated in the whole service time by translator code 19.
Similarly, the expression of between code 21 compositions after translater 19 and the translation, dividing the theme processor state.Translater 19 is stored in various explicit programming language devices with the theme memory state, such as variable and/or object, in; The compiler that is used for compiling translater is determined how enforcement state and operation in object code.Code 21 after the translation implicitly is stored in the theme processor state in destination register and the memory location by relatively, and it is by the target instruction target word direct control of the code 21 after translating.
For example, the rudimentary expression of global register store 27 is the zone of the storer that distributed.By preserving between defined memory area and a plurality of destination register and recover (restore), this is how code 21 after the translation sees abstract register and mutual with it.Yet in the source code of translater 19, global register store 27 is data arrays, or can be more senior by the object of access and operation.Code 21 as for after the translation does not just have senior expression.
In some cases, the theme processor state is static in translater 19 or can determines statically that it directly is encoded into the code 21 after the translation, rather than is dynamically calculated.For example, translater 19 can produce according to the instruction type of last flag affects (flag-affecting) instruction and the code 21 after the translation of appointment, this just means that if the instruction type of last flag affects instruction changes, then translater is that identical fundamental block produces different object codes.
Translater 19 comprises the data structure corresponding to each fundamental block translation, it is especially for promoting translation optimization, such as the fundamental block of expansion, be equal to the translation state optimization of piece (isoblock), chunk and buffer memory, as U.S. Patent application No.10/439, described in 966, and its full content is hereby incorporated by reference.Fig. 2 has described this fundamental block data structure 30, and it comprises theme address 31, object code pointer 33 (i.e. the destination address of the code after the translation), translation prompting 34, enter with exit criteria 35, general introduction tolerance (profiling metric) 37, to the reference 38,39 and the inlet register mappings 40 of the data structure of former and follow-up fundamental block.Fig. 2 has also described fundamental block buffer memory 23, and it is the set of fundamental block data structure, for example by 30,41,42,43,44 of theme address index ...In one embodiment, the data structure corresponding to the fundamental block after the certain translation can be stored in the C++ object.When the translation fundamental block, translater 19 is created new fundamental block object.
The theme address 31 of fundamental block is the start address of this fundamental block in the storage space of source program 17, if promptly source program 17 runs on the theme framework, and the present memory location of fundamental block.It is also referred to as the start address that is the theme.Though each fundamental block is corresponding to a theme address realm (one of each theme instruction), the theme start address is the theme address of first instruction in the fundamental block.
The destination address 33 of fundamental block is the memory location (start address) of the code 21 after the translation in the target program.Destination address 33 is also referred to as and is object code pointer, perhaps target start address.In order to carry out the piece after the translation, translater 19 is used as by dereference (dereference) destination address to call the function pointer of the code after (control transmission is given) translation.
Fundamental block data structure 30,41,42,43 ... be stored in the fundamental block buffer memory 23, it is the thesaurus by the fundamental block object of theme address tissue.When the code after the translation of fundamental block 21 finished to carry out, it returned to translater 19 with control, and also the value of purpose (follow-up) the theme address 31 of fundamental block was returned to translater.In order to determine whether follow-up fundamental block is translated, translater 19 compares the theme address 31 of the fundamental block (i.e. those that have been translated) in purpose theme address 31 and the fundamental block buffer memory 23.Translation is also carried out the fundamental block that also is not translated then.Carry out and be translated the fundamental block of (and have compatible entry condition, as described below) simply.As time goes on, the many fundamental blocks that run into will be translated, and this just makes the translation cost that increases progressively reduce.So it is faster that translater 19 becomes as time passes, because need the piece of translation fewer and feweri.
Subregion
In a preferred embodiment, translater 19 adopts choice of technology theme instruction set, after this is referred to as theme instruction group (SIG), so that each SIG is associated with the translater data structure (for example fundamental block) of different sets and the object code 21 after the translation.After this SIG is referred to as subregion with its relevant translater data structure and the combination of object code 21.Single SIG comprises the theme instruction in one or more theme address realms.Instruction from single theme address or a plurality of theme address realms can be included among several different SIG.Piece after the translation can include only the translation from a SIG.
The expression that the partitioning technique that translater 19 is utilized will be controlled the translater 19 of stream is divided into many groups theme instruction (SIG) that may be modified together.In some cases, these subregions are corresponding to different sink and the obj ect file of forming source program, thereby will arrive the theme storer as the partition map that the storehouse is created and replaced, and abandon in the back.When to revise its oneself subject code 17-and after this be referred to as " revising certainly "-source program when translating, partitioning technique can be particularly useful for translater 19.By with subject code 17 with and corresponding translation after object code 21 be divided into subregion, when the related subject code of affected one or more subregions is modified and does not influence in the useful information (for example translation) that its SIG does not have to set up in affected other subregion, can abandon these affected one or more subregions.If do not use this subregion,, need abandon all existing translations, even those are not subjected to the translation of code revision influence then in response to each code revision.
In a preferred embodiment, translater 19 keeps the data structure of isolating, thus by SIG with translation data structure organization Composition Region.This isolation makes it possible to once abandon and discharges the many block translations (and related data structure) that are included in the single subregion, rather than the lower floor of the code behind the ergodic translation represents, to search affected translation and with one of their each deletion.For example, in one embodiment, translater 19 keeps independent fundamental block buffer memory 23 for each subregion.
In a preferred embodiment, translater 19 definition SIG make the theme address among the single SIG form the address of single successive range.
In another preferred embodiment, translater 19 definition SIG make that the theme address among the single SIG comprises: the continuation address of the single scope that (1) may be modified together; The address of the additional range that (2) unlikely is modified.So just make single translation comprise instruction, thereby and form the translation of more optimizing from scope (1) and scope (2).
The step of being implemented in revising subregion by translater 19 has been described in Fig. 3.When subject code 17 is revised other subject code, in step 100, detect " modification incident " by translater 19.Definition modification incident is with corresponding to particular topic address realm (override, delete or other are modified the scope of the subject code that is influenced).Translater 19 must at first detect subject code when and where by modification certainly (that is, which subject code is carried out is revised, and which subject code is modified).The modification incident is any incident that subject code 17 is modified.Do not comprise the wherein situation of subject code 17 modification subject datas from revising code.Certainly the modification of subject code 17 can have various ways, includes, but are not limited to: (i) with File mapping (for example mmap () system call) in storer; (ii) from storer, remove file (for example munmap () system call); (iii) make memory area can carry out (for example using mprotect () system call to change its authority).
Under the situation of system call that use is known-revise such as mmap (), munmap () or mprotect ()-carry out subject code 17, translater 19 can detect in subject code 17 this system call all call, to detect the modification incident.Translater 19 also can detect subject code 17 by other mechanism and revise.For example, many theme processor requirements, before carrying out the code that has been modified, source program is the Instructions Cache of refresh process device (I-buffer memory) at first.Especially, the PowerPC framework has the specific instruction that is used for this purpose, and (the Instructions Cache piece is invalid: Instruction Cache Block Invalidate), and other framework can use the particular system that is used for identical purpose to call " ICBI ".On the framework with this cache flush requirement, translater 19 can detect the modification incident by the example that detects specific instruction (or particular system calls).
In another preferred embodiment, translater 19 uses the feature of destination OS 20 to monitor all write operations that carry out corresponding to the target memory zone of subject code, to detect the modification incident in step 100.In some system, system call mprotect () allows the specific region of translater 19 storeies to be set to " read-only ".Other system can utilize the function of the function that is equal to mprotect () system call, is defined as read-only with the specific region with storer.Any trial that writes to read-only zones all triggers the signal that is translated device 19 detections.Signalisation translater 19: subject code 17 occurred and revised, and translater 19 uses signal content to determine which theme address just is written.Afterwards, translater 19 allows to write normally then in the scope (being affected theme address) that detects modification incident and identification modification.
In another preferred embodiment, for the memory write operation after each translation in the subject code 17, translater 19 produces the specific objective code sequence, and it checks that whether write address is corresponding to subject code 17, rather than corresponding to subject data, in step 100, to detect the modification incident.
In each of various embodiments of the invention, after detecting the modification incident, revise and cause in step 102, creating new subregion, its SIG comprises the theme instruction in the scope that is modified.In addition, in step 104, revise existing subregion then, to consider (accountfor) new subregion of creating.In revising existing subregion, translater 19 is implemented the step described in Fig. 4.When because detected modification incident, when translater 19 is created new subregion, its at first in step 110, determine the SIG that newly creates the division whether with any existing subregion in SIG intersect.When finding that SIG with existing subregion does not have crossover, in step 116, keep existing subregion complete.If the SIG that any existing section post has comprises the theme address of intersecting (crossover) with the scope that is modified, then all these crossing subregions are destroyed in step 112, and in step 114, created again, only under some situation that following application additional information is optimized.For ruined each crossing subregion, in step 114 the new residue subregion of theme address creation of remaining one or more scopes among the original SIG, make new residue subregion comprise the original SIG that intersects subregion and deduct the crossing scope that is modified.When subregion was destroyed, existing object code 21 translations of all that are associated with this subregion all were dropped.The subregion of each new establishment is the object code 21 after the fully empty translation at first, this means, must be from the working area (scratch) translation is run into subsequently from any subject code 17 of the SIG of this subregion.
Fig. 5 A and 5B described from the example of one group of existing new subregion of partition creating and with the modification incident of the some of them crossover of these subregions.For the simple explanation example is provided, in the SIG of Fig. 5 A and 5B description, the theme instruction set that is used for each SIG forms single successive range, but the essence of this technology is not to want each SIG comprise single successive range.Before making amendment, the SIG of four subregion A, B, C and D is present in the theme address space, as shown in Fig. 5 A.Subject code 17 in this example is revised the scope that point 50 from storer extends to a little 52 theme coded address then.Modification scope 54 intersects with the SIG of subregion A and C, and fully the SIG of subregion B is surrounded.Fig. 5 B has described the change of existing section post being carried out in response to the modification incident.Be whole scope 104 M that creates the division that is modified.Subregion A and C are destroyed, and are the remainder of the A that not do not intersect with modification scope 104 and C create the division respectively A ' and C '.Subregion B is destroyed, and its SIG is comprised by new subregion M fully.The scope of subregion D does not have and modification scope 54 crossovers, and it remains unaffected.
In another preferred embodiment of translater 19, use inertia subregion allocation optimized technology by partitioning technique, to improve the performance of translater 19.In order to save storer, when creating the division, do not distribute the complete data structure of a subregion.On the contrary, the inactive partition of the SIG of initial creation reserved partition, but translater 19 does not initially distribute any lower floor translation data structure and storer.In this way, initial inactive partition is the empty framework subregion that only keeps specific SIG basically.Being translated device 19 is identified as the zone that just is modified the theme storage space that incident revises and can in fact never be translated into object code 21 in some cases.This may be because the theme memory area corresponding to data, or because the theme memory area corresponding to the code that never is performed.Inactive or the framework subregion of initial creation has been avoided the expense of the memory resource of waste.
When 17 actual being translated of any subject code among the SIG of subregion, inactive partition becomes alive or movable subregion, and the initialization partitioned data organization.Correspondingly, corresponding to the data segment of source program (for example, as data by the file of mmap (), and the file never carried out of source program as code) the modification incident make new inactive partition be created, but do not distribute any lower floor translation data structure and memory area.Has only the complete data structure that when translation occurring in the theme address realm at subregion, just realizes subregion.Because inactive partition does not comprise the translation of subject code, thus can create, delete or realize them, and the performance cost that does not need storer and be associated with active partition.
In some cases, translater 19 can distribute the large memories zone for new subregion, with 21 translations of storage object code.Object code 21 preferably is assigned to continuous, to avoid unnecessary segmentation.Translater 19 more may can make object code 21 continuous, if it uses the large memories zone.Error-detecting to subregion (promptly not corresponding to the modification incident in the theme memory range that can carry out subject code) sometimes may consume valuable memory resource, and without any purpose.By just just distributing translation data structure and storer in subject code 17 actual being translated in subregion (and execution), the inertia subregion distributes makes translater 19 can avoid because the negative influence of the false positive that the modification event detection mechanism that is associated with subregion is produced.
In another preferred embodiment, translater 19 has the interpreter function, with explanation subject code 17, rather than translates it.This just makes translater 19 can postpone the translation of subject code 17, thereby avoids distributing the subregion that is associated with this subject code 17.In the applying date is that on September 4th, 2003, title have been described interpretation method and the equipment of being convenient to this interpreter function among the common unsettled UK Patent Application No.03 20716.4 of " Method and Apparatus for PerformingInterpreter Optimizations during Program Code Conversion ", and its full content is hereby incorporated by reference.
In another preferred embodiment, 19 pairs of subregions of translater are handled the cuttable partition zone optimizing technology of using, to improve the performance of translater 19, wherein with the SIG reduction of subregion-rather than delete this subregion-to the littler SIG that comprises the actual address set of using in the subregion in response to the modification incident.The littler SIG of reduction does not comprise the defined scope of modification incident.Initially, in response to detecting the modification incident, create new subregion, wherein SIG comprises having its value by the start address of revising scope definition and the scope of end address.Yet in operation, the actual range of the theme address that is translated can be than defined subregion narrow range.Comprising that all reality in the subregion have been translated or have been labeled is used for the SIG of use that the SIG of the theme address of translation in the future is called " movable SIG " or subregion.The residue SIG of the theme address that also is not translated in the subregion is called " non-movable SIG ".In order to optimize the performance of translater 19, by deleting nude mobility range address portion at least, the scope of the SIG of subregion can be tapered to the Geng Xiaoji that comprises the address of its scope of activities the movable SIG from its initial defined address set corresponding to the crossover between non-movable SIG and the modification scope.
Though the notion that can implement to reduce subregion by any multiple mode, in a preferred embodiment, translater 19 keeps the address of the scope after scope of activities or the translation in the SIG of each subregion.When creating the division, its movable SIG initially is empty.At translate duration, when each theme instruction was translated, the movable SIG with current subregion compared with its theme address (" address after the translation ").If the address after the translation is outside current active SIG, expansion activity SIG then is to comprise the address after the translation.Like this, movable SIG will increase along with the carrying out of subject code translation.
Can reduce in the partition zone optimizing technology in execution, translater 19 is implemented in the step described in Fig. 6.When the device 19 of serving as interpreter detects the modification incident in step 200, create new subregion in step 202, wherein SIG comprises the modification scope.Translater 19 in step 204, determine then the modification scope whether with the initial defined SIG crossover of existing subregion.When finding not have crossover, the existing subregion that has defined is kept perfectly.If there is crossover, then translater 19 in step 208, determine then the modification scope in fact whether with the movable SIG crossover of subregion.If the modification scope not with movable SIG crossover, translater 19 can change the size of the initial defined SIG of subregion simply in step 210 so, and does not delete the translation data structure in the subregion.Reason is, though initial defined subregion SIG represents the possible range of subregion, as the last modification incident that creates the division defined, movable SIG represents the theme address set after the actual translation.Therefore the modification with movable SIG crossover does not make any translation in the subregion invalid, because translater 19 knows that the theme address after the translation is different with the theme address that is modified, and therefore not influenced by it.The size of SIG by changing subregion, to comprise scope of activities at least, the translation that is stored in the subregion can be maintained in this subregion, and does not need deleted.On the other hand, if the movable SIG crossover of modification scope and subregion, translater 19 must be deleted whole subregion in step 212 so, as mentioned above.
Referring now to Fig. 7 A and 7B, it has illustrated and can reduce the partition zone optimizing technology.Identical with shown in Fig. 5 A and the 5B basically at Fig. 7 A and the subregion described in the 7B is except subregion A and C comprise respectively the theme address 56 and 58 of scope of activities.Before revising, there are four subregion A, B, C and D, as shown in Figure 10 A.The point 50 that subject code is revised then from storer extends to a little 52 subject code address realm.Modification scope 54 intersects with the initial defined subregion scope of subregion A, but the modification scope is not crossing with the scope of activities 56 of subregion A.Fig. 7 B has described the change of existing section post being carried out in response to the modification incident.Creating the division after the M for modification scope 54, the scope that can reduce subregion A, and do not influence translation among the subregion A.On the contrary, can see in this example that modification scope 54 intersects with the scope of activities 58 of subregion C.So the scope that can not reduce subregion C simply must be destroyed subregion C, therefore be the new subregion C ' of remainder establishment that does not intersect with modification scope 54 of subregion C.Destroy subregion B, and its scope is comprised by new subregion M fully.Subregion D remains unaffected.
Referring now to Fig. 8 A-8E, described is cuttable partition zone optimizing technology, wherein has SIG 300, and it comprises a plurality of activities and nude mobility range.Fig. 8 A has described initial defined SIG 300, as its in theme address space 302 as shown in.SIG 300 comprises the subject code address 304 and 306 of two scopes.As shown in Fig. 8 B, each subject code address realm 304,306 comprises the subject code address 308,310 of scope of activities respectively.All the other theme addresses among the SIG 300 are the non-movable subject code addresses that are arranged in nude mobility range 312,314 and 316.In case the modification incident occurs, so subject code is revised the scope of subject code address, to create new SIG 318, described in Fig. 4 C.The scope of the new SIG 318 that creates and the initial defined subject code address realm of SIG 300 304 intersect, and wherein the scope of SIG 318 does not intersect with its scope of activities 308, and only intersects with its nude mobility range 314.After determining the range limit of SIG 318, can as shown in Fig. 4 D, reduce theme address realm 314, and not influence the translation in the scope of activities 308 of SIG 300.Theme address in the scope 320 that intersects by deletion and SIG318 reduces nude mobility range 314, with the nude mobility range 314 that produces reduction '.Fig. 4 E has described in response to the modification incident, to initial defined theme address realm 304,306 modifications of being carried out of SIG 300.As shown in the figure, as described above initial defined theme address realm 304 is tapered to comprise scope of activities 308 and nude mobility range 312,314 ' theme address realm 304 '.The influence that theme address realm 306 keeps not created new SIG 318.
Translater 19 can detect most of modification incidents in decoding, but may not know the actual subject address that will revise, the code 21 after carrying out translation.So the device 19 of serving as interpreter detects during decoding that subject code 17 is revised or during for the indication that occurs revising, translater 19 finishes the translation of current blocks, and and then inserts notice after the current block, will revise event notice to translater.
In an embodiment of translater 19,, in this translater 19, implement partitioning technique by means of specific.Though specific be those they can be corresponding to the particular topic address do not represent the piece of the translation of subject code.By contrast, the translation piece is represented the translation of the particular topic code sequence that begins with specific initial theme address.On the contrary, specific specific operation that comprises translater 19, it was inserted in the object code stream at translate duration before reality is carried out these pieces.In fact, specific is the certain translation structure of carrying out the operation of light weight translater, and it can be set at the specified point in the object code control stream, does not get back to the translater circulation and do not need high cost ground that content is switched out from object code.
Specific comprises pseudo-object code, rather than common object code.Common object code is represented the translation of certain subject code sequence.Pseudo-object code is made up of artificial (promptly untranslated) object code sequence, writes and is compiled to have the identical calling convention of object code that is produced with translater 19 in its object code that write direct or with high-level programming language (for example C++).Specific example is included in the notice piece and the Border Protection piece of this discussion.
During the control of the program after in a preferred embodiment, translater 19 will be called as " notice piece " specific and be inserted into translation on the point that and then comprises after revising the piece of subject code is flowed.The notice piece is " specific " translation structure, because be different from the translation piece, it does not represent the translation of any particular topic code, but expression modification incident.The actual subject code 17 of carrying out modification is translated the part as current block.The notice piece is inserted into as the follow-up of current block.So after and then carry out revising in the current block after translation, notice piece notice translater 19 is subsequently carried out suitable operation, with in response to this modification (being that subregion is regulated).Subject code 17 in the follow-up new piece that becomes the notice piece after the translation modification incident.
When operation in object code 21 during the arrival notice piece, the theme address realm of the code that is modified is notified to translater 19.Translater 19 uses this information to create new subregion, and it also can change or destroy existing subregion, as mentioned above.
Comprise from the piece of revising subject code (predecessor of notice piece) and after and then discerning the modification incident, finish, can be because revise so that current subregion is invalid.The subject code that is modified can be next theme instruction, the version that it can require the translater translation and carry out the new modification of this instruction, rather than the existing translation of execution legacy version.For example, on the PowerPC framework, after the cache flush instruction, piece must finish.So, when detecting the modification incident, finish the current block of translation, and insert the notice piece as follow-up.
The notice piece also with the copy of current theme address and compatibility list from its former block transfer to its successor block.After notice occurring,, in successor block, restart translation in next theme instruction.If owing to operation has destroyed current subregion, then notify piece also to carry out safe transition in the new subregion of replacing it, use the theme address and the compatibility list that are copied to come initialization successor block in new subregion.This has been avoided quoting at the transition period of new subregion the problem of data that may be deleted.
The translation piece must finish in partition boundaries, make the establishment of scoring area may have to otherwise the negative effect of the optimization that can on the major part of code, carry out.Because formed subregion, otherwise the code section that will be translated together is translated as independent piece, turns back to translater round-robin number of times so just reduced the scope of optimizing and increased.For example, optimize by partition boundaries restriction, such as common unsettled and transfer extension blocks and chunk optimization described in the assignee's identical with the present invention the U.S. Patent application No.10/439966, it is hereby incorporated by reference.Therefore, for the known source program of not revising its oneself subject code 17, can be applied to current partitioning technique with a kind of optimization that improves translater 19 performances is exactly, and all theme storeies are aggregated in the single subregion, makes all subject codes 17 be comprised in the subregion.
Can implement the polymerization of theme storer in several ways.In a kind of mode, the known one group of storehouse that is not modified in normal operations is aggregated in the single subregion.Source program is needed, be not that independent subregion is put in all the other storehouses of this invariant set part as common.Can more effectively translate with regard to making like this translation in the constant subregion, keep simultaneously response remaining, the subject code in the storehouse that may change is revised and the ability of other subject code.
In the another kind of mode of theme storer polymerization, the zone (1) that will comprise the theme address of one group of known subject code that is not modified in normal operations joins among the SIG of all subregions that comprise other zone (2) that may change dividually, so just make more desirably to produce the translation that is sent to the control stream of invariant region from the possible region of variation of subregion, but the ability that the subject code of the region of variation of the subregion of maintenance response is simultaneously revised.Revise if comprise the subject code in the whole zone of subregion (2), subregion is deleted with integral body, to save storer.
The scope of subregion must suitably define, because the subregion scope influences the performance of translater 19.If subregion is too little, control stream must constantly pass through Border Protection (as described below).If subregion is too big, it is invalid that small code revision needn't make that the code after the more most translation becomes.When selecting partition size, should consider this compromise appropriate balance, because it is related to the performance of translater 19.If determine the particular zones that is just being produced performance is had negative effect, then can be to the subregion optimizing application.Acquiescently, determine partition size by revising event detection mechanism.For example, if translater 19 detects the mmap () of runtime routine library, create the new subregion that comprises whole storehouse so.
Can be applied to subregion is exactly the subregion polymerization with a kind of optimisation technique that improves translater 19 performances.For example, but PowerPC ICBI cache flush instruction makes that a page of execute store is invalid.Yet if once revise a plurality of pages of subject code 17, source program can comprise the ICBI instruction of several successive, and it makes the invalid in abutting connection with multipage of storer.Under the situation of above-mentioned subregion mechanism, will produce the pagewidth subregion of a plurality of adjacency like this.Like this, a kind of optimization of subregion mechanism detects the cache flush instruction that continues exactly, and the scope that will revise engages the SIG that becomes " polymerization " subregion.
In an embodiment who implements subregion polymerization optimization, when creating new subregion, whether translater 19 inspection exists so existing subregion (promptly not being all the other subregions of creating as the secondary product of creating new subregion), and its SIG is adjacent and in its front with the SIG of new subregion in subject code.If have, the range expansion of the SIG of the last existing subregion scope to the SIG that comprises new subregion can be got up two subregion polymerizations effectively.After realizing polymerization, new subregion does not need to have independent expression.
Border Protection
In a preferred embodiment, translater 19 inserts the additional level of indirection that is used for the control stream of walking between two subregions.Translater 19 uses specific placeholder, is referred to as Border Protection herein, is used to contact the piece of partition boundaries, thereby whether former piece can be checked the successor block after the previous translation and also exist.Make in this way, when former piece follow-up deleted, can notify them effectively.Translater 19 strides across each point of partition boundaries at the control stream of source program, perhaps is referred to as boundary intersection, inserts a pair of Border Protection structure.This comprises Border Protection and withdraws from Border Protection and enter Border Protection.To withdraw from Border Protection be after former piece and specific of adding in the subregion identical with this predecessor's piece.Entering Border Protection is to withdraw from the data structure that Border Protection piece and successor block couple together accordingly.For the piece after the translation in the same subregion, control stream directly from former block transfer to successor block.For the piece in the different subregions (being boundary intersection), to withdrawing from Border Protection, utilization enters Border Protection and locatees successor block control stream then, withdraws from Border Protection and passes control to successor block from former block transfer.
Enter the placeholder of Border Protection, wherein enter the reference of withdrawing from Border Protection copy of Border Protection storage them as translater 19.Each data structure that withdraws from Border Protection also comprises the reference that it is entered the Border Protection copy.Also there is the illustrative successor block in front in the execution of withdrawing from Border Protection with regard to checking.The Border Protection piece is used for the bookkeeping function by the explicit representation that the subregion point of crossing is provided.When serving as interpreter device 19 deletion particular zones, it travels through interior each of this subregion and enters Border Protection, to search the corresponding protection of withdrawing from.Because subregion is deleted, each this copy of Border Protection that withdraws from is with reference to being set to sky.In certain embodiments, translater 19 is stored the Border Protection that enters of the given subregions that are useful on, thereby when subregion is deleted, can travel through them effectively.For example, in one embodiment, translater 19 is kept for the Border Protection that enters of each subregion and tabulates, and wherein as long as establishment or deletion enter Border Protection, just this tabulation is upgraded.
Correspondingly, when Border Protection was withdrawed from execution, it was by checking that simply its oneself copy is with reference to verifying that it follow-uply also exists.If defined reference, the so effectively follow-up existence after the translation, and control is sent to successor block by respectively entering Border Protection, (thereby also being sent to follow-up subregion).The successor block after Border Protection is not known effectively translation is withdrawed from the ifndef reference so, exists successor block and its deleted before promptly, and perhaps this withdraws from that Border Protection also never is performed and therefore follow-uply also never is determined.The reference of ifndef copy, then the fundamental block buffer memory by checking subregion separately or obtain new Border Protection and the successor block of entering by the translation successor block.From withdrawing from the angle of Border Protection, be translated and deleted then successor block does not have different with the successor block that never is translated.
Make the processing of scoring area deletion more effective by Border Protection to the explicit representation of resulting partition boundaries point of crossing.In order to delete subregion, all references to deleted block (being the piece of previous translation in the deleted subregion) must be discerned and cancel to translater 19.Do not have certain thin note mechanism, such as Border Protection, translater 19 needs the piece after a large amount of translations of traversal, with discern in the deleted subregion which piece have follow-up so that deletion is dropped follow-up reference to these.Except allowing the processing of deletion subregion become more effective, the Border Protection piece has promoted the boundary intersection of thread-safe, following with reference to multithread programs discuss like that.
In order to delete subregion, translater 19:(i existing under the situation of Border Protection) put sky (void) and point to the copy that all that will delete subregion withdraw from protection and link; (ii) to deleting the follow-up subregions notice of all of subregion: what can abandon them correspondingly enters protection; (iii) delete all translation structures and the object code 21 that belongs to deleted subregion.In first step (i), all in 19 pairs of subregions of translater enter Border Protection and travel through, and the Border Protection copy is withdrawed from their outside reset, and effectively to all former subregions notices: deleted subregion is put sky.Second step of subregion deletion (ii) in, all in the traversal subregion withdraw from Border Protection, with to follow-up subregion notice: what can abandon them correspondingly enters protection.In one embodiment, withdraw from Border Protection, carry out second step by each that travels through deleted subregion.In another embodiment, come in the index subregion all to enter protection by comprising the corresponding former subregion that withdraws from protection.In this case, deleted subregion only need be notified each follow-up subregion once, and each follow-up subregion can be discerned the corresponding inlet point that will delete then.
Multithread programs in the subregion
When using subregion, the multithreading source program provides difficulty to translater 19, just must carry out the subregion deletion in the mode of thread-safe.Particularly, during given subregion is just deleted, must prevent that thread from entering this subregion.Guaranteed that like this control always enters effective translation, and never entered deleted or invalid piece.After deleting or creating the division again, can allow thread to enter (empty again) subregion then.
In a preferred embodiment, translater 19 uses single overall mutual exclusion (" overall subregion locking ") with specific division operation serialization, to comprise: (i) control stream redirect between subregion (being boundary intersection); And (ii) delete subregion, and create the division again in adaptable place.So, withdraw from Border Protection and must be sent to it in control and correspondingly obtain overall subregion locking before entering Border Protection.Similarly, the notice piece must obtain overall subregion locking before destroying subregion.For needs deletions and the modification incident of creating one or more subregions subsequently again, under the protection of overall subregion locking, automatically carry out all this deletions and create again, just sequentially carry out all these operations and do not need to discharge and lock.Translater 19 is kept the partition identifier that is used for each thread, and it is changed when being controlled at when transmitting between the subregion.Keeping between overall subregion lockup period, by Border Protection to carrying out this change.
In another preferred embodiment, translater 19 uses single overall mutual exclusion (" overall subregion locking ") that particular zones is operated serialization, comprising: (i) create entering Border Protection; (ii) delete subregion, and create the division again in adaptable place.So, withdraw from Border Protection must its can obtain new enter Border Protection and successor block or create again previous delete enter Border Protection and successor block before obtain overall subregion locking.Under the situation of subregion deletion, the notice piece obtained overall subregion locking before deletion, and deleting mechanism is at first carried out traversal it is entered the operation of Border Protection set then, to withdraw from deletion copy reference the piece from corresponding.This just requires, and existing under the situation of carrying out other thread, can remove the link of single copy reference safely.In case all enter Border Protection and have all used this operation, then, must finish remaining deletion action, and discharge overall mutual exclusion any withdrawing from before Border Protection can obtain new follow-up among the SIG that deleted section post has of revising like this.
Referring now to Fig. 9 A and 9B, the control stream of wherein having described the program after the translation strides across partition boundaries, has and do not have the partition boundaries of passing through respectively.Fig. 9 A is depicted as when application partition not or when control stream is also stayed in the single subregion, the control stream of the particular source program in the translater 19.Control is sent to theme piece B 403 from theme piece A 401, is sent to theme piece C 405 then, is sent to theme piece D 407 then.For the program subject code, piece B 403 is the follow-up of piece A 401, and piece C 405 is the follow-up of piece B 403, and piece D 407 is the follow-up of piece C 405.
Exist between the theme piece B of Fig. 9 A and the theme piece C or the situation on the border 409 of creating the division under, when passing partition boundaries 409, the control Border Protection of must flowing through is right, as shown in Fig. 9 B.Piece A 401 and B 403 are in subregion 415, and piece C 405 and piece D 407 are in subregion 417.In the source program after translation, control directly is sent to the piece B 403 from piece A 401, because piece A 401 and B 403 are in same subregion 415.Yet the control from piece B 403 to piece C 405 transmits and strides across partition boundaries.So control is sent to from piece B 403 and withdraws from Border Protection piece 411.As mentioned above, withdraw from Border Protection 411 and check that its corresponding Border Protection 413 that enters does not also have deleted.In multithread programs (following), withdraw from Border Protection and also obtain overall subregion locking, thereby can stride across partition boundaries in the mode of thread-safe.Control is sent to it and enters Border Protection 213 accordingly from withdrawing from protection border 411 then.Carry out and entered into subregion 417 now.In multithread programs (following), enter the partition identifier that Border Protection changes current thread, at present in subregion 417, and discharge overall subregion locking then with the reflection thread.In case in subregion 417, control is sent to piece C 405 from entering Border Protection 413, and directly is sent to piece D 407 from piece C 405 then.
Memory management
Memory management be among each embodiment of dynamic binary translator 19 the emphasis of wanting consider.For translate be used in the program of carrying out on a kind of architecture higher to allow on another kind of architecture, to carry out to the demand of storer.Optimize when introducing-such as being equal to piece (isoblock), extension blocks and chunk, described in common unsettled U.S. Patent application No.10/439966-time, storage requirement is higher because each these optimize the possibility that the sequence that all produces a subject code 17 can be represented by a plurality of translations.The modification incident requires the deletion subregion, and therefore requires deletion all translation datas (being block structure and object code) wherein.
In a preferred embodiment, translater 19 provide its oneself the subject code subregion is carried out the memory management subsystem of mirror image.Subregion is used for by the pairing subject code of all translater data structures 17 zones all translater data structures being divided into groups.The part subject code 17 that might be disabled together forms subregion: therefore all relevant translater data structures are present in the intact target memory zone of identical definition.If subregion is disabled, then can wholely discharge all translation datas (translater structure and object code) that are associated with this subregion, needn't discharge each structure individually.
In this specific embodiment, translater 19 is carried out all memory allocation by the memory source object.Each subregion has a corresponding memory source.Memory source by conventional methods-such as mmap () system call-obtain storer from operating system, but not to be integral body carry out for they.Other translator code (comprising pseudo-object code) obtains storer (being less amount ground) as required, but from each partitioned memory source, rather than directly obtain from operating system.Like this by quantity that reduces lower floor's system call relevant and the performance that frequency has improved translater 19 with storer.Memory source also is provided for the function of the full content in a refresh memory source.Memory source can discharge lower floor's storer or implements to refresh by abandoning its all " distribution " of having carried out from this storer (be about to record (slate) removing, keep lower floor's storer simultaneously) simply by reality.
The memory sub-system of storer 19 is also simplified the processing of deletion subregion.In order to delete subregion, translater 19 is necessary: the copy link of withdrawing from protection of (i) putting empty all former subregions; (ii) notify all follow-up subregions: what can abandon them correspondingly enters protection; And (iii) delete all and translate structures and the object code that belongs to subregion.If there is not the memory management subsystem, translation structure and object code that third step (iii) requires translater to travel through each subregion are gathered, to discharge each structure respectively.If the use memory sub-system can pass through refresh memory source simply, once discharge all partitioned organizations.
Although illustrated and described a few preferred embodiment, those skilled in the art are understandable that, do not break away from as defined scope of the present invention in appended claims, can carry out various changes and modification.
Should be noted that apply for simultaneously with the application or application before and all openly give the public's All Files and document, and the content of all these files and document all is hereby incorporated by reference with this instructions.
Disclosed all features in this instructions (comprising any appending claims, summary and accompanying drawing), and/or the institute of disclosed so any method or processing in steps can combination in any, except some the conflicting combination in these features and/or the step at least.
In this instructions (comprising any appending claims, summary and accompanying drawing) disclosed each feature can be identical by being used for, be equal to or the replacement feature of similar purpose replaces, unless outside offering some clarification on.So, unless outside offering some clarification on, disclosed each feature is an example of being equal to of general class or similar features.
The present invention is not limited to the details of previous embodiment.The present invention expands to any new or any new combination of disclosed feature in this instructions (comprising any appending claims, summary and accompanying drawing), perhaps expands to any new or any new combination of the step of disclosed any method or processing.