Computer and program

The computer and program automatically set the extended ISA command line argument using a correspondence table, addressing the issue of suboptimal native code generation by optimizing for CPU capabilities.

JP2024119527AActive Publication Date: 2024-09-03TOSHIBA TEC KK
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
JP2023026504
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-02-22
Publication Date
2024-09-03
Estimated Expiration
2043-02-22

AI Technical Summary

Technical Problem

In systems where a runtime compiler generates and optimizes native code from a set of bytecodes, optimization cannot be performed unless the extended ISA supported by the CPU is manually specified in the command line argument, preventing the generation of optimal native code.

Method used

A computer and program that automatically set the extended ISA as a system command line argument by referring to a correspondence table, enabling the generation of native code optimal for the extended ISA, using a CPU with a storage device and functions to acquire and optimize the ISA.

Benefits of technology

Enables the generation of optimal native code for systems where manual specification of the extended ISA is not possible, enhancing performance by automatically setting command line arguments based on CPU capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2024119527000001
    Figure 2024119527000001
Patent Text Reader

Abstract

To provide a computer and a program for generating an optimal native code for a system which executes a bytecode.SOLUTION: A computer 100 includes a CPU and a storage device. The storage device stores; a bytecode; a system that cannot be optimized unless an extended ISA supported by the CPU is designated in a command line argument of the system for executing the bytecode; a correspondence table showing a correspondence between a value of an extension field indicating the extended ISA (Instruction Set Architecture) and the command line argument necessary for enabling optimization corresponding to the extended ISA in the system; and a program for implementing functions to cause the CPU to: acquire an ISA supported by the CPU; acquire the extended ISA from the ISA; refer to the correspondence table to automatically set the extended ISA in the command line argument of the system; and cause the extended ISA to generate an optimal native code.SELECTED DRAWING: Figure 1
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] An embodiment of the present invention relates to a computer and a program that executes a bytecode. [Background technology]

[0002] A system is known in which a runtime compiler generates and optimizes native code from a set of bytecodes presented to a compiler.

[0003] In addition, there are known systems in which, unless the extended instruction set architecture (ISA) supported by the CPU is specified in the command line arguments of the system that executes the bytecode, the runtime compiler cannot generate native code that is optimal for the extended ISA supported by the CPU. [Prior art documents] [Patent documents]

[0004] [Patent Document 1] JP 2000-40007 A [Non-patent literature]

[0005] [Non-Patent Document 1] https: / / wiki.openjdk.org / display / RISCVPort Summary of the Invention [Problem to be solved by the invention]

[0006] In a system in which native code is generated and optimized in a runtime compiler from a set of bytecodes presented to the compiler, in a system in which optimization cannot be performed unless an extended ISA supported by the CPU is manually specified as a command line argument for the system that executes the bytecode, it is not possible to generate and optimize native code in the runtime compiler because there is no means for setting the command line argument.

[0007] An object of the present invention is to provide a computer and a program capable of generating native code that is optimal for a system that executes bytecodes. [Means for solving the problem]

[0008] A computer according to an embodiment includes a CPU and a storage device. The storage device stores a bytecode, a system in which optimization cannot be performed unless an extended ISA supported by the CPU is specified in a command line argument of the system that executes the bytecode, a correspondence table indicating a correspondence between an extension field value representing the extended ISA and a command line argument required to enable optimization corresponding to the extended ISA in the system, and a program that causes the CPU to obtain an ISA supported by the CPU, obtain the extended ISA from the ISA, automatically set the extended ISA in the command line argument of the system by referring to the correspondence table, and generate native code optimal for the extended ISA. [Brief description of the drawings]

