Interface method dispatching method and device and electronic equipment

During the interface method dispatching process, the implementation node of the target interface method is found and stripped from the preset linked list and inserted into the queue header, the problem of low distribution efficiency of the interface method is solved and the operation efficiency of the virtual machine is improved.

CN119902849APending Publication Date: 2025-04-29GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311414242.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-27
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

In the object-oriented programming model, the interface method dispatch efficiency is low, which affects the operation efficiency of the virtual machine.

Method used

In the process of implementing interface method dispatch, the corresponding implementation of the target interface method is found from the preset linked list. If found, the node it is located is stripped from the preset linked list and inserted into the queue header to avoid hash conflicts.

Benefits of technology

It improves the dispatch efficiency of interface methods, reduces the average search time, and thus improves the operation efficiency of virtual machines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119902849A_ABST
    Figure CN119902849A_ABST
Patent Text Reader

Abstract

The invention discloses an interface method dispatching method and device, electronic equipment and a storage medium. The method comprises the steps that in the process of achieving interface method assignment, implementation corresponding to a target interface method is searched for in a preset linked list, and the preset linked list is constructed for avoiding hash conflicts; if the implementation corresponding to the target interface method is found, stripping a node where the implementation corresponding to the target interface method is located from the preset linked list; and inserting the node stripped from the preset linked list into a queue head of the preset linked list. According to the method, the node corresponding to the target interface method to be searched for is stripped from the preset linked list and then is directly inserted into the queue head of the preset linked list, so that the same interface method can be quickly hit when being accessed next time, the average searching time is shortened, the dispatching efficiency of the interface method is improved, and the user experience is improved. And the operation efficiency of the virtual machine is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to an interface method dispatching method, device, electronic device and storage medium. Background Art

[0002] In the object-oriented programming model, a "method" describes a behavior on an object, and usually a method is a function. In the ART (Android Runtime, Android application running) virtual machine, the process of finding the specific implementation of a method is called "dispatch". This "dispatch" usually includes VirtualMethod (virtual method) dispatch and Interface Method (interface method) dispatch. Compared with Virtual Method dispatch, Interface Method dispatch is more complicated. For Interface Method, a class may implement multiple interfaces, or implement an interface, but the interface inherits multiple other interfaces. Therefore, when implementing an Interface, all methods defined in the Interface must be implemented, which will seriously affect the dispatch efficiency of Interface Method, and then affect the operating efficiency of the virtual machine. Summary of the invention

[0003] The present application proposes an interface method dispatching method, device, electronic device and storage medium to improve the above-mentioned problems.

[0004] In the first aspect, an embodiment of the present application provides an interface method dispatching method, the method comprising: in the process of implementing interface method dispatching, searching for an implementation corresponding to a target interface method from a preset linked list, the preset linked list being constructed to avoid hash conflicts; if an implementation corresponding to the target interface method is found, stripping the node where the implementation corresponding to the target interface method is located from the preset linked list; and inserting the node stripped from the preset linked list into the queue head of the preset linked list.

[0005] In the second aspect, an embodiment of the present application provides an interface method dispatching device, which includes: a search module, which is used to search for an implementation corresponding to a target interface method from a preset linked list during the process of implementing interface method dispatch, and the preset linked list is constructed to avoid hash conflicts; a node stripping module, which is used to strip the node where the implementation corresponding to the target interface method is located from the preset linked list if the implementation corresponding to the target interface method is found; and an interface method dispatching module, which is used to insert the node stripped from the preset linked list into the queue head of the preset linked list.

[0006] In a third aspect, the present application provides an electronic device comprising one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method of the first aspect above.

[0007] In a fourth aspect, the present application provides a computer-readable storage medium having program code stored therein, wherein the method of the first aspect is executed when the program code is run.

[0008] The present application provides an interface method dispatching method, device, electronic device and storage medium. The method searches for the implementation corresponding to the target interface method from a preset linked list during the process of implementing the interface method dispatching. The preset linked list is constructed to avoid hash conflicts. If the implementation corresponding to the target interface method is found, the node where the implementation corresponding to the target interface method is located is stripped from the preset linked list. The node stripped from the preset linked list is inserted into the queue head of the preset linked list. Thus, the node where the implementation corresponding to the target interface method to be found is located can be stripped from the preset linked list and directly inserted into the queue head of the preset linked list through the above method, so that the next time the same interface method is accessed, it can be hit faster to reduce the average search time, thereby improving the dispatch efficiency of the interface method, and then improving the operation efficiency of the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0010] Figure 1 The flowchart of implementing Interface Method dispatching by ART virtual machine in the related art is shown.

[0011] Figure 2A flowchart of an interface method dispatching method provided by an embodiment of the present application is shown.

