CN114003317A - Inline implementation method and apparatus, electronic device, storage medium, and program product - Google Patents

Inline implementation method and apparatus, electronic device, storage medium, and program product Download PDF

Info

Publication number
CN114003317A
CN114003317A CN202111272867.9A CN202111272867A CN114003317A CN 114003317 A CN114003317 A CN 114003317A CN 202111272867 A CN202111272867 A CN 202111272867A CN 114003317 A CN114003317 A CN 114003317A
Authority
CN
China
Prior art keywords
inline
class
instruction
configuration information
node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111272867.9A
Other languages
Chinese (zh)
Inventor
吴嘉鑫
李盼
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202111272867.9A priority Critical patent/CN114003317A/en
Publication of CN114003317A publication Critical patent/CN114003317A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • 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
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

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)
  • Library & Information Science (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The disclosure relates to an inline implementation method and device, electronic equipment, storage medium and program product, and relates to the technical field of computers. The method comprises the following steps: acquiring configuration information, wherein the configuration information comprises a class with an inline method and a corresponding inline method; obtaining a class file of a class with an inline method in the configuration information, and obtaining a method node of the inline method in the configuration information through a byte code control frame; generating a corresponding relation between a class with an inline method and method nodes of the inline method; traversing the method instructions in the class files through the bytecode manipulation framework, if the bytecode instructions in the method instructions are calling instructions and the classes and methods corresponding to the method instructions belong to the corresponding relationship, acquiring method nodes corresponding to the method instructions, and replacing the method instructions with the method nodes. The method can realize the internal connection on Java semantics and solve the problem of time consumption of program operation caused by the method internal connection in the related technology.

Description

Inline implementation method and apparatus, electronic device, storage medium, and program product
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an inline implementation method and apparatus, an electronic device, a storage medium, and a program product.
Background
Java method inlining is a technique of "copying" caller function code into caller function to reduce the overhead due to function call. In the related art, Java does not support semantic inlining, and the judgment of an inlining method needs to be performed by a virtual machine. When a method is not marked as an inline method by a virtual machine, calls using common methods cause frequent entry and popping of the virtual machine stack, increasing the time consumed by program execution.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The present disclosure provides an inline implementation method and apparatus, an electronic device, a storage medium, and a program product, so as to at least solve a problem of time consumption of program operation caused by method inline in related technologies. The technical scheme of the disclosure is as follows:
according to an aspect of the embodiments of the present disclosure, there is provided an inline implementation method, including: acquiring configuration information, wherein the configuration information comprises a class with an inline method and a corresponding inline method; acquiring a class file of the class with the inline method in the configuration information, and acquiring a method node of the inline method in the configuration information through a byte code control frame; generating a corresponding relation between the class with the inline method and the method node of the inline method; traversing the method instruction in the class file through a byte code control frame, if the byte code instruction in the method instruction is a call instruction and the class and the method corresponding to the method instruction belong to the corresponding relation, acquiring a method node corresponding to the method instruction, and replacing the method instruction by using the method node.
In one embodiment of the present disclosure, the method further comprises: querying the inline method through an annotation processor, determining the class with the inline method according to the inline method; and generating the configuration information by taking the class name of the class with the inline method as an index and taking the method signature of one or more inline methods contained in the class with the inline method as a value.
In an embodiment of the present disclosure, the generating a correspondence between the class with the inline method and the method node of the inline method includes: and storing the class name of the class with the inline method as an index and the method nodes of one or more inline methods contained in the class with the inline method as values as Map data.
In an embodiment of the present disclosure, if a bytecode instruction in the method instruction is a call instruction, and a class and a method corresponding to the method instruction belong to the correspondence, acquiring a method node corresponding to the method instruction, and replacing the method instruction with the method node, includes: judging whether a bytecode instruction in the method instruction is a call instruction or not, and the class name and the method name behind the method instruction belong to stored Map data; if yes, inquiring a method node corresponding to the method instruction in the stored Map data according to the class name and the method name behind the method instruction, and further replacing the method instruction by using the instruction in the inquired method node.
In one embodiment of the present disclosure, the inline method has inline annotation tags.
In one embodiment of the present disclosure, the inline method is a static method.
According to another aspect of the embodiments of the present disclosure, an inline implementation apparatus is provided, including: a configuration module configured to obtain configuration information including a class having an inline method and a corresponding inline method; the acquisition module is configured to acquire a class file of the class with the inline method in the configuration information and acquire a method node of the inline method in the configuration information through a bytecode manipulation framework; a generation module configured to generate a correspondence between the class with inline methods and method nodes of the inline methods; and the replacing module is configured to traverse the method instruction in the class file through a bytecode manipulation framework, and if the bytecode instruction in the method instruction is a call instruction and the class and the method corresponding to the method instruction belong to the corresponding relationship, obtain a method node corresponding to the method instruction, and replace the method instruction with the method node.
In one embodiment of the disclosure, the configuration module is configured to: querying the inline method through an annotation processor, determining the class with the inline method according to the inline method; and generating the configuration information by taking the class name of the class with the inline method as an index and taking the method signature of one or more inline methods contained in the class with the inline method as a value.
In one embodiment of the disclosure, the generation module is configured to: and storing the class name of the class with the inline method as an index and the method nodes of one or more inline methods contained in the class with the inline method as values as Map data.
In one embodiment of the disclosure, the replacement module is configured to: judging whether a bytecode instruction in the method instruction is a call instruction or not, and the class name and the method name behind the method instruction belong to stored Map data; if yes, inquiring a method node corresponding to the method instruction in the stored Map data according to the class name and the method name behind the method instruction, and further replacing the method instruction by using the instruction in the inquired method node.
In one embodiment of the present disclosure, the inline method has inline annotation tags.
In one embodiment of the present disclosure, the inline method is a static method.
According to still another aspect of the embodiments of the present disclosure, there is provided an electronic device including: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the inline implementation method described above.
According to yet another aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein instructions of the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the above-mentioned inline implementation method.
According to yet another aspect of the embodiments of the present disclosure, there is provided a computer program product comprising computer programs/instructions which, when executed by a processor, implement the inline implementation method described above.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects: configuration information including classes with an inline method and the inline method can be acquired, and then a byte code control frame is used for analyzing class files of the classes with the inline method to obtain method nodes of the inline method, and a corresponding relation between the classes with the inline method and the method nodes of the inline method is generated.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is a flow chart illustrating a method for inline implementation, according to an example embodiment.
FIG. 2 is a flow diagram illustrating the generation of configuration information according to an example embodiment.
Fig. 3 is a data structure diagram of the generated Map data.
FIG. 4 is a flow diagram illustrating analysis of method instructions in a class file according to an exemplary embodiment.
FIG. 5 is a flowchart illustrating a method for inline implementation, according to yet another exemplary embodiment.
FIG. 6 is a block diagram illustrating an inline implementation, according to an example embodiment.
FIG. 7 is a block diagram illustrating an architecture of an inline implementation device, according to an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
The method provided by the embodiment of the disclosure can be executed by any type of electronic device, such as a server or a terminal device, or by interaction between the server and the terminal device. The terminal device and the server may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein.
The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a CDN (Content Delivery Network), a big data and artificial intelligence platform, and the like.
The terminal device may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, and the like.
FIG. 1 is a flow chart illustrating a method for inline implementation, according to an example embodiment. As shown in fig. 1, the inline implementation method includes the following steps.
In step S110, configuration information is obtained, wherein the configuration information includes a class having an inline method and a corresponding inline method.
An inline method refers to a method in a Java file that needs to be inline, and if a method is an inline method, the code of the method needs to be "copied" into the caller function. In the embodiments of the present disclosure, the inline method is a static method. Thus, inline methods belong to classes, do not belong to objects, and can be called by class name before instantiating an object.
A class with an inline method refers to a class that includes a method in which inline is desired. For example, class1, class2 and class3 are classes with an inline method, and the methods requiring inline in class1 include method1 and method4, the methods requiring inline in class2 include method2 and method3, and the methods requiring inline in class3 include method5, so that the configuration information includes class1, class2 and class3, and further includes method1, method2, method3, method4 and method 5.
In step S120, a class file of the class with the inline method in the configuration information is obtained, and a method node of the inline method in the configuration information is obtained through a bytecode manipulation framework.
The class file is a file generated by compiling the Java file, and is also called a byte code file. After the class with the inline method in the configuration information is obtained, the class file may be traversed, and then the class file of the class with the inline method may be obtained, and then the class file of the class with the inline method may be analyzed by using an ASM (namely, a bytecode manipulation framework), so as to obtain a methodnode (namely, a method node) of the inline method in the configuration information. The specific implementation may be that a gradle (i.e., an item automation construction open source tool based on the concepts of Apache Ant and Apache Maven) plug-in is customized, a class file of a class having an inline method is controlled through an object model access mode in the ASM by using the gradle plug-in, and the class file may obtain a methodnode through the classnode, so that a methodnode of the inline method recorded in the configuration information may be obtained. The method has an attribute lnlist, which is a doubly linked list object containing the byte order of the storage method.
In step S130, a correspondence between the class with the inline method and the method node of the inline method is generated.
After the method of the inline method and the class having the inline method are obtained, a correspondence between the class having the inline method and the method of the inline method may be generated. For example, methods 1 and 4 are methods for class1 requiring an inline connection, and since a method of method1 and a method of method4 can be obtained in step S120, a correspondence relationship between class1 and a method of method1 and a method of method4 can be generated.
In step S140, a method instruction in a class file is traversed through a bytecode manipulation framework, and if the bytecode instruction in the method instruction is a call instruction and a class and a method corresponding to the method instruction belong to the correspondence, a method node corresponding to the method instruction is obtained, and the method instruction is replaced with the method node.
And traversing the class file, and traversing all method instructions in the class file by using the ASM. If the bytecode instruction in a method instruction is a calling instruction, the method is indicated to be a calling method. In this case, if the correspondence relationship generated in step S130 includes the class and the method corresponding to the method instruction, it indicates that the method inlining needs to be executed, so that a method node corresponding to the method instruction can be acquired, and the method instruction is replaced with the method node.
The method for realizing Java inline provided by the embodiment of the present disclosure may acquire configuration information including a class having an inline method and the inline method, and further analyze a class file of the class having the inline method by using an ASM to acquire a method of the inline method, and generate a correspondence between the class having the inline method and the method of the inline method, so that when traversing a method instruction in the class file, a method instruction to be replaced is determined by combining the generated correspondence, and then the method instruction is replaced by the method of the inline method, thereby realizing Java semantic inline, solving a problem of time consumption for program operation caused by method inline in related technologies, reducing the number of calling methods, and reducing program operation and calling overhead.
In an exemplary embodiment, the inline implementation method may further include generation of configuration information. FIG. 2 is a flow diagram illustrating the generation of configuration information according to an example embodiment. As shown in fig. 2, the step of generating the configuration information may include:
step S210, the annotation processor queries the inline method, and then determines the class with the inline method according to the inline method.
Step S220, using the class name of the class with the inline method as an index, and using the method signature of one or more inline methods included in the class with the inline method as a value, to generate the configuration information.
During the encoding period of the Java file, a method that requires inlining of the Inline annotation tag, such as a method that requires inlining through the @ Inline annotation tag, may be used, so that during the compilation period, the method having the annotation tag may be queried through the annotation processor. Thus, in embodiments of the present disclosure, inline methods have inline annotation tags.
An annotation processor may be understood as a piece of Java program that may be used to parse annotations during the compilation time of a Java file. When the Java file is compiled into the bytecode file, the method with the inline annotation tag in the Java file can be analyzed by the annotation processor, that is, the inline method can be queried by the annotation processor, and then the class to which the inline method belongs, that is, the class with the inline method can be determined. Next, configuration information may be generated that has the class name of the class having the inline method as an index and the method signature of the inline method included in the class having the inline method as a value. Where a method signature consists of the name of the method and a list of parameters (i.e., the order and type of the parameters of the method).
For example, if methods 1, 2, 3, 4 and 5 are Inline methods, then methods 1, 2, 3, 4 and 5 can be marked by @ Inline notes during the encoding period of a Java file. When encoding a Java file, methods 1, 2, 3, 4 and 5 marked with the @ Inline comment are queried by the comment processor. Also, it can be determined that methods method1 and method4 belong to class1, methods method2 and method3 belong to class2, and method5 belongs to class3, then classes 1, class2, and class3 with inline methods can be obtained. Finally, configuration information is generated with the class name of class1 as an index and the method signatures of inline methods 1 and method4 contained in class1 as values, configuration information is generated with the class name of class2 as an index and the method signatures of inline methods 2 and method3 contained in class2 as values, and configuration information is generated with the class name of class3 as an index and the method signature of inline method5 contained in class3 as a value.
In the related technology, a virtual machine is required to perform inline judgment, but in the embodiment of the disclosure, in a Java file coding period, an inline annotation is adopted to mark a method requiring inline, so that in a Java file compiling period, a method requiring inline is obtained through an annotation processor, and a configuration file including a class having the inline method and the inline method is further generated, so as to realize the inline in Java semantics by subsequently utilizing the configuration file.
In an exemplary embodiment, the generating of the correspondence between the class with the inline method and the methodnode of the inline method in step S130 may include: and storing the class name of the class with the inline method as an index and the method of one or more inline methods contained in the class with the inline method as a value as Map data.
Fig. 3 is a data structure diagram of the generated Map data. In FIG. 3, method1, method2, method3, method4 and method5 are inline methods, and class1, class2 and class3 are classes with inline methods. It can be seen that class1 corresponds to method nodes of methods 1 and 4, class2 corresponds to method nodes of methods 2 and 3, and class3 corresponds to method nodes of methods 5. That is, the method nodes of method1 and method4 can be quickly queried through class1, the method nodes of method2 and method3 can be quickly queried through class2, and the method node of method5 can be quickly queried through class 3.
In the embodiment of the disclosure, the Map data storage can be performed by using the class name of the class with the inline method as the index and using the method node of the inline method included in the class with the inline method as the value, and since the Map data is a key value pair data type and has a very fast search speed, the instruction replacement is performed according to the stored Map data, so that the corresponding method node can be quickly searched, and the time consumed by program operation is further reduced.
FIG. 4 is a flow diagram illustrating analysis of method instructions in a class file according to an exemplary embodiment. As shown in fig. 4, the step of analyzing the method instructions in the class file may include:
step S410, determining whether the bytecode in the method instruction is a call instruction, if yes, performing step S420;
step S420, judging whether the class name and the method name behind the method instruction belong to the stored Map data, if so, executing step S430;
step S430, according to the class name and method name behind the method instruction, a method node corresponding to the method instruction is searched in the stored Map data, and the method instruction is replaced by an instruction in the searched method node.
And traversing the method instructions in the class file through the ASM, namely analyzing the instruction contents of all the methods in the class file in sequence. If the bytecode in a method instruction is a call instruction invokestatic, and the class name and method name following the method instruction belong to the stored Map data, it is said that the method function code is "copied", so that the method node corresponding to the method instruction can be searched in the stored Map data and then replaced. Taking the Map data shown in fig. 3 as an example, if the bytecode in a Method Instruction1 is a call Instruction invokestatic, and the following class name is class1 and the Method name is Method1, the Instruction statement is deleted, and the Instruction in the Method node of Method1 is added to the position of the deleted Instruction. If the class name is class1 and the Method name is Method2 after a Method Instruction2 is inquired, Instruction replacement is not needed because the class name and the Method name are not stored in Map data.
FIG. 5 is a flowchart illustrating a Java inline implementation method according to yet another example embodiment. As shown in fig. 5, the inline implementation method includes the following steps:
step S510, inquiring an inline method in the Java file through an annotation processor, and further determining a class with the inline method according to the inquired inline method, wherein the inquired inline method is a static method;
step S520, generating configuration information by using the class name of the class with the inline method as an index and using the method signature of one or more inline methods contained in the class with the inline method as a value;
step S530, traversing the Java class files through the gradle plug-in and the ASM, acquiring class files of classes with the inline method in the configuration information, and acquiring method nodes of the inline method in the configuration information;
step S540, storing the class name of the class with the inline method as an index and the method nodes of one or more inline methods contained in the class with the inline method as values, and storing the values as Map data;
step S550, traversing method instructions in the Java class file through the ASM;
step S560, determining whether the bytecode instruction in the method instruction is the call instruction invokestatic, and the class name and method name behind the method instruction belong to the stored Map data, if yes, performing step S570, and if no, performing step S580;
step S570, according to the class name and method name behind the method instruction, inquiring the method node corresponding to the method instruction in the stored Map data, and further replacing the method instruction by the instruction in the inquired method node;
step S580, determine whether to traverse all method instructions in the Java class file, if traverse all method instructions in the Java class file, then end, and implement Java inlining, otherwise, continue traversing.
In the encoding period of the Java file, the static method needing to be subjected to the inlining can be labeled by adopting the inlining annotation tag, so that the inlining method (namely, the static method needing to be subjected to the inlining) in the Java file can be inquired through the annotation processor, the class with the inlining method is obtained, then the class file can be modified by utilizing the gradle plug-in and the ASM, the inlining on the Java semantics is realized, the situation that the inlining is judged through the virtual machine is avoided, the frequent entering of a virtual machine stack can be reduced, the number of calling methods is reduced, and the program running calling expense is reduced.
The following describes the summation of two parameters by using an inline method, and the inline implementation method provided in the embodiment of the present disclosure is also applicable to service data in other service scenarios, which is not limited by the present disclosure.
Figure BDA0003329258010000081
Figure BDA0003329258010000091
As shown in the above code, the definition class T contains a method add, which is used to sum the parameters a and b, return c, and add the Inline annotation tag @ Inline to the method add. Therefore, in the compiling period, the annotation processor queries the class T to which the method add and the method add belong, and then corresponding configuration information can be generated by taking the class name of the class T as an index and the method signature of the method add contained in the class T as a value. Then, a class file of the class T is obtained through the gradle plug-in and the ASM, and a methodnode of the method add is further obtained. Then, the class name of the class T is used as an index, and the methodnode of the method add included in the class T is used as a value, and stored as Map data. When traversing the method instruction in the class file of the class User, the method instruction is determined to be a call instruction, the class corresponding to the method instruction is T, and the corresponding method is add, so that the method instruction can be replaced by the instruction in the methodnode of the method add, so that the code int c ═ T.
FIG. 6 is a block diagram illustrating an inline implementation, according to an example embodiment. Referring to fig. 6, the inline implementation 600 includes a configuration module 610, an acquisition module 620, a generation module 630, and a replacement module 640.
The configuration module 610 is configured to obtain configuration information. Wherein the configuration information may include: class with inline method and corresponding inline method.
The obtaining module 620 is configured to obtain a class file of a class having an inline method in the configuration information, and obtain a methodnode of the inline method in the configuration information through the ASM.
The generating module 630 is configured to generate a correspondence between the class with inline method and the methodnode of the inline method.
The replacing module 640 is configured to traverse the method instruction in the class file through the ASM, and if the bytecode instruction in the method instruction is a call instruction and the class and the method corresponding to the method instruction belong to the corresponding relationship, obtain the methodnode corresponding to the method instruction, and replace the method instruction with the methodnode.
In an exemplary embodiment, the configuration module 610 may be further configured to: inquiring an inline method through an annotation processor, and determining a class with the inline method according to the inline method; and generating configuration information by taking the class name of the class with the inline method as an index and taking the method signatures of one or more inline methods contained in the class with the inline method as values.
In an exemplary embodiment, the generating module 630 may be further configured to: the class name of the class with the inline method is used as an index, and the method nodes of one or more inline methods contained in the class with the inline method are used as values and stored as Map data.
In an exemplary embodiment, the replacement module 640 may be further configured to: judging whether a bytecode instruction in the method instruction is a call instruction or not, and the class name and the method name behind the method instruction belong to the stored Map data; if yes, inquiring a method node corresponding to the method instruction in the stored Map data according to the class name and the method name behind the method instruction, and further replacing the method instruction by using the instruction in the inquired method node.
In an exemplary embodiment, the inline method has inline annotation tags.
In an exemplary embodiment, the inline method is a static method.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
FIG. 7 is a block diagram illustrating an architecture of an inline implementation device, according to an example embodiment. It should be noted that the illustrated electronic device is only an example, and should not bring any limitation to the functions and the scope of the embodiments of the present invention.
An electronic device 700 according to this embodiment of the invention is described below with reference to fig. 7. The electronic device 700 shown in fig. 7 is only an example and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, electronic device 700 is embodied in the form of a general purpose computing device. The components of the electronic device 700 may include, but are not limited to: the at least one processing unit 710, the at least one memory unit 720, and a bus 730 that couples various system components including the memory unit 720 and the processing unit 710.
Wherein the storage unit stores program code that is executable by the processing unit 710 such that the processing unit 710 performs the steps according to various exemplary embodiments of the present invention as described in the above section "exemplary method" of the present specification. For example, the processing unit 710 may execute step S110 shown in fig. 1, and obtain configuration information, where the configuration information includes a class having an inline method and a corresponding inline method; step S120, obtaining the class file of the class with the inline method in the configuration information, and obtaining the method node of the inline method in the configuration information through a byte code control frame; step S130, generating the corresponding relation between the class with the inline method and the method node of the inline method; step S140, traversing the method instruction in the class file through the bytecode manipulation framework, if the bytecode instruction in the method instruction is a call instruction and the class and the method corresponding to the method instruction belong to the corresponding relationship, acquiring a method node corresponding to the method instruction, and replacing the method instruction with the method node.
The storage unit 720 may include readable media in the form of volatile memory units, such as a random access memory unit (RAM)7201 and/or a cache memory unit 7202, and may further include a read only memory unit (ROM) 7203.
The storage unit 720 may also include a program/utility 7204 having a set (at least one) of program modules 7205, such program modules 7205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 730 may be any representation of one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 700 may also communicate with one or more external devices 800 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 700, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 700 to communicate with one or more other computing devices. Such communication may occur via an input/output (I/O) interface 750. Also, the electronic device 700 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network such as the Internet) via the network adapter 770. As shown, the network adapter 770 communicates with the other modules of the electronic device 700 over the bus 730. It should be appreciated that although not shown in the figures, other hardware and/or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
In an exemplary embodiment of the present disclosure, there is also provided a computer-readable storage medium having stored thereon a program product capable of implementing the above-described method of the present specification. In some possible embodiments, aspects of the invention may also be implemented in the form of a program product comprising program code means for causing a terminal device to carry out the steps according to various exemplary embodiments of the invention described in the above section "exemplary methods" of the present description, when said program product is run on the terminal device.
According to the program product for implementing the method, the portable compact disc read only memory (CD-ROM) can be adopted, the program code is included, and the program product can be operated on terminal equipment, such as a personal computer. However, the program product of the present invention is not limited in this regard and, in the present document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A computer readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Moreover, although the steps of the methods of the present disclosure are depicted in the drawings in a particular order, this does not require or imply that the steps must be performed in this particular order, or that all of the depicted steps must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions, etc.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. An inline implementation method, comprising:
acquiring configuration information, wherein the configuration information comprises a class with an inline method and a corresponding inline method;
acquiring a class file of the class with the inline method in the configuration information, and acquiring a method node of the inline method in the configuration information through a byte code control frame;
generating a corresponding relation between the class with the inline method and the method node of the inline method;
traversing the method instruction in the class file through a byte code control frame, if the byte code instruction in the method instruction is a call instruction and the class and the method corresponding to the method instruction belong to the corresponding relation, acquiring a method node corresponding to the method instruction, and replacing the method instruction by using the method node.
2. The method of claim 1, further comprising:
querying the inline method through an annotation processor, determining the class with the inline method according to the inline method;
and generating the configuration information by taking the class name of the class with the inline method as an index and taking the method signature of one or more inline methods contained in the class with the inline method as a value.
3. The method of claim 1, wherein generating the correspondence between the class with inline methods and the method nodes of the inline methods comprises:
and storing the class name of the class with the inline method as an index and the method nodes of one or more inline methods contained in the class with the inline method as values as Map data.
4. The method according to claim 3, wherein if the bytecode instruction in the method instruction is a call instruction and the class and method corresponding to the method instruction belong to the correspondence, acquiring a method node corresponding to the method instruction, and replacing the method instruction with the method node, includes:
judging whether a bytecode instruction in the method instruction is a call instruction or not, and the class name and the method name behind the method instruction belong to stored Map data;
if yes, inquiring a method node corresponding to the method instruction in the stored Map data according to the class name and the method name behind the method instruction, and further replacing the method instruction by using the instruction in the inquired method node.
5. The method of any one of claims 1 to 4, wherein the inline method has inline annotation tags.
6. The method according to any one of claims 1 to 4, wherein the inline process is a static process.
7. An inline implementation apparatus, comprising:
a configuration module configured to obtain configuration information including a class having an inline method and a corresponding inline method;
the acquisition module is configured to acquire a class file of the class with the inline method in the configuration information and acquire a method node of the inline method in the configuration information through a bytecode manipulation framework;
a generation module configured to generate a correspondence between the class with inline methods and method nodes of the inline methods;
and the replacing module is configured to traverse the method instruction in the class file through a bytecode manipulation framework, and if the bytecode instruction in the method instruction is a call instruction and the class and the method corresponding to the method instruction belong to the corresponding relationship, obtain a method node corresponding to the method instruction, and replace the method instruction with the method node.
8. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the inline implementation method of any of claims 1 to 6.
9. A computer-readable storage medium, wherein instructions, when executed by a processor of an electronic device, enable the electronic device to perform the inline-implementation method of any of claims 1-6.
10. A computer program product comprising computer programs/instructions, characterized in that said computer programs/instructions, when executed by a processor, implement the inline implementation method of any of the claims 1 to 6.
CN202111272867.9A 2021-10-29 2021-10-29 Inline implementation method and apparatus, electronic device, storage medium, and program product Pending CN114003317A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111272867.9A CN114003317A (en) 2021-10-29 2021-10-29 Inline implementation method and apparatus, electronic device, storage medium, and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111272867.9A CN114003317A (en) 2021-10-29 2021-10-29 Inline implementation method and apparatus, electronic device, storage medium, and program product

