CN110569039A - Method for optimizing JAVA operation on platform - Google Patents

Method for optimizing JAVA operation on platform Download PDF

Info

Publication number
CN110569039A
CN110569039A CN201910850709.3A CN201910850709A CN110569039A CN 110569039 A CN110569039 A CN 110569039A CN 201910850709 A CN201910850709 A CN 201910850709A CN 110569039 A CN110569039 A CN 110569039A
Authority
CN
China
Prior art keywords
code
java
file
platform
running
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910850709.3A
Other languages
Chinese (zh)
Inventor
李朝铭
王建华
潘琪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Software Co Ltd
Original Assignee
Inspur Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Software Co Ltd filed Critical Inspur Software Co Ltd
Priority to CN201910850709.3A priority Critical patent/CN110569039A/en
Publication of CN110569039A publication Critical patent/CN110569039A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation

Abstract

the invention discloses a method for optimizing JAVA running on a platform, which relates to the technical field of computers; the Java dynamic call is converted into the C dynamic call in the byte code compiling stage, the JAVA byte code generates machine code which can be directly operated on a platform, the platform enables a C/C + + language to more easily call a JAVA program through a dynamic library, the performance is much faster than the interpretation and operation of the JAVA byte code, the safety problem of the JAVA language code is solved, the generated machine code can be executed without depending on a specific program of a third party, and the integration with the C/C + + language is also facilitated.

Description