[0012] Figure 3 A flowchart of an interface method dispatching method provided by another embodiment of the present application is shown.

[0013] Figure 4 A structural example diagram of a preset linked list provided in an embodiment of the present application is shown.

[0014] Figure 5 Another structural example diagram of the preset linked list provided in an embodiment of the present application is shown.

[0015] Figure 6 A flowchart of an interface method dispatching method provided by yet another embodiment of the present application is shown.

[0016] Figure 7 Another structural example diagram of the preset linked list provided in an embodiment of the present application is shown.

[0017] Figure 8 A flowchart of an interface method dispatching method provided by yet another embodiment of the present application is shown.

[0018] Fig. 9 A structural block diagram of an interface method dispatching device provided in an embodiment of the present application is shown.

[0019] Fig.10 A structural block diagram of an electronic device provided in an embodiment of the present application is shown.

[0020] Fig.11 A storage unit for storing or carrying program codes for implementing the interface method dispatching method according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0022] In the object-oriented programming model, C++ supports "multiple inheritance", while Java does not support "multiple inheritance". Java only allows "single inheritance", that is, a Java class can only have one parent class. "Single inheritance" makes the inheritance relationship simple. VirtualMethod is a method inherited from a parent class or an earlier ancestor class. A subclass can override the implementation of the VirtualMethod. If the subclass does not override the Virtual Method, the implementation of its parent class is used. If the parent class does not implement the Virtual Method, the implementation is searched in the parent class of the parent class until an implementation is found. In the object-oriented programming model, a "method" describes a behavior on an object. Usually a method is a function. In the Android ART virtual machine, the process of finding the specific implementation of a method is called "dispatch".

[0023] Although Java only allows "single inheritance", that is, a subclass can only have one parent class, by introducing the Interface abstract type, similar multiple inheritance capabilities can be achieved. The Interface abstract type is used to define a series of methods. Although a Java class is only allowed to inherit (extends) one parent class, it is allowed to implement (implements) multiple Interfaces. To implement an Interface, you need to implement all the methods defined in the Interface. The methods defined in the Interface can be called Interface Methods. Finding the specific implementation of an Interface Method is called Interface Method Dispatch.

[0024] However, the inventors found that for Interface Method, a class may implement multiple interfaces, or implement an interface, but the interface inherits multiple other interfaces. In these cases, it is impossible to guarantee that the offset of the implementation of Interface Method in the subclass is a fixed position. Then, when searching for the implementation corresponding to the interface method, it may be necessary to traverse multiple times, increasing the time complexity, which may seriously affect the dispatch efficiency of Interface Method, and further affect the operating efficiency of the virtual machine.

[0025] After long-term research, the inventor found that in the process of implementing the interface method dispatch, the implementation corresponding to the target interface method can be searched from a preset linked list, and the preset linked list is constructed to avoid hash conflicts; if the implementation corresponding to the target interface method is found, the node where the implementation corresponding to the target interface method is located is stripped from the preset linked list; and the node stripped from the preset linked list is inserted into the queue head of the preset linked list. Thus, through the above method, the node where the implementation corresponding to the target interface method to be found is located can be stripped from the preset linked list and directly inserted into the queue head of the preset linked list, so that the next time the same interface method is accessed, it can be hit faster, thereby reducing the average search time, thereby improving the dispatch efficiency of the interface method, and then improving the operating efficiency of the virtual machine.

[0026] Therefore, in order to improve the above problems, the inventors proposed the interface method dispatching method, device, electronic device and computer-readable storage medium provided in the present application, which can improve the dispatching efficiency of the interface method and thereby improve the operating efficiency of the virtual machine.

[0027] In order to facilitate a better understanding of the solution described in the embodiments of the present application, the following briefly describes the terms involved in the description of the embodiments of the present application:

[0028] ART (Android Runtime): represents the virtual machine that runs Android applications.

[0029] Hash Table: A data structure that represents direct access based on a key value. In other words, it accesses records by mapping the key value to a position in the table to speed up the search. This mapping function is called a hash function, and the array that stores the records is called a hash table.

[0030] VMT (Virtual Method Dispatch Table): represents the virtual method dispatch table.

[0031] IMT (Interface Method Dispatch Table): represents the interface method dispatch table.

[0032] IFT (Interface Table): represents the interface dispatch table.

[0033] O(n): A symbol that represents the time complexity. It means that when searching, the search time increases linearly according to the number of search targets. In addition, O(1) means that when searching for a certain target, there is no need to search and the position can be directly located, which is the most efficient.

