WO2012086288A1 - Exception control method, system, and program - Google Patents
Exception control method, system, and program Download PDFInfo
- Publication number
- WO2012086288A1 WO2012086288A1 PCT/JP2011/072876 JP2011072876W WO2012086288A1 WO 2012086288 A1 WO2012086288 A1 WO 2012086288A1 JP 2011072876 W JP2011072876 W JP 2011072876W WO 2012086288 A1 WO2012086288 A1 WO 2012086288A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- exception
- control
- register
- value
- instruction
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4812—Task transfer initiation or dispatching by interrupt, e.g. masked
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30003—Arrangements for executing specific machine instructions
- G06F9/30076—Arrangements for executing specific machine instructions to perform miscellaneous control operations, e.g. NOP
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/48—Indexing scheme relating to G06F9/48
- G06F2209/481—Exception handling
Definitions
- the present invention relates to exception control, and more particularly, to a method, system, and computer program for program-controlling exceptions.
- CPU exceptions such as runtime errors, TLB (Translation Look-aside Buffer) errors, timer interrupts, etc.
- runtime errors such as runtime errors, TLB (Translation Look-aside Buffer) errors, timer interrupts, etc.
- TLB Translation Look-aside Buffer
- timer interrupts such as timer interrupts, etc.
- the usage and exception conditions are all determined in advance. Conditions cannot be changed flexibly in terms of software, that is, program control cannot be performed. That is, most exceptions are not intentionally generated at the location specified by the programmer.
- conditional branch instruction As a CPU instruction. This reflects the state to be determined as a register value before calling a branch instruction. Whether or not to branch depends on the value. Therefore, a conditional branch instruction requires an operation on a volatile register in advance, and the conditional branch instruction itself is always executed even if it does not branch.
- conditional branch instructions are usually used. That is, a procedure is performed in which some operation is performed by the CPU instruction to update the value of the register, and the jump to the processing code is performed by the conditional branch instruction according to the value.
- FIG. 1 illustrates a conditional branch instruction 10 of a condition that is rarely established according to the prior art.
- task A it is rarely necessary to call the initialization function init () only for the first time and at the time of calling func () after reset (), and init () can only be called from the same process space as task B. .
- init it is necessary to check whether the reset state is performed before performing a certain process, and if so, an initialization process must be performed. The time spent is wasted every time.
- the process for determining whether or not the task B is in the reset state is viewed at the assembler language level shown on the right side, it can be seen that even a slight determination consumes a considerable amount of time due to memory access.
- the rst_f variable is the variable at the address pointed to by the pointer variable of the structure member, that is, the memory is referred to many times, and the conditional expression is if or (A or B or C %) If connected with or, the consumption time will be longer.
- Patent Document 1 scans an exception handling handler registration list registered by an exception handling handler registration means in an exception handling control system that shifts the process to an exception handling procedure indicated by “CALL” or another instruction word. Thus, it is described that the exception processing is transferred to the exception processing handler corresponding to the exception condition identifier directly, thereby speeding up the exception processing by speeding up the propagation to the exception processing.
- a normal processing program and a plurality of exception processing handler programs, as well as the execution state and exception status of a normal processing program that needs to be selected and executed in advance, are coded in advance for each exception processing handler. Prepared for each exception handler and added as information in the program code.
- the execution status of the normal program when the exception is detected and the execution of the normal processing program attached to each exception handler Describes an exception handling mechanism in which the presence or absence of an exception handling handler does not affect the processing amount of a normal processing program by selecting an exception handling handler and performing execution control by comparing with status information .
- JP-A-62-212732 Japanese Patent Laid-Open No. 4-169937 JP 7-44398 A
- the present invention aims to realize an exception that can be controlled by software.
- Objects of the present invention include providing methods, systems and computer programs for programmatic control of exceptions.
- the exceptional program control method includes a processor executing the following steps.
- a step of executing a control designation command for designating an exception control whether or not to enable an exception setting an exception control designation value in a register, and executing an exception control whether or not to generate an exception
- the control designation value set in the register is not a value that enables the exception, a step that does not cause an exception is executed.
- control designation instruction has a bitmap index part and a control designation part
- the register includes a bitmap register
- the step of setting the control designation value is the bitmap specified by the value of the bitmap index part Executing a step of setting a value of the control designating part to a bit of the register.
- control execution instruction has a bitmap index portion, and in the step of generating an exception, the value of the control designation portion set in the bit of the bitmap register specified by the value of the bitmap index portion causes an exception. Including executing an exception-generating step when the value is valid.
- the register includes a return address register
- the step of generating an exception includes executing a step of setting a next address of the control execution instruction in the return address register.
- control execution instruction has a key code part
- the register has a key register
- the step of generating an exception sets the value of the key code part in the key register for use in the exception to be generated Performing the step of performing.
- the register includes a vector base register
- the step of generating an exception includes an exception held in the vector base register associated with the bit of the bitmap register specified by the value of the bitmap index part of the control execution instruction. It includes the step of referring to the address of the handler and jumping to the exception handler at that address.
- the exception is Performing non-occurring steps.
- the step of not generating an exception includes executing a step of discarding the control execution instruction in the instruction queue.
- a computer program for controlling an exception program that causes a processor to execute each step of the above method.
- a processor controls a control designation instruction for designating an exception control whether to enable an exception and a control for executing exception control whether to generate an exception.
- An exception control unit that executes an execution instruction and controls an exception is included.
- the exception control unit executes a register, a control designation instruction, sets a control designation value of the exception in the register, and executes a control execution instruction, and the control designation value set in the register
- a control execution instruction processing unit that determines whether or not the exception is valid, and generates an exception when the specified control value is a value that validates the exception.
- the control execution instruction processing unit does not generate an exception when the control designation value set in the register is not a value that enables the exception.
- control designation instruction has a bitmap index part and a control designation part
- the register includes a bitmap register
- the control designation instruction processing part is stored in the bitmap register specified by the value of the bitmap index part. Set the value of the corresponding control specification part in the bit.
- control execution instruction has a bitmap index section
- control execution instruction processing section has an exception when the value of the control designation section set in the bit of the bitmap register specified by the value of the bitmap index section is an exception. Raise an exception when the value is valid.
- the register includes a return address register, and the control execution instruction processing unit sets the next address of the control execution instruction in the return address register.
- control execution instruction has a key code part
- the register includes a key register
- control execution instruction processing part sets the value of the key code part in the key register for use in the generated exception. To do.
- the register includes a vector base register
- the control execution instruction processing unit includes an exception held in the vector base register associated with the bit of the bitmap register specified by the value of the bitmap index part of the control execution instruction. Refers to the handler address and jumps to the exception handler at that address.
- control execution instruction processing unit outputs an exception when the value of the control designation unit set in the bit of the bitmap register specified by the value of the bitmap index part of the control execution instruction is not a value that enables the exception. Do not generate.
- an exception that cannot be generated or controlled by software is realized, and a method, a system, and a computer program for program-controlling the exception are provided.
- the occurrence of an exception can be controlled flexibly, that is, at a place set by a program, unnecessary processing operations by the CPU can be suppressed, and the processing efficiency of the CPU can be improved.
- FIG. 1 is a schematic configuration diagram of two types of CPU instructions newly provided for realizing software-controllable exceptions, a bitmap register indexed by the CPU instructions, and three types of registers corresponding to each exception in an embodiment of the present invention.
- FIG. 1 is a block diagram schematically showing a processor having an exception program control system according to an embodiment of the present invention.
- FIG. It is a flowchart figure which shows schematically the exception program control method which concerns on one Embodiment of this invention. It is the schematic of the example of a program produced in order to implement the exception program control method concerning one Embodiment of this invention.
- FIG. 2 shows two types of CPU instructions newly provided for realizing software-controllable exceptions in one embodiment of the present invention, a bitmap register indexed to the CPU instructions, and three types corresponding to each exception.
- 1 shows a schematic configuration of the register.
- the control designation instruction 11 indicated as one of the expand instructions is provided to enable or disable (invalidate) exceptions, that is, to specify exception control.
- the control execution instruction 12 indicated as the other expc instruction is provided to cause an exception not to be generated according to the exception validity / invalidity condition, that is, to execute the exception control.
- a bitmap register 20 indicated as a BM register is provided to define conditions for occurrence of an exception by being indexed by two types of CPU instructions.
- a plurality of vector base registers 21 indicated as VEC registers respectively hold exception handler addresses addr for handling exceptions generated by two types of CPU instructions, Support startup.
- a return address register 22 indicated as a RET register holds a return address raddr next to the CPU instruction in which the exception has occurred, and supports return from exception processing by the CPU.
- Each of the key registers 23 indicated as the KEY register holds a value kc designated by the program when the exception occurs, for example, the KC value of the expc instruction, and supports use in exception processing by the CPU.
- the number of VEC registers 21 corresponding to the number of exceptions processed by two types of CPU instructions is provided. In FIG. 2, 256 VEC registers 21 are provided.
- one RET register 22 and one KEY register 23 are provided as long as they can handle two types of CPU instructions.
- the control instruction 11 is shown in a 32-bit configuration, but is not limited to a 32-bit configuration.
- the opcode part written as OP of bits 0 to 5 indicates that this CPU instruction is an instruction that does not enable (invalidate) an exception or designates exception control.
- a bitmap index portion labeled BM of bits 8 to 15 indicates an index to the 256-bit BM register 20 provided for determining whether or not to generate an exception for each of 256 ways that can be represented by 8 bits. For example, if all the bits 8 to 15 of the BM are 0, the first bit of the BM register 20 is indicated, and if all the bits 8 to 15 of the BM are 1, the last 256 bits of the BM register 20 are indicated.
- the control specification part marked as EN in bit 31 does not enable (disable) the exception, that is, when EN is 1, the exception is enabled, and when EN is 0, the exception is enabled. Indicates a value that is not to be set (disabled).
- the EN value can be reversed so that the exception is enabled when EN is 0 and is not enabled (disabled) when EN is 1.
- the control execution instruction 12 is also shown in a 32-bit configuration, but is not limited to a 32-bit configuration.
- the opcode portion labeled OP of bits 0 to 5 indicates that this CPU instruction is an instruction that does not cause an exception or executes an exception control.
- the bitmap index part indicated as BM of bits 8 to 15 is provided with 256 bits for determining whether or not to generate an exception for each of 256 ways represented by 8 bits, as in the case of the control designation instruction 11.
- the key code part written as KC in bits 16 to 31 is a data field that is set and used in the program, and the value of KC is stored in the KEY register 23.
- kc Since the value of kc can be freely set by a program, not only does not cause an exception, but also the processing of the exception handler itself can be flexibly controlled.
- the processing by the exception handler When the processing by the exception handler is completed, it is possible to return to the processing immediately after the occurrence of the exception by referring to the return address raddr stored in the RET register 22 using a CPU instruction for returning from the exception provided by the CPU architecture. it can.
- FIG. 3 is a block diagram schematically showing a processor 100 having an exceptional program control system according to an embodiment of the present invention.
- the processor 100 includes a cache 110 and an MMU (Memory Management Unit) 120, and the MMU 120 includes a TLB 125.
- the processor 100 is provided with an exception control unit 135 that newly controls an exception.
- the exception control unit 135 is provided in the control designation instruction processing unit 30 that processes the control designation instruction 11 provided in the program and also in the program.
- a control execution instruction processing unit 40 for processing the control execution instruction 12 to be executed.
- the control designation command processing unit 30 includes a BM processing unit 31 and an EN processing unit 32.
- the BM processing unit 31 acquires a value designated by the BM from the control designation instruction 11 and specifies a bit of the BM register 20 that is associated with, or indexed to, the value.
- the EN processing unit 32 acquires the value specified by EN from the control specifying instruction 11 and sets the value to the bit of the BM register 20 specified by the BM processing unit 31.
- the control execution command processing unit 40 includes a BM processing unit 41, an EN determination unit 42, and a KC processing unit 43.
- the BM processing unit 41 acquires a value specified by the BM of the control execution instruction 12 and specifies a bit of the BM register 20 that is associated with the value, that is, indexed.
- the EN determination unit 42 determines the value of EN set in the bit of the BM register 20 specified by the BM processing unit 41. When EN is 0 that does not enable (invalidate) an exception, control execution is performed.
- the instruction processing unit 40 ends the process. Therefore, the exception processing is not executed, and the control execution instruction 12 is removed from the instruction queue 140.
- the control execution instruction processing unit 40 refers to the address addr of the VEC register 21 associated with the bit of the BM register 20 specified by the BM processing unit 41, and performs branch processing.
- the unit 130 jumps to the exception handler at the address addr and executes exception processing.
- the control execution instruction processing unit 40 adds the address obtained by adding 4 to the address of the control execution instruction 12 to the address of the control execution instruction 12, for example, to the RET register 22 as a return address raddr for return from exception processing. set.
- the exception control unit 135 provides the return address raddr to the branch processing unit 130.
- the KC processing unit 43 stores the KC value of the control execution instruction 12 in the KEY register 23.
- the exception control unit 135 provides the value of kc stored in the KEY register 23 to the exception handler, and the exception handler performs processing according to the value of kc.
- FIG. 4 is a flowchart (200) schematically showing the exceptional program control method according to the embodiment of the present invention.
- This method can be implemented in a processor 100 in which exceptions as shown in FIG. 3 are controlled by software.
- the processor 100 starts when the control designation instruction 11 is provided to the instruction queue 140 (step 201).
- the processor 100 acquires BM and EN from the control designation instruction 11 (step 202), sets the value of EN to the bit of the BM register 20 specified by BM (step 203), and ends (step 204).
- the processor 100 starts when the control execution instruction 12 is provided to the instruction queue 140 (step 205).
- the processor 100 acquires BM and KC from the control execution instruction 12 (step 206), and determines whether or not the value of EN in the bit of the BM register 20 specified by BM is 1 (step 207). When the determination is “No”, that is, when the value of EN is not 1, the control execution instruction 12 is not executed and discarded in the instruction queue 140 (step 208). When the determination is “Yes”, that is, when the value of EN is 1, the processor 100 sets the next address obtained by adding 4 to the address of the control execution instruction 12 in the 32-bit RISC CPU as the return address raddr, It is set in the RET register 22 (step 209). Further, the processor 100 sets KC in the KEY register 23 as kc (step 210).
- the processor 100 refers to the address addr of the VEC register 21 associated with the bit of the BM register 20 specified by the BM, and jumps to the exception handler of the address addr by the branch processing unit 130, that is, shifts execution. (Step 211).
- FIG. 5 schematically shows an example program 50 created to implement the exceptional program control method according to one embodiment of the present invention.
- the program 50 is provided with an expc instruction for the control execution instruction 12.
- the expc instruction of the control designation instruction 11 is designated to enable an exception
- execution of the expc instruction moves to the exception handler that handles the exception.
- the expc instruction is followed by the expc instruction. Execution returns.
- the expc instruction of the control designation instruction 11 is designated not to enable (invalidate) the exception, the expc instruction is passed without doing anything and execution proceeds to the next instruction.
- FIG. 6 schematically shows another example program 60 created to implement the exceptional program control method according to one embodiment of the present invention.
- the program 60 corresponds to the program shown in FIG.
- the if statement in task B is no longer necessary and has not been initialized in the initial state (uninitialized), so the function that initializes the exception with the expenexp20 and 1 instructions of the control specification instruction 11 is called first. It is.
- the control execution instruction 12 expc 20 is provided, and in most cases, this instruction is discarded in the instruction queue without consuming a CPU cycle. It is executed as an instruction to jump to the exception handler only when is valid.
- the second operand 512 of the expc 20, 512 instruction is used to identify in what condition or purpose the caller caused an exception in the called program. Here, it is used to specify the function number 512, and the initialization function init () is called. In the exception handler, since it is initialized (initialized) behind the initialization function, it is specified to invalidate the exception by the “expen 20,0” instruction of the control specifying instruction 11. In this manner, an exception interrupt can be generated only in the reset state and the initialization process can be performed without executing the code for the confirmation process in the prior art.
- FIG. 7 schematically shows still another example of a program 70 created to implement the exceptional program control method according to one embodiment of the present invention.
- This is an example in which an arbitrary software object is allocated by generalizing demand paging for allocating memory when necessary.
- the expc exp1, 0 instruction of the control execution instruction 12 is provided immediately after start :, and an exception is generated in the first execution, and a necessary object, for example, a memory heap is instantiated and initialized.
- the memory heap has already been materialized (the exception is invalidated by the expen instruction of the control designation instruction 11), so no exception occurs.
- This example relates to the memory heap.
- synchronization objects such as semaphores and mutexes can be allocated and initialized as necessary.
- FIG. 8 schematically shows still another example of a program 80 created to implement the exceptional program control method according to one embodiment of the present invention.
- This is an example of a generalized code protection mechanism that protects code from unauthorized code execution.
- an exception interrupt is generated for an access violation that executes a privileged mode code in the non-privileged mode, but this can only protect the code in units of memory pages.
- the control execution instruction 12 can be provided at a necessary place to generate a pinpoint exception, and a part of the code can be a protection area when a certain condition is satisfied, that is, in an arbitrary code unit. Can handle exceptions for illegal execution.
- the expand instruction and the BM register are expanded and associated with the privileged mode and the non-privileged mode, the state is kept separately, or an attribute such as whether or not it is readable can be separately registered. It is necessary to hold in.
- an arbitrary condition is defined as an access violation in a program to enable or disable the occurrence of an exception.
- exceptional program control method can be implemented in various ways. For example, tracing program execution for debugging purposes.
- An expc instruction of the control execution instruction 12 is provided at a place where the program is to be traced, and a log code is described in the exception handler.
- an exception is validated by the expand instruction of the control designation instruction 11, and the execution of the program is traced by the provided expc instruction.
- an expc command is provided in the task on the receiving side, and the expen command is executed on the transmitting side.
- the expc instruction provided in the execution starts the exception handler, the receiving side knows that the message has been sent.
- system call a system call that is executed only when a condition is satisfied can be realized.
- a read system call that executes a system call only when it is in an open state can be created using the present invention.
- Various applications are possible depending on the program.
- the expc instruction of the control designation instruction 11 and the expc instruction of the control execution instruction 12 provided in the program when no exception occurs, the expc instruction has a dependency relationship with other CPU instructions via the register file in addition to the expen instruction. Since there is nothing, the expc instruction may be deleted from the instruction queue before reaching the execution stage in the instruction pipeline. In this case, the CPU instruction can be executed without consuming extra CPU cycles as compared with the case where the expc instruction is not provided. In the case of a conditional branch instruction, it is not possible to determine whether or not to branch until the execution of the instruction that updates the condition register is completed. On the other hand, since the expc instruction has no dependency on such a register, if there is no expen instruction immediately before, it can be determined immediately after being read into the instruction queue whether or not an exception is generated.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Executing Machine-Instructions (AREA)
- Advance Control (AREA)
Abstract
Description
本発明は、例外の制御に関し、特に、例外をプログラム制御する方法、システムおよびコンピュータプログラムに関する。 The present invention relates to exception control, and more particularly, to a method, system, and computer program for program-controlling exceptions.
現在のCPUでは、CPU命令の実行に際して、ハードウエア的なエラーが生じたりアクセス違反などが生じたりした場合には、CPU例外が起きるようになっている。CPU例外が起きると、割り込みが発生し、指定されたアドレスの例外処理コードを実行するようになっている。例外処理が完了すると、例外が起きたCPU命令の位置に戻って実行を再開する。ただし、致命的なエラーや特殊な場合は、例外が起きた位置に戻らないこともある。 In the current CPU, when a hardware error occurs or an access violation occurs during execution of a CPU instruction, a CPU exception occurs. When a CPU exception occurs, an interrupt occurs and the exception handling code at the specified address is executed. When the exception processing is completed, execution returns to the position of the CPU instruction where the exception occurred. However, in the case of a fatal error or special case, it may not return to the position where the exception occurred.
CPU例外の種類としては、実行時エラー、TLB(Translation Look-aside Buffer:変換索引バッファ)ミス、タイマー割り込みなど様々なものが考えられるが、いずれも用途や例外の発生条件があらかじめ決まっていて、ソフトウエア的に柔軟に条件を変える、即ち、プログラム制御することはできない。即ち、ほとんどの例外はプログラマが指定した位置で意図的に発生するようにはなっていない。 There are various types of CPU exceptions, such as runtime errors, TLB (Translation Look-aside Buffer) errors, timer interrupts, etc., but the usage and exception conditions are all determined in advance. Conditions cannot be changed flexibly in terms of software, that is, program control cannot be performed. That is, most exceptions are not intentionally generated at the location specified by the programmer.
非特権モードのコードから特権モードのコードを呼び出すために使用されるシステムコールや、例えば、2つのレジスタの値の比較によって例外を発生させるかどうかを判定するPowerPC(PowerPCはIBM社の登録商標)のトラップ命令(tw命令)は、指定した位置で例外を起こせる。しかしながら、システムコールの場合は、それによって必ず例外が発生し、例外を無効にすることはできないし、前記のトラップ命令の場合は、実行前に2つのレジスタの値を取得する処理と実行時のレジスタの比較判定処理が必要である。 System call used to call privileged mode code from non-privileged mode code, or PowerPC that determines whether an exception is generated by comparing the values of two registers, for example (PowerPC is a registered trademark of IBM Corporation) The trap command (tw command) can raise an exception at the specified position. However, in the case of a system call, an exception always occurs, and the exception cannot be invalidated. In the case of the trap instruction described above, processing for obtaining the values of two registers before execution and execution A register comparison / determination process is required.
その他には、CPU命令として条件分岐命令がある。これは、分岐命令を呼び出す前に判定対象となる状態をレジスタの値として反映させておく。そして、その値により分岐するかどうかが決まる。したがって、条件分岐命令は前もって揮発性のレジスタに対する操作が必要であり、かつ、たとえ分岐しなくても条件分岐命令自体は必ず実行されるようになっている。 Besides, there is a conditional branch instruction as a CPU instruction. This reflects the state to be determined as a register value before calling a branch instruction. Whether or not to branch depends on the value. Therefore, a conditional branch instruction requires an operation on a volatile register in advance, and the conditional branch instruction itself is always executed even if it does not branch.
コンピュータプログラムにおいては、ある条件を満たす時にだけ特別な処理をさせたいことが良くあるが、その場合、通常は条件分岐命令を使用する。即ち、CPU命令で何らかの操作を行ってレジスタの値を更新し、その値に応じて条件分岐命令で処理コードにジャンプするという手順を踏む。しかし、ごく稀にしか成立しない条件を毎回ソフトウエア的に確認するのは効率が悪い。 In computer programs, it is often desirable to perform special processing only when certain conditions are met. In that case, conditional branch instructions are usually used. That is, a procedure is performed in which some operation is performed by the CPU instruction to update the value of the register, and the jump to the processing code is performed by the conditional branch instruction according to the value. However, it is inefficient to check the condition that is met only rarely by software.
図1に、従来技術によるごく稀にしか成立しない条件の条件分岐命令10を例示する。タスクAでは、初回とreset()後のfunc()呼び出し時だけのごく稀に初期化関数init()の呼び出しが必要であり、init()はタスクBと同じプロセス空間からしか呼べないとする。このように、ある処理を行う前にリセット状態かどうかを確認して、そうであれば初期化処理をしなければならないが、リセット状態であることがほとんど無いとすると、この確認処理のために費やす時間は毎回無駄になる。特に、タスクBでのリセット状態かどうかを判定する処理を右側に示されたアセンブラ言語レベルで見ると、ちょっとした判定にも、メモリアクセスが発生したりして結構時間を消費することが分かる。例えば、rst_f変数が構造体メンバのポインタ変数が指すアドレス先の変数であったり、即ちメモリを何度も参照したり、条件式がif (A or B or C...)のようにandやorで繋がっていると、消費する時間はさらに長くなる。
FIG. 1 illustrates a
特許文献1には、「CALL」その他の命令語により指示される例外処理手続きへその処理を移行する例外処理の制御方式において、例外処理ハンドラ登録手段により登録された例外処理ハンドラ登録リストを走査して、例外条件識別名に対応する例外処理ハンドラに直接例外処理の制御を移行することにより、例外処理への伝播を早めて例外処理を高速化することが、記載されている。
特許文献2には、命令メモリ以外の領域に割り込み要因ごとに割り込みアドレスを設定するアドレス設定手段と、割り込み検出回路により検出された要因を選択信号として、アドレス設定手段の出力をプログラム・カウンタに入力するマルチプレクサとを設けることにより、分岐命令に要するプログラム・メモリの消費を抑制し、またプログラム・メモリの無効空間を削除して、プログラム・メモリの効率化を図り、かつ割り込み処理時間を短縮することができるマイクロ・プロセッサが、記載されている。
In
特許文献3には、通常処理プログラムおよび複数の例外処理ハンドラのプログラムと共に、各例外処理ハンドラが選択されて実行する必要のある通常処理プログラムの実行状態と例外状況を予めコード化して例外処理ハンドラ毎に用意し、各例外処理ハンドラと結合してプログラムコード中の情報として付加しておき、例外検出時に、例外検出時の通常プログラムの実行状態と各例外処理ハンドラに付加された通常処理プログラムの実行状態の情報とを比較することにより、例外処理ハンドラを選択し、実行制御を行うことで、例外処理ハンドラの有無が通常処理プログラムの処理量に影響を与えない例外処理機構が、記載されている。
In
これまでは、予め設定されれば、例外は必ず発生し、条件分岐命令自体は必ず実行されるようになっている。即ち、例外を発生させたりさせなかったり、また、条件分岐命令自体を実行させたりさせなかったりする、ソフトウエア的にそれらを制御することはなされておらず、実際には必要のない処理動作もプログラムにより行われている。 So far, if preset, exceptions always occur and conditional branch instructions themselves are always executed. In other words, no exceptions are generated or conditional branch instructions themselves are not executed, and they are not controlled by software, and processing operations that are not actually required are also performed. It is done by the program.
本発明は、ソフトウエア的に制御できる例外の実現を目的とする。本発明の目的には、例外をプログラム制御する方法、システムおよびコンピュータプログラムを提供することが含まれる。 The present invention aims to realize an exception that can be controlled by software. Objects of the present invention include providing methods, systems and computer programs for programmatic control of exceptions.
本発明による1実施態様の例外プログラム制御方法は、プロセッサが次のステップを実行することを含む。即ち、例外を有効にするか否かの例外制御指定のための制御指定命令を実行して、レジスタに例外の制御指定値を設定するステップと、例外を発生させるか否かの例外制御実行のための制御実行命令を実行して、レジスタに設定された制御指定値が例外を有効にする値か否かを判定し、制御指定値が例外を有効にする値のときは例外を発生させるステップである。また、レジスタに設定された制御指定値が例外を有効にする値でないときには例外を発生させないステップを実行することを含む。 The exceptional program control method according to an embodiment of the present invention includes a processor executing the following steps. In other words, a step of executing a control designation command for designating an exception control whether or not to enable an exception, setting an exception control designation value in a register, and executing an exception control whether or not to generate an exception A control execution instruction for determining whether or not the specified control value set in the register is a value that enables the exception, and generating an exception if the specified control value is a value that enables the exception It is. In addition, when the control designation value set in the register is not a value that enables the exception, a step that does not cause an exception is executed.
好ましくは、制御指定命令はビットマップインデックス部および制御指定部を有し、レジスタはビットマップレジスタを備え、制御指定値を設定するステップは、当該ビットマップインデックス部の値で特定される当該ビットマップレジスタのビットに当該制御指定部の値を設定するステップを実行することを含む。 Preferably, the control designation instruction has a bitmap index part and a control designation part, the register includes a bitmap register, and the step of setting the control designation value is the bitmap specified by the value of the bitmap index part Executing a step of setting a value of the control designating part to a bit of the register.
好ましくは、制御実行命令はビットマップインデックス部を有し、例外を発生させるステップは、当該ビットマップインデックス部の値で特定されるビットマップレジスタのビットに設定された制御指定部の値が例外を有効にする値のときに、例外を発生させるステップを実行することを含む。 Preferably, the control execution instruction has a bitmap index portion, and in the step of generating an exception, the value of the control designation portion set in the bit of the bitmap register specified by the value of the bitmap index portion causes an exception. Including executing an exception-generating step when the value is valid.
好ましくは、レジスタはリターンアドレスレジスタを備え、例外を発生させるステップは、制御実行命令の次のアドレスを、当該リターンアドレスレジスタに設定するステップを実行することを含む。 Preferably, the register includes a return address register, and the step of generating an exception includes executing a step of setting a next address of the control execution instruction in the return address register.
好ましくは、制御実行命令はキーコード部を有し、レジスタはキーレジスタを備え、例外を発生させるステップは、当該キーコード部の値を、発生させる例外での使用のため、当該キーレジスタに設定するステップを実行することを含む。 Preferably, the control execution instruction has a key code part, the register has a key register, and the step of generating an exception sets the value of the key code part in the key register for use in the exception to be generated Performing the step of performing.
好ましくは、レジスタはベクタベースレジスタを備え、例外を発生させるステップは、制御実行命令のビットマップインデックス部の値で特定されるビットマップレジスタのビットに対応付けられた当該ベクタベースレジスタに保持する例外ハンドラのアドレスを参照し、当該アドレスの例外ハンドラにジャンプするステップを実行することを含む。 Preferably, the register includes a vector base register, and the step of generating an exception includes an exception held in the vector base register associated with the bit of the bitmap register specified by the value of the bitmap index part of the control execution instruction. It includes the step of referring to the address of the handler and jumping to the exception handler at that address.
好ましくは、例外を発生させないステップは、制御実行命令のビットマップインデックス部の値で特定されるビットマップレジスタのビットに設定された制御指定部の値が例外を有効にする値でないときには、例外を発生させないステップを実行することを含む。また、例外を発生させないステップは、制御実行命令を命令キューの中で破棄するステップを実行することを含む。 Preferably, in the step of not generating an exception, when the value of the control designation part set to the bit of the bitmap register specified by the value of the bitmap index part of the control execution instruction is not a value that enables the exception, the exception is Performing non-occurring steps. The step of not generating an exception includes executing a step of discarding the control execution instruction in the instruction queue.
本発明の1実施態様により、プロセッサに上記方法の各ステップを実行させる例外プログラム制御のためのコンピュータプログラムが提供される。 According to one embodiment of the present invention, there is provided a computer program for controlling an exception program that causes a processor to execute each step of the above method.
本発明による1実施態様の例外プログラム制御システムでは、プロセッサは、例外を有効にするか否かの例外制御指定のための制御指定命令と例外を発生させるか否かの例外制御実行のための制御実行命令とを実行して例外を制御する例外制御部を含む。例外制御部は、レジスタと、制御指定命令を実行して、レジスタに例外の制御指定値を設定する制御指定命令処理部と、制御実行命令を実行して、レジスタに設定された制御指定値が例外を有効にする値か否かを判定し、制御指定値が例外を有効にする値のときは例外を発生させる制御実行命令処理部とを含む。制御実行命令処理部は、レジスタに設定された制御指定値が例外を有効にする値でないときには例外を発生させない。 In an exception program control system according to an embodiment of the present invention, a processor controls a control designation instruction for designating an exception control whether to enable an exception and a control for executing exception control whether to generate an exception. An exception control unit that executes an execution instruction and controls an exception is included. The exception control unit executes a register, a control designation instruction, sets a control designation value of the exception in the register, and executes a control execution instruction, and the control designation value set in the register A control execution instruction processing unit that determines whether or not the exception is valid, and generates an exception when the specified control value is a value that validates the exception. The control execution instruction processing unit does not generate an exception when the control designation value set in the register is not a value that enables the exception.
好ましくは、制御指定命令はビットマップインデックス部および制御指定部を有し、レジスタはビットマップレジスタを含み、制御指定命令処理部は、当該ビットマップインデックス部の値で特定される当該ビットマップレジスタのビットに当該制御指定部の値を設定する。 Preferably, the control designation instruction has a bitmap index part and a control designation part, the register includes a bitmap register, and the control designation instruction processing part is stored in the bitmap register specified by the value of the bitmap index part. Set the value of the corresponding control specification part in the bit.
好ましくは、制御実行命令はビットマップインデックス部を有し、制御実行命令処理部は、当該ビットマップインデックス部の値で特定されるビットマップレジスタのビットに設定された制御指定部の値が例外を有効にする値のときに、例外を発生させる。 Preferably, the control execution instruction has a bitmap index section, and the control execution instruction processing section has an exception when the value of the control designation section set in the bit of the bitmap register specified by the value of the bitmap index section is an exception. Raise an exception when the value is valid.
好ましくは、レジスタはリターンアドレスレジスタを含み、制御実行命令処理部は、制御実行命令の次のアドレスを、当該リターンアドレスレジスタに設定する。 Preferably, the register includes a return address register, and the control execution instruction processing unit sets the next address of the control execution instruction in the return address register.
好ましくは、制御実行命令はキーコード部を有し、レジスタはキーレジスタを含み、制御実行命令処理部は、当該キーコード部の値を、発生させる例外での使用のため、当該キーレジスタに設定する。 Preferably, the control execution instruction has a key code part, the register includes a key register, and the control execution instruction processing part sets the value of the key code part in the key register for use in the generated exception. To do.
好ましくは、レジスタはベクタベースレジスタを含み、制御実行命令処理部は、制御実行命令のビットマップインデックス部の値で特定されるビットマップレジスタのビットに対応付けられた当該ベクタベースレジスタに保持する例外ハンドラのアドレスを参照し、当該アドレスの例外ハンドラにジャンプする。 Preferably, the register includes a vector base register, and the control execution instruction processing unit includes an exception held in the vector base register associated with the bit of the bitmap register specified by the value of the bitmap index part of the control execution instruction. Refers to the handler address and jumps to the exception handler at that address.
好ましくは、制御実行命令処理部は、制御実行命令のビットマップインデックス部の値で特定されるビットマップレジスタのビットに設定された制御指定部の値が例外を有効にする値でないときには、例外を発生させない。 Preferably, the control execution instruction processing unit outputs an exception when the value of the control designation unit set in the bit of the bitmap register specified by the value of the bitmap index part of the control execution instruction is not a value that enables the exception. Do not generate.
本発明により、発生させたりさせなかったりソフトウエア的に制御できる例外が実現され、例外をプログラム制御する方法、システムおよびコンピュータプログラムが提供される。特に、柔軟に、即ちプログラムで設定した箇所で例外の発生を制御して、CPUによる不要な処理動作を抑え、CPUの処理効率を向上させることができる。 According to the present invention, an exception that cannot be generated or controlled by software is realized, and a method, a system, and a computer program for program-controlling the exception are provided. In particular, the occurrence of an exception can be controlled flexibly, that is, at a place set by a program, unnecessary processing operations by the CPU can be suppressed, and the processing efficiency of the CPU can be improved.
以下、本発明を実施するための最良の形態を図面に基づいて詳細に説明するが、以下の実施形態は特許請求の範囲に係る発明を限定するものではなく、また実施形態の中で説明されている特徴の組み合わせの全てが発明の解決手段に必須であるとは限らない。本発明は多くの異なる態様で実施することが可能であり、記載された実施形態の内容に限定して解釈されるべきではない。なお、実施形態の説明の全体を通じて同じ構成部分乃至構成要素には同じ番号を付している。 BEST MODE FOR CARRYING OUT THE INVENTION Hereinafter, the best mode for carrying out the present invention will be described in detail with reference to the drawings. However, the following embodiments do not limit the invention according to the claims, and are described in the embodiments. Not all combinations of features that are present are essential to the solution of the invention. The present invention may be implemented in many different ways and should not be construed as limited to the details of the described embodiments. Note that the same reference numerals are given to the same components or components throughout the description of the embodiment.
まず、図2に、本発明の1実施形態においてソフトウエア制御可能な例外実現のため新たに設けられる2種類のCPU命令および当該CPU命令にインデックスされるビットマップレジスタ並びに各例外に対応する3種類のレジスタの概略構成を示す。2種類のCPU命令のうち、一方のexpen命令と示された制御指定命令11は、例外を有効にしたりしなかったり(無効にしたり)する、即ち例外の制御を指定するために設けられる。もう一方のexpc命令と示された制御実行命令12は、例外の有効・無効の条件に応じて例外を発生させたりさせなかったりする、即ち例外の制御を実行するために設けられる。BMレジスタと示されたビットマップレジスタ20は、2種類のCPU命令にインデックスされて例外発生の条件を規定するために設けられる。
First, FIG. 2 shows two types of CPU instructions newly provided for realizing software-controllable exceptions in one embodiment of the present invention, a bitmap register indexed to the CPU instructions, and three types corresponding to each exception. 1 shows a schematic configuration of the register. Of the two types of CPU instructions, the
3種類のレジスタのうち、VECレジスタと示された複数のベクタベースレジスタ21は、それぞれ、2種類のCPU命令によって発生される例外を処理する例外ハンドラのアドレスaddrを保持し、CPUによる例外ハンドラの起動をサポートする。RETレジスタと示されたリターンアドレスレジスタ22は、それぞれ、その例外が発生したCPU命令の次のリターンアドレスraddrを保持し、CPUによる例外処理からの復帰をサポートする。KEYレジスタと示されたキーレジスタ23は、それぞれ、その例外が発生した時にプログラム指定した値kc、例えばexpc命令のKCの値を保持し、CPUによる例外処理での使用をサポートする。VECレジスタ21は、2種類のCPU命令で処理する例外の数に対応した数分が設けられる。図2では、VECレジスタ21は、256個設けられている。一方、2種類のCPU命令に対応できれば良いRETレジスタ22およびKEYレジスタ23は、それぞれ1個設けられている。
Of the three types of registers, a plurality of vector base registers 21 indicated as VEC registers respectively hold exception handler addresses addr for handling exceptions generated by two types of CPU instructions, Support startup. A
制御指定命令11は、32ビット構成で示されているが、32ビット構成に限定されない。ビット0~5のOPと記されたオペコード部は、このCPU命令が例外を有効にしたりしなかったり(無効にしたり)、例外の制御を指定する命令であることを示す。ビット8~15のBMと記されたビットマップインデックス部は、8ビットで表せる256通りのそれぞれについて例外を発生させるかどうかを判定するために設けられる256ビットのBMレジスタ20へのインデックスを示す。例えば、BMのビット8~15がすべて0であればBMレジスタ20の最初の1ビット目を指し、BMのビット8~15がすべて1であればBMレジスタ20の最後の256ビット目を指す。ビット31のENと記された制御指定部は、例外を有効にしたりしなかったり(無効にしたり)する、即ち、ENが1のときは例外を有効にし、ENが0のときは例外を有効にしない(無効にする)値を示す。もちろん、ENが0のときに例外を有効にし、ENが1のときに例外を有効にしない(無効にする)ように、ENの値を反対にすることもできる。このENの値は、BMで指定される値に対応付けられる、即ちインデックスされるBMレジスタ20のビットに設定される。例えば、この命令の実行例であるexpen 20, 1は、BM=20およびEN=1であるので、BMレジスタ20の21ビット目に例外を有効にするEN=1をセットする。
The
制御実行命令12も、32ビット構成で示されているが、32ビット構成に限定されない。ビット0~5のOPと記されたオペコード部は、このCPU命令が例外を発生させたりさせなかったり、例外の制御を実行する命令であることを示す。ビット8~15のBMと記されたビットマップインデックス部は、制御指定命令11と同様に、8ビットで表せる256通りのそれぞれについて例外を発生させるかどうかを判定するために設けられている256ビットのBMレジスタ20へのインデックスを示す。BMレジスタ20のインデックスされたビットにEN=1が制御指定命令11のexpen命令によりセットされて例外を発生させるときには、BMレジスタ20におけるそのインデックスされたビットに対応付けられたVECレジスタ21のアドレスaddrが参照され、そこに指定される例外ハンドラのアドレスaddrにジャンプして例外処理が実行される。また、例外処理からの復帰のために、この命令の次のアドレスが、リターンアドレスraddrとして、RETレジスタ22にセットされる。ビット16~31のKCと記されたキーコード部は、プログラムでセットして使用するデータフィールドであり、KCの値は、KEYレジスタ23に保存される。
The
例えば、この命令の実行例であるexpc 20, 512は、BM=20およびKC=512であるので、BMレジスタ20の21ビット目を参照する。そこがEN=0になっていれば何もしない。そこがEN=1になっていれば例外を発生する。特に、例外ハンドラへ実行を移すために、21番目のVECレジスタ21が指定する例外ハンドラのアドレスaddrにジャンプする。また、RETレジスタ22にこのexpc命令の次のアドレス、即ちリターンアドレスraddrをセットする。さらに、KEYレジスタ23のビット16~31に512をkc値としてセットする。指定された例外ハンドラではkcの値512に応じた処理を行う。kcの値はプログラムで自由に設定できるので、例外を発生させたりさせなかったりするばかりでなく、例外ハンドラの処理自体も柔軟に制御することができる。例外ハンドラによる処理が完了すると、CPUアーキテクチャが提供する例外から復帰するためのCPU命令を用いて、RETレジスタ22に保存されたリターンアドレスraddrを参照することにより、例外発生直後の処理に戻ることができる。
For example,
図3は、本発明の1実施形態に係る例外プログラム制御システムを有するプロセッサ100を概略的に示すブロック図である。プロセッサ100は、キャッシュ110およびMMU(Memory Management Unit:メモリ管理ユニット)120を有し、MMU120はTLB125を備える。プロセッサ100には、分岐処理のための分岐処理部130および命令格納のための命令キュー140の外に、新たに例外をプログラム制御する例外制御部135が提供される。例外制御部135は、BMレジスタ20、VECレジスタ21、RETレジスタ22およびKEYレジスタ23を含むレジスタに加えて、プログラムに設けられる制御指定命令11を処理する制御指定命令処理部30および同じくプログラムに設けられる制御実行命令12を処理する制御実行命令処理部40を含む。
FIG. 3 is a block diagram schematically showing a processor 100 having an exceptional program control system according to an embodiment of the present invention. The processor 100 includes a
制御指定命令処理部30はBM処理部31およびEN処理部32を有する。BM処理部31は、制御指定命令11よりBMで指定される値を取得し、その値に対応付けられる、即ちインデックスされるBMレジスタ20のビットを特定する。EN処理部32は、制御指定命令11よりENで指定される値を取得し、その値をBM処理部31により特定されるBMレジスタ20のビットに設定する。
The control designation
制御実行命令処理部40はBM処理部41、EN判定部42およびKC処理部43を有する。BM処理部41は、制御実行命令12のBMで指定される値を取得し、その値に対応付けられる、即ちインデックスされるBMレジスタ20のビットを特定する。EN判定部42は、BM処理部41により特定されるBMレジスタ20のビットに設定されているENの値を判定し、ENが例外を有効にしない(無効にする)0であるときには、制御実行命令処理部40は処理を終了する。したがって、例外処理は実行されず、命令キュー140から制御実行命令12が取り除かれる。ENが例外を有効にする1であるときには、制御実行命令処理部40は、BM処理部41により特定されるBMレジスタ20のビットに対応付けられたVECレジスタ21のアドレスaddrを参照し、分岐処理部130によりそのアドレスaddrの例外ハンドラにジャンプして例外処理が実行される。また、制御実行命令処理部40は、例外処理からの復帰のために、制御実行命令12のアドレスに例えば32ビットのRISC CPUでは4を加算した次のアドレスをリターンアドレスraddrとして、RETレジスタ22にセットする。例外処理から復帰するときに、そのリターンアドレスraddrを例外制御部135は分岐処理部130へ提供する。さらに、制御実行命令処理部40では、KC処理部43が、制御実行命令12のKCの値をKEYレジスタ23に保存する。KEYレジスタ23に保存したkcの値を例外制御部135は例外ハンドラに提供して、例外ハンドラではkcの値に応じた処理が行われる。
The control execution
図4は、本発明の1実施形態に係る例外プログラム制御方法を概略的に示すフローチャート(200)図である。この方法は、図3に示されたような例外がソフトウエアにより制御されるプロセッサ100で実施できる。プロセッサ100において、制御指定命令11が命令キュー140に提供されると開始する(ステップ201)。プロセッサ100は、制御指定命令11よりBMおよびENを取得し(ステップ202)、BMで特定されるBMレジスタ20のビットにENの値を設定し(ステップ203)、終了する(ステップ204)。また、プロセッサ100において、制御実行命令12が命令キュー140に提供されると開始する(ステップ205)。プロセッサ100は、制御実行命令12よりBMおよびKCを取得し(ステップ206)、BMで特定されるBMレジスタ20のビットにあるENの値が1か否かを判定する(ステップ207)。判定が「いいえ」の場合、即ち、そのENの値が1でないとき、制御実行命令12は実行されず、命令キュー140の中で破棄される(ステップ208)。判定が「はい」の場合、即ち、そのENの値が1のとき、プロセッサ100は、制御実行命令12のアドレスに例えば32ビットのRISC CPUでは4を加算した次のアドレスをリターンアドレスraddrとして、RETレジスタ22にセットする(ステップ209)。また、プロセッサ100は、KCをKEYレジスタ23にkcとしてセットする(ステップ210)。さらに、プロセッサ100は、BMで特定されるBMレジスタ20のビットに対応付けられたVECレジスタ21のアドレスaddrを参照し、分岐処理部130によりそのアドレスaddrの例外ハンドラにジャンプする、即ち実行を移す(ステップ211)。
FIG. 4 is a flowchart (200) schematically showing the exceptional program control method according to the embodiment of the present invention. This method can be implemented in a processor 100 in which exceptions as shown in FIG. 3 are controlled by software. The processor 100 starts when the
図5は、本発明の1実施形態に係る例外プログラム制御方法を実施するために作成される1例のプログラム50を概略的に示す。プログラム50には制御実行命令12のexpc命令が設けてある。expc命令は、制御指定命令11のexpen命令により例外を有効にする指定がされているときには、例外を処理する例外ハンドラへ実行が移り、例外ハンドラにより例外が処理されると、expc命令の次へ実行が戻る。しかし、expc命令は、制御指定命令11のexpen命令により例外を有効にしない(無効にする)指定がされているときには、何もせずに通過され、その次の命令に実行が進む。
FIG. 5 schematically shows an
図6は、本発明の1実施形態に係る例外プログラム制御方法を実施するために作成される別例のプログラム60を概略的に示す。プログラム60は図1に示したプログラムに対応している。タスクBでのif文は不要になり、初期状態では初期化されていないため(未初期化)、制御指定命令11のexpen 20, 1命令により例外を有効にして初期化する関数が初めに呼び出されている。右側に示されたアセンブラ言語レベルでは、制御実行命令12のexpc 20, 512命令が設けてあり、この命令はほとんどの場合はCPUサイクルを消費することなく命令キューの中で破棄され、稀に例外が有効の時にだけ例外ハンドラにジャンプする命令として実行される。expc 20, 512命令の2番目のオペランド512は呼び出し側がどういう条件あるいは目的で例外を発生させたのかを呼び出された側のプログラムで識別するために使用される。ここでは関数番号512の指定のために使われ、初期化関数init()が呼び出される。例外ハンドラにおいて、その初期化関数の後方には、初期化されたため(初期化済)、制御指定命令11のexpen 20,0命令により例外を無効にする指定がされている。このように、従来技術における確認処理のためのコードを実行することなく、リセット状態の時だけ例外割り込みを発生して初期化処理を行わせることができる。
FIG. 6 schematically shows another
図7は、本発明の1実施形態に係る例外プログラム制御方法を実施するために作成されるさらに別例のプログラム70を概略的に示す。これは必要になった時にメモリを割り当てるデマンドページングを一般化して任意のソフトウエアオブジェクトの割り当てを行う例である。左側の従来技術では、ページが存在しない領域にCPUがアクセスしようとするとページフォールトが起きて例外処理の中でメモリが割り当てられる。プログラム70では、start:の直後に制御実行命令12のexpc 1, 0命令が設けてあり、初回の実行で例外を発生させて、必要なオブジェクト、例えばメモリヒープの実体化と初期化を行う。その後、2回目のexpc命令による例外の呼び出しでは、既にメモリヒープは実体化されている(制御指定命令11のexpen命令で例外を無効にされる)ので、例外は発生しない。この例はメモリヒープについてであるが、メモリだけでなく、任意のソフトウエアリソース、例えば、セマフォ、ミューテックスなどの同期オブジェクトなどの割り当てと初期化も必要に応じて行うことができるようになる。
FIG. 7 schematically shows still another example of a
図8は、本発明の1実施形態に係る例外プログラム制御方法を実施するために作成されるさらに別例のプログラム80を概略的に示す。これは不正なコード実行からコードを守るコード保護の仕組みを一般化した例である。左側の従来技術では、非特権モードの時に特権モードのコードを実行するアクセス違反に対して例外割り込みが起きるが、これはメモリのページ単位でコードを守ることしかできない。プログラム80では、制御実行命令12を必要な箇所に設けてピンポイントで例外を発生させることができ、コードの一部をある条件を満たす時の保護領域となし得る、即ち、任意のコード単位で不正な実行に対する例外処理を行える。ただし、従来技術と等価にするにはexpen命令およびBMレジスタを拡張して特権モードと非特権モードに関連付けて状態を別個に保持したり、リード可能かどうかなどの属性を必要であれば別途レジスタなどで保持する必要がある。本発明の場合は、プログラムで任意の条件をアクセス違反と定義して例外の発生を有効にしたり無効にしたりして使用することを想定している。プログラム80では、プログラム実行パスの先頭に制御実行命令12のexpc 3, 0命令を設けることにより、指定のコード領域(cond==Bの時)を例外発生領域にしている。制御指定命令11のexpen 3, 1で例外を有効にすることにより、制御実行命令12のexpc 3, xを含むコード領域はすべて一斉に例外の発生領域となる。
FIG. 8 schematically shows still another example of a
その他にも、本発明の1実施形態に係る例外プログラム制御方法を様々に実施することができる。例えば、デバッグ目的でプログラムの実行をトレースする場合である。プログラムのトレースしたい場所に、制御実行命令12のexpc命令を設けておき、例外ハンドラにログ用のコードを記述する。そして、トレースを開始したい時に、制御指定命令11のexpen命令で例外を有効にし、設けておいたexpc命令によりプログラムの実行がトレースされる。また、プロセス間通信の手段として用いる例の場合には、受信側のタスクにexpc命令を設けておき、送信側でexpen命令を実行する。その実行で設けておいたexpc命令が例外ハンドラを起動することにより、受信側はメッセージが送られたことを知る。さらに、システムコールの応用例として、条件が成立する場合だけ実行を行うシステムコールを実現できる。例えば、オープン(open)状態にある場合にだけシステムコールを実行するようなリード(read)システムコールを本発明を用いて作成することができる。プログラム次第で様々な応用が可能である。
In addition, the exceptional program control method according to the embodiment of the present invention can be implemented in various ways. For example, tracing program execution for debugging purposes. An expc instruction of the
プログラムに設けられる制御指定命令11のexpen命令および制御実行命令12のexpc命令については、例外が発生しない場合にexpc命令はexpen命令以外に他のCPU命令とはレジスタファイルを介して依存関係を持つことはないので、命令パイプラインの中で実行ステージに到達する前に命令キューからexpc命令を削除しても良い。その場合、expc命令を設けなかった場合と比較して、余分なCPUサイクルを消費することなくCPU命令を実行可能である。条件分岐命令の場合には、条件レジスタを更新する命令の実行が完了するまで、分岐するかどうかの判断はできない。一方、expc命令はそのようなレジスタとの依存関係はないので、expen命令が直前にない場合、例外を発生するかどうかは、命令キューに読み込まれてすぐに判断できる。
As for the expen instruction of the
このように、条件分岐命令と比較した場合、分岐判定のための前処理が不要なため、例外が発生しない場合、制御実行命令12のexpc命令は高速に処理される。例外が発生する場合、コンテキストの同期処理が伴うため低速な処理になるかも知れない。そこで、高速な処理が必要な場合は、コンテキストの同期処理を行わず、例外が発生した位置にも戻らないように、つまり無条件分岐命令と同じ動作をするようにしても良い。上記の例の場合には256通りであるが、多数の例外処理を扱えるので、あるものはコンテキストの同期処理を必要とするものとして、また、あるものは高速に分岐処理を行うものとして、それぞれ割り当てることができる。
As described above, when compared with a conditional branch instruction, preprocessing for branch determination is unnecessary, and therefore, when no exception occurs, the expc instruction of the
以上、実施態様を用いて本発明の説明をしたが、本発明の技術的範囲は実施態様について記載した範囲には限定されない。実施態様に種々の変更又は改良を加えることが可能であり、そのような変更又は改良を加えた態様も当然に本発明の技術的範囲に含まれる。 As mentioned above, although the present invention was explained using the embodiment, the technical scope of the present invention is not limited to the range described about the embodiment. Various modifications or improvements can be added to the embodiments, and the modes with such modifications or improvements are naturally included in the technical scope of the present invention.
Claims (18)
例外を有効にするか否かの例外制御指定のための制御指定命令を実行して、レジスタに前記例外の制御指定値を設定するステップと、
例外を発生させるか否かの例外制御実行のための制御実行命令を実行して、前記レジスタに設定された前記制御指定値が前記例外を有効にする値か否かを判定し、当該制御指定値が前記例外を有効にする値のときは前記例外を発生させるステップと、
を実行することを含む、例外プログラム制御方法。 A method of programmatically controlling an exception, wherein a processor
Executing a control specification instruction for specifying whether to enable an exception or not, and setting a control specification value of the exception in a register;
Execute a control execution instruction for exception control execution to determine whether or not to generate an exception, determine whether the control specified value set in the register is a value that enables the exception, and specify the control Generating the exception if the value is a value that enables the exception; and
An exception program control method including executing
プロセッサが、例外を有効にするか否かの例外制御指定のための制御指定命令と例外を発生させるか否かの例外制御実行のための制御実行命令とを実行して例外を制御する例外制御部を含み、
当該例外制御部が、
レジスタと、
前記制御指定命令を実行して、前記レジスタに前記例外の制御指定値を設定する制御指定命令処理部と、
前記制御実行命令を実行して、前記レジスタに設定された前記制御指定値が前記例外を有効にする値か否かを判定し、当該制御指定値が前記例外を有効にする値のときは前記例外を発生させる制御実行命令処理部とを含む、
例外プログラム制御システム。 A system for programmatic control of exceptions,
Exception control for controlling an exception by executing a control specification instruction for specifying an exception control whether or not to enable an exception and a control execution instruction for executing an exception control whether or not to generate an exception. Part
The exception control unit
Registers,
A control designation instruction processing unit for executing the control designation instruction and setting the control designation value of the exception in the register;
The control execution instruction is executed to determine whether the control specified value set in the register is a value that enables the exception. When the control specified value is a value that enables the exception, Including a control execution instruction processing unit that generates an exception,
Exception program control system.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2012549670A JP5822848B2 (en) | 2010-12-20 | 2011-10-04 | Exception control method, system and program |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2010-283459 | 2010-12-20 | ||
| JP2010283459 | 2010-12-20 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2012086288A1 true WO2012086288A1 (en) | 2012-06-28 |
Family
ID=46313572
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/JP2011/072876 Ceased WO2012086288A1 (en) | 2010-12-20 | 2011-10-04 | Exception control method, system, and program |
Country Status (2)
| Country | Link |
|---|---|
| JP (1) | JP5822848B2 (en) |
| WO (1) | WO2012086288A1 (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9710270B2 (en) | 2010-12-20 | 2017-07-18 | International Business Machines Corporation | Exception control method, system, and program |
| JP2019511042A (en) * | 2016-03-02 | 2019-04-18 | エイアールエム リミテッド | Register access control |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH04230533A (en) * | 1991-01-07 | 1992-08-19 | Nec Corp | Interruption control circuit |
| JPH04287231A (en) * | 1991-03-18 | 1992-10-12 | Nec Corp | Microprocessor |
| JPH0744398A (en) * | 1993-07-30 | 1995-02-14 | Sony Corp | Information processing equipment |
Family Cites Families (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH0496167A (en) * | 1990-08-09 | 1992-03-27 | Oki Electric Ind Co Ltd | Interruption system for multi-processor system |
| JPH0535499A (en) * | 1991-07-29 | 1993-02-12 | Fujitsu Ltd | Data processing device and data processing method |
| JP3822885B2 (en) * | 1994-09-09 | 2006-09-20 | 株式会社ルネサステクノロジ | 1 chip data processor |
| JP3600095B2 (en) * | 1999-12-07 | 2004-12-08 | 松下電器産業株式会社 | Interrupt management device and interrupt management method |
| JP2002196938A (en) * | 2000-12-11 | 2002-07-12 | Faraday Technology Corp | Device for exception handling flow and its handling execution method |
| JP3540802B2 (en) * | 2002-03-25 | 2004-07-07 | 松下電器産業株式会社 | Instruction generation method, instruction generation method, and information processing apparatus |
| JP2008015883A (en) * | 2006-07-07 | 2008-01-24 | Matsushita Electric Ind Co Ltd | Master device, slave device, communication method thereof, and communication system |
| JP2010092273A (en) * | 2008-10-08 | 2010-04-22 | Panasonic Corp | Information processor |
-
2011
- 2011-10-04 WO PCT/JP2011/072876 patent/WO2012086288A1/en not_active Ceased
- 2011-10-04 JP JP2012549670A patent/JP5822848B2/en not_active Expired - Fee Related
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH04230533A (en) * | 1991-01-07 | 1992-08-19 | Nec Corp | Interruption control circuit |
| JPH04287231A (en) * | 1991-03-18 | 1992-10-12 | Nec Corp | Microprocessor |
| JPH0744398A (en) * | 1993-07-30 | 1995-02-14 | Sony Corp | Information processing equipment |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9710270B2 (en) | 2010-12-20 | 2017-07-18 | International Business Machines Corporation | Exception control method, system, and program |
| JP2019511042A (en) * | 2016-03-02 | 2019-04-18 | エイアールエム リミテッド | Register access control |
Also Published As
| Publication number | Publication date |
|---|---|
| JP5822848B2 (en) | 2015-11-25 |
| JPWO2012086288A1 (en) | 2014-05-22 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| KR102116571B1 (en) | Systems And Methods for Exposing A Result Of A Current Processor Instruction Upon Exiting A Virtual Machine | |
| CN109840410B (en) | Method and system for isolating and protecting data in process | |
| JP5335887B2 (en) | Debugging method, control method, and debugging device for authenticating conditional debug instruction based on address | |
| CA2866809C (en) | Run-time instrumentation directed sampling | |
| JP6195571B2 (en) | Change in runtime instrumentation control from low privilege state | |
| WO2013136700A1 (en) | Run-time instrumentation reporting | |
| US20130246754A1 (en) | Run-time instrumentation indirect sampling by address | |
| JP7668280B2 (en) | Apparatus and method for capability-based processing - Patents.com | |
| US7730463B2 (en) | Efficient generation of SIMD code in presence of multi-threading and other false sharing conditions and in machines having memory protection support | |
| KR20190020036A (en) | Register recovery branch instruction | |
| JP7136888B2 (en) | Allow Non-Abort Processing of Transactions After an Exception Mask Update Instruction | |
| CN119806544B (en) | Binary translation method, binary translation device, electronic equipment and readable storage medium | |
| KR102846228B1 (en) | Control protection tag checking during memory access | |
| JP5822848B2 (en) | Exception control method, system and program | |
| JP7645190B2 (en) | Conditional Yield to Hypervisor Instructions | |
| US11216280B2 (en) | Exception interception | |
| US20060095726A1 (en) | Independent hardware based code locator | |
| US9710270B2 (en) | Exception control method, system, and program | |
| KR20040058228A (en) | Low overhead exception checking | |
| KR20230101878A (en) | Filtering based on scope specifier | |
| CN116917860A (en) | Flexible returns and event delivery | |
| Anwar et al. | Dynamic binary translation in a type-II hypervisor for Cavium Octeon MIPS64 based systems | |
| KR20200020926A (en) | Context data management | |
| HK1231981A1 (en) | Systems and methods for exposing a result of a current processor instruction upon exiting a virtual machine | |
| JP2005157537A (en) | Memory access monitoring device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 11851894 Country of ref document: EP Kind code of ref document: A1 |
|
| ENP | Entry into the national phase |
Ref document number: 2012549670 Country of ref document: JP Kind code of ref document: A |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 11851894 Country of ref document: EP Kind code of ref document: A1 |