EP0950216A2 - A processing device for executing virtual machine instructions - Google Patents

A processing device for executing virtual machine instructions

Info

Publication number
EP0950216A2
EP0950216A2 EP98940511A EP98940511A EP0950216A2 EP 0950216 A2 EP0950216 A2 EP 0950216A2 EP 98940511 A EP98940511 A EP 98940511A EP 98940511 A EP98940511 A EP 98940511A EP 0950216 A2 EP0950216 A2 EP 0950216A2
Authority
EP
European Patent Office
Prior art keywords
instruction
processor
instructions
feeding
native
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.)
Granted
Application number
EP98940511A
Other languages
German (de)
French (fr)
Other versions
EP0950216B1 (en
Inventor
Menno Menasshe Lindwer
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.)
Koninklijke Philips NV
Original Assignee
Koninklijke Philips Electronics NV
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 Koninklijke Philips Electronics NV filed Critical Koninklijke Philips Electronics NV
Priority to EP98940511A priority Critical patent/EP0950216B1/en
Priority to EP03101820A priority patent/EP1359501A3/en
Publication of EP0950216A2 publication Critical patent/EP0950216A2/en
Application granted granted Critical
Publication of EP0950216B1 publication Critical patent/EP0950216B1/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/3017Runtime instruction translation, e.g. macros
    • G06F9/30174Runtime instruction translation, e.g. macros for non-native instruction set, e.g. Javabyte, legacy code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3861Recovery, e.g. branch miss-prediction, exception handling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3877Concurrent instruction execution, e.g. pipeline or look ahead using a slave processor, e.g. coprocessor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/461Saving or restoring of program or task context