[0034] In the process of finding the implementation corresponding to a certain interface method, as a way, the entire process of Interface Method dispatch can be implemented through the ART virtual machine. Figure 1 , shows a flowchart of implementing Interface Method dispatching through ART virtual machine in related technology. Figure 1 As shown, the implementation of Interface Method dispatch through ART virtual machine may specifically include: first, searching for the Entry corresponding to the dispatched Interface Method from IMT Table; if the Entry corresponding to the dispatched Interface Method is found from IMTTable, but it is not the Implementation Method (i.e., the implementation of Interface Method), then searching for the Entry corresponding to Interface Method from IMTConflict Table; if the implementation corresponding to Interface Method is found from IMTConflict Table, then directly jump to the corresponding implementation function for execution; if the implementation corresponding to Interface Method is not found from IMTConflict Table, then searching for the Entry corresponding to Interface Method from IfTable. Optionally, if the Entry corresponding to the dispatched Interface Method is not found from IMT Table, then searching for the Entry corresponding to Interface Method from IfTable directly.

[0035] Then, the result found in IfTable can be written back to IMT Table or IMTConflictTable, so that the InterfaceMethod can be found directly from IMT Table or IMTConflict Table next time. Before writing back the result found in IfTable, it can be determined whether there is already an Entry corresponding to Interface Method in IMT Table. If there is already an Entry corresponding to Interface Method in IMT Table, the result found in IfTable can be written back (added) to IMTConflict Table, and then jump to the corresponding implementation function for execution; if there is no Entry corresponding to Interface Method in IMT Table, the result found in IfTable can be written back (added) to IMT Table, and then jump to the corresponding implementation function for execution.

[0036] Among them, the time complexity of searching in the IMT Table is O(1), the time complexity of searching from the IMTConflict Table is O(n), and the time complexity of searching in the IfTtable is higher (that is, greater than O(n)).

[0037] For IMTConflict Table, an Interface Method occupies two slots in IMTConflict Table, with the Interface Method pointer placed at slot+0 and the corresponding implementation placed at slot+1. When searching for the implementation of an Interface Method from IMTConflict Table, it is necessary to traverse the IMTConflict Table and compare the Interface Method pointer to be searched with the 0th, 2nd, 4th, 6th...2nth elements in IMTConflict Table in sequence. If the pointer value IMTConflict Table[2n] at the 2nth element is the same as the InterfaceMethod to be searched, the value at IMTConflict Table[2n+1] is the implementation of the Interface Method. Moreover, if an Interface Method is located at the last position of the IMTConflict Table, and the Interface Method has just been accessed, when it is accessed again, it is still necessary to traverse the entire IMTConflict Table again to find the implementation of the Interface Method, which greatly increases the time complexity of searching in the IMTConflict Table, thereby reducing the access efficiency of the IMTConflict Table and affecting the dispatch efficiency of the Interface Method.

[0038] The implementation method of the present application mainly optimizes the access process of searching for the implementation of the Interface Method from the IMTConflict Table.

[0039] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0040] See also Figure 2 , shows a flow chart of an interface method dispatching method provided by an embodiment of the present application. This embodiment provides an interface method dispatching method, which can be applied to a server. The method includes:

[0041] Step S110: In the process of implementing the interface method dispatch, the implementation corresponding to the target interface method is searched from a preset linked list, where the preset linked list is constructed to avoid hash conflicts.

[0042] In this implementation, in order to avoid hash conflicts in the process of accessing the implementation of the Interface Method from the IMTConflict Table, the IMTConflict Table can be transformed into a double linked list structure. For ease of description, the transformed double linked list can be called a preset linked list. The IMTConflict Table can be understood as a conflict resolution table.

[0043] A preset linked list stores multiple interface methods and the implementation corresponding to each interface method in advance, each interface method and the implementation corresponding to the interface method are stored in the same node, and the preset linked list may include multiple nodes. In the process of implementing the interface method dispatch, as an implementation method, the implementation corresponding to the target interface method can be directly searched from the preset linked list.

[0044] In this embodiment, the target interface method may include at least one of the most recently used interface method, the interface method with the most access times (within a preset time period, the specific duration of the preset time period may not be limited, for example, it may be within one minute, one hour, etc.), and the interface method with an access frequency greater than a frequency threshold. The specific value of the frequency threshold may not be limited.

[0045] It should be noted that in each search process, the number of target interface methods in this embodiment is one. For example, the target interface method may be an interface method used last time (i.e., the last time used), and the last used interface method may also be the interface method with the most access times within a preset time period, and even the last used interface method may also be an interface method with an access frequency greater than a frequency threshold.

[0046] Step S120: If the implementation corresponding to the target interface method is found, the node where the implementation corresponding to the target interface method is located is stripped from the preset linked list.

[0047] As an implementation method, if the implementation corresponding to the target interface method is found from the preset linked list, in order to reduce the time complexity of the next search for the target interface method and the corresponding implementation, the node where the implementation corresponding to the target interface method is located can be stripped from the preset linked list. Stripping can be understood as changing the position of the node where the target interface method is located in the preset linked list, so as to reduce the time complexity of finding the target interface method and its corresponding implementation by changing the position of the node where the target interface method is located in the preset linked list.

[0048] Step S130: inserting the node stripped from the preset linked list into the queue head of the preset linked list.

[0049] In order to improve the access efficiency of the preset linked list, the node stripped from the preset linked list can be inserted into the queue head of the preset linked list, so that when the stripped node needs to be accessed again, the search time can be shortened and the node can be found quickly.

[0050] The interface method dispatching method provided in this embodiment searches for the implementation corresponding to the target interface method from a preset linked list during the process of implementing the interface method dispatching, and the preset linked list is constructed to avoid hash conflicts; if the implementation corresponding to the target interface method is found, the node where the implementation corresponding to the target interface method is located is stripped from the preset linked list; and the node stripped from the preset linked list is inserted into the queue head of the preset linked list. Thus, through the above method, the node where the implementation corresponding to the target interface method to be found is located can be stripped from the preset linked list and directly inserted into the queue head of the preset linked list, so that the next time the same interface method is accessed, it can be hit faster, thereby reducing the average search time, thereby improving the dispatching efficiency of the interface method, and further improving the operating efficiency of the virtual machine.

[0051] See also Figure 3 , shows a flow chart of an interface method dispatching method provided by another embodiment of the present application. This embodiment provides an interface method dispatching method, which can be applied to a server. This implementation mainly describes the implementation process of moving the found node to the queue head of a preset linked list. The method includes:

[0052] Step S210: In the process of implementing the interface method dispatch, the implementation corresponding to the target interface method is searched from a preset linked list, where the preset linked list is constructed to avoid hash conflicts.

[0053] The specific implementation of step S210 may refer to the relevant description of step S110 in the aforementioned embodiment, which will not be repeated here.

[0054] Step S220: If the implementation corresponding to the target interface method is found, the next pointer of the previous node of the node where the implementation corresponding to the target interface method is located is set to point to the next node of the node where the implementation corresponding to the target interface method is located; and the prev pointer of the next node of the node where the implementation corresponding to the target interface method is located is set to point to the previous node of the node where the implementation corresponding to the target interface method is located, so as to strip the node where the implementation corresponding to the target interface method is located from the preset linked list.

[0055] In this implementation, the preset linked list may include multiple nodes, each of which may include an interface method pointer, an implementation of the interface method, a next pointer, and a prev pointer, wherein the next pointer is used to point to the next node, and the prev pointer is used to point to the previous node.

[0056] As an implementation method, if the implementation corresponding to the target interface method is found, the next pointer of the previous node of the node where the implementation corresponding to the target interface method is located can be set to point to the next node of the node where the implementation corresponding to the target interface method is located; and the prev pointer of the next node of the node where the implementation corresponding to the target interface method is located can be set to point to the previous node of the node where the implementation corresponding to the target interface method is located, so as to strip the node where the implementation corresponding to the target interface method is located from the preset linked list.

[0057] For example, assuming that the node to be moved is pToBeMoveToFront, you can set the next node of the previous node of pToBeMoveToFront to the next node of pToBeMoveToFront, and set the prev node of the next node of pToBeMoveToFront to the previous node of pToBeMoveToFront, so as to strip pToBeMoveToFront from the original linked list. The expression for stripping the node can be expressed as follows:

[0058] pToBeMoveToFront->Prev->Next=pToBeMoveToFront->Next

[0059] pToBeMoveToFront->Next->Prev=pToBeMoveToFront->Prev

[0060] In a specific application scenario, see Figure 4 , shows an example diagram of the structure of the preset linked list provided in the embodiment of the present application. Figure 4As shown, the preset linked list includes 4 nodes, each of which includes an interface method pointer, an implementation of the interface method, a next pointer, and a prev pointer. Assuming that Interface Artmethod2 is the target interface method, and Implementation Artmethod2 is the implementation corresponding to the target interface method, when the node where the implementation corresponding to the target interface method is located is stripped from the preset linked list, the next pointer of the node where Interface Artmethod1 is located can be set to point to the node where Interface Artmethod3 is located, and the prev pointer of the node where Interface Artmethod3 is located can be set to point to the node where Interface Artmethod1 is located, thereby realizing the stripping of the node where InterfaceArtmethod2 is located from the preset linked list.

[0061] Step S230: Set the next pointer of the node stripped from the preset linked list to point to the node last pointed to by the preset linked list; set the prev pointer of the node last pointed to by the preset linked list to point to the node stripped from the preset linked list; and set the head pointer of the preset linked list to point to the node stripped from the preset linked list.

[0062] As an implementation method, in the process of inserting a node stripped from a preset linked list into the queue head of the preset linked list, the next pointer of the node stripped from the preset linked list can be set to point to the node that the preset linked list pointed to last; the prev pointer of the node that the preset linked list pointed to last is set to point to the node stripped from the preset linked list; and the head pointer of the preset linked list is set to point to the node stripped from the preset linked list. It should be noted that the above three setting steps may not be limited in execution order, and may be executed simultaneously or sequentially.

[0063] As a method, when a node stripped from a preset linked list is reinserted into the preset linked list, it can be inserted into the queue head of the preset linked list by default, that is, when a new node is inserted into the preset linked list, it can be inserted into the queue head by default.

[0064] See also Figure 5 , shows an example diagram of the structure of the preset linked list provided in the embodiment of the present application. Continuing with the above example, Figure 5As shown, when the node where Interface Artmethod2 is located is stripped from the preset linked list and then inserted into the preset linked list again, the next pointer of the node where Interface Artmethod2 is located can be set to point to the node where InterfaceArtmethod0 is located, the prev pointer of the node where Interface Artmethod0 is located can be set to point to the node where Interface Artmethod2 is located, and the head pointer of the preset linked list can be set to point to the node where InterfaceArtmethod2 is located, so that the node stripped from the preset linked list can be inserted into the queue head of the preset linked list, so that the next time the node where Interface Artmethod2 is located is accessed, it can find the hit at the fastest speed.

[0065] The interface method dispatching method provided in this embodiment searches for the implementation corresponding to the target interface method from a preset linked list during the process of implementing the interface method dispatching, and the preset linked list is constructed to avoid hash conflicts; if the implementation corresponding to the target interface method is found, the next pointer of the previous node of the node where the implementation corresponding to the target interface method is located is set to point to the next node of the node where the implementation corresponding to the target interface method is located; and the prev pointer of the next node of the node where the implementation corresponding to the target interface method is located is set to point to the previous node of the node where the implementation corresponding to the target interface method is located, so as to strip the node where the implementation corresponding to the target interface method is located from the preset linked list; the next pointer of the node stripped from the preset linked list is set to point to the node pointed to by the preset linked list last time; the prev pointer of the node pointed to by the preset linked list last time is set to point to the node stripped from the preset linked list; and the head pointer of the preset linked list is set to point to the node stripped from the preset linked list. Through the above method, it is possible to peel the node corresponding to the implementation of the target interface method to be found from the preset linked list and directly insert it into the queue head of the preset linked list, so that the next time the same interface method is accessed, it can be hit faster, thereby reducing the average search time, thereby improving the dispatch efficiency of the interface method, and then improving the operation efficiency of the virtual machine.

[0066] See also Figure 6 , shows a flowchart of an interface method dispatching method provided by another embodiment of the present application. This embodiment provides an interface method dispatching method, which can be applied to a server. Based on the above embodiments, this implementation mainly describes the implementation process of inserting a new node in a preset linked list, which can also be understood as the construction process of a preset linked list. The method includes:

[0067] Step S310: create a new node, fill in the interface method and the corresponding implementation of the interface method in the new node, and set the next pointer and prev pointer of the new node to null.

[0068] In this implementation, the preset linked list may include multiple nodes, each node may include an interface method pointer, an implementation of the interface method, a next pointer, and a prev pointer, wherein the next pointer is used to point to the next node, and the prev pointer is used to point to the previous node.

[0069] As an implementation method, in the process of transforming the IMTConflict Table into a double linked list, a new node (NEW_NODE) ​​can be created, and the interface method (Interface ArtMethod) and the corresponding implementation (Implementation ArtMethod) of the interface method can be filled in the new node, and the next pointer and prev pointer of the new node can be set to null.

[0070] Step S320: modify the next pointer of the new node to point to the node that the preset linked list last pointed to.

[0071] See also Figure 4 as well as Figure 5 , IMTConflict Table can be understood as a HEAD pointer. IMTConflictTable can be used by Conflict Artmethod, and Conflict Artmethod can be referenced by IMT. IMTConflict Table points to the head node of the double linked list.

[0072] As an implementation method, the next pointer of the new node may be modified to point to the node that the preset linked list last pointed to. For example, the next pointer of the newly created NEW_NODE node may be set to the node that the IMTConflict Table originally pointed to.

[0073] Step S330: modify the prev pointer of the node that the preset linked list last pointed to to point to the new node.

[0074] As an implementation method, the prev pointer of the node pointed to by the preset linked list last time can be modified to point to the new node. For example, the prev pointer of the node originally pointed to by the IMTConflict Table can be modified to point to the new NEW_NODE node.

[0075] Step S340: modify the head pointer of the preset linked list to point to the new node.

[0076] As an implementation method, the head pointer of the preset linked list may be modified to point to the new node. For example, continuing with the above example, the IMTConflict Table may point to the new node NEW_NODE.

[0077] In a specific application scenario, see Figure 7 , shows an example diagram of the structure of the preset linked list provided in the embodiment of the present application. Figure 7 As shown, after executing steps S310 to S340 for multiple times, multiple node insertions can be implemented, and finally a similar Figure 7 The double linked list structure shown.

[0078] The interface method dispatching method provided in this embodiment creates a new node, fills the interface method and the corresponding implementation of the interface method in the new node, and sets the next pointer and prev pointer of the new node to null; modifies the next pointer of the new node to point to the node pointed to by the preset linked list last time; modifies the prev pointer of the node pointed to by the preset linked list last time to point to the new node; modifies the head pointer of the preset linked list to point to the new node. Thus, through the above method, each newly created node can be inserted into the queue head of the preset linked list, and the preset linked list can be transformed into a double linked list structure. And the node corresponding to the implementation of the target interface method to be searched can be stripped from the preset linked list and directly inserted into the queue head of the preset linked list, so that the next time the same interface method is accessed, it can be hit faster without traversing the entire preset linked list, so as to reduce the average search time, thereby improving the dispatch efficiency of the interface method, and then improving the operation efficiency of the virtual machine.

[0079] See also Figure 8 , shows a flowchart of an interface method dispatching method provided by another embodiment of the present application. This embodiment provides an interface method dispatching method, which can be applied to a server. This implementation mainly describes the process of searching for the implementation corresponding to the target interface method from a preset linked list. The method includes:

[0080] Step S410: in the process of implementing the interface method dispatch, the access pointer is initialized to the node currently pointed to by the preset linked list, and the preset linked list is constructed to avoid hash conflicts.

[0081] As an implementation mode, during the process of implementing the interface method dispatch, the access pointer is initialized to the node currently pointed to by the preset linked list. For example, the access pointer pVisit can be initialized to the node currently pointed to by the IMTConflict Table.

[0082] Step S420: Compare the interface method of the node currently pointed to by the access pointer with the target interface method.

[0083] As an implementation method, the node currently pointed to by the preset linked list can change as the search time increases. For a currently pointed node, the interface method of the node currently pointed to by the access pointer can be compared with the target interface method, that is, pVisit->Interface Artmethod is compared with the Interface Artmethod to be searched to confirm whether the interface method of the node currently pointed to by the access pointer is the target interface method.

[0084] Step S431: If the interface method of the node currently pointed to by the access pointer is different from the target interface method, the access pointer is moved backward until the interface method of the node currently pointed to by the access pointer is the same as the target interface method, so as to find the corresponding implementation of the target interface method from the preset linked list.

[0085] As an implementation method, if the interface method of the node currently pointed to by the access pointer is different from the target interface method, the access pointer can be moved backward in sequence until the interface method of the node currently pointed to by the access pointer is the same as the target interface method.

[0086] Specifically, if the interface method of the node currently pointed to by the access pointer is different from the target interface method, the access pointer can be set to point to the next node of the node currently pointed to by the preset linked list. For example, if the interface method of the node currently pointed to by the access pointer is different from the target interface method, pVisit can be set to pVisit->Next to move the access pointer backward and iterate the process in sequence until the node where the target interface method is found or all nodes of the preset linked list are searched.

[0087] Step S432: If the interface method of the node currently pointed to by the access pointer is the same as the target interface method, the search process ends.

[0088] As an implementation method, if the interface method of the node currently pointed to by the access pointer is the same as the target interface method, it means that the implementation corresponding to the target interface method has been found, and the search process can be ended.

[0089] Optionally, if pVisit equals NULL after searching all nodes, the search process can also be terminated.

[0090] Step S441: If the implementation corresponding to the target interface method is found, the node where the implementation corresponding to the target interface method is located is stripped from the preset linked list.

[0091] The specific implementation of step S441 may refer to the relevant description of step S120 and step S220 in the aforementioned embodiment, which will not be repeated here.

[0092] Step S451: inserting the node stripped from the preset linked list into the queue head of the preset linked list.

[0093] The specific implementation of step S451 may refer to the relevant description of step S130 and step S230 in the aforementioned embodiment, which will not be repeated here.

[0094] The interface method dispatching method provided in this embodiment initializes the access pointer to the node currently pointed to by the preset linked list during the process of implementing the interface method dispatching, and the preset linked list is constructed to avoid hash conflicts; compares the interface method of the node currently pointed to by the access pointer with the target interface method; if the interface method of the node currently pointed to by the access pointer is different from the target interface method, moves the access pointer backward until the interface method of the node currently pointed to by the access pointer is the same as the target interface method, so as to find the implementation corresponding to the target interface method from the preset linked list; if the interface method of the node currently pointed to by the access pointer is the same as the target interface method, ends the search process; if the implementation corresponding to the target interface method is found, removes the node where the implementation corresponding to the target interface method is located from the preset linked list; and inserts the node removed from the preset linked list into the queue head of the preset linked list. Through the above method, it is possible to peel the node corresponding to the implementation of the target interface method to be found from the preset linked list and directly insert it into the queue head of the preset linked list, so that the next time the same interface method is accessed, it can be hit faster, thereby reducing the average search time, thereby improving the dispatch efficiency of the interface method, and then improving the operation efficiency of the virtual machine.

[0095] See also Fig. 9 , is a structural block diagram of an interface method dispatching device provided in an embodiment of the present application. This embodiment provides an interface method dispatching device 500, which can be run on a server. The device 500 includes a search module 510, a node stripping module 520 and an interface method dispatching module 530:

[0096] The search module 510 is used to search for the implementation corresponding to the target interface method from a preset linked list during the process of implementing the interface method dispatch, and the preset linked list is constructed to avoid hash conflicts.

[0097] As an implementation method, the search module 510 can be used to initialize the access pointer to the node currently pointed to by the preset linked list; compare the interface method of the node currently pointed to by the access pointer with the target interface method; if the interface method of the node currently pointed to by the access pointer is the same as the target interface method, end the search process; if the interface method of the node currently pointed to by the access pointer is different from the target interface method, move the access pointer backward until the interface method of the node currently pointed to by the access pointer is the same as the target interface method, so as to find the corresponding implementation of the target interface method from the preset linked list.

[0098] In this implementation, if the interface method of the node currently pointed to by the access pointer is different from the target interface method, the access pointer can be set to point to the next node of the node currently pointed to by the preset linked list to move the access pointer backward.

[0099] In this implementation, the target interface method includes at least one of a most recently used interface method, an interface method with the most access times, and a method with an access frequency greater than a frequency threshold.

[0100] The node stripping module 520 is used to strip the node where the implementation corresponding to the target interface method is located from the preset linked list if the implementation corresponding to the target interface method is found.

[0101] In this embodiment, the preset linked list includes a plurality of nodes, each node includes an interface method pointer, an implementation of the interface method, a next pointer and a prev pointer, the next pointer is used to point to the next node, and the prev pointer is used to point to the previous node. As an embodiment, the node stripping module 520 can be used to set the next pointer of the previous node of the node where the implementation corresponding to the target interface method is located to point to the next node of the node where the implementation corresponding to the target interface method is located if the implementation corresponding to the target interface method is found; and set the prev pointer of the next node of the node where the implementation corresponding to the target interface method is located to point to the previous node of the node where the implementation corresponding to the target interface method is located, so as to strip the node where the implementation corresponding to the target interface method is located from the preset linked list.

[0102] The interface method dispatching module 530 is used to insert the node stripped from the preset linked list into the queue head of the preset linked list.

[0103] As an embodiment, the interface method dispatch module 530 can be used to set the next pointer of the node stripped from the preset linked list to point to the node last pointed to by the preset linked list; set the prev pointer of the node last pointed to by the preset linked list to point to the node stripped from the preset linked list; and set the head pointer of the preset linked list to point to the node stripped from the preset linked list.

[0104] Optionally, the device 500 may also include a node creation module, which is used to create a new node, fill in the interface method and the corresponding implementation of the interface method in the new node, and set the next pointer and prev pointer of the new node to null. In this way, the interface method dispatching module 530 can be used to modify the next pointer of the new node to point to the node that the preset linked list pointed to last; modify the prev pointer of the node that the preset linked list pointed to last to point to the new node; modify the head pointer of the preset linked list to point to the new node.

[0105] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0106] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0107] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0108] See also Fig.10 Based on the above interface method dispatching method and device, the embodiment of the present application also provides an electronic device 100 that can execute the above interface method dispatching method. The electronic device 100 includes a memory 102 and one or more (only one is shown in the figure) processors 104 coupled to each other, and the memory 102 and the processor 104 are connected by a communication line. The memory 102 stores a program that can execute the content of the above embodiment, and the processor 104 can execute the program stored in the memory 102.

[0109] Among them, the processor 104 may include one or more processing cores. The processor 104 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 102, and calling data stored in the memory 102. Optionally, the processor 104 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 104 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 104, but may be implemented separately through a communication chip.

[0110] The memory 102 may include a random access memory (RAM) or a read-only memory (ROM). The memory 102 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 102 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the aforementioned embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.

[0111] Please refer to Fig.11 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 500 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0112] The computer-readable storage medium 500 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium 500 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 500 has storage space for program code 510 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 510 can be compressed, for example, in an appropriate form.

[0113] In summary, the embodiments of the present application provide an interface method dispatching method, device, electronic device and storage medium. The method searches for the implementation corresponding to the target interface method from a preset linked list during the process of implementing the interface method dispatching, and the preset linked list is constructed to avoid hash conflicts; if the implementation corresponding to the target interface method is found, the node where the implementation corresponding to the target interface method is located is stripped from the preset linked list; and the node stripped from the preset linked list is inserted into the queue head of the preset linked list. Thus, through the above method, the node where the implementation corresponding to the target interface method to be found is located can be stripped from the preset linked list and directly inserted into the queue head of the preset linked list, so that the next time the same interface method is accessed, it can be hit faster, thereby reducing the average search time, thereby improving the dispatch efficiency of the interface method, and then improving the operation efficiency of the virtual machine.

[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. An interface method dispatching method, characterized in that: The method comprises: In the process of implementing the interface method dispatch, searching for the implementation corresponding to the target interface method from a preset linked list, wherein the preset linked list is constructed to avoid hash conflicts; If the implementation corresponding to the target interface method is found, the node where the implementation corresponding to the target interface method is located is stripped from the preset linked list; Insert the node stripped from the preset linked list into the queue head of the preset linked list.

2. The method according to claim 1, characterized in that The preset linked list includes a plurality of nodes, each of which includes an interface method pointer, an implementation of the interface method, a next pointer, and a prev pointer, wherein the next pointer is used to point to a next node, and the prev pointer is used to point to a previous node. If the implementation corresponding to the target interface method is found, the node where the implementation corresponding to the target interface method is located is stripped from the preset linked list, including: If the implementation corresponding to the target interface method is found, the next pointer of the previous node of the node where the implementation corresponding to the target interface method is located is set to point to the next node of the node where the implementation corresponding to the target interface method is located; And the prev pointer of the next node of the node where the implementation corresponding to the target interface method is located is set to point to the previous node of the node where the implementation corresponding to the target interface method is located, so as to strip the node where the implementation corresponding to the target interface method is located from the preset linked list.

3. The method according to claim 2, characterized in that The step of inserting the node stripped from the preset linked list into the queue head of the preset linked list comprises: Setting the next pointer of the node stripped from the preset linked list to point to the node that the preset linked list last pointed to; Setting the prev pointer of the node pointed to by the preset linked list last time to point to the node stripped from the preset linked list; And the head pointer of the preset linked list is set to point to the node stripped from the preset linked list.

4. The method according to claim 1, characterized in that: The preset linked list includes a plurality of nodes, each node includes an interface method pointer, an implementation of the interface method, a next pointer and a prev pointer, the next pointer is used to point to a next node, and the prev pointer is used to point to a previous node, and the method further includes: Create a new node, fill in the interface method and the corresponding implementation of the interface method in the new node, and set the next pointer and prev pointer of the new node to null; Modify the next pointer of the new node to point to the node that the preset linked list pointed to last time; Modify the prev pointer of the node that the preset linked list last pointed to to point to the new node; The head pointer of the preset linked list is modified to point to the new node.

5. The method according to any one of claims 1 to 4, characterized in that: The searching for the implementation corresponding to the target interface method from the preset linked list includes: Initialize the access pointer to the node currently pointed to by the preset linked list; Compare the interface method of the node currently pointed to by the access pointer with the target interface method; If the interface method of the node currently pointed to by the access pointer is the same as the target interface method, the search process ends; If the interface method of the node currently pointed to by the access pointer is different from the target interface method, the access pointer is moved backward until the interface method of the node currently pointed to by the access pointer is the same as the target interface method, so as to find the corresponding implementation of the target interface method from the preset linked list.

6. The method according to claim 5, characterized in that If the interface method of the node currently pointed to by the access pointer is different from the target interface method, the access pointer is moved backward, comprising: If the interface method of the node currently pointed to by the access pointer is different from the target interface method, the access pointer is set to point to the next node of the node currently pointed to by the preset linked list, so as to move the access pointer backward.

7. The method according to claim 1, characterized in that The target interface method includes at least one of a most recently used interface method, an interface method with the most access times, and a method with an access frequency greater than a frequency threshold.

8. An interface method dispatching device, characterized in that: The device comprises: A search module, used to search for the implementation corresponding to the target interface method from a preset linked list during the process of implementing the interface method dispatch, wherein the preset linked list is constructed to avoid hash conflicts; A node stripping module, used for stripping the node where the implementation corresponding to the target interface method is located from the preset linked list if the implementation corresponding to the target interface method is found; The interface method dispatching module is used to insert the node stripped from the preset linked list into the queue head of the preset linked list.

9. An electronic device, characterized in that: comprising one or more processors and memory; One or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, wherein when the program code is executed by a processor, the method according to any one of claims 1 to 7 is executed.