CN107861807A - The optimization method and device of routine call - Google Patents
The optimization method and device of routine call Download PDFInfo
- Publication number
- CN107861807A CN107861807A CN201711160655.5A CN201711160655A CN107861807A CN 107861807 A CN107861807 A CN 107861807A CN 201711160655 A CN201711160655 A CN 201711160655A CN 107861807 A CN107861807 A CN 107861807A
- Authority
- CN
- China
- Prior art keywords
- function
- optimised
- majorized
- majorized function
- optimization
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
Abstract
The invention discloses a kind of optimization method and device of routine call, it is related to a kind of applicating developing technology field, main purpose is in the version after solving existing Android 7.0, because JIT technologies are that dynamic optimization is carried out in function call, dynamic translation dex, for dynamic optimization, can not ensure the function of JIT optimization processings in function call next time to local function when i.e. program is run, what is called is the function after optimization, the problem of leading to not call.Main technical schemes:When optimised function operation is called in triggering, judge whether majorized function performs hook operation;If the majorized function performs hook operation, the majorized function optimizes processing to the optimised function by redirecting template with reference to default processing operation, and the template that redirects is used to optimize the optimised function.It is mainly used in the optimization of routine call.
Description
Technical field
The present invention relates to a kind of applicating developing technology field, more particularly to the optimization method and dress of a kind of routine call
Put.
Background technology
With the fast development of operating system applicating developing technology, using virtualization technology to operating system bottom at
Reason, develop and as main flow means.Wherein, (Android runtime, ART) virtual machine is different from tradition when Android is run
Dalvik virtual machine, using precompilation techniques substitute Dalvik in timely technique of compiling, accelerate the startup of application program
And execution.
At present, the ART virtual machines that Android system uses in the version of Android 4.4 using punctuality production mode JIT technologies come
Explain the dynamic optimization of execution in application process is opened to ART virtual machines, dynamic optimization is only limitted to this process can be with more
The situation of normal operation, in order to save the time, ART virtual machines install when do not do dynamic optimization, operation call function whether
Calling is balanced to carry out dynamic optimization, i.e., dex is defined as local function, is only limited to the situation of current process survival
Under, still, in the version after Android 7.0, because JIT technologies are that dynamic optimization is carried out in function call, i.e., program is run
When dynamic translation dex to local function, for dynamic optimization, can not ensure that the function of JIT optimization processings is adjusted in function next time
Used time, calling be optimization after function, lead to not call, the optimization to routine call has become urgently to be resolved hurrily ask
Topic.
The content of the invention
In view of this, the present invention provides a kind of optimization method and device of routine call, and main purpose is to solve existing
In version after Android 7.0, because JIT technologies are that dynamic optimization is carried out in function call, i.e., dynamic is turned over when program is run
Dex is translated to local function, for dynamic optimization, the function of JIT optimization processings can not be ensured in function call next time, called
Be optimization after function, lead to not call the problem of.
According to one aspect of the invention, there is provided a kind of optimization method of routine call, including:
When optimised function operation is called in triggering, judge whether majorized function performs hook operation;
If the majorized function performs hook operation, the majorized function is operated by redirecting the default processing of template combination
Processing is optimized to the optimised function, the template that redirects is used to optimize the optimised function.
Further, methods described also includes:
If the majorized function is not carried out hook operation, directly using default processing operation and the majorized function
Handle the optimised function.
Further, if the majorized function performs the hook operation, the majorized function is by redirecting mould
The hardened default processing operation of conjunction optimizes processing to the optimised function to be included:
When the majorized function hooks up optimised function by Hook functions, judge whether deposited in the optimised function
Redirecting mark;
If in the presence of mark is redirected, the parameter in the optimised function is parsed;
If the format transformation mark of the parameter is less than preset changeover condition, replacement is jumped to by preset directional order
Function is handled;
After the replacement function is finished, judge whether that performing first jumps according to the business demand of the majorized function
Turn instruction, if the business demand is defined as performing majorized function, perform first jump instruction, described first redirects finger
Make for jumping to the majorized function;
The majorized function is operated by default processing and handles the optimised function.
Further, methods described also includes:
If the conversion appropriate identification of the parameter is more than preset changeover condition, the second jump instruction is performed, described two jump
Turn instruction to be used to jump to the optimised function.
Further, it is described when the majorized function hooks up optimised function by Hook functions, judge described excellent
Changing in function includes with the presence or absence of redirecting mark:
When the majorized function hooks up optimised function by Hook functions, the head word in the optimised function is judged
Whether section is to redirect mark JMP.
Further, if it is described in the presence of redirect mark, after parsing the parameter in the optimised function, methods described
Also include:
Parameter after parsing is stored in local variable corresponding to preset thread, and according to the parameter by the part
Element in variable is converted to corresponding data type pointer, is transferred to Java layers, and the parameter includes format transformation information, ginseng
Number pass order information, parameter type information.It is described after the replacement function is finished, according to the industry of the majorized function
Whether business demand estimation performs the first jump instruction, if the business demand is defined as performing majorized function, performs described the
One jump instruction includes:
Being detected to whether there is in the majorized function business according to the data type pointer needs to perform the optimization letter
Several marks, if in the presence of the mark for needing to perform the majorized function, perform first jump instruction.
Described to be jumped to by preset directional order after replacement function handled, methods described also includes:
Further, format transformation mark is reset.
According to one aspect of the invention, there is provided a kind of optimization device of routine call, including:
Judging unit, for when optimised function operation is called in triggering, judging whether majorized function performs hook operation;
First processing units, if performing the hook operation for the majorized function, the majorized function passes through jump
The default processing operation of the hardened conjunction of revolving die optimizes processing to the optimised function, and the template that redirects is used for described excellent
Change function to optimize.
Further, described device also includes:
Second processing unit, if being not carried out hook operation for the majorized function, directly grasped using default processing
Make and the majorized function handles the optimised function.
Further, the first processing units include:
Judge module, for when the majorized function hooks up optimised function by Hook functions, judging described excellent
Change to whether there is in function and redirect mark;
Parsing module, if in the presence of mark is redirected, parsing the parameter in the optimised function;
First processing module, if the format transformation mark for the parameter is less than preset changeover condition, by preset
Directional order jumps to replacement function and handled;
First execution module, for after the replacement function is finished, according to the business demand of the majorized function
Judge whether to perform the first jump instruction, if the business demand is defined as performing majorized function, performs described first and redirect
Instruction, first jump instruction are used to jump to the majorized function;
Second processing module, the optimised function is handled for operating the majorized function by default processing.
Further, the first processing units also include:
Second execution module, if the conversion appropriate identification for the parameter is more than preset changeover condition, perform second
Jump instruction, two jump instruction are used to jump to the optimised function.
Further, the judge module, specifically for hooking up optimised letter by Hook functions when the majorized function
During number, judge whether the head byte in the optimised function is to redirect mark JMP.
Further, the first processing units also include:
Memory module, for the parameter after parsing to be stored in local variable corresponding to preset thread, and according to described
Element in the local variable is converted to corresponding data type pointer by parameter, is transferred to Java layers, the parameter includes
Format transformation information, parameter pass order information, parameter type information.
Further, first execution module, specifically for detecting the optimization letter according to the data type pointer
With the presence or absence of needing to perform the mark of the majorized function in number business, if in the presence of the mark for needing to perform the majorized function,
Then perform first jump instruction.
Further, the first processing units also include:
Module is reset, for format transformation mark to be reset.
According to another aspect of the invention, there is provided a kind of storage medium, being stored with least one in the storage medium can
Execute instruction, the executable instruction make computing device be operated as corresponding to the optimization method of above-mentioned routine call.
In accordance with a further aspect of the present invention, there is provided a kind of terminal, including:Processor, memory, communication interface and communication
Bus, the processor, the memory and the communication interface complete mutual communication by the communication bus;
The memory is used to deposit an at least executable instruction, and the executable instruction makes the computing device above-mentioned
Operated corresponding to the optimization method of routine call.
By above-mentioned technical proposal, technical scheme provided in an embodiment of the present invention at least has following advantages:
The invention provides a kind of optimization method and device of routine call, first when optimised function operation is called in triggering
When, judge whether majorized function performs hook operation, if the majorized function performs hook operation, the majorized function passes through
Redirect template and processing is optimized to the optimised function with reference to default processing operation, the template that redirects is used for the quilt
Majorized function optimizes.With in the version after existing Android 7.0, because JIT technologies are to enter Mobile state in function call
Dynamic translation dex is to local function when optimization, i.e. program are run, and for dynamic optimization, can not ensure the function of JIT optimization processings
In function call next time, calling be optimization after function, lead to not calling and compare, the embodiment of the present invention passes through when excellent
After change function is performed hook operation, operate to enter the optimised function that non-form optimizes with reference to preset processing by redirecting template
Row format optimizes, and so as to realize that majorized function is called to the optimised function for having entered row format optimization, and need not think
Format transformation is handled, improves the optimization efficiency of routine call.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention,
And can be practiced according to the content of specification, and in order to allow above and other objects of the present invention, feature and advantage can
Become apparent, below especially exemplified by the embodiment of the present invention.
Brief description of the drawings
By reading the detailed description of hereafter preferred embodiment, it is various other the advantages of and benefit it is common for this area
Technical staff will be clear understanding.Accompanying drawing is only used for showing the purpose of preferred embodiment, and is not considered as to the present invention
Limitation.And in whole accompanying drawing, identical part is denoted by the same reference numerals.In the accompanying drawings:
Fig. 1 shows a kind of optimization method flow chart of routine call provided in an embodiment of the present invention;
Fig. 2 shows a kind of JIT dynamic improving process schematic diagram provided in an embodiment of the present invention;
Fig. 3 shows the optimization method flow chart of another routine call provided in an embodiment of the present invention;
Fig. 4 shows that one kind provided in an embodiment of the present invention redirects template flow chart;
Fig. 5 shows that one kind provided in an embodiment of the present invention redirects template and combines default processing operation process chart;
Fig. 6 shows a kind of optimization device block diagram of routine call provided in an embodiment of the present invention;
Fig. 7 shows the optimization device block diagram of another routine call provided in an embodiment of the present invention;
Fig. 8 shows a kind of terminal schematic diagram provided in an embodiment of the present invention.
Embodiment
The exemplary embodiment of the disclosure is more fully described below with reference to accompanying drawings.Although the disclosure is shown in accompanying drawing
Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth here
Limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosure
Completely it is communicated to those skilled in the art.
The embodiments of the invention provide a kind of optimization method of routine call, as shown in figure 1, methods described includes:
101st, when optimised function operation is called in triggering, judge whether majorized function performs hook operation.
Wherein, the hook operation is inline hook Inline Hook operations, and the machine code progress for function is inline
Hook, machine code are the binary code after being compiled by ART.In addition, Hook functions are a kind of Hook Function, it is operating system message
A part for treatment mechanism, by setting " hook ", application program can filter system-level to all message, event,
The message that can not access under normal circumstances is accessed, the essence of hook is one section of program to processing system message, passes through and is
System is called, and it is linked into system, and Inline Hook are different from the common Hook of the call address by Modification growth function in the past,
But instruction is changed directly in the function body of function, the purpose of hook is realized with a jump instruction.
It should be noted that the majorized function is the COmpiler optimizations in JIT dynamic improving process as shown in Figure 2
Function, processing then is optimized to optimised artMethod functions.
If the 102, the majorized function performs hook operation, the majorized function combines default processing by redirecting template
Operation optimizes processing to the optimised function.
Wherein, if the template that redirects is used to enter the optimised function row format optimization majorized function execution hook behaviour
Make, then illustrate that function is the function that non-form optimizes for be called explaining, the template that redirects is used for optimised letter for one
The space internal memory that several forms is changed, the default processing operation provide the operation of respective handling for majorized function, such as wrapped
Include and code assignment etc. is operated again.Optimised function is regard artMethod as by the default processing operation of combination and enters row format
Conversion, so as to realize the optimised function of local function call for the function after form optimization.
The invention provides in the version after a kind of optimization method of routine call, with existing Android 7.0, due to JIT
Technology is that dynamic optimization is carried out in function call, i.e., dynamic translation dex is excellent for dynamic to local function when program is run
Change, the function of JIT optimization processings can not be ensured in function call next time, calling be optimization after function, lead to not
Calling is compared, and the embodiment of the present invention is by the way that after majorized function is performed hook operation, preset processing is combined by redirecting template
The optimised function of non-form optimization is entered row format optimization by operation, so as to realize majorized function to having entered row format optimization
Optimised function is called, and without artificially handling format transformation, improves the optimization efficiency of routine call.
The embodiments of the invention provide the optimization method of another routine call, as shown in figure 3, methods described includes:
201st, when optimised function operation is called in triggering, judge whether majorized function performs hook operation.
This step is identical with step 101 method shown in Fig. 1, will not be repeated here.
It should be noted that ART virtual machines are operationally, internal operation is by Class class description and Method
Class method description and perform.Wherein, each Java function can correspond to a Method structure, Method structures
Member variable includes the index in dex files of class object pointer, the attribute, method of method where method, the machine of method
Pointer of code pointer and method Native codes etc., Java functions are called to obtain the Method of optimised function in Native layers
Structure.
202nd, when the majorized function hooks up optimised function by Hook functions, judge be in the optimised function
No presence redirects mark.
After performing hook operation due to majorized function, as majorized function can be by Hook letters that Inline Hook are operated
Number hooks up optimised function to be called, that is, explains function, therefore, optimised function is hooked up by Hook functions in majorized function
When, the optimization of local function call local function can be converted into.Wherein, optimised function is being carried out by before hooking up, excellent
Change and be configured with the head byte of function for judging whether to the mark redirected, i.e., before optimised function is run, need
Judge to whether there is in optimised function and redirect mark, in general, in order to which the optimised function optimized to needs optimizes,
It can all be configured in these optimised function and redirect mark, to jump directly to that operation is optimized in template.Optimization
Function can be the COmpiler majorized functions of DEX forms, and optimised function is the artMethod functions of ELF format, of the invention
Embodiment is not specifically limited.
For the embodiment of the present invention, step 202 is specifically as follows:When the majorized function hooked up by Hook functions it is excellent
When changing function, judge whether the head byte in the optimised function is to redirect mark JMP.
It should be noted that just to needing the quilt into row format conversion before being performed for the instruction in optimised function
Majorized function enters row format conversion, it is necessary to be configured to the JMP instructions redirected, configuration in the head byte of optimised function
JMP instructions can take 8 bytes in optimised function.Therefore, in current step, optimised function is directly judged
Whether first 8 bytes are JMP instructions.
For the conversion between form in ART virtual machines, it is necessary to be directed to call between local function and local function
When optimization, therefore, when majorized function in the embodiment of the present invention and optimised function are local function, can just carry out lattice
Conversion between formula.
For the embodiment of the present invention, if step 203 after step 202, in the presence of mark is redirected, parse described optimised
Parameter in function.
Wherein, the parameter is that the parameter of space conversion whether is carried out in optimised function, and corresponding space conversion includes
Java layers between function include being used for conversion between Native layers, or Native layer Java layers, specific parameter
The parameter of Function Format, the parameter whether changed for embodying function etc. are embodied, the embodiment of the present invention is not specifically limited.
It should be noted that in general, the parsing for parameter, can specifically preset what some needs were changed
Format transformation identifies, and is identified according to format transformation and is matched with preset changeover condition, if inconsistent, illustrates that needs are turned
Change.When attending to anything else in ART virtual machines is called using function, further function to be called is determined the need for into
Row format transformation.For example, game is attended to anything else, it is virtual to be located at ART for the routine call of the acquisition advertisement link address of the DEX forms of application
During the chained address program of the ELF format in machine bottom, the inconsistent situation of the form of original function and object function just occurs.
For the embodiment of the present invention, also include after step 203:Parameter after parsing is stored in corresponding to preset thread
In local variable, and data type pointer corresponding to according to the parameter element in the local variable is converted to, transmit
To Java layers.
Wherein, the parameter includes format transformation information, parameter pass order information, parameter type information, described preset
Thread is the container that global variable can be supported to store, and the parameter includes format transformation information, parameter pass order information, ginseng
Number type information etc., format transformation includes Java layers to the conversion between Native layers, or Native layer Java layers, example
Such as, ELF format and DEX file etc., the embodiment of the present invention is not specifically limited.The local variable is to be used to deposit in preset thread
When storing up the limitation local variable of parameter, also, function is called due to jumping to Java layers from compilation layer, function can be related to
The problems such as parameter type and space are changed, therefore ART virtual machines need to parse from register and stack according to parameter delivery protocol
Parameter, the foundation then changed as form.Specifically, can be will compilation corresponding to parameter, with array form sequential storage
It is into the local variable of preset thread, and according to parameter pass order and parameter type, the local variable of preset thread is corresponding
Element be converted to corresponding to data type pointer, be transferred to Java layers.
If the format transformation mark of 204a, the parameter is less than preset changeover condition, redirected by preset directional order
Handled to replacement function.
Wherein, the format transformation is identified as the parameter that format transformation whether is carried out for embodying, and implements for the present invention
Example, typically by setting format transformation to be identified as specific F, if F is less than 0, it is set as that needs are changed, and by preset
Directional order jumps to and conversion process is carried out in replacement function, and replacement function is that can enter the function of row format conversion, that is, is being jumped
When going to the function of form conversion, the transcode in replacement function is run first, then by the letter of the ELF format of object function
Number is converted to the function of DEX forms, then judges whether to adjust back original function, the embodiment of the present invention is not specifically limited.In advance
Directional order is put to be assigned to the finger in PC registers for the address of first execute instruction in the replacement function by machine instruction
Order so that jump to the process currently performed in replacement function, PC registers store the next IA to be performed, and refer to
Show the next instruction to be performed, that is, realize and redirect.
It should be noted that because majorized function is when calling optimised function, for the operation characteristic of ART virtual machines,
Form conversion between different functions can enter row format conversion by jumping to replacement function.Further, since each letter
When being called between number by Hook operations, there can be different form conversions, therefore, preset directional order can be according to quilt
Majorized function and majorized function, the address of first directional order of dynamic configuration replacement function are assigned to PC registers, so as to real
Dynamic translation between existing different-format.
If the conversion appropriate identification of 204b, the parameter is more than preset changeover condition, the second jump instruction is performed.
As shown in figure 4, when format transformation mark F is more than 0, directly jumped to by the second jump instruction JMP optimised
In function, second jump instruction is used to jump to the optimised function, and in the second jump instruction dynamic configuration have by
First 8 bytes in majorized function, directly to perform the optimised function that need not enter row format conversion.For step 202
It is the advance configuration processor set in a template with step 203, and because LDR is instructed with jumping back to majorized function when F is more than 0
The step of be need changed according to the address of optimised function and replacement function, therefore, as shown in figure 4, in template for
LDR and recall to majorized function and be dynamically generated.
For the embodiment of the present invention, step 205 after step 204a, after the replacement function is finished, according to
The business demand of the majorized function judges whether to perform the first jump instruction, if the business demand is defined as performing optimization letter
Number, then perform first jump instruction.
For the embodiment of the present invention, first jump instruction is used to jump to the majorized function.
Due to after replacement function has been performed, it may appear that need to carry out returning to the target after the form conversion that original function performs
Function, and the object function after the form conversion of original function execution need not be returned, it is specific to return to sentencing for majorized function execution
Disconnected determined according to the business demand of system, the business demand is the execution purpose of call function, including business performs
Scene, such as System Privileges, parameter filtering, in general, it is arranged to not adjust back majorized function for the function call of System Privileges, pin
The function call of parameter filtering is arranged to adjust back majorized function, because the logic of business demand can typically write into function instruction
In, therefore, specific basis for estimation can be determined according to the parameter parsed in optimised function, and the embodiment of the present invention is not done
It is specific to limit.It can be JMP jump instructions that current execution thread jumps to majorized function that first jump instruction, which is, such as Fig. 4
It is shown, after replacement function is finished, JMP readjustment optimization letters are utilized if the business demand of majorized function filters for parameter
Number.
For the embodiment of the present invention, step 205 is specifically as follows:The optimization letter is detected according to the data type pointer
With the presence or absence of needing to perform the mark of the majorized function in number business, if in the presence of the mark for needing to perform the majorized function,
Then perform first jump instruction.
In general, because the business demand performed required for majorized function can be embodied by the mark in function, because
This, is identified by data type pointer in inspection optimization function one by one with the presence or absence of corresponding with business demand, so that it is determined that
Whether need to carry out readjustment majorized function.
Further, also include afterwards for the embodiment of the present invention, step 205:Format transformation mark is subjected to weight
Put.
In order to avoid after readjustment majorized function has been carried out, by the template that redirects as shown in Figure 4, jumping to replace again
In exchange the letters number, endless loop is formed, therefore, it is necessary to after once readjustment majorized function was performed, the F less than 0 is reset to more than 0
Any number so that current executive process jumps in optimised function the content for performing optimised function.
For the embodiment of the present invention, step 206 after step 205, pass through default processing and operate the optimization letter
Number handles the optimised function.
It should be noted that because optimised function artMethod needs to be preset by majorized function COmpiler
Processing operation, operated so as to carry out again assignment etc. to parameters such as the code in artMethod, therefore, in as shown in Figure 5,
After being carried out redirecting template processing by Hook majorized function COmpiler, cause majorized function optimization with reference to default processing operation
Optimised function artMethod is handled, i.e., by majorized function after redirecting template and carrying out Hook replacement functions, passes through default place
Manage the optimised function artMethod of operation optimization.
For the embodiment of the present invention, if step 202b arranged side by side step 202a, the majorized function are not carried out hook behaviour
Make, then the optimised function is directly handled using default processing operation and the majorized function.
As shown in Figure 2 carries out dynamic optimization using JIT technologies, if optimised function is form optimization with majorized function
The function crossed, illustrate that majorized function by Hook, is not then called directly by default processing operation.
The invention provides the optimization method of another routine call, the embodiment of the present invention when majorized function by being performed
After hook operation, jump to redirect parameter interpretation is carried out in template according to JMP instructions in head byte in object function, when being resolved to
When format transformation mark F is less than 0, calls replacement function to enter row format by LDR and change, the business of class is then filtered according to parameter
Demand judges to carry out readjustment majorized function, resets format transformation mark, avoids the majorized function of DEX forms to ELF
Optimization malloc failure malloc when the optimised function of form optimizes, so as to realize majorized function to having entered row format optimization
Optimised function is called, and without artificially handling format transformation, it is ensured that the uniformity of form is kept in invoked procedure, is improved
The optimization efficiency of routine call.
Further, as the realization to method shown in above-mentioned Fig. 1, the embodiments of the invention provide a kind of routine call
Optimize device, as shown in fig. 6, the device includes:Judging unit 31, first processing units 32.
Judging unit 31, for when optimised function operation is called in triggering, judging whether majorized function performs hook behaviour
Make;The judging unit 31 is performed when optimised function operation is called in triggering for the optimization device of routine call, judges to optimize
Whether function performs the program module of hook operation.
First processing units 32, if performing the hook operation for the majorized function, the majorized function passes through
Redirect template and processing is optimized to the optimised function with reference to default processing operation, the template that redirects is used for the quilt
Majorized function optimizes.If the first processing units 32 perform the majorized function for the optimization device of routine call and performed
The hook operation, then the majorized function is excellent to the optimised function progress with reference to default processing operation by redirecting template
Change the program module of processing.
The invention provides in the version after a kind of optimization device of routine call, with existing Android 7.0, due to JIT
Technology is that dynamic optimization is carried out in function call, i.e., dynamic translation dex is excellent for dynamic to local function when program is run
Change, the function of JIT optimization processings can not be ensured in function call next time, calling be optimization after function, lead to not
Calling is compared, and the embodiment of the present invention is by the way that after majorized function is performed hook operation, preset processing is combined by redirecting template
The optimised function of non-form optimization is entered row format optimization by operation, so as to realize majorized function to having entered row format optimization
Optimised function is called, and without artificially handling format transformation, improves the optimization efficiency of routine call.
Further, as the realization to method shown in above-mentioned Fig. 3, the embodiments of the invention provide another routine call
Optimization device, as shown in fig. 7, the device includes:Judging unit 41, first processing units 42, second processing unit 43.
Judging unit 41, for when optimised function operation is called in triggering, judging whether majorized function performs hook behaviour
Make;
First processing units 42, if performing the hook operation for the majorized function, the majorized function passes through
Redirect template and processing is optimized to the optimised function with reference to default processing operation, the template that redirects is used for the quilt
Majorized function optimizes.
Further, described device also includes:
Second processing unit 43, if being not carried out hook operation for the majorized function, directly using default processing
Operation and the majorized function handle the optimised function.
Further, the first processing units 42 include:
Judge module 4201, for when the majorized function hooks up optimised function by Hook functions, described in judgement
It whether there is in optimised function and redirect mark;
Parsing module 4202, if in the presence of mark is redirected, parsing the parameter in the optimised function;
First processing module 4203, if the format transformation mark for the parameter is less than preset changeover condition, pass through
Preset directional order jumps to replacement function and handled;
First execution module 4204, for after the replacement function is finished, according to the business of the majorized function
Whether demand estimation performs the first jump instruction, if the business demand is defined as performing majorized function, performs described first
Jump instruction, first jump instruction are used to jump to the majorized function;
Second processing module 4205, the optimised letter is handled for operating the majorized function by default processing
Number.
Further, the first processing units 42 also include:
Second execution module 4206, if the conversion appropriate identification for the parameter is more than preset changeover condition, perform
Second jump instruction, two jump instruction are used to jump to the optimised function.
Further, the judge module 4201, specifically for when the majorized function hooked up by Hook functions it is excellent
When changing function, judge whether the head byte in the optimised function is to redirect mark JMP.
Further, the first processing units 42 also include:
Memory module 4207, for the parameter after parsing to be stored in local variable corresponding to preset thread, and according to
Element in the local variable is converted to corresponding data type pointer by the parameter, is transferred to Java layers, the parameter
Including format transformation information, parameter pass order information, parameter type information.
First execution module 4204, specifically for detecting the majorized function business according to the data type pointer
In with the presence or absence of needing to perform the mark of the majorized function, if in the presence of the mark for needing to perform the majorized function, perform
First jump instruction.
Further, the first processing units 42 also include:
Module 4208 is reset, for format transformation mark to be reset.
The invention provides the optimization device of another routine call, the embodiment of the present invention when majorized function by being performed
After hook operation, jump to redirect parameter interpretation is carried out in template according to JMP instructions in head byte in object function, when being resolved to
When format transformation mark F is less than 0, calls replacement function to enter row format by LDR and change, the business of class is then filtered according to parameter
Demand judges to carry out readjustment majorized function, resets format transformation mark, avoids the majorized function of DEX forms to ELF
Optimization malloc failure malloc when the optimised function of form optimizes, so as to realize majorized function to having entered row format optimization
Optimised function is called, and without artificially handling format transformation, it is ensured that the uniformity of form is kept in invoked procedure, is improved
The optimization efficiency of routine call.
A kind of storage medium is provided according to one embodiment of the invention, it is executable that the storage medium is stored with least one
Instruction, the computer executable instructions can perform the data query method in above-mentioned any means embodiment.
Fig. 8 shows a kind of structural representation of the terminal provided according to one embodiment of the invention, of the invention specific real
Specific implementation of the example not to terminal is applied to limit.
As shown in figure 8, the terminal can include:Processor (processor) 502, communication interface (Communications
Interface) 504, memory (memory) 506 and communication bus 508.
Wherein:Processor 502, communication interface 504 and memory 506 complete mutual lead to by communication bus 508
Letter.
Communication interface 504, for being communicated with the network element of miscellaneous equipment such as client or other servers etc..
Processor 502, for configuration processor 510, it can specifically perform the correlation in above-mentioned data query embodiment of the method
Step.
Specifically, program 510 can include program code, and the program code includes computer-managed instruction.
Processor 502 is probably central processor CPU, or specific integrated circuit ASIC (Application
Specific Integrated Circuit), or it is arranged to implement the integrated electricity of one or more of the embodiment of the present invention
Road.The one or more processors that terminal includes, can be same type of processor, such as one or more CPU;Can also be
Different types of processor, such as one or more CPU and one or more ASIC.
Memory 506, for depositing program 510.Memory 506 may include high-speed RAM memory, it is also possible to also include
Nonvolatile memory (non-volatile memory), for example, at least a magnetic disk storage.
Program 510 specifically can be used for so that processor 502 performs following operation:
When optimised function operation is called in triggering, judge whether majorized function performs hook operation;
If the majorized function performs hook operation, the majorized function is operated by redirecting the default processing of template combination
Processing is optimized to the optimised function, the template that redirects is used to optimize the optimised function.
Algorithm and display be not inherently related to any certain computer, virtual system or miscellaneous equipment provided herein.
Various general-purpose systems can also be used together with teaching based on this.As described above, required by constructing this kind of system
Structure be obvious.In addition, the present invention is not also directed to any certain programmed language.It should be understood that it can utilize various
Programming language realizes the content of invention described herein, and the description done above to language-specific is to disclose this hair
Bright preferred forms.
In the specification that this place provides, numerous specific details are set forth.It is to be appreciated, however, that the implementation of the present invention
Example can be put into practice in the case of these no details.In some instances, known method, structure is not been shown in detail
And technology, so as not to obscure the understanding of this description.
Similarly, it will be appreciated that in order to simplify the disclosure and help to understand one or more of each inventive aspect,
Above in the description to the exemplary embodiment of the present invention, each feature of the invention is grouped together into single implementation sometimes
In example, figure or descriptions thereof.However, the method for the disclosure should be construed to reflect following intention:I.e. required guarantor
The application claims of shield features more more than the feature being expressly recited in each claim.It is more precisely, such as following
Claims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore,
Thus the claims for following embodiment are expressly incorporated in the embodiment, wherein each claim is in itself
Separate embodiments all as the present invention.
Those skilled in the art, which are appreciated that, to be carried out adaptively to the module in the equipment in embodiment
Change and they are arranged in one or more equipment different from the embodiment.Can be the module or list in embodiment
Member or component be combined into a module or unit or component, and can be divided into addition multiple submodule or subelement or
Sub-component.In addition at least some in such feature and/or process or unit exclude each other, it can use any
Combination is disclosed to all features disclosed in this specification (including adjoint claim, summary and accompanying drawing) and so to appoint
Where all processes or unit of method or equipment are combined.Unless expressly stated otherwise, this specification (including adjoint power
Profit requires, summary and accompanying drawing) disclosed in each feature can be by providing the alternative features of identical, equivalent or similar purpose come generation
Replace.
In addition, it will be appreciated by those of skill in the art that although some embodiments described herein include other embodiments
In included some features rather than further feature, but the combination of the feature of different embodiments means in of the invention
Within the scope of and form different embodiments.For example, in the following claims, embodiment claimed is appointed
One of meaning mode can use in any combination.
The all parts embodiment of the present invention can be realized with hardware, or to be run on one or more processor
Software module realize, or realized with combinations thereof.It will be understood by those of skill in the art that it can use in practice
Microprocessor or digital signal processor (DSP) realize the optimization method of routine call according to embodiments of the present invention and dress
The some or all functions of some or all parts in putting.The present invention is also implemented as described here for performing
Method some or all equipment or program of device (for example, computer program and computer program product).This
The program of the realization present invention of sample can store on a computer-readable medium, or can have one or more signal
Form.Such signal can be downloaded from internet website and obtained, and either be provided or with any other on carrier signal
Form provides.
It should be noted that the present invention will be described rather than limits the invention for above-described embodiment, and ability
Field technique personnel can design alternative embodiment without departing from the scope of the appended claims.In the claims,
Any reference symbol between bracket should not be configured to limitations on claims.Word "comprising" does not exclude the presence of not
Element or step listed in the claims.Word "a" or "an" before element does not exclude the presence of multiple such
Element.The present invention can be by means of including the hardware of some different elements and being come by means of properly programmed computer real
It is existing.In if the unit claim of equipment for drying is listed, several in these devices can be by same hardware branch
To embody.The use of word first, second, and third does not indicate that any order.These words can be explained and run after fame
Claim.
Embodiment of the invention discloses that:
A1, a kind of optimization method of routine call, including:
When optimised function operation is called in triggering, judge whether majorized function performs hook operation;
If the majorized function performs hook operation, the majorized function is operated by redirecting the default processing of template combination
Processing is optimized to the optimised function, the template that redirects is used to optimize the optimised function.
A2, the method according to A1, methods described also include:
If the majorized function is not carried out hook operation, directly using default processing operation and the majorized function
Handle the optimised function.
A3, the method according to A2, if the majorized function performs the hook operation, the majorized function
Processing is optimized to the optimised function included with reference to default processing operation by redirecting template:
When the majorized function hooks up optimised function by Hook functions, judge whether deposited in the optimised function
Redirecting mark;
If in the presence of mark is redirected, the parameter in the optimised function is parsed;
If the format transformation mark of the parameter is less than preset changeover condition, replacement is jumped to by preset directional order
Function is handled;
After the replacement function is finished, judge whether that performing first jumps according to the business demand of the majorized function
Turn instruction, if the business demand is defined as performing majorized function, perform first jump instruction, described first redirects finger
Make for jumping to the majorized function;
The majorized function is operated by default processing and handles the optimised function.
A4, the method according to A3, methods described also include:
If the conversion appropriate identification of the parameter is more than preset changeover condition, the second jump instruction is performed, described two jump
Turn instruction to be used to jump to the optimised function.
A5, the method according to A4, it is described when the majorized function hooks up optimised function by Hook functions, sentence
Breaking includes with the presence or absence of redirecting mark in the optimised function:
When the majorized function hooks up optimised function by Hook functions, the head word in the optimised function is judged
Whether section is to redirect mark JMP.
A6, the method according to A5, if described in the presence of mark is redirected, parse parameter in the optimised function it
Afterwards, methods described also includes:
Parameter after parsing is stored in local variable corresponding to preset thread, and according to the parameter by the part
Element in variable is converted to corresponding data type pointer, is transferred to Java layers, and the parameter includes format transformation information, ginseng
Number pass order information, parameter type information.
A7, the method according to A6, it is described after the replacement function is finished, according to the industry of the majorized function
Whether business demand estimation performs the first jump instruction, if the business demand is defined as performing majorized function, performs described the
One jump instruction includes:
Being detected to whether there is in the majorized function business according to the data type pointer needs to perform the optimization letter
Several marks, if in the presence of the mark for needing to perform the majorized function, perform first jump instruction.
A8, the method according to any one of A3-A7, it is described to be jumped to by preset directional order at replacement function
After reason, methods described also includes:
Format transformation mark is reset.
B9, a kind of optimization device of routine call, including:
Judging unit, for when optimised function operation is called in triggering, judging whether majorized function performs hook operation;
First processing units, if performing the hook operation for the majorized function, the majorized function passes through jump
The default processing operation of the hardened conjunction of revolving die optimizes processing to the optimised function, and the template that redirects is used for described excellent
Change function to optimize.
B10, the device according to B9, described device also include:
Second processing unit, if being not carried out hook operation for the majorized function, directly grasped using default processing
Make and the majorized function handles the optimised function.
B11, the device according to B10, the first processing units include:
Judge module, for when the majorized function hooks up optimised function by Hook functions, judging described excellent
Change to whether there is in function and redirect mark;
Parsing module, if in the presence of mark is redirected, parsing the parameter in the optimised function;
First processing module, if the format transformation mark for the parameter is less than preset changeover condition, by preset
Directional order jumps to replacement function and handled;
First execution module, for after the replacement function is finished, according to the business demand of the majorized function
Judge whether to perform the first jump instruction, if the business demand is defined as performing majorized function, performs described first and redirect
Instruction, first jump instruction are used to jump to the majorized function;
Second processing module, the optimised function is handled for operating the majorized function by default processing.
B12, the device according to B11, the first processing units also include:
Second execution module, if the conversion appropriate identification for the parameter is more than preset changeover condition, perform second
Jump instruction, two jump instruction are used to jump to the optimised function.
B13, the device according to B12,
The judge module, specifically for when the majorized function hooks up optimised function by Hook functions, judging
Whether the head byte in the optimised function is to redirect mark JMP.
B14, the device according to B13, the first processing units also include:
Memory module, for the parameter after parsing to be stored in local variable corresponding to preset thread, and according to described
Element in the local variable is converted to corresponding data type pointer by parameter, is transferred to Java layers, the parameter includes
Format transformation information, parameter pass order information, parameter type information.
B15, the device according to B14,
First execution module, it is specifically for being detected according to the data type pointer in the majorized function business
It is no exist need to perform the mark of the majorized function, if in the presence of the mark for needing to perform the majorized function, perform described in
First jump instruction.
B16, the device according to any one of B11-B15, the first processing units also include:
Module is reset, for format transformation mark to be reset.
C17, a kind of storage medium, an at least executable instruction, the executable instruction are stored with the storage medium
Make operation corresponding to the optimization method of routine call of the computing device as any one of A1-A8.
D18, a kind of terminal, including:Processor, memory, communication interface and communication bus, the processor, described deposit
Reservoir and the communication interface complete mutual communication by the communication bus;
The memory is used to deposit an at least executable instruction, and the executable instruction makes the computing device such as
Operated corresponding to the optimization method of routine call any one of A1-A8.
Claims (10)
- A kind of 1. optimization method of routine call, it is characterised in that including:When optimised function operation is called in triggering, judge whether majorized function performs hook operation;If the majorized function performs hook operation, the majorized function combines default processing operation to institute by redirecting template State optimised function and optimize processing, the template that redirects is used to optimize the optimised function.
- 2. according to the method for claim 1, it is characterised in that methods described also includes:If the majorized function is not carried out hook operation, directly using default processing operation and majorized function processing The optimised function.
- 3. according to the method for claim 2, it is characterised in that if the majorized function performs the hook operation, Then the majorized function optimizes processing to the optimised function and included by redirecting template with reference to default processing operation:When the majorized function hooks up optimised function by Hook functions, judge in the optimised function with the presence or absence of jump Turn mark;If in the presence of mark is redirected, the parameter in the optimised function is parsed;If the format transformation mark of the parameter is less than preset changeover condition, replacement function is jumped to by preset directional order Handled;After the replacement function is finished, judge whether that performing first redirects finger according to the business demand of the majorized function Order, if the business demand is defined as performing majorized function, first jump instruction is performed, first jump instruction is used In jumping to the majorized function;The majorized function is operated by default processing and handles the optimised function.
- 4. according to the method for claim 3, it is characterised in that methods described also includes:If the conversion appropriate identification of the parameter is more than preset changeover condition, the second jump instruction is performed, described two redirect finger Make for jumping to the optimised function.
- A kind of 5. optimization device of routine call, it is characterised in that including:Judging unit, for when optimised function operation is called in triggering, judging whether majorized function performs hook operation;First processing units, if performing the hook operation for the majorized function, the majorized function is by redirecting mould The hardened default processing operation of conjunction optimizes processing to the optimised function, and the template that redirects is used for the optimised letter Number optimizes.
- 6. device according to claim 5, it is characterised in that described device also includes:Second processing unit, if being not carried out hook operation for the majorized function, directly use it is default handle operate with And the majorized function handles the optimised function.
- 7. device according to claim 6, it is characterised in that the first processing units include:Judge module, for when the majorized function hooks up optimised function by Hook functions, judging the optimised letter It whether there is in number and redirect mark;Parsing module, if in the presence of mark is redirected, parsing the parameter in the optimised function;First processing module, if the format transformation mark for the parameter is less than preset changeover condition, pass through preset sensing Instruction jumps to replacement function and handled;First execution module, for after the replacement function is finished, being judged according to the business demand of the majorized function The first jump instruction whether is performed, if the business demand is defined as performing majorized function, performs first jump instruction, First jump instruction is used to jump to the majorized function;Second processing module, the optimised function is handled for operating the majorized function by default processing.
- 8. device according to claim 7, it is characterised in that the first processing units also include:Second execution module, if the conversion appropriate identification for the parameter is more than preset changeover condition, performs second and redirect Instruction, two jump instruction are used to jump to the optimised function.
- 9. a kind of storage medium, an at least executable instruction is stored with the storage medium, the executable instruction makes processing Device performs operation corresponding to the optimization method of the routine call as any one of claim 1-4.
- 10. a kind of terminal, including:Processor, memory, communication interface and communication bus, the processor, the memory and The communication interface completes mutual communication by the communication bus;The memory is used to deposit an at least executable instruction, and the executable instruction makes the computing device such as right will Ask and operated corresponding to the optimization method of the routine call any one of 1-4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711160655.5A CN107861807B (en) | 2017-11-20 | 2017-11-20 | Optimization method and device for program call |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711160655.5A CN107861807B (en) | 2017-11-20 | 2017-11-20 | Optimization method and device for program call |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107861807A true CN107861807A (en) | 2018-03-30 |
CN107861807B CN107861807B (en) | 2021-06-25 |
Family
ID=61702208
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711160655.5A Active CN107861807B (en) | 2017-11-20 | 2017-11-20 | Optimization method and device for program call |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107861807B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111124484A (en) * | 2018-10-31 | 2020-05-08 | 上海奥陶网络科技有限公司 | Java program parameter optimization method |
CN111352629A (en) * | 2018-12-24 | 2020-06-30 | 北京奇虎科技有限公司 | Optimization method and device for program call |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104598809A (en) * | 2015-02-13 | 2015-05-06 | 北京奇虎科技有限公司 | Program monitoring method and defending method thereof, as well as relevant device |
US20150379263A1 (en) * | 2014-06-27 | 2015-12-31 | Harshawardhan Vipat | Technologies for preventing hook-skipping attacks using processor virtualization features |
US20170185791A1 (en) * | 2015-12-24 | 2017-06-29 | Intel Corporation | Application program interface (API) monitoring bypass |
CN107102944A (en) * | 2017-04-07 | 2017-08-29 | 北京深思数盾科技股份有限公司 | The analysis method and device of a kind of call function |
-
2017
- 2017-11-20 CN CN201711160655.5A patent/CN107861807B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20150379263A1 (en) * | 2014-06-27 | 2015-12-31 | Harshawardhan Vipat | Technologies for preventing hook-skipping attacks using processor virtualization features |
CN104598809A (en) * | 2015-02-13 | 2015-05-06 | 北京奇虎科技有限公司 | Program monitoring method and defending method thereof, as well as relevant device |
US20170185791A1 (en) * | 2015-12-24 | 2017-06-29 | Intel Corporation | Application program interface (API) monitoring bypass |
CN107102944A (en) * | 2017-04-07 | 2017-08-29 | 北京深思数盾科技股份有限公司 | The analysis method and device of a kind of call function |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111124484A (en) * | 2018-10-31 | 2020-05-08 | 上海奥陶网络科技有限公司 | Java program parameter optimization method |
CN111124484B (en) * | 2018-10-31 | 2023-09-01 | 上海奥陶网络科技有限公司 | Java program parameter optimization method |
CN111352629A (en) * | 2018-12-24 | 2020-06-30 | 北京奇虎科技有限公司 | Optimization method and device for program call |
Also Published As
Publication number | Publication date |
---|---|
CN107861807B (en) | 2021-06-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108021357A (en) | The optimization method and device of routine call | |
US8832652B2 (en) | Method for customizing software applications | |
CN102193810B (en) | Cross-module inlining candidate identification | |
CN101276290B (en) | Method for detecting parameter access and task management system | |
US9645833B2 (en) | Additive independent object modification | |
US20070028222A1 (en) | Free/outer variable capture | |
CN104423968B (en) | It designs the method for service logic, execute its server and storage medium | |
CN107480476B (en) | Android native layer instruction compiling virtualization shell adding method based on ELF infection | |
JP7394211B2 (en) | Methods, devices, equipment, and media for parallel execution of smart contracts | |
CN102231162A (en) | Dynamic rule engine configuration method based on service processing | |
CN103092742A (en) | Optimization method and system of program logging | |
CN102023885A (en) | Method and system for storing bytecode of JCRE (Java card run time environment) | |
CN109445797A (en) | Handle task executing method and device | |
CN109445880A (en) | Transmission method, device and the electronic equipment of cross-thread calls chain context | |
US9552239B2 (en) | Using sub-processes across business processes in different composites | |
CN110502530A (en) | Database functions call method, system, computer equipment and storage medium | |
CN107861807A (en) | The optimization method and device of routine call | |
CN111813635A (en) | Monitoring method, system and device for intelligent contracts of block chains | |
US20090144528A1 (en) | Method for running native code across single or multi-core hybrid processor achitecture | |
CN107908391A (en) | The optimization method and device of routine call | |
CN109343856A (en) | The generation method and device of custom algorithm component | |
CN109634714A (en) | A kind of method and device of intelligent scheduling | |
CN107943517A (en) | The hook method and device of terminal applies | |
US20100049724A1 (en) | Process and a system for updating a data structure in a relational database used within a manufacturing execution system | |
US10657476B2 (en) | Just in time compilation (JIT) for business process execution |
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 |