Publications (1)

Publication Number Publication Date
CN114003317A true CN114003317A (en) 2022-02-01

Family

ID=79925297

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111272867.9A Pending CN114003317A (en) 2021-10-29 2021-10-29 Inline implementation method and apparatus, electronic device, storage medium, and program product

Country Status (1)

Country Link
CN (1) CN114003317A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020104076A1 (en) * 1998-06-30 2002-08-01 Nik Shaylor Code generation for a bytecode compiler
US20070204258A1 (en) * 2006-02-24 2007-08-30 Samsung Electronics Co., Ltd. Method of invoking inlined method and java virtual machine using the method
US20150199186A1 (en) * 2011-10-07 2015-07-16 Google Inc. Implement inline cache using a data array
CN107924326A (en) * 2016-07-12 2018-04-17 甲骨文国际公司 The moving method of updated type is covered
CN108021370A (en) * 2017-12-26 2018-05-11 网易(杭州)网络有限公司 Optimization method, device, storage medium, processor and the terminal of bytecode
CN108614702A (en) * 2016-12-28 2018-10-02 阿里巴巴集团控股有限公司 Bytecode-optimized method and device
CN108614960A (en) * 2018-05-11 2018-10-02 西北大学 A kind of JavaScript virtualization guard methods based on front end bytecode technology
CN109032572A (en) * 2017-06-08 2018-12-18 阿里巴巴集团控股有限公司 A method of the JAVA program technic based on bytecode is inline
CN111078279A (en) * 2019-12-20 2020-04-28 北京字节跳动网络技术有限公司 Processing method, device and equipment of byte code file and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020104076A1 (en) * 1998-06-30 2002-08-01 Nik Shaylor Code generation for a bytecode compiler
US20070204258A1 (en) * 2006-02-24 2007-08-30 Samsung Electronics Co., Ltd. Method of invoking inlined method and java virtual machine using the method
US20150199186A1 (en) * 2011-10-07 2015-07-16 Google Inc. Implement inline cache using a data array
CN107924326A (en) * 2016-07-12 2018-04-17 甲骨文国际公司 The moving method of updated type is covered
CN108614702A (en) * 2016-12-28 2018-10-02 阿里巴巴集团控股有限公司 Bytecode-optimized method and device
CN109032572A (en) * 2017-06-08 2018-12-18 阿里巴巴集团控股有限公司 A method of the JAVA program technic based on bytecode is inline
CN108021370A (en) * 2017-12-26 2018-05-11 网易(杭州)网络有限公司 Optimization method, device, storage medium, processor and the terminal of bytecode
CN108614960A (en) * 2018-05-11 2018-10-02 西北大学 A kind of JavaScript virtualization guard methods based on front end bytecode technology
CN111078279A (en) * 2019-12-20 2020-04-28 北京字节跳动网络技术有限公司 Processing method, device and equipment of byte code file and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
GIUSEPPE VENANZONI: "Design and Fabrication of 3-D Printed Inline Coaxial Filters With Improved Stopband", 《IEEE TRANSACTIONS ON MICROWAVE THEORY AND TECHNIQUES》, vol. 68, no. 7, 31 July 2020 (2020-07-31), pages 2633, XP011796025, DOI: 10.1109/TMTT.2020.2988244 *
史成荣: "基于即时编译器的Java语言同步优化研究", 《中国优秀硕士学位论文全文数据库 信息科技辑》, no. 7, 15 July 2010 (2010-07-15), pages 138 - 545 *
王雷 等: "基于持续监控的动态内联优化", 《软件学报》, no. 10, 15 October 2007 (2007-10-15), pages 2393 - 2402 *

