US 2002O194243A1 (19) United States (12) Patent Application Publication (10) Pub. No.: US 2002/0194243 A1 Sokolov et al. (43) Pub. Date: Dec. 19, 2002

(54) REDUCED INSTRUCTION SET FOR JAVA (52) U.S. Cl...... 709/101 VIRTUAL MACHINES (57) ABSTRACT (75) Inventors: Stepan Sokolov, Fremont, CA (US); Techniques for implementing instructions David Wallman, Sunnyvale, CA (US) Suitable for in Virtual machines are disclosed. The inventive virtual machine instructions can effectively repre Correspondence Address: Sent the complete Set of operations performed by the con BEYER WEAVER & THOMAS LLP ventional instruction set. Moreover, the P.O. BOX 778 operations performed by conventional instructions can be BERKELEY, CA 94704-0778 (US) performed by relatively fewer inventive virtual machine Assignee: Sun Microsystems, Inc. instructions. Thus, a more elegant, yet robust, Virtual (73) machine instruction Set can be implemented. This, in turn, allows implementation of relatively simpler interpreters as (21) Appl. No.: 09/819,120 well as allowing alternative uses of the limited 256 (2) (22) Filed: Mar. 27, 2001 Bytecode representation (e.g., a macro representing a set of commands). As a result, the performance of Virtual Publication Classification machines, especially, those operating in Systems with lim ited resources, can be improved by using the inventive (51) Int. Cl...... G06F 9/00 Virtual machine instructions.

204 2052 1 200 - Byte Byte 108 110 112 (Command) (Parameter) (Parameter)

Java Bytecode A Virtual machine instrcution

O2 2O6

Vitrual machine 210 Virtual machine instruction Loader 208

internal Repesentation 212 Patent Application Publication Dec. 19, 2002. Sheet 1 of 14 US 2002/0194243 A1 100 102 1.

CP-index

Constant Pool Execution Stack

Top Patent Application Publication Dec. 19, 2002. Sheet 2 of 14 US 2002/0194243 A1 1 250

Y W W V W

Y w t W w k

A. W BCM s B

V V B w

w V

W w Patent Application Publication Dec. 19, 2002. Sheet 3 of 14 US 2002/0194243 A1

205

204 2 1. 20 O

Byte Byte Byte

108 110 112

(Command) (Parameter) (Parameter)

Java Bytecode A Virtual machine Translator instrcution

2O6

Vitrual machine Virtual machine

210 instruction Loader 208

internal Repesentation 212

Fig. 2A Patent Application Publication Dec. 19, 2002 Sheet 4 of 14 US 2002/0194243 A1 -300

Command C

31 Patent Application Publication Dec. 19, 2002 Sheet 5 of 14 US 2002/0194243 A1

y 400

PUSH

Fig. 4A Patent Application Publication Dec. 19, 2002 Sheet 6 of 14 US 2002/0194243 A1

OP PUSHL

ldc2 w

Fig. 4C Fig. 4D Patent Application Publication Dec. 19, 2002 Sheet 7 of 14 US 2002/0194243 A1

PUSHB

iconst 1

iconst 4

Fig. 4F Patent Application Publication Dec. 19, 2002 Sheet 8 of 14 US 2002/0194243 A1 -500

T Execution Stack

522

Offset 1

524 Offset i(A)--...------

Patent Application Publication Dec. 19, 2002. Sheet 9 of 14 US 2002/0194243 A1

LOAD

LOADL

Fig. 5B Fig. 5C Patent Application Publication Dec. 19, 2002. Sheet 10 of 14 US 2002/0194243 A1

T Execution stack 604

Patent Application Publication Dec. 19, 2002 Sheet 11 of 14 US 2002/0194243 A1 1. 620 prowry-aa------assau---aaaaasser-mour-sroarr Execution Stack 604

Astore 622

ASTORE

ASTOREL

Patent Application Publication Dec. 19, 2002 Sheet 12 of 14 US 2002/0194243 A1

Fig. 6F

Fig. 6H Patent Application Publication Dec. 19, 2002 Sheet 13 of 14 US 2002/0194243 A1

Execution Stack Patent Application Publication Dec. 19, 2002 Sheet 14 of 14 US 2002/0194243 A1

& e D 5 Z.

? g o 55 9. 5 L

US 2002/0194243 A1 Dec. 19, 2002

