WO2019227899A1 - 程序调用解耦 - Google Patents

程序调用解耦 Download PDF

Info

Publication number
WO2019227899A1
WO2019227899A1 PCT/CN2018/121032 CN2018121032W WO2019227899A1 WO 2019227899 A1 WO2019227899 A1 WO 2019227899A1 CN 2018121032 W CN2018121032 W CN 2018121032W WO 2019227899 A1 WO2019227899 A1 WO 2019227899A1
Authority
WO
WIPO (PCT)
Prior art keywords
program
data
dependency
index value
index
Prior art date
Application number
PCT/CN2018/121032
Other languages
English (en)
French (fr)
Inventor
王志宇
徐臻
姜沂
Original Assignee
北京三快在线科技有限公司
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 北京三快在线科技有限公司 filed Critical 北京三快在线科技有限公司
Priority to US17/059,981 priority Critical patent/US20210232378A1/en
Publication of WO2019227899A1 publication Critical patent/WO2019227899A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • G06F8/433Dependency analysis; Data or control flow analysis
    • 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/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • G06F8/436Semantic checking
    • G06F8/437Type checking
    • 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/445Program loading or initiating

Definitions

  • the present application relates to the field of computer technology, and in particular, to a method, a device, and an electronic device for decoupling program calls.
  • an embodiment of the present disclosure provides a program call decoupling method, wherein the program has corresponding binary data, and the binary data includes dependency data.
  • the method includes: during execution of the program, in response to a call to a first element in the program, loading the dependency data in binary data of the program to a runtime environment.
  • the dependency relationship data includes at least: an index key corresponding to the first element and an index value corresponding to the second element, the first element depends on the second element; Obtaining the index value associated with the index key corresponding to the first element from the dependency relationship data; and invoking the second element corresponding to the index value.
  • an embodiment of the present disclosure provides a program call decoupling device, wherein the program has corresponding binary data, and the binary data includes dependency data.
  • the device includes a dependency relationship data loading module, an index value determination module, and a calling module.
  • the dependency data loading module is configured to load dependency data in binary data of the program into a runtime environment in response to a call to a first element in the program during execution of the program, wherein,
  • the dependency relationship data includes at least an index key corresponding to the first element and an index value corresponding to the second element, and the first element depends on the second element.
  • the index value determination module is configured to obtain, through the runtime environment, an index value associated with an index key corresponding to the first element from the dependency data loaded by the dependency data loading module.
  • the calling module is configured to call the second element corresponding to the index value determined by the index value determining module.
  • an embodiment of the present disclosure further provides an electronic device including a memory and a processor.
  • the memory stores a computer program that can be run on a processor, and when the processor executes the computer program, the program call decoupling method according to the embodiment of the present disclosure is implemented.
  • an embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored.
  • the program is executed by a processor, the method of the embodiment of the present disclosure calls a decoupling method.
  • the method for decoupling a program call disclosed in this embodiment is to write dependency data during program running into binary data of the program in advance, and load the dependency data only when it is necessary to call an element with a dependency, thereby effectively shortening
  • the program startup time is effectively improved.
  • FIG. 1 is a flowchart of a program call decoupling method according to the first embodiment of the present disclosure
  • FIG. 2 is a flowchart of a program call decoupling method according to a second embodiment of the present disclosure
  • FIG. 3 is a schematic structural diagram of a program call decoupling device according to a third embodiment of the present disclosure.
  • FIG. 4 is another schematic structural diagram of a program call decoupling device according to a third embodiment of the present disclosure.
  • FIG. 5 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present disclosure.
  • a program call decoupling method disclosed in this embodiment is shown in FIG. 1. The method includes steps 110 to 130.
  • Step 110 During the execution of the program, in response to a call to a first element in the program, load dependency data in binary data of the program to a runtime environment.
  • the dependency relationship data includes at least: an index key corresponding to the first element and an index value corresponding to the second element, wherein the second element is an element that the first element depends on.
  • the program described in the embodiment of the present disclosure has corresponding binary data, and the binary data includes dependency data.
  • the first element and the second element described in the embodiment of the present disclosure are used to represent two elements that are different from each other.
  • Each of the elements may be: a function, a class, a method, a character, a character string, and the like that are required during the running process of the program.
  • Accessed elements where the first element refers to the element that needs to depend on other elements to execute, and the second element refers to the dependent element. For example, when function A needs to depend on string B during execution, A is the first element and B is the second element.
  • dependency data between elements called when the current program is run is written in advance.
  • the dependency relationship data is stored in the form of key-value pairs in a preset format.
  • the data corresponding to the first element in the dependency relationship data is used as the index key, and the data corresponding to the second element that the first element depends on is used as the index value.
  • the dependency relationship data may further include type information of the index value.
  • the runtime environment of the current program loads the dependency data in the binary data of the program to the runtime environment by calling the method of reading the binary segment.
  • Step 120 Obtain an index value associated with an index key corresponding to the first element from the dependency relationship data through the runtime environment.
  • the dependency data is parsed according to a preset format to determine that the first element of the dependency relationship that is called during the execution of the program corresponds to An index key of one or more index values corresponding to each of the index keys.
  • Step 130 Call the second element corresponding to the index value.
  • the runtime environment of the current program further analyzes the dependency relationship data according to the index value, obtains a second element corresponding to the index value, and calls the second element.
  • the dependency relationship data may further include a second element type corresponding to the index value, and the runtime environment further analyzes the dependency relationship data according to the index value and the second element type.
  • the method for decoupling a program call according to the embodiment of the present disclosure, by writing the dependency data at the time of program running into the binary data of the program in advance, the dependency data is only loaded when the element with the dependency relationship is called, thereby effectively shortening The program startup time is effectively improved.
  • a method for decoupling a program call disclosed in this embodiment includes steps 210 to 250.
  • Step 210 Generate dependency relationship data that associates the index key with the index value corresponding to the second element according to the index key corresponding to the first element in the program and the second element that the first element depends on.
  • the method in response to a call to a first element in the program, before loading dependency data in binary data of the program to a runtime environment, the method further includes: An index key corresponding to the element and a second element that the first element depends on, to generate dependency data that associates the index key with an index value corresponding to the second element; and write the dependency data to all The binary data generated after the program is compiled.
  • the first element and the second element in the embodiment of the present disclosure are used to represent two elements that are different from each other, and each of the elements may be: a function, a class, a method, a character, a character string, or the like that needs to be called during a program running process.
  • the first element refers to an element that depends on other elements to execute, and the second element refers to an element that is dependent on.
  • the method of generating dependency data is different for different element types. Generating, according to an index key corresponding to a first element in the program and a second element that the first element depends on, dependency data that associates the index key with an index value corresponding to the second element, including at least one of the following Item: if the second element is a function, use the pointer of the second element as the index value of the second element to generate dependency data that associates the index key with the index value; if the second element is Character string, using the second element itself as the index value of the second element to generate dependency data that associates the index key with the index value; if the second element is a class, the first element The name of the two elements is used as the index value of the second element to generate dependency data that associates the index key with the index value; if the second element is an Objective-C method, the character obtained by the system macro The string is used as the index value of the second element, and dependency relationship data that associates the index key with the index value is generated.
  • the second element being relied on is a C language function.
  • the dependency relationship data includes at least an index key and an index value.
  • the dependency relationship data may further include information such as the type of the second element corresponding to the index value and whether it is an array. Therefore, for example, the dependency data can be defined as having the following structure:
  • the dependency relationship data is composed of two parts, the first part is a data header, and the second part is a data body.
  • key indicates the index key corresponding to the first element
  • type indicates the type of the second element
  • isArray indicates whether the second element is an array.
  • value represents the index value corresponding to the second element.
  • each element in the above data structure is determined according to a predetermined agreement and a compiled file of the current program.
  • the values of the key and the second element are determined according to the dependency convention; and the value can be determined by executing the compilation instruction according to the binary data obtained after the program is compiled.
  • the pointer of the second element is used as the index value of the second element, that is, the value of value is the pointer of the second element, which can be obtained from the compiled binary data. .
  • dependency relationship data that associates the index key with the index value is generated.
  • the value of type in the generated dependency data is used to indicate that the type of the second element corresponding to the index value is a function.
  • the second element to be relied upon is the Objective-C method.
  • the second element is an Objective-C method
  • a string consisting of the name, class name, and method type of the second element that can be obtained through the system macro __func__, and then using the string as the second element
  • the index value of the element is generated.
  • the value of type in the generated dependency data is used to indicate that the second element type corresponding to the index value is the ObjectC method.
  • the second element being relied on is a string.
  • the character string is directly used as the index value of the second element; and then, dependency data that associates the index key with the index value is generated.
  • dependency data that associates the index key with the index value is generated.
  • the value of type in the generated dependency data is used to indicate that the second element type corresponding to the index value is a character string.
  • the second element that is dependent is the class.
  • the second element When the second element is a class, directly use the name of the class as the index value of the second element; then, generate dependency data that associates the index key with the index value.
  • the structure of the dependency data is as described above, the value of type in the constructed dependency data is used to indicate that the second element type corresponding to the index value is a class.
  • the decoupling method disclosed in this application is not limited to the dependencies of the following types of elements.
  • the following types are used as examples for illustration.
  • non-array type dependency data The method for determining non-array type dependency data is described above. Assuming that the structure of the dependency data is as described above, the value of isArray in the constructed dependency data is used to indicate that the second element is a non-array. In other embodiments, one index key may also correspond to multiple index values, and the multiple index values are stored in the form of an array. In specific implementation, assuming that the structure of the dependency data is as described above, the value of isArray in the generated dependency data is used to indicate that the second element is an array.
  • Step 220 Write the dependency data into binary data generated after the program is compiled.
  • step 220 writes the dependency data into binary data generated after the program is compiled, including: calling a write method of a binary segment through a compilation instruction, and writing the dependency data into the binary data.
  • the binary data generated after the program is compiled.
  • a write macro _KLN_DATA_DEFINE (), _KLN_DATA_DEFINE () is defined in advance. After receiving the write information, use __attribute __ (section ()) to write.
  • the macro definition is as follows:
  • KLN_DATA KLN_UNIQUE_IDENTIFIER (KLN_DATA) ⁇ HEADER, VALUE ⁇ .
  • KLN_SEGMENT_SECTION is the data segment written by the dependency data KLN_DATA
  • HEADER represents the data header of the dependency data
  • VALUE represents the data body of the dependency data.
  • the data segment is generally divided into __DATA segment (Segment) and __TEXT segment, and there can be many Sections under each segment.
  • This disclosure writes dependency data to a preset Section in the __DATA section.
  • Step 230 During execution of the program, in response to a call to a first element in the program, load dependency data in binary data of the program to a runtime environment.
  • step 230 during the execution of the program, in response to the call to the first element in the program, loading the dependency data in the binary data of the program into the runtime environment includes: obtaining the calling program The operation of the first element; in response to the operation, obtaining the dependency data in the binary data of the program through a preset binary segment reading function.
  • the first element when calling an element that depends on other elements to execute, such as when the current program runs to calling the first element, because the first element depends on the second element to execute, the first element will pass
  • the index key call queries the runtime environment of the current program.
  • the runtime environment responds to the query operation of the first element, and obtains dependency data in binary data of the program through a preset binary segment reading function.
  • the runtime environment may read the data of the data segment in which the dependency data is located into the memory by calling a binary segment reading function provided in the macho library.
  • the runtime environment after the runtime environment acquires the operation of the first element in the calling program, it can also load all the dependency data corresponding to all the first elements to the index keys of all the first elements that depend on other elements in the current program. In memory.
  • step 240 an index value associated with an index key corresponding to the first element is obtained from the dependency data through the runtime environment.
  • the dependency relationship data includes at least: an index key corresponding to the first element and an index value corresponding to the second element, and the first element depends on the second element.
  • the runtime environment parses the dependency data according to the data format of the dependency data to determine the existence of dependencies called during the execution of the program The index key corresponding to the first element of the relationship, the index value corresponding to the index key, the second element type corresponding to the index value, and whether the second element corresponding to the index value is one or more of information such as an array item.
  • an index value corresponding to the index key is queried.
  • the runtime environment queries the dependency relationship data where the index key is located, and determines the index value in the dependency relationship data.
  • Step 250 Call the second element corresponding to the index value.
  • the dependency relationship data where the index key is located further includes a second element type corresponding to the index value.
  • the runtime environment parses the index value according to a preset index value declaration corresponding to the second element type, and determines a second element corresponding to the index value. Then, the second element corresponding to the index value is called. For example, when the dependency data shows that the second element type corresponding to the index value is a function, take out the content of the index value (that is, value), force it to a function type defined by the runtime environment, and jump to the function pointer To execute the function corresponding to the function pointer.
  • the string written during compilation is parsed to include the method type, class name, and method name string to obtain the class name string and method.
  • Name string use the Objective-C runtime environment, find the corresponding method of the corresponding class, combine it into a predefined object and return it to the first element, and the first element can get the relevant information of the method through the object to execute all Mentioned method.
  • the second element type corresponding to the index value of the dependency data display is a string
  • the index value written at compile time is a pointer to the string
  • the runtime environment can find the string and encode it according to the pointer of the string.
  • the content of the content is decoded by using the corresponding encoding method to obtain the written string information, and then the string information is returned to the first element.
  • the dependency data shows that the second element type corresponding to the index value is an Objective-C class
  • the index value written at compile time is a string containing the class name
  • the Objective-C runtime environment is used to characterize After the string is parsed, the class corresponding to the string is returned to the first element.
  • the first element is function A in the current program
  • the second element is function B.
  • Function B is in a dynamic library. Function A needs to call function B during execution, that is, function A depends on function B. Function A and function B negotiated to get the index key corresponding to function A as keyA.
  • the runtime environment loads the dependency data corresponding to function A written to the preset binary segment into memory by calling the binary segment read function, and then loads the data into the memory in accordance with the data format of the predefined dependency data.
  • the dependency data in the memory is parsed to determine an index key included in the dependency data, an index value corresponding to the index key, a second element type corresponding to the index value, and whether the index value is an identifier of an array.
  • index values corresponding to the index keys keyA and keyA will be obtained after parsing.
  • valueB and typeB indicate the function type corresponding to the index value
  • isArray 0 indicates that valueB is not an array.
  • the runtime environment then calls function B based on the index value.
  • the iOS platform is used as an example to describe the program call decoupling method.
  • the program call decoupling method of the present disclosure is also used in other platforms, such as the Android platform and the Windows platform.
  • the compilation instructions that are called when writing and reading on different platforms are roughly the same.
  • the compilation instructions of the Clang compiler are used by iOS, and the compilation instructions of GNU GCC or G ++ by other platforms can achieve the same effect.
  • the program in the embodiment of the present disclosure calls a decoupling method, and generates an index corresponding to the index key and the second element according to an index key corresponding to the first element in the program and a second element that the first element depends on.
  • Value-associated dependency data and then write the dependency data into binary data generated after the program is compiled, and during program execution, in response to a call to a first element in the program,
  • the dependency data in the binary data of the program is loaded into a runtime environment, and an index value associated with an index key corresponding to the first element is obtained from the dependency data through the runtime environment, and the index value is called The corresponding second element. Because the dependency data when the program is run is written into the binary data of the program in advance, the dependency data is only loaded when it is necessary to call the elements that have dependencies, thereby effectively reducing the startup time of the program and effectively improving it. Program startup efficiency.
  • + load performs an indiscriminate full load when the program starts, and many dependencies that are not on the critical path of the startup are also loaded at this time, causing unnecessary waste.
  • the disclosed program decoupling method makes full use of data writing during compilation, and corresponds to the method and data to be executed with the index key. When the program is executed until the corresponding index key needs to be loaded, the corresponding function is executed or the corresponding function is returned. Data to avoid unnecessary waste and greatly save the startup time of the program.
  • the program calling decoupling method of the present disclosure is used to decouple the 2000 functions. Compared with the + load method, this method saves 80% of the execution time of + load. .
  • + load performs registration of dependent or decoupled functions at startup, and can only achieve function decoupling, and this disclosure can not only achieve decoupling at the time of function call, but also decoupling of methods, classes, and character data, There are more application scenarios.
  • a program call decoupling processing device disclosed in this embodiment is shown in FIG. 3, wherein the program has corresponding binary data, the binary data includes dependency data, and the device includes: dependency data
  • the dependency data loading module 310 is configured to load dependency data in binary data of the program into a runtime environment in response to a call to a first element in the program during execution of the program.
  • the dependency relationship data includes at least: an index key corresponding to the first element and an index value corresponding to the second element, and the first element depends on the second element.
  • the index value determination module 320 is configured to obtain an index value associated with an index key corresponding to the first element from the dependency data loaded by the dependency data loading module 310 through the runtime environment.
  • the calling module 330 is configured to call the second element corresponding to the index value determined by the index value determining module 320.
  • the apparatus further includes a dependency relationship data determining module 340 and a dependency relationship data writing module 350.
  • the dependency relationship data determining module 340 is configured to generate an association between the index key and the index value corresponding to the second element according to the index key corresponding to the first element in the program and the second element dependent on the first element.
  • the dependency data writing module 350 is configured to write the dependency data determined by the dependency data determination module 340 into binary data generated after the program is compiled.
  • the dependency relationship data writing module 350 is further configured to: call the writing method of the binary segment through a compilation instruction, and write the dependency relationship data into the binary data generated after the program is compiled.
  • the dependency relationship data further includes the type of the second element.
  • the dependency relationship determination module 340 includes at least one of the following sub-modules: a function dependency determination sub-module 3401, a character string The dependency determination submodule 3402, the class dependency determination submodule 3403, and the method dependency determination submodule 3404.
  • the function dependency determining submodule 3401 is configured to determine a pointer of the second element as an index value of the second element if the second element is a function.
  • the string dependency determination submodule 3402 is configured to determine the second element as an index value of the second element if the second element is a character string.
  • the class dependency determining submodule 3403 is configured to determine a name of the second element as an index value of the second element if the second element is a class.
  • the method dependency determining submodule 3404 is used to determine a character string obtained through a system macro as an index value of the second element if the second element is an Objective-C method.
  • the apparatus disclosed in this embodiment is used to execute the steps of the methods described in Embodiments 1 and 2.
  • the modules of the apparatus refer to the corresponding steps in Embodiments 1 and 2, and will not be repeated here. To repeat.
  • the dependency relationship data determination module According to an index key corresponding to a first element in the program and a second element that the first element depends on, the dependency relationship data determination module generates a combination of the index key and the The dependency relationship data associated with the index value corresponding to the second element is described, and then, the dependency relationship data writing module writes the dependency relationship data into binary data generated after the program is compiled.
  • the dependency data loading module loads the dependency data in the binary data of the program to the runtime environment in response to the call to the first element in the program, and the index value determination module passes the running The time environment obtains an index value associated with an index key corresponding to the first element from the dependency relationship data, and the calling module calls the second element corresponding to the index value. Because the dependency data when the program is run is written into the binary data of the program in advance, the dependency data is only loaded when it is necessary to call the elements that have dependencies, thereby effectively reducing the startup time of the program and effectively improving it. Program startup efficiency.
  • the program call decoupling device of the present disclosure makes full use of data writing during compilation, and corresponds to the method and data to be executed with the index key. When the program is executed until the corresponding index key needs to be loaded, the corresponding function is executed or the corresponding return Data to avoid unnecessary waste and greatly save the startup time of the program.
  • the present disclosure also provides an electronic device 50 including a memory 501 and a processor 502.
  • the memory 501 stores a computer program that can be run on the processor 502.
  • the processor 502 executes the computer program, the program call decoupling method according to the first and second embodiments of the present disclosure is implemented.
  • the electronic device may be a PC, a mobile terminal, a personal digital assistant, a tablet computer, or the like.
  • the present disclosure also provides a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed by a processor, the method for decoupling a program call according to Embodiments 1 and 2 of the present disclosure is implemented.
  • the embodiments can be implemented by means of software plus a necessary universal hardware platform, and of course, they can also be implemented by hardware.
  • the above-mentioned technical solution essentially or part that contributes to the existing technology can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic A disc, an optical disc, and the like include instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or certain parts of the embodiments.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

一种程序调用解耦处理方法。该程序调用解耦方法包括:在程序的执行过程中,响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的依赖关系数据加载至运行时环境(110,230),所述依赖关系数据中至少包括所述第一元素对应的索引键和第二元素对应的索引值,所述第一元素依赖所述第二元素;通过所述运行时环境从所述依赖关系数据中获取与所述第一元素对应的索引键关联的索引值(120,240),并调用所述索引值对应的第二元素(130,250)。

Description

程序调用解耦
相关申请交叉引用
本申请要求于2018年5月31日提交的、申请号为201810550126.4、发明名称为“一种程序调用解耦方法、装置,电子设备及存储介质”的中国专利申请的优先权,该申请的全文以引用的方式并入本文中。
技术领域
本申请涉及计算机技术领域,特别是涉及一种程序调用解耦方法、装置,电子设备。
背景技术
软件开发过程中,当软件模块或函数之间存在依赖关系时,这些软件模块或函数之间就必然存在耦合。然而,理论上的绝对零耦合是做不到的,但可以通过一些现有的方法将耦合度降至最低。+load方法常常被作为解耦信息注入的首选,引入+load可以帮助处理依赖反转等解耦的问题。但与此同时,+load在程序启动时会导致动态加载器提前加载依赖关系对应的类,从而会延长程序启动时间。
发明内容
第一方面,本公开实施例提供了一种程序调用解耦方法,其中,所述程序具有对应的二进制数据,所述二进制数据中包括依赖关系数据。所述方法包括:在所述程序的执行过程中,响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的所述依赖关系数据加载至运行时环境。其中,所述依赖关系数据中至少包括:所述第一元素对应的索引键、第二元素对应的索引值,所述第一元素依赖所述第二元素;通过所述运行时环境从所述依赖关系数据中获取与所述第一元素对应的索引键关联的索引值;以及调用所述索引值对应的所述第二元素。
第二方面,本公开实施例提供了一种程序调用解耦装置,其中,所述程序具有对应的二进制数据,所述二进制数据中包括依赖关系数据。所述装置包括:依赖关系数据加载模块、索引值确定模块和调用模块。
依赖关系数据加载模块用于,在所述程序的执行过程中,响应于对所述程序中第一 元素的调用,将所述程序的二进制数据中的依赖关系数据加载至运行时环境,其中,所述依赖关系数据中至少包括所述第一元素对应的索引键、第二元素对应的索引值,所述第一元素依赖所述第二元素。
索引值确定模块用于,通过所述运行时环境从所述依赖关系数据加载模块加载的所述依赖关系数据中获取与所述第一元素对应的索引键关联的索引值。
调用模块用于,调用所述索引值确定模块确定的索引值对应的所述第二元素。
第三方面,本公开实施例还提供了一种电子设备,包括存储器、处理器。该存储器存储有可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现本公开实施例所述的程序调用解耦方法。
第四方面,本公开实施例提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时本公开实施例的程序调用解耦方法。
本实施例公开的程序调用解耦方法,通过将程序运行时的依赖关系数据预先写入到程序的二进制数据中,当需要调用存在依赖关系的元素时,才加载依赖关系数据,从而有效地缩短了程序的启动时间,并有效地提升了程序的启动效率。
附图说明
为了更清楚地说明本公开实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本公开的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本公开实施例一的程序调用解耦方法流程图;
图2是本公开实施例二的程序调用解耦方法流程图;
图3是本公开实施例三的程序调用解耦装置的结构示意图;
图4是本公开实施例三的程序调用解耦装置的另一结构示意图;
图5是本公开实施例四的电子设备的结构示意图。
具体实施方式
下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整 地描述,显然,所描述的实施例是本公开一部分实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。
实施例一
本实施例公开的一种程序调用解耦方法,如图1所示,该方法包括步骤110至步骤130。
步骤110,在程序的执行过程中,响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的依赖关系数据加载至运行时环境。
在步骤110中,所述依赖关系数据至少包括:所述第一元素对应的索引键、第二元素对应的索引值,其中所述第二元素为所述第一元素依赖的元素。
本公开实施例中所述的程序具有对应的二进制数据,所述二进制数据中包括依赖关系数据。本公开实施例中所述的第一元素和第二元素用于表示互不相同的两个元素,每个所述元素可以为:函数、类、方法、字符、字符串等程序运行过程中需要访问的元素,其中,第一元素指需要依赖其他元素才能执行的元素,第二元素指被依赖的元素。例如,函数A在执行过程中需要依赖字符串B,则A为第一元素,B为第二元素。
具体实施时,在当前程序的二进制数据中,例如在编译得到的当前程序的可执行文件中,预先写入了当前程序运行时调用的元素之间的依赖关系数据。通常,所述依赖关系数据以键值对的形式按照预设格式存储。其中,所述依赖关系数据中所述第一元素对应的数据作为索引键,该第一元素依赖的第二元素对应的数据作为索引值。具体实施时,所述依赖关系数据中还可以包括索引值的类型信息。
在程序的执行过程中,当需要调用第一元素时,当前程序的运行时环境通过调用读取二进制段的方法,将所述程序的二进制数据中的依赖关系数据加载至运行时环境。
步骤120,通过所述运行时环境从所述依赖关系数据中获取与所述第一元素对应的索引键关联的索引值。
所述运行时环境读取到二进制数据中的依赖关系数据之后,会根据预设格式,对所述依赖关系数据进行解析,确定所述程序的执行过程中调用的存在依赖关系的第一元素对应的索引键、每个所述索引键对应的一个或多个索引值。
步骤130,调用所述索引值对应的所述第二元素。
具体实施时,当前程序的运行时环境根据所述索引值进一步解析所述依赖关系数据,得到所述索引值对应的第二元素,并调用所述第二元素。具体实施时,所述依赖关系数据中还可包括所述索引值对应的第二元素类型,所述运行时环境根据所述索引值和所述第二元素类型进一步解析所述依赖关系数据。
本公开实施例的程序调用解耦方法,通过将程序运行时的依赖关系数据预先写入到程序的二进制数据中,当需要调用存在依赖关系的元素时,才加载依赖关系数据,从而有效地缩短了程序的启动时间,并有效地提升了程序的启动效率。
实施例二
本实施例公开的一种程序调用解耦方法,如图2所示,该方法包括:步骤210至步骤250。
步骤210,根据程序中第一元素对应的索引键、所述第一元素依赖的第二元素,生成将所述索引键和所述第二元素对应的索引值关联的依赖关系数据。
具体实施时,在程序执行过程中,响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的依赖关系数据加载至运行时环境之前,还包括:根据程序中第一元素对应的索引键、所述第一元素依赖的第二元素,生成将所述索引键和所述第二元素对应的索引值关联的依赖关系数据;并将所述依赖关系数据写入到所述程序编译后生成的二进制数据中。
本公开实施例中的第一元素和第二元素用于表示互不相同的两个元素,每个所述元素可以为:函数、类、方法、字符、字符串等程序运行过程中需要调用的元素,其中,第一元素指需要依赖其他元素才能执行的元素,第二元素指被依赖的元素。
具体实施时,对于不同的元素类型,生成依赖关系数据的方法有所不同。所述根据程序中第一元素对应的索引键和所述第一元素依赖的第二元素,生成将所述索引键和所述第二元素对应的索引值关联的依赖关系数据,包括以下至少一项:若第二元素为函数,则将所述第二元素的指针作为所述第二元素的索引值,生成将所述索引键和所述索引值关联的依赖关系数据;若第二元素为字符串,则将所述第二元素自身作为所述第二元素的索引值,生成将所述索引键和所述索引值关联的依赖关系数据;若第二元素为类,则将所述第二元素的名称作为所述第二元素的索引值,生成将所述索引键和所述索引值关联的依赖关系数据;若第二元素为Objective-C的方法,则将通过***宏获得的字符串作为所述第二元素的索引值,生成将所述索引键和所述索引值关联的依赖关系数据。
下面,分别介绍对于不同的元素类型,生成依赖关系数据的具体方案。第一种,被依赖的第二元素为C语言的函数。
首先定义依赖关系数据的数据格式。具体实施时,所述依赖关系数据至少包括索引键和索引值。在一实施例中,所述依赖关系数据还可以包括:索引值对应的第二元素的类型、是否为数组等信息。因此,例如可以将依赖关系数据定义为具有如下结构:
Figure PCTCN2018121032-appb-000001
上述数据结构定义中,所述依赖关系数据由两部分组成,第一部分为数据头,第二部分为数据体。数据头中,key表示第一元素对应的索引键,type表示第二元素的类型,isArray表示第二元素是否为数组。数据体中,value表示第二元素对应的索引值。
上述数据结构中的各元素的取值,根据预先约定和当前程序的编译文件确定。例如,key和第二元素的取值根据依赖约定确定;而value可以通过执行编译指令,根据程序编译后得到的二进制数据确定。
当第二元素为函数时,将所述第二元素的指针作为第二元素的索引值,也即,value的取值为所述第二元素的指针,这可以从编译得到的二进制数据中获得。然后,生成将所述索引键和所述索引值关联的依赖关系数据。所生成的依赖关系数据中的type的取值用于指示所述索引值对应的第二元素类型为函数。
第二种,被依赖的第二元素为Objective-C的方法。
当第二元素为Objective-C的方法时,可以通过***宏__func__获得的所述第二元素的名称、类名和方法类型构成的字符串,然后,将所述字符串作为所述第二元素的索引值;最后,生成将索引键和所述索引值关联的依赖关系数据。具体实施时,假设依赖关系数据的结构如前所述,则所生成的依赖关系数据中的type的取值用于指示所述索引值对应的第二元素类型为ObjectC方法。
第三种,被依赖的第二元素为字符串。
当第二元素为字符串时,直接将所述字符串作为所述第二元素的索引值;然后,生 成将所述索引键和所述索引值关联的依赖关系数据。具体实施时,假设依赖关系数据的结构如前所述,则所生成的依赖关系数据中的type的取值用于指示所述索引值对应的第二元素类型为字符串。
第四种,被依赖的第二元素为类。
当第二元素为类时,直接将类的名称作为所述第二元素的索引值;然后,生成将所述索引键和所述索引值关联的依赖关系数据。具体实施时,假设依赖关系数据的结构如前所述,则构成的依赖关系数据中的type的取值用于指示所述索引值对应的第二元素类型为类。
本申请公开的解耦方法不限于以下几种类型元素的依赖关系,本实施例中仅以以下几种类型进行举例说明。
以上介绍了非数组类型的依赖关系数据确定方法,假设依赖关系数据的结构如前所述,则构成的依赖关系数据中的isArray的取值用于指示第二元素为非数组。在其他实施例中,一个索引键还可以对应多个索引值,多个索引值以数组的形式存储。具体实施时,假设依赖关系数据的结构如前所述,则所生成的依赖关系数据中的isArray的取值用于指示第二元素为数组。
步骤220,将所述依赖关系数据写入到所述程序编译后生成的二进制数据中。
具体实施时,步骤220将所述依赖关系数据写入到所述程序编译后生成的二进制数据中,包括:通过编译指令调用二进制段的写入方法,将所述依赖关系数据写入到所述程序编译后生成的二进制数据中。例如,预先定义一个写入宏_KLN_DATA_DEFINE(),_KLN_DATA_DEFINE(),在接收到写入信息后,使用__attribute__(section())进行写入,宏定义如下所示:
#define_KLN_DATA_DEFINE(HEADER,VALUE)\
   __attribute__((used,section(KLN_SEGMENT_SECTION)))static const
KLN_DATA KLN_UNIQUE_IDENTIFIER=(KLN_DATA){HEADER,VALUE}。
上述宏定义中,KLN_SEGMENT_SECTION为依赖关系数据KLN_DATA写入的数据段,HEADER表示依赖关系数据的数据头,VALUE表示依赖关系数据的数据体。
具体实施时,所述数据段通常分为__DATA段(Segment)和__TEXT段,每个段下面可以有很多的Section。本公开将依赖关系数据写到__DATA段中的预设Section。
步骤230,在程序的执行过程中,响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的依赖关系数据加载至运行时环境。
具体实施时,步骤230在程序的执行过程中,响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的依赖关系数据加载至运行时环境,包括:获取调用程序中第一元素的操作;响应于所述操作,通过预设的二进制段读取函数,获取所述程序的二进制数据中的依赖关系数据。
具体实施时,当前程序在运行过程中,当调用到依赖其他元素执行的元素时,如当前程序运行到调用第一元素,由于所述第一元素依赖第二元素执行,因此第一元素会通过索引键调用查询当前程序的运行时环境。
所述运行时环境响应所述第一元素的查询操作,通过预设的二进制段读取函数,获取所述程序的二进制数据中的依赖关系数据。以iOS平台为例,运行时环境可以通过调用macho库中提供的二进制段读取函数,将所述依赖关系数据所在的数据段的数据读取到内存中。
具体实施时,运行时环境在获取调用程序中第一元素的操作之后,还可以根据当前程序中依赖其他元素的所有第一元素的索引键,将所有第一元素对应的依赖关系数据全部加载到内存中。
步骤240,通过所述运行时环境从所述依赖关系数据中获取与所述第一元素对应的索引键关联的索引值。
本公开的实施例中,所述依赖关系数据中至少包括:所述第一元素对应的索引键、第二元素对应的索引值,所述第一元素依赖所述第二元素。在所述运行时环境将依赖关系数据加载到内存中之后,所述运行时环境按照依赖关系数据的数据格式,对所述依赖关系数据进行解析,确定所述程序的执行过程中调用的存在依赖关系的第一元素对应的索引键、所述索引键对应的索引值、所述索引值对应的第二元素类型、所述索引值对应的第二元素是否为数组等信息中的一项或多项。然后,在解析得到的依赖关系数据中,查询所述索引键对应的索引值。具体实施时,运行时环境查询所述索引键所在的依赖关系数据,并确定该依赖关系数据中的索引值。
步骤250,调用所述索引值对应的所述第二元素。
进一步的,所述索引键所在的依赖关系数据还包括所述索引值对应的第二元素类型。所述运行时环境根据第二元素类型对应的预设索引值声明,对所述索引值进行解析,确 定所述索引值对应的第二元素。然后,调用所述索引值对应的所述第二元素。例如,当依赖关系数据显示索引值对应的第二元素类型为函数时,取出索引值(即value)中的内容,将其强转成运行时环境定义的函数类型,并跳转至该函数指针,执行该函数指针对应的函数。再例如,当依赖关系数据显示索引值对应的第二元素类型为Objective-C的方法时,解析编译时写入的包括:方法类型、类名和方法名的字符串从而得到类名字符串和方法名字符串,使用Objective-C运行时环境,查到对应类的对应方法,组合成预定义的对象返回给第一元素,第一元素方可以通过所述对象得到方法的相关信息,从而执行所述方法。又例如,当依赖关系数据显示索引值对应的第二元素类型为字符串时,编译时写入的索引值为字符串的指针,运行时环境根据字符串的指针,可以找到字符串进行编码后的内容,使用对应的编码方式对其解码,可以得到写入的字符串信息,然后,将该字符串信息返回给第一元素。再例如,当依赖关系数据显示索引值对应的第二元素类型为Objective-C的类时,编译时写入的索引值为一个含有类名称的字符串,使用Objective-C的运行时环境对字符串进行解析后,将字符串对应的类返回给第一元素。
例如,第一元素为当前程序中的函数A,第二元素为函数B,函数B在动态库中,函数A在执行过程中需要调用函数B,即函数A依赖函数B。函数A和函数B协商得到了函数A对应的索引键为keyA。当程序调用函数A时,运行时环境通过调用二进制段读函数将写入预设二进制段的函数A对应的依赖关系数据加载到内存,然后,按照预定义的依赖关系数据的数据格式对加载到内存的依赖关系数据进行解析,确定所述依赖关系数据包括的索引键、与所述索引键对应的索引值、所述索引值对应的第二元素类型以及所述索引值是否为数组的标识。本例中,解析后将得到索引键keyA、keyA对应的索引值,例如,valueB、typeB表示索引值对应函数类型、isArray=0表示valueB非数组。之后,运行时环境基于该索引值调用函数B。
本实施例中,以iOS平台为例说明了程序调用解耦方法,本公开的程序调用解耦方法还用于其他平台,例如,安卓平台、windows平台。不同平台写入和读取时调用的编译指令大致相同,例如,iOS使用Clang编译器的编译指令,其他平台使用GNU的GCC或者G++等编译器的编译指令,可以达到相同的效果。
本公开实施例的程序调用解耦方法,根据所述程序中第一元素对应的索引键、所述第一元素依赖的第二元素,生成将所述索引键和所述第二元素对应的索引值关联的依赖关系数据,然后,将所述依赖关系数据写入到所述程序编译后生成的二进制数据中,在程序执行过程中,响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的 依赖关系数据加载至运行时环境,通过所述运行时环境从所述依赖关系数据获取与所述第一元素对应的索引键关联的索引值,并调用所述索引值对应的所述第二元素。由于将程序运行时的依赖关系数据预先写入到程序的二进制数据中,当需要调用存在依赖关系的元素时,才加载依赖关系数据,从而有效地缩短了程序的启动时间,并有效地提升了程序的启动效率。
+load在程序启动的时候执行无差别的完全加载,很多不在启动关键路径上面的依赖也会在这个时候被执行加载,造成了不必要的浪费。本公开的程序调用解耦方法充分利用了编译时的数据写入,将需要执行的方法和数据与索引键进行对应,程序执行到需要加载对应索引键的时候,再执行相应的函数或者返回相应的数据,避免了不必要的浪费,大大节省了程序的启动时间。以需要解耦2000个函数举例,采用本公开的程序调用解耦方法对所述2000个函数进行解耦,与采用+load方法相比,本方法节省的执行时间为+load执行时间的80%。
并且,+load在启动时进行依赖或解耦函数的注册,且只能实现函数解耦,而本公开不仅可以实现函数调用时的解耦,还可以实现方法、类和字符数据的解耦,应用场景更多。
实施例三
本实施例公开的一种程序调用解耦处理装置,如图3所示,其中,所述程序具有对应的二进制数据,所述二进制数据中包括依赖关系数据,所述的装置包括:依赖关系数据加载模块310、索引值确定模块320和调用模块330。
依赖关系数据加载模块310用于,在程序的执行过程中,响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的依赖关系数据加载至运行时环境,其中,所述依赖关系数据中至少包括:所述第一元素对应的索引键、第二元素对应的索引值,所述第一元素依赖所述第二元素。
索引值确定模块320用于,通过所述运行时环境从依赖关系数据加载模块310加载的依赖关系数据中获取与所述第一元素对应的索引键关联的索引值。
调用模块330用于调用索引值确定模块320确定的索引值对应的所述第二元素。
在一实施例中,如图4所示,所述装置还包括依赖关系数据确定模块340和依赖关系数据写入模块350。依赖关系数据确定模块340用于,根据所述程序中第一元素对应的索引键、所述第一元素依赖的第二元素,生成将所述索引键和所述第二元素对应的索 引值关联的依赖关系数据。依赖关系数据写入模块350用于,将依赖关系数据确定模块340确定的依赖关系数据写入到所述程序编译后生成的二进制数据中。
在一实施例中,依赖关系数据写入模块350进一步用于:通过编译指令调用二进制段的写入方法,将所述依赖关系数据写入到所述程序编译后生成的二进制数据中。
在一实施例中,所述依赖关系数据还包括所述第二元素的类型,如图4所示,依赖关系数据确定模块340包括以下至少一个子模块:函数依赖关系确定子模块3401、字符串依赖关系确定子模块3402、类依赖关系确定子模块3403和方法依赖关系确定子模块3404。
函数依赖关系确定子模块3401用于若第二元素为函数,则将所述第二元素的指针确定作为所述第二元素的索引值。
字符串依赖关系确定子模块3402用于若第二元素为字符串,则将所述第二元素确定作为所述第二元素的索引值。
类依赖关系确定子模块3403用于若第二元素为类,则将所述第二元素的名称确定作为所述第二元素的索引值。
方法依赖关系确定子模块3404用于若第二元素为Objective-C的方法,则将通过***宏获得的字符串确定作为所述第二元素的索引值。
本实施例公开的装置用于执行实施例一和实施例二所述的方法的步骤,所述装置的各模块的具体实施方式参见实施例一和实施例二中的相应步骤,此处不再赘述。
在本公开实施例的程序调用解耦装置中,根据所述程序中第一元素对应的索引键、所述第一元素依赖的第二元素,依赖关系数据确定模块生成将所述索引键和所述第二元素对应的索引值关联的依赖关系数据,然后,依赖关系数据写入模块将所述依赖关系数据写入到所述程序编译后生成的二进制数据中。在程序执行过程中,依赖关系数据加载模块响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的依赖关系数据加载至运行时环境,索引值确定模块通过所述运行时环境从所述依赖关系数据中获取与所述第一元素对应的索引键关联的索引值,且调用模块调用所述索引值对应的所述第二元素。由于将程序运行时的依赖关系数据预先写入到程序的二进制数据中,当需要调用存在依赖关系的元素时,才加载依赖关系数据,从而有效地缩短了程序的启动时间,并有效地提升了程序的启动效率。
+load是在程序启动的时候执行无差别的完全加载,很多不在启动关键路径上面的 依赖也会在这个时候被执行加载,造成了不必要的浪费。本公开的程序调用解耦装置充分利用了编译时的数据写入,将需要执行的方法和数据与索引键进行对应,程序执行到需要加载对应索引键的时候,再执行相应的函数或者返回相应的数据,避免了不必要的浪费,大大节省了程序的启动时间。
实施例四
相应的,如图5所示,本公开还提供了一种电子设备50,该电子设备50包括存储器501和处理器502。存储器501存储有可在处理器502上运行的计算机程序,处理器502执行所述计算机程序时实现如本公开实施例一和实施例二所述的程序调用解耦方法。所述电子设备可以为PC机、移动终端、个人数字助理、平板电脑等。
本公开还提供了一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如本公开实施例一和实施例二所述的程序调用解耦方法。
本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。对于装置实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
以上对本公开提供的一种程序调用解耦方法及装置进行了详细介绍,本文中应用了具体个例对本公开的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本公开的方法及其核心思想;同时,对于本领域的一般技术人员,依据本公开的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本公开的限制。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件实现。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。

Claims (14)

  1. 一种程序调用解耦方法,所述程序具有对应的二进制数据,所述二进制数据中包括依赖关系数据,所述方法包括:
    在所述程序的执行过程中,响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的所述依赖关系数据加载至运行时环境,其中,所述依赖关系数据至少包括所述第一元素对应的索引键、第二元素对应的索引值,所述第一元素依赖所述第二元素;
    通过所述运行时环境从所述依赖关系数据中获取与所述第一元素对应的索引键关联的索引值;
    调用所述索引值对应的所述第二元素。
  2. 根据权利要求1所述的方法,其特征在于,在所述程序的执行过程中,响应于对所述程序中所述第一元素的调用,将所述程序的二进制数据中的所述依赖关系数据加载至运行时环境之前,还包括:
    根据所述程序中所述第一元素对应的索引键、所述第一元素依赖的所述第二元素,生成将所述索引键和所述第二元素对应的索引值关联的所述依赖关系数据;
    将所述依赖关系数据写入到所述程序编译后生成的二进制数据中。
  3. 根据权利要求2所述的方法,其特征在于,将所述依赖关系数据写入到所述程序编译后生成的所述二进制数据中,包括:
    通过编译指令调用二进制段的写入方法,将所述依赖关系数据写入到所述程序编译后生成的所述二进制数据中。
  4. 根据权利要求3所述的方法,其特征在于,所述依赖关系数据还包括所述第二元素的类型,
    若所述第二元素为函数,则将所述第二元素的指针作为所述第二元素对应的索引值;
    若所述第二元素为字符串,则将所述第二元素本身作为所述第二元素对应的索引值;
    若所述第二元素为类,则将所述第二元素的名称作为所述第二元素对应的索引值;
    若所述第二元素为Objective-C的方法,则将通过***宏获得的字符串作为所述第二元素对应的索引值。
  5. 根据权利要求3所述的方法,其特征在于,所述依赖关系数据还包括表示所述第二元素是否为数组的布尔值,
    若所述布尔值为特定值,则表示所述第二元素为数组,所述第二元素对应的索引值有多个。
  6. 根据权利要求1所述的方法,其特征在于,在所述程序的执行过程中,响应于对所述程序中所述第一元素的调用,将所述程序的二进制数据中的依赖关系数据加载至所述运行时环境的步骤,包括:
    获取调用所述程序中所述第一元素的操作;
    响应于所述操作,通过预设的二进制段读取函数,获取所述程序的二进制数据中的所述依赖关系数据。
  7. 一种程序调用解耦装置,所述程序具有对应的二进制数据,所述二进制数据中包括依赖关系数据,所述装置包括:
    依赖关系数据加载模块,用于在所述程序的执行过程中,响应于对所述程序中第一元素的调用,将所述程序的二进制数据中的所述依赖关系数据加载至运行时环境,其中,所述依赖关系数据至少包括所述第一元素对应的索引键、第二元素对应的索引值,所述第一元素依赖所述第二元素;
    索引值确定模块,用于通过所述运行时环境从所述依赖关系数据加载模块加载的所述依赖关系数据中获取与所述第一元素对应的索引键关联的索引值;
    调用模块,用于调用所述索引值确定模块确定的索引值对应的所述第二元素。
  8. 根据权利要求7所述的装置,其特征在于,所述装置还包括:
    依赖关系数据确定模块,用于根据所述程序中所述第一元素对应的索引键、所述第 一元素依赖的所述第二元素,生成将所述索引键和所述第二元素对应的索引值关联的依赖关系数据;
    依赖关系数据写入模块,用于将所述依赖关系数据确定模块确定的依赖关系数据写入到所述程序编译后生成的二进制数据中。
  9. 根据权利要求8所述的装置,其特征在于,所述依赖关系数据写入模块还用于:
    通过编译指令调用二进制段的写入方法,将所述依赖关系数据写入到所述程序编译后生成的所述二进制数据中。
  10. 根据权利要求8所述的装置,其特征在于,所述依赖关系数据还包括所述第二元素的类型,所述依赖关系数据确定模块包括以下至少一个子模块:
    函数依赖关系确定子模块,用于若所述第二元素为函数,则将所述第二元素的指针确定作为所述第二元素对应的索引值;
    字符串依赖关系确定子模块,用于若所述第二元素为字符串,则将所述第二元素本身确定作为所述第二元素对应的索引值;
    类依赖关系确定子模块,用于若所述第二元素为类,则将所述第二元素的名称确定作为所述第二元素对应的索引值;
    方法依赖关系确定子模块,用于若所述第二元素为Objective-C的方法,则将通过***宏获得的字符串确定作为所述第二元素对应的索引值。
  11. 根据权利要求8所述的装置,其特征在于,所述依赖关系数据还包括表示所述第二元素是否为数组的布尔值,所述依赖关系数据确定模块还用于:
    若所述布尔值为特定值,则表示所述第二元素为数组,所述第二元素对应的索引值有多个。
  12. 根据权利要求7所述的装置,其特征在于,所述依赖关系数据加载模块还用于:
    获取调用程序中第一元素的操作;
    响应于所述操作,通过预设的二进制段读取函数,获取所述程序的二进制数据中的 依赖关系数据。
  13. 一种电子设备,包括存储器、处理器,所述存储器存储有可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现权利要求1至6中任意一项所述的程序调用解耦方法。
  14. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现权利要求1至6中任意一项所述的程序调用解耦方法。
PCT/CN2018/121032 2018-05-31 2018-12-14 程序调用解耦 WO2019227899A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/059,981 US20210232378A1 (en) 2018-05-31 2018-12-14 Program calling, electronic device, and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810550126.4A CN108984223B (zh) 2018-05-31 2018-05-31 一种程序调用解耦方法、装置、电子设备及存储介质
CN201810550126.4 2018-05-31

Publications (1)

Publication Number Publication Date
WO2019227899A1 true WO2019227899A1 (zh) 2019-12-05

Family

ID=64542839

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/121032 WO2019227899A1 (zh) 2018-05-31 2018-12-14 程序调用解耦

Country Status (3)

Country Link
US (1) US20210232378A1 (zh)
CN (1) CN108984223B (zh)
WO (1) WO2019227899A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108984223B (zh) * 2018-05-31 2021-04-02 北京三快在线科技有限公司 一种程序调用解耦方法、装置、电子设备及存储介质
CN110737409B (zh) * 2019-10-21 2023-09-26 网易(杭州)网络有限公司 数据加载方法、装置和终端设备
CN114860340B (zh) * 2022-05-17 2024-07-16 中国平安财产保险股份有限公司 配置逻辑代码的启动控制方法、装置、设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902544A (zh) * 2012-09-29 2013-01-30 福建升腾资讯有限公司 一种电话支付终端软件平台的实现方法
US8719849B1 (en) * 2011-04-05 2014-05-06 Nettapp, Inc. Decoupled application program-operating system computing architecture
CN104572316A (zh) * 2014-12-31 2015-04-29 福建天晴数码有限公司 游戏程序与运行平台交互的方法和***
CN106569835A (zh) * 2016-11-14 2017-04-19 济南浪潮高新科技投资发展有限公司 一种基于go语言控制反转组件的实现方法
CN106648563A (zh) * 2015-10-30 2017-05-10 阿里巴巴集团控股有限公司 应用程序中共享模块的依赖解耦处理方法和装置
CN108984223A (zh) * 2018-05-31 2018-12-11 北京三快在线科技有限公司 一种程序调用解耦方法、装置、电子设备及存储介质

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101819526B (zh) * 2009-09-18 2013-08-28 华为技术有限公司 调用底层软件的方法、装置和嵌入式***
CN102567033B (zh) * 2010-12-14 2015-09-16 北京大学 基于嵌入式实时Java虚拟机的预先类加载方法及装置
CN105354049B (zh) * 2015-09-29 2019-03-08 北京畅游天下网络技术有限公司 一种三维动画引擎的资源加载方法、装置及***
CN107729063A (zh) * 2017-10-25 2018-02-23 武汉斗鱼网络科技有限公司 软件开发工具包的调用方法、装置及终端

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8719849B1 (en) * 2011-04-05 2014-05-06 Nettapp, Inc. Decoupled application program-operating system computing architecture
CN102902544A (zh) * 2012-09-29 2013-01-30 福建升腾资讯有限公司 一种电话支付终端软件平台的实现方法
CN104572316A (zh) * 2014-12-31 2015-04-29 福建天晴数码有限公司 游戏程序与运行平台交互的方法和***
CN106648563A (zh) * 2015-10-30 2017-05-10 阿里巴巴集团控股有限公司 应用程序中共享模块的依赖解耦处理方法和装置
CN106569835A (zh) * 2016-11-14 2017-04-19 济南浪潮高新科技投资发展有限公司 一种基于go语言控制反转组件的实现方法
CN108984223A (zh) * 2018-05-31 2018-12-11 北京三快在线科技有限公司 一种程序调用解耦方法、装置、电子设备及存储介质

Also Published As

Publication number Publication date
CN108984223B (zh) 2021-04-02
CN108984223A (zh) 2018-12-11
US20210232378A1 (en) 2021-07-29

Similar Documents

Publication Publication Date Title
CN109375899B (zh) 一种形式验证Solidity智能合约的方法
US10152309B2 (en) Cross-library framework architecture feature sets
US20180136914A1 (en) Programming Language with Extensions using a Strict Meta-Model
US8549502B2 (en) Compiler with user-defined type inference rules
WO2019233293A1 (zh) 一种应用程序的开发方法和装置
WO2019227899A1 (zh) 程序调用解耦
CN105164641A (zh) 扩展开发环境
US9753705B2 (en) Conditional compilation of bytecode
US10296313B2 (en) Safely consuming dynamically-typed code from a statically-typed programming language
WO2018161509A1 (zh) 条件编译预处理方法、终端及存储介质
CN114153459A (zh) 接口文档生成方法及装置
JP4806158B2 (ja) マークアップ内でサブクラスを宣言的に定義し、使用するためのシステムおよび方法
WO2018001041A1 (zh) 接口实现方法、装置、机顶盒及存储介质
Blanchard et al. Logic against ghosts: comparison of two proof approaches for a list module
CN109032572B (zh) 一种基于字节码的java程序方法内联的方法
US20060101412A1 (en) Method to bridge between unmanaged code and managed code
US9229698B2 (en) Method and apparatus for compiler processing for a function marked with multiple execution spaces
WO2020157795A1 (ja) 試験装置、試験方法および試験プログラム
CN115629795A (zh) 一种可执行文件的配置方法、装置及电子设备
CN111796865B (zh) 一种字节码文件修改方法、装置、终端设备及介质
CN111399842B (zh) 一种代码编译方法及装置
CN111796832B (zh) 热补丁文件生成方法、装置、设备及存储介质
CN114625373A (zh) 应用转换方法、装置、电子设备和存储介质
CN114936368A (zh) 一种Java内存木马检测方法、终端设备及存储介质
CN111782196A (zh) 基于mvp架构的开发方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18921028

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18921028

Country of ref document: EP

Kind code of ref document: A1