Cross-platform virtual machine and method

A system includes a virtual source code specification corresponding to no particular platform and at least one transform mechanism corresponding to a particular platform and configured to be applied to the virtual source code specification to generate a source code corresponding to the particular platform.

BACKGROUND

The present invention relates to a virtual machine, and more specifically, to a source-level virtual machine that is used to generate executable applications on any number of separate high-level platforms, and a method for generating the executable applications on the high-level platforms.

Personal computers, cellular phones, laptop computers, tablet PCs, media devices, gaming consoles, and other electronic devices are all examples of hardware that may run software applications. Each type of electronic device may include an software resources, such as an operating system, and hardware resources particular to the device that are available to software applications designed to run on the device. A group of software and/or hardware resources available to applications is generally referred to as a platform, and software applications are designed to run on particular platforms by utilizing the resources of the platform.

SUMMARY

According to one embodiment of the present invention, a computer program product comprises a virtual source code specification to interact, respectively, with a plurality of transform mechanisms, each transform mechanism corresponding to a different platform, to generate a plurality of target source codes corresponding respectively to each platform of the plurality of transform mechanisms.

According to another embodiment of the present invention, a method of generating code includes generating a transform mechanism corresponding to a particular platform, and applying the transform mechanism to a virtual source code specification that does not correspond to the particular platform to generate a target source code corresponding to the particular platform.

According to another embodiment of the present invention, a method of generating code includes receiving a transform mechanism corresponding to a particular platform, and applying the transform mechanism to a virtual source code specification that does not correspond to the particular platform to generate a target source code corresponding to the particular platform.

According to another embodiment of the present invention, a system comprises a virtual source code specification corresponding to no particular platform, and at least one transform mechanism corresponding to a particular platform and configured to be applied to the virtual source code specification to generate a high-level source code corresponding to the particular platform.

DETAILED DESCRIPTION

Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). Although some aspects of the present invention may be carried out in object oriented programming languages, such as C, other aspects may not be carried out in C, and are instead carried out in source code, such as XML.

Typical platforms include hardware architecture and software to run applications on the hardware architecture. Examples of platforms include personal computers and corresponding operating systems (Mac OS, Windows, Linux, Java, .NET), portable media devices including portable music players, portable video players, mobile phones, laptop computers, tablet computers, and gaming consoles, each with respective software to provide platforms for applications to run on the hardware. Although some examples of hardware, software, and platforms are provided, the present invention may be implemented with any type of computing platform.

Referring toFIG. 1, a system to generate a platform-specific executable application with a source-level virtual machine includes a source-level virtual machine10and a platform-specific environment20.

The source-level virtual machine10includes an abstraction of a platform, or a virtual platform, including virtual hardware and a virtual operating system, that defines interfaces and resources available to an application or class of applications. In one embodiment the virtual source code specification12is a state machine including one or more states that act on an input stream of data to produce an output stream. The state machine includes virtual instructions to be executed on the virtual interfaces and resources of the source-level virtual machine10. In one embodiment, the virtual source code specification12is a generic markup language document, such as an XML document.

In the present specification and claims, the term “virtual” refers to rules and definitions defined in software that interact with other software to represent actual interfaces and resources. For example, if an actual resource would provide a particular input to a software application in response to a particular event, the source-level virtual machine10may include instructions to provide that particular input to the virtual source code specification12when the particular event occurs, and the virtual source code specification12may include instructions that are executed in response to the input.

One or more transform mechanisms14,16, and18may be applied to the virtual source code specification12. The virtual source code specification12may be a platform-neutral application. Each separate transform mechanism14,16, and18may correspond to a different high-level source code, and the number and type of different high-level source codes is not limited by the virtual source code specification12, since the virtual source code specification12is written to be platform-neutral, or to correspond to no one particular platform. In the embodiment in which the virtual source code specification12is a generic markup language document, such as XML, each of the transform mechanisms14,16, and18may be an instruction set applied to the generic markup language document. One example of an instruction set is an XSL style sheet that is applied to the XML document to generate a high-level language target source code22,24, or26.

Applying transform mechanisms14,16, and18to the same virtual source code specification results in high-level target source code22,24, and26, each high-level target source code corresponding to a different high-level target language (language1, language2, language N) and/or target platform. Each set of high-level target source code22,24, and26is compiled by a compiler28,30, and32corresponding to the respective target language1, language2, or language N. The resulting executable applications (or “executables”) are specific to a particular platform associated with the respective language1, language2, or language N.

AlthoughFIG. 1illustrates each high-level target source code22,24, and26corresponding to a different language and platform, it is understood that some languages may be implemented on a plurality of platforms, and some platforms may operate based on a plurality of different languages.

FIG. 2illustrates an implementation of a virtual source-level virtual machine10according to one embodiment of the present invention. The source-level virtual machine10is stored on a computing device40. The computing device40may have any operating system, and the operating system of the computing device40may either be related to an operating system represented by the source-level virtual machine10or one of the platforms56,58, or60. Alternatively, the operating system of the computing device40may be unrelated to the operating system represented by the source-level virtual machine10or the platforms56,58, or60.