REDUCED INSTRUCTION SET FOR JAVA the instructions for the methods of a VIRTUAL MACHINES class, the class file format includes a Significant amount of ancillary information that is associated with the class. The CROSS-REFERENCE TO RELATED class file format (as well as the general operation of the Java APPLICATIONS virtual machine) is described in some detail in The Java Virtual Machine Specification by Tim Lindholm and Frank 0001. This application is related to U.S. patent applica Yellin (ISBN 0-201-31006-6), which is hereby incorporated tion Ser. No. (Att.Dkt.No. SUN1P827/P6095), entitled herein by reference. “ENHANCED VIRTUAL MACHINE INSTRUCTIONS", filed on an even date, and hereby incorporated herein by 0009 Conventional virtual machines decodes reference for all purposes. and executes the Java Bytecode instructions, one instruction at a time during execution, e.g., “at runtime.” To execute a 0002 This application is related to U.S. patent applica Java instruction, typically, Several operations have to been tion Ser. No. 09/703,361 (Att.Dkt.No. SUN1P809/P5500), performed to obtain the information that is necessary to entitled “IMPROVED FRAMEWORKS FOR INVOKING execute the Java instruction. For example, to invoke a METHODS IN VIRTUAL MACHINES", which is hereby method referenced by a Java bytecode, the Virtual machine incorporated herein by reference for all purposes. must perform Several operations to access the Constant Pool 0003. This application is related to U.S. patent applica Simply to identify the information necessary to locate and tion Ser. No. 09/703,356 (Att.Dkt.No. SUN1P810/P5510), access the invoked method. entitled “IMPROVED METHODS AND APPARTUS FOR 0010. As described in The Java Virtual Machine Speci NUMERIC CONSTANT VALUE INLINING IN VIRTUAL fication, one of the Structures of a Standard class file is MACHINES", which is hereby incorporated herein by ref known as the “Constant Pool.” The Constant Pool is a data erence for all purposes. Structure that has several uses. One of the uses of the 0004. This application is related to U.S. patent applica Constant Pool that is relevant to the present invention is that tion Ser. No. 09/703,449 (Att.Dkt.No. SUN1P814/P5417), the Constant Pool contains the information that is needed to entitled “IMPROVED FRAMEWORKS FOR LOADING resolve various Java Instructions. To illustrate, FIG. 1 AND EXECUTION OF OBJECT-BASED PROGRAMS", depicts a conventional computing environment 100 includ which is hereby incorporated herein by reference for all ing a stream of Java Bytecodes 102, a constant pool 104 and purposes. an execution stack 106. The stream of Java Bytecodes 102 represents a Series of in a stream where one or more BACKGROUND OF THE INVENTION bytes can represent a Java Bytecode instruction. For example, a byte 108 can represent a Ldc (load constant on 0005 The present invention relates generally to object the execution stack) Bytecode command 108. Accordingly, based high level programming environments, and more the bytes 110 and 112 represent the parameters for the Ldc particularly, to virtual machine instruction Sets Suitable for Bytecode comand 108. In this case, these bytes respectively execution in Virtual machines operating in portable, platform represent a CP-IndexA 100 and CP-lindexB 112 that collec independent programming environments tively represent the indeX to appropriate constant value in 0006 Recently, the JavaTM programming environment the constant pool 104. For example, bytes C1, C2, C3 and has become quite popular. The Java" programming lan C4 of the constant pool 104 can collectively represent the guage is a language that is designed to be portable enough appropriate 4 byte (one word) constant C that is to loaded to to be executed on a wide range of computers ranging from the top of the execution stack 106. It should be noted that Small devices (e.g., pagers, cell phones and Smart cards) up Ldc Bytecode command 108 and its parameters represented to Supercomputers. Computer programs written in the Java by bytes 110 and 112 are collectively referred to herein as a (and other languages) may be com Java Bytecode instruction. piled into Java Bytecode instructions that are suitable for 0011. In order to execute the Java Bytecode Ldc Instruc execution by a Java virtual machine implementation. tion 108, at run time, an index to the Constant Pool 104 is 0007. The Java virtual machine is commonly imple constructed from the CP-IndexA and CP-IndexA. Once an mented in Software by means of an interpreter for the Java index to the Constant Pool has been determined, the appro Virtual machine instruction Set but, in general, may be priate Structures in the Constant Pool have to be accessed So Software, hardware, or both. A particular Java Virtual that the appropriate constant value can be determined. machine implementation and corresponding Support librar Accordingly, the Java Bytecode Ldc instruction can be ies, together constitute a Java" runtime environment. executed only after performing Several operations at run time. AS can be appreciated from the example above, the 0008 Computer programs in the Java programming lan execution of a relatively simple instruction Such as loading guage are arranged in one or more classes or interfaces a constant value can take a Significant amount of run time. (referred to herein jointly as classes or class files). Such programs are generally platform, i.e., hardware and operat Hence, this conventional technique is an inefficient approach ing System, independent. AS Such, these computer programs that may result in Significantly longer execution times. may be executed without modification, on any computer that 0012 Another problem is that the conventional Java is able to run an implementation of the JavaTM runtime Bytecode instruction Set has more than 220 instructions. environment. A class written in the Java programming Moreover, there is a Significant amount of redundancy language is compiled to a particular binary format called the between Some instructions in the conventional Java Byte “class file format” that includes Java virtual instruction Set. For example, there are different Java instructions for the methods of a single class. In addition to Bytecode instructions for storing (or pushing) integer local US 2002/0194243 A1 Dec. 19, 2002 variables on the execution Stack (e.g., iLoad), and storing (or can be represented by at least one of the virtual machine pushing) a pointer local variable on the execution Stack (e.g., instructions in the Virtual machine instruction Set. aLoad). However, the operations performed by these 0018. As a method of converting a set of Java Bytecode instructions are virtually identical, namely, storing (or push instructions into a set of executable virtual ing) 4 byte values (a word) on the execution Stack. There is machine instructions, one embodiment of the invention also a significant amount of Overlap between Some instruc includes the acts of receiving one or more bytes represent tions of the conventional Java Bytecode instruction set. For ing a Java Bytecode instruction Suitable for execution in a example, there are 5 different Java Bytecode instructions for Virtual machine, Selecting a corresponding virtual machine pushing one byte integer values on the execution Stack (i.e., instruction. The corresponding virtual machine instruction iconst 1, iconst 2, iconst 3, iconst 4 and iconst 5). How are Suitable for execution in the virtual machine and repre ever, these operations virtually perform the same operations, Sent one or more operations that can be performed when the namely, pushing a constant one byte integer value on the Java Bytecode instruction is executed. In addition, the execution Stack. Virtual machine instruction can represent at least two or 0013 As noted above, the Java Bytecode instruction set more Java Bytecode executable instructions Such that opera has more than 220 instructions. This means that conven tions that can be performed by executing the at least two or tionally nearly all of the 256 (2) allowable Bytecode values more Java Bytecode executable instructions can be per have to be assigned to Java instructions (commands or formed by execution of the virtual machine instruction. ). As a result, Java interpreters are needlessly com 0019. As a Java Bytecode instruction translator, one plex Since they need to recognize a relatively large number embodiment of the invention operates to convert a set of of Java instructions and possibly implement various mecha Java Bytecode executable instructions Suitable for execution nisms for executing many instructions. Thus, the conven on a virtual machine into a set of corresponding executable tional Java Bytecode instruction Set is not a very desirable Virtual machine instructions. The corresponding virtual Solution for Systems with limited resources (e.g., embedded machine instructions are also Suitable for execution in the Systems) Virtual machine and represent operations that can be per 0.014. Accordingly, there is a need for alternative instruc formed by execution of a number of corresponding Java tions Suitable for execution in Virtual machines. Bytecode instructions. In addition, the corresponding Set of the virtual machine instructions consists of a number of Virtual machine instructions that is less than the number of SUMMARY OF THE INVENTION the corresponding Java Bytecode executable instructions. 0.015 To achieve the foregoing and other objects of the 0020. Other aspects and advantages of the invention will invention, techniques for implementing virtual machine become apparent from the following detailed description, instructions Suitable for execution in Virtual machines are taken in conjunction with the accompanying drawings, disclosed. The inventive Virtual machine instructions can illustrating by way of example the principles of the inven effectively represent the complete Set of operations per tion. formed by the conventional Java Bytecode instruction set. Moreover, the operations performed by conventional instructions can be performed by relatively fewer inventive BRIEF DESCRIPTION OF THE DRAWINGS Virtual machine instructions. Furthermore, the inventive 0021. The present invention will be readily understood by Virtual machine instructions can be used to perform opera the following detailed description in conjunction with the tions that cannot readily be performed by conventional Java accompanying drawings, wherein like reference numerals Bytecode instructions. Thus, a more elegant yet robust designate like Structural elements, and in which: Virtual machine instruction Set can be implemented. This in turn allows implementation of relatively simpler interpreters 0022 FIG. 1 depicts a conventional computing environ as well as allowing alternative uses of the limited 256 (2) ment including a stream of Java Bytecodes, a constant pool, Bytecode representation (e.g., a macro representing a set of and an execution Stack. commands). As a result, the performance of virtual 0023 FIG. 2A is a block diagram representation of a machines, especially, those operating in Systems with lim computing environment including a Java Bytecode instruc ited resources, can be improved. tion translator in accordance with one embodiment of the 0016. The invention can be implemented in numerous invention. ways, including a System, an apparatus, a method or a 0024 FIG. 2B illustrates a mapping that can be per computer readable medium. Several embodiments of the formed by the Java Bytecode instruction translator of FIG. invention are discussed below. 2A in accordance with one embodiment of the invention. 0.017. As a set of virtual machine instructions suitable for 0025 FIG. 3 illustrates an internal representation of Java execution in a virtual machine, one embodiment of the instructions in accordance with one embodiment of the invention provides a Set of Virtual machine instructions invention. representing a number of corresponding Java Bytecode 0026 FIG. 4A illustrates an internal representation of a executable instructions that are also Suitable for execution in Set of Java Load Constant Bytecode instructions in accor the virtual machine. The set of the virtual machine instruc dance with one embodiment of the invention. tions consists of a number of Virtual machine instructions which is less than the number of the corresponding Java 0027 FIG. 4B illustrates a set of conventional Java Bytecode executable instructions. In addition, every one of Bytecode instructions that can be represented by an inven the corresponding Java Bytecode executable instructions tive Push command. US 2002/0194243 A1 Dec. 19, 2002

