WO2004061655A1 - Program compaction method employing dynamic code deletion - Google Patents

Program compaction method employing dynamic code deletion Download PDF

Info

Publication number
WO2004061655A1
WO2004061655A1 PCT/FR2003/003736 FR0303736W WO2004061655A1 WO 2004061655 A1 WO2004061655 A1 WO 2004061655A1 FR 0303736 W FR0303736 W FR 0303736W WO 2004061655 A1 WO2004061655 A1 WO 2004061655A1
Authority
WO
WIPO (PCT)
Prior art keywords
program
fragments
memory
deletable
deleted
Prior art date
Application number
PCT/FR2003/003736
Other languages
French (fr)
Inventor
Renaud Marlet
PHilippe TIGNOL
Original Assignee
Trusted Logic
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Trusted Logic filed Critical Trusted Logic
Priority to AU2003300617A priority Critical patent/AU2003300617A1/en
Publication of WO2004061655A1 publication Critical patent/WO2004061655A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44594Unloading

Definitions

  • the present invention relates to a program compacting method by dynamic code deletion.
  • This method is particularly suitable for the release of memory resources in these systems and therefore allows the reuse of these said memory resources.
  • Deleting program fragments can be done as many times as necessary during an execution to save more memory space.
  • An ordinary program execution platform is generally provided with a memory manager which comprises at least two functionalities: (1) allocate a memory block, and (2) free up a previously allocated memory block. When a block is released, the corresponding memory area can be re-used for other uses, in particular for a new memory allocation.
  • the "malloc" function allocates a memory block of a given size and returns a pointer to the beginning of the block, and the "free” function frees a given block.
  • Resizing Memory managers also often include functionality to resize a previously allocated memory block, reducing the size of the block at the end. Some systems also sometimes allow resizing by increasing the size of a block at the end. A block can be physically moved or not in memory to allow this resizing. For example, in type systems
  • the "realloc" function reduces (or increases) the size of a block from the end. Reducing the size of the allocated block thus makes it possible to delete a final fragment and to free the corresponding memory so that it can be reused by the system.
  • Dynamic cutting More rarely, memory managers also make it possible to dynamically split a previously allocated memory block into several fragments, as if as many blocks had initially been allocated separately. Selected fragments can thus be released and re-used by the system. • Defragmentation. Some memory managers also perform a defragmentation of the memory, whether transparent or not for the user. This operation consists in moving the allocated memory blocks to group them. Defragmentation reduces the number of small gaps in free areas between allocated memory blocks, which are difficult to reuse.
  • the displacement of allocated memory blocks induces certain constraints concerning the pointers towards the interior of blocks.
  • displacements of portions of the program take place, in particular after a possible phase of editing links, relocation of addresses and jumps displacements may be necessary.
  • Dynamic fragmentation If the program did not receive any particular structuring when it was loaded, fragments can nevertheless be flagged as deleted during the execution. So that the corresponding memory areas can be reused, the system can perform a dynamic division of the memory block initially allocated for the program and thus reduce itself to the above scenario of a pre-fragmented program.
  • Dynamic block size reduction Although not all systems have a memory manager powerful enough to perform dynamic fragmentation. There is however a special case that systems with simple memory management generally know: it is when the memory fragment to be deleted is located at the final end of the block allocated for the program. In this case, it is sufficient that the system allows a readjustment of the size of the memory blocks already allocated. Reducing the size of the block allocated for the program thus makes it possible to delete the final fragment and free up the corresponding memory so that it can be reused by the system.
  • Defragmentation It is also possible to dynamically and explicitly defragment a program block where areas of code have been deleted, without going through the memory manager. This operation consists in assembling some of the program portions remaining after deletion so as to form one or more compact, continuous blocks, without a free landlocked region. This technique is useful in several cases. It is first of all applicable in systems whose memory manager does not allow an arbitrary dynamic fragmentation but simply a resizing of the allocated memory blocks: the remaining program portions are assembled in a compact group at the start of the block or blocks and the size of the block (s) is adjusted to their content. Defragmentation can also be useful more generally to increase the possibility of re-using the freed memory areas.
  • a programmer who has knowledge of the life cycle of the program, knows, from what stages of execution, which fragments of programs can be considered as deletable.
  • fragments of a program can be deleted by construction, as is the case for "install” and “processData” in "Java
  • the compaction of a program by dynamic deletion of code is carried out according to the following four steps: • the determination of fragments of a program which, under certain assumptions, can be deleted without modifying the semantics, • the instrumentation of a program to mark deletable fragments and the conditions under which they can be deleted,
  • the determination of fragments of a program that can be deleted is based on static program analysis.
  • Static program analysis means a set of automatic program processing techniques that allow properties to be determined concerning the execution of a program without having to actually execute it.
  • An extremely common example of static analysis is abstract interpretation, which studies approximations to the execution of a program.
  • This process makes it possible to construct an oriented graph which models the state transitions of the program.
  • the vertices (or nodes) of this graph are made up of the different states encountered; the edges (or arcs) of this graph represent the calculations and interactions carried out by the program, and the corresponding portions of the program executed.
  • the program fragments determined to be deleted are those which are no longer executable once the program has reached a certain state.
  • the program regions corresponding to these inaccessible edges and not appearing among the regions corresponding to the edges accessible from S are suppressable when the program execution reaches a state corresponding to S.
  • the fragments thus identified can be deleted without affecting the semantics of the program, on the assumption that the program is at its last execution.
  • the quantity and size of the removable program fragments determined by this process depend on several parameters, in particular:
  • this determination method will generally be implemented outside of the program execution system, before it is loaded. There is nothing to prevent it from taking place on the system itself.
  • a fragment consisting of a continuous sequence of instructions of a routine can for example be identified by a start address and an end address of a fragment, or else a start or end address and a length of fragment.
  • a fragment can also be identified by special marks, neutral for execution, to indicate the location of the start and end of a fragment.
  • a fragment made up of a routine can for example be identified by the name of the routine or its memory address.
  • the code deletion condition associated with a program fragment must also be preserved. It can be arbitrarily complex.
  • the deletion condition can be based on the current control of the program. It can be for example the address of a program point: when this execution point is reached, then the associated fragment can be deleted. It can also be the designation of a routine of the program: when this routine is called, or when it returns, then the associated fragment can be deleted.
  • the deletion condition can also be based on the current data handled by the program. For example, it could be the designation of a program variable which, when it takes a certain value, or exceeds a certain threshold, signals that the associated fragment can be deleted.
  • the indication of the fragments to be deleted can also be present in the executable code itself.
  • the program itself signals to the system, during its execution, that a given fragment can be deleted.
  • This type of implementation is particularly well suited to the case of removal conditions complex because we then have all the power of expression of a program to make a decision to delete.
  • deletable program fragments can be automatic or not, carried out on the very platform of execution of the program or else outside. Following this determination, and the corresponding instrumentation, the program can optionally be automatically transformed, without changing its semantics, in order to optimize the possibility of re-using the freed memory areas. This optimization process is based on several kinds of program transformations, sources of various gains.
  • Deletable fragments initially separated in the body of the program can be moved to become contiguous.
  • This program transformation reduces the fragmentation of programs where code has been deleted: the total size of the deletable fragments is increased and the number of these fragments is reduced. The possibility of re-using the freed memory areas is therefore better.
  • This transformation is particularly useful for memory management systems that do not have a defragmentation mechanism.
  • Deletable fragments can also be placed in specific routines. As previously mentioned with regard to the structuring of a program in memory (for defragmentation), this transformation facilitates the code deletion mechanism. It does not even require any mechanism if the last routine of the memory block contains the program.
  • Deletable fragments can also be grouped together at the end of the program, in the reverse order of probable deletion.
  • the fragment most likely to be deleted is placed at the very end of the program block.
  • the next fragment most likely to be deleted is placed just before, and so on.
  • This transformation facilitates the deletion of code by dynamic reduction of block size. For example, in the case of "Java Card”, we can place the "install” method at the end of the “Method Component", preceded by the "processData” method.
  • transformations can be automated or manual, that is to say left to the discretion of the person preparing the program for compacting by deleting code.
  • three entities can decide to delete a code fragment: the program, the system and the system administrator.
  • the program can be instrumented, manually or automatically, to signal to the system that one of its fragments can be deleted. It is the very execution of the program which then triggers the deletion. Signaling that a fragment can be deleted can be implemented in various ways: instruction or group of specialized instructions, call to a specific routine of the system, etc.
  • the specification of the deletable fragment can be implemented in various ways: designation of one or more code areas, of a routine or a group of particular routines, of the current routine, etc. For example, in "Java Card", the "install” method could be ended by calling a system method which would signal that the method being executed is no longer useful and can be deleted.
  • the system if it has information concerning the possible deletion of program fragments during execution (whether these fragments and conditions for deletion have been determined automatically or not), can take the initiative to delete some of these fragments as soon as the corresponding conditions are met.
  • the person managing the system can also force the deletion of certain program fragments. In this case, the system must have a command which makes it possible to stipulate program fragments to be deleted.
  • a new memory block can be allocated for this purpose.
  • the deleted block can also be reused by resizing it to adapt to the size of the code that signals the error.
  • the method proposed according to the invention is particularly suitable for the release of memory resources on platforms such as small on-board systems and therefore allows the reuse of these said memory resources.

