This application is related to U.S. patent application Ser. No. 09/703,361, filed Oct. 31, 2000, entitled “IMPROVED FRAMEWORKS FOR INVOKING METHODS IN VIRTUAL MACHINES”, filed concurrently herewith, and hereby incorporated herein by reference.
This application is related to U.S. patent application Ser. No. 09/703,356, filed Oct. 31, 2000, entitled “IMPROVED METHODS AND APPARATUS FOR NUMERIC CONSTANT VALUE INLINING IN VIRTUAL MACHINES”, filed concurrently herewith, and hereby incorporated herein by reference.
The present invention relates generally to object-based high level programming environments, and more particularly, to frameworks for loading and execution of portable, platform independent programming instructions within a virtual machine.
Recently, the Java™ programming environment has become quite popular. The Java™ programming language is an language that is designed to be portable enough to be executed on a wide range of computers ranging from small devices (e.g., pagers, cell phones and smart cards) up to supercomputers. Computer programs written in the Java™ programming language (and other languages) may be compiled into Java™ virtual machine instructions (typically referred to as Java™ bytecodes) that are suitable for execution by a Java™ virtual machine implementation.
The Java™ virtual machine is commonly implemented in software by means of an interpreter for the Java™ virtual machine instruction set but, in general, may be software, hardware, or both. A particular Java™ virtual machine implementation and corresponding support libraries, together constitute a Java™ runtime environment.
Computer programs in the Java™ programming language are arranged in one or more classes or interfaces (referred to herein jointly as classes or class files). Such programs are generally platform, i.e., hardware and operating system, independent. As such, these computer programs may be executed, unmodified, on any computer that is able to run an implementation of the Java™ runtime environment. A class written in the Java™ programming language is compiled to a particular binary format called the “class file format” that includes Java™ virtual machine instructions for the methods of a single class. In addition to the Java™ virtual machine instructions for the methods of a class, the class file format includes a significant amount of ancillary information that is associated with the class. The class file format (as well as the general operation of the Java™ virtual machine) is described in some detail in The Java™ Virtual Machine Specification by Tim Lindholm and Frank Yellin (ISBN 0-201-31006-6), which is hereby incorporated herein by reference.
Conventionally, when a class file is loaded into the virtual machine, the virtual machine essentially makes a copy of the class file for its internal use. The virtual machine's internal copy is sometimes referred to as an “internal class representation.” In conventional virtual machines, the internal class representation is typically almost an exact copy of the class file and it replicates the entire Constant Pool. This is true regardless of whether multiple classes loaded into the virtual machine reference the same method and thus replicate some (or much) of the same Constant Pool information. Such replication may, of course, result in an inefficient use of memory resources. In some circumstances (particularly in embedded systems which have limited memory resources) this inefficient use of memory resources can be a significant disadvantage.
As described in The Java™ Virtual Machine Specification, one of the structures of a standard class file is known as the “Constant Pool.” The Constant Pool is a data structure that has several uses. One of the uses of the Constant Pool that is relevant to the present invention is that the Constant Pool contains the information that is needed to resolve various Java™ Instructions, for example, a method invocation instruction that can be invoked by any of the methods within the class.
Additionally, conventional virtual machine interpreters decode and execute the virtual machine instructions (Java™ bytecodes) one instruction at a time during execution, e.g., “at runtime.” To execute a Java™ instruction, typically, several operations have to been performed to obtain the information that is necessary to execute the Java™ instruction. For example, to invoke a method referenced by a Java™ bytecode, the virtual machine must make several operations to access the Constant Pool simply to identify the information necessary to locate and access the invoked method.
To illustrate,
Furthermore, execution of relatively more complex Java™ instructions requires even more processing than noted above. For example, in order to conventionally execute an invoke method command 158, the constant pool has to be accessed several times at run time just to obtain the symbolic representation of information associated with the method. The CP—IndexC and CP—IndexD are indexes to a constant pool where information relating to the method including its parameter values needed for execution can be found. Accordingly, a CP—IndexD associated with the method instruction 158 is typically an index to an entry into the Constant Pool wherein that entry itself provides another pair of indexes to other entries in the Constant Pool, and so forth. Thus, execution of an invoke method command would require a significant amount of processing at run time (e.g., accessing the Constant Pool several times to obtain symbolic representation relating to the method). As will be appreciated, this conventional technique is an inefficient approach that may result in significantly longer execution times. In addition, once the symbolic information relating to the method has been obtained, there may be a need to convert the symbolic information into an internal representation at run time. Again, this is an inefficient approach.
Accordingly, there is a need for improved frameworks for loading and execution of portable, platform independent programming instructions within a virtual machine.
To achieve the foregoing and other objects of the invention, improved frameworks for loading and execution of portable, platform independent programming instructions within a virtual machine will be described. One aspect of the present invention seeks to provide a mechanism that will generally improve the runtime performance of virtual machines by eliminating the need to always traverse a constant pool at runtime to execute a Java™ instruction. In effect, the described system contemplates doing some extra work during the loading of a class into a virtual machine by obtaining the information from the constant pool during loading and representing that information in a form that can be used more efficiently at runtime.
In other aspects of the invention, specific data structures that are suitable for use within a virtual machine and methods for creating such data structures are described. In one embodiment, an enhanced Java™ bytecode representation having a pair of Java™ bytecode streams is disclosed. The enhanced Java™ bytecode has a Java™ code stream suitable for storing various Java™ commands as bytecodes within a code stream. A Java™ data stream is used to store the data parameters associated with the Java™ commands in the code stream. As will be appreciated, the invention allows for representation of actual parameter values, or references to actual parameter values, in the code stream. Accordingly, data parameters can be provided for efficient execution of Java™ instructions without requiring further processing of Constant Pools at run time. As a result, the performance of Java™ complaint virtual machine can be enhanced.
The invention can be implemented in numerous ways, including a system, an apparatus, a method or a computer readable medium. Several embodiments of the invention are discussed below.
As a method of creating data structures suitable for use by a virtual machine to execute computer instructions, one embodiment of the invention includes converting a stream, having commands and data associated with the commands, into a pair of streams for use in the virtual machine. The pair of streams includes a code stream and a data stream for data associated with the commands in the code stream.
As a data structure for containing computer executable commands and data associated with the computer executable commands, the data structure suitable for use by a virtual machine in an object oriented programming environment, one embodiment of the invention includes a code portion having one or more computer executable commands, and a data stream having data corresponding to the one or more computer executable commands.
As a method of executing computer instructions on a virtual machine, one embodiment of the invention includes the acts of: fetching a command associated with a computer instruction from a code stream; determining whether the command has an associated parameter; fetching from a data stream the associated parameter of the command when that command has an associated parameter; and executing the command with the associated parameters after the associated parameter of the commands have been fetched.
As a method of creating data structures suitable for use by a virtual machine to execute Java™ instructions, another embodiment of the invention includes converting a Java™ bytecode into a pair of Java™ bytecode streams suitable for use by the virtual machine. The pair of Java™ bytecode streams being a Java™ code stream that includes Java™ commands and a Java™ data stream that includes the data associated with the commands in the Java™ code stream.
Other aspects and advantages of the invention will become apparent from the following detailed description, taken in conjunction with the accompanying drawings, illustrating by way of example the principles of the invention.
The present invention will be readily understood by the following detailed description in conjunction with the accompanying drawings, wherein like reference numerals designate like structural elements, and in which:
As described in the background section, the Java™ programming environment has enjoyed widespread success. Therefore, there are continuing efforts to extend the breadth of Java™ compatible devices and to improve the performance of such devices. One of the most significant factors influencing the performance of Java™ based programs on a particular platform is the performance of the underlying virtual machine. Accordingly, there have been extensive efforts by a number of entities to provide improved performance Java™ compliant virtual machines. In order to be Java™ compliant, a virtual machine must be capable of working with Java™ classes, which have a defined class file format. Although it is important that any Java™ virtual machine be capable of handling Java™ classes, the Java™ virtual machine specification does not dictate how such classes are represented internally within a particular Java™ virtual machine implementation.
The Java™ class file format utilizes the constant pool construct to store the information necessary to execute a Java™ instruction at run time. However, as suggested above, traversing the constant pool at runtime to obtain the information necessary to execute Java™ instructions is not particularly efficient. One aspect of the present invention seeks to provide a mechanism that will generally improve the runtime performance of virtual machines by eliminating the need to always traverse a constant pool at runtime to execute a Java™ instruction. Accordingly, a significant amount of work is conventionally performed at runtime. In effect, the described system contemplates doing some extra work during the loading of a class into a virtual machine by obtaining the information from the constant pool during loading and representing that information in a form that can be used more efficiently at runtime.
In other aspects of the invention, specific data structures that are suitable for use within a virtual machine and methods for creating such data structures are described. In one embodiment, an enhanced Java™ bytecode representation having a pair of Java™ bytecode streams is disclosed. The enhanced Java™ bytecode has a Java™ code stream suitable for storing various Java™ commands as bytecodes within a code stream. A Java™ data stream of the enhanced Java™ bytecode representation is used to store the data parameters associated with the Java™ commands in the code stream. As will be appreciated, the invention allows for representation in the code stream of actual parameter values, or references to actual parameter values. Accordingly, data parameters can be provided for efficient execution of Java™ instructions without requiring further processing of Constant Pools at run time. As a result, the performance of Java™ complaint virtual machine can be enhanced.
Furthermore, if the invention is implemented together with other improvements as described in concurrently filed, co-pending application No. U.S. patent application Ser. No. 09/703,361, filed Oct. 31, 2000, entitled “IMPROVED FRAMEWORKS FOR INVOKING METHODS IN VIRTUAL MACHINES”, the constant pool may not even need to be copied into the virtual machine's in order to invoke methods. Thus, the use of the invention in conjunction with the improved techniques provided as described in U.S. patent application Ser. No. 09/703,361, filed Oct. 31, 2000, entitled “IMPROVED FRAMEWORKS FOR INVOKING METHODS IN VIRTUAL MACHINES” has the potential in many circumstances to even further improve the performance of the virtual machines.
Embodiments of the invention are discussed below with reference to
As noted above, the Java™ bytecode 200 streams are suitable for use by a virtual machine. Referring now to
On the other hand, if it is determined at operation 306 that the fetched command has an associated parameter, the execution method 300 proceeds to operation 308 where the parameter values associated with the fetched command are fetched from the data stream. Referring back to
After the appropriate data is fetched, at operation 310, the pointer to the data command stream is incremented to point to the appropriate position in the data stream. As will be appreciated, the pointer to the data stream can be updated based on the command type (i.e., based on the number of bytecodes appropriated for the data associated with the command). When the command and the appropriate parameter values have been fetched, the execution method 300 proceeds to operation 314 where the fetched command is executed. Finally, at operation 314 a determination is made as to whether there are more commands in the Java™ code stream to execute. If it is determined at operation 314 that there are no more commands to execute, the execution method 300 ends. However, if it is determined at operation 314 that there is at least one more command to execute, that execution method 300 proceeds back to operation 302 where the next command in the code stream is fetched.
As noted above, the invention, among other things, provides for a pair of Java™ bytecode streams suitable for use by a virtual machine, for example, the code stream 202 and a Java™ data stream 204. Referring now to
On the other hand, when it is determined at operation 406 that the command has associated parameters, the bytecode stream generation method 400 proceeds to operation 408 where the associated parameters are read and processed. As will be appreciated, the processing of the associated parameters can be performed based on the command type in accordance with one aspect of the invention. This processing will be further illustrated in
Initially, at operation 502, a determination is made as to whether the Java™ command is a load constant command. If it is determined at operation 502 that the Java™ command is a load constant command, the loading method 500 proceeds to operation 504 where the load constant command is processed in accordance with one aspect of the invention. For example, such processing can be performed as illustrated below in
On the other hand, if it is determined at operation 502 that the Java™ command is not a load constant command, the loading method 500 proceeds to operation 506 where a determination is made as to whether the Java™ command is an invoke method command. If it is determined at operation 506 that the Java™ command is an invoke method command, the loading method 500 proceeds to operation 508 where the invoke method command is processed in accordance with another aspect of the invention. In a preferred embodiment, the invoke method command is processed to create a reference cell which provides the information necessary to invoke the method at run time. For example, such processing can be performed as illustrated in co-pending U.S. patent application Ser. No. 09/703,361, filed Oct. 31, 2000, entitled “IMPROVED FRAMEWORKS FOR INVOKING METHODS IN VIRTUAL MACHINES”. Accordingly, in the described embodiment, the address of the reference cell corresponding to the invoke method command is written into the data stream.
However, If it is determined at operation 506 that the Java™ command is not an Invoke method command, the loading method 500 proceeds to operation 512 where a determination is made as to whether the Java™ command is a Jump command. If it is determined at operation 512 that Java™ command is a Jump command, the appropriate code and data stream offsets of the Jump command are written into the data stream entry corresponding to the jump.
On the other hand, if it is determined at operation 512 that the Java™ command is not a jump command, the loading method 500 proceeds to operation 516 where a determination is made as to whether the Java™ command is an instantiation command. As will be appreciated, if it is determined at operation 516 that the Java™ command is an instantiation command, the Constant pool information for the instantiation command can be processed at operation 518. Following operation 518, in the described embodiment, the appropriate type-descriptor is written into the data stream at operation 520. However, if it is determined at operation 516 that the Java™ command is not an instantiation command, the loading method 500 proceeds to operation 522 where it is determined whether the Java™ command is a Get/Put field command.
As will be appreciated, if it is determined at operation 522 that the Java™ command is a Get/Put field command, the Constant pool information for the instantiation command can be processed at operation 518. For example, a reference cell which provides the information necessary to execute the Get/Put field command at run time can be generated. Accordingly, following operation 524, the address of a reference cell corresponding to the Get/Put field command can be written into the data stream at operation 526. The loading method 500 ends if it is determined at operation 522 that the Java™ command is not a Get/Put field command.
Initially, at operation 602, the first bytecode of the Constant Pool index (e.g., bytecode 156 of
Initially, at operation 702, the Java™ Load Constant command is fetched from the code stream. For example, referring back to
After the appropriate constant value is fetched, at operation 710, the pointer to the data command stream is incremented to point to the appropriate position in the data stream. As will be appreciated, the pointer to the data stream can be updated based on the type of the Load constant command (i.e., based on the number of bytecodes appropriated for the data associated with the command). Finally, at operation 712, the Constant Load command is executed, for example, the appropriate Constant value command in pushed on the stack.
The many features and advantages of the present invention are apparent from the written description, and thus, it is intended by the appended claims to cover all such features and advantages of the invention. Further, since numerous modifications and changes will readily occur to those skilled in the art, it is not desired to limit the invention to the exact construction and operation as illustrated and described. Hence, all suitable modifications and equivalents may be resorted to as falling within the scope of the invention.
| Number | Name | Date | Kind |
|---|---|---|---|
| 4086626 | Chung | Apr 1978 | A |
| 4199811 | Borgerson et al. | Apr 1980 | A |
| 4667290 | Goss et al. | May 1987 | A |
| 4910731 | Sakurai et al. | Mar 1990 | A |
| 5418964 | Conner et al. | May 1995 | A |
| 5815718 | Tock | Sep 1998 | A |
| 5838980 | Guillen et al. | Nov 1998 | A |
| 5872978 | Hoskins | Feb 1999 | A |
| 5878430 | Lafuse | Mar 1999 | A |
| 5893084 | Morgan et al. | Apr 1999 | A |
| 5899997 | Ellacott | May 1999 | A |
| 5903761 | Tyma | May 1999 | A |
| 5920720 | Toutonghi et al. | Jul 1999 | A |
| 5970242 | O'Connor et al. | Oct 1999 | A |
| 5978585 | Crelier | Nov 1999 | A |
| 6003038 | Chen | Dec 1999 | A |
| 6021469 | Tremblay et al. | Feb 2000 | A |
| 6026237 | Berry et al. | Feb 2000 | A |
| 6026485 | O'Connor et al. | Feb 2000 | A |
| 6047125 | Agesen et al. | Apr 2000 | A |
| 6072951 | Donovan et al. | Jun 2000 | A |
| 6072953 | Cohen et al. | Jun 2000 | A |
| 6075942 | Cartwright, Jr. | Jun 2000 | A |
| 6081665 | Nilsen et al. | Jun 2000 | A |
| 6096095 | Halstead | Aug 2000 | A |
| 6101580 | Agesen et al. | Aug 2000 | A |
| 6118940 | Alexander, III et al. | Sep 2000 | A |
| 6151618 | Wahbe et al. | Nov 2000 | A |
| 6151703 | Crelier | Nov 2000 | A |
| 6163780 | Ross | Dec 2000 | A |
| 6182202 | Muthukkaruppan | Jan 2001 | B1 |
| 6202208 | Holiday, Jr. | Mar 2001 | B1 |
| 6205578 | Grove | Mar 2001 | B1 |
| 6223202 | Bayeh | Apr 2001 | B1 |
| 6260187 | Cirne | Jul 2001 | B1 |
| 6292883 | Augusteijn et al. | Sep 2001 | B1 |
| 6317872 | Gee et al. | Nov 2001 | B1 |
| 6324685 | Balassanian | Nov 2001 | B1 |
| 6330709 | Johnson et al. | Dec 2001 | B1 |
| 6332215 | Patel et al. | Dec 2001 | B1 |
| 6338160 | Patel et al. | Jan 2002 | B1 |
| 6339841 | Merrick et al. | Jan 2002 | B1 |
| 6349377 | Lindwer | Feb 2002 | B1 |
| 6372286 | Azuma et al. | Apr 2002 | B1 |
| 6374286 | Gee et al. | Apr 2002 | B1 |
| 6412108 | Blandy et al. | Jun 2002 | B1 |
| 6427228 | Wigger | Jul 2002 | B1 |
| 6434625 | Loen | Aug 2002 | B1 |
| 6434694 | Slaughter et al. | Aug 2002 | B1 |
| 6442753 | Gerard et al. | Aug 2002 | B1 |
| 6446084 | Shaylor et al. | Sep 2002 | B1 |
| 6446254 | Chapman et al. | Sep 2002 | B1 |
| 6467037 | Griesemer | Oct 2002 | B1 |
| 6477702 | Yellin et al. | Nov 2002 | B1 |
| 6496871 | Koyama et al. | Dec 2002 | B1 |
| 6553565 | Click, Jr. et al. | Apr 2003 | B2 |
| 6557023 | Taivalsaari | Apr 2003 | B1 |
| 6557054 | Reisman | Apr 2003 | B2 |
| 6571388 | Venkatraman et al. | May 2003 | B1 |
| 6584612 | Mueller et al. | Jun 2003 | B1 |
| 6643711 | Bracha et al. | Nov 2003 | B2 |
| 6658421 | Seshadri | Dec 2003 | B1 |
| 6684394 | Shann | Jan 2004 | B1 |
| 6704803 | Wilson et al. | Mar 2004 | B2 |
| 6704923 | Gosling | Mar 2004 | B1 |
| 6738977 | Berry et al. | May 2004 | B1 |
| 6851108 | Syme et al. | Feb 2005 | B1 |
| 6851111 | McGuire et al. | Feb 2005 | B2 |
| 20020046298 | Bak et al. | Apr 2002 | A1 |
| 20020170041 | Shann | Nov 2002 | A1 |
| 20020170043 | Bagley et al. | Nov 2002 | A1 |
| 20020188726 | Schick et al. | Dec 2002 | A1 |
| Number | Date | Country |
|---|---|---|
| 0810522 | Dec 1997 | EP |
| 0943989 | Sep 1999 | EP |
| 0 996 059 | Apr 2000 | EP |
| 0996059 | Apr 2000 | EP |
| WO9918484 | Apr 1999 | WO |
| WO9931576 | Jun 1999 | WO |
| WO0122213 | Mar 2001 | WO |
| WO0241145 | May 2002 | WO |
| WO02077807 | Oct 2002 | WO |