WO2003019366A1 - Compression of a programme in intermediate language - Google Patents

Compression of a programme in intermediate language Download PDF

Info

Publication number
WO2003019366A1
WO2003019366A1 PCT/FR2002/002962 FR0202962W WO03019366A1 WO 2003019366 A1 WO2003019366 A1 WO 2003019366A1 FR 0202962 W FR0202962 W FR 0202962W WO 03019366 A1 WO03019366 A1 WO 03019366A1
Authority
WO
WIPO (PCT)
Prior art keywords
instructions
sequence
instruction
macro
processing device
Prior art date
Application number
PCT/FR2002/002962
Other languages
French (fr)
Inventor
Gilles Grimaud
Gabriel Bizzotto
Original Assignee
Gemplus
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 Gemplus filed Critical Gemplus
Publication of WO2003019366A1 publication Critical patent/WO2003019366A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation
    • G06F8/4434Reducing the memory space required by the program code

Definitions

  • the present invention relates to the compression of a program compiled in intermediate language, such as an applet or a class library originally written in a high level object oriented language.
  • the compiled language is made up of standard instructions in the form of bytes of code, also called "bytecodes".
  • the data processing device in which the compression of the intermediate language program can be carried out is in particular a portable electronic object whose processing capacities as well as the memory capacities are relatively limited.
  • the portable electronic object is a smart card.
  • the compression of standard instructions to which the invention refers is without loss of information. More specifically, the compression according to the invention must comply with certain constraints on the succession of instructions as well as. on the succession of bytes of code in the instructions, which constraints prohibit the use of known compression algorithms of the LZ (Lempel, Ziv) or Huffman type.
  • a second solution consists in directly transmitting the program compiled in intermediate language without any other processing outside the chip card, then in completely compressing the program compiled in the chip card. This second solution has not been applied on the grounds that the compression algorithm which must be implemented in the smart card is far too complex compared to the processing and memory capacities in a smart card.
  • the present invention aims to compress a program compiled in intermediate language by not offering the drawbacks of the previous solutions. More particularly, the invention aims to prepare the effective compression in the smart card so that the smart card performs only the compression proper without being responsible for the choice of factorization of the instructions in the compiled program, and the compression in the smart card does not require any increase in memory and processing capacity.
  • a method for compressing a program compiled in intermediate language composed of successive instructions, according to which sequences of instructions are detected outside of a data processing device is characterized in that it comprises the stages of:
  • the method may include, after the step of loading, a step of checking the annotations loaded as a function of the constraints in the data processing device.
  • a first part outside the data processing device such as a portable electronic object which can be a smart card, analyzes the program compiled in intermediate language in order to generate annotations on the sequences repetitive instructions standardized according to the intermediate language which will make it possible to participate in the compression in the data processing device.
  • the annotations provide information on the characteristics of the detected sequences which will be transformed into macro-instructions.
  • Sequence analysis does not alter the instructions of the compiled program • that are well loaded without modification with the annotations in the data processing device in a conventional manner. Thus, the complexity of the analysis is transferred to the outside of the data processing device which will only proceed to the final compression process, the directives of which are previously prepared in the annotations.
  • the second part of the method is implemented in the data processing device, such as a smart card, in which the annotations are interpreted so that a compressor integrated in the data processing device produces according to the annotations and stores macro-instructions corresponding to repetitive instruction sequences compatible with predetermined constraints.
  • Each annotation relating to a sequence of instructions can comprise at least one address positioning the sequence of instructions in the compiled program and the length of the sequence of instructions, as well as the instructions contained in the sequence.
  • the AN annotations are included for example in an additional component which is linked to the compiled program and which is loaded with this into the data processing device.
  • the constraints imposed on each sequence of instructions to be compressed into macro-instructions can include at least one of the following: the instructions in the sequence are contained in the body of a common method; the instructions in the sequence do not contain any label in the sequence, except for the first instruction in the sequence; no instruction in the sequence except the last instruction in the sequence breaks the flow of execution of the compiled program.
  • the step of analyzing sequences can generate at least one annotation defining a so-called "associated" macroinstruction corresponding to an analyzed sequence of instructions contained in another previously analyzed sequence of instructions.
  • the step of analyzing sequences can generate at least one "global" macro-instruction corresponding to a sequence d 'instructions analyzed, the correspondence between the latter macro-instruction and sequence of instructions being previously stored in the. data processing device.
  • the step of producing and storing comprises writing each macro-instruction into a memory space of the data processing device into which the sequence of instructions corresponding to the macro-instruction has been loaded.
  • FIG. 1 is a block diagram of a telecommunications system comprising a server and a smart card in a reception terminal, showing the implementation of various software means for the implementation of the compiled program compression method in intermediate language according to the invention
  • FIG. 2 is an algorithm for verifying and executing an instruction sequence annotation for compressing instruction sequences in the smart card.
  • FIG. 1 shows both hardware and software means for implementing the invention in a portable electronic object, and electronic means external thereto.
  • the electronic object is typically a CA chip card, also called a microcontroller or integrated circuit card, housed in a removable manner in a reader of a TE reception terminal.
  • the external electronic means is an SE server connected to the reception terminal
  • FIG. 1 shows steps of the program compression method according to the invention which are carried out respectively by functional blocks in the aforementioned electronic entities SE and CA.
  • SIM Subscriber Identity Module
  • the smart card covers all known types of contact or contactless smart card, such as payment card, telephone card, additional card, game card, etc.
  • the program PG to be executed in the smart card CA was initially written in a high level language of the object oriented type such as the Java language, or more particularly the Java Card language.
  • This program can include one or more class files in order to form a package which can constitute an applet to be transmitted to the chip card and to be processed by the latter.
  • the server SE being an electronic entity external to the card CA, it belongs for example to The CA card editor or the editor of one or more applications installed in the CA card.
  • the server SE mainly comprises a compiler
  • the COM compiler is a known compiler for the Java language which converts the PG program in Java source language into a compiled PGC program in intermediate language, also called pseudo-code, composed of instruction words formed by bytes, called bytecodes, which are ready to be executed by an interpreter in the CA card.
  • the PG source language program such as an applet or a library
  • the COM compiler compiles them separately and a link editor groups them together as will be seen below on the CA card level.
  • Each instruction byte supports an instruction proper, that is to say an operation code (opcode) or one of the parameters of an instruction called operands.
  • opcode operation code
  • operands operands
  • the compression method according to the invention comprises a detection of repeated sequences of instructions SQ in the compiled program PGC in a step E2, then generates in intermediate language AN annotations respectively defining characteristics of the sequences repeated detected SQ in step E3. , The detected sequences are replaced later, during the actual compression in the chip card CP, by respective macro-instructions MI.
  • the two steps E2 and E3 are carried out by one semantic analyzer AS according to the invention.
  • Each of the 254-184-1 69 bytes of instruction remaining, which can each be followed by a predetermined number of bytes of parameters, called operands, are not used and are used to designate at least 69 macro 1-byte MI instructions.
  • the 69 possible macro-instructions preferably one of them is used to indicate that the following byte is an additional macro-instruction, called "extended" macro-instruction, which makes it possible to define 256 additional macro-instructions. thus each to 2 bytes.
  • a macro instruction MI is defined, defined by respective annotations AN in intermediate language.
  • the annotations on a given sequence mainly consist of a 2-byte indirection table comprising an ADSQ address specifying the position of the first instruction of the given sequence in the PGC program and the 3-bit LSQ length expressed in bytes of the given sequence. SQ and following instructions composing the given sequence.
  • the length LSQ of a repetitive instruction sequence coded on 3 bits makes it possible to detect sequences having sizes from 1 to 8 bytes in the normalized IN instructions of the PGC compiled program. For example, in the following series of standardized instructions IN of the PGC program: ...
  • ABCADBCABC in which each letter represents an instruction (opcode and possibly operand (s))
  • the analyzer AS finds the four repetitive sequences following: a sequence with three instructions ABC appearing twice, a sequence with two instructions BC appearing three times, a sequence with two instructions CA appearing twice, and a sequence with two instructions AB appearing twice.
  • the analyzer AS in fact only selects the first sequence with three instructions ABC as the preferred model in order to define a respective macroinstruction Ml which will factorize this sequence of repetitive instructions later during the compression carried out in the smart card CA.
  • the algorithm for selecting repetitive sequences to subsequently constitute macro-instructions included in the AS analyzer obeys certain criteria while respecting certain constraints so that each macro-instruction is easily executable by the IT interpreter, that is to say ie the Java Card virtual machine installed in the CA smart card.
  • the selection of a macro instruction depends not only on the length of the corresponding sequence saved by the macro instruction, but also on the reduction result resulting from the repetition of the sequence in the PGC compiled program after the sequence has been selected.
  • the analyzer AS again selects the sequence with two instructions BC which appears in the sequence ABC repeated twice as well as another time following the instruction D.
  • the analyzer AS then generates annotations AN relating to a macro-instruction M2 which define the characteristics of the sequence BC in order to find it later.
  • the macro-instruction M2 is said to be "associated” with, or “nested” with, the macro-instruction Ml, which means that the code of the macro-instruction M2 is a part of the code of the macro-instruction ml.
  • the compressed sequence contains the macro instruction M1 in place of each occurrence of the repetitive sequence ABC and the macro instruction M2 in place of each occurrence of the repetitive sequence BC contained in the sequence ABC analyzed above.
  • the analyzer AS receives the following sequence of instructions in which II and 12 are instruction bytes proper (opcode) and PI, P2 and P3 are parameter bytes: 12; II, PI, P2; he, PI, P3
  • the preceding sequence comprises a first sequence with seven bytes (12; II, PI, P2; II, PI, P3) repeated three times and a second sequence with three bytes (II, PI, P3) repeated twice, that is 27 bytes which should occupy the non-volatile memory of type EEPROM in the smart card CA, if the compiled program PGC containing this suite was not compressed.
  • the analyzer AS determines a second macroinstruction MI2 corresponding to the second sequence (II, PI, P3) which is repeated three times in the first repetitive sequence, then which is repeated twice in isolation.
  • the sequence subsequently compressed in the CA card is: ... Mil ... Mil ... Mil ... MI2 ... MI2 in which MI2 is associated "with Mil.
  • the factorization of the second sequence in macroinstruction MI2 saves another two bytes, and the final compressed program then occupies 16 bytes in non-volatile memory in the smart card.
  • the AN annotations generated by the standardized instruction semantic analyzer AS respect several constraints CSQ on the instruction sequences, so that each macro-instruction MI defined by annotations during the subsequent compression can be easily executed by the IT interpreter and preserves the security properties provided by the verifier:
  • the instructions of the SQ sequence must not contain any label (label), only the first instruction of the repetitive sequence can be pointed by a label, which means that the macro-instruction itself will be pointed by a label; - CSQ3) the instructions in the SQ sequence must not contain any standard instruction breaking the execution flow such as direction, switching, conditioned jump instructions, etc. (GOTO, S ITCH, INVOKE, JUMP SUBROUTINE, JUMP-CONDITION, etc.); only the last instruction in the sequence can break the execution flow; reading the last operand byte of this last instruction will trigger the end of the macro-instruction and the continuation of the compressed program, as if it was the macro-instruction itself which broke the flow of execution.
  • the IT interpreter that is to say the virtual machine, implemented in the smart card CA
  • macro-instructions executable directly by the interpreter.
  • These macro-instructions hereinafter called "global macro-instructions" MG
  • more than a hundred global MG macro-instructions can be identified; for each compiled PGC program sent to the card, the AS analyzer. can only select at most 69 global macro-instructions among the hundred global macro-instructions.
  • the AN analyzer after having detected a repetitive sequence of instructions SQ in the PGC program, searches for the sequence detected in a TMG table matching sequences SQ to of global macro-instructions MG.
  • the analyzer AS considers that the macro-instruction corresponding to the detected sequence is a global macro-instruction MG which is already known by the interpreter IT and whose annotations pre - memorized AN are read by the analyzer in a step E5.
  • the annotations for a global macro are reduced to one byte generated by the AS analyzer. If no sequence in the TMG correspondence table is identical to the sequence detected in step E4, the analyzer AS generates the annotations AN defining a new macroinstruction MI, in step E3.
  • the instructions of a sequence corresponding to a global macro-instruction MG also satisfy the first two constraints CSQ1 and CSQ2 stated previously for instructions of an MI macroinstruction defined by the AS parser, namely that the sequence of instructions must start inside a method body and end in the same method body, and must not contain no label except . of the first instruction in the sequence.
  • a global macro-instruction MG must be strictly identical to the portion of code already stored in the ROM memory of the card CA in relation to the interpreter IT and defining the global macro-instruction.
  • the semantic instruction analyzer AS first detects the patterns of repetitive sequences of SQ instructions found in the compiled program PGC in step E2, then constructs a graph whose states are the patterns of the detected sequences and whose arrows define links between the macro-instructions corresponding to the detected sequences, in order to follow the graph and to try many sets of macro-instructions to select the best compression in step E3, taking into account, if they exist of global macroinstructions MG selected in step E4.
  • annotations AN containing the information on how to compress the instructions IN of the program PGC that is to say the indirection tables and the sequences of instructions SQ respectively defining the macro-instructions MI, MG, are included in an additional CAD component.
  • the additional component CAD includes in particular a byte representing the number of this one and two bytes indicating the size in byte of the component.
  • the format of the additional component CAD allows the compression of the instructions in intermediate language IN in a single pass in the smart card CA.
  • the additional component includes entries which each define a code area in the PGC program, that is to say a sequence of SQ instructions, which is to be replaced by a respective macro instruction.
  • the entry for the first zone containing the sequence marks the beginning of the sequence, the number of repetitions of the sequence, its length and the macro-instruction which it contains.
  • the start of the code zone to be compressed is determined by means of a displacement field which indicates the number of instructions to be skipped in the following instructions of the PGC compiled program since the end of the last zone to be compressed containing the same sequence of SQ instructions.
  • the secure charger CH assembles the instruction component CN (IN) and the additional annotation component CAD (AN) into a PCH program which is downloaded into the smart card CA through the internet network RES and the TE terminal.
  • the smart card CA essentially comprises a verifier VER and an editor for links EL, a compressor CP and the interpreter IT.
  • these latter software modules are installed in the non-volatile memory EEPROM and the ROM ROM of the smart card CA.
  • the IT interpreter is a Java Card virtual machine which is capable of sequentially interpreting the normalized instructions IN of a PGC compiled program loaded in the card's EEPROM memory. After interpretation of an IN instruction, the IT interpreter has it executed in native code by the microprocessor PR of the card.
  • the PCH program When the PCH program is transmitted by the server SE through the internet network RES via the terminal TE, the PCH program is loaded into the verifier VER of the card through the browser and an intermediate software module of plugin or proxy type of the terminal.
  • the verifier VER provides security functions in order to verify that the loaded program PCH contains files and classes and more precisely IN instructions as well as annotations AN according to the invention which are compatible with the bytecode of the IT interpreter.
  • the VER verifier can analyze a signature of the loaded PCH program in order to ensure that the instructions contained in it have not been modified since it was signed in the secure loader CH.
  • the EL linker identifies the links between the various files and classes contained in the loaded PCH program and in particular between the additional CAD annotation component (AN) and the standard instruction component CN (IN) in order to write these components respectively in MAN and MIN memory spaces linked to the CP compressor.
  • the operation of compressing the instructions contained in the received component CN (IN) carried out in the compressor CP is closely linked to a verification of the annotations and to an execution of these in the verifier VER. 66
  • the verification and execution of the annotations to effect the compression of the instructions mainly comprise steps SI to SU implemented in the modules VER and CP, as shown in FIG. 2.
  • the PAN pointer is a pointer for reading the annotations AN of the additional component CAD written in the memory space MAN.
  • the pointer PL is a read pointer for reading uncompressed instructions IN from the received component CN (IN) loaded in the memory space MIN.
  • the pointer PE is a pointer for writing instructions compressed in the memory space MIN in order to write there the macro-instructions MI, MG, resulting from the compression of sequences received SQ according to corresponding annotations received, as well as write any instructions there that are not compressed between the detected sequences.
  • the compression is carried out in a single pass of the sequence of uncompressed IN instructions included in the loaded component CN (IN), and the instructions received uncompressed and the instructions compressed at least in part are respectively read and written in the same MIN memory space in order to optimize the memory space occupied by the program loaded PCP after compression.
  • the read pointer PL then progresses faster than the write pointer PE.
  • step SI the pointer PAN commands the reading of a current entry in the additional component CAD, that is to say the reading of a current annotation AN in the memory space MAN.
  • the current annotation AN read is checked in step S2 as a function of the sequence of instructions SQ to be compressed corresponding to the annotation AN and read by the read pointer PL in the memory space MIN.
  • the verification in step S2 consists in checking the characteristics of the sequence read SQ with regard to the sequence constraints CSQ defined above. If the characteristics of the sequence SQ do not satisfy the constraints CSQ1 to CSQ3, the sequence SQ is not compressed in step S3, and is rewritten without modification in the memory space MIN according to the pointer of writing PE. For example, step S2 verifies that the sequence SQ to be compressed does not contain any label (label) unless the first instruction is a label, in which case the corresponding macro-instruction will be a label.
  • step S4 checks that the macro-instruction MI, MG designated by the current annotation AN is already defined in the compressor CP may include the correspondence table, TMG relating to global micro-instructions.
  • the compressor creates and stores in step S6 the macro-instruction MI in correspondence with the sequence of SQ instructions; more precisely, a correspondence table in the compressor CP writes the correspondence between the indirection table comprising the sequence address ADSQ and the length LSQ of the sequence SQ and the sequence of instructions composing the sequence SQ on the one hand and the macro - MI instruction, on the other hand.
  • step S5 succeeding step S4, the macroinstruction designated by the current annotation AN is deemed to be "associated" with another macroinstruction, like the macroinstruction M2 associated with the macroinstruction Ml in the example below above instructions, the compressor CP creates and stores the macro-instruction MI in step S7, as in step S6, but with a reference index to the macro-instruction with which it is associated. This indication subsequently allows the interpreter IT to execute the macro-instruction deemed to be “associated” MI in the macro-instruction with which it is associated.
  • step S4 when the macro-instruction MI defined by the current annotation AN is already listed in a table in the compressor CP, either the macro-instruction MI has already been created during a previous step S6 or S7, ie the macro-instruction designated MI is a global macro-instruction MG initially contained in the compressor CP before the loading of the program PCH.
  • the next step S8 then verifies that the sequence of instructions SQ read by the pointer PL in step S2 is exactly identical to the sequence SQ stored in a correspondence table of the compressor CP in correspondence with the macro-instruction MI, MG designated by the current annotation AN. If this is not the case, the compressor S3 refuses to compress the sequence of instructions SQ read.
  • the CP compressor After the step of creating macro-instruction S6 or S7, or when the sequence read SQ is exactly identical to the sequence stored in a correspondence table in correspondence with the macro-instruction designated MI, MG in step S8, the CP compressor performs sequence compression of instructions read SQ in step S9, by replacing the sequence SQ in the component loaded CN (IN) by the macro-instruction designated MI, MG which is written in the memory space MIN according to the writing pointer EP.
  • the pointer PE is then incremented by one and, if necessary, by the number of following instructions contained in the component CN (IN) which are not to be compressed and which are to be rewritten following the macro-instruction MI , MG resulting from the compression of the last sequence SQ read in the memory space MIN.
  • the two pointers PAN and PL are incremented suitably before proceeding to verify the next annotation in the additional component CAD, as a function of the number of any subsequent instructions not to be compressed.
  • the annotation read pointer PAN is incremented by one to go to the next annotation
  • the read pointer PL which has been incremented by the length LSQ of the sequence SQ which has just been compressed is also incremented by number of uncompressed intermediate instructions.
  • Step S10 is followed by step SI if there are still annotations to be processed in the additional component CAD in the memory space MAN.
  • the compressor CP stops the compression in step SU so that possibly the interpreter IT executes the compressed instruction program PCP.
  • the execution of the compressed compressed CP by the IT interpreter takes place in the following manner, with reference to the following series of standardized instructions in the compiled program PGC ' and therefore written in the MIN memory space when the corresponding program PCH is loaded after step E5: ... ABCADBCABC ..., corresponding to the following series of compressed instructions rewritten in the MIN memory space:
  • the interpreter IT first interprets the first occurrence of the macroinstruction M1.
  • the macro-instruction M1 is a macro-instruction specific to the initial program PGC and composed of three normalized instructions A, B and C.
  • the address AD (ABC) and the length L (ABC) of the sequence corresponding to the macro-instruction Ml is coded in a compact form in the correspondence table linked to the PCP program.
  • the current program counter is then positioned on the macro-instruction M1 and the three normalized instructions A, B and C are processed and interpreted. Then the program counter goes to the next instruction which is the macro-instruction Gl marked as global.
  • the interpreter IT then reads a correspondence table as a function of the address of the global macroinstruction G1 so as to read there the native code CAD in order to execute the corresponding operation. Then the next instruction in the compressed program PCP is the macro-instruction M2 "associated" with the macro-instruction Ml already executed once.
  • the correspondence table is consulted by the IT interpreter in order to read there the two standard instructions B and C pointed by the program counter. After execution of the two standardized instructions corresponding to the macro-instruction M2, the macro-instruction Ml is executed again.
  • the interpretation implemented in the IT interpreter is not thus modified but simply extended. When a macro-instruction must be executed by the interpreter, the latter reads the instructions corresponding to the macro-instruction in the correspondence table as if it were executing a single instruction.
  • the loading, verification, link editing, compression and interpretation in the VER verifier, the EL link editor and the compressor CP are carried out on the fly, almost simultaneously as and when loading the PCH program into the CA card.