Abstract

The invention relates to a program compaction method employing dynamic code deletion. More specifically, but not exclusively, the invention relates to the compaction of programs which are executed on platforms having small memory resources, e.g. small on-board systems such as chip cards and payment terminals. The inventive method comprises four steps, namely: the determination of fragments of a program which, under certain hypotheses, can be deleted without modifying the semantics; the instrumentation of a program in order to mark fragments which can be deleted and the conditions in which they can be deleted; the optional transformation of the program in order to increase the memory saving that will be produced by the deletion of deletable fragments; and the memory structuring of a program with deletable fragments and the effective deletion of said fragments in order to enable the re-use of the corresponding freed-up memory areas.

Description

PROCEDE DE COMPACTAGE DE PROGRAMME PAR SUPPRESSION DYNAMIQUE DE CODE.METHOD FOR COMPACTING A PROGRAM BY DYNAMIC CODE DELETION.
La présente invention concerne un procédé de compactage de programme par suppression dynamique de code.The present invention relates to a program compacting method by dynamic code deletion.
Elle a plus particulièrement pour objet, mais non exclusivement, de compacter des programmes qui s'exécutent sur des plates-formes disposant de faibles ressources mémoire ; c'est le cas par exemple des petits systèmes embarqués tels que les cartes à puce et les terminaux de paiement.It has more particularly, but not exclusively, the object of compacting programs which execute on platforms having low memory resources; this is the case, for example, of small on-board systems such as smart cards and payment terminals.
Ce procédé est particulièrement adapté à la libération de ressources mémoire dans ces systèmes et par conséquent autorise la réutilisation de ces dites ressources mémoire.This method is particularly suitable for the release of memory resources in these systems and therefore allows the reuse of these said memory resources.
Il comprend quatre étapes :It includes four stages:
• la détermination de fragments d'un programme qui, sous certaines hypothèses, peuvent être supprimés sans en modifier la sémantique,• the determination of fragments of a program which, under certain assumptions, can be deleted without modifying the semantics,
• l'instrumentation d'un programme pour marquer des -fragments supprimables et les conditions sous lesquelles ils peuvent être supprimés,• the instrumentation of a program to mark deletable fragments and the conditions under which they can be deleted,
• la transformation éventuelle du programme pour augmenter l'économie mémoire qu'apportera une suppression des fragments supprimables, • la structuration en mémoire d'un programme avec fragments supprimables et la suppression effective de ces fragments pour permettre la réutilisation des zones mémoire libérées correspondantes.• the possible transformation of the program to increase the memory economy that a deletion of the deletable fragments will bring, • the structuring in memory of a program with deletable fragments and the effective deletion of these fragments to allow the reuse of the corresponding freed memory areas.
Ce compactage de programme par suppression dynamique de code est particulièrement utile dans les deux cas de figure suivants :This program compacting by dynamic code deletion is particularly useful in the following two cases:
• si, au cours de l'exécution d'un programme, un ou plusieurs fragments de ce programme ne sont plus utiles dans la suite de l'exécution, ils peuvent être totalement supprimés. La place mémoire correspondante peut être ainsi récupérée pour d'autres usages, sans incidence sur le comportement du programme.• if, during the execution of a program, one or more fragments of this program are no longer useful in the rest of the execution, they can be completely deleted. The corresponding memory space can thus be recovered for other uses, without affecting the behavior of the program.
• la suppression d'un ou de plusieurs fragments de programme peut aussi être forcée à tout moment. Le ou les fragments supprimés, ainsi que les portions de programme qui exploitaient ces fragments supprimés, sont alors remplacés par du code qui signale la suppression desdits fragments, afin qu'une erreur soit notifiée dans le cas où l'exécution du programme nécessiterait lesdits fragments. Suite à la suppression de code, le programme peut ainsi perdre certaines fonctionnalités. Le choix de fragments de programme à supprimer réalise donc un compromis entre les fonctionnalités offertes par le programme et la taille mémoire qu'il occupe.• the deletion of one or more program fragments can also be forced at any time. The deleted fragment (s), as well as the portions of the program which exploited these deleted fragments, are then replaced by code which signals the deletion of said fragments, so that an error is notified if the execution of the program requires said fragments . Following the deletion of code, the program may thus lose certain functionality. The choice of program fragments to delete therefore achieves a compromise between the functionalities offered by the program and the memory size it occupies.
La suppression de fragments de programmes peut être opérée autant de fois que nécessaire au cours d'une exécution pour gagner davantage de place mémoire.Deleting program fragments can be done as many times as necessary during an execution to save more memory space.
La suppression de fragments de programmes a également un intérêt sécuritaire : si les circonstances veulent que des fonctionnalités d'un programme doivent devenir définitivement inopérantes pour des raisons de sécurité, il est plus sûr de les supprimer effectivement de la mémoire du système que de mettre en place un contrôle d'accès.The deletion of program fragments is also of security interest: if the circumstances require that functionalities of a program must become permanently inoperative for reasons of security, it is safer to actually delete them from system memory than to set up access control.
Le besoin d'économiser la mémoire n'est pas la seule raison qui fait des petits systèmes embarqués une bonne cible pour le compactage par suppression de code ; la nature même des programmes qui s'exécutent sur ces systèmes y contribue également. En effet, il est fréquent que des programmes chargés sur ces systèmes ne soient exécutés qu'une unique fois. Ce sont toutefois le plus souvent des programmes sans terminaison véritable qui réagissent sans fin à des événements et des commandes qui leur sont soumis. Or le cycle de vie de ces programmes passe souvent par des phases irréversibles d'initialisation préalable. Par conséquent, les fragments de programmes qui réalisent ces phases d'initialisation deviennent inutiles une fois les initialisations effectuées, et peuvent donc être supprimés.The need to save memory is not the only reason that small embedded systems are a good target for code deletion compaction; the very nature of the programs that run on these systems also contributes to this. Indeed, it is frequent that programs loaded on these systems are executed only once. However, it is most often programs without real termination that react endlessly to events and commands submitted to them. However, the life cycle of these programs often goes through irreversible phases of initial initialization. Consequently, the program fragments which carry out these initialization phases become useless once the initializations have been carried out, and can therefore be deleted.
Deux cas courants de telles phases d'initialisation sont dans le cas de la carte à puce : V installation, qui crée en mémoire un exemplaire exécutable d'un programme, et la personnalisation, qui configure cet exemplaire exécutable de programme pour un utilisateur particulier.Two common cases of such initialization phases are in the case of the smart card: installation, which creates in memory an executable copy of a program, and personalization, which configures this executable copy of program for a particular user.
Par exemple, dans les systèmes qui acceptent des programmes "Java Card", langage employé couramment sur les cartes à puce, l'installation est effectuée par l'appel d'une méthode (routine) réservée à cet usage unique, nommée "install". Une fois cette méthode appelée, son contenu n'est plus jamais exécuté, sauf pour créer un nouvel exemplaire du même programme. Sous l'hypothèse, très fréquente, que le système ne devra jamais exécuter qu'un seul exemplaire de ce programme, le contenu de la méthode "install" peut être totalement supprimé, de même que toute autre méthode auxiliaire appelée uniquement par "install" (et non par d'autres méthodes du programme). La situation est identique pour la personnalisation. La seule différence, dans le cas de "Java Card", est que les fragments de code responsables de la personnalisation ne sont pas nécessairement identifiables par une méthode particulière. Néanmoins, une extension très répandue du système "Java Card", nommée "Open Platform", introduit une méthode, nommée "processData", qui n'est appelée que dans la phase de personnalisation. Une fois la personnalisation terminée, cette méthode peut donc aussi être supprimée, au même titre qu"'instaU" pour la phase d'installation, sous une hypothèse identique.For example, in systems that accept "Java Card" programs, a language commonly used on smart cards, installation is performed by calling a method (routine) reserved for this single use, called "install" . Once this method is called, its content is never executed again, except to create a new copy of the same program. Under the very frequent assumption that the system should never execute a single copy of this program, the content of the "install" method can be completely deleted, as well as any other auxiliary method called only by "install" (and not by other methods of the program). The situation is the same for personalization. The only difference, in the case of "Java Card", is that the code fragments responsible for personalization are not necessarily identifiable by a particular method. Nevertheless, a very widespread extension of the "Java Card" system, called "Open Platform", introduces a method, called "processData", which is called only in the personalization phase. Once the customization is complete, this method can therefore also be deleted, in the same way as "instaU" for the installation phase, under an identical assumption.
Dans le cas où l'exécution d'un fragment de programme supprimé resterait matériellement possible bien qu'interdite par hypothèse, il est recommandé de remplacer le fragment supprimé par du code qui signale une erreur. Dans le cas de "Java Card", le code supprimé peut être remplacé, qu'il recouvre le contenu complet d'une méthode ou non, par une levée d'exception.In the event that the execution of a deleted program fragment remains physically possible although prohibited by hypothesis, it is recommended to replace the deleted fragment with code that signals an error. In the case of "Java Card", the deleted code can be replaced, whether it covers the complete content of a method or not, by an exception throwing.
Il s'avère que la suppression dynamique de code pose néanmoins plusieurs questions :It turns out that dynamic code deletion nevertheless raises several questions:
• la structuration d'un programme en mémoire pour permettre la libération de fragments,• structuring a program in memory to allow the release of fragments,
• la détermination de fragments de code supprimables dans un programme,• determination of deletable code fragments in a program,
• l'instrumentation du programme pour signaler les fragments supprimables, • la transformation éventuelle du programme pour optimiser les fragments supprimables,• the instrumentation of the program to signal the deletable fragments, • the possible transformation of the program to optimize the deletable fragments,
• la prise de décision de suppression de ces fragments,• the decision to delete these fragments,
• la suppression effective de ces fragments, selon leur forme,• the effective deletion of these fragments, depending on their form,
• la restructuration éventuelle du programme résultant pour accroître la possibilité de réutilisation des zones mémoire ainsi libérées. Préalablement il faut rappeler les diverses fonctionnalités qui peuvent être offertes par les gestionnaires mémoire présents dans les systèmes d'exécution. Il en existe quatre grands types principaux :• the possible restructuring of the resulting program to increase the possibility of re-using the memory areas thus freed. Beforehand, it is necessary to recall the various functionalities which can be offered by the memory managers present in the execution systems. There are four main types:
• Allocation / libération. Une plate-forme ordinaire d'exécution de programme est généralement munie d'un gestionnaire mémoire qui comporte au moins deux fonctionnalités : (1) allouer un bloc de mémoire, et (2) libérer un bloc de mémoire précédemment alloué. Quand un bloc est libéré, la zone mémoire correspondante peut être réexploitée pour d'autres usages, notamment pour une nouvelle allocation mémoire. Par exemple, dans les systèmes d'exploitation de type "Unix", la fonction "malloc" alloue un bloc mémoire d'une taille donnée et retourne un pointeur vers le début du bloc, et la fonction "free" libère un bloc donné. • Retaillage. Les gestionnaires mémoire comportent également souvent des fonctionnalités de retaillage d'un bloc mémoire précédemment alloué, en réduisant la taille du bloc par la fin. Certains systèmes permettent aussi parfois un retaillage en augmentant la taille d'un bloc par la fin. Un bloc peut être physiquement déplacé ou non en mémoire pour permettre ce retaillage. Par exemple, dans les systèmes de type• Allowance / release. An ordinary program execution platform is generally provided with a memory manager which comprises at least two functionalities: (1) allocate a memory block, and (2) free up a previously allocated memory block. When a block is released, the corresponding memory area can be re-used for other uses, in particular for a new memory allocation. For example, in "Unix" operating systems, the "malloc" function allocates a memory block of a given size and returns a pointer to the beginning of the block, and the "free" function frees a given block. • Resizing. Memory managers also often include functionality to resize a previously allocated memory block, reducing the size of the block at the end. Some systems also sometimes allow resizing by increasing the size of a block at the end. A block can be physically moved or not in memory to allow this resizing. For example, in type systems
"Unix", la fonction "realloc" effectue une réduction (ou un accroissement) de la taille d'un bloc par la fin. La réduction de la taille du bloc alloué permet ainsi de supprimer un fragment final et de libérer la mémoire correspondante pour qu'elle puisse être réutilisée par le système."Unix", the "realloc" function reduces (or increases) the size of a block from the end. Reducing the size of the allocated block thus makes it possible to delete a final fragment and to free the corresponding memory so that it can be reused by the system.
• Découpage dynamique. Plus rarement, les gestionnaires mémoire permettent aussi de découper dynamiquement en plusieurs fragments un bloc mémoire précédemment alloué, comme si autant de blocs avaient initialement été alloués séparément. Des fragments choisis peuvent ainsi être libérés et réexploités par le système. • Défragmentation. Certains gestionnaires mémoire effectuent également, de manière transparente ou non pour l'utilisateur, une défragmentation de la mémoire. Cette opération consiste à déplacer les blocs mémoire alloués pour les regrouper. La défragmentation permet de réduire le nombre de petits interstices de zones libre entre blocs mémoire alloués, qui sont difficilement réutilisables.• Dynamic cutting. More rarely, memory managers also make it possible to dynamically split a previously allocated memory block into several fragments, as if as many blocks had initially been allocated separately. Selected fragments can thus be released and re-used by the system. • Defragmentation. Some memory managers also perform a defragmentation of the memory, whether transparent or not for the user. This operation consists in moving the allocated memory blocks to group them. Defragmentation reduces the number of small gaps in free areas between allocated memory blocks, which are difficult to reuse.
Le déplacement de blocs mémoire alloués induit toutefois certaines contraintes concernant les pointeurs vers l'intérieur de blocs. En particulier, si des déplacements de portions de programme ont lieu, notamment après une phase éventuelle d'édition de liens, un relogeage des adresses et des déplacements de sauts peut être nécessaire.The displacement of allocated memory blocks however induces certain constraints concerning the pointers towards the interior of blocks. In particular, if displacements of portions of the program take place, in particular after a possible phase of editing links, relocation of addresses and jumps displacements may be necessary.
Il s'avère que pour permettre la suppression de fragments d'un programme, et surtout la réutilisation efficace de la mémoire correspondante, il faut structurer le programme en mémoire à bon escient. Quatre cas typiques de gestion de la représentation en mémoire d'un programme sont à considérer : la préfragmentation statique (avant l'exécution) d'un programme, la fragmentation dynamique (après l'exécution), la réduction dynamique de taille de blocs, et la restructuration de programme après suppression de fragments.It turns out that to allow the removal of fragments from a program, and especially the efficient reuse of the corresponding memory, the program must be structured in memory wisely. Four typical cases for managing the memory representation of a program are to be considered: static prefragmentation (before execution) of a program, dynamic fragmentation (after execution), dynamic reduction in block size, and program restructuring after deleting fragments.
• Préfragmentation statique. Si, lors du chargement d'un programme, le système a connaissance des fragments qui pourront être supprimés dans le futur, il peut structurer le programme en mémoire en plusieurs blocs, utilisant pour cela son mécanisme ordinaire d'allocation de mémoire. Un espace mémoire individuel est dans ce cas alloué pour chaque fragment supprimable, qui peut ainsi être libéré séparément, sans impact sur le reste du programme.• Static pre-fragmentation. If, during the loading of a program, the system has knowledge of the fragments which could be deleted in the future, it can structure the program in memory in several blocks, using for this its ordinary mechanism of memory allocation. In this case, an individual memory space is allocated for each deletable fragment, which can thus be freed separately, without impacting the rest of the program.
• Fragmentation dynamique. Si le programme n'a pas reçu de structuration particulière lors de son chargement, des fragments peuvent néanmoins être signalés comme supprimés au cours de l'exécution. Pour que les zones mémoire correspondantes puissent être réutilisées, le système peut effectuer un découpage dynamique du bloc mémoire alloué initialement pour le programme et se ramener ainsi au cas de figure ci-dessus d'un programme préfragmenté. • Réduction dynamique de taille de blocs. Cependant, tous les systèmes ne disposent pas d'un gestionnaire mémoire assez puissant pour réaliser la fragmentation dynamique. Il est toutefois un cas particulier que savent généralement traiter des systèmes avec gestion mémoire simple : c'est lorsque le fragment mémoire à supprimer est situé à l'extrémité finale du bloc alloué pour le programme. Dans ce cas, il suffit que le système permette un réajustement de la taille des blocs mémoire déjà alloués. La réduction de la taille du bloc alloué pour le programme permet ainsi de supprimer le fragment final et de libérer la mémoire correspondante pour qu'elle puisse être réutilisée par le système.• Dynamic fragmentation. If the program did not receive any particular structuring when it was loaded, fragments can nevertheless be flagged as deleted during the execution. So that the corresponding memory areas can be reused, the system can perform a dynamic division of the memory block initially allocated for the program and thus reduce itself to the above scenario of a pre-fragmented program. • Dynamic block size reduction. However, not all systems have a memory manager powerful enough to perform dynamic fragmentation. There is however a special case that systems with simple memory management generally know: it is when the memory fragment to be deleted is located at the final end of the block allocated for the program. In this case, it is sufficient that the system allows a readjustment of the size of the memory blocks already allocated. Reducing the size of the block allocated for the program thus makes it possible to delete the final fragment and free up the corresponding memory so that it can be reused by the system.
• Défragmentation. Il est également possible de défragmenter dynamiquement et explicitement un bloc programme où des zones de code ont été supprimées, sans passer par l'intermédiaire du gestionnaire mémoire. Cette opération consiste à assembler certaines des portions de programme restantes après suppression de manière à former un ou des blocs compacts, continus, sans région libre enclavée. Cette technique est utile dans plusieurs cas de figure. Elle est tout d'abord applicable dans des systèmes dont le gestionnaire mémoire ne permet pas une fragmentation dynamique arbitraire mais simplement un retaillage des blocs mémoire alloués : les portions de programme restantes sont assemblées en un groupe compact en début du ou des blocs et la taille du ou des blocs est ajustée à leur contenu. La défragmentation peut aussi être utile plus généralement pour accroître la possibilité de réutilisation des zones mémoire libérées. En effet, de nombreuses petites zones sont plus difficiles à réutiliser qu'une unique grande zone, qui peut éventuellement être redécoupée. Il faut toutefois noter que le déplacement de portions de programme en mémoire peut nécessiter de reloger le code résultant. Par exemple, les adresses ou les déplacements des sauts interblocs doivent être recalculés. C'est une tâche délicate à effectuer, tant sur le langage machine d'un microprocesseur réel que sur le langage d'une machine virtuelle. Mais si des routines entières sont supprimées dans un programme, reloger le code restant est souvent beaucoup plus facile car les informations à mettre à jour concernent alors davantage les adresses, déplacements et indices qui permettent d'identifier les routines plutôt que les sauts dans le corps des routines même.• Defragmentation. It is also possible to dynamically and explicitly defragment a program block where areas of code have been deleted, without going through the memory manager. This operation consists in assembling some of the program portions remaining after deletion so as to form one or more compact, continuous blocks, without a free landlocked region. This technique is useful in several cases. It is first of all applicable in systems whose memory manager does not allow an arbitrary dynamic fragmentation but simply a resizing of the allocated memory blocks: the remaining program portions are assembled in a compact group at the start of the block or blocks and the size of the block (s) is adjusted to their content. Defragmentation can also be useful more generally to increase the possibility of re-using the freed memory areas. Indeed, many small areas are more difficult to reuse than a single large area, which can possibly be cut again. However, note that moving portions of the program into memory may require relocating the resulting code. For example, the addresses or movements of inter-block jumps must be recalculated. It is a delicate task to perform, both on the machine language of a real microprocessor and on the language of a virtual machine. But if whole routines are deleted in a program, relocating the remaining code is often much easier because the information to be updated then relates more to the addresses, movements and indices which make it possible to identify the routines rather than the jumps in the body. routines even.
Il s'avère que la détermination de fragments supprimables peut être effectuée de trois manières :It turns out that the determination of deletable fragments can be carried out in three ways:
1. Un programmeur, qui a connaissance du cycle de vie du programme, sait, à partir de quelles étapes d'exécution, quels fragments de programmes peuvent être considérés comme supprimables.1. A programmer, who has knowledge of the life cycle of the program, knows, from what stages of execution, which fragments of programs can be considered as deletable.
2. Suivant les langages, des fragments d'un programme sont supprimables par construction, comme c'est le cas pour "install" et "processData" en "Java2. Depending on the language, fragments of a program can be deleted by construction, as is the case for "install" and "processData" in "Java
Card".Card ".
3. Enfin un traitement automatique de programme permet de déterminer des fragments de codes qui ne sont matériellement plus utiles à partir de certains points et conditions d'exécution : ce mode de détermination constitue la première étape du procédé décrit ci-après.3. Finally, automatic program processing makes it possible to determine fragments of code which are no longer materially useful from certain points and conditions of execution: this mode of determination constitutes the first step of the method described below.
Conformément au procédé selon l'invention, le compactage de programme par suppression dynamique de code s'effectue suivant les quatre étapes suivantes : • la détermination de fragments d'un programme qui, sous certaines hypothèses, peuvent être supprimés sans en modifier la sémantique, • l'instrumentation d'un programme pour marquer des fragments supprimables et les conditions sous lesquelles ils peuvent être supprimés,In accordance with the method according to the invention, the compaction of a program by dynamic deletion of code is carried out according to the following four steps: • the determination of fragments of a program which, under certain assumptions, can be deleted without modifying the semantics, • the instrumentation of a program to mark deletable fragments and the conditions under which they can be deleted,
• la transformation éventuelle du programme pour augmenter l'économie mémoire qu'apportera une suppression des fragments supprimables,• the possible transformation of the program to increase the memory economy that a deletion of the deletable fragments will bring,
• la structuration en mémoire d'un programme avec fragments supprimables et la suppression effective de ces fragments pour permettre la réutilisation des zones mémoire libérées correspondantes.• the structuring in memory of a program with deletable fragments and the effective deletion of these fragments to allow the reuse of the corresponding freed memory areas.
Premièrement, la détermination de fragments d'un programme supprimables est basée sur l'analyse statique de programme.First, the determination of fragments of a program that can be deleted is based on static program analysis.
Vanalyse statique de programme désigne un ensemble de techniques de traitement automatique de programme qui permettent de déterminer des propriétés concernant l'exécution d'un programme sans avoir à l'exécuter véritablement. Un exemple extrêmement répandu d'analyse statique est Y interprétation abstraite, qui étudie des approximations de l'exécution d'un programme.Static program analysis means a set of automatic program processing techniques that allow properties to be determined concerning the execution of a program without having to actually execute it. An extremely common example of static analysis is abstract interpretation, which studies approximations to the execution of a program.
La détermination automatique de fragments de programmes supprimables par analyse statique de programme pourra être mise en œuvre selon la séquence opératoire suivante :The automatic determination of fragments of programs that can be deleted by static program analysis can be implemented according to the following operating sequence:
• modélisation, sous forme d'un état abstrait, de l'état initial d'un exemplaire exécutable du programme ;• modeling, in the form of an abstract state, of the initial state of an executable copy of the program;
• marquage de cet état comme "non encore exploré" ;• marking this state as "not yet explored";
• tant qu'il existe un ou plusieurs états abstraits non-terminaux marqués "non encore explorés" :• as long as there are one or more non-terminal abstract states marked "not yet explored":
- choix de l'un de ces états ; - marquage de l'état choisi comme "désormais exploré" ; - exécution abstraite du programme à partir de cet état en prenant en compte toutes ses interactions possibles (événements et commandes reçus, etc.), ce qui conduit à un ou plusieurs nouveaux états ; - marquage de ces nouveaux états comme "non encore explorés" ;- choice of one of these states; - marking of the state chosen as "now explored"; - abstract execution of the program from this state taking into account all its possible interactions (events and commands received, etc.), which leads to one or more new states; - marking of these new states as "not yet explored";
- fusion des états de programmes résultants qui sont similaires, en les généralisant si nécessaire.- merging of the resulting program states which are similar, generalizing them if necessary.
L'arrêt de l'algorithme avec certitude pourra être mis en œuvre de la manière suivante :Stopping the algorithm with certainty can be implemented as follows:
• modélisation de l'état d'un programme de manière à ce qu'il n'existe qu'un nombre fini de configurations différentes, ou• modeling the state of a program so that there is only a finite number of different configurations, or
• généralisation plus ou moins effective des états résultants pour borner le nombre d'états à considérer, l'état quelconque généralisant tous les autres et garantissant ainsi que la fin du processus puisse toujours être forcée.• more or less effective generalization of the resulting states to limit the number of states to be considered, the arbitrary state generalizing all the others and thus ensuring that the end of the process can always be forced.
Ce procédé permet de construire un graphe orienté qui modélise les transitions d'état du programme. Les sommets (ou nœuds) de ce graphe sont constitués par les différents états rencontrés ; les arêtes (ou arcs) de ce graphe représentent les calculs et interactions effectuées par le programme, et les portions de programme exécutées correspondantes.This process makes it possible to construct an oriented graph which models the state transitions of the program. The vertices (or nodes) of this graph are made up of the different states encountered; the edges (or arcs) of this graph represent the calculations and interactions carried out by the program, and the corresponding portions of the program executed.
Les fragments de programme déterminés comme supprimables sont ceux qui ne sont plus exécutables une fois que le programme a atteint un certain état. Autrement dit, s'il existe un sommet S du graphe à partir duquel certaines arêtes ne sont pas accessibles, alors les régions de programme correspondant à ces arêtes inaccessibles et ne figurant pas parmi les régions correspondant aux arêtes accessibles depuis S sont supprimables lorsque l'exécution du programme atteint un état correspondant à S. Les fragments ainsi identifiés sont supprimables sans affecter la sémantique du programme, sous l'hypothèse que le programme en est à sa dernière exécution.The program fragments determined to be deleted are those which are no longer executable once the program has reached a certain state. In other words, if there exists a vertex S of the graph from which certain edges are not accessible, then the program regions corresponding to these inaccessible edges and not appearing among the regions corresponding to the edges accessible from S are suppressable when the program execution reaches a state corresponding to S. The fragments thus identified can be deleted without affecting the semantics of the program, on the assumption that the program is at its last execution.
La quantité et la taille des fragments de programme supprimables déterminés par ce procédé dépendent de plusieurs paramètres, notamment :The quantity and size of the removable program fragments determined by this process depend on several parameters, in particular:
• le degré de précision avec lequel les états du programme sont modélisés,• the degree of precision with which the states of the program are modeled,
• le degré de précision avec lequel les interactions avec le programme sont modélisées,• the degree of precision with which the interactions with the program are modeled,
• la création éventuelle d'états intermédiaires entre chaque interaction avec le programme,• the possible creation of intermediate states between each interaction with the program,
• les conditions d'emploi de la généralisation d'état pour éventuellement forcer la terminaison de l'algorithme.• the conditions of use of the generalization of state to possibly force the termination of the algorithm.
Pour des raisons pratiques de ressources mémoire, ce procédé de détermination sera généralement mis en œuvre en dehors du système d'exécution du programme, avant son chargement. Rien n'interdit toutefois qu'il puisse avoir lieu sur le système même.For practical reasons of memory resources, this determination method will generally be implemented outside of the program execution system, before it is loaded. There is nothing to prevent it from taking place on the system itself.
Deuxièmement, l'instrumentation du programme pour marquer les fragments supprimables, ainsi que les conditions sous lesquelles ils peuvent être supprimés, s'effectue de la manière suivante :Second, the instrumentation of the program to mark the deletable fragments, as well as the conditions under which they can be deleted, is carried out as follows:
Les fragments doivent tout d'abord être marqués afin d'être connus du système. Ce marquage permet d'une part de structurer le programme en mémoire afin de favoriser la suppression de code, par exemple avec une préfragmentation, et d'autre part de désigner les fragments à supprimer à un moment donné de l'exécution. Le marquage des zones de code supprimables peut s'effectuer de multiples manières. Un fragment constitué d'une suite continue d'instructions d'une routine peut par exemple être repéré par une adresse de début et une adresse de fin de fragment, ou bien une adresse de début ou de fin et une longueur de fragment. Un fragment peut être également repéré par des marques spéciales, neutres pour l'exécution, pour indiquer l'emplacement du début et de la fin d'un fragment. Un fragment constitué d'une routine peut par exemple être repéré par le nom de la routine ou son adresse mémoire.The fragments must first be marked in order to be known to the system. This marking makes it possible on the one hand to structure the program in memory in order to favor the deletion of code, for example with a prefragmentation, and on the other hand to indicate the fragments to be deleted at a given moment of the execution. There are many ways to mark deletable code areas. A fragment consisting of a continuous sequence of instructions of a routine can for example be identified by a start address and an end address of a fragment, or else a start or end address and a length of fragment. A fragment can also be identified by special marks, neutral for execution, to indicate the location of the start and end of a fragment. A fragment made up of a routine can for example be identified by the name of the routine or its memory address.
La condition de suppression de code associée à un fragment de programme doit également être conservée. Elle peut être arbitrairement complexe.The code deletion condition associated with a program fragment must also be preserved. It can be arbitrarily complex.
La condition de suppression peut être basée sur le contrôle courant du programme. Ce peut être par exemple l'adresse d'un point de programme : lorsque ce point d'exécution est atteint, alors le fragment associé peut être supprimé. Ce peut être aussi la désignation d'une routine du programme : lorsque cette routine est appelée, ou lorsqu'elle retourne, alors le fragment associé peut être supprimé.The deletion condition can be based on the current control of the program. It can be for example the address of a program point: when this execution point is reached, then the associated fragment can be deleted. It can also be the designation of a routine of the program: when this routine is called, or when it returns, then the associated fragment can be deleted.
La condition de suppression peut aussi être basée sur les données courantes manipulées par le programme. Ce peut être par exemple la désignation d'une variable du programme qui, lorsqu'elle prend une certaine valeur, ou dépasse un certain seuil, signale que le fragment associé peut être supprimé.The deletion condition can also be based on the current data handled by the program. For example, it could be the designation of a program variable which, when it takes a certain value, or exceeds a certain threshold, signals that the associated fragment can be deleted.
L'indication des fragments à supprimer peut également être présente dans le code exécutable même.The indication of the fragments to be deleted can also be present in the executable code itself.
Dans ce cas, le programme signale lui-même au système, au cours de son exécution, qu'un fragment donné peut être supprimé. Ce type de mise en œuvre est particulièrement bien adapté au cas de conditions de suppression complexes car on dispose alors de toute la puissance d'expression d'un programme pour prendre une décision de suppression.In this case, the program itself signals to the system, during its execution, that a given fragment can be deleted. This type of implementation is particularly well suited to the case of removal conditions complex because we then have all the power of expression of a program to make a decision to delete.
Dans le cas d'un système "Java Card", l'information complémentaire concernant les fragments supprimables d'un code exécutable (code rangé dans le "Method Component") peut être intégrée de manière portable au programme objet ("CAP file") sous forme de composants de programmes auxiliaires ("Custom Components") : ces composants seront ignorés par les systèmes qui ne savent pas gérer le compactage par suppression de code.In the case of a "Java Card" system, the additional information concerning the deletable fragments of an executable code (code stored in the "Method Component") can be integrated in a portable manner into the object program ("CAP file") in the form of components of auxiliary programs ("Custom Components"): these components will be ignored by systems which do not know how to manage compaction by deleting code.
Troisièmement, la transformation éventuelle du programme pour augmenter l'économie mémoire apportée par la suppression de code, s'effectue de la manière suivante :Thirdly, the possible transformation of the program to increase the memory economy brought by the deletion of code, is carried out as follows:
La déteraiination de fragments de programme supprimables peut être automatique ou non, effectuée sur la plate-forme même d'exécution du programme ou bien à l'extérieur. Suite à cette détermination, et à l'instrumentation correspondante, le programme peut optionnellement être automatiquement transformé, sans changer sa sémantique, afin d'optimiser la possibilité de réutilisation des zones mémoire libérées. Ce procédé d'optimisation est basé sur plusieurs sortes de transformations de programme, sources de gains divers.The determination of deletable program fragments can be automatic or not, carried out on the very platform of execution of the program or else outside. Following this determination, and the corresponding instrumentation, the program can optionally be automatically transformed, without changing its semantics, in order to optimize the possibility of re-using the freed memory areas. This optimization process is based on several kinds of program transformations, sources of various gains.
Des fragments supprimables initialement séparés dans le corps du programme peuvent être déplacés pour devenir contigus. Cette transformation de programme réduit la fragmentation des programmes où l'on a supprimé du code : la taille totale des fragments supprimables est augmentée et le nombre de ces fragments est réduit. La possibilité de réutilisation des zones mémoires libérées est donc meilleure. Cette transformation est particulièrement utile pour les systèmes de gestion mémoire qui ne disposent pas de mécanisme de défragmentation. Des fragments supprimables peuvent aussi être placés dans des routines spécifiques. Comme indiqué précédemment en ce qui concerne la structuration d'un programme en mémoire (pour la défragmentation), cette transformation facilite le mécanisme de suppression de code. Elle ne nécessite même aucun mécanisme si la dernière routine du bloc mémoire contient le programme.Deletable fragments initially separated in the body of the program can be moved to become contiguous. This program transformation reduces the fragmentation of programs where code has been deleted: the total size of the deletable fragments is increased and the number of these fragments is reduced. The possibility of re-using the freed memory areas is therefore better. This transformation is particularly useful for memory management systems that do not have a defragmentation mechanism. Deletable fragments can also be placed in specific routines. As previously mentioned with regard to the structuring of a program in memory (for defragmentation), this transformation facilitates the code deletion mechanism. It does not even require any mechanism if the last routine of the memory block contains the program.
Des fragments supprimables peuvent être également regroupés à la fin du programme, dans l'ordre inverse de suppression probable. Autrement dit, le fragment qui a le plus de chance d'être supprimé est placé tout à la fin du bloc programme. Le fragment suivant qui a le plus de chance d'être supprimé est placé juste avant, et ainsi de suite. Cette transformation facilite la suppression de code par réduction dynamique de taille de blocs. Par exemple, dans le cas de "Java Card", on pourra placer la méthode "install" à la fin du "Method Component", précédée de la méthode "processData".Deletable fragments can also be grouped together at the end of the program, in the reverse order of probable deletion. In other words, the fragment most likely to be deleted is placed at the very end of the program block. The next fragment most likely to be deleted is placed just before, and so on. This transformation facilitates the deletion of code by dynamic reduction of block size. For example, in the case of "Java Card", we can place the "install" method at the end of the "Method Component", preceded by the "processData" method.
Dans le cas général, il n'existe pas d'ordre optimal pour l'ordonnancement des fragments supprimables car les choix de suppression peuvent dépendre de données dynamiques : il n'existe pas de tri meilleur que les autres. Dans le cas où les fragments supprimables sont déterminés par traitement automatique de programme, comme décrit ci-dessus, un ordre convenable est fourni par un parcours en profondeur d'abord du graphe d'état, en partant de l'état initial, et une sélection des fragments supprimables rencontrés lors de ce parcours. Certains fragments qui sont supprimables en fonction de données dynamiques (donc inconnues au moment de l'ordonnancement) peuvent être omis de la suppression pour aménager une chaîne continue de fragments dont la suppression successive est certaine.In the general case, there is no optimal order for the ordering of the deletable fragments because the choices of deletion can depend on dynamic data: there is no sort better than the others. In the case where the deletable fragments are determined by automatic program processing, as described above, a suitable order is provided by first traversing the state graph in depth, starting from the initial state, and a selection of deletable fragments encountered during this journey. Certain fragments which can be deleted as a function of dynamic data (therefore unknown at the time of scheduling) can be omitted from the deletion to arrange a continuous chain of fragments whose successive deletion is certain.
Ces transformations peuvent nécessiter l'introduction de sauts ou d'appels de routine. Dans la mesure où ces transformations de programme déplacent du code, elles peuvent aussi nécessiter le relogeage des zones de programme affectées par les mouvements de code.These transformations may require the introduction of jumps or routine calls. To the extent that these program transformations displace code, they may also require relocation of program areas affected by code movements.
Ces transformations peuvent être automatisées ou bien manuelles, c'est-à-dire laissées à l'appréciation de la personne qui prépare le programme pour le compactage par suppression de code.These transformations can be automated or manual, that is to say left to the discretion of the person preparing the program for compacting by deleting code.
Il faut noter que ces transformations ne sont pas exclusives les unes des autres ; elles peuvent être combinées.It should be noted that these transformations are not mutually exclusive; they can be combined.
Concernant la décision de suppression de fragments de programme, trois entités peuvent décider de supprimer un fragment de code : le programme, le système et l'adm- -ust-rateur du système.Regarding the decision to delete program fragments, three entities can decide to delete a code fragment: the program, the system and the system administrator.
Le programme peut être instrumenté, manuellement ou automatiquement, pour signaler au système qu'un de ses fragments peut être supprimé. C'est l'exécution même du programme qui déclenche alors la suppression. Signaler qu'un fragment est supprimable peut être mis en œuvre de diverses manières : instruction ou groupe d'instructions spécialisé, appel à une routine spécifique du système, etc. La spécification du fragment supprimable peut être mis en œuvre de diverses manières : désignation d'une ou plusieurs zones de code, d'une routine ou d'un groupe de routines particulières, de la routine courante, etc. Par exemple, en "Java Card", la méthode "install" pourrait être terminée par l'appel à une méthode du système qui signalerait que la méthode en cours d'exécution n'est plus utile et peut être supprimée.The program can be instrumented, manually or automatically, to signal to the system that one of its fragments can be deleted. It is the very execution of the program which then triggers the deletion. Signaling that a fragment can be deleted can be implemented in various ways: instruction or group of specialized instructions, call to a specific routine of the system, etc. The specification of the deletable fragment can be implemented in various ways: designation of one or more code areas, of a routine or a group of particular routines, of the current routine, etc. For example, in "Java Card", the "install" method could be ended by calling a system method which would signal that the method being executed is no longer useful and can be deleted.
Le système, s'il dispose d'informations concernant la suppression possible de fragments de programme au cours de l'exécution (que ces fragments et conditions de suppression aient été déterminés automatiquement ou non), peut prendre l'initiative de supprimer certains de ces fragments dès lors que les conditions correspondantes sont remplies. La personne qui gère le système peut également forcer la suppression de certains fragments de programme. Dans ce cas de figure, le système doit disposer d'une commande qui permet de stipuler des fragments de programme à supprimer.The system, if it has information concerning the possible deletion of program fragments during execution (whether these fragments and conditions for deletion have been determined automatically or not), can take the initiative to delete some of these fragments as soon as the corresponding conditions are met. The person managing the system can also force the deletion of certain program fragments. In this case, the system must have a command which makes it possible to stipulate program fragments to be deleted.
Ces trois sources de choix ne sont pas exclusives les unes des autres ; elles peuvent être combinées.These three sources of choice are not mutually exclusive; they can be combined.
Quatrièmement, la structuration en mémoire d'un programme avec fragments supprimables et la suppression effective de ces fragments pour permettre la réutilisation des zones mémoire libérées correspondantes s'effectue de la manière suivante :Fourth, the structuring in memory of a program with deletable fragments and the effective deletion of these fragments to allow the reuse of the corresponding freed memory areas is carried out as follows:
Une fois prise la décision de supprimer certains fragments, la libération des zones mémoire correspondantes ne devient effective qu'en fonction de la structuration réelle du programme en mémoire. Cela se résume aux cas suivants :Once the decision has been made to delete certain fragments, the release of the corresponding memory areas only becomes effective as a function of the actual structure of the program in memory. It boils down to the following cases:
• si le programme est statiquement préfragmenté, chaque fragment à supprimer est libéré individuellement, auprès du gestionnaire mémoire du système.• if the program is statically prefragmented, each fragment to be deleted is released individually, to the memory manager of the system.
• si le gestionnaire mémoire du système permet une fragmentation dynamique, le programme est fragmenté au vol et les fragments à supprimer sont libérés individuellement, comme dans le cas précédent.• if the system memory manager allows dynamic fragmentation, the program is fragmented on the fly and the fragments to be deleted are released individually, as in the previous case.
• si les fragments à supprimer sont localisés en fin de blocs mémoire, l'espace mémoire correspondant est libéré en redimensionnant les blocs pour en réduire la taille.• if the fragments to be deleted are located at the end of memory blocks, the corresponding memory space is freed by resizing the blocks to reduce their size.
• si le système est muni d'un mécanisme pour reloger du code, tous les éléments non supprimés du programme sont rassemblés en début de bloc, relogés, et le bloc est redimensionné pour en réduire la taille. Ces différents types de suppression effective ne sont pas exclusifs ; ils peuvent être combinés.• if the system is equipped with a mechanism to relocate code, all the elements not deleted from the program are gathered at the beginning of the block, relocated, and the block is resized to reduce its size. These different types of effective deletion are not exclusive; they can be combined.
Si un fragment de code peut être supprimé sans que la sémantique du programme soit préservée (le programme perd alors certaines de ses fonctionnalités), il est recommandé de mettre en place un mécanisme de contrôle. Une erreur sera ainsi notifiée si l'exécution du programme nécessite un fragment supprimé. Pour ce faire, on peut par exemple remplacer le code supprimé par du code qui lève une erreur.If a code fragment can be deleted without preserving the semantics of the program (the program then loses some of its functionality), it is recommended to set up a control mechanism. An error will thus be notified if the execution of the program requires a deleted fragment. To do this, you can for example replace the deleted code with code that throws an error.
Si un fragment supprimé doit être remplacé par du code qui signale une erreur, un nouveau bloc mémoire peut être alloué à cet effet. Alternativement, le bloc supprimé peut aussi être réutilisé en le redimensionnant pour l'adapter à la taille du code qui signale l'erreur.If a deleted fragment must be replaced by code that signals an error, a new memory block can be allocated for this purpose. Alternatively, the deleted block can also be reused by resizing it to adapt to the size of the code that signals the error.
Ainsi le procédé proposé selon l'invention est particulièrement adapté à la libération de ressources mémoire sur des plates-formes telles que des petits systèmes embarqués et par conséquent autorise la réutilisation de ces dites ressources mémoire. Thus the method proposed according to the invention is particularly suitable for the release of memory resources on platforms such as small on-board systems and therefore allows the reuse of these said memory resources.