Similar Documents

Publication Publication Date Title
US20200192640A1 (en) Efficient State Machines for Real-Time Dataflow Programming
US8997070B2 (en) Extension mechanism for scripting language compiler
US8479178B2 (en) Compiler in a managed application context
US20190146764A1 (en) Using comments of a program to provide optimizations
CN111414350B (en) Service generation method and device
CN111324833A (en) Page display method, device, electronic design and computer readable medium
CN110058861B (en) Source code processing method and device, storage medium and electronic equipment
CN114238948A (en) Application program detection method and device, electronic equipment and storage medium
CN115599386A (en) Code generation method, device, equipment and storage medium
CN107391528B (en) Front-end component dependent information searching method and equipment
US9886251B2 (en) Optimized compiling of a template function
CN112015374B (en) Cross-programming-language micro-service integration system based on natural language
CN114115884B (en) Method and related device for managing programming service
CN109063059A (en) User behaviors log processing method, device and electronic equipment
CN112631563A (en) System development method and device based on framework, computer equipment and storage medium
KR20180131009A (en) System and method for converting large scale application
CN110018831B (en) Program processing method, program processing apparatus, and computer-readable storage medium
CN116450723A (en) Data extraction method, device, computer equipment and storage medium
CN112346774A (en) Method and device for generating application installation package
US20230418566A1 (en) Programmatically generating evaluation data sets for code generation models
CN114003317A (en) Inline implementation method and apparatus, electronic device, storage medium, and program product
CN115640279A (en) Method and device for constructing data blood relationship
CN112181407B (en) Service realization processing method, device, system, electronic equipment and storage medium
CN114547106A (en) Data query method and device, storage medium and computer system
CN114625372A (en) Automatic component compiling method and device, 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