[0009] [Figure 1] FIG. 2 is a diagram illustrating a hardware configuration of a computer according to an embodiment. [Diagram 2] FIG. 2 is a diagram illustrating a software configuration of a computer according to an embodiment. [Diagram 3] FIG. 2 is a diagram illustrating an ID register included in a CPU of a computer according to an embodiment. [Figure 4] FIG. 2 is a diagram showing a Base field of an ID register included in a CPU of a computer according to an embodiment. [Diagram 5] FIG. 13 is a diagram showing an Extensions field of an ID register included in a CPU of a computer according to an embodiment. [Figure 6] FIG. 11 is a diagram showing an ISA-command line correspondence table in the computer according to the embodiment. [Figure 7]4 is a flowchart showing a process executed by a Java (registered trademark) virtual machine calling unit in the computer according to the embodiment. [Figure 8] 11 is a diagram showing an execution command of a Java virtual machine calling unit in the computer according to the embodiment. FIG. [Figure 9] FIG. 11 is a diagram showing an actual Java Virtual Machine call command in the computer according to the embodiment. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0010] (Hardware configuration) First, a hardware configuration of a computer 100 according to an embodiment will be described with reference to Fig. 1. Fig. 1 is a diagram showing the hardware configuration of the computer 100. The computer 100 is, for example, a computer. The computer is a personal computer, a server computer, or the like.

[0011] The computer 100 includes a CPU 101, a bus 102, a RAM 103, a solid state drive (SSD) 104, an Ethernet (registered trademark) interface (I / F) 105, a keyboard 106, and a display 107. The computer 100 may include other devices in addition to these.

[0012] The CPU 101 is, for example, a RISC-V CPU. The RISC-V CPU has, for example, an ISA of RV64IMAFDC, a base ISA of RV64I, and an extended ISA of MAFDC.

[0013] The relationship between RISC-V ISAs and the letters of the alphabet that represent ISAs is described in "riscv-privileged.pdf" at "https: / / github.com / riscv / riscv-isa-manual / releases".

[0014] Here, an example is given in which CPU 101 is a RISC-V CPU, but any other CPU may be used as long as it has an optional instruction set other than the basic instruction set, such as an extended instruction set or a dedicated instruction set, like the RISC-V CPU.

[0015] The CPU 101, RAM 103, solid state drive 104, Ethernet interface 105, keyboard 106, and display 107 are electrically connected to one another via a bus 102, and exchange commands, programs, and data via the bus 102.

[0016] The CPU 101 is a hardware processor, and controls the RAM 103, the solid state drive 104, the Ethernet interface 105, the display 107, and the keyboard 106.

[0017] The RAM 103 is a main memory that temporarily stores programs and data required for the processing executed by the CPU 101 .

[0018] The solid state drive 104 is an auxiliary storage device that non-temporarily stores the programs and data that the RAM 103 temporarily stores.

[0019] The CPU 101 loads programs and data from the solid state drive 104 into the RAM 103, and executes various functions by executing the programs.

[0020] The display 107 is an output device that outputs data and presents various types of information to the user.

[0021] The keyboard 106 is an input device for receiving commands and data, and receives commands and data through operations by the user.

[0022] The Ethernet interface 105 is an interface for connecting to a network or other devices. For example, the computer 100 can be connected to a network or other devices via the Ethernet interface 105.

[0023] The bus 102, RAM 103, solid state drive 104, Ethernet interface 105, keyboard 106, and display 107 may be general-purpose components.

[0024] (Software configuration) At the time of startup, the computer 100 loads the operating system stored in the solid state drive 104 into the RAM 103 and runs the operating system. For example, the operating system is Linux (registered trademark). In the following, an example in which the operating system is Linux will be described, but the present invention is not limited to this, and the operating system may be another operating system.

[0025] The software configuration of the computer 100 will be described below with reference to Fig. 2. Fig. 2 is a diagram showing the software configuration of the computer 100. In detail, Fig. 2 is a diagram showing the configuration of Linux 201 stored in the solid state drive 104.

[0026] The solid state drive 104 stores Linux 201. Linux 201 may be, for example, Debian GNU Linux running on a RISC-V CPU.

[0027] Linux 201 has a Java development environment 202. Java development environment 202 has a Java compiler 204. Linux 201 stores Java source code 203 prepared by a user. Java compiler 204 is a program that compiles Java source code 203 to generate Java byte code 205. Java compiler 204 may be, for example, javac. Java byte code 205 generated from Java source code 203 by Java compiler 204 is stored in Linux 201. Java byte code 205 may be a class file, a jar archive, or the like.