Method for optimizing JAVA operation on platform
Technical Field
The invention discloses a method for optimizing JAVA running on a platform, and relates to the technical field of computers.
background
JAVA is a cross-platform language and has a wide application range. The JAVA feature enables cross-platform, platform independent bytecode can be interpreted and executed by the JVM on a variety of platforms, but the problem is that the performance is slow and the source code can be relatively easily disassembled from the bytecode, the system is insecure.
in the existing mode, when a platform runs JAVA, a Hotspot JVM provided by an oracle JDK of a high version provides a JIT (Just In Time) compiler and a dynamic compiler, and when a program runs, the JIT converts a hot spot code into a machine code by preheating, and caches a bytecode during compilation In a codeCache, and In this case, a part of the hot spot code is compiled and executed instead of interpreted, although the JIT part improves the running performance of the JAVA program, the compilation is still required when the JAVA program is loaded, which consumes a long Time, and the problem of code security is not solved.
In addition, the oracle JDK9 provides a new compiling method, i.e., AOT (ahead-of-time compilation), which directly compiles the bytecode into machine code, thereby avoiding the pre-heating consumption in the aspects of JIT, etc., but the AOT compiled code is static, the performance is greatly improved, but the program still needs to rely on JAVA and class files during running, the original hello world class files are still needed during running, and the problem of code security is still not solved.
The invention discloses a method for optimizing JAVA running on a platform, which directly compiles a class file into machine codes which are the same as those generated by a C/C + + program, wherein the class file comprises an executable JAVA program and a dynamic library, the JAVA program can be directly run under an operating system without depending on a third-party program, the performance problem of the JAVA program is solved, the code safety problem is solved, and the integration with C/C + + language is facilitated.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a method for optimizing the running of JAVA on a platform, which has the characteristics of strong universality, simple and convenient implementation and the like and has wide application prospect.
The specific scheme provided by the invention is as follows:
A method for optimizing the running of JAVA on platform includes such steps as pre-compiling byte codes in class file, analyzing byte code file structure, compiling to generate assembly code, assembling the assembly code to generate object code file with organization format of o file, and linking the object code files to confirm the mutual dependency relationship.
in the method, the byte code file of JAVA main method is used for generating a directly operated machine code, and other byte code files are respectively used for generating dynamic libraries.
In the method, byte codes are compiled to generate assembly codes s files through lexical analysis, syntactic analysis and semantic analysis.
In the method, a gcc compiler is used for performing pre-compiling, compiling and assembling on the byte codes.
An optimization tool for JAVA running on a platform comprises an optimization unit,
The optimization unit carries out pre-compiling on byte codes in the JAVA general class file to analyze a byte code file structure, then carries out compiling to generate an assembly code s file, the assembly code s file is assembled to generate an object code file with an organization format of an o file, and the object code files confirm mutual dependency relationship through links to generate machine codes running on a platform and used for executing JAVA and a corresponding dynamic library.
The optimizing unit in the optimizing tool generates the byte code file of the JAVA main method into a directly operated machine code and respectively generates other byte code files into dynamic libraries.
The optimization unit in the optimization tool compiles the byte codes to generate assembly codes through lexical analysis, syntactic analysis and semantic analysis.
The optimization unit in the optimization tool utilizes a gcc compiler to perform pre-compilation, compilation and assembly on byte codes.
The invention has the advantages that:
The invention provides a method for optimizing JAVA running on a platform, which is characterized in that JAVA dynamic call is converted into C dynamic call in a byte code compiling stage, JAVA byte code is generated into machine code which can be directly run on the platform, the platform enables a C/C + + language to call a JAVA program more easily through a dynamic library, the performance is much faster than the interpretation and running of the JAVA byte code, the safety problem of the JAVA language code is solved, the generated machine code can be executed without depending on a specific program of a third party, and the integration with the C/C + + language is facilitated.
Drawings
FIG. 1 is a schematic flow diagram of the process of the present invention.
Detailed Description
The invention provides a method for optimizing JAVA running on a platform, which comprises the steps of carrying out precompilation on byte codes in a JAVA general class file to analyze a byte code file structure, then carrying out compilation to generate an assembly code s file, assembling the assembly code s file to generate an object code file with an organization format of an o file, confirming mutual dependency relationship among the object code files through links, and generating a machine code running on the platform for executing JAVA and a corresponding dynamic library.
Meanwhile, the optimization tool for the JAVA running on the platform, which is provided corresponding to the method, comprises an optimization unit,
The optimization unit carries out pre-compiling on byte codes in the JAVA general class file to analyze a byte code file structure, then carries out compiling to generate an assembly code s file, the assembly code s file is assembled to generate an object code file with an organization format of an o file, and the object code files confirm mutual dependency relationship through links to generate machine codes running on a platform and used for executing JAVA and a corresponding dynamic library.
The present invention is further described below in conjunction with the following figures and specific examples so that those skilled in the art may better understand the present invention and practice it, but the examples are not intended to limit the present invention.
By using the method of the invention, the byte codes in the JAVA general class file are pre-compiled, assembled and linked to generate a high-performance machine code executable program related to a platform,
In the pre-compiling stage, the whole byte code file is pre-read, the byte code file structure is preliminarily analyzed, then lexical analysis, syntactic analysis and semantic analysis methods are utilized to compile to generate assembly codes, the assembly code is converted into machine language in the assembling stage and correspondingly optimized, the assembly codes are assembled to generate a target code file with an organization format of o file, the target code files are linked to confirm mutual dependency relationship, and a final machine code executable program capable of directly running under an operating system and a corresponding dynamic library are generated.
in the above process, the byte code file of JAVA containing main method is generated into directly running machine code executable program, and other byte code files are respectively generated into dynamic libraries which can be called by other languages such as C/C + +, compared with JNI of JAVA, the JAVA program can be called more easily by C/C + + language through the dynamic libraries,
In the above process, the gcc compiler can be used to perform pre-compilation, compilation and assembly on the byte codes, and the mutual dependency relationship between the corresponding object code files is confirmed through linking, so as to generate machine codes running on the platform, and the machine codes are used for executing JAVA and the corresponding dynamic libraries.
In the above-mentioned process, in the byte code compiling stage, the dynamic call of JAVA is converted into dynamic call of C, so that it can be used for Linux platform, also can be used for Unix and Windows platforms, etc., and can use different versions of compiler for different types of CPU.
Similarly, when the optimization tool of the invention is used for JAVA in the optimized operation of the platform, the optimization unit pre-compiles, assembles and links the byte codes in the class file which is universal in JAVA to generate a high-performance machine code executable program related to the platform,
The optimization unit pre-reads the whole byte code file in the pre-compiling stage, preliminarily analyzes the byte code file structure, compiles the byte code file structure by utilizing lexical analysis, syntactic analysis and semantic analysis methods to generate an assembly code s file, converts the assembly code s file into machine language in the assembling stage, performs corresponding optimization, assembles the assembly code s file to generate a target code file with an organization format of an o file, confirms the mutual dependency relationship among the target code files through linking, and generates a final machine code executable program capable of directly running under an operating system and a corresponding dynamic library.
In the process, the optimizing unit generates a machine code executable program which directly runs from the byte code file of JAVA containing the main method, and respectively generates a dynamic library from other byte code files, wherein the dynamic library can be called by other languages such as C/C + + and the like, compared with JNI of JAVA, the JAVA program can be called more easily by C/C + + language through the dynamic library,
In the above process, the optimization unit may utilize the gcc compiler to perform pre-compilation, compilation and assembly on the bytecode, and the mutual dependency relationship between the corresponding object code files is confirmed through linking, so as to generate a machine code running on the platform for executing JAVA and the corresponding dynamic library.
In the process, the optimizing unit mixes the byte codes into the s file in the compiling stage, converts the dynamic call of JAVA into the dynamic call of C, can be used for Linux platforms, can also be used for Unix, Windows and other platforms, and can use compilers of different versions aiming at different types of CPUs.
The above-mentioned embodiments are merely preferred embodiments for fully illustrating the present invention, and the scope of the present invention is not limited thereto. The equivalent substitution or change made by the technical personnel in the technical field on the basis of the invention is all within the protection scope of the invention. The protection scope of the invention is subject to the claims.