Definitions

  • a processing device for executing virtual machine instructions
  • the invention relates to a processing device for executing virtual machine instructions; the processing device comprising: an instruction memory for storing instructions including at least one of the virtual machine instructions; a microcontroller comprising a processor comprising a predetermined microcontroller core for executing native instructions from a predetermined set of microcontroller specific instructions; the native instructions being different from the virtual machine instructions; and a pre-processor comprising: a converter for converting at least one virtual machine instruction, fetched from the instruction memory into at least one native instruction; and feeding means for feeding native instructions to the microcontroller core for execution.
  • the invention further relates to a pre-processor for use with a microcontroller comprising a processor comprising a predetermined microcontroller core for executing native instructions from a predetermined set of microcontroller specific instructions; the pre-processor comprising: a converter for converting at least one virtual machine instruction, fetched from an instruction memory, into at least one native instruction; the native instructions being different from the virtual machine instructions; and feeding means for feeding native instructions to the microcontroller core for execution.
  • source programs are expressed in (compiled to) instructions of a virtual machine instead of native instructions of a microcontroller on which the program is to be executed.
  • a main reason for using a virtual machine is portability of programs between different machines (platforms).
  • a program expressed in the virtual machine instructions of the virtual machine can be executed relatively easily on several concrete machines, using suitable interpreters operating on those machines.
  • a driving force for using portable programs is Java, where Java programs (referred to as applets) are exchanged via Internet and can be executed on different native machines using processors with different instruction sets.
  • Java applets are expressed in Java byte codes (JBCs), which form the instructions of the Java Virtual Machine.
  • JBCs Java byte codes
  • a specific virtual machine for an embedded application can be defined by first expressing the source program in virtual machine instructions of a chosen virtual machine, such as a stack machine, and additionally, replacing sequences of virtual machine instructions which occur frequently in the compiled code by newly defined additional virtual machine instructions, where, for instance, one new instruction replaces a sequence of four existing instructions.
  • the MC68000 After power-on, the MC68000 first performs a booting procedure by executing native MC68000 instructions. At the end of the booting procedure, the MC68000 is ready to initiate the execution of a Prolog program. This is started by jumping to a predetermined address range.
  • the pre-processor is a memory- mapped device, which is mapped to this range. When the pre-processor is addressed it reads a Warren instruction (of the translated Prolog program) from its own RAM, adaptively synthesizes a sequence of MC68000 instructions and constants and sends these directly to the CPU for execution.
  • the MC68000 instructions for each Warren instruction are stored in ROM of the pre-processor.
  • the pre-processor translates one Warren instruction into a sequence of MC68000 instructions.
  • the pre-processor contains its own RAM controller and ROM controller, which generate the addresses for the RAM and ROM of the pre-processor.
  • the RAM controller manages the RAM instruction pointer.
  • Each successive read operation of the MC68000 results in the pre-processor sending the next instruction (and optional constants) of the sequence to the CPU. If the sequence has been completed, a next read operation results in the first instruction of the sequence corresponding to the next Warren instruction of the program being send to the CPU. After an interrupt, a repeated read operation of the CPU results in re-sending the last instruction (and optional constants).
  • the processor is of a type which after the occurrence of a predetermined condition, such as an interrupt, requests re-feeding of up to a predetermined maximum of n native instructions, where n > 1 ; and the feeding means comprises means for in response to the processor requesting re-feeding of a number of native instructions, re-feeding the requested native instructions.
  • a predetermined condition such as an interrupt
  • the feeding means comprises means for in response to the processor requesting re-feeding of a number of native instructions, re-feeding the requested native instructions.
  • the inventor had the insight that in order to cope with the situation in which the processor discards at least some of the already loaded instructions and at a later stage requests re-feeding of several instructions (e.g. on the occurrence of certain conditions, such as an interrupt), a re-feeding mechanism is required for re-feeding the requested native instructions to the processor.
  • the preprocessor comprises a feeding memory, such as a FIFO, for storing last fed instructions and re- feeding from the feeding memory, providing a simple and effective way of re-feeding the instructions.
  • a feeding memory such as a FIFO
  • the first native instruction to be re-fed may be any instruction of the sequence.
  • the native instruction may correspond to an earlier virtual machine instruction than the current one.
  • the sequence length may be different for different virtual machine instructions.
  • instructions being actively processed in the pipeline of the microcontroller can be re-fed.
  • instructions stored in the instruction cache of the processor can be re-fed.
  • instruction stored in the cache or being processed in the pipeline can be re-fed.
  • the feeding memory is capable of storing, in addition to instructions which may need to be re-fed, also instructions which are to be fed for the first time.
  • the pre-processor may in advance generate native instructions before the native instruction is actually requested, avoiding possible delays in feeding a first time requested instruction to the processor.
  • it allows the use of only one feeding mechanism which takes care of feeding first time requested instructions and of re-feeding instructions.
  • the measure defined in the dependent claim 7 shows a simple and effective way for unifying first time feeding and re-feeding.
  • the instructions which have already been fed and the instruction(s) still to be fed are stored successively in the feeding memory, such as a FIFO.
  • the pre-processor maintains a pointer indicating a memory location in the feeding memory containing the instruction expected to be requested next (i.e. the first instruction which has not yet been requested before). In practice, this memory location may always be at a fixed position of the feeding memory, so that no separate pointer needs to be maintained.
  • the pre-processor comprises a counter which indicates an address of the native instruction expected to be requested next by the processor for first time feeding.
  • the counter is incremented.
  • the processor indicates (using an instruction pointer) an address of the instruction required next by the processor. This may be a request for a first time feeding or a re-feeding of an instruction.
  • the pre-processor compares the requested address to the address stored in the counter. Based on the offset, the instruction is located in the feeding memory. For instance, the counter may store the address of the instruction expected to be requested next, being one higher than the address of the instruction fed last. If indeed the processor requests this new instruction, the offset is zero. If the logical pointer points to the location of the new instruction, the instruction stored at this location is fed to the processor.
  • the offset may be one or minus one (counted in units of an instruction, which may be 4 counted in units of bytes for a 32-bit instruction). By subtracting (or respectively adding) the offset from the pointer the requested instruction is located. It will also be appreciated that the counter and the logical pointer do not need to store the exact address/location of the instruction expected to be requested next. For instance, the logical pointer may also indicate the last fed instruction.
  • the measure defined in the dependent claim 8 shows an alternative arrangement where no additional feeding memory is required. Instead the pre-processor stores state information which enable recreating the instructions requested by the processor for refeeding. As an example, instead of storing fed instructions in a feeding memory, also pointers indicating instructions or information used to initially create the instructions may be stored in a memory.
  • part of the state is stored in the instruction pointer of the microcontroller, potentially reducing the costs of the pre-processor.
  • the pre-processor comprises for at least one virtual machine instruction a corresponding translation table for translating the virtual machine instruction into a sequence of native instructions.
  • the translation table may, for instance, be stored in ROM.
  • the least significant part of the instruction pointer of the processor is used to indicate which of the native instructions in the table is required (i.e. the least-significant part of the instruction pointer acts as a translation table offset indicator).
  • the processor automatically increments the instruction pointer.
  • the pre-processor does not need to store an own counter and increment this counter for indicating the native instruction expected to be read next. If the processor requests a re-feeding, the processor will automatically set the instruction pointer to a previous value. In this way also re-feeding can be taken care of automatically.
  • the measure defined in dependent claim 11 provides an effective way for determining, in addition to the translation table offset, also the translation table in which the requested native instruction is located.
  • a predetermined further part of the instruction pointer comprises a virtual machine instruction pointer indicating a virtual machine instruction in the instruction memory. This virtual machine instruction pointer can be seen as a virtual machine program counter, which needs to be incremented each time a new virtual machine instruction is required.
  • the pre-processor fetches the virtual machine instruction indicated by the virtual machine instruction pointer from the instruction memory and based on the fetched virtual machine instruction locates the translation table. The least significant pan of the instruction pointer of the processor is then used as an offset in the translation table.
  • the virtual machine instruction pointer can be set to indicate the next virtual machine instruction, for instance, by using as a last native instruction in the sequence an explicit jump which sets the virtual machine instruction pointer to the desired value and resets the translation offset part of the instruction pointer or using one or more NOP (no operation) instructions so that eventually an overflow of the translation offset part results in the processor incrementing the virtual machine instruction pointer.
  • NOP no operation
  • the translation table contains a native instruction skeleton for at least native instructions with variable parts.
  • the skeleton comprises predetermined fixed parts of the native instruction, such as the operation code, whereas variable elements of the instruction, such as certain operands, are loaded adaptively, for instance from parameters of the corresponding virtual machine instruction.
  • the measure defined in dependent claim 12 provides an alternative for the use of the virtual machine instruction pointer.
  • the translation table is divided into several sub-tables, at least one of the sub-tables comprising a sequence of native instructions or native instruction skeletons. A sub-table may but does not need to correspond to a complete sequence of native instructions corresponding to one virtual instruction.
  • the translation table offset indicator indicates an offset in one of the sub-tables.
  • a predetermined further part of the instruction pointer comprises a sub-table indicator.
  • the pre-processor uses the value of the sub-table indicator to locate the actually involved sub- table.
  • the sub-table indicator is incremented by one unit each time a native instruction is fetched from a next sub-table (regardless of the sub-table being related to the same or different virtual machine instructions) .
  • the pre-processor may store pointers to the related sub-table(s) for the last used sub-table indicators.
  • a sequence of native instructions relating to one virtual machine instruction may be complemented by NOP instructions in order to ensure that the sequence ends on a sub-table boundary (eliminating the use of jump operations to correct the value of the sub-table indicator part of the instruction pointer).
  • NOP instructions Most processors can execute a NOP operation significantly faster than a jump operation.
  • the measure defined in the dependent claim 13 ensures that no deadlock situation can occur wherein the processor has requested an instruction and blocks the bus until the instruction has been supplied, whereas the pre-processor first needs to obtain a (virtual machine) instruction from the instruction memory via the same bus before it can supply the native instruction.
  • Figure 1 illustrates four possible architectural options of locating the preprocessor in the processing device
  • Figure 2 shows a translation table for translating a virtual machine instruction into a sequence of native instructions
  • FIG. 3 shows a block diagram of an embodiment of the processing device wherein a feeding memory is used for re-feeding instructions
  • Figure 4 illustrates a uniform way of feeding and re-feeding instructions
  • Figure 5 illustrates using the instruction pointer of the processor as an index into the translation table
  • Figure 6 shows an alternative use of the instruction pointer.
  • Figure 1 illustrates four possible architectural options of locating the pre- processor in the processing device 100.
  • Three main components of the processing device 100 are the microcontroller 110, the instruction memory 120 and the pre-processor 130.
  • the microcontroller 110 comprises the instruction memory 120 and the preprocessor 130.
  • the processing device 100 is not shown explicitly. By combining all main elements in the microcontroller 110, which preferably is a one-chip device, optimum performance can be achieved.
  • the instruction memory 120 and/or the pre-processor 130 may be located outside the microcontroller 110, where the microcontroller bus 140 is extended outside the microcontroller 110 and, for instance, coupled to an external bus such as PCI.
  • the instruction memory 120 contains virtual machine instructions, such as instructions for a stack machine.
  • the microcontroller 110 comprises a processor 112 with a predetermined microcontroller core 114, referred to as a native machine, for executing native instructions from a predetermined set of microcontroller specific instructions.
  • a microcontroller suitable for executing embedded software is a RISC-type microcontroller, like the MIPS PR3001 range of microprocessors.
  • the native instructions of the microcontroller core 114 are different from the virtual machine instructions of the virtual machine. As such the microcontroller 110 is not able to directly execute virtual machine instructions stored in the instruction memory 120.
  • the pre-processor 130 issues the native instruction.
  • the pre-processor 130 may fetch a virtual machine instruction from the instruction memory 120 using fetching means 134.
  • the pre-processor 130 comprises a converter 132 for converting a virtual machine instruction, fetched from the instruction memory 120, into at least one native instruction.
  • a virtual machine instruction is converted to a sequence of native instructions.
  • the pre-processor 130 further comprises a feeding means 136 for feeding native instructions of the sequence to the microcontroller core for execution. When executing a virtual machine program the microcontroller 110 in fact executes a native program generated by the pre-processor 130.
  • an instruction pointer of the microcontroller 110 indicates the next instruction in the instruction memory 120 required by the microprocessor 110 to be executed next, now the instruction pointer indicates to the pre-processor 130 that a next native instruction is required (or a re-feeding of a previous instruction).
  • the pre-processor 130 manages an independent virtual machine instruction pointer indicating the current (or next) virtual machine instruction in the instruction memory 120.
  • the microcontroller has no (explicit) knowledge of the virtual machine instruction or the virtual machine instruction pointer.
  • the processor 112 is of a type which after the occurrence of a predetermined condition requests re-feeding of up to a predetermined maximum of n native instructions, where n > 1.
  • a condition may be an interrupt, causing the processor to discard instructions already in the processor.
  • a processor 112 with a k-stage pipelined will normally operate on k instructions at a time. The occurrence of the condition may result in discarding all k instructions.
  • a further reason for discarding more than one instruction is where the processor comprises an instruction cache 116 for storing up to h instructions. The occurrence of the condition may result in discarding all h instructions in the cache 116.
  • the processor 112 may return to the execution of the virtual machine program and request re-feeding of more than one instruction.
  • the feeding means 136 comprises means for in response to the processor 112 requesting re-feeding of a number of native instructions, re-feeding the requested native instructions.
  • the instruction memory 120 may also contain native instructions. Such native instructions may for instance be used to initialise the system or to allow certain software modules, such as drivers or special parts of the embedded software application, to be compiled to native instructions for optimal performance.
  • native instructions and virtual machine instructions in the instruction memory 120 may be made on the address of the instruction, where a predetermined range of addresses is allocated for virtual machine instructions.
  • Fig. 1A the main components of the processing device are interconnected via a general peripheral interconnect bus 140, such as the PI bus.
  • the preprocessor 130 is a peripheral on the bus.
  • the pre-processor 130 may act as a memory - mapped peripheral, where a predetermined range of addresses is allocated to the preprocessor.
  • the pre-processor 130 issues the native instruction on the bus 140.
  • the pre-processor 130 fetches a virtual machine instruction from the instruction memory 120 via the bus 140.
  • the pre-processor 130 is located in between the microcontroller 110 and the instruction memory 120. If the pre-processor 130 needs to distinguish between native and virtual machine instructions, these configurations may delay execution of native instructions stored in the instruction memory 120. For reasons of clarity not all elements shown in Fig. 1A are repeated in Fig. IB, 1C and ID.
  • the pre-processor 130 is embedded in the microcontroller 110.
  • the pre-processor 130 is preferably located between an instruction cache 116 of the microcontroller 110 and the core 114. This configuration allows for optimal performance but, unlike the configurations of Figs 1A, IB and 1C, requires changes to the microcontroller 110 and, as such, the pre-processor 130 can not as an off-the-shelf design be used for different types of microcontrollers.
  • the converter 132 is used for converting a virtual machine instruction, fetched from the instruction memory 120, into at least one native instruction.
  • the Java byte code (a virtual machine instruction) for integer addition (0x60) results in adding the two top elements of the stack, removing the two top elements from the stack and pushing the sum on the stack.
  • This virtual machine instruction may be converted to the following sequence of instructions (native instructions) for a MIPS processor (a 32-bits machine), where $tosp is a register pointing to the first empty location of the stack (above the top of stack): lw $a0, 4 ($tosp) /* load the top element of the stack in register $a0 lw $al, 8 ($tosp) /* load the second element of the stack in Sal add $a0, Sal, $a0 /* add $a0 and Sal, place the sum in $a0 addi $tosp, $tosp, 4/* lower the stack by one element sw $a0, 4 (Stosp) /* store the sum in the new top of stack
  • the converter 132 comprises a table for converting a virtual machine instruction to a sequence of native instructions.
  • a one dimensional table may be used, where each cell of the table comprises a sequence of native instructions for one corresponding virtual machine instruction.
  • the cell number may correspond to the value of the corresponding virtual machine instruction.
  • Such a translation table 200 is shown in Fig. 2, where the implicit cell boundaries are indicated using dotted lines.
  • a code index table 210 may be used, which for each virtual machine instruction (VMI 1 to VMI N) indicates the starting point of the corresponding sequence in the translation table 200.
  • VMI 1 to VMI N For the cell of the translation table 200 which corresponds to VMI 3 the related sequence 220 of native instruction NI 1 to NI M are shown.
  • Java byte code bipush n (used for sign extending byte n and placing the result on top of the stack).
  • This virtual machine instruction consists of two bytes ⁇ 0x16 and ⁇ ), where the first byte specifies the operation and the second byte provides the parameter n.
  • the instruction may be converted to the following sequence of native MIPS instructions: ori $a0, $0, n /* Load register $a0 with constant n */ sll $a0, $a0, 24 /* Shift left by 24 bits */ sra $a0, $a0, 24 /* Arithmetic shift right, causing sign extension, by /* replicating last left-most bit */ sw $a0, 0 (Stosp) /* Store result at new top of stack */ addi Stosp, -4 /* Increment stack size */
  • the converter 132 comprises a translation table 200, where native instructions are represented either by the full code or by an instruction skeleton.
  • the instruction addi Stosp, -4 (last instruction of the sequence of the previous example) contains no variable parts and may be located in full as a 4-byte entry in the table.
  • the instruction ori $a0, $0, n (first instruction of the sequence of the previous example) contains a variable part and may be located in the table as a skeleton, not specifying the variable part (being ⁇ ).
  • the entry in the table for an instruction skeleton is the same width as a full instruction (e.g.
  • the virtual machine is a stack oriented machine
  • the stack or at least the top elements of the stack are mapped onto registers of the microcontroller 110.
  • the memory stack (with the virtual machine stack) is mapped to the register stack.
  • registers $rl, $r2 and $r3 contain three successive elements of the memory stack, where initially $rl corresponds to the first empty location of the memory stack (above the top of the stack), $r2 contains the top of the memory stack, and $r3 contains the second element of the memory stack
  • the Java byte code bipush n may be converted to the following sequence of native MIPS instructions: ori $rl, $0, n sll $rl, $rl, 24 sra $rl, $rl, 24 After this operation, $rl contains the top of the memory stack.
  • the Java byte code (a virtual machine instruction) for integer addition (0x60) may be converted to the following sequence of MIPS instructions, starting from the same position where initially $rl corresponds to the first empty location of the memory stack (above the top of the stack), $r2 contains the top of the memory stack, and $r3 contains the second element of the memory stack: add $r3, $r2, $r3 After this operation, $r3 contains the top of the memory stack.
  • the position of the top of the memory stack is indicated using a register 138 of the converter 132.
  • the converter uses the register 138, referred to as the Register Stack Pointer (RSP), to generate the appropriate native instructions.
  • RSP Register Stack Pointer
  • microprogramming is used to specify the register operands of the native instructions. In this way also fixed native instructions have become variable, since the register operands need to be specified by the converter 132.
  • such operands are also stored in the translation table 200 using instruction skeletons.
  • FIG. 3 illustrates an embodiment according to the invention wherein the pre-processor 130 comprises a feeding memory 300.
  • the feeding memory 300 comprises a part 310 for storing at least n instructions which were last fed to the processor (n being the maximum number of native instructions of which the processor could request re-feeding).
  • the feeding means 136 re-feeds the requested instructions from the feeding memory 300.
  • the feeding memory part 310 has a FIFO function 136. Each time an instruction is fed to the processor 112 for the first time, the instruction is loaded into the part 310 and, if the part 310 is full, the oldest instruction is removed.
  • n is equal to or larger than k.
  • n is preferably equal to or larger than k + h.
  • the feeding memory 300 comprises memory locations 320 for storing a further m native instructions, where m > 1.
  • the part 320 of the feeding memory 300 has a FIFO function. Each time an instruction is fed to the processor 112 this instruction is removed from part 320 and inserted into part 310. The pre-processor 130 inserts the instructions in the part 320.
  • the two memory parts 310 and 320 of the feeding memory 300 are be combined. This may be implemented using one unified FIFO. Other alternatives, such as cyclic buffers with corresponding pointer, may also be used.
  • a unified mechanism is used for first time feeding and re-feeding of native instructions from the feeding memory 300 to the processor 112.
  • the feeding memory 300 stores instructions to be successively first-time fed (part 320) or re-fed (part 310) in a successive manner, as illustrated in Fig.4.
  • the pre-processor 130 comprises a counter 400 which indicates an address of a native instruction expected to be requested next by the processor for first time feeding.
  • the counter 400 can be seen as the expected instruction pointer.
  • the pre-processor 130 receives from the processor an actual instruction pointer 410 which indicates the actually requested native instruction. This may be the expected instruction, but may also be an already fed instruction.
  • the pre-processor 130 comprises means to determine an offset of an actual address of an instruction (410) requested by the processor with respect to the address stored in the counter 400. Shown is a subtracter 420 for subtracting the expected and the received instruction pointer. If the received instruction pointer is subtracted from the expected instruction pointer, the outcome will range from 0 to n, where 0 indicates that the first new instruction is requested and the other values indicate a request for re-feeding. Based on the offset, the instruction is located in the feeding memory 300 and fed to the processor 112. Preferably the locating is performed by combining the offset with a value of a pointer to the feeding memory 300. Shown is a pointer 430 which indicates the first native instruction which has not yet been fed to the processor 112 (i.e.
  • a subtracter 440 subtracts the offset from the value of the pointer 430. The resulting value points to the desired instruction.
  • the expected instruction pointer is normally set to the received instruction pointer + 1 instruction (for a 4-byte instruction this may imply incrementing the counter 400 by 4).
  • the pre-processor 130 comprises storing means for storing a state of the pre-processor enabling to regenerate at least n instructions which were last fed to the processor.
  • the pre-processor 130 could comprises a memory similar to the feeding memory 130 for storing pointers to the last fed n instructions or other state information allowing any of these instructions to be located or otherwise regenerated.
  • the feeding means 136 is operative to, in response to the processor requesting re-feeding of a number of instructions, re-feeding the requested instructions by regenerating the instructions based on the stored state.
  • the storing means is operative to store at least part of the state in an instruction pointer of the microcontroller.
  • the feeding means 136 is operative to retrieve the stored part from the instruction pointer.
  • Fig. 5 illustrates storing part of the state in the instruction pointer.
  • the pre-processor 130 comprises for at least one virtual machine instruction a corresponding translation table for translating the virtual machine instruction into a sequence of native instructions.
  • the translation table may, for instance, be stored in ROM.
  • the translation table may be a cell 220 of the table described earlier and for which an example is shown in Fig.2.
  • the least significant part of the instruction pointer of the processor is used to indicate which of the native instructions (e.g.
  • NI 1 to NI n in the table is required (i.e. the least-significant part of the instruction pointer acts as a translation table offset indicator). This part may, for instance, be 5-bit wide, allowing for a maximum of 32 native instructions for a virtual machine instruction without using further measures.
  • the processor 112 automatically increments the instruction pointer.
  • the pre-processor 130 does not need to store an own counter, like counter 400, and increment this counter for indicating the native instruction expected to be read next. If the processor requests a re-feeding, the processor 112 will automatically set the instruction pointer to a previous value. In this way also re-feeding can be taken care of automatically. Fig.
  • the pre-processor 130 comprises means 540 for extracting the translation table offset indicator 510 from the instruction pointer 500 (this may same involve an XOR operation on the instruction pointer 500 with a predetermined bit mask with ' l'-bits at the position of the part 510 and 'O'-bits for the other part(s).
  • the extracted part may directly be used as a pointer into the translation table or used as an offset.
  • a predetermined further part 520 of the instruction pointer 500 comprises a virtual machine instruction pointer indicating a virtual machine instruction in the instruction memory 120.
  • This virtual machine instruction pointer 520 can be seen as a virtual machine program counter, which needs to be incremented each time a new virtual machine instruction is required.
  • the pre-processor 130 is a memory mapped peripheral, one or more of the most significant bits of the instruction pointer 500 are reserved for indicating the address range reserved for the pre-processor 130. In principle, the remaining bits may be used for the part 520. Preferably this part is at least 16 bit wide, allowing for 64 KB blocks of virtual machine program.
  • the Register Stack Pointer 138 of Fig. 1A may be encoded in the instruction pointer, eliminating the need for the preprocessor 130 to maintain this pointer.
  • the pre-processor 130 comprises means 530 for extracting the virtual machine instruction pointer 520 from the instruction pointer 500.
  • the pre-processor 130 fetches the virtual machine instruction indicated by the extracted virtual machine instruction pointer from the instruction memory 120. Based on the fetched virtual machine instruction the pre-processor 130 locates the translation table.
  • the least significant part 510 of the instruction pointer 500 of the processor is then used as an offset in the translation table.
  • Means 540 are used for extracting the least significant part 510 from the instruction pointer 500.
  • the translation tables for the respective virtual machine instructions are combined into one sequential table, where a cell is reserved for native instructions corresponding to one virtual machine instruction. Such a table has been described before and an example 200 has also been shown in Fig. 2.
  • An index table 210 may be used for locating the relevant part of the translation table 200 for each virtual machine instruction.
  • Adding means 560 may be used for adding the output of the index table 200 (i.e. a cell address of the translation table 200) to the translation table offset (output of the extracting means 540).
  • the pre-processor 130 comprises a cache 550 for storing already fetched or expected to be fetched virtual machine instructions from the instruction memory 120.
  • the virtual machine instruction pointer can be set to indicate the next virtual machine instruction, for instance, by using as a last native instruction in the sequence an explicit jump which sets the virtual machine instruction pointer to the desired value and resets the translation offset part of the instruction pointer.
  • the part 520 of the instruction pointer is the next higher part in significance compared to the part 510.
  • the virtual machine instruction pointer can also be incremented by using one or more NOP (no operation) instructions so that eventually an overflow of the translation offset part 510 results in the processor 112 incrementing the virtual machine instruction pointer.
  • NOP no operation
  • the translation table 600 is divided into several sub-tables; shown are sub-tables 602, 604, 606, 608, and 609.
  • Each sub- table comprises at least one native instruction or native instruction skeleton, where at least one of the sub-tables comprises a sequence of native instructions or native instruction skeletons.
  • a sequence of native instructions for a virtual machine instruction starts at the first entry of a sub-table.
  • the sub-table may, but does not need to, correspond to a complete sequence of native instructions corresponding to one virmal machine instruction.
  • the sub-table may be shorter than the sequence, in which case it is preferred that the sequence continues in the sequentially next sub-table.
  • the translation table offset indicator 510 indicates an offset in one of the sub-tables.
  • a predetermined further part 620 of the instruction pointer 500 comprises a sub-table indicator.
  • the pre-processor 130 uses the value of the sub-table indicator 620 to locate the actually involved sub-table. To this end, the pre-processor 130 comprises means 610 for extracting the sub-table indicator 620 from the instruction pointer 500.
  • the sub-table indicator is incremented by one unit each time a native instruction is fetched from a next sub-table (regardless of the sub-table being related to the same or different virtual machine instructions).
  • a native instruction is fetched from a next sub-table (regardless of the sub-table being related to the same or different virtual machine instructions).
  • the sequence of a first virmal machine instruction is stored in the successive sub-tables with respective sub-table numbers of 110, 111, and 112; that the next virmal machine instruction is stored in sub-tables 85 and 86, and that a third virtual machine instruction is stored in sub-tables 41 and 42.
  • the first series of four native instructions (of sub-table with number 110) may be indicated by, for instance, a sub-table indicator 620 value of 1 , where the translation table offset indicators runs from 0 to 3.
  • the second series of four native instructions (of sub-table with number 111) will then be indicated by a sub- table indicator 620 value of 2.
  • the third series will be indicated by a sub-table indicator 620 value of 3.
  • the fourth series (although relating to a different virtual machine instruction) will be indicated by the next value of the sub-table indicator 620, being 4.
  • the pre-processor 130 comprises a cache 630 for storing pointers to the related sub-table(s) for the last used sub-table indicators.
  • the cache would store:
  • the sub-tables have equal size. If so, for the purpose of re-feeding, an instruction can be located by, based on the sub-table indicator 620, locating the sub-table number in the cache 630, multiplying the sub-table number by the size, and adding the translation table offset 510.
  • the sub-tables have an equal size which is a power of 2.
  • additional NOP instruction(s) may be used to complement the sequence to end at the boundary of the sub-table.
  • the sub-table indicator 620 will also be automatically incremented to a correct value for successive sequences of instructions.
  • a jump instruction may be used, which resets the translation table offset indicator 510 and increments the sub-table indicator 620.
  • a separate index table similar to table 210, may be used for locating the starting address of a sub-table based on the sub-table number.. In practice it may be possible to use a very small sub-table indicator 620. For a processor which requests re-feeding of up to 16 instructions and using sub-tables with 4 entries, it is sufficient to use a 2-bit sub-table indicator 620. In this example, the cache 630 only needs to have 4 entries.
  • the sub-table indicator 620 also the actual sub-table number may be used. In this case, however, jumps are required to set the sub-table indicator 620 to the correct value, for instance if a different sequence is started. Also the size of the sub-table indicator 620 will have to be larger, to be able to represent all sub-table numbers. Using such an arrangement, the combination of the sub-table indicator 620 and the translation table offset indicator 510 can directly indicate an entry in the table 600, making the cache 630 redundant.
  • the microcontroller 110 comprises the instruction memory 120 and the pre-processor 130.
  • the processor 112 , the instruction memory 120 and the pre-processor 130 being coupled via an atomic- transaction microcontroller bus 140.
  • an atomic transaction bus is meant a bus on which a device in order to perform a read operation, such as fetching an instruction, performs the following sequence of steps:
  • the device requests data (such as an instruction) by putting a request on the bus, - the device obtains the data when another device has put the data on the bus,
  • the device releases the bus, allowing other devices access to the bus.
  • the processor 112 requests (re-)feeding of native instructions via the bus 140 .
  • the preprocessor 130 fetches virmal machine instructions from the instruction memory 120 also via the bus 140 for conversion to associated native instruction(s) . Without special precautions, a deadlock can occur if the processor 112 has requested a native instruction and blocks the bus 140 until the instruction has been supplied, whereas the pre-processor 130 first needs to obtain a (virmal machine) instruction from the instruction memory 120 via the same bus 140 before it can supply the native instruction.
  • the pre-processor 130 comprises means for, in response to the processor 112 requesting (re-)feeding of a native instruction whose associated virtual machine instruction is not or no longer present in the pre-processor 130, feeding a no-operation (NOP) instruction to the processor 112 completing the bus transaction initiated by the processor 112.
  • NOP no-operation
  • the processing device 100 is capable of executing virtual machine instructions of more than one program.
  • the processing device 100 supports a plurality of tasks expressed in virtual machine instructions.
  • some of the tasks may also be expressed in native instructions.
  • the support for multiple virtual machine tasks is implemented by a task switching routine in the operating system running on the microcontroller 110.
  • a task switch is triggered (e.g. driven by a timer interrupt and handled by a task switching interrupt handling routine)
  • information relevant for the currently active task is saved from the pre-processor 130 in addition to saving information from the processor 112.
  • the information may be saved in a memory.
  • the same type information is reloaded for the new task and provided to the pre-processor 130 and the processor 112.
  • the relevant pre-processor information includes the contents of the feeding memory 300, the counter 400 and the pointer 430.
  • the relevant pre-processor information includes the contents of the cache 550 and 630, respectively.
  • the relevant elements of the pre-processor 130 are of a type which can be read and set under control of the processor 112. It will be appreciated that as an alternative the cache 550 may be saved and restored by the pre-processor 130.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Advance Control (AREA)
  • Executing Machine-Instructions (AREA)
  • Devices For Executing Special Programs (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

A processing device comprises an instruction memory (120) for storing virtual machine instructions, such as Java byte codes. A processor (112) of the processing device comprises a predetermined microcontroller core (114) for executing native instructions from a predetermined set of microcontroller specific instructions. The native instructions differ from the virtual machine instructions. The processor (112) is of a type which may request re-feeding of a plurality of native instructions. For instance, the processor (112) may have a pipeline and/or instruction cache which after an interrupt need to be re-filled. The processing device comprises a pre-processor (130) with a converter (132) for converting at least one virtual machine instruction, fetched from the instruction memory, into at least one native instruction. Feeding means (136) of the pre-processor (130) feed native instructions to the micontroller core (114) and re-feed native instructions in response to the processor requesting re-feeding of a number of native instructions.

Description

A processing device for executing virtual machine instructions
The invention relates to a processing device for executing virtual machine instructions; the processing device comprising: an instruction memory for storing instructions including at least one of the virtual machine instructions; a microcontroller comprising a processor comprising a predetermined microcontroller core for executing native instructions from a predetermined set of microcontroller specific instructions; the native instructions being different from the virtual machine instructions; and a pre-processor comprising: a converter for converting at least one virtual machine instruction, fetched from the instruction memory into at least one native instruction; and feeding means for feeding native instructions to the microcontroller core for execution.
The invention further relates to a pre-processor for use with a microcontroller comprising a processor comprising a predetermined microcontroller core for executing native instructions from a predetermined set of microcontroller specific instructions; the pre-processor comprising: a converter for converting at least one virtual machine instruction, fetched from an instruction memory, into at least one native instruction; the native instructions being different from the virtual machine instructions; and feeding means for feeding native instructions to the microcontroller core for execution.
Increasingly, source programs are expressed in (compiled to) instructions of a virtual machine instead of native instructions of a microcontroller on which the program is to be executed. A main reason for using a virtual machine is portability of programs between different machines (platforms). A program expressed in the virtual machine instructions of the virtual machine can be executed relatively easily on several concrete machines, using suitable interpreters operating on those machines. At this moment a driving force for using portable programs is Java, where Java programs (referred to as applets) are exchanged via Internet and can be executed on different native machines using processors with different instruction sets. Using a compiler, Java applets are expressed in Java byte codes (JBCs), which form the instructions of the Java Virtual Machine. For embedded applications, a further driving force for using virtual machines is the need for compact code. As the size of software continuously grows, software compression techniques which, due to a certain initial costs, where not attractive before become feasible. One of such techniques is to choose a suitable virtual machine for a specific embedded application, such that the program can be expressed more compactly in the virtual machine instructions than in the native instructions. An example of such a virtual machine is a stack machine, which is known for its compact representation. A specific virtual machine for an embedded application can be defined by first expressing the source program in virtual machine instructions of a chosen virtual machine, such as a stack machine, and additionally, replacing sequences of virtual machine instructions which occur frequently in the compiled code by newly defined additional virtual machine instructions, where, for instance, one new instruction replaces a sequence of four existing instructions.
Conventionally, programs expressed in virtual machine instructions are executed by means of software interpretation. The processor (CPU) executes a special interpreter program, where in a loop the processor fetches a virtual machine instruction, decodes it into a sequence of native instructions of the microcontroller core of the processor and executes each native instruction. This technique is slow and requires an additional interpreter program, which can be relatively large. To improve the execution speed, the so- called Just-In-Time (JIT) compilation technique is used. Just before starting execution of software module expressed in virtual machine instructions, the module is compiled to native code (expressed in native machine instructions). In this way, the module needs to be stored twice in addition to the code for the compiler. The additional storage requirements of software interpretation are not desired for embedded systems. Instead it is preferred to use a hardware interpreter. In itself a hardware interpreter is known in the form of a Prolog pre- processor for Warren's abstract instruction set. In the paper "A Prolog pre-processor for Warren's abstract instruction set" by B. Knόdler and W. Rosenstiel, Microprocessing and Microprogramming 18 (1986) pages 71-81, a pre-processor is described for interpreting programs written in the Prolog programming language on a Motorola 68000 processor (MC68000). A compiler is used to translate the Prolog source program into instructions, which have been defined by Mr. Warren and which are generally used for executing Prolog programs. The set of Warren instructions forms a virtual machine designed for executing Prolog programs. The sequence of Warren instructions resulting from the compilation are executed by the MC68000 with the aid of the pre-processor. After power-on, the MC68000 first performs a booting procedure by executing native MC68000 instructions. At the end of the booting procedure, the MC68000 is ready to initiate the execution of a Prolog program. This is started by jumping to a predetermined address range. The pre-processor is a memory- mapped device, which is mapped to this range. When the pre-processor is addressed it reads a Warren instruction (of the translated Prolog program) from its own RAM, adaptively synthesizes a sequence of MC68000 instructions and constants and sends these directly to the CPU for execution. The MC68000 instructions for each Warren instruction are stored in ROM of the pre-processor. In general, the pre-processor translates one Warren instruction into a sequence of MC68000 instructions. The pre-processor contains its own RAM controller and ROM controller, which generate the addresses for the RAM and ROM of the pre-processor. The RAM controller manages the RAM instruction pointer. Each successive read operation of the MC68000 results in the pre-processor sending the next instruction (and optional constants) of the sequence to the CPU. If the sequence has been completed, a next read operation results in the first instruction of the sequence corresponding to the next Warren instruction of the program being send to the CPU. After an interrupt, a repeated read operation of the CPU results in re-sending the last instruction (and optional constants).
It is an object of the invention to provide a processor device of the kind set forth which is suitable for use with a microcontroller which contains more than one instruction at a time.
To achieve the object, the processor is of a type which after the occurrence of a predetermined condition, such as an interrupt, requests re-feeding of up to a predetermined maximum of n native instructions, where n > 1 ; and the feeding means comprises means for in response to the processor requesting re-feeding of a number of native instructions, re-feeding the requested native instructions. The inventor has realised that modern processors can comprise several native instructions at a time, where the execution of the instruction has not yet begun or has not yet been completed, and that in order to increase performance it is desired to exploit the capabilities of the processor of containing more than one instruction. The inventor had the insight that in order to cope with the situation in which the processor discards at least some of the already loaded instructions and at a later stage requests re-feeding of several instructions (e.g. on the occurrence of certain conditions, such as an interrupt), a re-feeding mechanism is required for re-feeding the requested native instructions to the processor.
According to the measure defined in the dependent claim 2, the preprocessor comprises a feeding memory, such as a FIFO, for storing last fed instructions and re- feeding from the feeding memory, providing a simple and effective way of re-feeding the instructions. In view of the fact that in general a virtual machine instruction is converted to a sequence of more than one native instruction, the first native instruction to be re-fed may be any instruction of the sequence. Moreover, the native instruction may correspond to an earlier virtual machine instruction than the current one. Finally, the sequence length may be different for different virtual machine instructions. Using the feeding memory makes it possible to simply re-feed native instructions from the memory instead of retracing virtual machine instructions and the corresponding native instructions.
According to the measure defined in the dependent claim 3, instructions being actively processed in the pipeline of the microcontroller can be re-fed. This makes the pre-processor particularly suitable for use in combination with a RISC-type processor which usually has a pipelined architecture.
According to the measure defined in the dependent claim 4, instructions stored in the instruction cache of the processor can be re-fed. This makes the pre-processor particularly suitable for use in combination with modern processors, such as RISC-type processors, which usually have an instruction cache.
According to the measure defined in the dependent claim 5, instruction stored in the cache or being processed in the pipeline can be re-fed.
According to the measure defined in the dependent claim 6, the feeding memory is capable of storing, in addition to instructions which may need to be re-fed, also instructions which are to be fed for the first time. In this way the pre-processor may in advance generate native instructions before the native instruction is actually requested, avoiding possible delays in feeding a first time requested instruction to the processor. Moreover, it allows the use of only one feeding mechanism which takes care of feeding first time requested instructions and of re-feeding instructions.
The measure defined in the dependent claim 7 shows a simple and effective way for unifying first time feeding and re-feeding. The instructions which have already been fed and the instruction(s) still to be fed are stored successively in the feeding memory, such as a FIFO. Logically the pre-processor maintains a pointer indicating a memory location in the feeding memory containing the instruction expected to be requested next (i.e. the first instruction which has not yet been requested before). In practice, this memory location may always be at a fixed position of the feeding memory, so that no separate pointer needs to be maintained. The pre-processor comprises a counter which indicates an address of the native instruction expected to be requested next by the processor for first time feeding. Normally, each time a native instruction has been fed for the first time, the counter is incremented. The processor indicates (using an instruction pointer) an address of the instruction required next by the processor. This may be a request for a first time feeding or a re-feeding of an instruction. The pre-processor compares the requested address to the address stored in the counter. Based on the offset, the instruction is located in the feeding memory. For instance, the counter may store the address of the instruction expected to be requested next, being one higher than the address of the instruction fed last. If indeed the processor requests this new instruction, the offset is zero. If the logical pointer points to the location of the new instruction, the instruction stored at this location is fed to the processor. If the processor requests re-feeding of the previous instruction, the offset may be one or minus one (counted in units of an instruction, which may be 4 counted in units of bytes for a 32-bit instruction). By subtracting (or respectively adding) the offset from the pointer the requested instruction is located. It will also be appreciated that the counter and the logical pointer do not need to store the exact address/location of the instruction expected to be requested next. For instance, the logical pointer may also indicate the last fed instruction.
The measure defined in the dependent claim 8 shows an alternative arrangement where no additional feeding memory is required. Instead the pre-processor stores state information which enable recreating the instructions requested by the processor for refeeding. As an example, instead of storing fed instructions in a feeding memory, also pointers indicating instructions or information used to initially create the instructions may be stored in a memory.
In the measure defined in the dependent claim 9, part of the state is stored in the instruction pointer of the microcontroller, potentially reducing the costs of the pre-processor.
In the measure defined in the dependent claim 10, the pre-processor comprises for at least one virtual machine instruction a corresponding translation table for translating the virtual machine instruction into a sequence of native instructions. The translation table may, for instance, be stored in ROM. The least significant part of the instruction pointer of the processor is used to indicate which of the native instructions in the table is required (i.e. the least-significant part of the instruction pointer acts as a translation table offset indicator). During normal operation, the processor automatically increments the instruction pointer. Advantageously, the pre-processor does not need to store an own counter and increment this counter for indicating the native instruction expected to be read next. If the processor requests a re-feeding, the processor will automatically set the instruction pointer to a previous value. In this way also re-feeding can be taken care of automatically.
The measure defined in dependent claim 11 provides an effective way for determining, in addition to the translation table offset, also the translation table in which the requested native instruction is located. A predetermined further part of the instruction pointer comprises a virtual machine instruction pointer indicating a virtual machine instruction in the instruction memory. This virtual machine instruction pointer can be seen as a virtual machine program counter, which needs to be incremented each time a new virtual machine instruction is required. The pre-processor fetches the virtual machine instruction indicated by the virtual machine instruction pointer from the instruction memory and based on the fetched virtual machine instruction locates the translation table. The least significant pan of the instruction pointer of the processor is then used as an offset in the translation table. Whenever a sequence of native instructions relating to one virtual machine instruction has been completed, the virtual machine instruction pointer can be set to indicate the next virtual machine instruction, for instance, by using as a last native instruction in the sequence an explicit jump which sets the virtual machine instruction pointer to the desired value and resets the translation offset part of the instruction pointer or using one or more NOP (no operation) instructions so that eventually an overflow of the translation offset part results in the processor incrementing the virtual machine instruction pointer. It will be appreciated that it is not required that each request from the processor for an instruction results in fetching a virtual machine instruction from the instruction memory. Advantageously, the pre-processor comprises a cache for storing already fetched or expected to be fetched virtual machine instructions from the instruction memory.
Advantageously, as an alternative to a full native instruction the translation table contains a native instruction skeleton for at least native instructions with variable parts. The skeleton comprises predetermined fixed parts of the native instruction, such as the operation code, whereas variable elements of the instruction, such as certain operands, are loaded adaptively, for instance from parameters of the corresponding virtual machine instruction. The measure defined in dependent claim 12, provides an alternative for the use of the virtual machine instruction pointer. In this embodiment the translation table is divided into several sub-tables, at least one of the sub-tables comprising a sequence of native instructions or native instruction skeletons. A sub-table may but does not need to correspond to a complete sequence of native instructions corresponding to one virtual instruction. In practice it may be preferred to choose a sub-table size of only 4 or 8 native instructions, which may be less than the maximum sequence of native instructions for a virtual machine instruction. The translation table offset indicator indicates an offset in one of the sub-tables. A predetermined further part of the instruction pointer comprises a sub-table indicator. The pre-processor uses the value of the sub-table indicator to locate the actually involved sub- table. Preferably, in normal operation the sub-table indicator is incremented by one unit each time a native instruction is fetched from a next sub-table (regardless of the sub-table being related to the same or different virtual machine instructions) . The pre-processor may store pointers to the related sub-table(s) for the last used sub-table indicators. Particularly for relatively small sub-tables, a sequence of native instructions relating to one virtual machine instruction may be complemented by NOP instructions in order to ensure that the sequence ends on a sub-table boundary (eliminating the use of jump operations to correct the value of the sub-table indicator part of the instruction pointer). Most processors can execute a NOP operation significantly faster than a jump operation. The measure defined in the dependent claim 13 ensures that no deadlock situation can occur wherein the processor has requested an instruction and blocks the bus until the instruction has been supplied, whereas the pre-processor first needs to obtain a (virtual machine) instruction from the instruction memory via the same bus before it can supply the native instruction. These and other aspects of the invention will be apparent from and elucidated with reference to the embodiments shown in the drawings.
Figure 1 illustrates four possible architectural options of locating the preprocessor in the processing device; Figure 2 shows a translation table for translating a virtual machine instruction into a sequence of native instructions;
Figure 3 shows a block diagram of an embodiment of the processing device wherein a feeding memory is used for re-feeding instructions;
Figure 4 illustrates a uniform way of feeding and re-feeding instructions; Figure 5 illustrates using the instruction pointer of the processor as an index into the translation table; and
Figure 6 shows an alternative use of the instruction pointer.
Figure 1 illustrates four possible architectural options of locating the pre- processor in the processing device 100. Three main components of the processing device 100, are the microcontroller 110, the instruction memory 120 and the pre-processor 130. In all figures the microcontroller 110 comprises the instruction memory 120 and the preprocessor 130. The processing device 100 is not shown explicitly. By combining all main elements in the microcontroller 110, which preferably is a one-chip device, optimum performance can be achieved. It will be appreciated that, if desired, the instruction memory 120 and/or the pre-processor 130 may be located outside the microcontroller 110, where the microcontroller bus 140 is extended outside the microcontroller 110 and, for instance, coupled to an external bus such as PCI. The instruction memory 120 contains virtual machine instructions, such as instructions for a stack machine. An example of such virtual machine instructions are Java bytecodes. The microcontroller 110 comprises a processor 112 with a predetermined microcontroller core 114, referred to as a native machine, for executing native instructions from a predetermined set of microcontroller specific instructions. An example of a microcontroller suitable for executing embedded software is a RISC-type microcontroller, like the MIPS PR3001 range of microprocessors. The native instructions of the microcontroller core 114 are different from the virtual machine instructions of the virtual machine. As such the microcontroller 110 is not able to directly execute virtual machine instructions stored in the instruction memory 120. In response to the processor 110 requesting an instruction, the pre-processor 130 issues the native instruction. In order to be able to generate the native instruction the pre-processor 130 may fetch a virtual machine instruction from the instruction memory 120 using fetching means 134. The pre-processor 130 comprises a converter 132 for converting a virtual machine instruction, fetched from the instruction memory 120, into at least one native instruction. In general, a virtual machine instruction is converted to a sequence of native instructions. The pre-processor 130 further comprises a feeding means 136 for feeding native instructions of the sequence to the microcontroller core for execution. When executing a virtual machine program the microcontroller 110 in fact executes a native program generated by the pre-processor 130. Where normally an instruction pointer of the microcontroller 110 indicates the next instruction in the instruction memory 120 required by the microprocessor 110 to be executed next, now the instruction pointer indicates to the pre-processor 130 that a next native instruction is required (or a re-feeding of a previous instruction). Logically, the pre-processor 130 manages an independent virtual machine instruction pointer indicating the current (or next) virtual machine instruction in the instruction memory 120. The microcontroller has no (explicit) knowledge of the virtual machine instruction or the virtual machine instruction pointer.
The processor 112 is of a type which after the occurrence of a predetermined condition requests re-feeding of up to a predetermined maximum of n native instructions, where n > 1. Such a condition may be an interrupt, causing the processor to discard instructions already in the processor. A processor 112 with a k-stage pipelined will normally operate on k instructions at a time. The occurrence of the condition may result in discarding all k instructions. A further reason for discarding more than one instruction is where the processor comprises an instruction cache 116 for storing up to h instructions. The occurrence of the condition may result in discarding all h instructions in the cache 116. At a later stage, the processor 112 may return to the execution of the virtual machine program and request re-feeding of more than one instruction. To this end, the feeding means 136 comprises means for in response to the processor 112 requesting re-feeding of a number of native instructions, re-feeding the requested native instructions. It will be appreciated that the instruction memory 120 may also contain native instructions. Such native instructions may for instance be used to initialise the system or to allow certain software modules, such as drivers or special parts of the embedded software application, to be compiled to native instructions for optimal performance. A distinction between native instructions and virtual machine instructions in the instruction memory 120 may be made on the address of the instruction, where a predetermined range of addresses is allocated for virtual machine instructions. Other alternatives include using a special bit for each instruction indicating whether the instruction is a native instruction or a virtual machine instruction; or using a special register which indicates the current type of instruction, where the content of the register needs to be changed each time a change of type occurs. The pre-processor 130 ensures that native instructions are passed from the instruction memory 120 to the processor 112 unmodified.
In Fig. 1A the main components of the processing device are interconnected via a general peripheral interconnect bus 140, such as the PI bus. The preprocessor 130 is a peripheral on the bus. The pre-processor 130 may act as a memory - mapped peripheral, where a predetermined range of addresses is allocated to the preprocessor. In response to the processor 110 issuing on the bus 140 a request for an instruction with an address in this range, the pre-processor 130 issues the native instruction on the bus 140. When required, the pre-processor 130 fetches a virtual machine instruction from the instruction memory 120 via the bus 140. In Figs. IB and 1C, the pre-processor 130 is located in between the microcontroller 110 and the instruction memory 120. If the pre-processor 130 needs to distinguish between native and virtual machine instructions, these configurations may delay execution of native instructions stored in the instruction memory 120. For reasons of clarity not all elements shown in Fig. 1A are repeated in Fig. IB, 1C and ID.
In Fig. ID, the pre-processor 130 is embedded in the microcontroller 110. The pre-processor 130 is preferably located between an instruction cache 116 of the microcontroller 110 and the core 114. This configuration allows for optimal performance but, unlike the configurations of Figs 1A, IB and 1C, requires changes to the microcontroller 110 and, as such, the pre-processor 130 can not as an off-the-shelf design be used for different types of microcontrollers.
The converter 132 is used for converting a virtual machine instruction, fetched from the instruction memory 120, into at least one native instruction. As an example, the Java byte code (a virtual machine instruction) for integer addition (0x60) results in adding the two top elements of the stack, removing the two top elements from the stack and pushing the sum on the stack. This virtual machine instruction may be converted to the following sequence of instructions (native instructions) for a MIPS processor (a 32-bits machine), where $tosp is a register pointing to the first empty location of the stack (above the top of stack): lw $a0, 4 ($tosp) /* load the top element of the stack in register $a0 lw $al, 8 ($tosp) /* load the second element of the stack in Sal add $a0, Sal, $a0 /* add $a0 and Sal, place the sum in $a0 addi $tosp, $tosp, 4/* lower the stack by one element sw $a0, 4 (Stosp) /* store the sum in the new top of stack Preferably, the converter 132 comprises a table for converting a virtual machine instruction to a sequence of native instructions. A one dimensional table may be used, where each cell of the table comprises a sequence of native instructions for one corresponding virtual machine instruction. The cell number may correspond to the value of the corresponding virtual machine instruction. As an example, the sequence of native instructions for the Java integer addition (0x60) may be located in cell 96 (= 0x60 in hexadecimal notation). Since the length of the sequence of native instructions may vary considerably for the various virtual instructions, preferably the sequences are located in a one-dimensional table without any explicit cells where the sequences immediately follow each other. Such a translation table 200 is shown in Fig. 2, where the implicit cell boundaries are indicated using dotted lines. In order to be able to locate a sequence for a virtual machine instruction a code index table 210 may be used, which for each virtual machine instruction (VMI 1 to VMI N) indicates the starting point of the corresponding sequence in the translation table 200. For the cell of the translation table 200 which corresponds to VMI 3 the related sequence 220 of native instruction NI 1 to NI M are shown.
A further example of a conversion is given for the Java byte code bipush n (used for sign extending byte n and placing the result on top of the stack). This virtual machine instruction consists of two bytes {0x16 and ή), where the first byte specifies the operation and the second byte provides the parameter n. The instruction may be converted to the following sequence of native MIPS instructions: ori $a0, $0, n /* Load register $a0 with constant n */ sll $a0, $a0, 24 /* Shift left by 24 bits */ sra $a0, $a0, 24 /* Arithmetic shift right, causing sign extension, by /* replicating last left-most bit */ sw $a0, 0 (Stosp) /* Store result at new top of stack */ addi Stosp, -4 /* Increment stack size */
This example illustrates that a virtual machine instruction may be parameterised, where an operation code is followed by at least one operand. Advantageously, the converter 132 comprises a translation table 200, where native instructions are represented either by the full code or by an instruction skeleton. As an example, the instruction addi Stosp, -4 (last instruction of the sequence of the previous example) contains no variable parts and may be located in full as a 4-byte entry in the table. The instruction ori $a0, $0, n (first instruction of the sequence of the previous example) contains a variable part and may be located in the table as a skeleton, not specifying the variable part (being ή). Preferably, the entry in the table for an instruction skeleton is the same width as a full instruction (e.g. 4-bytes for a MIPS processor), allowing a uniform table. Further information may be located in the table (or in separate table(s)) for indicating how the unspecified part of the native instruction skeleton should be filled in. Advantageously, microprogramming is used to fill in the unspecified parts. The further information may then comprise or indicate micro code. It will be appreciated that it is advantageous to use for an instruction skeleton a same structure (width and composition) as for a full native instruction. However, other structures may be used as well.
If the virtual machine is a stack oriented machine, preferably the stack or at least the top elements of the stack are mapped onto registers of the microcontroller 110. In this way the memory stack (with the virtual machine stack) is mapped to the register stack. Assuming that registers $rl, $r2 and $r3 contain three successive elements of the memory stack, where initially $rl corresponds to the first empty location of the memory stack (above the top of the stack), $r2 contains the top of the memory stack, and $r3 contains the second element of the memory stack, the Java byte code bipush n may be converted to the following sequence of native MIPS instructions: ori $rl, $0, n sll $rl, $rl, 24 sra $rl, $rl, 24 After this operation, $rl contains the top of the memory stack.
Similarly, the Java byte code (a virtual machine instruction) for integer addition (0x60) may be converted to the following sequence of MIPS instructions, starting from the same position where initially $rl corresponds to the first empty location of the memory stack (above the top of the stack), $r2 contains the top of the memory stack, and $r3 contains the second element of the memory stack: add $r3, $r2, $r3 After this operation, $r3 contains the top of the memory stack.
In above examples, preferably the position of the top of the memory stack (i.e. which register contains the top of the memory stack) is indicated using a register 138 of the converter 132. The converter uses the register 138, referred to as the Register Stack Pointer (RSP), to generate the appropriate native instructions. Preferably, microprogramming is used to specify the register operands of the native instructions. In this way also fixed native instructions have become variable, since the register operands need to be specified by the converter 132. Preferably, such operands are also stored in the translation table 200 using instruction skeletons. Assuming that RSP points to the first free register, the Java byte code bipush n may be converted to the following sequence of native MIPS instructions under control of the corresponding micro code: Micro code Instructions rsp -= 1; ftg = rsp + 1 ori $(rsp + 1), $0, n ftg = rsp + 1; fao = rsp + 1 sll $(rsp + 1), $(rsp + 1), 24 ftg = rsp -I- 1; fa0 = rsp + 1 sra $(rsp + 1), $(rsp + 1), 2 where ftg indicates the target register for the instruction, and fa0 and fa, indicate the first and, respectively, second argument register for the instruction. A following Java byte code iadd for adding the two top elements of he stack would result in the following micro code and instruction: ftg = rsp + 2; fao = rsp + 2; fal = rsp + 1; rsp + = 1 add $(rsp + 2), $(rsp + 2), $(rsp + 1)
Figure 3 illustrates an embodiment according to the invention wherein the pre-processor 130 comprises a feeding memory 300. The feeding memory 300 comprises a part 310 for storing at least n instructions which were last fed to the processor (n being the maximum number of native instructions of which the processor could request re-feeding). In response to the processor 112 requesting re-feeding of a number of instructions, the feeding means 136 re-feeds the requested instructions from the feeding memory 300. Preferably, the feeding memory part 310 has a FIFO function 136. Each time an instruction is fed to the processor 112 for the first time, the instruction is loaded into the part 310 and, if the part 310 is full, the oldest instruction is removed. Advantageously, for a microcontroller with a k- stage pipeline n is equal to or larger than k. Similarly, for a processor with an instruction cache for storing up to h instructions n is equal to or larger than h. If both a k-stage pipeline and an instruction cache for storing up to h instructions, n is preferably equal to or larger than k + h.
In a further embodiment according to the invention, the feeding memory 300 comprises memory locations 320 for storing a further m native instructions, where m > 1. This allows the pre-processor 130 to generate up to m native instructions in advance for first time feeding to the processor and to store the additional instructions also in the feeding memory 300. Preferably, the part 320 of the feeding memory 300 has a FIFO function. Each time an instruction is fed to the processor 112 this instruction is removed from part 320 and inserted into part 310. The pre-processor 130 inserts the instructions in the part 320. Preferably the two memory parts 310 and 320 of the feeding memory 300 are be combined. This may be implemented using one unified FIFO. Other alternatives, such as cyclic buffers with corresponding pointer, may also be used.
In a further embodiment according to the invention a unified mechanism is used for first time feeding and re-feeding of native instructions from the feeding memory 300 to the processor 112. The feeding memory 300 stores instructions to be successively first-time fed (part 320) or re-fed (part 310) in a successive manner, as illustrated in Fig.4. The pre-processor 130 comprises a counter 400 which indicates an address of a native instruction expected to be requested next by the processor for first time feeding. The counter 400 can be seen as the expected instruction pointer. The pre-processor 130 receives from the processor an actual instruction pointer 410 which indicates the actually requested native instruction. This may be the expected instruction, but may also be an already fed instruction. The pre-processor 130 comprises means to determine an offset of an actual address of an instruction (410) requested by the processor with respect to the address stored in the counter 400. Shown is a subtracter 420 for subtracting the expected and the received instruction pointer. If the received instruction pointer is subtracted from the expected instruction pointer, the outcome will range from 0 to n, where 0 indicates that the first new instruction is requested and the other values indicate a request for re-feeding. Based on the offset, the instruction is located in the feeding memory 300 and fed to the processor 112. Preferably the locating is performed by combining the offset with a value of a pointer to the feeding memory 300. Shown is a pointer 430 which indicates the first native instruction which has not yet been fed to the processor 112 (i.e. the instruction expected to be fed under normal circumstances). A subtracter 440 subtracts the offset from the value of the pointer 430. The resulting value points to the desired instruction. After the pre-processor 130 has compared the expected and the received instruction pointers the expected instruction pointer is normally set to the received instruction pointer + 1 instruction (for a 4-byte instruction this may imply incrementing the counter 400 by 4). Depending on the arrangement chosen for the feeding memory 300 it may be required to increment the value of the pointer 430 by one each time an instruction is fed for the first time to the processor 112. If for instance a shift register is used for the feeding memory where a first time feeding of an instruction results in a shift, this is not required.
As an alternative to an alternative to the use of the feeding memory 300, the pre-processor 130 comprises storing means for storing a state of the pre-processor enabling to regenerate at least n instructions which were last fed to the processor. For instance, the pre-processor 130 could comprises a memory similar to the feeding memory 130 for storing pointers to the last fed n instructions or other state information allowing any of these instructions to be located or otherwise regenerated. The feeding means 136 is operative to, in response to the processor requesting re-feeding of a number of instructions, re-feeding the requested instructions by regenerating the instructions based on the stored state. Advantageously, in a further embodiment the storing means is operative to store at least part of the state in an instruction pointer of the microcontroller. This can be simply performed by issuing a jump instruction to the microcontroller which set the instruction pointer to a value reflecting the part of the state. The feeding means 136 is operative to retrieve the stored part from the instruction pointer. Fig. 5 illustrates storing part of the state in the instruction pointer. The pre-processor 130 comprises for at least one virtual machine instruction a corresponding translation table for translating the virtual machine instruction into a sequence of native instructions. The translation table may, for instance, be stored in ROM. The translation table may be a cell 220 of the table described earlier and for which an example is shown in Fig.2. In this alternative embodiment, the least significant part of the instruction pointer of the processor is used to indicate which of the native instructions (e.g. NI 1 to NI n) in the table is required (i.e. the least-significant part of the instruction pointer acts as a translation table offset indicator). This part may, for instance, be 5-bit wide, allowing for a maximum of 32 native instructions for a virtual machine instruction without using further measures. During normal operation, the processor 112 automatically increments the instruction pointer. Advantageously, the pre-processor 130 does not need to store an own counter, like counter 400, and increment this counter for indicating the native instruction expected to be read next. If the processor requests a re-feeding, the processor 112 will automatically set the instruction pointer to a previous value. In this way also re-feeding can be taken care of automatically. Fig. 5 shows a structure of the instruction pointer 500 of the processor 112, where the least significant part 510, starting at the least significant bit (LSB) is used for the translation table offset indicator. The pre-processor 130 comprises means 540 for extracting the translation table offset indicator 510 from the instruction pointer 500 (this may same involve an XOR operation on the instruction pointer 500 with a predetermined bit mask with ' l'-bits at the position of the part 510 and 'O'-bits for the other part(s). The extracted part may directly be used as a pointer into the translation table or used as an offset.
In a further embodiment, a predetermined further part 520 of the instruction pointer 500 comprises a virtual machine instruction pointer indicating a virtual machine instruction in the instruction memory 120. This virtual machine instruction pointer 520 can be seen as a virtual machine program counter, which needs to be incremented each time a new virtual machine instruction is required. If the pre-processor 130 is a memory mapped peripheral, one or more of the most significant bits of the instruction pointer 500 are reserved for indicating the address range reserved for the pre-processor 130. In principle, the remaining bits may be used for the part 520. Preferably this part is at least 16 bit wide, allowing for 64 KB blocks of virtual machine program. Also the Register Stack Pointer 138 of Fig. 1A may be encoded in the instruction pointer, eliminating the need for the preprocessor 130 to maintain this pointer.
The pre-processor 130 comprises means 530 for extracting the virtual machine instruction pointer 520 from the instruction pointer 500. The pre-processor 130 fetches the virtual machine instruction indicated by the extracted virtual machine instruction pointer from the instruction memory 120. Based on the fetched virtual machine instruction the pre-processor 130 locates the translation table. The least significant part 510 of the instruction pointer 500 of the processor is then used as an offset in the translation table. Means 540 are used for extracting the least significant part 510 from the instruction pointer 500. Preferably, the translation tables for the respective virtual machine instructions are combined into one sequential table, where a cell is reserved for native instructions corresponding to one virtual machine instruction. Such a table has been described before and an example 200 has also been shown in Fig. 2. An index table 210, as described earlier, may be used for locating the relevant part of the translation table 200 for each virtual machine instruction. Adding means 560 may be used for adding the output of the index table 200 (i.e. a cell address of the translation table 200) to the translation table offset (output of the extracting means 540). Advantageously, the pre-processor 130 comprises a cache 550 for storing already fetched or expected to be fetched virtual machine instructions from the instruction memory 120. Whenever a sequence of native instructions relating to one virtual machine instruction has been completed, the virtual machine instruction pointer can be set to indicate the next virtual machine instruction, for instance, by using as a last native instruction in the sequence an explicit jump which sets the virtual machine instruction pointer to the desired value and resets the translation offset part of the instruction pointer. Advantageously, the part 520 of the instruction pointer is the next higher part in significance compared to the part 510. In this way, the virtual machine instruction pointer can also be incremented by using one or more NOP (no operation) instructions so that eventually an overflow of the translation offset part 510 results in the processor 112 incrementing the virtual machine instruction pointer. Depending on the processor, it may be faster to execute one or more NOP instructions than a jump. It will be appreciated that it is not required that each request from the processor 112 for a native instruction results in the pre-processor 130 fetching a virtual machine instruction from the instruction memory 120.
In an alternative embodiment shown in Fig. 6, the translation table 600 is divided into several sub-tables; shown are sub-tables 602, 604, 606, 608, and 609. Each sub- table comprises at least one native instruction or native instruction skeleton, where at least one of the sub-tables comprises a sequence of native instructions or native instruction skeletons. Advantageously, a sequence of native instructions for a virtual machine instruction starts at the first entry of a sub-table. The sub-table may, but does not need to, correspond to a complete sequence of native instructions corresponding to one virmal machine instruction. The sub-table may be shorter than the sequence, in which case it is preferred that the sequence continues in the sequentially next sub-table. In practice it may be preferred to choose a sub-table size of only 4 or 8 native instructions, which may be less than the maximum sequence of native instructions for a virtual machine instruction. The translation table offset indicator 510 indicates an offset in one of the sub-tables. A predetermined further part 620 of the instruction pointer 500 comprises a sub-table indicator. The pre-processor 130 uses the value of the sub-table indicator 620 to locate the actually involved sub-table. To this end, the pre-processor 130 comprises means 610 for extracting the sub-table indicator 620 from the instruction pointer 500. Preferably, in normal operation the sub-table indicator is incremented by one unit each time a native instruction is fetched from a next sub-table (regardless of the sub-table being related to the same or different virtual machine instructions). As an example, assume that the sequence of a first virmal machine instruction is stored in the successive sub-tables with respective sub-table numbers of 110, 111, and 112; that the next virmal machine instruction is stored in sub-tables 85 and 86, and that a third virtual machine instruction is stored in sub-tables 41 and 42. If the sub-table size is 4 entries (using a 2-bit translation table offset indicator 510), the first series of four native instructions (of sub-table with number 110) may be indicated by, for instance, a sub-table indicator 620 value of 1 , where the translation table offset indicators runs from 0 to 3. The second series of four native instructions (of sub-table with number 111) will then be indicated by a sub- table indicator 620 value of 2. The third series will be indicated by a sub-table indicator 620 value of 3. The fourth series (although relating to a different virtual machine instruction) will be indicated by the next value of the sub-table indicator 620, being 4. Advantageously, the pre-processor 130 comprises a cache 630 for storing pointers to the related sub-table(s) for the last used sub-table indicators. In this example, the cache would store:
sub-table indicator sub-table number
1 110
2 111
3 112
4 85
Preferably, the sub-tables have equal size. If so, for the purpose of re-feeding, an instruction can be located by, based on the sub-table indicator 620, locating the sub-table number in the cache 630, multiplying the sub-table number by the size, and adding the translation table offset 510. Advantageously, the sub-tables have an equal size which is a power of 2. By using a translation table offset indicator 510 with a corresponding length (a k-bit indicator corresponds to a sub-table size of 2k), the sub-table indicator will be incremented automatically (as a result of an overflow of the translation table offset indicator 510) each time all instructions of a sub-table have been dealt with. At the end of a sequence of native instructions for one virtual machine instruction, additional NOP instruction(s) may be used to complement the sequence to end at the boundary of the sub-table. In this way, the sub-table indicator 620 will also be automatically incremented to a correct value for successive sequences of instructions. Alternatively a jump instruction may be used, which resets the translation table offset indicator 510 and increments the sub-table indicator 620. For variable size sub-tables, a separate index table, similar to table 210, may be used for locating the starting address of a sub-table based on the sub-table number.. In practice it may be possible to use a very small sub-table indicator 620. For a processor which requests re-feeding of up to 16 instructions and using sub-tables with 4 entries, it is sufficient to use a 2-bit sub-table indicator 620. In this example, the cache 630 only needs to have 4 entries.
It will be appreciated that for the sub-table indicator 620 also the actual sub-table number may be used. In this case, however, jumps are required to set the sub-table indicator 620 to the correct value, for instance if a different sequence is started. Also the size of the sub-table indicator 620 will have to be larger, to be able to represent all sub-table numbers. Using such an arrangement, the combination of the sub-table indicator 620 and the translation table offset indicator 510 can directly indicate an entry in the table 600, making the cache 630 redundant.
In a further embodiment according to the invention, the microcontroller 110 comprises the instruction memory 120 and the pre-processor 130. The processor 112 , the instruction memory 120 and the pre-processor 130 being coupled via an atomic- transaction microcontroller bus 140. With an atomic transaction bus is meant a bus on which a device in order to perform a read operation, such as fetching an instruction, performs the following sequence of steps:
- the device obtains exclusive access to the bus,
- the device requests data (such as an instruction) by putting a request on the bus, - the device obtains the data when another device has put the data on the bus,
- the device releases the bus, allowing other devices access to the bus.
The processor 112 requests (re-)feeding of native instructions via the bus 140 . The preprocessor 130 fetches virmal machine instructions from the instruction memory 120 also via the bus 140 for conversion to associated native instruction(s) . Without special precautions, a deadlock can occur if the processor 112 has requested a native instruction and blocks the bus 140 until the instruction has been supplied, whereas the pre-processor 130 first needs to obtain a (virmal machine) instruction from the instruction memory 120 via the same bus 140 before it can supply the native instruction. To avoid such a situation, the pre-processor 130 comprises means for, in response to the processor 112 requesting (re-)feeding of a native instruction whose associated virtual machine instruction is not or no longer present in the pre-processor 130, feeding a no-operation (NOP) instruction to the processor 112 completing the bus transaction initiated by the processor 112.
Advantageously, the processing device 100 is capable of executing virtual machine instructions of more than one program. For instance, the processing device 100 supports a plurality of tasks expressed in virtual machine instructions. Optionally, some of the tasks may also be expressed in native instructions. Preferably, the support for multiple virtual machine tasks is implemented by a task switching routine in the operating system running on the microcontroller 110. When a task switch is triggered (e.g. driven by a timer interrupt and handled by a task switching interrupt handling routine), information relevant for the currently active task is saved from the pre-processor 130 in addition to saving information from the processor 112. The information may be saved in a memory. The same type information is reloaded for the new task and provided to the pre-processor 130 and the processor 112. In the embodiments shown in Figures 3 and 4, the relevant pre-processor information includes the contents of the feeding memory 300, the counter 400 and the pointer 430. In the embodiments shown in Figures 5 and 6, the relevant pre-processor information includes the contents of the cache 550 and 630, respectively. To enable saving and restoring the information, the relevant elements of the pre-processor 130 are of a type which can be read and set under control of the processor 112. It will be appreciated that as an alternative the cache 550 may be saved and restored by the pre-processor 130.

Claims

CLAIMS:
1. A processing device for executing virmal machine instructions; the processing device comprising: an instruction memory for storing instructions including at least one of the virmal machine instructions; a microcontroller comprising a processor comprising a predetermined microcontroller core for executing native instructions from a predetermined set of microcontroller specific instructions; the native instructions being different from the virtual machine instructions; and a pre-processor comprising: a converter for converting at least one virtual machine instruction, fetched from the instruction memory into at least one native instruction; and feeding means for feeding native instructions to the microcontroller core for execution; characterised in that: the processor is of a type which after the occurrence of a predetermined condition, such as an interrupt, requests re-feeding of up to a predetermined maximum of n native instructions, where n > 1; and the feeding means comprises means for in response to the processor requesting re-feeding of a number of native instructions, re-feeding the requested native instructions.
2. A processing device as claimed in claim 1, characterised in that the preprocessor comprises a feeding memory for storing at least n instructions which were last fed to the processor; and in that the feeding means is operative to, in response to the processor requesting re-feeding of a number of instructions, re-feeding the requested instructions from the feeding memory.
3. A processing device as claimed in claim 2, wherein the microcontroller is of a pipelined architecture, with a k-stage pipeline and n is equal to or larger than k.
4. A processing device as claimed in claim 2, wherein the processor comprises an instruction cache for storing up to h instructions and n is equal to or larger than h.
5. A processing device as claimed in claim 2, wherein the microcontroller is of a pipelined architecture, with a k-stage pipeline, and the processor comprises an instruction cache for storing up to h instructions; and n is equal to or larger than k + h.
6. A processing device as claimed in claim 2, wherein the feeding memory comprises locations for storing at least n + m native instructions, where m > 1 and the preprocessor is operative to generate and store in the feeding memory up to m native instructions for first-time feeding to the processor.
7. A processing device as claimed in claim 6, wherein instructions to be successively fed or re-fed to the processor are stored successively; and the pre-processor comprises: a counter indicating an address of an instruction expected to be requested next by the processor for first time feeding; means to determine an offset of an actual address of an instruction requested by the processor with respect to the address stored in the counter; and based on the offset locating the requested instruction in the feeding memory.
8. A processing device as claimed in claim 1, characterised in that the pre- processor comprises storing means for storing a state of the pre-processor enabling to regenerate at least n instructions which were last fed to the processor; and in that the feeding means is operative to, in response to the processor requesting re-feeding of a number of instructions, re-feeding the requested instructions by regenerating the instructions based on the stored state.
9. A processing device as claimed in claim 8, characterised in that the storing means is operative to store at least part of the state in an instruction pointer of the microcontroller; and in that the feeding means is operative to retrieve the stored part from the instruction pointer.
10. A processing device as claimed in claim 9, characterised in that the pre- processor comprises for at least one virtual machine instruction a corresponding translation table for translating the virtual machine instruction into a sequence of native instructions; the table comprising native instructions and/or native instruction skeletons; in that the state comprises a translation table offset indicator; and in that the storing means is operative to store the translation table offset indicator in a predetermined least-significant part of the instruction pointer of the microcontroller; and in that the feeding means is operative to locate a native instruction or a native instruction skeleton in the translation table under control of the translation table offset indicator in the instruction pointer.
11. A processing device as claimed in claim 10, characterised in that the state further comprises a virmal machine instruction pointer indicating a virtual machine instruction in the instruction memory; and in that the storing means is operative to store the virtual machine instruction pointer in a predetermined further part of the instruction pointer of the microcontroller; and in that the pre-processor comprises means for fetching a virtual machine instruction from a location in the instruction memory indicated by the virtual machine instruction pointer in the instruction pointer of the microcontroller, and in that the feeding means is operative to locate the translation table corresponding to the fetched virtual machine instruction.
12. A processing device as claimed in claim 10, characterised: in that the translation table is divided into a plurality of sub-tables, at least one of the sub-tables comprising a sequence of native instructions or native instruction skeletons; in that the translation table offset indicator indicates an offset in a sub- table; in that the state further comprises a sub-table indicator; and in that the storing means is operative to store the sub-table indicator in a predetermined further part of the instruction pointer of the microcontroller; and in that the feeding means is operative to locate a native instruction or native instruction skeleton at a location in the sub-table indicated by the sub-table indicator of the instruction pointer and the translation table offset indicator of the instruction pointer.
13. A processing device as claimed in claim 1, wherein the microcontroller comprises the instruction memory and the pre-processor; the processor, instruction memory and pre-processor being coupled via an atomic-transaction microcontroller bus; the microcontroller being of a type requesting (re-)feeding of a native instruction via the bus and the pre-processor being operative to fetch a virtual machine instruction from the instruction memory via the bus for conversion to associated native instruction(s); and wherein the preprocessor comprises means for, in response to the processor requesting (re-)feeding of a native instruction whose associated virtual machine instruction is not or no longer present in the pre-processor, feeding a no-operation (NOP) instruction to the processor completing the bus transaction initiated by the processor.
14. A pre-processor for use with a microcontroller comprising a processor comprising a predetermined microcontroller core for executing native instructions from a predetermined set of microcontroller specific instructions; the pre-processor comprising: a converter for converting at least one virtual machine instruction, fetched from an instruction memory, into at least one native instruction; the native instructions being different from the virtual machine instructions; and feeding means for feeding native instructions to the microcontroller core for execution; characterised in that the feeding means comprises means for in response to the processor requesting re-feeding of more than one native instruction, re-feeding the requested native instructions.
EP98940511A 1997-10-02 1998-09-17 A processing device for executing virtual machine instructions Expired - Lifetime EP0950216B1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP98940511A EP0950216B1 (en) 1997-10-02 1998-09-17 A processing device for executing virtual machine instructions
EP03101820A EP1359501A3 (en) 1997-10-02 1998-09-17 A processing device for executing virtual machine instructions

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
EP97203033 1997-10-02
EP97203033 1997-10-02
EP98940511A EP0950216B1 (en) 1997-10-02 1998-09-17 A processing device for executing virtual machine instructions
PCT/IB1998/001432 WO1999018484A2 (en) 1997-10-02 1998-09-17 A processing device for executing virtual machine instructions

Related Child Applications (2)

Application Number Title Priority Date Filing Date
EP03101820A Division EP1359501A3 (en) 1997-10-02 1998-09-17 A processing device for executing virtual machine instructions
EP03101820.3 Division-Into 2003-06-20

Publications (2)

Publication Number Publication Date
EP0950216A2 true EP0950216A2 (en) 1999-10-20
EP0950216B1 EP0950216B1 (en) 2003-11-26

Family

ID=8228783

Family Applications (2)

Application Number Title Priority Date Filing Date
EP03101820A Withdrawn EP1359501A3 (en) 1997-10-02 1998-09-17 A processing device for executing virtual machine instructions
EP98940511A Expired - Lifetime EP0950216B1 (en) 1997-10-02 1998-09-17 A processing device for executing virtual machine instructions

Family Applications Before (1)

Application Number Title Priority Date Filing Date
EP03101820A Withdrawn EP1359501A3 (en) 1997-10-02 1998-09-17 A processing device for executing virtual machine instructions

Country Status (5)

Country Link
US (2) US6349377B1 (en)
EP (2) EP1359501A3 (en)
JP (1) JP3945829B2 (en)
DE (1) DE69820027T2 (en)
WO (1) WO1999018484A2 (en)

Families Citing this family (49)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6513156B2 (en) * 1997-06-30 2003-01-28 Sun Microsystems, Inc. Interpreting functions utilizing a hybrid of virtual and native machine instructions
WO2000034854A2 (en) * 1998-12-08 2000-06-15 Koninklijke Philips Electronics N.V. Method of executing an interpreter program
US6826749B2 (en) * 1998-12-08 2004-11-30 Nazomi Communications, Inc. Java hardware accelerator using thread manager
US7225436B1 (en) 1998-12-08 2007-05-29 Nazomi Communications Inc. Java hardware accelerator using microcode engine
US6332215B1 (en) 1998-12-08 2001-12-18 Nazomi Communications, Inc. Java virtual machine hardware for RISC and CISC processors
WO2001061477A1 (en) * 2000-02-14 2001-08-23 Chicory Systems, Inc. Predecoding instructions to determine stack change information
GB2367653B (en) 2000-10-05 2004-10-20 Advanced Risc Mach Ltd Restarting translated instructions
GB2367654B (en) 2000-10-05 2004-10-27 Advanced Risc Mach Ltd Storing stack operands in registers
US20020069402A1 (en) * 2000-10-05 2002-06-06 Nevill Edward Colles Scheduling control within a system having mixed hardware and software based instruction execution
GB2367651B (en) * 2000-10-05 2004-12-29 Advanced Risc Mach Ltd Hardware instruction translation within a processor pipeline
EP1197847A3 (en) * 2000-10-10 2003-05-21 Nazomi Communications Inc. Java hardware accelerator using microcode engine
US6996813B1 (en) * 2000-10-31 2006-02-07 Sun Microsystems, Inc. Frameworks for loading and execution of object-based programs
GB2369464B (en) 2000-11-27 2005-01-05 Advanced Risc Mach Ltd A data processing apparatus and method for saving return state
US7076771B2 (en) 2000-12-01 2006-07-11 Arm Limited Instruction interpretation within a data processing system
US7162621B2 (en) * 2001-02-21 2007-01-09 Mips Technologies, Inc. Virtual instruction expansion based on template and parameter selector information specifying sign-extension or concentration
US7181484B2 (en) * 2001-02-21 2007-02-20 Mips Technologies, Inc. Extended-precision accumulation of multiplier output
US7711763B2 (en) * 2001-02-21 2010-05-04 Mips Technologies, Inc. Microprocessor instructions for performing polynomial arithmetic operations
US7096466B2 (en) 2001-03-26 2006-08-22 Sun Microsystems, Inc. Loading attribute for partial loading of class files into virtual machines
US7020874B2 (en) * 2001-03-26 2006-03-28 Sun Microsystems, Inc. Techniques for loading class files into virtual machines
US7543288B2 (en) 2001-03-27 2009-06-02 Sun Microsystems, Inc. Reduced instruction set for Java virtual machines
US6957428B2 (en) 2001-03-27 2005-10-18 Sun Microsystems, Inc. Enhanced virtual machine instructions
GB2376098B (en) * 2001-05-31 2004-11-24 Advanced Risc Mach Ltd Unhandled operation handling in multiple instruction set systems
GB2376100B (en) * 2001-05-31 2005-03-09 Advanced Risc Mach Ltd Data processing using multiple instruction sets
GB2376099B (en) * 2001-05-31 2005-11-16 Advanced Risc Mach Ltd Program instruction interpretation
GB2376097B (en) 2001-05-31 2005-04-06 Advanced Risc Mach Ltd Configuration control within data processing systems
US8769508B2 (en) 2001-08-24 2014-07-01 Nazomi Communications Inc. Virtual machine hardware for RISC and CISC processors
US7228533B2 (en) * 2001-08-24 2007-06-05 Sun Microsystems, Inc. Frameworks for generation of Java macro instructions for performing programming loops
US6988261B2 (en) 2001-08-24 2006-01-17 Sun Microsystems, Inc. Frameworks for generation of Java macro instructions in Java computing environments
US7058934B2 (en) 2001-08-24 2006-06-06 Sun Microsystems, Inc. Frameworks for generation of Java macro instructions for instantiating Java objects
US7039904B2 (en) 2001-08-24 2006-05-02 Sun Microsystems, Inc. Frameworks for generation of Java macro instructions for storing values into local variables
EP1313012A1 (en) * 2001-11-15 2003-05-21 Texas Instruments France Java DSP acceleration by byte-code optimization
US7162620B2 (en) * 2002-03-13 2007-01-09 Sony Computer Entertainment Inc. Methods and apparatus for multi-processing execution of computer instructions
US7131118B2 (en) * 2002-07-25 2006-10-31 Arm Limited Write-through caching a JAVA® local variable within a register of a register bank
US7747989B1 (en) 2002-08-12 2010-06-29 Mips Technologies, Inc. Virtual machine coprocessor facilitating dynamic compilation
JP4127495B2 (en) * 2002-09-05 2008-07-30 株式会社ルネサステクノロジ Information processing device
GB2399897B (en) * 2003-03-26 2006-02-01 Advanced Risc Mach Ltd Memory recycling in computer systems
US7694301B1 (en) * 2003-06-27 2010-04-06 Nathan Laredo Method and system for supporting input/output for a virtual machine
JP4224430B2 (en) * 2003-07-07 2009-02-12 株式会社ルネサステクノロジ Information processing device
GB2412192B (en) * 2004-03-18 2007-08-29 Advanced Risc Mach Ltd Function calling mechanism
US7802080B2 (en) 2004-03-24 2010-09-21 Arm Limited Null exception handling
US7930526B2 (en) 2004-03-24 2011-04-19 Arm Limited Compare and branch mechanism
US7278122B2 (en) * 2004-06-24 2007-10-02 Ftl Systems, Inc. Hardware/software design tool and language specification mechanism enabling efficient technology retargeting and optimization
US7802073B1 (en) 2006-03-29 2010-09-21 Oracle America, Inc. Virtual core management
US8359585B1 (en) * 2007-01-18 2013-01-22 Advanced Testing Technologies, Inc. Instrumentation ATS/TPS mitigation utilizing I/O data stream
US8225315B1 (en) 2007-07-23 2012-07-17 Oracle America, Inc. Virtual core management
EP3058467A4 (en) * 2013-10-15 2017-06-28 Mill Computing, Inc. Computer processor employing cache memory storing backless cache lines
US10114638B2 (en) * 2014-12-15 2018-10-30 Cisco Technology, Inc. Command message generation and execution using a machine code-instruction
US9477453B1 (en) * 2015-06-24 2016-10-25 Intel Corporation Technologies for shadow stack manipulation for binary translation systems
CN112256331B (en) * 2020-12-22 2021-04-27 鹏城实验室 Virtual machine instruction analysis acceleration method and device and computer storage medium

Family Cites Families (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4524415A (en) * 1982-12-07 1985-06-18 Motorola, Inc. Virtual machine data processor
US4841476A (en) * 1986-10-06 1989-06-20 International Business Machines Corporation Extended floating point operations supporting emulation of source instruction execution
US5117387A (en) * 1988-08-18 1992-05-26 Delco Electronics Corporation Microprogrammed timer processor
ES2132073T3 (en) * 1991-01-10 1999-08-16 Siemens Ag CIRCUIT PROVISION FOR THE REPRODUCTION OF THE LOGICAL ADDRESS SPACE OF A PROCESSOR UNIT OVER THE PHYSICAL ADDRESS SPACE OF A MEMORY.
US5432795A (en) * 1991-03-07 1995-07-11 Digital Equipment Corporation System for reporting errors of a translated program and using a boundry instruction bitmap to determine the corresponding instruction address in a source program
US5577259A (en) 1991-09-19 1996-11-19 Unisys Corporation Instruction processor control system using separate hardware and microcode control signals to control the pipelined execution of multiple classes of machine instructions
US5577295A (en) * 1994-09-27 1996-11-26 Chrysler Corporation Three diameter hinge pin
US5925123A (en) * 1996-01-24 1999-07-20 Sun Microsystems, Inc. Processor for executing instruction sets received from a network or from a local memory
US6021469A (en) * 1996-01-24 2000-02-01 Sun Microsystems, Inc. Hardware virtual machine instruction processor
US5842017A (en) * 1996-01-29 1998-11-24 Digital Equipment Corporation Method and apparatus for forming a translation unit
DE69719269T2 (en) * 1996-08-01 2003-10-30 International Business Machines Corp., Armonk Ensuring indivisibility for a collection of transactional work steps in a workflow management system
JP3467167B2 (en) * 1997-04-16 2003-11-17 日本電気株式会社 Interrupt processing method and apparatus in programming language processing system and recording medium thereof
US6021273A (en) * 1997-06-30 2000-02-01 Sun Microsystems, Inc. Interpreter generation and implementation utilizing interpreter states and register caching
GB2327784B (en) * 1997-07-28 2002-04-03 Microapl Ltd A method of carrying out computer operations
US6112018A (en) * 1997-12-18 2000-08-29 Advanced Micro Devices, Inc. Apparatus for exchanging two stack registers
US6134573A (en) * 1998-04-20 2000-10-17 Ip-First, L.L.C. Apparatus and method for absolute floating point register addressing
US6314445B1 (en) * 1998-08-03 2001-11-06 International Business Machines Coproration Native function calling
US6826749B2 (en) * 1998-12-08 2004-11-30 Nazomi Communications, Inc. Java hardware accelerator using thread manager

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See references of WO9918484A2 *

Also Published As

Publication number Publication date
DE69820027D1 (en) 2004-01-08
EP0950216B1 (en) 2003-11-26
US6349377B1 (en) 2002-02-19
WO1999018484A2 (en) 1999-04-15
US20020129225A1 (en) 2002-09-12
JP3945829B2 (en) 2007-07-18
DE69820027T2 (en) 2004-07-08
JP2001508907A (en) 2001-07-03
EP1359501A2 (en) 2003-11-05
EP1359501A3 (en) 2007-11-21
US6996703B2 (en) 2006-02-07
WO1999018484A3 (en) 1999-06-24

Similar Documents

Publication Publication Date Title
EP0950216B1 (en) A processing device for executing virtual machine instructions
US6332215B1 (en) Java virtual machine hardware for RISC and CISC processors
EP1019794B1 (en) Data processing device for processing virtual machine instructions
EP0941508B1 (en) Variable instruction set computer
US8473718B2 (en) Java hardware accelerator using microcode engine
JP4171496B2 (en) Instruction folding processing for arithmetic machines using stacks
KR100890244B1 (en) Storing stack operands in registers
US7243213B2 (en) Process for translating instructions for an arm-type processor into instructions for a LX-type processor; relative translator device and computer program product
JP4485198B2 (en) Processor system with Java accelerator
WO2000034844A9 (en) Java virtual machine hardware for risc and cisc processors
US20010010072A1 (en) Instruction translator translating non-native instructions for a processor into native instructions therefor, instruction memory with such translator, and data processing apparatus using them
KR100258650B1 (en) A method and system for performing an emulation context save and restore that is transparent to the operating system
JP2004511041A (en) Restarting converted instructions
US20070288909A1 (en) Hardware JavaTM Bytecode Translator
JP2002116908A (en) Mutual calling between native and nonnative instruction sets
US8769508B2 (en) Virtual machine hardware for RISC and CISC processors
KR20030040515A (en) Hardware instruction translation within a processor pipeline
EP0786722A1 (en) A method and system for improving emulation performance
US5732235A (en) Method and system for minimizing the number of cycles required to execute semantic routines
JP3345787B2 (en) Data processing device

Legal Events

Date Code Title Description
PUAI Public reference made under article 153(3) epc to a published international application that has entered the european phase

Free format text: ORIGINAL CODE: 0009012

17P Request for examination filed

Effective date: 19990702

AK Designated contracting states

Kind code of ref document: A2

Designated state(s): DE FR GB

GRAH Despatch of communication of intention to grant a patent

Free format text: ORIGINAL CODE: EPIDOS IGRA

GRAS Grant fee paid

Free format text: ORIGINAL CODE: EPIDOSNIGR3

GRAA (expected) grant

Free format text: ORIGINAL CODE: 0009210

AK Designated contracting states

Kind code of ref document: B1

Designated state(s): DE FR GB

REG Reference to a national code

Ref country code: GB

Ref legal event code: FG4D

REG Reference to a national code

Ref country code: GB

Ref legal event code: 746

Effective date: 20031128

REF Corresponds to:

Ref document number: 69820027

Country of ref document: DE

Date of ref document: 20040108

Kind code of ref document: P

ET Fr: translation filed
PLBE No opposition filed within time limit

Free format text: ORIGINAL CODE: 0009261

STAA Information on the status of an ep patent application or granted ep patent

Free format text: STATUS: NO OPPOSITION FILED WITHIN TIME LIMIT

REG Reference to a national code

Ref country code: FR

Ref legal event code: D6

26N No opposition filed

Effective date: 20040827

REG Reference to a national code

Ref country code: DE

Ref legal event code: R082

Ref document number: 69820027

Country of ref document: DE

Representative=s name: MEYER, MICHAEL, DIPL.-ING., DE

REG Reference to a national code

Ref country code: DE

Ref legal event code: R082

Ref document number: 69820027

Country of ref document: DE

Representative=s name: MEYER, MICHAEL, DIPL.-ING., DE

Effective date: 20140331

Ref country code: DE

Ref legal event code: R081

Ref document number: 69820027

Country of ref document: DE

Owner name: KONINKLIJKE PHILIPS N.V., NL

Free format text: FORMER OWNER: KONINKLIJKE PHILIPS ELECTRONICS N.V., EINDHOVEN, NL

Effective date: 20140331

REG Reference to a national code

Ref country code: FR

Ref legal event code: CD

Owner name: KONINKLIJKE PHILIPS N.V., NL

Effective date: 20141126

Ref country code: FR

Ref legal event code: CA

Effective date: 20141126

REG Reference to a national code

Ref country code: FR

Ref legal event code: PLFP

Year of fee payment: 18

REG Reference to a national code

Ref country code: FR

Ref legal event code: PLFP

Year of fee payment: 19

PGFP Annual fee paid to national office [announced via postgrant information from national office to epo]

Ref country code: GB

Payment date: 20160930

Year of fee payment: 19

PGFP Annual fee paid to national office [announced via postgrant information from national office to epo]

Ref country code: FR

Payment date: 20160928

Year of fee payment: 19

PGFP Annual fee paid to national office [announced via postgrant information from national office to epo]

Ref country code: DE

Payment date: 20161130

Year of fee payment: 19

REG Reference to a national code

Ref country code: DE

Ref legal event code: R119

Ref document number: 69820027

Country of ref document: DE

GBPC Gb: european patent ceased through non-payment of renewal fee

Effective date: 20170917

REG Reference to a national code

Ref country code: FR

Ref legal event code: ST

Effective date: 20180531

PG25 Lapsed in a contracting state [announced via postgrant information from national office to epo]

Ref country code: DE

Free format text: LAPSE BECAUSE OF NON-PAYMENT OF DUE FEES

Effective date: 20180404

Ref country code: GB

Free format text: LAPSE BECAUSE OF NON-PAYMENT OF DUE FEES

Effective date: 20170917

PG25 Lapsed in a contracting state [announced via postgrant information from national office to epo]

Ref country code: FR

Free format text: LAPSE BECAUSE OF NON-PAYMENT OF DUE FEES

Effective date: 20171002