0028 FIG. 4C illustrates an internal representation of a 0043 FIG. 9 illustrates a mapping of Java Bytecode Set of conventional Java Load Constant Bytecode instruc instantiation instructions to the virtual machine instructions tions in accordance with another embodiment of the inven provided in accordance with one embodiment of the inven tion. tion

0029 FIG. 4-D illustrates a set of conventional Java DETAILED DESCRIPTION OF THE Bytecode instructions that can be represented by a single INVENTION PushL command in accordance with one embodiment of the invention. 0044 As described in the background section, the Java programming environment has enjoyed widespread Success. 0030 FIG. 4E illustrates an internal representation of a Therefore, there are continuing efforts to extend the breadth Set of Java Load Constant Bytecode instructions in accor of Java compatible devices and to improve the performance dance with yet another embodiment of the invention. of Such devices. One of the most significant factors influ 0031 FIG. 4F illustrates a set of Java Bytecode instruc encing the performance of Java based programs on a par tions that can be represented by a Single PushB command in ticular platform is the performance of the underlying virtual accordance with one embodiment of the invention. machine. Accordingly, there have been extensive efforts by a number of entities to improve performance in Java com 0.032 FIG. 5A illustrates an internal representation of a pliant Virtual machines. Set of Java Load from a local variable instructions in accordance with another embodiment of the invention. 004.5 To achieve this and other objects of the invention, techniques for implementing virtual machine instructions 0033 FIG. 5B illustrates a set of Java Bytecode instruc Suitable for execution in Virtual machines are disclosed. The tions for loading 4 byte local variables that can be repre inventive virtual machine instructions can effectively repre Sented by an inventive Load command in accordance with Sent the complete Set of operations performed by the con one embodiment of the invention. ventional Java Bytecode instruction set. Moreover, the operations performed by conventional instructions can be 0034 FIG. 5C illustrates a set of Java Bytecode instruc performed by relatively fewer inventive virtual machine tions for loading 8 byte local variables in accordance with instructions. Furthermore, the inventive Virtual machine one embodiment of the invention. instructions can be used to perform operations that cannot 0.035 FIG. 6A illustrates a computing environment readily be performed by the conventional Java Bytecode including an Aload (load from array) virtual machine instructions. Thus, a more elegant yet robust Virtual machine instruction in accordance with one embodiment of the instruction Set can be implemented. This, in turn, allows invention. implementation of relatively simpler interpreters as well as allowing for alternative uses of the limited 256 (2) Byte 0036 FIG. 6B illustrates a set of conventional Java code representation (e.g., a macro representing a set of Bytecode instructions for loading arrays that can be repre commands). As a result, the performance of Virtual Sented by a single inventive virtual machine instruction in machines, especially, those operating in Systems with lim accordance with one embodiment of the invention. ited resources, can be improved. 0037 FIG. 6C illustrates a computing environment 0046 Embodiments of the invention are discussed below including an AStore (store into array) virtual machine with reference to FIGS.2-9. However, those skilled in the art instruction in accordance with one embodiment of the will readily appreciate that the detailed description given invention. herein with respect to these figures is for explanatory 0038 FIGS. 6D and 6E illustrate a set of conventional purposes only as the invention extends beyond these limited Java Bytecode instructions for Storing arrays that can be embodiments. represented by a single inventive virtual machine instruc 0047 FIG. 2A is a block diagram representation of a tion. computing environment 200 including a Java Bytecode instruction translator 202 in accordance with one embodi 0039 FIGS. 6F and 6G illustrate some Java conven ment of the invention. The Java Bytecode instruction trans tional Bytecode instructions for performing conditional flow lator 202 operates to convert one or more bytes of a Java operations which can be represented by two inventive Virtual Bytecode Stream 204, representing a Java Bytecode instruc machine instructions in accordance with one embodiment of tion 205 into a virtual machine instruction 206 containing the invention. one or more bytes. The Java Bytecode instruction 205 in the 0040 FIG. 7A illustrates a computing environment Java Bytecode stream 204 can be, for example, a “Lcd” including an internal representation of a DUP instruction command 108 with its associated parameters 110 and 112, as Suitable for duplicating values on the Stack in accordance described in FIG. 1. with one embodiment of the invention. 0048 Typically, one byte of the virtual machine instruc 0041 FIGS. 7B and 7C illustrate various Java Bytecode tion 206 is designated to represent a virtual machine com instructions that can be represented by an inventive Virtual mand (or ). In addition, one or more additional bytes machine instruction in accordance with one embodiment of may be associated with the virtual machine command (or the invention. opcode) to represent its parameters. As a result, one or more bytes of the virtual machine instruction 206 can represent a 0042 FIGS. 8A and 8B illustrate mapping of Java Byte Java Bytecode instruction having one or more bytes that code return instructions to virtual machine instructions pro collectively represent a Java Bytecode instruction, namely a Vided in accordance with one embodiment of the invention. command and possibly the parameters associated with the US 2002/0194243 A1 Dec. 19, 2002 command (e.g., a one byte Java iconst1 Bytecode instruc 0053. It should be noted that conventionally Java Byte tion, three bytes representing Java Bytecode Lcd instruction, code instructions are internally represented as a Single etc). stream in the virtual machine. However, as shown in FIG. 0049. As will be appreciated, the virtual machine instruc 3, the internal representation 300 includes a pair of streams, tion 206 can represent Similar virtual machine operations namely, a code stream 302 and a data stream 304. More that the Java Bytecode instruction 205 represents. In addi details about representing instructions as a pair of Streams tion, the virtual machine instruction 206 can be loaded by a can be found in the U.S. patent application Ser. No. 09/703, virtual machine instruction loader 208 into a virtual machine 449 (Att.Dkt.No. SUN1P814/P5417), entitled 210 as an internal representation 212. As will become “IMPROVED FRAMEWORKS FOR LOADING AND apparent, the internal representation 212 can be used to EXECUTION OF OBJECT-BASED PROGRAMS. Significantly improve the performance of the Virtual 0054 Each one of the entries in the code stream 302 machine. and/or data stream 304 represent one or more bytes. The 0050. Furthermore, the Java Bytecode instruction trans code stream 302 includes various virtual machine com lator 202 is capable of converting a set of Java Bytecode mands (or instructions) 306, 308 and 310. The virtual executable instructions into a more elegant Set of instruc machine commands (or instruction) 306 represents a virtual tions that is especially Suitable for Systems with limited machine instruction that does not have any parameters resources. The operations performed by a conventional associated with it. On the other hand, each of the virtual Bytecode instruction set can effectively be represented by machine commands B and C have associated data param fewer inventive virtual machine instructions. Accordingly, eters that are represented in the data stream 304. More the number of the executable virtual machine instructions particularly, data B is the corresponding data parameter of can be significantly less than the number of conventional the virtual machine command B, and data C1 and C2 are the Java Bytecode executable instructions needed to perform the data parameters associated with the command C. Same Set of operations. In other words, two or more distinct 0055. It should be noted that the inventive virtual conventional Java Bytecode executable instructions can machine command B and data B represents one or more effectively be mapped into an inventive virtual machine conventional Java Bytecodes which have been converted, instruction. for example, by the Java Bytecode instruction translator 202 0051) To elaborate, FIG. 2B illustrates a mapping 250 of FIG. 2A. Similarly, the virtual machine command C, data that can be performed, for example, by the Java Bytecode C1 and C2 collectively represent the one or more Java instruction translator 202 in accordance with one embodi Bytecodes that have been converted into an inventive virtual ment of the invention. As illustrated in FIG. 2B, a set of machine instruction with its appropriate data parameters. conventional Java Bytecode executable instructions 252 can 0056 FIG. 4A illustrates an internal representation 400 be mapped into a corresponding Set of inventive virtual of a set of Java Load Constant Bytecode instructions in machine instructions 254. It should be noted that the set of accordance with one embodiment of the invention. The Java Bytecode executable instructions 252 consists of M internal representation 400 can, for example, be imple instructions, Bytecode Instructions (BC-BCM). It should mented as a data Structure embodied in a computer readable also be noted that each of the Byte code Instructions BC-BCM represent a unique instruction in the set of Java medium that is Suitable for use by a virtual machine. Bytecode executable instructions 252. As will be appreci 0057. In the described embodiment, each entry in the ated, the corresponding Set of executable virtual machine code stream 402 and data stream 404 represents one byte. As instructions 254 consists of N instructions (AVM-AVM), such, the code stream 402 includes a one byte Push com a number that can be significantly less than M (the number mand 406, representing an inventive Virtual machine com of Java Bytecode executable instructions 252). Accordingly, mand Suitable for representation of one or more conven two or more Byte code Instructions of the Java Bytecode tional Java Load Constant Bytecode instructions. The data executable instructions 252 can be mapped into the same Stream 404 includes the data parameters associated with the executable virtual machine instruction. For example, Byte Push command 406, namely, bytes A, B, C and D. As will code Instructions BC, BC, and BC can all be mapped into be appreciated, at execution time, the Virtual machine can the same virtual machine executable instruction, namely, the execute the Push command 406. Accordingly, the value instruction AVM. In addition, as will be described below, represented by the bytes A, B, C and D in the data stream two or more inventive Virtual machine instructions from the 404 can be pushed on the execution stack. In this way, the set 254 can be combined to effectively represent a Java Push command 406 can effectively represent various Java Bytecode instruction in the set 252. Bytecode instructions that push values represented by 4 0.052 As noted above, a virtual machine instruction, for bytes (one word) on the execution stack at run time. FIG. 4B example, the instruction AVM, can be loaded by a virtual illustrates a set of conventional Java Bytecode instructions machine instruction loader into a virtual machine as an that can be represented by an inventive Push command (e.g., internal representation that can be used to significantly Push command 406). improve the performance of the virtual machine. FIG. 3 0.058 FIG. 4C illustrates an internal representation 410 illustrates an internal representation 300 in accordance with of a set of conventional Java Load Constant Bytecode one embodiment of the invention. The internal representa instructions in accordance with another embodiment of the tion 300 can, for example, be implemented as a data Struc invention. Similar to the internal representation 400 of FIG. ture embodied in a computer readable medium that is 4A, the internal representation 410 includes a pair of suitable for use by a virtual machine. As shown in FIG. 3, streams, namely, the code stream 402 and data stream 404, the internal representation 300 includes a pair of streams, wherein each entry in the Streams represents one byte. namely, a code stream 302 and a data stream 304. However, in FIG. 4B, the code stream 402 includes a one US 2002/0194243 A1 Dec. 19, 2002