The source-level virtual machine10defines interfaces and resources available to applications, such as the virtual source code specification12. Each of the interfaces and resources defined by the virtual source code specification is “virtual,” since it represents actual resources available to an executable application, but is not an actual resource available to an actual executable application. Examples of interfaces and resources include virtual memory42including virtual libraries43, virtual databases44, virtual drivers45, and other virtual data46. Other examples include a virtual control unit48including a virtual processing unit49, a virtual display50, a virtual printer52, and a virtual I/O54. Although some examples of virtual interfaces and resources are provided, any virtual resource or interface may be defined.

A program or programmer corresponding to a particular platform56,58, or60may provide a transform mechanism14,16, or18to the source-level virtual machine10. The transform mechanism14,16, or18may interact with the virtual source code specification12to be transformed into an executable application or program34,36, or38that is particular to the respective platform56,58, or60. Each of the respective platforms56,58, and60includes resources57,59, and61corresponding to the resources defined by the source-level virtual machine10, such as memory, a control unit, a display, a printer, and I/O. The transform mechanisms14,16, and18interact with the virtual source code specification12to generate the executable applications34,36, and38utilizing the resources57,59, and61, respectively. After the executable applications34,36, and38are generated, the virtual source code specification12may remain unchanged and platform-neutral, while the transform mechanism14,16, or18is changed into the executable application34,36, or38. Alternatively, executable application34,36, or38may be software that is generated as a new piece of software by the transform mechanism14,16, or18, and the virtual source code specification12, instead of being the result of a transformation of the transform mechanism14,16, or18.

FIG. 3illustrates a state-machine aspect of the virtual source code specification12. The virtual source code specification12includes a virtual state machine70including a plurality of states (state1, state2. . . state N). The virtual state machine70includes rules to generate instructions75(instruction group1, instruction group2. . . instruction group N) based on results of tests on input data. The instructions75are executed over resources80(resource A, resource B . . . resource X), and the resources80may provide inputs to the instructions75.

FIG. 4represents a state of the virtual state machine70in further detail. The state illustrated inFIG. 4(PRESENT STATE) represents any one of the states (state1, state2. . . state N) that may occur in the virtual state machine70. Each state tests input data with one or more tests (test1, test2. . . test N). Upon a positive result, the state includes information to execute instructions75with one or more of the resources80. Each state includes information about a next state when one or more of the tests is successful, and a return state for when none of the tests is successful.

In one embodiment of the present invention, each application is implemented as a virtual source code specification12. The virtual source code specification12may be an XML document that describes a state machine containing a set of states and transitions that act upon an input stream to produce an output stream. Each state performs one or more tests on the current input and executes a set of virtual instructions over common virtual resources for any successful test. A platform-specific target code22,24, or26is generated when a transform mechanism14,16, or18is applied to the virtual source code specification12. In one embodiment, the transform mechanism is an XSL style sheet containing templates with the platform-specific implementation details. Each style sheet may be tailored to a separate platform to generate the application embodied by the virtual source code specification12on a separate platform as a platform-specific executable application34,36, or38.

In one embodiment, although the platform-specific executable application is written in a high-level language, such as C or PL/1, the platform-specific executable applications34,36, and38are structured to be very flat, similar to an assembler application. For example there may be few sub-routines, or none, and there may be no classes or objects utilized in the platform-specific executable application34,36, and38.

According to some embodiments, the source-level virtual machine10is implemented in a cloud computing environment. It is understood that although this disclosure includes embodiments executed in a cloud computing environment, implementation of the teachings recited herein are not limited to a cloud computing environment. Rather, embodiments of the present invention are capable of being implemented in conjunction with any other type of computing environment now known or later developed.

Characteristics Are as Follows:

Service Models Are as Follows:

Deployment Models Are as Follows:

As shown inFIG. 5, computer system/server112in cloud computing node110is shown in the form of a general-purpose computing device. The components of computer system/server112may include, but are not limited to, one or more processors or processing units116, a system memory128, and a bus118that couples various system components including system memory128to processor116.

Computer system/server112typically includes a variety of computer system readable media. Such media may be any available media that is accessible by computer system/server112, and it includes both volatile and non-volatile media, removable and non-removable media.

Program/utility140, having a set (at least one) of program modules142, may be stored in memory128by way of example, and not limitation, as well as an operating system, one or more application programs, other program modules, and program data. Each of the operating system, one or more application programs, other program modules, and program data or some combination thereof, may include an implementation of a networking environment. Program modules142generally carry out the functions and/or methodologies of embodiments of the invention as described herein.

Computer system/server112may also communicate with one or more external devices114such as a keyboard, a pointing device, a display124, etc.; one or more devices that enable a user to interact with computer system/server112; and/or any devices (e.g., network card, modem, etc.) that enable computer system/server112to communicate with one or more other computing devices. Such communication can occur via Input/Output (I/O) interfaces122. Still yet, computer system/server112can communicate with one or more networks such as a local area network (LAN), a general wide area network (WAN), and/or a public network (e.g., the Internet) via network adapter120. As depicted, network adapter120communicates with the other components of computer system/server112via bus118. It should be understood that although not shown, other hardware and/or software components could be used in conjunction with computer system/server112. Examples, include, but are not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc.