Abstract

The invention concerns a method for compressing a programme compiled in intermediate language (PGC), whereby instruction sequences (SQ) of the programme are detected and analysed outside a low-capacity data processing device, such as a smart card (CA), so as to generate (E3) annotations (AN) in intermediate language defining macro-instructions (MI) when the detected instruction sequences satisfy predetermined constraints (CSQ). The data processing device thus released from analysing sequences verifies (VER) the loaded annotations (AN) in accordance with the constraints, and produces and stores (CP) macro-instructions (MI) defined by the annotations, for replacement of the loaded instruction sequences.

Description

Compression d'un programme en langage intermédiaire Compression of a program in intermediate language
La présente invention concerne la compression d'un programme compilé en langage intermédiaire, tel qu'une applet ou une bibliothèque de classes écrite initialement dans un langage de haut niveau orienté objet. Le langage compilé est composé d'instructions normalisées sous forme d'octets de code, appelés également "bytecodes". Le dispositif de traitement de données dans lequel la compression du programme en langage intermédiaire peut être effectuée est notamment un objet électronique portable dont les capacités de traitement ainsi que les capacités de mémoire sont relativement limitées. Typiquement, l'objet électronique portable est une carte à puce .The present invention relates to the compression of a program compiled in intermediate language, such as an applet or a class library originally written in a high level object oriented language. The compiled language is made up of standard instructions in the form of bytes of code, also called "bytecodes". The data processing device in which the compression of the intermediate language program can be carried out is in particular a portable electronic object whose processing capacities as well as the memory capacities are relatively limited. Typically, the portable electronic object is a smart card.
La compression d'instructions normalisées auxquelles se réfère 1 ' invention est sans perte d'information. Plus précisément, la compression selon l'invention doit respecter certaines contraintes sur la succession des instructions ainsi que . sur la succession des octets de code dans les instructions, lesquelles contraintes interdisent l'utilisation d'algorithmes de compression connus du type LZ (Lempel, Ziv) ou Huffman.The compression of standard instructions to which the invention refers is without loss of information. More specifically, the compression according to the invention must comply with certain constraints on the succession of instructions as well as. on the succession of bytes of code in the instructions, which constraints prohibit the use of known compression algorithms of the LZ (Lempel, Ziv) or Huffman type.
A priori, pour compresser un programme compilé en langage intermédiaire, deux solutions sont apparemment possibles . Selon une première solution proposée par la demande de brevet F -A-2785695, le programme compilé en langage intermédiaire est compressé à 1 ' extérieur de la carte à puce, puis le programme compilé compressé est transmis à la carte à puce pour y être mémorisé. La compression à l'extérieur de la carte à puce engendre de nouvelles instructions qui sont additionnées au programme initial et qui rompt la compatibilité avec les instructions compilées en langage intermédiaire. Les nouvelles instructions sont méconnues par 1 ' interpréteur dans la carte qui refusera d'enregistrer et . d'exécuter le programme ainsi compressé si l'interpréteur de la carte n'a pas été modifié auparavant.A priori, to compress a program compiled in intermediate language, two solutions are apparently possible. According to a first solution proposed by patent application F -A-2785695, the program compiled in intermediate language is compressed outside the chip card, then the compressed compiled program is transmitted to the chip card to be stored there. . Compression on the outside of the card puce generates new instructions which are added to the initial program and which breaks the compatibility with the instructions compiled in intermediate language. The new instructions are ignored by the interpreter in the card who will refuse to record and. execute the program thus compressed if the card interpreter has not been modified before.
Une deuxième solution consiste à transmettre directement le programme compilé en langage intermédiaire sans autre traitement à 1 ' extérieur de la carte à puce, puis à compresser complètement le programme compilé dans la carte à puce . Cette deuxième solution n'a pas reçu application au motif que 1 ' algorithme de compression qui doit être implémenté dans la carte à puce est beaucoup trop complexe par rapport aux capacités de traitement et de mémoire dans une carte à puce .A second solution consists in directly transmitting the program compiled in intermediate language without any other processing outside the chip card, then in completely compressing the program compiled in the chip card. This second solution has not been applied on the grounds that the compression algorithm which must be implemented in the smart card is far too complex compared to the processing and memory capacities in a smart card.
En outre, chacune de ces deux solutions impose certaines modifications de l'interpréteur, c'est-à- dire de la machine virtuelle dans la carte à puce .In addition, each of these two solutions imposes certain modifications of the interpreter, that is to say of the virtual machine in the smart card.
La présente invention vise à compresser un programme compilé en langage intermédiaire en n'offrant pas les inconvénients des solutions précédentes. Plus particulièrement, l'invention a pour objectif de préparer la compression effective dans la carte à puce afin que la carte à puce n'effectue que la compression proprement dite sans être chargée du choix de la factorisation des instructions dans le programme compilé, et la compression dans la carte à puce ne nécessite aucune augmentation de capacité de mémoire et de traitement . A cette fin, un procédé pour compresser un programme compilé en langage intermédiaire composé d'instructions successives, selon lequel des séquences d'instructions sont détectées à l'extérieur d'un dispositif de traitement de données, est caractérisé en ce qu'il comprend les étapes de :The present invention aims to compress a program compiled in intermediate language by not offering the drawbacks of the previous solutions. More particularly, the invention aims to prepare the effective compression in the smart card so that the smart card performs only the compression proper without being responsible for the choice of factorization of the instructions in the compiled program, and the compression in the smart card does not require any increase in memory and processing capacity. To this end, a method for compressing a program compiled in intermediate language composed of successive instructions, according to which sequences of instructions are detected outside of a data processing device, is characterized in that it comprises the stages of:
- analyser, à l'extérieur du dispositif de traitement de données, des séquences d'instructions détectées afin de générer respectivement des annotations en langage intermédiaire définissant des macro-instructions respectives lorsque les séquences d'instructions détectées satisfont des contraintes prédéterminées,- analyze, outside the data processing device, detected instruction sequences in order to respectively generate annotations in intermediate language defining respective macro-instructions when the detected instruction sequences satisfy predetermined constraints,
- charger depuis l'extérieur les instructions et les annotations dans le dispositif de traitement de données, et- load instructions and annotations from the outside into the data processing device, and
- produire et mémoriser dans le dispositif de traitement de données des macro-instructions définies par des annotations de séquences d'instructions chargées, respectivement en remplacement des séquences d'instructions chargées.- Producing and storing in the data processing device macro-instructions defined by annotations of loaded instruction sequences, respectively replacing the loaded instruction sequences.
En variante complémentaire, le procédé peut comprendre après l'étape de charger, une étape de vérifier les annotations chargées en fonction des contraintes dans le dispositif de traitement de données .In an additional variant, the method may include, after the step of loading, a step of checking the annotations loaded as a function of the constraints in the data processing device.
Ainsi la compression selon 1 ' invention est divisée en deux parties.Thus the compression according to the invention is divided into two parts.
Une première partie à l'extérieur du dispositif de traitement de données, tel qu'un objet électronique portable qui peut être une carte à puce, analyse le programme compilé en langage intermédiaire afin de générer des annotations sur les séquences d'instructions répétitives normalisées selon le langage intermédiaire qui permettront de participer à la compression dans le dispositif de traitement de données . Les annotations renseignent sur les caractéristiques des séquences détectées qui seront à transformer en macro-instructions. L'analyse de séquences ne modifie pas les instructions du programme compilé qui sont ainsi chargées sans modification avec les annotations dans le dispositif de traitement de données d'une manière conventionnelle. Ainsi, la complexité de l'analyse est déportée à l'extérieur du dispositif de traitement de données qui ne procédera qu'au processus final de la compression dont les directives sont préalablement préparées dans les annotations .A first part outside the data processing device, such as a portable electronic object which can be a smart card, analyzes the program compiled in intermediate language in order to generate annotations on the sequences repetitive instructions standardized according to the intermediate language which will make it possible to participate in the compression in the data processing device. The annotations provide information on the characteristics of the detected sequences which will be transformed into macro-instructions. Sequence analysis does not alter the instructions of the compiled program that are well loaded without modification with the annotations in the data processing device in a conventional manner. Thus, the complexity of the analysis is transferred to the outside of the data processing device which will only proceed to the final compression process, the directives of which are previously prepared in the annotations.
La deuxième partie du procédé est mise en œuvre dans le dispositif de traitement.de données, tel que carte à - puce, dans lequel les annotations sont interprétées afin qu'un compresseur intégré dans le dispositif de traitement de données produise selon les annotations et mémorise les macro-instructions en correspondance aux séquences d'instructions répétitives compatibles avec les contraintes prédéterminées .The second part of the method is implemented in the data processing device, such as a smart card, in which the annotations are interpreted so that a compressor integrated in the data processing device produces according to the annotations and stores macro-instructions corresponding to repetitive instruction sequences compatible with predetermined constraints.
Chaque annotation relative à une séquence d'instructions peut comprendre au moins une adresse positionnant la séquence d'instructions dans le programme compilé et la longueur de la séquence d'instructions, ainsi que les instructions contenues dans la séquence. Les annotations AN sont incluses par exemple dans un composant additionnel qui est lié au programme compilé et qui est chargé avec celui-ci dans le dispositif de traitement de données. Les contraintes imposées sur chaque séquence d'instructions à compresser en macro-instructions peuvent comprendre au moins l'une des suivantes : les instructions dans la séquence sont contenues dans le corps d'une méthode commune ; les instructions dans la séquence ne contiennent aucune étiquette dans la séquence, à l'exception de la première instruction dans la séquence ; aucune instruction de la séquence à 1 ' exception de la dernière instruction de la séquence ne rompt le flot d'exécution du programme compilé .Each annotation relating to a sequence of instructions can comprise at least one address positioning the sequence of instructions in the compiled program and the length of the sequence of instructions, as well as the instructions contained in the sequence. The AN annotations are included for example in an additional component which is linked to the compiled program and which is loaded with this into the data processing device. The constraints imposed on each sequence of instructions to be compressed into macro-instructions can include at least one of the following: the instructions in the sequence are contained in the body of a common method; the instructions in the sequence do not contain any label in the sequence, except for the first instruction in the sequence; no instruction in the sequence except the last instruction in the sequence breaks the flow of execution of the compiled program.
L ' étape d' analyser des séquences peut générer au moins une annotation définissant une macroinstruction dite "associée" correspondant à une séquence d'instructions analysée contenue dans une autre séquence d'instructions analysée précédemment.The step of analyzing sequences can generate at least one annotation defining a so-called "associated" macroinstruction corresponding to an analyzed sequence of instructions contained in another previously analyzed sequence of instructions.
Lorsque le dispositif de traitement de données contient déjà des macro-instructions dites "globales" préalablement à l'analyse du programme compilé, l'étape d'analyser des séquences peut générer au moins une macro-instruction "globale" correspondant à une séquence d'instructions analysée, la correspondance entre ces dernières macro-instruction et séquence d'instructions étant préalablement mémorisée dans le. dispositif de traitement de données .When the data processing device already contains so-called "global" macro-instructions prior to the analysis of the compiled program, the step of analyzing sequences can generate at least one "global" macro-instruction corresponding to a sequence d 'instructions analyzed, the correspondence between the latter macro-instruction and sequence of instructions being previously stored in the. data processing device.
Lorsqu'une séquence d'instructions chargée correspond à une macro-instruction déjà produite au cours de la compression du programme compilé ou mémorisée préalablement à la compression dans le dispositif de traitement de. données, ladite séquence d'instructions est remplacée par ladite macroinstruction déjà produite ou mémorisée.When a loaded sequence of instructions corresponds to a macro-instruction already produced during the compression of the compiled program or stored before compression in the processing device. data, said sequence of instructions is replaced by said macroinstruction already produced or stored.
Afin d'optimiser l'occupation de l'espace mémoire dans le dispositif de traitement de données par la compression, l'étape de produire et mémoriser comprend une écriture de chaque macro-instruction dans un espace de mémoire du dispositif de traitement de données dans lequel la séquence d'instructions correspondant à la macro-instruction a été chargée.To optimize the use of memory space in the data processing device by compression, the step of producing and storing comprises writing each macro-instruction into a memory space of the data processing device into which the sequence of instructions corresponding to the macro-instruction has been loaded.
D ' autres caractéristiques et avantages de la présente invention apparaîtront plus clairement à la lecture de la description suivante de plusieurs réalisations préférées de l'invention en référence aux dessins annexés correspondants dans lesquels :Other characteristics and advantages of the present invention will appear more clearly on reading the following description of several preferred embodiments of the invention with reference to the corresponding appended drawings in which:
- la figure 1 est un bloc-diagramme d'un système de télécommunications comprenant un serveur et une carte à puce dans un terminal d'accueil, montrant 1 ' implantation de divers moyens logiciels pour la mise en oeuvre du procédé de compression de programme compilé en langage intermédiaire selon 1 ' invention ; et- Figure 1 is a block diagram of a telecommunications system comprising a server and a smart card in a reception terminal, showing the implementation of various software means for the implementation of the compiled program compression method in intermediate language according to the invention; and
- la figure 2 est un algorithme de vérification et d'exécution d'annotation de séquence d'instructions pour compresser des séquences d'instructions dans la carte à puce.FIG. 2 is an algorithm for verifying and executing an instruction sequence annotation for compressing instruction sequences in the smart card.
La figure 1 montre à la fois des moyens matériels et logiciels pour la mise en oeuvre de l'invention dans un objet électronique portable, et un moyen électronique externe à celui-ci. L'objet électronique est typiquement une carte à puce CA, dite également carte à microcontrôleur ou à circuit intégré, logée d'une manière amovible dans un lecteur d'un terminal d'accueil TE. Le moyen électronique externe est un serveur SE relié au terminal d'accueilFIG. 1 shows both hardware and software means for implementing the invention in a portable electronic object, and electronic means external thereto. The electronic object is typically a CA chip card, also called a microcontroller or integrated circuit card, housed in a removable manner in a reader of a TE reception terminal. The external electronic means is an SE server connected to the reception terminal
TE de la carte à travers un réseau de télécommunications de type internet RES . Les blocs représentés dans la figure 1 concernent des fonctions mises en oeuvre principalement par les entités électroniques SE et CA et peuvent correspondre à des modules logiciels implantés respectivement dans ces entités. En outre, la figure 1 montre des étapes du procédé de compression de programme selon l'invention qui sont réalisées respectivement par des blocs fonctionnels dans les entités électroniques précitées SE et CA.TE of the card through a RES internet type telecommunications network. The blocks shown in Figure 1 relate to functions implemented mainly by the electronic entities SE and CA and may correspond to software modules located respectively in these entities. In addition, FIG. 1 shows steps of the program compression method according to the invention which are carried out respectively by functional blocks in the aforementioned electronic entities SE and CA.
L'ensemble composé par le terminal électronique TE, tel qu'un ordinateur personnel PC ou un terminal bancaire ou un terminal point de vente, et la carte à puce CA peut être remplacé par un terminal radiotéléphonique avec une carte à puce d'abonné téléphonique SIM (Subscriber Identity Module) , ou bien par tout autre objet électronique portable tel qu'un assistant numérique personnel PDA ou porte- monnaie électronique relié par un modem au réseau RES . Il sera également compris que la carte à puce recouvre tous les types connus de carte à puce à contact ou sans contact, telle que carte de paiement, carte téléphonique, carte additionnelle, carte de jeux, etc.The assembly composed by the electronic terminal TE, such as a personal computer PC or a banking terminal or a point of sale terminal, and the smart card CA can be replaced by a radiotelephone terminal with a smart card for telephone subscribers SIM (Subscriber Identity Module), or by any other portable electronic object such as a personal digital assistant PDA or electronic wallet connected by a modem to the RES network. It will also be understood that the smart card covers all known types of contact or contactless smart card, such as payment card, telephone card, additional card, game card, etc.
Dans la suite, il sera supposé que le programme PG à exécuter dans la carte à puce CA a été écrit initialement dans un langage de haut niveau du type orienté objet tel que le langage Java, ou plus particulièrement le langage Java Card. Ce programme peut comprendre un ou plusieurs fichiers de classe afin de former un paquetage pouvant constituer une applet à transmettre à la carte à puce et à traiter par celle-ci.In the following, it will be assumed that the program PG to be executed in the smart card CA was initially written in a high level language of the object oriented type such as the Java language, or more particularly the Java Card language. This program can include one or more class files in order to form a package which can constitute an applet to be transmitted to the chip card and to be processed by the latter.
Le serveur SE étant une entité électronique externe à la carte CA, il appartient par exemple à 1 ' éditeur de la carte CA ou à 1 ' éditeur d'une ou plusieurs applications implantées dans la carte CA.The server SE being an electronic entity external to the card CA, it belongs for example to The CA card editor or the editor of one or more applications installed in the CA card.
Comme montré à la figure 1, pour la mise en oeuvre du procédé de compression selon l'invention, le serveur SE comprend principalement un compilateurAs shown in FIG. 1, for the implementation of the compression method according to the invention, the server SE mainly comprises a compiler
COM, un analyseur sémantique d'instruction AS et un chargeur de programme CH sécurisé .COM, a semantic AS instruction analyzer and a secure CH program loader.
Le compilateur COM est un compilateur connu pour le langage Java qui convertit le programme PG en langage source Java en un programme compilé PGC en langage intermédiaire, appelé également pseudo-code, composé de mots d'instruction formés par des octets, appelés bytecodes, qui sont prêts à être exécutés par un interpréteur dans la carte CA. Lorsque le programme en langage source PG, tel qu'une applet ou une librairie, contient plusieurs fichiers, le compilateur COM les compile séparément et un éditeur de liens les regroupe comme on le verra dans la suite au niveau de la carte CA. Chaque octet d'instruction supporte une instruction proprement dite, c'est-à-dire un code opération (opcode) ou bien l'un des paramètres d'une instruction appelée opérandes. Dans la suite, sauf exception, le vocable "instruction" désigne l'ensemble des octets définissant une instruction, c'est-à-dire le code opération (opcode) et ses éventuels opérandes.The COM compiler is a known compiler for the Java language which converts the PG program in Java source language into a compiled PGC program in intermediate language, also called pseudo-code, composed of instruction words formed by bytes, called bytecodes, which are ready to be executed by an interpreter in the CA card. When the PG source language program, such as an applet or a library, contains several files, the COM compiler compiles them separately and a link editor groups them together as will be seen below on the CA card level. Each instruction byte supports an instruction proper, that is to say an operation code (opcode) or one of the parameters of an instruction called operands. In the following, barring exceptions, the term "instruction" designates all the bytes defining an instruction, that is to say the operation code (opcode) and its possible operands.
Après une première étape principale El, consistant en la compilation effectuée par le compilateur COM, le procédé de compression selon l'invention comporte une détection de séquences répétées d'instructions SQ dans le programme compilé PGC à une étape E2, puis génère en langage intermédiaire des annotations AN définissant respectivement des caractéristiques des séquences répétées détectées SQ à une étape E3. , Les séquences détectées sont remplacées ultérieurement, lors de la compression effective dans la carte à puce CP, par des macro-instructions respectives MI. Les deux étapes E2 et E3 sont réalisées par 1 ' analyseur sémantique AS selon l'invention.After a first main step E1, consisting of the compilation carried out by the compiler COM, the compression method according to the invention comprises a detection of repeated sequences of instructions SQ in the compiled program PGC in a step E2, then generates in intermediate language AN annotations respectively defining characteristics of the sequences repeated detected SQ in step E3. , The detected sequences are replaced later, during the actual compression in the chip card CP, by respective macro-instructions MI. The two steps E2 and E3 are carried out by one semantic analyzer AS according to the invention.
Il est rappelé que la norme Java Card 2.11 réserve 187 octets d'instruction normalisée IN, numérotés de 0 à 184 puis de 254 à 255 = 28 - 1. Chacun des 254-184-1=69 octets d'instruction restants, qui peuvent être suivis chacun d'un nombre prédéterminé d'octets de paramètres, appelés opérandes, ne sont pas utilisés et sont exploités pour désigner au moins 69 macro-instructions MI à 1 octet. Parmi les 69 macro-instructions possibles, de préférence l'une d'elles est utilisée pour indiquer que l'octet suivant est une macro-instruction supplémentaire, appelée macro-instruction "étendue", ce qui permet de définir 256 macro-instructions supplémentaires ainsi chacune à 2 octets.It is recalled that the Java Card 2.11 standard reserves 187 bytes of normalized instruction IN, numbered from 0 to 184 then from 254 to 255 = 2 8 - 1. Each of the 254-184-1 = 69 bytes of instruction remaining, which can each be followed by a predetermined number of bytes of parameters, called operands, are not used and are used to designate at least 69 macro 1-byte MI instructions. Among the 69 possible macro-instructions, preferably one of them is used to indicate that the following byte is an additional macro-instruction, called "extended" macro-instruction, which makes it possible to define 256 additional macro-instructions. thus each to 2 bytes.
A chaque séquence SQ répétée selon un modèleAt each SQ sequence repeated according to a pattern
(pattern) déterminé par l'analyseur AS, comme on le verra ci-après, est attribuée une macro-instruction MI définie par des annotations respectives AN en langage intermédiaire. Les annotations sur une séquence donnée consistent principalement en une table d' indirection à 2 octets comportant une adresse ADSQ spécifiant la position de la première instruction de la séquence donnée dans le programme PGC et la longueur à 3 bits LSQ exprimée en octets de la séquence donnée SQ et en la suite d'instructions composant la séquence donnée. En l'espèce, la longueur LSQ d'une séquence d'instructions répétitive codée sur 3 bits permet de détecter des séquences ayant des tailles de 1 à 8 octets dans les instructions normalisées IN du programme compilé PGC. Par exemple, dans la suite suivante d'instructions normalisées IN du programme PGC : ... A B C A D B C A B C ..., dans laquelle chaque lettre représente une instruction (opcode et éventuellement opérande (s)) , 1 ' analyseur AS trouve les quatre séquences répétitives suivantes : - une séquence à trois instructions ABC apparaissant deux fois, une séquence à deux instructions BC apparaissant trois fois, une séquence à deux instructions CA apparaissant deux fois, et une séquence à deux instructions AB apparaissant deux fois.(pattern) determined by the AS analyzer, as will be seen below, a macro instruction MI is defined, defined by respective annotations AN in intermediate language. The annotations on a given sequence mainly consist of a 2-byte indirection table comprising an ADSQ address specifying the position of the first instruction of the given sequence in the PGC program and the 3-bit LSQ length expressed in bytes of the given sequence. SQ and following instructions composing the given sequence. In this case, the length LSQ of a repetitive instruction sequence coded on 3 bits makes it possible to detect sequences having sizes from 1 to 8 bytes in the normalized IN instructions of the PGC compiled program. For example, in the following series of standardized instructions IN of the PGC program: ... ABCADBCABC ..., in which each letter represents an instruction (opcode and possibly operand (s)), the analyzer AS finds the four repetitive sequences following: a sequence with three instructions ABC appearing twice, a sequence with two instructions BC appearing three times, a sequence with two instructions CA appearing twice, and a sequence with two instructions AB appearing twice.
L'analyseur AS ne sélectionne en fait que la première séquence à trois instructions ABC en tant que modèle préféré afin de définir une macroinstruction respective Ml qui factorisera cette séquence d'instructions répétitive ultérieurement lors de la compression effectuée dans la carte à puce CA. L'algorithme de sélection des séquences répétitives pour en constituer ultérieurement des macro-instructions inclus dans l'analyseur AS obéit à certains critères tout en respectant certaines contraintes afin que chaque macro-instruction soit facilement exécutable par l'interpréteur IT, c'est-à- dire la machine virtuelle Java Card implantée dans la carte à puce CA.The analyzer AS in fact only selects the first sequence with three instructions ABC as the preferred model in order to define a respective macroinstruction Ml which will factorize this sequence of repetitive instructions later during the compression carried out in the smart card CA. The algorithm for selecting repetitive sequences to subsequently constitute macro-instructions included in the AS analyzer obeys certain criteria while respecting certain constraints so that each macro-instruction is easily executable by the IT interpreter, that is to say ie the Java Card virtual machine installed in the CA smart card.
Dans l'exemple précédent, la sélection d'une macro-instruction ne dépend pas seulement de la longueur de la séquence correspondante économisée par la macro-instruction, mais également de la réduction globale qui en résulte due à la répétition de la séquence dans le programme compilé PGC après que la séquence ait été sélectionnée. Dans la suite d'instructions précédente, si la séquence à deux instructions BC était sélectionnée, aucun autre modèle de séquence répétitive ne pourrait être trouvé. Par contre, une fois que la séquence à trois instructions ABC est sélectionnée par l'analyseur AS, 1 ' analyseur sélectionne encore la séquence à deux instructions BC qui apparaît dans la séquence ABC répétée deux fois ainsi qu'une autre fois à la suite de l'instruction D. L'analyseur AS génère alors des annotations AN relatives à une macro-instruction M2 qui définissent les caractéristiques de la séquence BC afin de la retrouver ultérieurement. Dans ce cas, la macro-instruction M2 est dite "associée" à, ou "imbriquée" avec, la macro-instruction Ml, ce qui signifie que le code de la macro-instruction M2 est une partie du code de la macro-instruction Ml. Ainsi ultérieurement, après téléchargement des instructions normalisées IN et des annotations AN des séquences d'instructions détectées, la carte à puce CA compresse la suite d'instructions précitée en la suite compressée suivante Ml A D M2 Ml ... , avec Ml = [A, M2 (B C) ] . La suite compressée contient la macroinstruction Ml à la place de chaque occurrence de la séquence répétitive ABC et la macro-instruction M2 à la place de chaque occurrence de la séquence répétitive BC contenue dans la séquence ABC analysée précédemment.In the previous example, the selection of a macro instruction depends not only on the length of the corresponding sequence saved by the macro instruction, but also on the reduction result resulting from the repetition of the sequence in the PGC compiled program after the sequence has been selected. In the previous instruction sequence, if the two-instruction BC sequence was selected, no other repeating sequence pattern could be found. On the other hand, once the sequence with three instructions ABC is selected by the analyzer AS, the analyzer again selects the sequence with two instructions BC which appears in the sequence ABC repeated twice as well as another time following the instruction D. The analyzer AS then generates annotations AN relating to a macro-instruction M2 which define the characteristics of the sequence BC in order to find it later. In this case, the macro-instruction M2 is said to be "associated" with, or "nested" with, the macro-instruction Ml, which means that the code of the macro-instruction M2 is a part of the code of the macro-instruction ml. Thus later, after downloading the standardized instructions IN and the annotations AN of the detected instruction sequences, the smart card CA compresses the above-mentioned sequence of instructions into the following compressed sequence Ml AD M2 Ml ..., with Ml = [A , M2 (BC)]. The compressed sequence contains the macro instruction M1 in place of each occurrence of the repetitive sequence ABC and the macro instruction M2 in place of each occurrence of the repetitive sequence BC contained in the sequence ABC analyzed above.
Selon un exemple pratique, l'analyseur AS reçoit la suite d'instructions suivantes dans laquelle II et 12 sont des octets d'instruction proprement dite (opcode) et PI, P2 et P3 sont des octets de paramètre : 12 ; II , PI , P2 ; il , PI , P3According to a practical example, the analyzer AS receives the following sequence of instructions in which II and 12 are instruction bytes proper (opcode) and PI, P2 and P3 are parameter bytes: 12; II, PI, P2; he, PI, P3
12 ; II , PI , P2 ; il , I , P312; II, PI, P2; he, I, P3
Ï2 ; II , PI , P2 ; il , PI , P3Ï2; II, PI, P2; he, PI, P3
II , PI , P3 ; . . .II, PI, P3; . . .
La suite précédente comporte une première séquence à sept octets (12 ; II, PI, P2 ; II, PI, P3) répétée trois fois et une deuxième séquence à trois octets (II, PI, P3) répétée deux fois, soit 27 octets qui devraient occuper la mémoire non-volatile de type EEPROM dans la carte à puce CA, si le programme compilé PGC contenant cette suite n'était pas compressé. En fait, l'analyseur AS produit des annotations relatives à une première macro- instruction Mil définissant la première séquence à sept octets par une table d' indirection à deux octets déterminant son adresse et sa taille, ainsi que des annotations analogues définissant la deuxième séquence répétitive à trois octets. Le remplacement de chacune des trois occurrences de la première séquence permet d'économiser 21 - 12 = 9 octets. Puis 1 ' analyseur AS détermine une deuxième macroinstruction MI2 correspondant à la deuxième séquence (II, PI, P3) qui est répétée trois fois dans la première séquence répétitive, puis qui est répétée deux fois isolément. Finalement la suite ultérieurement compressée dans la carte CA est : ... Mil ... Mil ... Mil ... MI2 ... MI2 dans laquelle MI2 est associée" à Mil. La factorisation de la deuxième séquence en la macroinstruction MI2 permet d'économiser encore deux octets, et le programme final compressé occupe alors 16 octets en mémoire non volatile dans la carte à puce. Les annotations AN générées par l'analyseur sémantique d'instruction normalisée AS respectent plusieurs contraintes CSQ sur les séquences d'instructions, afin que chaque macro-instruction MI définie par des annotations lors de la compression ultérieure puisse être facilement exécutée par 1 ' interpréteur IT et préserve les propriétés de sécurité apportées par le vérificateur :The preceding sequence comprises a first sequence with seven bytes (12; II, PI, P2; II, PI, P3) repeated three times and a second sequence with three bytes (II, PI, P3) repeated twice, that is 27 bytes which should occupy the non-volatile memory of type EEPROM in the smart card CA, if the compiled program PGC containing this suite was not compressed. In fact, the AS analyzer produces annotations relating to a first Mil macro-instruction defining the first seven-byte sequence by a two-byte indirection table determining its address and its size, as well as similar annotations defining the second sequence. repetitive to three bytes. Replacing each of the three occurrences of the first sequence saves 21 - 12 = 9 bytes. Then the analyzer AS determines a second macroinstruction MI2 corresponding to the second sequence (II, PI, P3) which is repeated three times in the first repetitive sequence, then which is repeated twice in isolation. Finally the sequence subsequently compressed in the CA card is: ... Mil ... Mil ... Mil ... MI2 ... MI2 in which MI2 is associated "with Mil. The factorization of the second sequence in macroinstruction MI2 saves another two bytes, and the final compressed program then occupies 16 bytes in non-volatile memory in the smart card. The AN annotations generated by the standardized instruction semantic analyzer AS respect several constraints CSQ on the instruction sequences, so that each macro-instruction MI defined by annotations during the subsequent compression can be easily executed by the IT interpreter and preserves the security properties provided by the verifier:
- CSQ1) les instructions IN dans une séquence répétitive SQ correspondant à la macro-instruction MI commencent à 1 ' intérieur d 'un corps de méthode et se terminent dans la même méthode, c'est-à-dire sont contenues dans le corps d'une méthode commune ;- CSQ1) the IN instructions in a repetitive sequence SQ corresponding to the macro-instruction MI start inside a method body and end in the same method, that is to say are contained in the body d 'a common method;
- CSQ2) les instructions de la séquence SQ ne doivent contenir aucune étiquette (label) , seule la première instruction de la séquence répétitive pouvant être pointée par une étiquette, ce qui signifie que la macro-instruction elle-même sera pointée par une étiquette ; - CSQ3) les instructions de la séquence SQ ne doivent contenir aucune instruction normalisée brisant le flot d'exécution telle que des instructions de direction, de commutation, de saut conditionné, etc. (GOTO, S ITCH, INVOKE, JUMP SUBROUTINE, JUMP-CONDITION, etc.) ; seule la dernière instruction dans la séquence peut rompre le flot d'exécution ; la lecture du dernier octet d'opérande de cette dernière instruction déclenchera la fin de la macro-instruction et la poursuite du programme compressé, comme si c'était la macro-instruction elle-même qui rompait le flot d'exécution.- CSQ2) the instructions of the SQ sequence must not contain any label (label), only the first instruction of the repetitive sequence can be pointed by a label, which means that the macro-instruction itself will be pointed by a label; - CSQ3) the instructions in the SQ sequence must not contain any standard instruction breaking the execution flow such as direction, switching, conditioned jump instructions, etc. (GOTO, S ITCH, INVOKE, JUMP SUBROUTINE, JUMP-CONDITION, etc.); only the last instruction in the sequence can break the execution flow; reading the last operand byte of this last instruction will trigger the end of the macro-instruction and the continuation of the compressed program, as if it was the macro-instruction itself which broke the flow of execution.
En variante complémentaire, il est supposé que l'interpréteur IT, c'est-à-dire la machine virtuelle, implémenté dans la carte à puce CA, comprend déjà des macro-instructions exécutables directement par l'interpréteur. Ces macro-instructions, appelées ci- après "macro-instructions globales" MG, sont le fruit d'une analyse d'un jeu conséquent d'applications dans la carte CA et sont implémentées dans 1 ' interprêteur IT également sous forme d'objets compilés en langage intermédiaire. En pratique, plus d'une centaine de macro-instructions globales MG peuvent être identifiées ; pour chaque programme PGC compilé envoyé à la carte, l'analyseur AS . ne peut sélectionner qu'au plus 69 macro-instructions globales parmi la centaine de macro-instructions globales . Quel que soit le nombre de macroinstructions globales déjà prévues dans l'interpréteur IT, l'analyseur AN, après avoir détecté une séquence d'instructions répétitive SQ dans le programme PGC, recherche la séquence détectée dans une table TMG faisant correspondre des séquences SQ à des macro-instructions globales MG. Dans ce cas, à une étape E4 intermédiaire entre les étapes E2 et E3 , l'analyseur AS considère que la macro-instruction correspondant à la séquence détectée est une macroinstruction globale MG qui est déjà connue par l'interpréteur IT et dont les annotations pré- mémorisées AN sont lues par l'analyseur à une étape E5. Les annotations relatives à une macro-instruction globale sont réduites à un octet généré par l'analyseur AS. Si aucune séquence dans la table de correspondance TMG n'est identique à la séquence détectée à l'étape E4, l'analyseur AS génère les annotations AN définissant une nouvelle macroinstruction MI, à l'étape E3.As an additional variant, it is assumed that the IT interpreter, that is to say the virtual machine, implemented in the smart card CA, already includes macro-instructions executable directly by the interpreter. These macro-instructions, hereinafter called "global macro-instructions" MG, are the result of an analysis of a substantial set of applications in the card CA and are implemented in the interpreter IT also in the form of objects. compiled in intermediate language. In practice, more than a hundred global MG macro-instructions can be identified; for each compiled PGC program sent to the card, the AS analyzer. can only select at most 69 global macro-instructions among the hundred global macro-instructions. Regardless of the number of global macro instructions already provided in the IT interpreter, the AN analyzer, after having detected a repetitive sequence of instructions SQ in the PGC program, searches for the sequence detected in a TMG table matching sequences SQ to of global macro-instructions MG. In this case, at a step E4 intermediate between steps E2 and E3, the analyzer AS considers that the macro-instruction corresponding to the detected sequence is a global macro-instruction MG which is already known by the interpreter IT and whose annotations pre - memorized AN are read by the analyzer in a step E5. The annotations for a global macro are reduced to one byte generated by the AS analyzer. If no sequence in the TMG correspondence table is identical to the sequence detected in step E4, the analyzer AS generates the annotations AN defining a new macroinstruction MI, in step E3.
Les instructions d'une séquence correspondant à une macro-instruction globale MG satisfont également les deux premières contraintes CSQ1 et CSQ2 énoncées précédemment pour des instructions d'une macroinstruction MI définie par l'analyseur AS, à savoir que la séquence d'instructions doit commencer à 1 ' intérieur d 'un corps de méthode et se terminer dans le même corps de méthode, et ne doit contenir aucune étiquette (label) à l'exception . de la première instruction dans la séquence. En outre, selon une autre contrainte CSQ4, une macro-instruction globale MG doit être strictement identique à la portion de code déjà stockée dans la mémoire ROM de la carte CA en relation avec l'interpréteur IT et définissant la macro-instruction globale.The instructions of a sequence corresponding to a global macro-instruction MG also satisfy the first two constraints CSQ1 and CSQ2 stated previously for instructions of an MI macroinstruction defined by the AS parser, namely that the sequence of instructions must start inside a method body and end in the same method body, and must not contain no label except . of the first instruction in the sequence. In addition, according to another constraint CSQ4, a global macro-instruction MG must be strictly identical to the portion of code already stored in the ROM memory of the card CA in relation to the interpreter IT and defining the global macro-instruction.
En résumé, l'analyseur sémantique d'instruction AS d'abord détecte les modèles des séquences répétitives d'instructions SQ trouvées dans le programme compilé PGC à 1 ' étape E2 , puis construit un graphe dont les états sont les modèles des séquences détectées et dont les flèches définissent des liens entre les macro-instructions correspondant aux séquences détectées, afin de suivre le graphe et d'essayer de nombreux jeux de macro-instructions pour sélectionner la meilleure compression à l'étape E3, en tenant compte, si elles existent de macroinstructions globales MG sélectionnées à 1 ' étape E4.In summary, the semantic instruction analyzer AS first detects the patterns of repetitive sequences of SQ instructions found in the compiled program PGC in step E2, then constructs a graph whose states are the patterns of the detected sequences and whose arrows define links between the macro-instructions corresponding to the detected sequences, in order to follow the graph and to try many sets of macro-instructions to select the best compression in step E3, taking into account, if they exist of global macroinstructions MG selected in step E4.
En pratique, les annotations AN contenant les informations sur la manière de compresser les instructions IN du programme PGC, c'est-à-dire les tables d' indirection et les séquences d'instructions SQ définissant respectivement les macro-instructions MI, MG, sont incluses dans un composant additionnel CAD . cap construit par 1 ' analyseur AN et ajoutë au composant CN normalisé selon la norme Java Card 1.11 et contenant les instructions IN du programme compilé PGC sans macro-instruction. Le composant additionnel CAD comprend notamment un octet représentant le numéro de celui-ci et deux octets indiquant la taille en octet du composant .In practice, the annotations AN containing the information on how to compress the instructions IN of the program PGC, that is to say the indirection tables and the sequences of instructions SQ respectively defining the macro-instructions MI, MG, are included in an additional CAD component. course constructed by the AN analyzer and added to the CN component standardized according to the Java Card 1.11 standard and containing the IN instructions of the PGC compiled program without macro-instruction. The additional component CAD includes in particular a byte representing the number of this one and two bytes indicating the size in byte of the component.
Le format du composant additionnel CAD (AN) permet la compression des instructions en langage intermédiaire IN en une seule passe dans la carte à puce CA. Le composant additionnel comprend des entrées qui définissent chacune une zone de code dans le programme PGC, c'est-à-dire une séquence d'instructions SQ, qui est à remplacer par une macroinstruction respective. L'entrée pour la première zone contenant la séquence repère le début de la séquence, le nombre de répétitions de la séquence, sa longueur et la macro-instruction qu'elle contient. Le début de la zone de code à compresser est déterminé grâce à un champ de déplacement qui indique le nombre d'instructions à sauter dans la suite des instructions du programme compilé PGC depuis la fin de la dernière zone à compresser contenant la même séquence d'instructions SQ.The format of the additional component CAD (AN) allows the compression of the instructions in intermediate language IN in a single pass in the smart card CA. The additional component includes entries which each define a code area in the PGC program, that is to say a sequence of SQ instructions, which is to be replaced by a respective macro instruction. The entry for the first zone containing the sequence marks the beginning of the sequence, the number of repetitions of the sequence, its length and the macro-instruction which it contains. The start of the code zone to be compressed is determined by means of a displacement field which indicates the number of instructions to be skipped in the following instructions of the PGC compiled program since the end of the last zone to be compressed containing the same sequence of SQ instructions.
A une étape E6, le chargeur sécurisé CH assemble le composant d'instructions CN(IN) et le composant additionnel d'annotations CAD (AN) en un programme PCH qui est téléchargé dans la carte à puce CA à travers le réseau internet RES et le terminal TE.In a step E6, the secure charger CH assembles the instruction component CN (IN) and the additional annotation component CAD (AN) into a PCH program which is downloaded into the smart card CA through the internet network RES and the TE terminal.
Comme montré également à la figure 1, la carte à puce CA comprend essentiellement un vérificateur VER et un éditeur de liens EL, un compresseur CP et l'interpréteur IT. Ces derniers modules logiciels sont implantés dans la mémoire non volatile EEPROM et la mémoire morte ROM de la carte à puce CA. En particulier, de manière connue, l'interpréteur IT est une machine virtuelle Java Card qui est propre à interpréter séquentiellement de manière connue les instructions normalisées IN d'un programme compilé PGC chargé dans la mémoire EEPROM de la carte. Après interprétation d'une instruction IN, l'interpréteur IT fait exécuter celle-ci en code natif par le microprocesseur PR de la carte .As also shown in FIG. 1, the smart card CA essentially comprises a verifier VER and an editor for links EL, a compressor CP and the interpreter IT. These latter software modules are installed in the non-volatile memory EEPROM and the ROM ROM of the smart card CA. In particular, in a known manner, the IT interpreter is a Java Card virtual machine which is capable of sequentially interpreting the normalized instructions IN of a PGC compiled program loaded in the card's EEPROM memory. After interpretation of an IN instruction, the IT interpreter has it executed in native code by the microprocessor PR of the card.
Lorsque le programme PCH est transmis par le serveur SE à travers le réseau internet RES via le terminal TE, le programme PCH est chargé dans le vérificateur VER de la carte à travers le navigateur et un module logiciel intermédiaire de type Plugin ou proxy du terminal. D'une manière connue, le vérificateur VER assure des fonctions de sécurité afin de vérifier que le programme chargé PCH contient des fichiers et des classes et plus précisément des instructions IN ainsi que des annotations AN selon 1 ' invention qui sont compatibles avec le bytecode de l'interpréteur IT. En particulier, le vérificateur VER peut analyser une signature du programme chargé PCH afin de s'assurer que les instructions contenues dans celui-ci n'ont pas été modifiées depuis qu'il a été signé dans le chargeur sécurisé CH.When the PCH program is transmitted by the server SE through the internet network RES via the terminal TE, the PCH program is loaded into the verifier VER of the card through the browser and an intermediate software module of plugin or proxy type of the terminal. In a known manner, the verifier VER provides security functions in order to verify that the loaded program PCH contains files and classes and more precisely IN instructions as well as annotations AN according to the invention which are compatible with the bytecode of the IT interpreter. In particular, the VER verifier can analyze a signature of the loaded PCH program in order to ensure that the instructions contained in it have not been modified since it was signed in the secure loader CH.
L'éditeur de liens EL identifie les liens entre les divers fichiers et classes contenus dans le programme chargé PCH et en particulier entre le composant additionnel d'annotations CAD (AN) et le composant d'instructions normalisées CN(IN) afin d'écrire ces composants respectivement dans des espaces de mémoire MAN et MIN liés au compresseur CP.The EL linker identifies the links between the various files and classes contained in the loaded PCH program and in particular between the additional CAD annotation component (AN) and the standard instruction component CN (IN) in order to write these components respectively in MAN and MIN memory spaces linked to the CP compressor.
Selon l'invention, l'opération de compression des instructions contenues dans le composant reçu CN(IN) réalisée dans le compresseur CP est étroitement liée à une vérification des annotations et à une exécution de celles-ci dans le vérificateur VER. 66According to the invention, the operation of compressing the instructions contained in the received component CN (IN) carried out in the compressor CP is closely linked to a verification of the annotations and to an execution of these in the verifier VER. 66
1818
La vérification et 1 ' exécution des annotations pour effectuer la compression des instructions comprennent principalement des étapes SI à SU mises en oeuvre dans les modules VER et CP, comme montré à la figure 2.The verification and execution of the annotations to effect the compression of the instructions mainly comprise steps SI to SU implemented in the modules VER and CP, as shown in FIG. 2.
Initialement, trois pointeurs PAN, PL et PE sont mis à zéro à une étape initiale SO en réponse au téléchargement du programme PCH. Le pointeur PAN est un pointeur de lecture des annotations AN du composant additionnel CAD écrit dans l'espace de mémoire MAN. Le pointeur PL est un pointeur de lecture pour lire des instructions non compressées IN du composant reçu CN(IN) chargé dans l'espace de mémoire MIN. Le pointeur PE est un pointeur d'écriture des instructions compressées dans l'espace de mémoire MIN afin d'y écrire les macro-instructions MI, MG, résultant de la compression de séquences reçues SQ selon des annotations correspondantes reçues, ainsi que d'y écrire d'éventuelles instructions qui ne subissent aucune compression entre les séquences détectées. Comme on le verra ci- après, la compression est effectuée en une seule passe de la suite d ' instructions IN non compressées comprises dans le composant chargé CN(IN), et les instructions reçues non compressées et les instructions compressées au moins en partie sont respectivement lues et écrites dans le même espace mémoire MIN afin d'optimiser l'espace mémoire occupé par le programme chargé PCP après la compression. Le pointeur de lecture PL progresse alors plus vite que le pointeur d'écriture PE.Initially, three pointers PAN, PL and PE are set to zero at an initial step SO in response to the downloading of the PCH program. The PAN pointer is a pointer for reading the annotations AN of the additional component CAD written in the memory space MAN. The pointer PL is a read pointer for reading uncompressed instructions IN from the received component CN (IN) loaded in the memory space MIN. The pointer PE is a pointer for writing instructions compressed in the memory space MIN in order to write there the macro-instructions MI, MG, resulting from the compression of sequences received SQ according to corresponding annotations received, as well as write any instructions there that are not compressed between the detected sequences. As will be seen below, the compression is carried out in a single pass of the sequence of uncompressed IN instructions included in the loaded component CN (IN), and the instructions received uncompressed and the instructions compressed at least in part are respectively read and written in the same MIN memory space in order to optimize the memory space occupied by the program loaded PCP after compression. The read pointer PL then progresses faster than the write pointer PE.
A l'étape SI, le pointeur PAN commande la lecture d'une entrée courante dans le composant additionnel CAD, c'est-à-dire la lecture d'une annotation courante AN dans l'espace de mémoire MAN. L'annotation courante AN lue est vérifiée à l'étape S2 en fonction de la séquence d'instructions SQ à compresser correspondant à 1 ' annotation AN et lue par le pointeur de lecture PL dans l'espace de mémoire MIN. La vérification à l'étape S2 consiste à contrôler les caractéristiques de séquence lue SQ au regard des contraintes de séquence CSQ définies ci- dessus . Si les caractéristiques de la séquence SQ ne satisfont pas les contraintes CSQ1 à CSQ3 , la séquence SQ n'est pas compressée à l'étape S3, et est ré-écrite sans modification dans l'espace de mémoire MIN en fonction du pointeur d'écriture PE. Par exemple, l'étape S2 vérifie que la séquence SQ à compresser ne contient aucune étiquette (label) sauf si la première instruction est une étiquette, auquel cas la macro-instruction correspondante sera une étiquette.In step SI, the pointer PAN commands the reading of a current entry in the additional component CAD, that is to say the reading of a current annotation AN in the memory space MAN. The current annotation AN read is checked in step S2 as a function of the sequence of instructions SQ to be compressed corresponding to the annotation AN and read by the read pointer PL in the memory space MIN. The verification in step S2 consists in checking the characteristics of the sequence read SQ with regard to the sequence constraints CSQ defined above. If the characteristics of the sequence SQ do not satisfy the constraints CSQ1 to CSQ3, the sequence SQ is not compressed in step S3, and is rewritten without modification in the memory space MIN according to the pointer of writing PE. For example, step S2 verifies that the sequence SQ to be compressed does not contain any label (label) unless the first instruction is a label, in which case the corresponding macro-instruction will be a label.
Si les contraintes CSQ sont satisfaites par la séquence SQ correspondant à l'annotation courante AN à l'étape S2, l'étape suivante S4 contrôle que la macro-instruction MI, MG désignée par l'annotation courante AN est déjà définie dans le compresseur CP pouvant comporter la table de correspondance , TMG relative aux micro-instructions globales. Si la macro-instruction désignée MI est inconnue du compresseur CP et n'est pas associée à une autre instruction à l'étape S5, le compresseur crée et mémorise à l'étape S6 la macro-instruction MI en correspondance avec la séquence d'instructions SQ ; plus précisément une table de correspondance dans le compresseur CP inscrit la correspondance entre la table d' indirection comprenant l'adresse de séquence ADSQ et la longueur LSQ de la séquence SQ et la suite des instructions composant la séquence SQ d'une part et la macro-instruction MI, d'autre part. Si à l'étape S5 succédant à l'étape S4, la macroinstruction désignée par 1 ' annotation courante AN est réputée comme "associée" à une autre macroinstruction, comme la macro-instruction M2 associée à la macro-instruction Ml dans l'exemple de suite d'instructions précité, le compresseur CP crée et mémorise la macro-instruction MI à l'étape S7, comme à l'étape S6, mais avec un index de référence à la macro-instruction à laquelle elle est associée. Cette indication permet ultérieurement à 1 ' interpréteur IT d'exécuter la macro-instruction réputée "associée" MI dans la macro-instruction à laquelle elle est associée.If the constraints CSQ are satisfied by the sequence SQ corresponding to the current annotation AN in step S2, the next step S4 checks that the macro-instruction MI, MG designated by the current annotation AN is already defined in the compressor CP may include the correspondence table, TMG relating to global micro-instructions. If the macro-instruction designated MI is unknown to the compressor CP and is not associated with another instruction in step S5, the compressor creates and stores in step S6 the macro-instruction MI in correspondence with the sequence of SQ instructions; more precisely, a correspondence table in the compressor CP writes the correspondence between the indirection table comprising the sequence address ADSQ and the length LSQ of the sequence SQ and the sequence of instructions composing the sequence SQ on the one hand and the macro - MI instruction, on the other hand. If at step S5 succeeding step S4, the macroinstruction designated by the current annotation AN is deemed to be "associated" with another macroinstruction, like the macroinstruction M2 associated with the macroinstruction Ml in the example below above instructions, the compressor CP creates and stores the macro-instruction MI in step S7, as in step S6, but with a reference index to the macro-instruction with which it is associated. This indication subsequently allows the interpreter IT to execute the macro-instruction deemed to be “associated” MI in the macro-instruction with which it is associated.
En revenant à l'étape S4, lorsque la macro- instruction MI définie par 1 ' annotation courante AN est déjà répertoriée dans une table dans le compresseur CP, soit la macro-instruction MI a déjà été créée lors d'une étape précédente S6 ou S7, soit la macro-instruction désignée MI est une macro- instruction globale MG initialement contenue dans le compresseur CP avant le chargement du programme PCH. L'étape suivante S8 vérifie alors que la séquence d'instructions SQ lue par le pointeur PL à l'étape S2 est exactement identique à la séquence SQ mémorisée dans une table de correspondance du compresseur CP en correspondance avec la macro-instruction MI, MG désignée par l'annotation courante AN. Si ce n'est pas le cas, le compresseur S3 refuse de compresser la séquence d'instructions SQ lue. Après l'étape de création de macro-instruction S6 ou S7, ou lorsque la séquence lue SQ est exactement identique à la séquence mémorisée dans une table de correspondance en correspondance avec la macro-instruction désignée MI, MG à l'étape S8, le compresseur CP effectue la compression de la séquence d'instructions lue SQ à l'étape S9, en remplaçant la séquence SQ dans le composant chargé CN(IN) par la macro-instruction désignée MI, MG qui est écrite dans 1 ' espace de mémoire MIN en fonction du pointeur d'écriture PE. Le pointeur PE est alors incrémenté d'une unité et, le cas échéant, du nombre d'instructions suivantes contenues dans le composant CN(IN) qui ne sont pas à compresser et qui sont à réécrire à la suite de la macro-instruction MI, MG résultant de la compression de la dernière séquence SQ lue dans l'espace de mémoire MIN.Returning to step S4, when the macro-instruction MI defined by the current annotation AN is already listed in a table in the compressor CP, either the macro-instruction MI has already been created during a previous step S6 or S7, ie the macro-instruction designated MI is a global macro-instruction MG initially contained in the compressor CP before the loading of the program PCH. The next step S8 then verifies that the sequence of instructions SQ read by the pointer PL in step S2 is exactly identical to the sequence SQ stored in a correspondence table of the compressor CP in correspondence with the macro-instruction MI, MG designated by the current annotation AN. If this is not the case, the compressor S3 refuses to compress the sequence of instructions SQ read. After the step of creating macro-instruction S6 or S7, or when the sequence read SQ is exactly identical to the sequence stored in a correspondence table in correspondence with the macro-instruction designated MI, MG in step S8, the CP compressor performs sequence compression of instructions read SQ in step S9, by replacing the sequence SQ in the component loaded CN (IN) by the macro-instruction designated MI, MG which is written in the memory space MIN according to the writing pointer EP. The pointer PE is then incremented by one and, if necessary, by the number of following instructions contained in the component CN (IN) which are not to be compressed and which are to be rewritten following the macro-instruction MI , MG resulting from the compression of the last sequence SQ read in the memory space MIN.
Puis à l'étape suivante S10, les deux pointeurs PAN et PL sont incrëmentés convenablement avant de procéder à la vérification de la prochaine annotation dans le composant additionnel CAD, en fonction du nombres des éventuelles instructions suivantes à ne pas compresser. Ainsi le pointeur de lecture d'annotation PAN est incrémenté d'une unité pour passer à la prochaine annotation, et le pointeur de lecture PL qui a été incrémenté de la longueur LSQ de la séquence SQ qui vient d'être compressée est également incrémentée du nombre d'instructions intermédiaires non compressées.Then in the next step S10, the two pointers PAN and PL are incremented suitably before proceeding to verify the next annotation in the additional component CAD, as a function of the number of any subsequent instructions not to be compressed. Thus the annotation read pointer PAN is incremented by one to go to the next annotation, and the read pointer PL which has been incremented by the length LSQ of the sequence SQ which has just been compressed is also incremented by number of uncompressed intermediate instructions.
L'étape S10 est suivie de l'étape SI s'il existe encore des annotations à traiter dans le composant additionnel CAD dans l'espace de mémoire MAN. En revanche, lorsque toutes les annotations ont été lues dans l'espace de mémoire MAN et toutes les instructions IN ont été ré-ëcrites dans l'espace de mémoire MIN soit après compression sous la forme de macro-instructions correspondantes MI, MG, soit sans changement, le compresseur CP arrête la compression à l'étape SU afin qu'éventuellement l'interpréteur IT exécute le programme d'instructions compressé PCP. L'exécution du programmé compressé CP par l'interpréteur IT, c'est-à-dire la machine virtuelle, se déroule de la manière suivante, en référence à la suite d'instructions normalisées suivante dans le programme compilé PGC' et donc écrite dans l'espace de mémoire MIN lors du chargement du programme correspondant PCH après 1 'étape E5 : ... A B C A D B C A B C ..., correspondant à la suite d'instructions compressées suivantes ré-écrites dans l'espace de mémoire MIN :Step S10 is followed by step SI if there are still annotations to be processed in the additional component CAD in the memory space MAN. On the other hand, when all the annotations have been read in the memory space MAN and all the instructions IN have been rewritten in the memory space MIN either after compression in the form of corresponding macro-instructions MI, MG, or without change, the compressor CP stops the compression in step SU so that possibly the interpreter IT executes the compressed instruction program PCP. The execution of the compressed compressed CP by the IT interpreter, that is to say the virtual machine, takes place in the following manner, with reference to the following series of standardized instructions in the compiled program PGC ' and therefore written in the MIN memory space when the corresponding program PCH is loaded after step E5: ... ABCADBCABC ..., corresponding to the following series of compressed instructions rewritten in the MIN memory space:
... Ml Gl M2 Ml ... avec Ml = [A, M2 (B C) ] .... Ml Gl M2 Ml ... with Ml = [A, M2 (B C)].
Au début de 1 ' interprétation du programme compressé précédant PCP, l'interpréteur IT interprète d'abord la première occurrence de la macroinstruction Ml. La macro-instruction Ml est une macro-instruction propre au programme initial PGC et composée de trois instructions normalisées A, B et C. L'adresse AD (ABC) et la longueur L (ABC) de la séquence correspondant à la macro-instruction Ml est codée sous une forme compacte dans la table de correspondance liée au programme PCP. Le compteur de programme courant est alors positionné sur la macro- instruction Ml et les trois instructions normalisées A, B et C sont traitées et interprétées. Puis le compteur de programme passe à la prochaine instruction qui est la macro-instruction Gl marquée comme globale . L'interpréteur IT lit alors une table de correspondance en fonction de 1 ' adresse de la macroinstruction globale Gl de manière à y lire le code natif C A D afin d'exécuter l'opération correspondante . Puis la prochaine instruction dans le programme compressé PCP est la macro-instruction M2 "associée" à la macro-instruction Ml déjà exécutée une fois. La table de correspondance est consultée par l'interpréteur IT afin d'y lire les deux instructions normalisées B et C pointées par le compteur de programme . Après exécution des deux instructions normalisées correspondant à la macro-instruction M2, la macro-instruction Ml est à nouveau exécutée. L'interprétation mise en oeuvre dans l'interpréteur IT n'est pas ainsi modifiée mais simplement étendue. Lorsqu'une macro-instruction doit être exécutée par l'interpréteur, celui-ci lit les instructions correspondantes à la macro-instruction dans la table de correspondance comme s ' il exécutait une seule instruction.At the start of the interpretation of the compressed program preceding PCP, the interpreter IT first interprets the first occurrence of the macroinstruction M1. The macro-instruction M1 is a macro-instruction specific to the initial program PGC and composed of three normalized instructions A, B and C. The address AD (ABC) and the length L (ABC) of the sequence corresponding to the macro-instruction Ml is coded in a compact form in the correspondence table linked to the PCP program. The current program counter is then positioned on the macro-instruction M1 and the three normalized instructions A, B and C are processed and interpreted. Then the program counter goes to the next instruction which is the macro-instruction Gl marked as global. The interpreter IT then reads a correspondence table as a function of the address of the global macroinstruction G1 so as to read there the native code CAD in order to execute the corresponding operation. Then the next instruction in the compressed program PCP is the macro-instruction M2 "associated" with the macro-instruction Ml already executed once. The correspondence table is consulted by the IT interpreter in order to read there the two standard instructions B and C pointed by the program counter. After execution of the two standardized instructions corresponding to the macro-instruction M2, the macro-instruction Ml is executed again. The interpretation implemented in the IT interpreter is not thus modified but simply extended. When a macro-instruction must be executed by the interpreter, the latter reads the instructions corresponding to the macro-instruction in the correspondence table as if it were executing a single instruction.
En variante, le chargement, la vérification, l'édition de lien, la compression et l'interprétation dans le vérificateur VER, l'éditeur de liens EL et le compresseur CP sont effectuées à la volée, quasi- simultanément au fur et à mesure du chargement du programme PCH dans la carte CA. As a variant, the loading, verification, link editing, compression and interpretation in the VER verifier, the EL link editor and the compressor CP are carried out on the fly, almost simultaneously as and when loading the PCH program into the CA card.