[0028] The Java development environment 202 is a system in which a runtime compiler cannot generate native code optimal for an extended instruction set architecture (ISA) supported by the CPU 101 unless the extended ISA supported by the CPU 101 is specified in a command line argument of the system that executes the Java bytecode 205. An example of such a Java development environment 202 is OpenJDK described in Non-Patent Document 1.

[0029] The Java development environment 202 also includes a Java virtual machine 208. The Java virtual machine 208 may be a java command included in the Java development environment 202. The Java virtual machine 208 includes an interpreter 209 and a dynamic compiler 210, and can internally generate native code 211. The native code 211 may be a machine code for a RISC-V CPU.

[0030] Linux 201 also has a Java virtual machine calling unit 206 and an ISA-command line correspondence table 207. Java virtual machine calling unit 206 has a program that refers to ISA-command line correspondence table 207 and automatically sets an extended ISA in the command line arguments of Java development environment 202. Details of Java virtual machine calling unit 206 and ISA-command line correspondence table 207 will be described later.

[0031] (CPU) Next, the CPU 101 (RISC-V CPU) will be described with reference to Fig. 3 to Fig. 5. Fig. 3 is a diagram showing a CPU ID register 300 included in the CPU 101 (RISC-V CPU). Fig. 4 is a diagram showing a Base field of the CPU ID register 300 (mcpuid) shown in Fig. 3. Fig. 5 is a diagram showing an Extensions field of the CPU ID register 300 (mcpuid) shown in Fig. 3.

[0032] The CPU 101 (RISC-V CPU) has a CPU ID register 300 shown in Fig. 3. The CPU ID register 300 has a Base field 301 that indicates the basic ISA, and an Extensions field 302 that indicates the extended ISA.

[0033] The Base field 301, which indicates the basic ISA, is composed of 2 bits. As shown in Fig. 4, the Values ​​0, 1, 2, and 3 of the Base field 301 correspond to Descriptions RV32I, RV32E, RV64I, and RV128I, respectively.

[0034] The Extensions field 302, which indicates the extended ISA, is composed of 26 bits. As shown in Fig. 4, the least significant bit is 0 bit and the most significant bit is 25 bits. In other words, from the right, it is 0 bit, 1 bit, ..., 25 bit. Each bit has a value of 0 or 1. 0 bit, 1 bit, ..., 25 bit correspond to the letters A, B, ..., Z, respectively. Each of the letters A, B, ..., Z indicates an extended ISA.

[0035] The CPU 101 (RISC-V CPU) can obtain the value of the Base field 301 representing the basic ISA shown in FIG. 4 and the value of the Extensions field 302 representing the extended ISA shown in FIG. 5 by executing the mcpuid machine instruction.

[0036] (ISA-Command Line Compatibility Table) 6 is a diagram showing the ISA-command line correspondence table 207. The ISA-command line correspondence table 207 shows the correspondence between the value of the Extensions field 302, which indicates an extended ISA, and the command line arguments required to enable optimizations corresponding to the extended ISA in the Java virtual machine 208.

[0037] In ISA-command line correspondence table 207, an extension ISA represents a character in Extensions field 302, a value represents a bit position corresponding to the character, and an argument represents a command line argument corresponding to the character. That is, ISA-command line correspondence table 207 shows the following:

[0038] The extended ISAs that enable optimization in the Java virtual machine 208 are the letters C and V. That is, the letters C and V are flagged. Furthermore, the bit digit corresponding to the letter C of the extended ISA is 2, the value of the 2nd bit digit is 1, and the command line argument for the letter C of the extended ISA is -XX:+UseRVC. Furthermore, the bit digit corresponding to the letter V of the extended ISA is 21, the value of the 21st bit digit is 1, and the command line argument for the letter V of the extended ISA is -XX:+UseRVC.

