CN108153530A - Optimization method, device, storage medium, processor and the terminal of bytecode - Google Patents

Optimization method, device, storage medium, processor and the terminal of bytecode Download PDF

Info

Publication number
CN108153530A
CN108153530A CN201711430709.5A CN201711430709A CN108153530A CN 108153530 A CN108153530 A CN 108153530A CN 201711430709 A CN201711430709 A CN 201711430709A CN 108153530 A CN108153530 A CN 108153530A
Authority
CN
China
Prior art keywords
bytecode
code
recursive call
function
partial bytes
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.)
Granted
Application number
CN201711430709.5A
Other languages
Chinese (zh)
Other versions
CN108153530B (en
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.)
Shanghai Neteasy Brilliant Network Technology Co ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201711430709.5A priority Critical patent/CN108153530B/en
Publication of CN108153530A publication Critical patent/CN108153530A/en
Application granted granted Critical
Publication of CN108153530B publication Critical patent/CN108153530B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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
    • G06F8/4441Reducing the execution time required by the program code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45508Runtime interpretation or emulation, e g. emulator loops, bytecode interpretation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention discloses a kind of optimization method of bytecode, device, storage medium, processor and terminals.This method includes:Function byte code is parsed from function to be optimized;Recursive call partial bytes code is obtained from function byte code, wherein, recursive call partial bytes code has fixed cycle-index;Recursive call partial bytes code is converted into the bytecode that single continuously performs, and delete the associated call instruction byte code of recursive call partial bytes code according to the cycling condition of cycle-index and recursive call partial bytes;Function byte code is replaced with into transformed bytecode and is exported.The technical issues of prioritization scheme complexity that the present invention solves the Python program runnabilities provided in the relevant technologies is higher, practicability is poor, performance boost is limited.

Description