byte PushL command 412, representing another inventive variables on top of the execution Stack at run time. AS will Virtual machine instruction Suitable for representation of one be appreciated, the Load command 506 can effectively or more Java Load Constant Bytecode instructions. It should represent various conventional Java Bytecode instructions. be noted that the PushL command 412 has 8 bytes of data FIG. 5B illustrates a set of Java Bytecode instructions for asSociated with it, namely, the bytes represented by A, B, C, loading 4 byte local variables that can be represented by an D, E, F, G and H in the data stream 404. At execution time, inventive Load command (e.g., Load command 412) in the virtual machine can execute the PushL command 412 to accordance with one embodiment of the invention. push the value represented by the bytes A, B, C, D, E, F, G 0062. It should be noted that the invention also provides and H in the data stream 404, on the top of the execution for loading local variables that do not have values repre Stack. Accordingly, the PushL command 412 can effectively sented by 4 bytes. For example, FIG. 5C illustrates a set of represent various Java Bytecode instructions that push 8 Java Bytecode instructions for loading 8 byte local variables byte (two word) values on the execution Stack at run time. in accordance with one embodiment of the invention. AS will FIG. 4D illustrates a set of conventional Java Bytecode be appreciated, all of the Java Bytecode instructions listed in instructions that can be represented by a single PushL FIG. 5C can be represented by a single inventive virtual command (e.g., PushL command 412) in accordance with machine instruction (e.g., a LoadL command). The LoadL one embodiment of the invention. command can operate, for example, in a similar manner as 0059 FIG. 4E illustrates an internal representation 420 discussed above. of a Set of Java Load Constant Bytecode instructions in accordance with yet another embodiment of the invention. 0063. In addition, the invention provides for loading Again, the internal representation 420 includes the code values from arrays into an execution Stack. By way of stream 402 and data stream 404, wherein each entry in the example, FIG. 6A illustrates a computing environment 600 streams represents one byte. However, in FIG. 4E, the code in accordance with one embodiment of the invention. The stream 402 includes a one byte PushB command 422, computing environment 600 includes an array 602 repre representing yet another inventive virtual machine instruc Sentative of a Java array Stored in a portion of a memory of tion Suitable for representation of one or more Java Load the computing environment 600. An execution stack 604 is Constant Bytecode instructions. It should be noted that the also depicted in FIG. 6. As will be appreciated, an inventive PushB command 422 has a one byte data parameter A virtual machine instruction ALoad (array load) 605 can be associated with it. As shown in FIG. 4E, the data parameter utilized to facilitate loading of various values from the array can be stored in the code stream 402. However, it should be 602 to the top of the execution stack 604. noted that in accordance with other embodiment of the 0064. During the execution of the virtual machine invention, the data parameter A can be Stored in the data instruction ALoad 605, an array-reference 606 can be uti stream 404. In any case, the PushB command 422 can lized (e.g., resolved) to determine the location of the array effectively represent various Java Bytecode instructions that 602. In addition, an array-index 608 can be used to identify push one byte values on the execution Stack at run time. the appropriate offset of the array 602 and thereby indicate FIG. 4F illustrates a set of Java Bytecode instructions that the appropriate value that is to loaded from the array 602 on can be represented by a single PushB command (e.g., PushB the execution stack 604. As will be appreciated, the inven command 422) in accordance with one embodiment of the tive virtual machine instruction ALoad can be used to load invention. the appropriate values from various types of arrays (e.g., 1 0060 FIG. 5A illustrates an internal representation 500 byte, 2 bytes, 4 bytes, 8 bytes arrays). To achieve this, a of a set of Java "Load from a local variable' instructions in header 610 of the array 602 can be read to determine the accordance with another embodiment of the invention. In arrays type. Accordingly, based on the type of the array 602 the described embodiment, a code stream 502 of the internal as indicated by the header 610, the appropriate value that is representation 500 includes a Load command 506, repre to be loaded from the array can be determined by using the Senting an inventive Virtual machine instruction Suitable for array-index 608. This value can then be loaded onto the top representation of one or more Java "Load from a local of the execution stack 604. variable' Bytecode instructions. It should be noted that the 0065 Thus, the inventive virtual machine instruction Load command 506 has a one byte parameter associated ALoad can effectively represent various Java Bytecode with it, namely, an index, 508 in the data stream 504. As will instructions that are used to load values from an array. FIG. be appreciated, at run time, the Load command 506 can be 6B illustrates a set of conventional Java Bytecode instruc executed by a virtual machine to load (or push) a local tions for loading arrays that can be represented by a single variable on top of the execution stack 520. By way of inventive virtual machine instruction (e.g., ALoad) in accor example, an offseto 522 can indicate the Starting offset for dance with one embodiment of the invention. the local variables stored on the execution stack 520. Accordingly, an offset 524 identifies the position in the 0066. As will be appreciated, the invention also provides execution stack 520 which corresponds to the index, 508 for virtual machine instructions used to Store values into shown in FIG. 5A. arrays. By way of example, FIG. 6C illustrates a computing environment 620 in accordance with one embodiment of the 0061. It should be noted that in the described embodi invention. An inventive AStore 622 (store into array) virtual ment, the Load command 506 is used to load local variables machine instruction can be used to Store various values from as 4 bytes (one word). As a result, the value indicated by the the execution stack 604 into different types of arrays in 4 bytes A, B, C and D (starting at offset 524) is loaded on accordance with on embodiment of the invention. Again, the the top of the execution stack 520 when the Load command header 610 of the array 602 can be read to determine the 506 is executed. In this manner, the Load command 506 and array's type. Based on the array's type, the appropriate value index, 508 can be used to load (or Push) 4 byte local (i.e., the appropriate number of bytes N on the execution US 2002/0194243 A1 Dec. 19, 2002 stack 604 of FIG. 6B) can be determined. This value can respectively allow duplication of W1, W2 and W3 on the then be stored in the array 602 by using the array-index 626. Stack). However, the inventive virtual machine instructions Thus, the inventive virtual machine instruction ALoad can DUP and DUPL can be used to duplicate a much wider range effectively represent various Java Bytecode instructions that of values on the execution stack (e.g., W4, Wi, WN, etc.) are used to store values into an array. FIGS. 6D and 6E 0070 FIGS. 8A and 8B illustrate mapping of Java Byte illustrate a set of conventional Java Bytecode instructions code "Return” instructions to virtual machine instructions for Storing arrays that can be represented by an inventive provided in accordance with one embodiment of the inven Virtual machine instruction (e.g., Astore) in accordance with tion. As shown in FIG. 8A, various Java Bytecode instruc one embodiment of the invention. tions can be effectively mapped into a Return Virtual 0067 Still further, two or more of the inventive virtual machine instruction. AS will be appreciated, the Return machine instructions can be combined to perform relatively Virtual machine instruction operates to put 4 byte values more complicated operations in accordance with one (one word) on the execution Stack in a similar manner as the embodiment of the invention. By way of example, the Virtual machine instructions for loading constants on the conditional flow control operation performed by the Java stack described above (e.g., iload). FIG. 8B illustrates a Bytecode instruction "Icmp' (compare two long values on mapping of Java Bytecode return instructions to a "Lreturn” the Stack and based on the comparison push 0 or 1 on the Virtual machine instruction that can operate to put 8 byte Stack) can effectively be performed by performing an inven values (two words) on the execution stack. tive virtual machine instruction LSUB (Long subdivision) 0071. In a similar manner, FIG. 9 illustrates a mapping of followed by another inventive virtual machine instruction Java Bytecode instantiation instructions to the Virtual JMPEQ (Jump if equal). FIG. 6F and 6G illustrate some machine instructions provided in accordance with one Java conventional Bytecode instructions for performing embodiment of the invention. Again, the four various Java conditional flow operations which can be represented by two Bytecode instructions can be effectively mapped into a inventive virtual machine instructions in accordance with virtual machine instruction (e.g., NEW). The virtual one embodiment of the invention. machine instruction NEW operates to instantiate objects and 0068 The invention also provides for inventive opera arrays of various types. In one embodiment, the inventive tions that cannot be performed by Java Bytecode instruc virtual machine instruction NEW operates to determine the tions. By way of example, an inventive virtual machine types of the objects or arrayS based on the parameter value operation “DUP is provided in accordance with one of the Bytecode instantiation instructions. AS will be appre embodiment of the invention. The inventive virtual machine ciated, the Bytecode instructions for instantiation are typi instruction DUP allows values in various positions on the cally followed by a parameter value that indicates the type. execution Stack to be duplicated on the top of the execution Thus, the parameter value is readily available and can be stack. FIG. 7A illustrates a computing environment 700 used to allow the NEW virtual machine instruction to including an internal representation 701 of a DUP instruc instantiate the appropriate type at execution time. tion 702 suitable for duplicating values on the stack in 0072 Appendix A illustrates mapping of a set of conven accordance with one embodiment of the invention. The tional Java Bytecode instructions to one or more of the internal representation 701 includes a pair of Streams, inventive virtual machine instructions listed the in right namely, a code stream 402 and a data stream 404. In the column. described embodiment, each entry in the code stream 402 and data stream 404 represents one byte. The inventive 0073. The many features and advantages of the present virtual machine instruction DUP 702 is associated with a invention are apparent from the written description, and data parameter A in the code Stream 402. Again, it should be thus, it is intended by the appended claims to cover all Such noted that Data parameter A can be implemented in the data features and advantages of the invention. Further, Since Stream 404. In any case, the data parameter A indicates numerous modifications and changes will readily occur to which 4 byte value (word value) on an execution stack 704 those skilled in the art, it is not desired to limit the invention should be duplicated on the top of the execution stack 704. to the exact construction and operation as illustrated and The data parameter A can indicate, for example, an offset described. Hence, all Suitable modifications and equivalents from the top of the execution stack 704. As shown in FIG. may be resorted to as falling within the Scope of the 7A, the data parameter A can be a reference to W, a word invention. (4 byte) value on the execution stack. Accordingly, at execution time, the virtual machine can execute the DUP What is claimed is: command 702. As a result, the W word will be duplicated on 1. A set of virtual machine instructions Suitable for the top of the Stack. Thus, as will be appreciated, the execution in a virtual machine, the Set of Virtual machine inventive DUP virtual machine instructions can effectively instructions representing a number of corresponding Java replace various Java Byte instructions that operate to dupli Bytecode executable instructions that are also Suitable for cate 4 byte values on top of the execution. FIG. 7B execution in the virtual machine, illustrates some of these Java Bytecode instructions. Simi wherein the Set of the Virtual machine instructions con larly, as illustrated in FIG. 7C, an inventive DUPL virtual Sists of a number of Virtual machine instructions which machine can be provided to effectively replace various Java is less than the number of the corresponding Java Bytecode instructions that operate to duplicate 8 byte values Bytecode executable instructions, and (2 words) on top of the execution Stack. wherein every one of the corresponding Java Bytecode 0069. It should be noted that conventional Java Bytecode executable instructions can be represented by at least instructions only allow for duplication of values in certain one of the Virtual machine instructions in the virtual positions on the execution Stack (i.e., dup, dup X1 and dupx2 machine instruction Set. US 2002/0194243 A1 Dec. 19, 2002

2. A set of Virtual machine instructions as recited in claim 12. A method as recited in claim 10, wherein the pair of 1, wherein the number of Virtual machine instructions is Streams includes a code Stream and a data Stream, the code about 30 to 50 percent of the number of the corresponding Stream Suitable for containing a code portion of the at least Java Bytecode executable instructions. one virtual machine instruction, and the data Stream Suitable 3. A set of Virtual machine instructions as recited in claim for containing a data portion of the at least one virtual 1, wherein two or more Java Bytecode executable instruc machine instruction. tions are represented by one virtual machine instruction. 13. A Java Bytecode instruction translator operating to 4. A set of Virtual machine instructions as recited in claim convert a set of Java Bytecode executable instructions 1, wherein at least one of the Java Bytecode executable Suitable for execution on a virtual machine into a Set of instructions can be represented by the two or more virtual corresponding executable virtual machine instructions, machine instructions. 5. A set of Virtual machine instructions as recited in claim wherein the corresponding virtual machine instructions 4, wherein the least one Java Bytecode executable instruc are also Suitable for execution in the Virtual machine tion is a conditional data flow operation. and represent operations that can be performed by 6. A set of Virtual machine instructions as recited in claim execution of a number of corresponding Java Bytecode 1, wherein the Set includes at least one virtual machine instructions, and instruction that represents at least one operation that cannot wherein the corresponding Set of the Virtual machine be represented by any one of the Java Bytecode executable instructions consists of a number of Virtual machine instructions. instructions that is less than the number of the corre 7. A set of Virtual machine instructions as recited in claim 6, wherein the at least one virtual machine instruction sponding Java Bytecode executable instructions. represents a duplicate Stack operation. 14. A Java Bytecode instruction translator as recited in 8. A set of Virtual machine instructions as recited in claim claim 13, wherein two or more Java Bytecode executable 1, wherein at least one virtual machine instruction is inter instructions are represented by one virtual machine instruc nally represented in the virtual machine by a pair of Streams. tion. 9. A set of Virtual machine instructions as recited in claim 15. A Java Bytecode instruction translator as recited in 8, wherein the pair of Streams includes a code Stream and a claim 13, wherein at least one of the Java Bytecode execut data Stream, able instructions can be represented by two or more Virtual machine instructions. wherein the code Stream is Suitable for containing a code 16. A Java Bytecode instruction translator as recited in portion of the at least one virtual machine instruction, claim 15, wherein the least one Java Bytecode executable and the data Stream is Suitable for containing a data instruction is a conditional data flow operation. portion of the at least one virtual machine instruction. 17. A Java Bytecode instruction translator as recited in 10. A method of converting a set of Java Bytecode claim 13, wherein the Set includes at least one virtual executable instructions into a set of executable virtual machine instruction that represents operations that cannot be machine instructions, the method comprising: represented by any one of the Java Bytecode executable receiving one or more bytes representing a Java Bytecode instructions. instruction Suitable for execution in a virtual machine; 18. A Java Bytecode instruction translator as recited in claim 17, wherein the at least one virtual machine instruction Selecting a corresponding virtual machine instruction, the represents a duplicate Stack operation. corresponding virtual machine instruction Suitable for 19. A Java Bytecode instruction translator as recited in execution in the Virtual machine and representing one claim 13, wherein at least one virtual machine instruction is or more operations that can be performed when the internally represented in the virtual machine by a pair of Java Bytecode instruction is executed; and StreamS. wherein the virtual machine instruction can represent at 20. A Java Bytecode instruction translator as recited in least two or more Java Bytecode executable instruc claim 19, wherein the pair of Streams includes a code Stream tions Such that operations that can be performed by and a data Stream, executing the at least two or more Java Bytecode executable instructions can be performed by execution wherein the code Stream is Suitable for containing a code of the virtual machine instruction. portion of the at least one virtual machine instruction, 11. A method as recited in claim 10, wherein the method and further comprises: wherein the data Stream is Suitable for containing a data loading the Virtual machine instruction into the virtual portion of the at least one virtual machine instruction. machine as an internal representation with a pair of StreamS.