[0039] (Java Virtual Machine Caller) The Java virtual machine calling unit 206 is a program that realizes the following functions: causing the CPU 101 to acquire an ISA supported by the CPU 101; causing the CPU 101 to acquire an extended ISA from the acquired ISA; causing the CPU 101 to automatically set the extended ISA in the command line arguments of the Java development environment 202 by referring to an ISA-command line correspondence table 207; and causing the CPU 101 to generate native code that is optimal for the extended ISA.

[0040] An example of the operation of the Java virtual machine calling unit 206 will be described below with reference to Fig. 7 to Fig. 9. Fig. 7 is a flowchart showing the processing executed by the Java virtual machine calling unit 206. Fig. 8 is a diagram showing an execution command of the Java virtual machine calling unit 206. Fig. 9 is a diagram showing an example of a command for calling the Java virtual machine 208.

[0041] In this operation example, the user executes the javawrap command representing the Java virtual machine call unit 206 from the command line with an argument 801 called sample, as shown in Fig. 8. Here, it is assumed that the Java bytecode 205 is sample.class, and the character string sample in the argument 801 represents the execution of sample.class.

[0042] By executing the javawrap command, the Java virtual machine calling unit 206 causes the CPU 101 to perform the processes described below.

[0043] In step S 101 , the CPU 101 executes the mcpuid command and copies the value of the CPU ID register 300 to the RAM 103 .

[0044] In step S102, the CPU 101 copies the value of the Extensions field 302 included in the value of the CPU ID register 300 copied to the RAM 103 to a variable e.

[0045] In step S103, the CPU 101 sets the command line argument to the character string s.

[0046] In step S104, CPU 101 refers to ISA-command line correspondence table 207 and determines whether e&2=0. Here, e&2 means a bit operation to check whether a flag is set for character C corresponding to the 2-bit digit of variable e. In detail, e&2 compares the 2-bit digit value of variable e with the 2-bit digit value of ISA-command line correspondence table 207, and returns 0 if either value is 0.

[0047] If the determination result in step S104 is No, that is, if e&2=0 is not true, then the value of the 2nd bit of variable e and the value of the 2nd bit of ISA-command line correspondence table 207 are both 1, indicating that the character C of the extended ISA corresponding to the 2nd bit is valid for optimization in the Java virtual machine 208. In this case, next, in step S105, the character string s is changed to -XX:+UseRVC+s. Then, the process proceeds to step S106.

[0048] If the determination result in step S104 is Yes, that is, if e&2=0, either the 2-bit digit value of variable e or the 2-bit digit value of ISA-command line correspondence table 207 is 0, indicating that the character C of the extended ISA corresponding to the 2-bit digit is not valid for optimization in the Java virtual machine 208. In this case, the process of step S105 is omitted and the process proceeds to step S106.

[0049] In step S106, CPU 101 refers to ISA-command line correspondence table 207 and determines whether e&21=0. Here, e&21 means a bit operation to check whether a flag is set for the character V corresponding to the 21st bit digit of variable e. In detail, e&21 compares the value of the 21st bit digit of variable e with the value of the 21st bit digit of ISA-command line correspondence table 207, and returns 0 if either value is 0.

[0050] If the determination result in step S106 is No, that is, if e&21=0 is not true, then the value of the 21st bit of variable e and the value of the 21st bit of ISA-command line correspondence table 207 are both 1, indicating that the character V of the extended ISA corresponding to the 21st bit is valid for optimization in the Java virtual machine 208. In this case, next, in step S107, the character string s is changed to -XX:+UseRVV+s. Then, the process proceeds to step S108.

[0051] If the determination result in step S106 is Yes, that is, if e&21=0, either the value of the 21st bit of variable e or the value of the 21st bit of ISA-command line correspondence table 207 is 0, indicating that the letter V of the extended ISA corresponding to the 21st bit is not valid for optimization in the Java virtual machine 208. In this case, the process of step S107 is omitted and the process proceeds to step S108.

[0052] In step S108, CPU 101 executes a java command representing Java virtual machine 208 with s as an argument. Fig. 9 is a diagram showing an example of a command for calling Java virtual machine 208. The command shown in Fig. 9 is a command in an example where the determination result in step S104 is No and the determination result in step S106 is Yes in the flowchart shown in Fig. 7. In this example, -XX:+UseRVC, which is a command line argument effective for optimization in Java virtual machine 208, is added to argument 801 of sample.

[0053] If the determination results of steps S104 and S106 are both Yes, the argument 801 of the java command becomes "sample." If the determination results of steps S104 and S106 are both Yes and No, the argument 801 of the java command becomes "-XX:+UseRVV sample." If the determination results of steps S104 and S106 are both No, the argument 801 of the java command becomes "-XX:+UseRVV -XX:+UseRVC sample."

[0054] In this way, by executing the java command with arguments that are effective for optimization in the Java virtual machine 208, the Java development environment 202 can generate native code that is optimal for the extended ISA.

[0055] (effect) As can be seen from the above explanation, according to the embodiment, it becomes possible to generate native code that is optimal for the extended ISA on a computer having a system that cannot perform optimization unless an extended ISA supported by the CPU is specified in the command line arguments of the system that executes the bytecode.

[0056] In the embodiment, an environment using Java is given as an example of a system in which optimization cannot be performed unless an extended ISA supported by the CPU is specified in the command line arguments of the system that executes the bytecode. However, the present invention is not limited to this and can also be applied to environments using other programming languages, such as Python.

[0057] The program according to the present embodiment may be transferred in a state where it is stored in an electronic device, or in a state where it is not stored in an electronic device. In the latter case, the program may be transferred via a network, or in a state where it is stored in a storage medium. The storage medium is a non-transitory tangible medium. The storage medium is a computer-readable medium. The storage medium may be in any form, such as a CD-ROM or a memory card, as long as it is capable of storing a program and is computer-readable.

[0058] Although the embodiments of the present invention have been described, the embodiments are presented as examples and are not intended to limit the scope of the invention. These novel embodiments can be implemented in various other forms, and various omissions, substitutions, and modifications can be made without departing from the spirit of the invention. These embodiments and their modifications are included in the scope and spirit of the invention, and are included in the scope of the invention and its equivalents described in the claims. [Explanation of symbols]

[0059] 100...computer, 101...CPU, 102...bus, 103...RAM, 104...solid state drive, 105...Ethernet interface, 106...keyboard, 107...display, 201...Linux, 202...Java development environment, 203...Java source code, 204...Java compiler, 205...Java bytecode, 206...Java virtual machine caller, 207...ISA-command line correspondence table, 208...Java virtual machine, 209...interpreter, 210...dynamic compiler, 211...native code, 300...CPU ID register, 301...Base field, 302...Extensions field, 801...command line arguments.

Claims

1. A CPU, a storage device storing a bytecode and a system that cannot perform optimization unless an extended ISA supported by the CPU is specified in a command line argument of the system that executes the bytecode; A computer having: The storage device includes: a correspondence table indicating a correspondence between values ​​of an extension field representing the extended ISA and command line arguments required to enable optimizations corresponding to the extended ISA in the system; a program for causing the CPU to acquire an ISA supported by the CPU, acquire the extended ISA from the ISA, automatically set the extended ISA in a command line argument of the system by referring to the correspondence table, and generate a native code optimal for the extended ISA, calculator.

2. A computer having a system which cannot perform optimization unless an extended ISA supported by a CPU is specified in a command line argument of the system for executing a bytecode, A function for acquiring an ISA supported by the CPU; a function for acquiring an extended ISA from the ISA; a function of automatically setting the extended ISA in a command line argument of the system by referring to a correspondence table indicating a correspondence between a value of an extension field representing the extended ISA and a command line argument required to enable optimization corresponding to the extended ISA in the system; A function for generating native code optimal for the extended ISA; A program to achieve this.

Citation Information

Patent Citations

  • Import mechanism for hardware intrinsics

    US20200225973A1

  • Virtual machine management method, virtual machine management device, and virtual machine management program

    WO2015001615A1

  • Code generation for bytecode compiler

    JP2000040007A