Claims

REVENDICATIONS
1 - Procédé pour compresser un programme (PGC) compilé en langage intermédiaire composé d'instructions successives (IN), selon lequel des séquences d'instructions (SQ) sont détectées à l'extérieur d'un dispositif de traitement de données (CA) , caractérisé en ce qu'il comprend les étapes de : - analyser (AN, E2 , E3) , à l'extérieur du dispositif de traitement de données, des séquences d'instructions détectées (SQ) afin de générer respectivement des annotations (AN) en langage intermédiaire définissant des macro-instructions respectives (MI) lorsque les séquences d'instructions détectées satisfont des contraintes prédéterminées (CSQ) ,1 - Method for compressing a program (PGC) compiled in intermediate language composed of successive instructions (IN), according to which sequences of instructions (SQ) are detected outside of a data processing device (CA) , characterized in that it comprises the steps of: - analyzing (AN, E2, E3), outside the data processing device, sequences of detected instructions (SQ) in order to respectively generate annotations (AN ) in intermediate language defining respective macro-instructions (MI) when the detected instruction sequences satisfy predetermined constraints (CSQ),
- charger (E6) depuis l'extérieur les instructions (IN) et les annotations (AN) dans le dispositif de traitement de données (CA) , et- load (E6) from the outside the instructions (IN) and the annotations (AN) into the data processing device (CA), and
- produire et mémoriser (CP, S6-S9) dans le dispositif de traitement de données (CA) des macroinstructions (MI) définies par des annotations de séquences d'instructions chargées qui sont compatibles avec les contraintes (CSQ) , respectivement en remplacement des séquences d'instructions chargées (SQ) .- produce and store (CP, S6-S9) in the data processing device (CA) macroinstructions (MI) defined by annotations of loaded instruction sequences which are compatible with the constraints (CSQ), respectively replacing the loaded instruction sequences (SQ).
2 - Procédé conforme à la revendication 1, comprenant après l'étape de charger, l'étape de vérifier (VER, S1-S4) les annotations chargées (AN) en fonction des contraintes (CSQ) dans le dispositif de traitement de données . 3 - Procédé conforme à la revendication 1 ou 2 , selon lequel chaque annotation (AN) relative à une séquence d'instructions (SQ) comprend au moins une adresse (ADSQ) positionnant la séquence d'instructions dans le programme compilé (PGC) et la longueur (LSQ) de la séquence d'instructions, ainsi que les instructions contenues dans la séquence.2 - Method according to claim 1, comprising after the step of loading, the step of checking (VER, S1-S4) the loaded annotations (AN) according to the constraints (CSQ) in the data processing device. 3 - Method according to claim 1 or 2, according to which each annotation (AN) relating to a sequence of instructions (SQ) comprises at least one address (ADSQ) positioning the sequence of instructions in the compiled program (PGC) and the length (LSQ) of the instruction sequence, as well as the instructions contained in the sequence.
4 - Procédé conforme à l'une quelconque des revendications 1 à 3 , selon lequel les annotations4 - Process according to any one of claims 1 to 3, according to which the annotations
(AN) sont incluses dans un composant additionnel (CAD) qui est lié au programme compilé (PGC) et qui est chargé avec celui-ci dans le dispositif de traitement de données (CA) .(AN) are included in an additional component (CAD) which is linked to the compiled program (PGC) and which is loaded with it in the data processing device (CA).
5 - Procédé conforme à l'une quelconque des revendications 1 à 4, selon lequel les contraintes (CSQ) imposées sur chaque séquence d'instructions (SQ) à compresser en macro-instruction (MI) comprennent au moins l'une des suivantes : les instructions dans la séquence sont contenues dans le corps d'une méthode commune ; les instructions dans la séquence ne contiennent aucune étiquette dans la séquence, à l'exception de la première instruction dans la séquence ; aucune instruction de la séquence à 1 ' exception de la dernière instruction de la séquence ne rompt le flot d'exécution du programme compilé .5 - Method according to any one of claims 1 to 4, according to which the constraints (CSQ) imposed on each sequence of instructions (SQ) to be compressed in macro-instruction (MI) comprise at least one of the following: the instructions in the sequence are contained in the body of a common method; the instructions in the sequence do not contain any label in the sequence, except for the first instruction in the sequence; no instruction in the sequence except the last instruction in the sequence breaks the flow of execution of the compiled program.
6 - Procédé conforme à l'une quelconque des revendications 1 à 5, selon lequel l'étape d'analyser des séquences (AN, E2, E3) génère au moins une annotation définissant une macro-instruction correspondant à une séquence d'instructions analysée contenue dans une autre séquence d'instructions analysée précédemment .6 - Method according to any one of claims 1 to 5, according to which the step of analyzing sequences (AN, E2, E3) generates at least one annotation defining a macro-instruction corresponding to a sequence of instructions analyzed contained in another sequence of instructions previously analyzed.
7 - Procédé conforme à l'une quelconque des revendications 1 à 6, selon lequel l'étape d'analyser des séquences. (AN, E2 , E3) génère au moins une macroinstruction (MG) correspondant à une séquence d'instructions analysée, la correspondance entre ces dernières macro-instruction (MG) et séquence d'instructions étant préalablement mémorisée dans le dispositif de traitement de données (CA) .7 - Process according to any one of claims 1 to 6, according to which the step of analyzing sequences. (AN, E2, E3) generates at least one macroinstruction (MG) corresponding to an analyzed sequence of instructions, the correspondence between the latter macroinstruction (MG) and sequence of instructions being previously stored in the data processing device (CA).
8 - Procédé conforme à l'une quelconque des revendications 1 à 7, selon lequel, lorsqu'une séquence d'instructions chargée (SQ) correspond à une macro-instruction (MI, MG) déjà produite au cours de la compression du programme compilé ou mémorisée préalablement à la compression dans le dispositif de traitement de données (CA) , ladite séquence d'instructions est remplacée par ladite macroinstruction déjà produite ou mémorisée.8 - Process according to any one of claims 1 to 7, according to which, when a loaded sequence of instructions (SQ) corresponds to a macro-instruction (MI, MG) already produced during the compression of the compiled program or stored prior to compression in the data processing device (CA), said sequence of instructions is replaced by said macroinstruction already produced or stored.
9 - Procédé conforme à l'une quelconque des revendications 1 à 8, selon lequel l'étape de produire et mémoriser (CP, S6-S9) comprend une écriture de chaque macro-instruction (MI, MG) dans un espace de mémoire (MIN) du dispositif de traitement de données (CA) dans lequel la séquence d'instructions (SQ) correspondant à la macro- instruction a été chargée.9 - Method according to any one of claims 1 to 8, according to which the step of producing and memorizing (CP, S6-S9) comprises a writing of each macro-instruction (MI, MG) in a memory space ( MIN) of the data processing device (CA) into which the sequence of instructions (SQ) corresponding to the macro-instruction has been loaded.
10 - Procédé conforme à l'une quelconque des revendications 1 à 9, selon lequel le dispositif de traitement de données est un objet électronique portable du type carte à puce (CA) . 10 - Process according to any one of claims 1 to 9, according to which the data processing device is a portable electronic object of the smart card (CA) type.
PCT/FR2002/002962 2001-08-30 2002-08-29 Compression of a programme in intermediate language WO2003019366A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
FR01/11279 2001-08-30
FR0111279A FR2829252B1 (en) 2001-08-30 2001-08-30 COMPRESSION OF AN INTERMEDIATE LANGUAGE PROGRAM