Claims (8)

1. A method for optimizing JAVA running on platform includes such steps as pre-compiling byte codes in class file of JAVA, analyzing byte code file structure, compiling to generate assembly code, assembling the assembly code to generate object code file with organization format of o file, confirming mutual dependency relationship between object code files by link, and generating machine code running on platform for executing JAVA and relative dynamic library.
2. The method as claimed in claim 1, wherein the bytecode file of main method of JAVA is made into direct-running machine code, and other bytecode files are made into dynamic library separately.
3. A method according to claim 1 or 2, wherein the bytecode is compiled to generate an assembly code.s file by lexical analysis, syntactic analysis and semantic analysis.
4. the method as claimed in claim 3, wherein the byte code is precompiled, compiled and assembled using a gcc compiler.
5. An optimization tool for JAVA running on a platform is characterized by comprising an optimization unit,
the optimization unit carries out pre-compiling on byte codes in the JAVA general class file to analyze a byte code file structure, then carries out compiling to generate an assembly code s file, the assembly code s file is assembled to generate an object code file with an organization format of an o file, and the object code files confirm mutual dependency relationship through links to generate machine codes running on a platform and used for executing JAVA and a corresponding dynamic library.
6. The optimization tool according to claim 5, wherein the optimization unit generates the bytecode file of the main method in JAVA into a direct-running machine code and the other bytecode files into dynamic libraries, respectively.
7. An optimization tool according to claim 5 or 6, characterized in that the optimization unit compiles bytecodes into assembly code. s-files by lexical analysis, syntactic analysis and semantic analysis.
8. The optimization tool of claim 7, wherein the optimization unit precompiles, compiles, and assembles the byte code using a gcc compiler.
CN201910850709.3A 2019-09-10 2019-09-10 Method for optimizing JAVA operation on platform Pending CN110569039A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910850709.3A CN110569039A (en) 2019-09-10 2019-09-10 Method for optimizing JAVA operation on platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910850709.3A CN110569039A (en) 2019-09-10 2019-09-10 Method for optimizing JAVA operation on platform

Publications (1)

Publication Number Publication Date
CN110569039A true CN110569039A (en) 2019-12-13

Family

ID=68778789

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910850709.3A Pending CN110569039A (en) 2019-09-10 2019-09-10 Method for optimizing JAVA operation on platform

Country Status (1)

