CN1313927C - Method for controlling smart card running environment - Google Patents

Method for controlling smart card running environment Download PDF

Info

Publication number
CN1313927C
CN1313927C CNB2005100771607A CN200510077160A CN1313927C CN 1313927 C CN1313927 C CN 1313927C CN B2005100771607 A CNB2005100771607 A CN B2005100771607A CN 200510077160 A CN200510077160 A CN 200510077160A CN 1313927 C CN1313927 C CN 1313927C
Authority
CN
China
Prior art keywords
instruction
folding
type
card
class
Prior art date
Legal status (The legal status 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 status listed.)
Expired - Fee Related
Application number
CNB2005100771607A
Other languages
Chinese (zh)
Other versions
CN1687900A (en
Inventor
张其善
张大伟
杨东凯
姚黎明
吴鑫山
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beihang University
Original Assignee
Beihang University
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 Beihang University filed Critical Beihang University
Priority to CNB2005100771607A priority Critical patent/CN1313927C/en
Publication of CN1687900A publication Critical patent/CN1687900A/en
Application granted granted Critical
Publication of CN1313927C publication Critical patent/CN1313927C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The present invention discloses a method for controlling running environments of a smart card. Firstly, the input bytecode sequences are classified in folding types. Secondly, the folding types are folded by a folding rule. Thirdly, the output folding order parameters are analyzed and classified. Finally, the bytecode sequences which are suitable for the operating environments of the smart card of the present invention are obtained. In order to effectively enhance the running efficiency of the application programs, the control method of the present invention designs a corresponding virtual instruction of a virtual machine by utilizing the method of the folding optimization and the analysis optimization of the bytecode instructions on the basis of the structures of an inner virtual machine and an outer virtual machine of a Java card, and thus, the code spaces on the smart card are shorted; the running speed of the application program is effectively enhanced.

Description

The control method of smart card running environment
Technical field
The present invention relates to a kind of method that smart card running environment is controlled, specifically, be meant a kind of control method of the Java of being applicable to platform intelligent card running environment.
Background technology
The Java smart card techniques is the transplanting of Java Virtual Machine technology to the limited resources equipment platform.The Applet of Java smart card generates the bytecode program of virtual machine instructions collection through compiling and conversion back.These bytecodes are gone up virtual machine by card again and are moved.The early stage running technology of Java Virtual Machine mainly is to explain execution mechanism, and being about to bytecode is that corresponding local run time version moves by interpretive program translation, and it is suitable for using in the resource less equipment.Then, in order to improve the execution speed of bytecode, local code execution, on-the-flier compiler and running technologies such as jit compiling execution, HotSpot technology and the execution of direct specialized hardware structure have been proposed to be compiled as again in succession.Improved speed significantly though be compiled as the method for local code, influenced the security mechanism and the portability of Java language to a certain extent, this in the application of IC cards that high security requires obviously and be not suitable for.On-the-flier compiler, jit compiling technology and HotSpot technology are when operation bytecode to be compiled as local code, the storage resources when this needs a large amount of operations, and this is not feasible in the smart card that has only 2K left and right sides RAM usually yet.
The smart card hardware structure of the employing special use that also has is at present moved bytecode with raising speed, and this performance gain that brings is very significant, but has also improved the cost of card simultaneously exponentially.Special-purpose hardware configuration also has certain limitation, as the expansion of pseudoinstruction, and at present can not be general at the CPU of intelligent card chip and other limited resources apparatus field Java application specific architecture.
Summary of the invention
The control method that the purpose of this invention is to provide a kind of smart card running environment, this control method is in order to improve the operational efficiency of application program effectively, in the Java card card, outside the card on the basis of virtual machine structure, the instruction folding optimizing of utilization bytecode and parsing optimal way, and design corresponding virtual machine pseudoinstruction, thereby reduced the code space on the smart card, improved the travelling speed of application program effectively.
The control method of a kind of smart card running environment of the present invention, described smart card comprise virtual machine in the card, the outer virtual machine of card at least, are provided with the interpreter unit in the virtual machine in the described card, and described interpreter unit is used to realize the resolving of byte code sequence; Be provided with converter unit in the outer virtual machine of described card, described converter unit is used to realize the transfer process of byte code sequence, the treatment step of its byte code sequence has (A) that the byte code sequence of described converter unit output is carried out the folding type classification, obtains folding type; (B) the described folding type after handling through (A) folding classification is instructed folding optimizing according to folding rule, the instruction folding optimizing byte code sequence after being optimized; (C) resolve classification of type to importing in the described interpreter, obtain resolving type through the described instruction folding optimizing byte code sequence that (B) is folding after handling; (D) the described parsing type of resolving through (C) after classification is handled is instructed analytical optimization according to resolution rules, obtain the physical address of object.
The advantage of the control method of smart card running environment of the present invention: (one) adopts the instruction folding optimizing to improve the execution speed of instruction and the response speed of Java card effectively outside the card of smart card on the virtual machine, promptly Zhi Ling execution speed is brought up to original 2.33 times, so folding optimizing has obviously been accelerated execution speed and the response speed of Java smart card Applet; (2) adopt the instruction analytical optimization on the virtual machine in the card of smart card, instruction behind the analytical optimization is resolved have (1) and reduced size of code in the card, has reduced smartcard internal data access number of times (2), and (3) have improved instruction execution speed.
Description of drawings
Fig. 1 is the structural representation of Java smart card running environment.
Fig. 2 is that the present invention instructs the sequential structure synoptic diagram of folding optimizing.
Fig. 3 is an IFA state transition graph of the present invention.
Fig. 4 is instantiation instruction process of analysis figure behind the analytical optimization of the present invention.
Fig. 5 is method call instruction process of analysis figure behind the analytical optimization of the present invention.
Fig. 6 is static fields access instruction process of analysis figure behind the analytical optimization of the present invention.
Fig. 7 is a JCVM system architecture diagram behind the analytical optimization of the present invention.
Embodiment
The present invention is described in further detail below in conjunction with accompanying drawing.
The present invention is a kind of control method of smart card running environment, and described smart card comprises virtual machine in the card, the outer virtual machine of card at least, is provided with the interpreter unit in the virtual machine in the described card, and described interpreter unit is used to realize the resolving of byte code sequence; Be provided with converter unit in the outer virtual machine of described card, described converter unit is used to realize the transfer process of byte code sequence, the treatment step of its byte code sequence has (A) that the byte code sequence of described converter unit output is carried out the folding type classification, obtains folding type; (B) the described folding type after handling through (A) folding classification is instructed folding optimizing according to folding rule, the instruction folding optimizing byte code sequence after being optimized; (C) resolve classification of type to importing in the described interpreter, obtain resolving type through the described instruction folding optimizing byte code sequence that (B) is folding after handling; (D) the described parsing type of resolving through (C) after classification is handled is instructed analytical optimization according to resolution rules, obtain the physical address of object.Described object is meant instantiation class, the static fields that is called method or is visited.
(1) instruction folding optimizing technology
In order to improve the execution efficient of in the processor of depositing the type architecture, using interpreter (software realization) to carry out the Java smart card of bytecode, during the software that the present invention will instruct folding thought to be incorporated into the Java card interpreter is realized, the control method of the instruction folding optimizing that virtual machine, the outer virtual machine of card combine in the card has been proposed according to the design feature of JCVM (Java card virtual machine).
The folding basic thought of instruction is one group of relevant operational order to be merged into an independent virtual machine pseudoinstruction carry out, thereby has avoided the pilot process by the stack reference operation number.Be the outer part of the folding card of instruction shown in Fig. 1 frame of broken lines, it (is included in byte code sequence in CAP (Converted Applet) file, the CAP file is that the Java application program of intelligent card is through after compiling, transforming, promptly generate the installation file that will download in the Java intelligent card, wherein include executable code and be called bytecode.) in one group of relevant collapsible instruction towards stack architecture be folded into one and independent be suitable for two-address or the three-address virtual machine pseudoinstruction that register architecture is carried out.These self-defining virtual machine pseudoinstructions are downloading on the card back by the execution that makes an explanation of the interpreter of supporting these pseudoinstructions.
The POC model structure that instruction folds is as follows:
Instruction is folding to be the process that one group of dependent instruction towards stack manipulation is merged into an independent compound instruction.
The folding group of instruction i.e. one group of folding dependent instruction.
The Java card virtual machine is a storehouse computing machine, therefore byte code instruction can be divided into three kinds of basic role types according to the correlation properties to stack manipulation: producer P, operator O and consumer C.
Producer P: the instruction that stack is counted in constant, local variable, static fields or the territory push operation of this object, as sconst_O, sload, getstatic_s, getfield_s_this.
Operator O: obtain operand and carry out the instruction of corresponding operating from the operand stack stack top, it can be divided into following four classes again:
Computing O is patrolled in calculation A: carry out and calculate the instruction of patrolling computing and result write back operation being counted stack.
O is shifted in control T: the class instruction is shifted in unconditional control, as jsr, and athrow, invoke*, goto, ret, sreturn, stableswitch.
Change stack states class instruction O S: can't add direct stack operation instruction or other change stack states class instructions of the folding group of instruction, as pop, swap, dup, conversion instruction i2s, s2i, non-this example domains operational order getfield, putfield.
Miscellany O M: can't add the folding group of instruction but do not influence the folding instruction of judging, as direct control local variable class instruction sinc.
Consumer C: eject the data class instruction from operand stack, it can be divided into following two classes again:
Variable storage C S: eject stack top data and store in local variable, static fields or this object, as sstore, putstatic_s, putfield_s_this.
Judge the C of branch B: eject stack top data and compare to carry out programmed control branch, as ifeq, ifnull.
The virtual machine pseudoinstruction of the instruction generation after folding processing the in the folding group of instruction can be divided into two kinds of three-address instruction and two-address instructions, and its formal definition is as follows:
The folding instruction of three-address I 3Quadruple notation be: I 3=(O, S 1, S 2, T), wherein: O is the operational code of representative instruction semantic, S 1, S 2Be source operand address, T is the destination operand address.
The folding instruction in two-address I 2Triple table be shown: I 2=(O, S 1, T), wherein: O is the operational code of representative instruction semantic, S 1Be source operand address, T is the destination operand address.
Folding instruction is towards the JCVM virtual-machine architecture, and therefore operational code is wherein used 185 to 253 intervals of reserving in the JCVM standard, and the addressing mode in the instruction comprises following five kinds:
Count addressing immediately: the address in the instruction can be used for S for counting immediately 1And S 2
Local variable directly address: the address in the instruction is the numbering of local variable in local variable area, can be used for S 1, S 2And T.
The operand stack addressing: the address in the instruction is the operand stack stack top, can be used for T.
The side-play amount addressing: be used for the T of condition jump instruction, the address in the instruction is the redirect side-play amount or the assembly side-play amount of program in the method district.
The constant pool addressing: the address in the instruction is the constant pool index, can be used for S 1, S 2And T.
According to aforesaid basic definition, the instruction folding process can be expressed as the folding group of instruction that is made of P, O, the instruction of C class and be folded into an independent I 3Or I 2The process of folding instruction.Be defined as follows corresponding to the folding grammatical F four-tuple of the instruction of this process: F=(V N, V T, G, S), wherein: finishing sign collection V T=x | x is a byte code instruction }, non-terminal collection V N={ the label symbol P in the POC model, O A, C S, C BThe folding cue mark I of U{ 3, I 2U{S}S ∈ V N, be the distinguished symbol of the syntax.
Production collection G={
S→I 3|I 2
I 3→PPO AC S|PPC B|PPO A
I 2→PC S
P →<P class byte code sequence 〉
O A→<O AClass byte code sequence 〉
C S→<C SClass byte code sequence 〉
C B→<C BThe class byte code sequence〉}
Production I among the set G 3, I 2Right part both be the folding group of discernible instruction, the folding process of instruction is biconditional operation and counts type instruction by the stipulations process of production right part to left part, the operand in the P instruction is the source operand in folding instruction the, C SOperand in the instruction is the destination operand in the folding instruction, PPC BDestination address after folding is jump instruction C BIn side-play amount, PPO ADestination operand address after folding is O ADestination address-operand stack stack top.Contain the instruction of O class in the group if instruction folds, then folding instruction semantic is determined by it, otherwise is determined by the instruction of C class.
The folding type of the folding group of instruction has first folding type, second folding type, the 3rd folding type and the 4th folding type in the byte code sequence after the compiling conversion.The folding group of instruction structure sees also shown in Figure 2.
First folding type: realize that two folding groups of instruction occur in order.
Second folding type: realize that instruction group B is instructed group A to separate, and instruction group A and instruction group B no datat associated.
The 3rd folding type realize that instruction group B is instructed group A to separate, and there is substance data associated in instruction group A and instruction group B.(sload 3 and sstore 3)
The 4th folding type realize that instruction group B is instructed group A to separate, and there is the double data associated in instruction group A and instruction group B.(sload 3 and sstore 3, sload 2 and sstore 2)
Data be correlated with (Data Dependence)
Data are relevant to be for instruction i and instruction j, if the result that (1) instructs j to use instruction i to produce, perhaps (2) instruction j makes k that data are relevant with finger 0, and instruction k and instruction i data are relevant, then instructs to have a write-then-read intersecting chain between the j and instruction i.There is a write-then-read intersecting chain in relevant being meant of substance data; There are two write-then-read intersecting chains in relevant being meant of double data.
As follows at every type of corresponding folding processing rule:
Folding rule one realizes described first folding type is folded in order;
Folding rule two at first folds the instruction group A in described second folding type, and the instruction that instruction is organized after A folds is ejected from instruction queue, then the instruction group B in described second folding type is folded;
Folding rule three, for instruction group A in the 3rd folding type is folded earlier, after folding it is ejected from instruction queue, thereby make the adjacent formation of instruction among the instruction group B treat folding group, and then folding instruction group B, make the code execution sequence be generated as instruction group B and instruction group A;
Folding rule four is for folding the instruction group A in the 4th folding type;
The concrete example of every kind of sequence as shown in Figure 2.
The folding process of instruction can be divided into two basic steps: at first, be that the folding rule of foundation is finished the identification to the folding group of instruction of input byte code sequence.Secondly, judge the type (first folding type, second folding type, the 3rd folding type or the 4th folding type) of the folding group of adjacent instructions, handle according to the aforementioned every type of corresponding folding rule that provides, thereby guarantee the bytecode of algorithm output and the correctness that folding instruction mixed sequence is carried out.
The instruction folding process is by a shift-in---the protocol analysis device is finished, a bytecode symbol stack at first is set, current state according to system decides in the bytecode shift-in character stack suitable in the input block, can carry out stipulations in case the right part of top stack symbol string and production is complementary.In this process, should follow following principle:
Folding process carries out C in a fundamental block BAnd O TThe class instruction is indicating the end of fundamental block, therefore can stop folding process after handling this type of instruction.
O SClass changes the instruction of operand stack state can't carry out further folding judgement, runs into this type of instruction and should empty the symbol stack, the reset system idle condition.
Do not change the O of operand stack state MThe class instruction does not enter the symbol stack and folds processing.
Adopt the shift-in strategy when shift-in-stipulations are conflicted when running into, both given long production with higher right of priority.
Formulation based on the finite state machine model IFA of the instruction folding algorithm of shift-in-protocol analysis device is as follows:
IFA is a five-tuple: IFA=(Q, ∑, f, q 0, E), wherein: Q is the finite aggregate of shift-in-protocol analysis device state, except that idle condition and final state, runs into P, O, C class order set changes corresponding state over to, so state set is as follows:
The Q={ idle condition, P state, O AState, C BState, C SState, final state }
∑ is limited incoming symbol collection, is finishing sign collection V among the grammatical F at this T
F is a state transition function, and field of definition is the cartesian product of state set and incoming symbol collection, and codomain is a state set:
F:Q * ∑ → Q, concrete graphic representation sees also Fig. 3 .4.
q 0∈ Q is the initial state of state machine, at this q 0=idle condition.
E is a final state, represents a folding end of fundamental block instruction.
Fig. 3 adopts the constitutional diagram in the UML modeling language that the state exchange of IFA has been carried out pattern description.
In the process that folds (D2), must fold the set type judgement relevant, therefore folding buffer queue Q is set with data F, need are carried out that folding group of correlated judgment adds in this formation and when output, shift out, be I if make current folding group G, the type of the rightest instruction wherein is R (I G), then folding process is described below: FoldAndCheckDependency () { ejects I from the symbol stack GIf (formation Q FBe sky)
If (ditto continuous P class instruction exists relevant)
I GAdd formation Q FIn;
else
Folding I GAnd output; Else{
If (I GSame Q FMiddle I PStructure types 3 sequences)
Abandon folding I G, folding I PAnd output;
Else // type 2
{
switch R(I G)
case C S,O A
Fold and output I GI P
case C B
Abandon folding I G, folding I PAnd output;
}}
}
(2) analytical optimization technology
JCVM needs it is resolved before explaining fill order.But traditional resolving frequent visit is positioned at the internal datas such as class, method and territory assembly of smartcard internal, has expended a large amount of system times.Therefore we are according to the special implementation structure of JCVM, propose and have realized that the analytical optimization technology that virtual machine, the outer virtual machine of card combine in the card comes the execution of instructing in the accelerator card.
Whether relevant according to resolving with the distribution of card stored, parsing can be divided into static binding resolving and dynamic binding resolving.Static binding resolving is only visited this CAP file, and be need not resource in the smart card, therefore with card stored structure-irrelevant, process when being a compiling.And dynamic binding resolving must obtain resource in the card, just can finish its resolving, so this process and card stored structurally associated, process when being an operation.
The collaborative design concept that realizes of two parts outside the card of JCVM virtual machine and in the card, we can decompose the standard resolving of instruction, static binding resolving during compiling is put to card and is finished, simultaneously with creating new instruction operation code (pseudoinstruction operational code, its value is greater than 184) and resolve after result (side-play amount or token) be configured to pseudoinstruction, and create the pseudoinstruction collection, as shown in Table 1.And the dynamic binding process will move the time is put and is finished to card, explains pseudoinstruction by virtual machine in blocking, and obtains the result that above-mentioned static binding is resolved, and finishes resolving in the follow-up card.
Table one pseudoinstruction collection
Pseudoinstruction Operational code Parameter
New 185 By the physical address of the category information of instantiation class
invokevirtual 186 The physical address of the method code of the method that is called
getstaticfield 189 The physical address of the static fields mirror image in accessed territory
... ... ...
The analytical optimization of instantiation instruction
Before execution command, at first will according to order parameter obtain will instantiation class, promptly finish class resolving.According to the difference of definition bag, can be divided into this by the instantiation class and wrap defined class (being called for short this bag class) and two kinds of situations of the defined class of outsourcing (being called for short the outsourcing class).
As shown in Figure 4, the parsing of this bag class will be carried out following operation:
Step 1: earlier with order parameter as the constant pool array indexing, and it is taken advantage of 4 (constant pool array element sizes) backs and the plot addition of constant pool assembly on CAP, promptly obtain the corresponding relative address of constant term on CAP, the mathematic(al) representation of this process is: constant term address=4 times constant pool index+constant pool plot (hereinafter to be referred as functional expression)
Step 2: take out and represent in the constant term that class_token is numerically equal to the side-play amount that is arranged in the CAP class component by the class of instantiation by the class_token of instantiation class.
Step 3:, obtain by the physical address of the category information of instantiation class on card with the interior class component plot addition of this side-play amount and card.
Step 1 and step 2 are the static binding process in the above resolving, can put to card is outer to carry out, and execution result and pseudoinstruction operational code are configured to pseudoinstruction return CAP, substitute CAP Central Plains and instruct.Step 3 item is the dynamic binding process, explains pseudoinstruction on card, determines the category information physical address, finishes class resolving.
The resolving step 1 of outsourcing class is identical with the resolving of Ben Bao class, but owing to the class_token of outsourcing class is made up of package_token (expression defines this type of bag) and class_token (expression is by the class of instantiation).Find CAP file address in the card by package_token earlier, obtain the physical address of category information in the class component of CAP by class_token again.
Wherein step 1 is the static binding process, is placed on outside the card to finish, and returns pseudoinstruction.All the other processes then are the dynamic binding process, explain in card and pseudoinstruction continue class resolving, obtain the physical address of category information in card at last.
The analytical optimization of method call instruction
Before the method call instruction is carried out, at first to obtain corresponding method, i.e. Method Of Accomplishment resolving according to order parameter.According to the difference of the class under the method, method can be divided into the method (being called for short the outsourcing method) of the class of the method (being called for short this bag method) of the class of this package definition and outer package definition.
As shown in Figure 5, the parsing of this bag method need be carried out following operation:
Step 1: the call function formula is converted into the corresponding relative address of constant term on CAP with the constant pool index.
Step 2: take out class_token in the constant term (class of expression definition the method) and method_token (representing invoked method).And class_token is carried out class resolve, obtain defining the relative address of category information in the CAP file of the class of the method.
Step 3: according to method_token (equaling the method table index on the numerical value), search the method table in the category information, obtain the side-play amount of method code in the method assembly of the method.Method assembly (Method Component) has been described defined each method in this bag, comprises the abnormality processing that the defined empty method of class and each method are got in touch.All methods in the method assembly and exception handling code all are the scale-of-two virtual machine instructions, by virtual machine interpreter it are explained and carry out, and can realize the defined function of this method.
Step 4: with method assembly plot addition in this side-play amount and the card, obtain will the call method code physical address.
Step 1, step 2 and step 3 are the static binding process, it is placed on outside the card finishes, and return corresponding pseudoinstruction.Step 4 item is the dynamic binding process, explanation pseudoinstruction in card, the physical address of the method code that obtains being called, Method Of Accomplishment resolving.
The resolving of outsourcing method is similar to this bag method, just because the class of define method is the outsourcing class, so will finish outsourcing class resolving earlier, obtains the physical address of category information in card, and all the other processes are then identical.In the above process, only 1 be the static binding process in steps, outside card, finish, and with the structure pseudoinstruction as a result of return, other steps then be the dynamic binding process, the card in the explanation pseudoinstruction, continuation method resolving obtains the physical address of method code in card at last.
The analytical optimization of static fields access instruction
Before the static fields access instruction is carried out, also to obtain the physical address in the access static territory of wanting earlier, promptly need finish static fields resolving earlier.According to the difference of the affiliated class of static fields, static fields can be divided into two kinds of situations of static fields (being called for short the outsourcing static fields) of the class of the static fields (being called for short this bag static fields) of the class of this package definition and outer package definition.
As shown in Figure 6, this bag static fields is resolved needs to carry out following operation:
Step 1: the call function formula is converted into the corresponding relative address of constant term on CAP with the constant pool index.
Step 2: take out staticfield_token (being numerically equal to the side-play amount of this static fields in the static fields mirror image) in the constant term.
Step 3:, can obtain the physical address of accessed static fields on card with the interior static fields mirror image plot addition of this side-play amount and card.
Step 1 and step 2 are the static binding process, can finish outside card, and return corresponding pseudoinstruction.Step 3 item is the dynamic binding process, and explanation pseudoinstruction in card is determined the physical address of static fields, finishes static fields resolving.
Because the outsourcing static fields is resolved information needed not in this CAP, therefore after the execution in step 1, the constant term that obtains is by package_token (representing the bag that this static fields is affiliated), class_token (representing the class that this static fields is affiliated) and staticfield_token (static fields that expression will be visited) form, need to obtain defining according to package_token earlier the CAP file address of this static fields, obtain physical address in the card of this static fields by information among the CAP by class_token and staticfield_token then.By resolving as can be known, only 1 be the static binding process in steps, put to card is outer and carry out, and return corresponding pseudoinstruction that other processes then be the dynamic binding process, explanation pseudoinstruction in card is converted into the physical address of accessed static fields in blocking with token.
The realization of CAP document analysis optimization also is divided into realization two parts in outer realization of card and the card accordingly.Blocking outer process carries out on the PC platform, here we realize with Java language, with the inlet flow among the Java instruction in the CAP file is read, finish the card of all kinds of instructions and resolve outward by defining different analytical functions, by the output stream among the Java result is replaced former instruction then and write among the CAP, promptly finished the outer resolving of card.
The content that resolving will realize in the card is that the explanation of pseudoinstruction is carried out.When explaining pseudoinstruction, our employing table jump method is every pseudoinstruction location, according to different pseudoinstruction operational codes, system skips to corresponding processing code place, continues to carry out not intact resolving, and last analysis result is returned to interpreter, interpreter will be according to this result, data structures such as visit Java stack, heap are called relevant nation method, finish the explanation of instruction and carry out.
The system chart of JCVM after the optimization as shown in Figure 7.
Beneficial effect:
(1) instruction folding optimizing technology
The present invention has improved the execution speed of instruction and the response speed of Java card.
The folding performance gain P that is brought of defined instruction gFor:
The average execution time before and after folding is as shown in the table:
Instruction time behind the table eighty percent discount prestack
Folding group First folding type Second folding type The 3rd folding type The 4th folding type
Before folding (μ s) 54.76 156.72 127.39 117.33
Folding back (μ s) 27.94 58.67 58.67 50.29
Therefore the average performance gain of this folding algorithm is:
Figure C20051007716000142
54.76 + 156.72 + 127.39 + 117.33 28.94 + 58.67 + 58.67 + 50.29 = 456.2 195.57 = 2.33
Promptly Zhi Ling execution speed is brought up to original 2.33 times.Therefore folding optimizing has obviously been accelerated execution speed and the response speed of Java smart card Applet.
(2) analytical optimization technology
Process of analysis after the optimization has the advantage of the following aspects:
(1) reduced size of code in the card
By process of analysis as can be seen, analytical optimization is the part resolving on card originally, moves to the outer execution of card, therefore reduced card internal program size of code, table three has shown optimizes in the forward and backward card size of code relatively, and as seen by analytical optimization, size of code can reduce to original 1/2 even 1/4 in the card.
Table three is optimized forward and backward size of code relatively
Instruction Size of code (OK) before optimizing Optimize post code amount (OK)
Instantiation 282 138
Method call 258 63
The static fields visit 118 28
(2) reduced smartcard internal data access number of times
Table four shown optimize data in the front and rear card access times relatively, the total access times of optimizing data in the card of back drop to original 3/8.
Table four is optimized the interior data access number of times of forward and backward card relatively
Instruction Data access number of times in the card before optimizing Optimize data access number of times in the card of back
Instantiation 2 1
Method call 4 1
The static fields visit 2 1
(3) improved instruction execution speed
Table five has shown optimizes the front and back comparison of instruction parsing time, and the visible resolution speed of instructing the back of optimizing is brought up to original 3.45 times, has therefore greatly improved the execution speed of resolving instruction.
Instruction was resolved time ratio before and after table five was optimized
Instruction The parsing time (μ S) before optimizing Optimize the back parsing time (μ S) Performance gain (optimize back parsing time/preceding parsing time of optimizations)
The visit of instantiation method call static fields 316.0 289.1 132.2 154.6 70.6 31.4 2.043 4.095 4.210

Claims (8)

1. the control method of a smart card running environment, described smart card comprise virtual machine in the card, the outer virtual machine of card at least, are provided with the interpreter unit in the interior virtual machine of described card, and described interpreter unit is used to realize the resolving of byte code sequence; Be provided with converter unit in the outer virtual machine of described card, described converter unit is used to realize the transfer process of byte code sequence, it is characterized in that: the treatment step of byte code sequence has
(A) byte code sequence to described converter unit output carries out the folding type classification, obtains folding type;
Described folding type has first folding type, realizes that two folding groups of instruction occur in order; With
Second folding type realizes that instruction group B is instructed group A to separate, and instruction group A and instruction group B no datat associated; With
The 3rd folding type realize that instruction group B is instructed group A to separate, and there is substance data associated in instruction group A and instruction group B; With
The 4th folding type realize that instruction group B is instructed group A to separate, and there is the double data associated in instruction group A and instruction group B;
(B) the described folding type after handling through (A) folding classification is instructed folding optimizing according to folding rule, the instruction folding optimizing byte code sequence after being optimized;
Described folding rule has folding rule one, and described first folding type is folded in order; With
Folding rule two at first folds the instruction group A in described second folding type, and the instruction that instruction is organized after A folds is ejected from instruction queue, then the instruction group B in described second folding type is folded; With
Folding rule three, instruction group A in the 3rd folding type is folded earlier, after folding it is ejected from instruction queue, thereby make the adjacent formation of instruction among the instruction group B treat folding group, and then folding instruction group B, make the code execution sequence be generated as instruction group B and instruction group A; With
Folding rule four folds the instruction group A in the 4th folding type;
(C) resolve classification of type to importing in the described interpreter, obtain resolving type through the described instruction folding optimizing byte code sequence that (B) is folding after handling;
Described parsing type has first to resolve type, resolves the physical address that obtains the instantiation class by the order parameter in the described instruction folding optimizing byte code sequence through outer virtual machine of described card and Ka Nei virtual machine, realizes the analytical optimization of instantiation instruction; With
Second resolves type, resolves the physical address that obtains the method for being called, the analytical optimization of implementation method call instruction by the order parameter in the described instruction folding optimizing byte code sequence through outer virtual machine of described card and Ka Nei virtual machine; With
The 3rd resolves type, resolves the physical address that obtains institute access static territory by the order parameter in the described instruction folding optimizing byte code sequence through outer virtual machine of described card and Ka Nei virtual machine, realizes the analytical optimization of static fields access instruction;
(D) the described parsing type of resolving through (C) after classification is handled is instructed analytical optimization according to resolution rules, obtain the physical address of object.
2. the control method of smart card running environment according to claim 1 is characterized in that: resolve in the type and to the described first analytical optimization process of resolving instantiation instruction in the type be:
(1) earlier with the order parameter in the described instruction folding optimizing byte code sequence as the constant pool array indexing, obtain the constant term address with 4 times described constant pool array indexing and the plot addition of constant pool assembly on the CAP file then, i.e. constant term address=4 times constant pool index+constant pool plot; (2) represent by the class mark of instantiation class in the taking-up constant term; (3) the interior class component plot addition of described class mark and card is obtained by the physical address of instantiation class in smart card.
3. the control method of smart card running environment according to claim 2, it is characterized in that: step described in the analytical optimization process (1) and described step (2) are the static binding process, can put to card and carry out on the virtual machine, and the result after the instruction operation code that will newly create and the described static binding parsing is in conjunction with being defined as pseudoinstruction, return the CAP file, substitute the former instruction among the CAP; Described step (3) is the dynamic binding process, resolves pseudoinstruction on the virtual machine in card, is used for the parsing that definite category information physical address is finished described instantiation class.
4. the control method of smart card running environment according to claim 1 is characterized in that: resolve in the type and to the described second analytical optimization process of resolving method call instruction in the type be:
(1) earlier with the order parameter in the described instruction folding optimizing byte code sequence as the constant pool array indexing, obtain the constant term address with 4 times described constant pool array indexing and the plot addition of constant pool assembly on the CAP file then, i.e. constant term address=4 times constant pool index+constant pool plot; (2) take out class mark and method mark in the constant term, and described class mark is carried out class resolve, obtain defining the relative address of category information in the CAP file of the class of the method; (3) be marked in the described category information that obtains in (2) step according to described method and search, obtain the side-play amount of method code in the method assembly of described method; (4) side-play amount that will obtain through step (3) and the addition of the described method assembly plot physical address that obtains required call method code.
5. the control method of smart card running environment according to claim 1 is characterized in that: resolve in the type and to the described the 3rd analytical optimization process of resolving static fields access instruction in the type be:
(1) earlier with the order parameter in the described instruction folding optimizing byte code sequence as the constant pool array indexing, obtain the constant term address with 4 times described constant pool array indexing and the plot addition of constant pool assembly on the CAP file then, i.e. constant term address=4 times constant pool index+constant pool plot; (2) the static fields mark in the taking-up constant term; (3) the static fields mark and the addition of static fields mirror image plot of taking out in the step (2) obtained the physical address of accessed static fields on smart card.
6. the control method of smart card running environment according to claim 1, it is characterized in that: described the 3rd folding type in the folding type is substance data associated.
7. the control method of smart card running environment according to claim 1, it is characterized in that: described the 4th folding type in the folding type is the double data associated.
8. the control method of smart card running environment according to claim 1, it is characterized in that: described object is meant instantiation class, the static fields that is called method or is visited.
CNB2005100771607A 2005-06-16 2005-06-16 Method for controlling smart card running environment Expired - Fee Related CN1313927C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005100771607A CN1313927C (en) 2005-06-16 2005-06-16 Method for controlling smart card running environment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005100771607A CN1313927C (en) 2005-06-16 2005-06-16 Method for controlling smart card running environment

Publications (2)

Publication Number Publication Date
CN1687900A CN1687900A (en) 2005-10-26
CN1313927C true CN1313927C (en) 2007-05-02

Family

ID=35305941

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005100771607A Expired - Fee Related CN1313927C (en) 2005-06-16 2005-06-16 Method for controlling smart card running environment

Country Status (1)

Country Link
CN (1) CN1313927C (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7868897B2 (en) * 2006-06-30 2011-01-11 Intel Corporation Apparatus and method for memory address re-mapping of graphics data
CN100454256C (en) * 2006-12-25 2009-01-21 北京飞天诚信科技有限公司 Method and device for increasing self definition program operation speed
CN101739404B (en) * 2008-11-05 2012-08-29 爱思开电讯投资(中国)有限公司 Bytecode-optimized database and establishing method thereof and bytecode optimizing mehtod
CN101777061B (en) * 2009-12-31 2014-06-04 北京握奇数据系统有限公司 JAVA card object management method and JAVA card
CN102103489A (en) * 2011-01-28 2011-06-22 武汉天喻信息产业股份有限公司 Method for improving execution efficiency of static field access command
CN105653351B (en) * 2015-12-30 2019-08-06 北京博思汇众科技股份有限公司 The optimization method and system of java card virtual machine
CN106020920A (en) * 2016-05-11 2016-10-12 广州新诚芯信息科技有限公司 Preprocessing method and system for JCVM interpreter
CN106293529A (en) * 2016-08-08 2017-01-04 北京数码视讯支付技术有限公司 Method, device and the smart card of a kind of smart cards for storage data

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2003021428A1 (en) * 2001-08-31 2003-03-13 Schlumberger Systemes S.A. Method and apparatus for linking converted applet files
CN1450450A (en) * 2003-05-15 2003-10-22 复旦大学 32-bit embedded microprocessor adopting double instruction set

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2003021428A1 (en) * 2001-08-31 2003-03-13 Schlumberger Systemes S.A. Method and apparatus for linking converted applet files
CN1450450A (en) * 2003-05-15 2003-10-22 复旦大学 32-bit embedded microprocessor adopting double instruction set

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
JAVA处理器中指令合并技术的研究与实现 王涛,毛志刚,叶以正,计算机研究与发展,第37卷第1期 2000 *
JAVA处理器中指令合并技术的研究与实现 王涛,毛志刚,叶以正,计算机研究与发展,第37卷第1期 2000;羊性滋应用于智能卡的JAVA嵌入式微处理器核的设计 唐小勇,微电子学,第30卷第6期 2000;一种JAVAIC卡专用CPU结构研究 王涛,毛志刚,叶以正,电子学报,第28卷第11期 2000 *
一种JAVAIC卡专用CPU结构研究 王涛,毛志刚,叶以正,电子学报,第28卷第11期 2000 *
羊性滋应用于智能卡的JAVA嵌入式微处理器核的设计 唐小勇,微电子学,第30卷第6期 2000 *

Also Published As

Publication number Publication date
CN1687900A (en) 2005-10-26

Similar Documents

Publication Publication Date Title
CN1313927C (en) Method for controlling smart card running environment
CN1186722C (en) Method and device for using register distributor to establish calling convented preface and ending program code
CN1324467C (en) Token-based linking
CN1922574A (en) Method and system for performing link-time code optimization without additional code analysis
CN1119756C (en) Method and system for performing static initialization
CN1848088A (en) Method and apparatus for transforming java native interface function calls into simpler operations during just-in-time compilation
CN1421001A (en) Optimization of N-base typed arithmetic expressions
CN1160624C (en) Method and equipment for distributing stack channel
CN1234548A (en) Mixed execution of stack and abnormal processing
CN1823323A (en) Method and apparatus for performing native binding
CN1367895A (en) Migration of different source languages to executing medium
CN1687862A (en) Smart card safety environment control method
CN1295605C (en) Software support for virtual machine interpreter (VMI) acceleration hardware
CN1419192A (en) Intermediate code pretreatment, executive device, executive system and computer program products
CN1813243A (en) Apparatus and methods for desynchronizing object-oriented software applications in managed runtime environments
CN1173262C (en) Optimized bytecode interpreter of virtual machine instructions
CN1313926C (en) Template compilation method
CN1892602A (en) Method for processing library function call in binary translation
US20060101437A1 (en) Data processing device and method
CN1801093A (en) Class loading implementation method in Java operation system
CN1975693A (en) Command simulation analytic system with automatic driving function and realizing method thereof
CN1255744C (en) Universal high speed IC card issuing apparatus and method
CN1900910A (en) Identifying method of multiple target branch statement through jump list in binary translation
US20040015850A1 (en) Specialized heaps for creation of objects in object-oriented environments
CN1231838C (en) Method for verifying code transfermers for incorporated system, in particular in chip card

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20070502

Termination date: 20100616