CN110275713A - A kind of improved method of Java Virtual Machine rear end compiling - Google Patents
A kind of improved method of Java Virtual Machine rear end compiling Download PDFInfo
- Publication number
- CN110275713A CN110275713A CN201910590531.3A CN201910590531A CN110275713A CN 110275713 A CN110275713 A CN 110275713A CN 201910590531 A CN201910590531 A CN 201910590531A CN 110275713 A CN110275713 A CN 110275713A
- Authority
- CN
- China
- Prior art keywords
- compiled
- virtual machine
- compiling
- analysis
- bytecode
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The invention discloses a kind of improved methods of Java Virtual Machine rear end compiling, and the method includes the steps 1: being labeled to the source code of java program, append notes to needing the method head locally compiled to increase@NativeCompile;Step 2: the code appended notes to being compiled, morphological analysis is carried out, syntactic analysis is carried out after morphological analysis is out of question, then carry out lexical analysis, bytecode generation is carried out after the completion of semantic analysis, the bytecode of generation is saved in file system;Step 3: operation java program, compiler judge whether to need to open local compiling according to computing resource by obtaining virtual machine operating condition.
Description
Technical field
The present invention relates to computer software technical fields, are a kind of improvement of Java Virtual Machine rear end compiling specifically
Method.
Background technique
Software systems have applied to all trades and professions of social production, and java development language accounting compares in Software Industry
Greatly, small to arrive personal mobile phone tablet computer, field of aerospace is arrived greatly, all uses java as software development language.
Java obtains cross-platform characteristic by way of sacrificing runnability and some localisation features, accomplishes primary
It writes, multi-platform operation facilitates software development.Java applet optimizes in all fields, and compilation phase is divided into front end volume
Device and back-end compiler are translated, front end stresses morphological analysis, syntactic analysis and semantic analysis.Rear end stresses to carry out bytecode excellent
Change, enables the program of java language development as far as possible close to the local system speed of service.Rear end compiling optimization have Just-In-Time and
Static compilation.Two kinds of compiling mode major defects are that Just-In-Time is compiled for hot spot code, in the process of compiling
Middle relatively consumption computing resource, can influence arithmetic speed to a certain extent.And the time of static compilation is longer, influences program
Start speed.Therefore it is labeled in code layer in face of code for situation as above proposition.Emphasis code segment is labeled as needing
It is compiled as local machine code.Java applet just can determine which code is the part for needing to optimize before runtime.
Java compiler can be compiled as particular code segment local machine code, can directly be run in memory, and not have to again
It is run in java virtual machine.To mitigate jvm load.What emphasis code segment was primarily directed to be closely related with client
Logic.Everyone is different to the tolerance of system reaction time.Normal client is required of shortest time response, system response
Overlong time be easy to cause customer churn, affects to company's business revenue.
Summary of the invention
The purpose of the present invention is to provide a kind of improved methods of Java Virtual Machine rear end compiling, for solving the prior art
Middle system response time length causes user to be difficult to the problem of enduring and causing customer churn.
The present invention is solved the above problems by following technical proposals:
A kind of improved method of Java Virtual Machine rear end compiling, described method includes following steps:
Step 1: the source code of java program being labeled, increases@on the method head for needing locally to be compiled
NativeCompile appends notes to;
Step 2: the code appended notes to being compiled, morphological analysis is carried out, carries out grammer point after morphological analysis is out of question
Analysis, then lexical analysis is carried out, bytecode generation is carried out after the completion of semantic analysis, and the bytecode of generation is saved in file system
In;
Step 3: operation java program, compiler are judged whether by obtaining virtual machine operating condition according to computing resource
Need to open local compiling.
By this method, the rear end jvm compiles targeted code logic and optimizes, to spy in the compiling of the rear end jvm
Calibration is known and is judged, if there is the method for significant field, starts compiling in real time, code is localized compiling, allows journey
Sequence is run directly on local computer, rather than on virtual machine.The execution efficiency of ad hoc approach can be improved in this way.It keeps away simultaneously
Exempt from other uncorrelated logic effects and executes speed.It is advanced optimized in terms of general optimum, facilitates promotion and execute effect
Rate.
Further, current environment is judged when bytecode is loaded into virtual machine for the first time, if current environment
Available computational resources deficiency does not compile then, is compiled again in the case where resources of virtual machine abundance.
Further, after front-end compiler is compiled into bytecode to java source code when compiling, back-end compiler is first to source code
The conventional optimization of progress such as common subexpression is eliminated, array range is eliminated, method is inline and escape analysis, after the completion again by word
Section code is compiled as nation method.
Compared with prior art, the present invention have the following advantages that and the utility model has the advantages that
(1) after carrying out rear end co mpiler optimization present invention uses the method, it can obviously accelerate compilation speed and execute speed,
User terminal can obtain good user experience.Avoid that static compilation and JIT compile bring starting problem in time and compiling accounts for
The problems such as with resource.
(2) present invention compiles targeted code logic in virtual machine rear end and optimizes, and compiles in virtual machine rear end
In specific identifier is judged, if there is the method for significant field, start in real time compiling, code is localized volume
It translates, program is allowed to run directly on local computer, rather than on virtual machine, it can avoid other uncorrelated logic effects and execute speed
Degree.
Detailed description of the invention
Fig. 1 is java code compilation process schematic diagram of the invention.
Specific embodiment
The present invention is described in further detail below with reference to embodiment, embodiments of the present invention are not limited thereto.
Embodiment 1:
In conjunction with shown in attached drawing 1, a kind of improved method of Java Virtual Machine rear end compiling, described method includes following steps:
Step 1: the source code of java program being labeled, increases@on the method head for needing locally to be compiled
NativeCompile appends notes to;
Step 2: the code appended notes to being compiled, morphological analysis is carried out, carries out grammer point after morphological analysis is out of question
Analysis, then lexical analysis is carried out, bytecode generation is carried out after the completion of semantic analysis, and the bytecode of generation is saved in file system
In, current environment is judged when bytecode is loaded into virtual machine for the first time, if current environment available computational resources are not
It is sufficient then do not compile, it is compiled again in the case where resources of virtual machine abundance;
Step 3: operation java program, compiler are judged whether by obtaining virtual machine operating condition according to computing resource
Need to open local compiling, after front-end compiler is compiled into bytecode to java source code when compiling, back-end compiler is first to source code
The conventional optimization of progress such as common subexpression is eliminated, array range is eliminated, method is inline and escape analysis, after the completion again by word
Section code is compiled as nation method.
By this method, the rear end jvm compiles targeted code logic and optimizes, to spy in the compiling of the rear end jvm
Calibration is known and is judged, if there is the method for significant field, starts compiling in real time, code is localized compiling, allows journey
Sequence is run directly on local computer, rather than on jvm virtual machine.The execution efficiency of ad hoc approach can be improved in this way.Together
When avoid other uncorrelated logic effects from executing speed.It is advanced optimized in terms of general optimum, helps to be promoted and hold
Line efficiency.
For same code, using different compiling modes, Comparative result is as follows:
Java static compilation | Java on-the-flier compiler | Customized compiling | |
Compilation time | 1000 milliseconds | 30 milliseconds | 40 milliseconds |
Start speed | 30 milliseconds | 10 milliseconds | 20 milliseconds |
Cpu occupancy when operation | 10% | 20% | 10% |
File size after compiling | 200M | 160M | 170M |
Combined data is it is recognised that customized locally compile the Optimum Synthesis advantage of static compilation and on-the-flier compiler.
Although reference be made herein to invention has been described for explanatory embodiment of the invention, and above-described embodiment is only this hair
Bright preferable embodiment, embodiment of the present invention are not limited by the above embodiments, it should be appreciated that those skilled in the art
Member can be designed that a lot of other modification and implementations, these modifications and implementations will fall in principle disclosed in the present application
Within scope and spirit.
Claims (3)
1. a kind of improved method of Java Virtual Machine rear end compiling, which is characterized in that described method includes following steps:
Step 1: the source code of java program being labeled, increases@on the method head for needing locally to be compiled
NativeCompile appends notes to;
Step 2: the code appended notes to is compiled, morphological analysis is carried out, syntactic analysis is carried out after morphological analysis is out of question, then
Lexical analysis is carried out, bytecode generation is carried out after the completion of semantic analysis, the bytecode of generation is saved in file system;
Step 3: operation java program, compiler judge whether needs according to computing resource by obtaining virtual machine operating condition
Open local compiling.
2. the improved method of Java Virtual Machine rear end compiling according to claim 1, which is characterized in that in bytecode first
It is secondary current environment to be judged when being loaded into virtual machine, it is not compiled if current environment available computational resources deficiency, in void
It is compiled again in the case that quasi- machine resource is sufficient.
3. the improved method of Java Virtual Machine rear end compiling according to claim 1, which is characterized in that front end is compiled when compiling
It translates after device is compiled into bytecode to java source code, back-end compiler first carries out conventional optimization such as common subexpression to source code and disappears
Remove, array range is eliminated, method is inline and escape analysis, bytecode is compiled as nation method again after the completion.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910590531.3A CN110275713A (en) | 2019-07-02 | 2019-07-02 | A kind of improved method of Java Virtual Machine rear end compiling |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910590531.3A CN110275713A (en) | 2019-07-02 | 2019-07-02 | A kind of improved method of Java Virtual Machine rear end compiling |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110275713A true CN110275713A (en) | 2019-09-24 |
Family
ID=67962750
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910590531.3A Pending CN110275713A (en) | 2019-07-02 | 2019-07-02 | A kind of improved method of Java Virtual Machine rear end compiling |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110275713A (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111190585A (en) * | 2019-12-12 | 2020-05-22 | 杭州安恒信息技术股份有限公司 | Method for realizing JAVA mode matching characteristic based on bytecode enhancement technology |
CN111274551A (en) * | 2019-12-30 | 2020-06-12 | 上海上讯信息技术股份有限公司 | Compiler-based java code protection method and device and electronic equipment |
CN111770113A (en) * | 2020-08-31 | 2020-10-13 | 支付宝(杭州)信息技术有限公司 | Method for executing intelligent contract, block chain node and node equipment |
CN111796865A (en) * | 2020-06-28 | 2020-10-20 | 北京字节跳动网络技术有限公司 | Byte code file modification method and device, terminal equipment and medium |
CN111984243A (en) * | 2020-08-31 | 2020-11-24 | 上海玳鸽信息技术有限公司 | General security check and function extension method and device based on annotation |
CN112346778A (en) * | 2020-10-28 | 2021-02-09 | 常州微亿智造科技有限公司 | Optimization method for automatically generating byte codes during compiling of Java program |
CN112394941A (en) * | 2020-11-18 | 2021-02-23 | 京东数字科技控股股份有限公司 | Code preheating method and device, electronic equipment and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1790267A (en) * | 2005-12-14 | 2006-06-21 | 浙江大学 | Virtual machine compiling system implementation method applied in Java operation system |
US20070234315A1 (en) * | 2006-02-09 | 2007-10-04 | International Business Machines Corporation | Compiling an application by cluster members |
US20130311980A1 (en) * | 2010-06-29 | 2013-11-21 | Google Inc. | Selective compiling method, device, and corresponding computer program product |
CN103729235A (en) * | 2013-12-24 | 2014-04-16 | 华为技术有限公司 | Java virtual machine (JVM) and compiling method thereof |
CN104133844A (en) * | 2014-06-27 | 2014-11-05 | 小米科技有限责任公司 | Method and device for loading webpage |
CN107729118A (en) * | 2017-09-25 | 2018-02-23 | 复旦大学 | Towards the method for the modification Java Virtual Machine of many-core processor |
CN107943486A (en) * | 2017-12-19 | 2018-04-20 | 北京星河星云信息技术有限公司 | A kind of multilingual code compiling method, distribution method, device and system |
-
2019
- 2019-07-02 CN CN201910590531.3A patent/CN110275713A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1790267A (en) * | 2005-12-14 | 2006-06-21 | 浙江大学 | Virtual machine compiling system implementation method applied in Java operation system |
US20070234315A1 (en) * | 2006-02-09 | 2007-10-04 | International Business Machines Corporation | Compiling an application by cluster members |
US20130311980A1 (en) * | 2010-06-29 | 2013-11-21 | Google Inc. | Selective compiling method, device, and corresponding computer program product |
CN103729235A (en) * | 2013-12-24 | 2014-04-16 | 华为技术有限公司 | Java virtual machine (JVM) and compiling method thereof |
CN104133844A (en) * | 2014-06-27 | 2014-11-05 | 小米科技有限责任公司 | Method and device for loading webpage |
CN107729118A (en) * | 2017-09-25 | 2018-02-23 | 复旦大学 | Towards the method for the modification Java Virtual Machine of many-core processor |
CN107943486A (en) * | 2017-12-19 | 2018-04-20 | 北京星河星云信息技术有限公司 | A kind of multilingual code compiling method, distribution method, device and system |
Non-Patent Citations (1)
Title |
---|
黑尾土拨鼠: "java编译器优化和运行期优化", 《HTTPS://BLOG.CSDN.NET/U013305783/ARTICLE/DETAILS/81279175》 * |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111190585A (en) * | 2019-12-12 | 2020-05-22 | 杭州安恒信息技术股份有限公司 | Method for realizing JAVA mode matching characteristic based on bytecode enhancement technology |
CN111190585B (en) * | 2019-12-12 | 2023-05-02 | 杭州安恒信息技术股份有限公司 | Method for realizing JAVA mode matching characteristic based on byte code enhancement technology |
CN111274551A (en) * | 2019-12-30 | 2020-06-12 | 上海上讯信息技术股份有限公司 | Compiler-based java code protection method and device and electronic equipment |
CN111796865A (en) * | 2020-06-28 | 2020-10-20 | 北京字节跳动网络技术有限公司 | Byte code file modification method and device, terminal equipment and medium |
CN111796865B (en) * | 2020-06-28 | 2024-04-16 | 北京字节跳动网络技术有限公司 | Byte code file modification method, device, terminal equipment and medium |
CN111770113A (en) * | 2020-08-31 | 2020-10-13 | 支付宝(杭州)信息技术有限公司 | Method for executing intelligent contract, block chain node and node equipment |
CN111984243A (en) * | 2020-08-31 | 2020-11-24 | 上海玳鸽信息技术有限公司 | General security check and function extension method and device based on annotation |
CN111770113B (en) * | 2020-08-31 | 2021-07-30 | 支付宝(杭州)信息技术有限公司 | Method for executing intelligent contract, block chain node and node equipment |
US11366677B2 (en) | 2020-08-31 | 2022-06-21 | Alipay (Hangzhou) Information Technology Co., Ltd. | Methods, blockchain nodes, and node devices for executing smart contract |
CN112346778A (en) * | 2020-10-28 | 2021-02-09 | 常州微亿智造科技有限公司 | Optimization method for automatically generating byte codes during compiling of Java program |
CN112394941A (en) * | 2020-11-18 | 2021-02-23 | 京东数字科技控股股份有限公司 | Code preheating method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110275713A (en) | A kind of improved method of Java Virtual Machine rear end compiling | |
US5815719A (en) | Method and apparatus for easy insertion of assembler code for optimization | |
US8522223B2 (en) | Automatic function call in multithreaded application | |
US6233733B1 (en) | Method for generating a Java bytecode data flow graph | |
US6973644B2 (en) | Program interpreter | |
CN100405294C (en) | System, method and program product to optimize code during run time | |
US8612948B2 (en) | Dynamic compiler program, dynamic compiling method and dynamic compiling device | |
US9081586B2 (en) | Systems and methods for customizing optimization/transformation/ processing strategies | |
US20060064682A1 (en) | Compiler, compilation method, and compilation program | |
JP2002024032A (en) | Method and system for compiling plurality of languages | |
CN111770205B (en) | Method, block chain node, system and storage medium for executing intelligent contract | |
JPH07129412A (en) | Method and equipment for compilation | |
US8341613B2 (en) | Reducing stack space consumption via head-call optimization | |
CN111770204A (en) | Method for executing intelligent contract, block chain node and storage medium | |
CN111768183A (en) | Method for executing intelligent contract, block chain node and storage medium | |
US20200210156A1 (en) | Compiler-Generated Asynchronous Enumerable Object | |
US8117604B2 (en) | Architecture cloning for power PC processors | |
CN113220326B (en) | Intelligent contract upgrading method and block chain system | |
CN107145367A (en) | A kind of visualization dissemination method developed for front end and system | |
CN112416313B (en) | Compiling method supporting large integer data type and operator | |
US8938728B2 (en) | Dynamic compiler program, dynamic compiling method and dynamic compiling device | |
Lee et al. | Scalable size inliner for mobile applications (WIP) | |
CN105786465A (en) | Scripting language execution method and device | |
US11429358B2 (en) | Representing asynchronous state machine in intermediate code | |
JP2007226589A (en) | Program conversion system |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190924 |