Claims

REVENDICATIONS
1. Procédé de compactage de programme par suppression dynamique de code, caractérisé en ce qu'il comprend les étapes suivantes :1. A method of compacting a program by dynamic deletion of code, characterized in that it comprises the following steps:
• la détermination de fragments d'un programme qui peuvent être supprimés soit sans en modifier la sémantique lorsque le programme en est à sa dernière exécution soit en modifiant la sémantique lorsque ces modifications sont acceptables, • l'instrumentation d'un programme pour marquer des fragments supprimables et les conditions sous lesquelles ils peuvent être supprimés,• the determination of fragments of a program which can be deleted either without modifying the semantics when the program is at its last execution or by modifying the semantics when these modifications are acceptable, • the instrumentation of a program to mark deletable fragments and the conditions under which they can be deleted,
• la structuration en mémoire d'un programme avec fragments supprimables et la suppression effective de ces fragments pour permettre la réutilisation des zones mémoire libérées correspondantes.• the structuring in memory of a program with deletable fragments and the effective deletion of these fragments to allow the reuse of the corresponding freed memory areas.
2. Procédé selon la revendication 1, caractérisé en ce qu'avant la susdite structuration en mémoire d'un programme, le procédé comprend la transformation du programme pour augmenter l'économie mémoire qu'apportera la suppression de programmes supprimables.2. Method according to claim 1, characterized in that before the aforesaid structuring in memory of a program, the method comprises the transformation of the program to increase the memory economy that will bring the deletion of deletable programs.
3. Procédé selon la revendication 1, caractérisé en ce que la susdite détermination de fragments de programmes supprimables s'effectue automatiquement par analyse statique de programme.3. Method according to claim 1, characterized in that the above determination of deletable program fragments is carried out automatically by static program analysis.
4. Procédé selon la revendication 3, caractérisé en ce que la susdite détermination de fragments de programmes supprimables s'effectue à partir d'un graphe orienté construit selon la séquence opératoire suivante : • modélisation, sous forme d'un état abstrait, de l'état initial d'un exemplaire exécutable du programme ;4. Method according to claim 3, characterized in that the above determination of fragments of deletable programs is carried out from an oriented graph constructed according to the following operating sequence: • modeling, in the form of an abstract state, of the initial state of an executable copy of the program;
• marquage de cet état comme "non encore exploré" ;• marking this state as "not yet explored";
• tant qu'il existe un ou plusieurs états abstraits non-terminaux marqués comme "non encore explorés" :• as long as there are one or more non-terminal abstract states marked as "not yet explored":
- choix de l'un de ces états ;- choice of one of these states;
- marquage de l'état choisi comme "désormais exploré" ;- marking of the state chosen as "now explored";
- exécution abstraite du programme à partir de cet état en prenant en compte toutes ses interactions possibles et produisant un ou plusieurs nouveaux états ;- abstract execution of the program from this state taking into account all its possible interactions and producing one or more new states;
- marquage de ces nouveaux états comme "non enclore explorés" ;- marking of these new states as "not enclosed explored";
- fusion des états de programmes résultants qui sont similaires, en les généralisant si nécessaire ; les nœuds du graphe étant constitués par les différents états rencontrés dans la susdite séquence opératoire, les arcs entre deux états de ce graphe représentant les portions de programme exécutées pour passer d'un état à l'autre dans la susdite séquence opératoire, et les fragments supprimables étant les portions de programme correspondant aux arcs qui ne sont plus accessibles à partir d'un certain nœud sous la condition que l'exécution conduit à l'état représenté par ce nœud.- merging of the resulting program states which are similar, generalizing them if necessary; the nodes of the graph being constituted by the different states encountered in the above operating sequence, the arcs between two states of this graph representing the portions of the program executed to pass from one state to another in the above operating sequence, and the fragments deletable being the portions of the program corresponding to the arcs which are no longer accessible from a certain node under the condition that the execution leads to the state represented by this node.
5. Procédé selon la revendication 4, caractérisé en ce que l'arrêt de la susdite séquence avec certitude est mis en œuvre selon au moins l'un des deux processus suivants : • la modélisation de l'état d'un programme de manière à ce qu'il n'existe qu'un nombre fini de configurations différentes,5. Method according to claim 4, characterized in that the stopping of the above sequence with certainty is implemented according to at least one of the following two processes: • modeling the state of a program so as to that there are only a finite number of different configurations,
• la généralisation des états résultants pour borner le nombre d'états à considérer, l'état quelconque généralisant tous les autres et garantissant ainsi que la fin du processus puisse toujours être forcée. • the generalization of the resulting states to limit the number of states to be considered, the arbitrary state generalizing all the others and thus guaranteeing that the end of the process can always be forced.
6. Procédé selon la revendication 4, caractérisé en ce qu'il comprend une détermination des fragments de programme supprimables qui s'effectue en fonction d'un ou plusieurs des paramètres suivants : • le degré de précision avec lequel les états du programme sont modélisés,6. Method according to claim 4, characterized in that it comprises a determination of the deletable program fragments which is carried out as a function of one or more of the following parameters: • the degree of precision with which the states of the program are modeled ,
• le degré de précision avec lequel les interactions avec le programme sont modélisées,• the degree of precision with which the interactions with the program are modeled,
• la possibilité de création d'états intermédiaires entre chaque interaction avec le programme,• the possibility of creating intermediate states between each interaction with the program,
• les conditions d'emploi de la généralisation d'état pour forcer la terminaison de l'algorithme.• the conditions of use of the generalization of state to force the termination of the algorithm.
7. Procédé selon la revendication 1, caractérisé en ce que l'instrumentation du programme consiste en une ou plusieurs des informations suivantes :7. Method according to claim 1, characterized in that the instrumentation of the program consists of one or more of the following information:
• des données auxiliaires n'altérant pas l'exécution du programme et destinées à être exploitées par le système d'exécution,• auxiliary data that does not alter the execution of the program and intended to be used by the execution system,
• des instructions supplémentaires incluses dans le corps du programme et destinées à être exécutées au même titre que les instructions ordinaires du programme.• additional instructions included in the body of the program and intended to be executed in the same way as ordinary program instructions.
8. Procédé selon la revendication 1, caractérisé en ce qu'il comprend un marquage des fragments supprimables effectué de la manière suivante :8. Method according to claim 1, characterized in that it comprises a marking of the deletable fragments carried out in the following manner:
• le repérage d'une adresse de début et d'une adresse de fin du fragment, et/ou• the identification of a start address and an end address of the fragment, and / or
• le repérage d'une adresse de début ou de fin et de la longueur du fragment, et/ou • le repérage d'un identifiant de routine, et/ou • l'introduction de marques spéciales, neutres pour l'exécution, pour indiquer l'emplacement du début et de la fin d'un fragment.• the location of a start or end address and the length of the fragment, and / or • the location of a routine identifier, and / or • the introduction of special marks, neutral for execution, to indicate the location of the start and end of a fragment.
9. Procédé selon la revendication 1, caractérisé en ce que les conditions de suppression sont basées sur :9. Method according to claim 1, characterized in that the suppression conditions are based on:
• le contrôle courant du programme, et/ou• routine control of the program, and / or
• les données courantes manipulées par le programme.• the current data handled by the program.
10. Procédé selon la revendication 2, caractérisé en ce que la transformation du programme pour augmenter l'économie mémoire apportée par la suppression de code s'effectue selon au moins l'une des trois possibilités suivantes :10. Method according to claim 2, characterized in that the transformation of the program to increase the memory economy provided by the deletion of code is carried out according to at least one of the following three possibilities:
• le déplacement des fragments supprimables initialement séparés dans le corps du programme, pour devenir contigus, « le positionnement des fragments supprimables dans des routines spécifiques,• the displacement of the deletable fragments initially separated in the body of the program, to become contiguous, “the positioning of the deletable fragments in specific routines,
• le regroupement des fragments supprimables en fin de bloc de programme dans l'ordre inverse de suppression probable.• regrouping of the fragments that can be deleted at the end of the program block in the reverse order of probable deletion.
11. Procédé selon l'une des revendications 4 et 10, caractérisé en ce que, dans le cas où les fragments supprimables sont déterminés par analyse statique de programme, un ordre de suppression convenable est fourni par un parcours en profondeur d'abord du graphe d'état, en partant de l'état initial, et une sélection des fragments supprimables rencontrés lors de ce parcours.11. Method according to one of claims 4 and 10, characterized in that, in the case where the deletable fragments are determined by static program analysis, a suitable deletion order is provided by first traversing the graph in depth state, starting from the initial state, and a selection of the deletable fragments encountered during this journey.
12. Procédé selon la revendication 10, caractérisé en ce que certains fragments qui sont supprimables en fonction des données dynamiques, peuvent être omis de la suppression pour aménager une chaîne continue de fragments dont la suppression successive est certaine. 12. Method according to claim 10, characterized in that certain fragments which can be deleted as a function of the dynamic data, can be omitted from the deletion to arrange a continuous chain of fragments whose successive deletion is certain.
13. Procédé selon la revendication 1, caractérisé en ce que la structuration en mémoire d'un programme avec fragments supprimables et la suppression effective de ces fragments pour permettre la réutilisation des zones mémoire libérées correspondantes s'effectuent selon au moins l'un des quatre types de suppression suivants :13. Method according to claim 1, characterized in that the structuring in memory of a program with deletable fragments and the effective deletion of these fragments to allow the reuse of the corresponding freed memory areas is carried out according to at least one of the four following types of deletion:
• si le programme est statiquement préfragmenté, chaque fragment à supprimer est libéré individuellement, auprès du gestionnaire mémoire du système,• if the program is statically prefragmented, each fragment to be deleted is freed individually, with the memory manager of the system,
• si le gestionnaire mémoire du système permet une fragmentation dynamique, le programme est fragmenté au vol et les fragments à supprimer sont libérés individuellement, comme dans le cas précédent,• if the system memory manager allows dynamic fragmentation, the program is fragmented on the fly and the fragments to be deleted are released individually, as in the previous case,
• si les fragments à supprimer sont localisés en fin de blocs mémoire, l'espace mémoire correspondant est libéré en redimensionnant les blocs pour en réduire la taille, • si le système est muni d'un mécanisme pour reloger du code, tous les éléments non supprimés du programme sont rassemblés en début de bloc, relogés, et le bloc est redimensionné pour en réduire la taille.• if the fragments to be deleted are located at the end of memory blocks, the corresponding memory space is freed by resizing the blocks to reduce their size, • if the system is equipped with a mechanism to re-code, all the elements not deleted from the program are gathered at the start of the block, re-located, and the block is resized to reduce its size.
14. Procédé selon la revendication 1 destiné à être implémenté sur des systèmes embarqués, caractérisé en ce qu'un programme à fragments supprimables s'exécutant sur ces susdits systèmes est structuré en mémoire selon les informations mises à disposition par l'instrumentation de ce programme, et en ce que des fragments supprimables sont effectivement supprimés lorsque les conditions stipulées par l'instrumentation du programme sont remplies. 14. The method of claim 1 intended to be implemented on embedded systems, characterized in that a program with removable fragments executing on these above systems is structured in memory according to the information made available by the instrumentation of this program , and in that deletable fragments are effectively deleted when the conditions stipulated by the instrumentation of the program are fulfilled.
PCT/FR2003/003736 2002-12-18 2003-12-15 Program compaction method employing dynamic code deletion WO2004061655A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
AU2003300617A AU2003300617A1 (en) 2002-12-18 2003-12-15 Program compaction method employing dynamic code deletion

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
FR02/16253 2002-12-18
FR0216253A FR2849229B1 (en) 2002-12-18 2002-12-18 METHOD OF PROGRAM COMPACTION BY DYNAMIC CODE DELETION

Publications (1)

Publication Number Publication Date
WO2004061655A1 true WO2004061655A1 (en) 2004-07-22

Family

ID=32406232

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/FR2003/003736 WO2004061655A1 (en) 2002-12-18 2003-12-15 Program compaction method employing dynamic code deletion

Country Status (3)

Country Link
AU (1) AU2003300617A1 (en)
FR (1) FR2849229B1 (en)
WO (1) WO2004061655A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0996059A2 (en) * 1998-10-19 2000-04-26 International Business Machines Corporation Class loading model
US6170083B1 (en) * 1997-11-12 2001-01-02 Intel Corporation Method for performing dynamic optimization of computer code
US6247175B1 (en) * 1998-12-22 2001-06-12 Nortel Networks Limited Method and apparatus for identifying and removing unused software procedures
US20020013938A1 (en) * 2000-02-09 2002-01-31 Evelyn Duesterwald Fast runtime scheme for removing dead code across linked fragments
US20020029357A1 (en) * 1998-11-16 2002-03-07 Insignia Solution, Plc Method and system of memory management using stack walking

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6170083B1 (en) * 1997-11-12 2001-01-02 Intel Corporation Method for performing dynamic optimization of computer code
EP0996059A2 (en) * 1998-10-19 2000-04-26 International Business Machines Corporation Class loading model
US20020029357A1 (en) * 1998-11-16 2002-03-07 Insignia Solution, Plc Method and system of memory management using stack walking
US6247175B1 (en) * 1998-12-22 2001-06-12 Nortel Networks Limited Method and apparatus for identifying and removing unused software procedures
US20020013938A1 (en) * 2000-02-09 2002-01-31 Evelyn Duesterwald Fast runtime scheme for removing dead code across linked fragments

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ARNOLD M ET AL: "Online feedback-directed optimization of Java", 17TH INTERNATIONAL CONFERENCE ON OBJECT-ORIENTED PROGRAMMING, SYSTEMS, LANGUAGES AND APPLICATIONS (OOPSLA 2002), SEATTLE, WA, USA, 4-8 NOV. 2002, vol. 37, no. 11, November 2002 (2002-11-01) - 8 November 2002 (2002-11-08), SIGPLAN Notices, Nov. 2002, ACM, USA, pages 111 - 129, XP002251020, ISSN: 0362-1340 *
TIP F ET AL: "Practical experience with an application extractor for Java", CONFERENCE ON OBJECT-ORIENTED PROGRAMMING, SYSTEMS, LANGUAGES AND APPLICATIONS (OOPSLA'99), DENVER, CO, USA, 1-5 NOV. 1999, vol. 34, no. 10, October 1999 (1999-10-01) - 5 November 1999 (1999-11-05), SIGPLAN Notices, Oct. 1999, ACM, USA, pages 292 - 305, XP002251021, ISSN: 0362-1340 *

Also Published As

Publication number Publication date
AU2003300617A1 (en) 2004-07-29
FR2849229B1 (en) 2005-02-25
FR2849229A1 (en) 2004-06-25

Similar Documents

Publication Publication Date Title
EP1046105B1 (en) Data compaction method for an intermediate object code programme executable in an onboard system provided with data processing resources and corresponding onboard system with multiple applications
EP2786317B1 (en) Writing data in a non-volatile memory of a smart card
EP1386230B1 (en) Method and system for managing shared-library executables
CN102279748A (en) Method, system, server and client side for remotely storing locally executed software
EP2350836B1 (en) Device for managing data buffers in a memory space divided into a plurality of memory elements
EP0421845A1 (en) Virtual addressing method to operate a memory in a computer system and device for carrying out said method
EP2210209A1 (en) Method for managing access rights in a smart card
FR2827974A1 (en) PROCESS FOR THE COMPRESSION OF A CODE INTERPRETED BY SEMANTIC ANALYSIS
KR20020061543A (en) Method and device for downloading application data
EP3507690B1 (en) Java card application memory footprint optimization
WO2004061655A1 (en) Program compaction method employing dynamic code deletion
FR2823330A1 (en) Loading of application code data into a programmable computer chip memory or similar device, uses data designed to be managed in two modes the first of which is provisory
US20100179980A1 (en) Cache system for mobile communications devices
EP1365323B1 (en) Method to exchange information between operating systems hosted on a same computer
US10915270B2 (en) Random file I/O and chunked data upload
CA2352420A1 (en) Memory management device for entering data blocks by substitution
EP2901291B1 (en) Method for managing the memory resources of a security device, such as a smart card, and security device implementing said method
EP2530586B1 (en) Method for generating software
FR2864650A1 (en) METHOD FOR UPDATING APPLICATIONS FOR A CHIP CARD
CA2504431C (en) Microcircuit card comprising means for publishing its computer objects
WO2021130420A1 (en) Method and device implementing said method for generating and installing an executable code in the memory of a core of a virtual machine from a hypervisor
CN101460932A (en) Device for remote defragmentation of an embedded device
EP3470999A1 (en) Securing of conditional connection instructions composed in a computer program in intermediate code
CN115134349B (en) Method, device, medium and equipment for executing transmission task
EP1070303B1 (en) Method for indivisibly modifying a plurality of sites in a microcircuit card non volatile memory, in particular a contactless card

Legal Events

Date Code Title Description
AK Designated states

Kind code of ref document: A1

Designated state(s): AE AG AL AM AT AU AZ BA BB BG BR BY BZ CA CH CN CO CR CU CZ DE DK DM DZ EC EE ES FI GB GD GE GH GM HR HU ID IL IN IS JP KE KG KP KR KZ LC LK LR LS LT LU LV MA MD MG MK MN MW MX MZ NO NZ OM PG PH PL PT RO RU SC SD SE SG SK SL TJ TM TN TR TT TZ UA UG US UZ VC VN YU ZA ZM ZW

AL Designated countries for regional patents

Kind code of ref document: A1

Designated state(s): BW GH GM KE LS MW MZ SD SL SZ TZ UG ZM ZW AM AZ BY KG KZ MD RU TJ TM AT BE BG CH CY CZ DE DK EE ES FI FR GB GR HU IE IT LU MC NL PT RO SE SI SK TR BF BJ CF CG CI CM GA GN GQ GW ML MR NE SN TD TG

121 Ep: the epo has been informed by wipo that ep was designated in this application
122 Ep: pct application non-entry in european phase
NENP Non-entry into the national phase

Ref country code: JP

WWW Wipo information: withdrawn in national office

Country of ref document: JP