Publications (1)

Publication Number Publication Date
WO2003019366A1 true WO2003019366A1 (en) 2003-03-06

Family

ID=8866842

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/FR2002/002962 WO2003019366A1 (en) 2001-08-30 2002-08-29 Compression of a programme in intermediate language

Country Status (2)

Country Link
FR (1) FR2829252B1 (en)
WO (1) WO2003019366A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106843996A (en) * 2017-03-08 2017-06-13 百富计算机技术(深圳)有限公司 Conditional compilation preprocess method and device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2785695A1 (en) * 1998-11-06 2000-05-12 Bull Cp8 METHOD FOR COMPACTING AN EXECUTABLE INTERMEDIATE OBJECT-CODE PROGRAM IN AN ON-BOARD SYSTEM PROVIDED WITH DATA PROCESSING RESOURCES, COMPACTOR SYSTEM AND CORRESPONDING MULTI-APPLICATION ONBOARD SYSTEM
WO2001022213A2 (en) * 1999-09-21 2001-03-29 Koninklijke Philips Electronics N.V. Optimized bytecode interpreter of virtual machine instructions

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2785695A1 (en) * 1998-11-06 2000-05-12 Bull Cp8 METHOD FOR COMPACTING AN EXECUTABLE INTERMEDIATE OBJECT-CODE PROGRAM IN AN ON-BOARD SYSTEM PROVIDED WITH DATA PROCESSING RESOURCES, COMPACTOR SYSTEM AND CORRESPONDING MULTI-APPLICATION ONBOARD SYSTEM
WO2001022213A2 (en) * 1999-09-21 2001-03-29 Koninklijke Philips Electronics N.V. Optimized bytecode interpreter of virtual machine instructions

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
HOOGERBRUGGE J ET AL: "A CODE COMPRESSION SYSTEM BASED ON PIPELINED INTERPRETERS", SOFTWARE PRACTICE & EXPERIENCE, JOHN WILEY & SONS LTD. CHICHESTER, GB, vol. 29, no. 11, September 1999 (1999-09-01), pages 1005 - 1023, XP000848752, ISSN: 0038-0644 *
PROEBSTING T A: "Optimizing an ANSI C interpreter with superoperators", CONFERENCE RECORD OF POPL 95: 22ND ACM SIGPLAN-SIGACT SYMPOSIUM PRINCIPLES OF PROGRAMMING LANGUAGES, PROCEEDINGS OF 22ND SYMPOSIUM ON PRINCIPLES OF PROGRAMMING LANGUAGES (POPL 95), SAN FRANCISCO, CA, USA, 22-25 JAN. 1995, 1995, New York, NY, USA, ACM, USA, pages 322 - 332, XP002202605, ISBN: 0-89791-692-1 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106843996A (en) * 2017-03-08 2017-06-13 百富计算机技术(深圳)有限公司 Conditional compilation preprocess method and device