In one embodiment, the virtual source code specification12is stored in memory128. An external device114connected to the computer system server112via the I/O interface122provides to the computer system server112a transform mechanism14,16, or18. The processing unit116applies the transform mechanism14,16, or18to the virtual source code specification12to generate high-level language source code22,24, or26corresponding to a desired executable application on a particular platform. The processing unit116may run a compiler program stored in memory128to compile the high-level language source code22,24, or26to generate a platform-specific executable program34,36, or38, and the computer system server112may transmit the platform-specific executable program34,36, or38to either the external device114from which the transform mechanism14,16, or18was received, or to another external device114.

Alternatively, the computer system server112may transmit the high-level language target source code22,24, or26to an external device114to compile the high-level language target source code22,24, or26to generate the respective platform-specific executable program34,36, or38.

Referring now toFIG. 6, an illustrative cloud computing environment150is depicted. As shown, cloud computing environment150comprises one or more cloud computing nodes110with which local computing devices used by cloud consumers, such as, for example, personal digital assistant (PDA) or cellular telephone154A, desktop computer154B, laptop computer154C, and/or automobile computer system154N may communicate. Nodes110may communicate with one another. They may be grouped (not shown) physically or virtually, in one or more networks, such as Private, Community, Public, or Hybrid clouds as described hereinabove, or a combination thereof. This allows cloud computing environment150to offer infrastructure, platforms and/or software as services for which a cloud consumer does not need to maintain resources on a local computing device. It is understood that the types of computing devices154A-N shown inFIG. 6are intended to be illustrative only and that computing nodes110and cloud computing environment150can communicate with any type of computerized device over any type of network and/or network addressable connection (e.g., using a web browser).

In one embodiment, any one of the computing devices154A-N may transmit to the cloud computing node110a transform mechanism14,16, or18and receive from the cloud computing node110either a high-level language target source code22,24, or26to be compiled, or a platform-specific executable program34,36, or38capable of being executed by the respective computing device154A-N, even when the respective computing devices each operate on different hardware and software platforms.

FIG. 7is a flowchart illustrating a method of generating a platform-specific application according to one embodiment. In operation91, a virtual source code specification is generated. The virtual source code specification may be a state machine describing rules to use virtual resources upon the success of tests on input data, as discussed above. The virtual source code specification may be generated by a human developer, by a computer program, or by any other means. In operation92, a transform mechanism or virtual instruction set is received. The transform mechanism is designed to correspond to a particular platform. In operation93, a high-level target source code is generated by transforming the transform mechanism with the virtual source code specification. The high-level target source code corresponds to the particular platform of the transform mechanism.

In operation94, the high-level target source code is compiled into a platform-specific application, and in operation95, the platform-specific application is output. The platform-specific application corresponds to the platform of the transform mechanism. In one embodiment, the virtual source code specification is stored in a first computer or computer system and each of the operations91-95is performed by the first computer or computer system. However, in alternative embodiments, the operations of compiling the high-level target source code94and outputting the platform-specific application95may be performed by a second computer. For example, if the transform mechanism is provided in operation92by a user or program from a second computer, in one embodiment the first computer may output the high-level target source code to the second computer, and the second computer may compile the high-level target source code in operation94.

FIG. 8illustrates an operation to receive a platform-specific executable application according to one embodiment. In operation96, a platform-specific transform mechanism is generated. In operation97, the platform-specific transform mechanism is applied to a virtual source code specification. The virtual source code specification is an abstract and platform-neutral state machine describing an application. In operation98, a platform-specific executable application is received based on the combination of the virtual source code specification and the platform-specific transform mechanism. As discussed above with respect toFIG. 7, in some embodiments, a platform-specific high-level target source code may be received and compiled to generate the platform-specific executable application.

According some embodiments, an abstract virtual machine provides isolation for a virtual source code specification from any particular platform. The virtual source code is an application in the form of a state machine that is not tailored to any particular platform. A user or program associated with a particular platform may provide a virtual instruction set or transform mechanism corresponding to a particular platform, and the user or program may custom-tailor the virtual instruction set or transform mechanism for the best possible performance on the particular platform. The majority of the application may be embodied in the virtual source code specification, which remains unchanged as the virtual instruction sets or transform mechanisms generate programs for particular platforms. Since only the virtual instruction sets or transform mechanisms change to generate platform-specific executable programs, less programming resources are required than if the entire virtual instruction set were to be changed. Transforming the virtual instruction set or transform mechanism into a target code and then compiling and linking the target code effectively eliminates any runtime overhead of a conventional virtual machine, which may act as an intermediary between an application and a platform to run the application on the platform. Instead, the virtual source code specification may act as a programming model for a developer, and the virtual source code specification does not need to be accessed once the platform-specific executable program is generated.