Optimization method, device, storage medium, processor and the terminal of bytecode
Technical field
The present invention relates to computer realm, in particular to a kind of optimization method of bytecode, device, storage medium, Processor and terminal.
Background technology
Python is the conventional computer programming language of a kind of object-oriented, explanation type, fast with grammer gracefulness, exploitation Speed supports that the advantages that regime type, abundant java standard library is famous, therefore is used widely in different field.It is opened in game During hair, used mainly as Business Logic script.However, in practical item development, Python languages The shortcomings that speech also very significantly, wherein, it is maximum the problem of one of be that the speed of service is slow.It is many to be developed using Python Project in stage middle and later periods since service logic is increasingly complicated, calculated load aggravate, it is easy to reach performance bottleneck.Through excessive The reason of analysis finds, causes this phenomenon is:The design defect of Python interpreters in itself.Python is born in last Century, many design concepts adopted at that time have not been suitable for current hardware condition.In actual use Python In Project-developing, it usually needs special manpower is arranged to remove optimization program code, part producing power is caused to be wasted in program optimization In work.
Python interpreters are bytecode first by compilation of source code, recycle Python virtual machines when performing program Bytecode after loading compiling performs.On the one hand technology based on virtual machine can realize the cross-platform characteristic of language, the opposing party Face can realize that regime type is supported.Bytecode-optimized scheme provided in the relevant technologies can mainly include following step Suddenly:
The first step, by function expense statistical tool (such as:CProfile it) counts in a period of time, performs different functions The time consumed.
Second step, for time longer function is performed, analyze the source code of the function, search the generation there are performance bottleneck Code.
Third step, change there are performance bottleneck code, to promote program feature.
4th step, by modification, there are the executive overhead before the code of performance bottleneck, there are the codes of performance bottleneck with modification Whether executive overhead later is compared, verify that there are the code revisions of performance bottleneck to come into force.If changing Pending The Entry Into Force, weigh Multiple above-mentioned steps, until program feature reaches service requirement.
Based on abovementioned steps, when navigating to the code there are performance bottleneck, additionally provided in the relevant technologies following several Prioritization scheme, but these prioritization schemes are the improvement made based on linguistic level mostly:
Scheme one, the optimization by changing the literary style of Python to realize to Python.The defects of such scheme, exists In:Manual modification source code line by line is needed, and the impact of performance promoted is limited.
Scheme two, the C++ization of Python source codes realize the optimization to Python.Although the program can be greatly Program operational efficiency is promoted, but is had a disadvantage in that:Development efficiency is low, it is difficult to take out the code of suitable C++ization, and lose The regime type characteristic of Python loses the hot update mechanism of Python.Once needing to change source code, just need to compile again It is translated into C++ to be issued, cost consumption is huge.Therefore, this prioritization scheme is only suitable for service logic fixed project.
Scheme three is realized by Just-In-Time technology (Just in time, referred to as JIT) to the excellent of Python Change.But for particular platform, apple IOS systems do not support JIT at present, and process can be led to by operating system by opening JIT Terminate.Android system although supporting JIT, need interpreter support advanced reduced instruction set machine (ARM) framework across flat Platform compiles, and maintenance cost is higher, and the JIT interpreters realization of increasing income such as Pyston at present has stopped safeguarding or for ARM framework branch Hold limit.
For it is above-mentioned the problem of, currently no effective solution has been proposed.
Invention content
At least part embodiment of the present invention provide a kind of optimization method of bytecode, device, storage medium, processor and Terminal, it is higher, practical at least to solve the prioritization scheme complexity of the Python program runnabilities provided in the relevant technologies The technical issues of property is poor, performance boost is limited.
According to a wherein embodiment of the invention, a kind of optimization method of bytecode is provided, including:
Function byte code is parsed from function to be optimized;Recursive call partial bytes code is obtained from function byte code, Wherein, recursive call partial bytes code has fixed cycle-index;According to following for cycle-index and recursive call partial bytes Recursive call partial bytes code is converted to the bytecode that single continuously performs by ring condition, and deletes recursive call partial bytes code Associated call instruction byte code;Function byte code is replaced with into transformed bytecode and is exported.
Optionally, recursive call partial bytes code is obtained from function byte code to include:It searches and adjusts from function byte code With command byte code;Recursive call partial bytes code is obtained by call instruction byte code.
Optionally, recursive call partial bytes code is converted to what single continuously performed according to cycle-index and cycling condition Bytecode includes:The copy amount of bytecode that single continuously performs is determined by cycle-index;It is determined often using cycling condition The corresponding execution content of a copy;According to copy amount and perform content that recursive call partial bytes code is converted to single is continuous The bytecode of execution.
Optionally, it continuously performs recursive call partial bytes code is converted to single according to cycle-index and cycling condition Bytecode after, further include:Determine that there are jump instruction bytecodes before recursive call partial bytes code is performed;According to list The byte location that byte location adjustment jump instruction bytecode occupied by the secondary bytecode continuously performed is directed toward again.
Optionally, function byte code is replaced with into transformed bytecode using Python hot update mechanisms and exported.
According to a wherein embodiment of the invention, a kind of optimization device of bytecode is additionally provided, including:
Parsing module, for parsing function byte code from function to be optimized;Acquisition module, for from function byte code Middle acquisition recursive call partial bytes code, wherein, recursive call partial bytes code has fixed cycle-index;First processing mould Block, for recursive call partial bytes code to be converted to single according to the cycling condition of cycle-index and recursive call partial bytes The bytecode continuously performed, and delete the associated call instruction byte code of recursive call partial bytes code;Second processing module is used In function byte code is replaced with transformed bytecode and is exported.
Optionally, acquisition module includes:Searching unit, for searching call instruction byte code from function byte code;It obtains Unit is taken, recursive call partial bytes code is obtained for passing through call instruction byte code.
Optionally, first processing module includes:First determination unit determines that single continuously performs for passing through cycle-index Bytecode copy amount;Second determination unit, for determining the corresponding execution content of each copy using cycling condition;Turn Unit is changed, for according to copy amount and performing content recursive call partial bytes code being converted to the byte that single continuously performs Code.
Optionally, above device further includes:Determining module, for determining to deposit before recursive call partial bytes code is performed In jump instruction bytecode;Module is adjusted, adjusts and jumps for the byte location according to occupied by the bytecode that single continuously performs Turn the byte location that command byte code is directed toward again.
Optionally, function byte code is replaced with into transformed bytecode using Python hot update mechanisms and exported.
According to a wherein embodiment of the invention, a kind of storage medium is additionally provided, storage medium includes the program of storage, In, equipment performs the optimization method of above-mentioned bytecode where controlling storage medium when program is run.
According to a wherein embodiment of the invention, a kind of processor is additionally provided, processor is used to run program, wherein, journey The optimization method of above-mentioned bytecode is performed during sort run.
According to a wherein embodiment of the invention, a kind of terminal is additionally provided, including:One or more processors, memory, Display device and one or more program, wherein, one or more programs are stored in memory, and be configured as by One or more processors perform, and one or more programs are used to perform the optimization method of above-mentioned bytecode.
In at least part embodiment of the present invention, using parsing function byte code from function to be optimized, and from function The mode of the recursive call partial bytes code with fixed cycle-index is obtained in bytecode, by according to cycle-index and following Recursive call partial bytes code is converted to the bytecode that single continuously performs by the cycling condition of ring calling section byte, and is deleted The associated call instruction byte code of recursive call partial bytes code and function byte code is replaced with into transformed bytecode simultaneously Output has reached on the basis of the optimization of existing code layer, by analyzing the circle logic of bytecode and passing through loop unrolling Mode optimizes circle logic expense, further to promote the purpose of Python program runnabilities, it is achieved thereby that The technique effect of bytecode rank significantly lifting function execution efficiency, and then solve the Python provided in the relevant technologies The technical issues of prioritization scheme complexity of program runnability is higher, practicability is poor, performance boost is limited.
Description of the drawings
Attached drawing described herein is used to provide further understanding of the present invention, and forms the part of the application, this hair Bright illustrative embodiments and their description do not constitute improper limitations of the present invention for explaining the present invention.In the accompanying drawings:
Fig. 1 is the flow chart according to the present invention wherein optimization method of the bytecode of an embodiment;
Fig. 2 is the flow chart according to the bytecode loop unrolling process of a wherein preferred embodiment of the invention;
Fig. 3 is the flow chart according to the optimization device of the present invention wherein bytecode of an embodiment;
Fig. 4 is the flow chart according to the optimization device of the present invention wherein bytecode of a preferred embodiment.
Specific embodiment
In order to which those skilled in the art is made to more fully understand the present invention program, below in conjunction in the embodiment of the present invention The technical solution in the embodiment of the present invention is clearly and completely described in attached drawing, it is clear that described embodiment is only The embodiment of a part of the invention, instead of all the embodiments.Based on the embodiments of the present invention, ordinary skill people Member's all other embodiments obtained without making creative work should all belong to the model that the present invention protects It encloses.
It should be noted that term " first " in description and claims of this specification and above-mentioned attached drawing, " Two " etc. be the object for distinguishing similar, and specific sequence or precedence are described without being used for.It should be appreciated that it uses in this way Data can be interchanged in the appropriate case, so as to the embodiment of the present invention described herein can in addition to illustrating herein or Sequence other than those of description is implemented.In addition, term " comprising " and " having " and their any deformation, it is intended that cover Cover it is non-exclusive include, be not necessarily limited to for example, containing the process of series of steps or unit, method, system, product or equipment Those steps or unit clearly listed, but may include not listing clearly or for these processes, method, product Or the intrinsic other steps of equipment or unit.
According to a wherein embodiment of the invention, a kind of embodiment of the optimization method of bytecode is provided, needs what is illustrated It is that step shown in the flowchart of the accompanying drawings can perform in the computer system of such as a group of computer-executable instructions, Also, although logical order is shown in flow charts, in some cases, it can be performed with the sequence being different from herein Shown or described step.
Fig. 1 is according to the flow chart of the present invention wherein optimization method of the bytecode of an embodiment, as shown in Figure 1, the party Method includes the following steps:
Step S10 parses function byte code from function to be optimized;
Step S12 obtains recursive call partial bytes code from function byte code, wherein, recursive call partial bytes code With fixed cycle-index;
Step S14, according to the cycling condition of cycle-index and recursive call partial bytes by recursive call partial bytes code The bytecode that single continuously performs is converted to, and deletes the associated call instruction byte code of recursive call partial bytes code;
Function byte code is replaced with transformed bytecode and exported by step S16.
By above-mentioned steps, it may be used and function byte code is parsed from function to be optimized, and from function byte code The mode of the recursive call partial bytes code with fixed cycle-index is obtained, by according to cycle-index and recursive call portion Recursive call partial bytes code is converted to the bytecode that single continuously performs by the cycling condition of point byte, and deletes recursive call The associated call instruction byte code of partial bytes code and function byte code is replaced with into transformed bytecode and is exported, reached Arrived existing code layer optimization on the basis of, analyze the circle logic of bytecode and by loop unrolling by way of to following Ring logistical overhead optimizes, further to promote the purpose of Python program runnabilities, it is achieved thereby that in bytecode level The not significantly technique effect of lifting function execution efficiency, and then solve the operation of the Python programs provided in the relevant technologies The technical issues of prioritization scheme complexity of performance is higher, practicability is poor, performance boost is limited.
In a preferred implementation process, function byte code is replaced with into transformed bytecode using Python hot update mechanisms And it exports.
The type function (FunctionType) of Python is made of following member:
(1) func_code refers to type of code (CodeType) object of Python;
(2) func_globals includes the dictionary of global context;
(3) func_closure includes cell space tuple;
(4) func_defaults includes default parameters;
(5) func_dict represents the NameSpace of arbitrary function attribute;
(6) func_name representative functions title.
The type of code of Python is made of following member:
(1) co_code represents bytecode;
(2) co_cellvars represents the variable name tuple that nested function calls;
(3) co_consts represents constant tuple;
(4) co_filename represents filename;
(5) number of co_argcount expression parameters, not including * and * * parameters;
(6) co_firstlineno expressions are compiled the first row line number of source code;
(7) co_flags represents flag bit;
(8) co_freevars represents free variable;
(9) co_lnotab represents the corresponding bytecode offset of source code line number;
(10) co_names represents all variable name tuples in code;
(11) co_nlocals represents local variable number;
(12) co_stacksize represents virtual machine storehouse size;
(13) co_varnames represents the local variable name of whole and parameter name tuple.
By analysis it is found that the function of Python is mainly by member compositions such as func_code, and bytecode is then present in In the co_code of func_code.For this purpose, the prioritization scheme that the embodiment of the present invention is provided is mainly by changing func_ The objects such as code, co_code are realized.
Optionally, in step s 12, recursive call partial bytes code is obtained from function byte code can include following hold Row step:
Step S121 searches call instruction byte code from function byte code;
Step S122 obtains recursive call partial bytes code by call instruction byte code.
Specifically, it is searched by taking FOR loop as an example, in the bytecode obtained in parsing and obtains iterator (GET_ITER), for Cycle starting (FOR_ITER) redirects bytecodes such as (JUMP_ABSOLUTE), and then determines the bytecode of cyclic part.In addition, The optimal way is equally applicable to WHILE cycles.
Optionally, in step S14, recursive call partial bytes code is converted into list according to cycle-index and cycling condition The secondary bytecode continuously performed can include step performed below:
Step S141 determines the copy amount of bytecode that single continuously performs by cycle-index;
Step S142 determines the corresponding execution content of each copy using cycling condition;
Recursive call partial bytes code is converted to single and continuously performed by step S143 according to copy amount and execution content Bytecode.
For loop unrolling optimization, it is (i.e. N number of the bytecode that fixed cycles number is N can be launched into n times calling Copy) and cycle associated byte code is deleted, so as to achieve the purpose that loop unrolling optimizes.Such as:For following Python functions:
def f():
for i in xrange(2):
print“hello world!”
The function of the function is to print " hello world twice using for cycles!" (i.e. above-mentioned execution content) character String.Its bytecode of decompiling is as follows:
Wherein, function byte code arranges the byte location represented where bytecode positioned at the leftmost side one since byte 0, in Between a row represent the corresponding virtual machine assembly instruction of binary bytecode, the row of the rightmost side one represent the corresponding parameter of instruction.
It can be seen that from byte location 0 to byte location 27 be for cycles in itself, from byte location 22 to byte location 23 be the sentence in cycle.Specifically, SETUP_LOOP, CALL_FUNCTION, GET_ITER, FOR_ITER, JUMP_ These bytecodes of ABSOLUTE and POP_BLOCK and for cycles itself are related.This part instruction executive overhead is larger, but with Printing " hello world " character string is unrelated in cycle, is carried for this purpose, can be optimized to circle logic expense with obtaining performance It rises.Above-metioned instruction is deleted, while for is recycled into interior sentence printable character string " the hello world performed!" bytecode LOAD_CONST and PRINT_ITEM replicates two parts (i.e. copy amount is 2), so as to obtain effect of optimization.Modified bytecode It is as follows:
Finally, the relevant instruction of above-mentioned cycle is all optimized, and function behavior does not change, still So represent printing " hello world twice!" character string.If being translated into Python code, function work(can be obtained Can be still cycle printing " hello world twice!" character string.
def f():
print“hello world!”
print“hello world!”
It should be noted that in the case where recycling on-fixed number, then without above-mentioned optimal way, reason exists In:Modification bytecode process is also there are expense in itself and modification process expense is larger.If function is fixed cycles number, A bytecode then need to be only changed, with this majorized function execution performance.However, if cycle-index is not fixed, need repeatedly Bytecode is changed, it is this to operate the decline that cause function execution performance instead.
Optionally, in step S14, recursive call partial bytes code is converted into single according to cycle-index and cycling condition After the bytecode continuously performed, step performed below can also be included:
Step S17 determines that there are jump instruction bytecodes before recursive call partial bytes code is performed;
Step S18, the byte location adjustment jump instruction bytecode weight according to occupied by the bytecode that single continuously performs The byte location being newly directed toward.
Such as:Before the bytecode of modification cyclic part, JUMP_ABSOLUTE expressions jump to byte address 3, i.e.,
0 JUMP_ABSOLUTE 3
3 LOAD_CONST 0(None)
5 RETURN_VALUE
After the bytecode of modification cyclic part, due to being newly inserted into sentence copy in the N part cycles replicated, then JUMP_ ABSOLUTE, which needs to be directed toward new byte location, just can guarantee and is consistent with original function behavior.
Fig. 2 is according to the flow chart of the bytecode loop unrolling process of a wherein preferred embodiment of the invention, such as Fig. 2 institutes Show, bytecode loop unrolling process can include following execution step:
Step S201, function to be optimized is inputted, wherein, function to be optimized includes at least:Function byte code and context are empty Between.
Step S202, the byte of function is parsed from function to be optimized using Python java standard library dis, opcode libraries Code.
Step S203, the bytecode obtained according to parsing, analyzes the bytecode for being related to cyclic part.
Step S204, bytecode in cycle is replicated more parts according to the bytecode of cycle-index expansion cyclic part, laid equal stress on New modification JUMP instructions, the bytecode that its direction is made originally to be directed toward.
Step S205, finally the function changed is exported.
Specifically, the hot update mechanism of Python can be used, by whole bytes of function to be optimized during program performs Code replaces with modified bytecode, so as to significantly promote program execution performance.
It finds after tested, the bytecode after optimization dramatically saves the unnecessary instruction of python virtual machines.Test wrapper Border is personal computer (PC), and interpreter version is Python 2.7, uses timeit module computing costs, default loop 100 The function call test of ten thousand times.Function call expense before loop unrolling optimization is 0.379 second, the function call expense after optimization It it is 0.144 second, i.e., expense declines about 62%.
According to a wherein embodiment of the invention, a kind of embodiment of the optimization device of bytecode is additionally provided, Fig. 3 is basis The flow chart of the optimization device of the present invention wherein bytecode of an embodiment, as shown in figure 3, the device includes:Parsing module 10, For parsing function byte code from function to be optimized;Acquisition module 20, for obtaining recursive call from function byte code Partial bytes code, wherein, recursive call partial bytes code has fixed cycle-index;First processing module 30, for according to Recursive call partial bytes code is converted to what single continuously performed by the cycling condition of cycle-index and recursive call partial bytes Bytecode, and delete the associated call instruction byte code of recursive call partial bytes code;Second processing module 40, for by function Bytecode replaces with transformed bytecode and exports.
In a preferred implementation process, function byte code is replaced with into transformed bytecode using Python hot update mechanisms And it exports.
Optionally, acquisition module 20 includes:Searching unit (not shown) is called for being searched from function byte code Command byte code;Acquiring unit (not shown) obtains recursive call partial bytes code for passing through call instruction byte code.
Optionally, first processing module 30 includes:First determination unit (not shown), it is true for passing through cycle-index The copy amount of bytecode that order continuously performs;Second determination unit (not shown), for true using cycling condition Determine the corresponding execution content of each copy;Converting unit (not shown), for that will be followed according to copy amount and execution content Ring calling section bytecode is converted to the bytecode that single continuously performs.
Optionally, Fig. 4 is according to the flow chart of the optimization device of the present invention wherein bytecode of a preferred embodiment, is such as schemed Shown in 4, above device further includes:Determining module 50 redirects for determining to exist before recursive call partial bytes code is performed Command byte code;Module 60 is adjusted, finger is redirected for the byte location adjustment according to occupied by the bytecode that single continuously performs Enable the byte location that bytecode is directed toward again.
According to a wherein embodiment of the invention, a kind of storage medium is additionally provided, storage medium includes the program of storage, In, equipment performs the optimization method of above-mentioned bytecode where controlling storage medium when program is run.Above-mentioned storage medium can be with Including but not limited to:USB flash disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disc or CD etc. The various media that can store program code.
According to a wherein embodiment of the invention, a kind of processor is additionally provided, processor is used to run program, wherein, journey The optimization method of above-mentioned bytecode is performed during sort run.Above-mentioned processor can include but is not limited to:Microprocessor (MCU) can The processing unit of programmed logic device (FPGA) etc..
According to a wherein embodiment of the invention, a kind of terminal is additionally provided, including:One or more processors, memory, Display device and one or more program, wherein, one or more programs are stored in memory, and be configured as by One or more processors perform, and one or more programs are used to perform the optimization method of above-mentioned bytecode.In some embodiments In, above-mentioned terminal can be smart mobile phone (such as:Android phone, iOS mobile phones etc.), tablet computer, palm PC and shifting The terminal devices such as dynamic internet device (Mobile Internet Devices, referred to as MID), PAD.Above-mentioned display device can To be the liquid crystal display (LCD) of touch-screen type, which may be such that user can carry out with the user interface of terminal Interaction.In addition, above-mentioned terminal can also include:Input/output interface (I/O interfaces), universal serial bus (USB) port, net Network interface, power supply and/or camera.
The embodiments of the present invention are for illustration only, do not represent the quality of embodiment.
In the above embodiment of the present invention, all emphasize particularly on different fields to the description of each embodiment, do not have in some embodiment The part of detailed description may refer to the associated description of other embodiment.
In several embodiments provided herein, it should be understood that disclosed technology contents can pass through others Mode is realized.Wherein, the apparatus embodiments described above are merely exemplary, such as the division of the unit, Ke Yiwei A kind of division of logic function, can there is an other dividing mode in actual implementation, for example, multiple units or component can combine or Person is desirably integrated into another system or some features can be ignored or does not perform.Another point, shown or discussed is mutual Between coupling, direct-coupling or communication connection can be INDIRECT COUPLING or communication link by some interfaces, unit or module It connects, can be electrical or other forms.
The unit illustrated as separating component may or may not be physically separate, be shown as unit The component shown may or may not be physical unit, you can be located at a place or can also be distributed to multiple On unit.Some or all of unit therein can be selected according to the actual needs to realize the purpose of this embodiment scheme.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, it can also That each unit is individually physically present, can also two or more units integrate in a unit.Above-mentioned integrated list The form that hardware had both may be used in member is realized, can also be realized in the form of SFU software functional unit.
If the integrated unit is realized in the form of SFU software functional unit and is independent product sale or uses When, it can be stored in a computer read/write memory medium.Based on such understanding, technical scheme of the present invention is substantially The part to contribute in other words to the prior art or all or part of the technical solution can be in the form of software products It embodies, which is stored in a storage medium, is used including some instructions so that a computer Equipment (can be personal computer, server or network equipment etc.) perform each embodiment the method for the present invention whole or Part steps.And aforementioned storage medium includes:USB flash disk, read-only memory (ROM, Read-Only Memory), arbitrary access are deposited Reservoir (RAM, Random Access Memory), mobile hard disk, magnetic disc or CD etc. are various can to store program code Medium.
The above is only the preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications also should It is considered as protection scope of the present invention.

Claims (13)

1. a kind of optimization method of bytecode, which is characterized in that including:
Function byte code is parsed from function to be optimized;
Recursive call partial bytes code is obtained from the function byte code, wherein, the recursive call partial bytes code has Fixed cycle-index;
According to the cycling condition of the cycle-index and the recursive call partial bytes by the recursive call partial bytes code The bytecode that single continuously performs is converted to, and deletes the associated call instruction byte code of the recursive call partial bytes code;
The function byte code is replaced with into transformed bytecode and is exported.
2. according to the method described in claim 1, it is characterized in that, the recursive call portion is obtained from the function byte code Bytecode is divided to include:
The call instruction byte code is searched from the function byte code;
The recursive call partial bytes code is obtained by the call instruction byte code.
3. according to the method described in claim 1, it is characterized in that, according to the cycle-index and the cycling condition by described in Recursive call partial bytes code is converted to the bytecode that the single continuously performs and includes:
The copy amount of bytecode that the single continuously performs is determined by the cycle-index;
The corresponding execution content of each copy is determined using the cycling condition;
It is continuous that the recursive call partial bytes code is converted to by the single according to the copy amount and the execution content The bytecode of execution.
4. according to the method described in claim 3, it is characterized in that, according to the cycle-index and the cycling condition by institute It states after recursive call partial bytes code is converted to the bytecode that the single continuously performs, further includes:
Determine that there are jump instruction bytecodes before the recursive call partial bytes code is performed;
Byte location according to occupied by the bytecode that the single continuously performs adjusts the jump instruction bytecode and refers to again To byte location.
5. according to the method described in claim 1, it is characterized in that, using the hot update mechanisms of Python by the function byte code It replaces with the transformed bytecode and exports.
6. a kind of optimization device of bytecode, which is characterized in that including:
Parsing module, for parsing function byte code from function to be optimized;
Acquisition module, for obtaining recursive call partial bytes code from the function byte code, wherein, the recursive call portion Divide bytecode that there is fixed cycle-index;
First processing module, for being followed according to the cycling condition of the cycle-index and the recursive call partial bytes by described Ring calling section bytecode is converted to the bytecode that single continuously performs, and it is associated to delete the recursive call partial bytes code Call instruction byte code;
Second processing module, for the function byte code to be replaced with transformed bytecode and is exported.
7. device according to claim 6, which is characterized in that the acquisition module includes:
Searching unit, for searching the call instruction byte code from the function byte code;
Acquiring unit, for obtaining the recursive call partial bytes code by the call instruction byte code.
8. device according to claim 6, which is characterized in that the first processing module includes:
First determination unit, for determining the copy amount of bytecode that the single continuously performs by the cycle-index;
Second determination unit, for determining the corresponding execution content of each copy using the cycling condition;
Converting unit, for being converted to the recursive call partial bytes code according to the copy amount and the execution content The bytecode that the single continuously performs.
9. device according to claim 8, which is characterized in that described device further includes:
Determining module, for determining that there are jump instruction bytecodes before the recursive call partial bytes code is performed;
Module is adjusted, the jump instruction is adjusted for the byte location occupied by the bytecode that is continuously performed according to the single The byte location that bytecode is directed toward again.
10. device according to claim 6, which is characterized in that using the hot update mechanisms of Python by the function byte Code replaces with the transformed bytecode and exports.
11. a kind of storage medium, which is characterized in that the storage medium includes the program of storage, wherein, it is run in described program When control the storage medium where bytecode in equipment perform claim requirement 1 to 5 described in any one optimization method.
12. a kind of processor, which is characterized in that the processor is used to run program, wherein, right of execution when described program is run Profit requires the optimization method of the bytecode described in any one in 1 to 5.
13. a kind of terminal, which is characterized in that including:One or more processors, memory, display device and one or more A program, wherein, one or more of programs are stored in the memory, and are configured as by one or more A processor performs, and one or more of programs are excellent for the bytecode described in any one in perform claim requirement 1 to 5 Change method.
CN201711430709.5A 2017-12-26 2017-12-26 Byte code optimization method and device, storage medium, processor and terminal Active CN108153530B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711430709.5A CN108153530B (en) 2017-12-26 2017-12-26 Byte code optimization method and device, storage medium, processor and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711430709.5A CN108153530B (en) 2017-12-26 2017-12-26 Byte code optimization method and device, storage medium, processor and terminal

Publications (2)

Publication Number Publication Date
CN108153530A true CN108153530A (en) 2018-06-12
CN108153530B CN108153530B (en) 2020-06-16

Family

ID=62462780

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711430709.5A Active CN108153530B (en) 2017-12-26 2017-12-26 Byte code optimization method and device, storage medium, processor and terminal

Country Status (1)

Country Link
CN (1) CN108153530B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110032394A (en) * 2019-04-12 2019-07-19 深圳市腾讯信息技术有限公司 A kind of analysis method, device and the storage medium of passive coding file
CN111124424A (en) * 2019-12-27 2020-05-08 珠海金山网络游戏科技有限公司 Method and device for analyzing algorithm complexity
CN112631729A (en) * 2020-12-28 2021-04-09 杭州趣链科技有限公司 Deployment method, execution method and device of intelligent contract and terminal equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101739404A (en) * 2008-11-05 2010-06-16 爱思开电讯投资(中国)有限公司 Bytecode-optimized database and establishing method thereof and bytecode optimizing mehtod
US8484465B1 (en) * 2010-12-08 2013-07-09 Google Inc. Heterogeneous virtual machines sharing a security model
CN103914657A (en) * 2014-04-16 2014-07-09 南京大学 Malicious program detection method based on function characteristics
CN105393217A (en) * 2013-07-24 2016-03-09 马维尔国际贸易有限公司 Method and system for compiler optimization

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101739404A (en) * 2008-11-05 2010-06-16 爱思开电讯投资(中国)有限公司 Bytecode-optimized database and establishing method thereof and bytecode optimizing mehtod
US8484465B1 (en) * 2010-12-08 2013-07-09 Google Inc. Heterogeneous virtual machines sharing a security model
CN105393217A (en) * 2013-07-24 2016-03-09 马维尔国际贸易有限公司 Method and system for compiler optimization
CN103914657A (en) * 2014-04-16 2014-07-09 南京大学 Malicious program detection method based on function characteristics

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
刘巧红 等: "Python语言整数运算实现机制分析与性能评估", 《计算机系统应用》 *
张昱 等: "一种Java字节码优化框架", 《计算机工程》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110032394A (en) * 2019-04-12 2019-07-19 深圳市腾讯信息技术有限公司 A kind of analysis method, device and the storage medium of passive coding file
CN110032394B (en) * 2019-04-12 2022-05-31 深圳市腾讯信息技术有限公司 Analysis method and device for passive code file and storage medium
CN111124424A (en) * 2019-12-27 2020-05-08 珠海金山网络游戏科技有限公司 Method and device for analyzing algorithm complexity
CN111124424B (en) * 2019-12-27 2023-09-19 珠海金山数字网络科技有限公司 Method and device for analyzing algorithm complexity
CN112631729A (en) * 2020-12-28 2021-04-09 杭州趣链科技有限公司 Deployment method, execution method and device of intelligent contract and terminal equipment

Also Published As

Publication number Publication date
CN108153530B (en) 2020-06-16

Similar Documents

Publication Publication Date Title
CN111770113B (en) Method for executing intelligent contract, block chain node and node equipment
US7661096B2 (en) Interaction with nested and non-nested streams
CN108037926A (en) Optimization method, device, storage medium, processor and the terminal of bytecode
CN108021370A (en) Optimization method, device, storage medium, processor and the terminal of bytecode
CN108845839A (en) Application page loading method, device and computer readable storage medium
CN111768183B (en) Method for executing intelligent contract, block chain node and storage medium
CN111815310B (en) Method for executing intelligent contract, block chain node and storage medium
CN108153530A (en) Optimization method, device, storage medium, processor and the terminal of bytecode
US12032941B2 (en) Method and system for updating legacy software
CN111770204A (en) Method for executing intelligent contract, block chain node and storage medium
CN111770202B (en) Method for executing intelligent contract, block chain node and storage medium
CN111768184A (en) Method for executing intelligent contract and block link point
CN116628066B (en) Data transmission method, device, computer equipment and storage medium
CN106020920A (en) Preprocessing method and system for JCVM interpreter
CN112632924B (en) Method, system, electronic equipment and storage medium for regularized execution sequence labeling
Meier et al. An architecture for prolog extensions
CN115033249A (en) File compiling method and device
Freiburghouse The multics PL/1 compiler
CN113031952A (en) Method and device for determining execution code of deep learning model and storage medium
CN103019801A (en) Compiler applied to high-speed digital I/O wave engines
CN111190917B (en) Data processing method and device
Barker A Few More Java Details
Hall A New Human-Readability Infrastructure for Computing
CN117873626A (en) Bank business page translation method and device
CN116931947A (en) Method for optimizing wasm byte code, execution method, computer equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20230307

Address after: 200232 Room 2047, Floor 2, No. 24, Lane 315, Fenggu Road, Xuhui District, Shanghai

Patentee after: Shanghai NetEasy Brilliant Network Technology Co.,Ltd.

Address before: 310000 7 storeys, Building No. 599, Changhe Street Network Business Road, Binjiang District, Hangzhou City, Zhejiang Province

Patentee before: NETEASE (HANGZHOU) NETWORK Co.,Ltd.

TR01 Transfer of patent right