Also Published As

Publication number Publication date
FR2829252A1 (en) 2003-03-07
FR2829252B1 (en) 2004-10-01

Similar Documents

Publication Publication Date Title
EP1836568B1 (en) Source code translator
CN102200911B (en) variable closure
CN110764791A (en) Channel adaptation method and device of applet and electronic equipment
CN106502746A (en) The packaging method and device of application program
CN102696016B (en) Method for compressing mark symbol
JP2002529849A (en) Data compression method for intermediate object code program executable in embedded system supplied with data processing resources, and embedded system corresponding to this method and having multiple applications
US20100077392A1 (en) Cap file for the personalization of a java application
FR2827974A1 (en) PROCESS FOR THE COMPRESSION OF A CODE INTERPRETED BY SEMANTIC ANALYSIS
CN110069259A (en) Analytic method, device, electronic equipment and storage medium based on idl file
FR2794543A1 (en) MIGRATING DIFFERENT LANGUAGES SOURCES TO AN EXECUTION MEDIUM
EP2453356A1 (en) Method, computer program and device for securing byte code to be run by a virtual machine
CN108920179A (en) Java reflects implementation method, device and system
FR2841997A1 (en) APPLICATION SECURITY DOWNLOADED IN PARTICULAR FROM A CHIP CARD
WO2003019366A1 (en) Compression of a programme in intermediate language
US6922735B2 (en) Management of co-processor information by integrating non-program information with program information
EP1566068B1 (en) Loading of an application that is to be deployed in a terminal and a chip card
CN111880800B (en) Application downloading method and application downloading system
CN111259042B (en) Dynamic query method and system
CN110659022B (en) Method for automatically calling Python script based on Java
CN111176628B (en) Front-end access method under modular architecture and storage medium
CN115292203B (en) Source code analysis method and device
FR2795835A1 (en) METHOD FOR VERIFYING CODE TRANSFORMERS FOR AN ON-BOARD SYSTEM, IN PARTICULAR ON A CHIP CARD
CN111385302A (en) Automatic load generation system
FR2831684A1 (en) INSTALLING A COMPILE PROGRAM, ESPECIALLY IN A CHIP CARD
US6266807B1 (en) Method and system for executing instructions in an application-specific microprocessor

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 PH PL PT RO RU SD SE SG SI SK SL TJ TM TN TR TT TZ UA UG US UZ VC VN YU ZA ZM ZW

Kind code of ref document: A1

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

AL Designated countries for regional patents

Kind code of ref document: A1

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

Kind code of ref document: A1

Designated state(s): 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 IE IT LU MC NL PT SE 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
DFPE Request for preliminary examination filed prior to expiration of 19th month from priority date (pct application filed before 20040101)
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