Country Link
CN (1) CN110569039A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112685049A (en) * 2021-01-22 2021-04-20 大连高德瑞信科技有限公司 JAVA byte code compiling method
CN113032035A (en) * 2019-12-24 2021-06-25 Oppo广东移动通信有限公司 Configuration file processing method and device and electronic equipment
CN113760490A (en) * 2020-10-27 2021-12-07 北京京东振世信息技术有限公司 Method and device for processing micro-service, electronic equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104077173A (en) * 2013-03-31 2014-10-01 宋浩 Execution method for JAVA program instruction in smart card, and smart card
CN105683924A (en) * 2013-06-06 2016-06-15 微软技术许可有限责任公司 Debugging native code by transitioning from execution in native mode to execution in interpreted mode

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104077173A (en) * 2013-03-31 2014-10-01 宋浩 Execution method for JAVA program instruction in smart card, and smart card
CN105683924A (en) * 2013-06-06 2016-06-15 微软技术许可有限责任公司 Debugging native code by transitioning from execution in native mode to execution in interpreted mode

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
曾亮: "嵌入式浏览器Javascript引擎的分析与优化", 《万方数据库》, 1 September 2016 (2016-09-01), pages 3 *
曾亮: "嵌入式浏览器Javascript引擎的分析与优化", 《万方数据库》, pages 3 *
石学林: "Cobol2Java源代码翻译关键技术研究", 《中国优秀博硕士学位论文全文数据库 (博士) 信息科技辑 (月刊) 》, pages 2 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113032035A (en) * 2019-12-24 2021-06-25 Oppo广东移动通信有限公司 Configuration file processing method and device and electronic equipment
WO2021129339A1 (en) * 2019-12-24 2021-07-01 Oppo广东移动通信有限公司 Method and device for processing configuration file, electronic apparatus, and storage medium
CN113032035B (en) * 2019-12-24 2022-07-12 Oppo广东移动通信有限公司 Configuration file processing method and device and electronic equipment
CN113760490A (en) * 2020-10-27 2021-12-07 北京京东振世信息技术有限公司 Method and device for processing micro-service, electronic equipment and storage medium
CN113760490B (en) * 2020-10-27 2023-09-05 北京京东振世信息技术有限公司 Method and device for processing micro-service, electronic equipment and storage medium
CN112685049A (en) * 2021-01-22 2021-04-20 大连高德瑞信科技有限公司 JAVA byte code compiling method
CN112685049B (en) * 2021-01-22 2024-02-13 大连高德瑞信科技有限公司 JAVA byte code compiling method

Similar Documents

Publication Publication Date Title
US9417857B2 (en) Unifying static and dynamic compiler optimizations in source-code bases
JP4841118B2 (en) Software development infrastructure
CN110569039A (en) Method for optimizing JAVA operation on platform
US5854932A (en) Compiler and method for avoiding unnecessary recompilation
Zhao et al. The HipHop compiler for PHP
US20010011371A1 (en) Compilation of embedded language statements in a source code program
WO2001002956A2 (en) Compiling and persisting of intermediate language code
Shen et al. A retargetable static binary translator for the ARM architecture
Hwang et al. DisIRer: Converting a retargetable compiler into a multiplatform binary translator
CN113220326B (en) Intelligent contract upgrading method and block chain system
Béra et al. Sista: Saving optimized code in snapshots for fast start-up
US7152223B1 (en) Methods and systems for compiling and interpreting one or more associations between declarations and implementations in a language neutral fashion
US7685565B1 (en) Run time reconfiguration of computer instructions
Kawahito et al. A new idiom recognition framework for exploiting hardware-assist instructions
Kwon et al. Assessment of the Java programming language for use in high integrity systems
Allan et al. abc the aspectBench compiler for aspectJ a workbench for aspect-oriented programming language and compilers research
CN113220327B (en) Intelligent contract upgrading method and block chain system
Bockisch et al. Envelope-based weaving for faster aspect compilers
JP2007226589A (en) Program conversion system
US7774767B2 (en) System and method for compiler interprocedural optimization having support for object files in libraries
Park et al. Reusing the Optimized Code for JavaScript Ahead-of-Time Compilation
Golsch WebAssembly: Basics
Nadera et al. The varying faces of a program transformation systems
Ralston et al. Tail Call Elimination in OpenSmalltalk
CN112162736A (en) Device and method for realizing software cross-platform binary compatibility among same CPU instruction set devices

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination