CN105573814A - Method for analysis and execution of local variable byte code of JAVA card by applying chip hardware - Google Patents
Method for analysis and execution of local variable byte code of JAVA card by applying chip hardware Download PDFInfo
- Publication number
- CN105573814A CN105573814A CN201510555310.4A CN201510555310A CN105573814A CN 105573814 A CN105573814 A CN 105573814A CN 201510555310 A CN201510555310 A CN 201510555310A CN 105573814 A CN105573814 A CN 105573814A
- Authority
- CN
- China
- Prior art keywords
- bytecode
- local variable
- byte code
- java card
- hardware
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 45
- 230000000875 corresponding effect Effects 0.000 description 8
- 238000007689 inspection Methods 0.000 description 3
- 238000010586 diagram Methods 0.000 description 2
- 230000002596 correlated effect Effects 0.000 description 1
- 230000007423 decrease Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000002203 pretreatment Methods 0.000 description 1
- 230000002123 temporal effect Effects 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
The invention discloses a method for analyzing a local variable byte code of a JAVA card by hardware. The method comprises the following steps of returning to initialization of status word (SW) through instruction execution; determining a pointer PC of the byte code is not 0, wherein the current byte code is not processed by a native method; reading the byte code at the current pointer PC; and calling an instruction processing byte code of central processing unit (CPU) by a byte code processing function according to the read byte code. With the adoption of the method, the problems of low performance and difficulty in reaching the performance index applied in the industry because the byte code of the JAVA card is realized by software in the JAVA card industry can be solved.
Description
Technical field
The present invention relates to JAVA field of intelligent cards, particularly a kind of JAVA card local variable bytecode adopts chip hardware to resolve the method performed.
Background technology
JAVA card virtual machine (hereinafter referred to as JCVM) is the scaled-down version java virtual machine be loaded on intelligent card chip, and the technological core of virtual machine is the management of JAVA card stack frame, and the parsing of JAVA card bytecode performs.But due to current intelligent card chip resource-constrained, CPU frequency is lower, the JAVA card virtual machine execution speed realized with Software Coding is slow, when parsing performs bank finance related application, is difficult to the transaction performance index meeting the sector requirement.And after increase security mechanism, hydraulic performance decline is serious, the more difficult performance requirement reaching sector application.The slow problem of virtual machine execution speed is at other industry also ubiquity except banking industry, and therefore to resolve the efficiency performed particularly important for JAVA card Virtual Machine bytecodes, and its performance height becomes one of factor of JAVA card product success or failure most critical.
Summary of the invention
The invention provides a kind of JAVA card local variable bytecode adopts chip hardware to resolve the method performed, and greatly can improve performance, ensures the reliability of the functional module that hardware realizes simultaneously.JCVM local variable bytecode refers to Fig. 3 and Fig. 4.
In JCVM bytecode resolver implementation, if the bytecode that local variable is correlated with (refers to Fig. 3, bytecode in Fig. 4 form), namely the processing logic (aiming at the cpu instruction of JCVM expansion) that directly can call chip hardware provided by the invention provides processes, and the Software Coding mode no longer adopting performance lower realizes.Processing mode provided by the invention is pioneering, not yet finds that there is similar technique and exists.
The principle that JAVA card system realizes is: keep JCVM resolver framework constant, the processing module of local variable associated byte code is turned to hardware logic to realize, if chip is JCVM extension CPU instruction set specially, not only can not affect the system of overall JCVM, and the reliability of this part can be improved.The method can be applied in the realization of various JAVA card virtual machine resolver, greatly improves JAVA card Virtual Machine bytecodes and resolves the efficiency and reliability that perform.
In order to realize foregoing invention object, the method for the hardware parser JAVA card local variable bytecode that this method provides comprises the following steps:
Step one, chip are used for the hardware register of managing stacks frame for JCVM expansion specially, comprise three: reg_FP, reg_FP_TOP, reg_SP;
Step 2, chip are specially for JCVM expansion is used for the PC pointer hardware register reg_PC of JAVA card bytecode flow management;
The bytecode that step 3, local variable are relevant all no longer adopts Software Coding to realize, and adopts the cpu instruction of extended chip to realize its function.
Specifically, comprising: the codomain of the local variable suggested by current byte code is taken out, is stored in corresponding operand; And the operand suggested by current byte code is taken out, and be stored in the local variable of bytecode prompting.Comprising the codomain of taking out local variable, find corresponding operand position, value is stored into correspondence position; Or take out corresponding operand, find corresponding local variable position, value is stored into correspondence position.Therebetween, the legitimacy being checked variable position by stack pointer is needed, the legitimacy of operand position.
Step 4, chip interrupt for JCVM expansion specially, when the bytecode that hardware implementing local variable is relevant, when running into mistake generation, trigger JCVM process and interrupt, in interrupt handling routine, carry out error handle to corresponding mistake.Mode for error handle has multiple, and each user can need to carry out according to system, such as carries out security alarm, or quotes the informations such as code error.
Accompanying drawing explanation
Fig. 1 JAVA card stack frame structure schematic diagram
Fig. 2 JAVA card local variable of the present invention bytecode adopts chip hardware to resolve the method flow schematic diagram performed
Fig. 3 operand plank road local variable carries out the bytecode stored
Fig. 4 local variable is to the bytecode of operand stack
Embodiment
Adopt chip hardware to resolve the process performed below in conjunction with accompanying drawing and example to JAVA card local variable bytecode provided by the present invention to be described further.
One, stack management
As shown in Figure 1, JAVA card stack frame comprises operand stack, local variable area, and contextual information district, and operand stack is JAVA card bytecode operand stack region, and local variable area is JAVA card current method local variable storage area.Resolve in the process performed at JAVA card bytecode, data are mainly carried out alternately in operand stack and local variable region, and the performance height in this region can affect JAVA card Virtual Machine bytecodes largely and resolve the performance performed.In the present invention, by the FP (at the bottom of stack) in accompanying drawing 1, G_FP_top (local variable stack top), SP (operand stack top) intelligent card chip dedicated hardware register carries out its storage stored, and the pop down of data is realized by hardware logic, Pop operations manages; The processing time of register will much smaller than the time of carrying out managing and processing with software (for the ease of hereafter describing, these three registers are called reg_FP, reg_FP_TOP, reg_SP by this invention for the time being).
Two, the hardware management of JAVA card bytecode flow index is realized
Carry out bytecode value at JCVM bytecode resolver, and when obtaining operand from byte code stream, need from the operational code in current PC pointer reading bytecode code stream or operand.Design chips hardware register reg_PC of the present invention is used for special sensing JAVA card byte code stream current location.When JCVM bytecode resolver carries out bytecode parsing execution, deposit data can be read to temporal cache from the position pointed by register reg_PC, resolve for bytecode, after current byte code reads, hardware logic realizes the increment operation (the PC pointer value of namely preserving in reg_PC is incremented to the position that next bytecode starts automatically) of bytecode PC pointer automatically.Because JAVA card application is JAVA card byte code stream, in application implementation, when each acquisition bytecode, all need to read, frequency is very high, with this operation of hardware handles, greatly can shorten the time of bytecode process.
Three, in the bytecode processing procedure that local variable is relevant, the invention provides the functional module of chip hardware logic realization local variable process, the mode as cpu instruction processes, and substitutes original pure software processes mode.As increased following instruction set:
A, realize the store byte code of operand stack data to local variable
1)CPUCmd_SSTORE、CPUCmd_SSTORE_0、CPUCmd_SSTORE_1、CPUCmd_SSTORE_2、CPUCmd_SSTORE_3
This type of cpu instruction is for realizing the function of bytecode SSTORE, SSTORE_0, SSTORE_1, SSTORE_2, SSTORE_3, and command function illustrates and refers to Fig. 3.
2)CPUCmd_ASTORE、CPUCmd_ASTORE_0、CPUCmd_ASTORE_1、CPUCmd_ASTORE_2、CPUCmd_ASTORE_3
This type of cpu instruction is for realizing the function of bytecode ASTORE, ASTORE_0, ASTORE_1, ASTORE_2, ASTORE_3, and command function illustrates and refers to Fig. 3.
3)CPUCmd_ISTORE、CPUCmd_ISTORE_0、CPUCmd_ISTORE_1、CPUCmd_ISTORE_2、CPUCmd_ISTORE_3
This type of cpu instruction is for realizing the function of bytecode ISTORE, ISTORE_0, ISTORE_1, ISTORE_2, ISTORE_3, and command function illustrates and refers to Fig. 3.
B, the store byte code realizing from local variable data to operand stack
1)CPUCmd_SLOAD、CPUCmd_SLOAD_0、CPUCmd_SLOAD_1、CPUCmd_SLOAD_2、CPUCmd_SLOAD_3
This type of cpu instruction is for realizing the function of bytecode SLOAD, SLOAD_0, SLOAD_1, SLOAD_2, SLOAD_3, and command function illustrates and refers to Fig. 4.
2)CPUCmd_ALOAD、CPUCmd_ALOAD_0、CPUCmd_ALOAD_1、CPUCmd_ALOAD_2、CPUCmd_ALOAD_3
This type of cpu instruction is for realizing the function of bytecode ALOAD, ALOAD_0, ALOAD_1, ALOAD_2, ALOAD_3, and command function illustrates and refers to Fig. 4.
3)CPUCmd_ILOAD、CPUCmd_ILOAD_0、CPUCmd_ILOAD_1、CPUCmd_ILOAD_2、CPUCmd_ILOAD_3
This type of cpu instruction is for realizing the function of bytecode ILOAD, ILOAD_0, ILOAD_1, ILOAD_2, ILOAD_3, and command function illustrates and refers to Fig. 4.
Four, when the bytecode that the local variable of cpu instruction process is above relevant, the bounds checking that its bytecode is relevant is realized by hardware logic.
1, local variable operates inspection of crossing the border
In reading or when storing local variable, originally be at byte code stream or operational code and can obtain the local variable index index of this bytecode when pre-treatment, hardware logic needs to check in conjunction with this index and reg_FP and reg_FP_top, checks whether this index exceeds local variable scope.
2, operand stack operates inspection of crossing the border
Obtaining data be stored into local variable from operand stack, or from local variable obtain data be stored into operand stack time, whether the operand stack all needing inspection to operate within the scope of reg_FP_top, reg_SP and maximum stack frame boundaries.
Five, error handling processing
Realize in the bytecode treatment scheme of (cpu instruction) at above hardware logic, when makeing mistakes in corresponding border etc., trigger hardware interrupts, in interrupt handling routine, JAVA card platform developer can carry out the subsequent treatment of mistake, as security alarm or prompting code error.
Six, JAVA card virtual machine resolves the flow process calling cpu instruction
JCVM bytecode resolver treatment scheme is with reference to accompanying drawing 2:
Step 1, code start, and instruction performs the status word SW returned and is initialized as 9000;
If step 2 bytecode PC pointer is not 0, then enter next step, otherwise return current SW, process terminates;
Step 3, judging current byte code whether about the process of native method, is call the process of naive method, be not, enter next step;
The bytecode at step 4, reading current PC pointer place, according to the bytecode read, enters corresponding bytecode process function, is disposed, turns back to step 2.
Describedly entering corresponding bytecode process function, carrying out bytecode process for calling cpu instruction.
As SLOAD order:
void_sload()
{ // programme with c Eembedded Assembly instruction mode below, calls cpu instruction
CPUCmd_SLOAD;
}
The treatment scheme that different cpu instructions carries out bytecode is different, illustrates below for two cpu instruction process bytecodes:
1, CPUCmd_SSTORE instruction processing pipeline:
Byte code stream position pointed by the reg_PC register of chip hardware location, reads SSTORE operational code operand index below, and the codomain bounds recorded according to reg_SP, reg_FP and reg_FP_top judges index whether within the scope of this.If do not existed, triggered interrupts, enters interrupt handling routine and carries out error handle; If, show that current operation number index is within the scope of correct local variable, respective value need be stored into the local variable position pointed by index.
2, CPUCmd_SLOAD instruction processing pipeline:
Byte code stream position pointed by the reg_PC register of chip hardware location, read SLOAD operational code operand index below, and judge index whether within correct local variable scope according to reg_FP, reg_FP_top etc., make mistakes and then produce and interrupt or reset (chip hardware can setting operation mode); Correctly, then take out data from index, data are stored into inside JCVM operand stack.
Claims (4)
1. JAVA card local variable bytecode adopts chip hardware to resolve the method performed, and it is characterized in that, the method comprises:
Instruction performs return state word SW initialization;
Determine that bytecode PC pointer is not 0, and current byte code not the process about native method;
Read the bytecode at current PC pointer place, according to the bytecode read, by bytecode process function call cpu instruction process bytecode.
2. method according to claim 1, is characterized in that, is describedly comprised by bytecode process function call cpu instruction process bytecode:
Pointed by the reg_PC register of chip hardware location bytecode position, the operand index of read opcode, judge index whether within correct local variable scope according to register, not within described local variable scope, then produce and interrupt or reset; Within described local variable scope, then take out data from index, be stored into operand stack.
3. method according to claim 1 and 2, is characterized in that, described cpu instruction is realize the newly-increased instruction set of hardware parser local variable bytecode, is specially prefixing CPUCmd_ before bytecode.
4. method according to claim 3, is characterized in that, before the method starts, specially for JCVM expansion is used for the hardware register of managing stacks frame, expansion is used for the PC pointer hardware register of JAVA card bytecode management, for JCVM expansion is interrupted.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510555310.4A CN105573814A (en) | 2015-09-01 | 2015-09-01 | Method for analysis and execution of local variable byte code of JAVA card by applying chip hardware |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510555310.4A CN105573814A (en) | 2015-09-01 | 2015-09-01 | Method for analysis and execution of local variable byte code of JAVA card by applying chip hardware |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN105573814A true CN105573814A (en) | 2016-05-11 |
Family
ID=55883986
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201510555310.4A Pending CN105573814A (en) | 2015-09-01 | 2015-09-01 | Method for analysis and execution of local variable byte code of JAVA card by applying chip hardware |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN105573814A (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106406932A (en) * | 2016-08-26 | 2017-02-15 | 北京中电华大电子设计有限责任公司 | Improved Java card initialization method and Java card |
| CN106649009A (en) * | 2016-11-30 | 2017-05-10 | 北京中电华大电子设计有限责任公司 | JAVA card bytecode reference access test method |
| CN106845225A (en) * | 2016-12-20 | 2017-06-13 | 北京中电华大电子设计有限责任公司 | A kind of boundary detection method of JAVA card frame |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2003025743A1 (en) * | 2001-09-12 | 2003-03-27 | Hitachi, Ltd. | Processor system having java accelerator |
| CN1468399A (en) * | 2000-10-10 | 2004-01-14 | 纳佐米通信公司 | JAVA hardware accelerator using microcode engine |
| CN1513137A (en) * | 2001-05-31 | 2004-07-14 | Arm | Data processing using multiple instruction sets |
| CN101375248A (en) * | 2006-06-07 | 2009-02-25 | 香港应用科技研究院有限公司 | Hardware JavaTM Bytecode Decoder |
-
2015
- 2015-09-01 CN CN201510555310.4A patent/CN105573814A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1468399A (en) * | 2000-10-10 | 2004-01-14 | 纳佐米通信公司 | JAVA hardware accelerator using microcode engine |
| CN1513137A (en) * | 2001-05-31 | 2004-07-14 | Arm | Data processing using multiple instruction sets |
| WO2003025743A1 (en) * | 2001-09-12 | 2003-03-27 | Hitachi, Ltd. | Processor system having java accelerator |
| CN101375248A (en) * | 2006-06-07 | 2009-02-25 | 香港应用科技研究院有限公司 | Hardware JavaTM Bytecode Decoder |
Non-Patent Citations (4)
| Title |
|---|
| 谢晶晶: "JCVM解释器的研究与设计", 《中国优秀硕士学位论文全文数据库 信息科级辑》 * |
| 赵丽等: "一种JVM硬件体系结构的探讨", 《科技资讯》 * |
| 赵睿: "软硬件结合构造JVM的方法", 《计算机工程应用技术》 * |
| 黄以华等: "Java处理器关键技术分析", 《小型微型计算机系统》 * |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106406932A (en) * | 2016-08-26 | 2017-02-15 | 北京中电华大电子设计有限责任公司 | Improved Java card initialization method and Java card |
| CN106406932B (en) * | 2016-08-26 | 2020-01-07 | 北京中电华大电子设计有限责任公司 | Improved Java card initialization method and Java card |
| CN106649009A (en) * | 2016-11-30 | 2017-05-10 | 北京中电华大电子设计有限责任公司 | JAVA card bytecode reference access test method |
| CN106845225A (en) * | 2016-12-20 | 2017-06-13 | 北京中电华大电子设计有限责任公司 | A kind of boundary detection method of JAVA card frame |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| RU2281547C2 (en) | Method for data exchange using several sets of commands | |
| US7783867B2 (en) | Controlling instruction execution in a processing environment | |
| CN106326107A (en) | Non-intrusion type embedded software abnormity processing verification method based on simulation environment | |
| KR101875225B1 (en) | Process, computer program, and device for security of intermediate code of programming for the execution thereof by a virtual machine | |
| US20070006224A1 (en) | Controlled execution of a program used for a virtual machine on a portable data carrier | |
| KR20060029178A (en) | Method and apparatus for performing exception handling with adjustable precision | |
| US8261251B2 (en) | Modification of array access checking in AIX | |
| US8387031B2 (en) | Providing code improvements for nested virtual machines | |
| CN105573814A (en) | Method for analysis and execution of local variable byte code of JAVA card by applying chip hardware | |
| JP3732198B2 (en) | Non-processing operation processing in multiple instruction set systems | |
| KR101249693B1 (en) | Selecting subroutine return mechanisms | |
| US6907515B2 (en) | Configuration control within data processing systems | |
| US7802080B2 (en) | Null exception handling | |
| CN117742791A (en) | Instruction processing method and device | |
| KR102462864B1 (en) | Apparatus and method for dynamic binary instrumentation using multi-core | |
| US10802854B2 (en) | Method and apparatus for interpreting bytecode instruction stream | |
| Lackner et al. | Towards the hardware accelerated defensive virtual machine–type and bound protection | |
| Mao et al. | eWAPA: an eBPF-based WASI performance analysis framework for web assembly runtimes | |
| CN112199160B (en) | Virtual instruction recovery method, device, equipment and storage medium | |
| CN104077173A (en) | Execution method for JAVA program instruction in smart card, and smart card | |
| US20250322356A1 (en) | Identifying active code sections via memory forensics | |
| US11966619B2 (en) | Background processing during remote memory access | |
| EP2297636A1 (en) | Method of interruption of meta language program code execution | |
| US11152076B2 (en) | Apparatus and method for executing debug instructions | |
| CN119127396A (en) | Bytecode execution method, device, electronic device, terminal, medium and program |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| DD01 | Delivery of document by public notice |
Addressee: Gai Ana Document name: Notification of Acceptance of Patent Application |
|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20160511 |
|
| WD01 | Invention patent application deemed withdrawn after publication |