Method and device for determining function calling condition and computer equipment

By identifying and constructing the function call stack of mixed-language programming, the problem of profiler tools being unable to capture the mixed-language stack is solved, enabling accurate reconstruction of function call details and accurate identification of performance bottlenecks.

CN120407352APending Publication Date: 2025-08-01HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410141925.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-30
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

Existing profiler tools cannot capture function call stacks in mixed-language programming, making it impossible to accurately reconstruct function call behavior and affecting developers' ability to identify performance bottlenecks.

Method used

By identifying the boundary stack frames in the function call stacks of different languages ​​and determining their correspondence, a hybrid function call stack is constructed, including function stack frames of the first and second languages, to accurately reconstruct the function call situation in hybrid language programming.

Benefits of technology

It can accurately reflect function call behavior, helping developers to accurately identify performance bottlenecks and improve program optimization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407352A_ABST
    Figure CN120407352A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for determining a function call condition and computer equipment, and the method comprises the steps: executing a first program, and capturing a first function call stack and a second function call stack; determining a corresponding relationship between the first type boundary stack frame and a stack frame in the second function call stack according to the identification information of the first type boundary stack frame in the first function call stack; and determining a third function call stack according to the first function call stack, the second function call stack and the corresponding relation. In the embodiment of the invention, the function call stacks of different languages can be respectively captured, then the corresponding relation between the boundary stack frame in the function call stack of the first language and the stack frame in the function call stack of the second language is identified and determined, and then the mixed function call stack is determined according to the corresponding relation and the function call stacks of the different languages. The mixed function call stack can truly reflect the call condition of the function, and can help developers to judge the performance bottleneck.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and more particularly, to a method, an apparatus, and a computer device for determining function call situations. Background Art

[0002] The function call stack stores the hierarchical information of function calls and changes continuously as functions are called and returned. By recording the changes in the function call stack over time, the entire process of function calls can be reflected through this record. This process includes the start time and end time of each function, so the execution duration of each function can be reflected. Currently, developers can capture the function call stack through a profiler tool. However, when the profiler tool captures the function call stack, it only captures the function call stack of a single language and cannot be applied to programs using mixed-language programming, that is, it cannot restore the real function call situation. Based on this, how to capture the function call stack to accurately restore the function call situation has become an urgent technical problem to be solved. Summary of the Invention

[0003] The present application provides a method, an apparatus, and a computer device for determining function call situations. During the execution of a program using mixed-language programming, the function call stacks of different languages can be captured separately, and a mixed function call stack can be determined based on the function call stacks of different languages. This mixed function call stack can truly reflect the function call situation and can help developers judge performance bottlenecks.

[0004] In a first aspect, a method for determining function call situations is provided. The method includes: executing a first program and capturing a first function call stack and a second function call stack, where the first program is a program written in a first language and calls a second-language function, the second function call stack corresponds to the second language, the first function call stack includes stack frames corresponding to M first-language functions, the second function call stack includes stack frames corresponding to N second-language functions, the first function call stack further includes a first-type boundary stack frame for indicating the position where a function in the first language calls a function in the second language, M≥1, N≥1, and M and N are integers; determining the correspondence between the first-type boundary stack frame in the first function call stack and the stack frames in the second function call stack according to the identification information of the first-type boundary stack frame in the first function call stack; and determining a third function call stack according to the first function call stack, the second function call stack, and the correspondence. The third function call stack includes the stack frames corresponding to the M first-language functions and the stack frames corresponding to the N second-language functions.

[0005] In an embodiment of the present application, during the execution of a program written in a mixed language, function call stacks of different languages can be captured separately, and then the correspondence between the boundary stack frames in the first language function call stack and the stack frames in the second language function call stack can be identified and determined. Furthermore, based on this correspondence and the function call stacks of different languages, a mixed function call stack can be determined. This mixed function call stack can truly reflect the function call situation and can help developers judge performance bottlenecks.

[0006] In combination with the first aspect, in some implementation manners of the first aspect, the second function call stack further includes a second type of boundary stack frame, which is used to indicate the position where a function of the second language calls the first language function. Determining the third function call stack according to the first function call stack, the second function call stack, and the correspondence includes: determining the third function call stack according to the first function call stack, the second function call stack, the correspondence, and the position of the second type of boundary stack frame in the second function call stack.

[0007] In an embodiment of the present application, the position of the boundary stack frame in the second language function call stack can also be identified, and based on this position, the position where the second language function calls the first language function can be determined. Then, in the third function call stack, the position where the second language function calls the first language function can be accurately restored.

[0008] In combination with the first aspect, in some implementation manners of the first aspect, the identification information is a function pointer.

[0009] In combination with the first aspect, in some implementation manners of the first aspect, the identification information further includes the program counter PC value.

[0010] In combination with the first aspect, in some implementation manners of the first aspect, the first language is the JavaScript language, and the second language is the C++ language or the C language.

[0011] Second aspect, there is provided an apparatus, which includes an execution unit, a sampling unit, and a processing unit. The execution unit is configured to execute a first program, where the first program is written in a first language and calls a second language function; the sampling unit is configured to capture a first function call stack and a second function call stack, the second function call stack corresponding to the second language, the first function call stack including stack frames corresponding to M first language functions, the second function call stack including stack frames corresponding to N second language functions, the first function call stack further including a first type of boundary stack frame for indicating a position where a function of the first language calls a function of the second language, M≥1, N≥1, and M and N are integers; the processing unit is configured to determine a correspondence between the first type of boundary stack frame and stack frames in the second function call stack according to identification information of the first type of boundary stack frame in the first function call stack; the processing unit is further configured to determine a third function call stack according to the first function call stack, the second function call stack, and the correspondence, the third function call stack including the stack frames corresponding to the M first language functions and the stack frames corresponding to the N second language functions.

[0012] In combination with the second aspect, in some implementation manners of the second aspect, the second function call stack further includes a second type of boundary stack frame for indicating a position where a function of the second language calls a function of the first language, and the processing unit is specifically configured to determine the third function call stack according to the first function call stack, the second function call stack, the correspondence, and a position of the second type of boundary stack frame in the second function call stack.

[0013] In combination with the second aspect, in some implementation manners of the second aspect, the identification information is a function pointer.

[0014] In combination with the second aspect, in some implementation manners of the second aspect, the identification information further includes a program counter PC value.

[0015] In combination with the second aspect, in some implementation manners of the second aspect, the first language is JavaScript, and the second language is C++ or C.

[0016] For the beneficial effects of the second aspect, please refer to the beneficial effects of the first aspect and will not be repeated here.

[0017] In a third aspect, a method for determining function call situations is provided. The method includes: executing a first program; constructing a first function call stack and a second function call stack according to the first program. When constructing the first function call stack, M first-type stack frames and M second-type stack frames are generated. The M first-type stack frames and the M second-type stack frames are associated and correspond to M functions in the first language. The M first-type stack frames are pushed onto the first function call stack. When constructing the second function call stack, N second-type stack frames are generated. The N second-type stack frames correspond to N functions in the second language. The M second-type stack frames and the N second-type stack frames are pushed onto the second function call stack; determining a third function call stack according to the positional relationship between the M second-type stack frames and the N second-type stack frames in the second function call stack.

[0018] In an embodiment of the present application, when constructing the first-type stack frames in the first function call stack, second-type stack frames associated with the first-type stack frames can be synchronously generated and pushed onto the second function call stack. When it is necessary to determine the function call situation, only the second function call stack can be captured, and the functions corresponding to the second-type stack frames associated with the first-type stack frames can be obtained through the second function call stack. Furthermore, a mixed function call stack can be determined. The mixed function call stack can truly reflect the function call situation and can help developers judge performance bottlenecks.

[0019] In a fourth aspect, a computer device is provided. The computer device includes one or more processors; one or more memories; the one or more memories store one or more computer programs. The one or more computer programs include instructions. When the instructions are executed by the one or more processors, the above aspects or any possible implementation manner of the above aspects is executed.

[0020] In a fifth aspect, a computer-readable storage medium is provided. The computer-readable storage medium includes a computer program or instructions. When the computer program or instructions run on a computer, the above aspects or any possible implementation manner of the above aspects is executed.

[0021] In a sixth aspect, a computer program product is provided. The computer program product includes a computer program or instructions. When the computer program or instructions run on a computer, the above aspects or any possible implementation manner of the above aspects is executed.

[0022] In a seventh aspect, a computer program is provided. When it runs on a computer, the above aspects or any possible implementation manner of the above aspects is executed.

[0023] For the beneficial effects of the fourth aspect to the seventh aspect, please refer to the beneficial effects of the first aspect, the second aspect, and the third aspect, and will not be repeated here. Description of the Drawings

[0024] Figure 1 It is a schematic diagram of the application scenario provided by the embodiment of the present application.

[0025] Figure 2 It is a schematic diagram for determining a function call stack.

[0026] Figure 3 It is a schematic flowchart of the method for determining function call situations provided by the embodiment of the present application.

[0027] Figure 4 It is a schematic diagram of the program running situation and the function call stack provided by the embodiment of the present application.

[0028] Figure 5 It is a schematic diagram of the program running situation and the function call stack provided by the embodiment of the present application.

[0029] Figure 6 It is a schematic diagram of the function call stack provided by the embodiment of the present application.

[0030] Figure 7 It is a schematic diagram of the function call stack provided by the embodiment of the present application.

[0031] Figure 8 It is a schematic diagram of the function call stack provided by the embodiment of the present application.

[0032] Figure 9 It is a schematic diagram of the function call stack provided by the embodiment of the present application.

[0033] Figure 10 It is a schematic flowchart of the method for determining function call situations provided by the embodiment of the present application.

[0034] Figure 11 It is a schematic diagram of the program running situation and the function call stack provided by the embodiment of the present application.

[0035] Figure 12 It is a schematic structural diagram of a device for determining function call situations provided by the embodiment of the present application.

[0036] Figure 13 It is a schematic hardware structure diagram of a computer device in the embodiment of the present application. Detailed Embodiments

[0037] Next, the technical solutions in the present application will be described with reference to the accompanying drawings.

[0038] In the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B may mean A or B. The "and / or" herein is merely a description of the relationship between associated objects, indicating that there can be three relationships. For example, A and / or B may mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality of" means two or more than two.

[0039] Hereinafter, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of this embodiment, unless otherwise specified, the meaning of "a plurality of" is two or more.

[0040] In addition, the terms "comprise" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices.

[0041] In the embodiments of the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner for easy understanding.

[0042] In this application, "at least one (item)" means one or more. "Multiple" means two or more. "At least two (items)" means two, three or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, "A and / or B" can mean: only A exists, only B exists, and both A and B exist at the same time. Among them, A and B can be singular or plural. The character " / " generally means that the associated objects before and after are in an "or" relationship. "At least one (individual) of the following" or its similar expressions refer to any combination of these items, including any combination of single items (individuals) or plural items (individuals). For example, at least one (individual) of a, b, and (or) c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple. "When..." and "if" both refer to corresponding processing under a certain objective situation, not limited to time, and do not require a judgment action when implemented, nor does it mean that there are other limitations.

[0043] Reference to "one embodiment" or "some embodiments" described in this specification means that a specific feature, structure, or characteristic described in connection with that embodiment is included in one or more embodiments of this application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "comprising", "including", "having" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0044] For the sake of easy understanding, the relevant terms and related concepts involved in the embodiments of this application are introduced below. The terms used in the embodiments of this application are only used to explain the specific embodiments of this application, and are not intended to limit this application.

[0045] Source code: It refers to the original code written by developers, usually written in high-level programming languages, such as Java, JavaScript, Swift, etc. The source code contains information such as the logic, algorithms, variables, and function definitions of the program.

[0046] Object code: It refers to the code generated after processing the source code by a compiler. The object code can be bytecode or machine code. The object code includes the instructions specified by the developer in the source code. These instructions will be encoded in binary form, and the object code is machine-readable, or rather, machine-executable.

[0047] High-level programming language function: Also known as an interpreted execution function, it refers to the function code described in a high-level programming language.

[0048] Native function: It refers to a function implemented in another programming language in a high-level programming language program. Such a function implemented in another programming language is called a native function. A native function can also be called a local function. For example, in the JavaScript language, a native function is a C++ function or a C function.

[0049] Stack frame: It refers to the stack space separately allocated for a function call. The stack frame corresponding to each function can be used to save the local variables of the function, the parameters passed to the called function, the return value of the function, and the return address of the function, etc. The construction of the stack frame occurs when a function is called. Each function corresponds to a stack frame. When a function is called, a corresponding stack frame will be generated synchronously and pushed onto the function call stack. On the contrary, when a function call ends and returns to the upper-level function that called it, the corresponding stack frame will be popped from the function call stack.

[0050] Boundary function: The boundary function can also be called the entry function. It refers to the function used to implement the call of functions in different languages when running a program written in a hybrid language. In other words, the boundary function can be regarded as an interface. The function of a certain language can call the function of another language through the boundary function. In the embodiments of the present application, the boundary function can be divided into an internal-to-external boundary function and an external-to-internal boundary function. Among them, the internal-to-external boundary function is the boundary function used when a high-level programming language function calls a native function, and the external-to-internal boundary function is the boundary function used when a native function calls a high-level programming language function.

[0051] Boundary stack frame: It refers to the stack frame generated when the boundary function is executed. In the embodiments of the present application, the boundary stack frame can be divided into an internal-to-external boundary stack frame and an external-to-internal boundary stack frame. Among them, the internal-to-external boundary stack frame is the stack frame corresponding to the internal-to-external boundary function. The external-to-internal boundary stack frame is the stack frame corresponding to the external-to-internal boundary function. In the embodiments of the present application, the internal-to-external boundary stack frame can also be called the first type of boundary stack frame, and the external-to-internal boundary stack frame can also be called the second type of boundary stack frame.

[0052] It should be noted that when a high-level programming language function (e.g., a JavaScript function) calls a Native function (e.g., a C++ function) through a boundary function, the inner-to-outer boundary stack frame can be pushed onto the function call stack corresponding to the high-level programming language, and the inner-to-outer boundary stack frame includes identification information indicating the stack frame corresponding to the called Native function. In other words, a stack frame in the function call stack corresponding to the Native language can be found through the identification information included in the inner-to-outer boundary stack frame, and the Native function corresponding to this stack frame is called.

[0053] For example, if JavaScript function #1 calls C++ function #1 through a boundary function, then stack frame #1 corresponding to JavaScript function #1 and the inner-to-outer boundary stack frame #2 corresponding to the boundary function will be pushed onto function call stack #1, and stack frame #3 corresponding to C++ function #1 will be pushed onto function call stack #2. Here, function call stack #1 is the function call stack corresponding to the JavaScript language, and function call stack #2 is the function call stack corresponding to the C++ language. Looking from the bottom to the top of function call stack #1, the inner-to-outer boundary stack frame #2 is located above stack frame #1. It can be understood that there is a corresponding relationship between the inner-to-outer boundary stack frame #2 in function call stack #1 and stack frame #3 in function call stack #2, that is, the inner-to-outer boundary stack frame #2 includes the identification information of stack frame #3.

[0054] It should also be noted that when a native function (e.g., a C++ function) calls a high-level programming language function (e.g., a JavaScript function) through a boundary function, the outer-to-inner boundary stack frame can be pushed onto the stack frame corresponding to the native function language.

[0055] For example, if C++ function #1 calls JavaScript function #1 through a boundary function, then stack frame #1 corresponding to JavaScript function #1 will be pushed onto function call stack #1, and stack frame #2 corresponding to C++ function #1 and the outer-to-inner boundary stack frame #3 corresponding to the boundary function will be pushed onto function call stack #2. Here, function call stack #1 is the function call stack corresponding to the JavaScript language, and function call stack #2 is the function call stack corresponding to the C++ language. Looking from the bottom to the top of function call stack #2, the outer-to-inner boundary stack frame #3 is located above stack frame #2.

[0056] Figure 1 Shows a schematic diagram of an application scenario provided by an embodiment of the present application.

[0057] Such as Figure 1As shown, developers can use the profiler tool to output the performance analysis results of a program. The performance analysis results of the profiler tool correspond to accessing the function call stack during the program execution process, and thus can determine the execution time of the function corresponding to each stack frame in the function call stack, as well as the call situation between functions. Developers can discover the performance bottlenecks of the program based on the display results of the profiler tool. However, when the profiler tool captures the function call stack, it only captures the function call stack of a single language and cannot be applied to programs using mixed-language programming, that is, it cannot restore the real function call situation. The following will be described in detail in combination with Figure 2 for a detailed description.

[0058] Currently, many engines support the mutual call between code of multiple languages. In the embodiments of this application, the JavaScript language and the C++ language will be taken as examples for introduction, but no specific limitation is made thereto. For example, it can also be the mutual call between the Java language and the C++ language. This programming method of mutual call between multiple languages is relatively common in the process of program development. For example, developers can call C++ functions in the JavaScript language, and can also call JavaScript functions in the C++ language. Therefore, when analyzing a program written in the JavaScript language and the C++ language, both the JavaScript language and the C++ language need to be considered in order to determine the correct function call situation.

[0059] Figure 2 shows a schematic diagram for determining the function call stack.

[0060] As Figure 2 shown in, the program includes JavaScript function #1, JavaScript function #2, JavaScript function #3, JavaScript function #4, C++ function #1, C++ function #2, C++ function #3, and C++ function #4. Among them, the call relationship of the above functions is as shown by the arrows in (a) of Figure 2 Specifically, JavaScript function #1 calls JavaScript function #2, JavaScript function #2 calls C++ function #1, C++ function #1 calls C++ function #2, C++ function #2 calls JavaScript function #3, JavaScript function #3 calls JavaScript function #4, JavaScript function #4 calls C++ function #3, and C++ function #3 calls C++ function #4.

[0061] As Figure 2As shown, during the execution of the program, stack frames corresponding to the above functions are generated and pushed onto the function call stack in the order of call. Since the program includes functions in two languages, the stack frames corresponding to functions in different languages will be pushed onto different function call stacks. For example, JavaScript function #1, JavaScript function #2, JavaScript function #3, and JavaScript function #4 respectively correspond to stack frame #1, stack frame #2, stack frame #3, and stack frame #4. The above 4 stack frames will be pushed onto function call stack #1 in sequence. From the bottom to the top of the stack, they are stack frame #1, stack frame #2, stack frame #3, and stack frame #4. Similarly, C++ function #1, C++ function #2, C++ function #3, and C++ function #4 respectively correspond to stack frame #5, stack frame #6, stack frame #7, and stack frame #8. The above 4 stack frames will be pushed onto function call stack #2 in sequence. From the bottom to the top of the stack, they are stack frame #5, stack frame #6, stack frame #7, and stack frame #8.

[0062] When the Profile tool performs performance analysis, it will capture function call stack #1 and function call stack #2 respectively to determine the adoption result #1 and the sampling result #2. The sampling result #1 reflects the distribution relationship of the stack frames in function call stack #1, and the sampling result #2 reflects the distribution relationship of the stack frames in function call stack #2. However, combined with Figure 2 It is not difficult to see that there are only stack frames corresponding to JavaScript functions in the sampling result #1. Therefore, it can only reflect the call situation between JavaScript functions, and there will also be incorrect call situations. For example, during the actual operation of the program, it is C++ function #2 that calls JavaScript function #3. But from the sampling result #1, it will be JavaScript function #2 that calls JavaScript function #3. Similarly, the sampling result #2 can only reflect the call situation between C++ functions, and there will also be incorrect call situations. For example, during the actual operation of the program, it is JavaScript function #4 that calls C++ function #3. But from the sampling result #2, it will be C++ function #2 that calls C++ function #3.

[0063] In summary, for the currently programmed programs using a mixed language, it is impossible to truly and completely restore the actual function call situation, which will hinder the optimization of developers and affect the judgment of developers on performance bottlenecks. [[ID=⑨]] [[ID=⑩]]

[0064] [[ID=⑪]]Based on this, the embodiment of the present application provides a method for determining the function call situation, which can truly restore the complete function call situation and helps developers better judge performance bottlenecks. [[ID=⑫]] [[ID=⑬]]

[0065] [[ID=⑭]] Figure 3The figure shows a schematic flowchart of a method for determining function call situations provided by an embodiment of the present application. As Figure 3 shown, the method includes:

[0066] S301, execute a first program to capture a first function call stack and a second function call stack.

[0067] Among them, the first program is a program written in a first language and calls a second language function. The first function call stack corresponds to the first language, and the second function call stack corresponds to the second language. The first function call stack includes stack frames corresponding to M functions written in the first language. The second function call stack includes stack frames corresponding to N functions written in the second language, where M≥1, N≥1, and M and N are integers.

[0068] Exemplarily, the first language can be the JavaScript language, and the second language can be the C++ language.

[0069] In some embodiments, the first function call stack includes one or more inner-to-outer boundary stack frames, that is, includes one or more first-type boundary stack frames.

[0070] In some embodiments, the second function call stack may further include one or more outer-to-inner boundary functions, that is, includes one or more second-type boundary stack frames.

[0071] For example, as Figure 4 shown in (a) of the figure, during the actual running process of the program, the main function is the entry point of the program. The main function calls JavaScript function #1 through an outer-to-inner boundary function, and then JavaScript function #1 calls C++ function #1 through an inner-to-outer boundary function.

[0072] It should be noted that during the actual running process of the program, an internal C++ function of the engine will also be called. This internal C++ function of the engine is used to support the JavaScript engine to interpret and execute JavaScript functions.

[0073] Continue to refer to Figure 4In (a) among them, during the running process of the program, the first function call stack and the second function call stack can be captured. Among them, the first function call stack corresponds to the JavaScript language, and the second function call stack corresponds to the C++ language. The first function call stack includes stack frame #1 and stack frame #2. Among them, stack frame #1 is the stack frame corresponding to JavaScript function #1, and stack frame #2 is the inner-to-outer boundary stack frame. From the bottom to the top of the first function call stack, stack frame #2 is located above stack frame #1. The second function call stack includes stack frame #3 and stack frame #4. Among them, stack frame #3 is the outer-to-inner boundary stack frame, and stack frame #4 is the stack frame corresponding to C++ function #1. From the bottom to the top of the second function call stack, stack frame #4 is located above stack frame #3. Among them, stack frame #2 includes the identification information of stack frame #5.

[0074] For another example, as Figure 4 shown in (b) among them, during the actual running process of the program, the main function is the entry point of the program. The main function calls JavaScript function #1 through the outer-to-inner boundary function #1, then JavaScript function #1 calls JavaScript function #2, then JavaScript function #2 calls C++ function #1 through the inner-to-outer boundary function, and then C++ function #1 calls JavaScript function #3 through the outer-to-inner boundary function #2.

[0075] Continue to refer to Figure 4 In (b) among them, during the running process of the program, the first function call stack and the second function call stack can be captured. Among them, the first function call stack corresponds to the JavaScript language, and the second function call stack corresponds to the C++ language. The first function call stack includes stack frame #1, stack frame #2, stack frame #3, and stack frame #4. Among them, stack frame #1 is the stack frame corresponding to JavaScript function #1, stack frame #2 is the stack frame corresponding to JavaScript function #2, stack frame #3 is the inner-to-outer boundary stack frame, and stack frame #4 is the stack frame corresponding to JavaScript function #3. From the bottom to the top of the first function call stack, stack frame #3 is located above stack frame #2, and stack frame #2 is located above stack frame #1. The second function call stack includes stack frame #5, stack frame #6, and stack frame #7. Among them, stack frame #5 is the outer-to-inner boundary stack frame corresponding to the outer-to-inner boundary function #1, stack frame #6 is the stack frame corresponding to C++ function #1, and stack frame #7 is the outer-to-inner boundary stack frame corresponding to the outer-to-inner boundary function #2. From the bottom to the top of the second function call stack, they are stack frame #5, stack frame #6, and stack frame #7 in sequence. Among them, stack frame #3 includes the identification information of stack frame #6.

[0076] It can be understood that in Figure 4The second function call stacks in (a) and (b) in it may also include stack frames corresponding to the main function and the internal C++ functions of the engine.

[0077] It should be noted that, in Figure 4 the example shown, taking the main function as the program entry is used for introduction, but the embodiments of the present application do not make specific limitations on this. In some other embodiments, the main function may not be used as the program entry. When the program does not include the main function, Figure 4 the second function call stack shown in (a) in it may not include stack frame #3, that is, the second function call stack as shown in (c) in Figure 4 it; the second function call stack shown in (b) in Figure 4 it may not include stack frame #5, that is, the second function call stack as shown in (d) in Figure 4 it.

[0078] S302. Determine the correspondence between the first type of boundary stack in the first function call stack and the stack frames in the second function call stack according to the identification information of the first type of boundary stack frames in the first function call stack.

[0079] Specifically, the first type of boundary stack frames are generated and pushed into the first function call stack when a function in the first language in the program calls a function in the second language, and the first boundary type stack frames include identification information. Through this identification information, the stack frames in the second function call stack corresponding to each first type of boundary stack frame can be determined.

[0080] For example, as Figure 4 shown in (a) in it, stack frame #2 is a first type of boundary stack frame, and stack frame #2 is pushed into function call stack #1 when JavaScript function #1 calls C++ function #1. This stack frame #2 may include identification information indicating stack frame #4. Therefore, stack frame #2 and stack frame #4 can be understood as having a corresponding relationship.

[0081] It can be understood that when the first function call stack includes multiple first type of boundary stack frames, the correspondence between the multiple first type of boundary stack frames and the stack frames in the second function call stack can be determined one by one.

[0082] For example, as Figure 5As shown, during the actual operation of the program, the main function is the entry point of the program. The main function calls JavaScript function #1 by invoking the inner boundary function #1 externally, then JavaScript function #1 calls JavaScript function #2, then JavaScript function #2 calls C++ function #1 by invoking the outer boundary function #1 internally, then C++ function #1 calls C++ function #2, then C++ function #2 calls JavaScript function #3 by invoking the inner boundary function #2 externally, then JavaScript function #3 calls JavaScript function #4, and then JavaScript function # calls C++ function #3 by invoking the outer boundary function #2 internally.

[0083] Continue to refer to Figure 5 , during the operation of the program, the first function call stack and the second function call stack can be captured. Among them, the first function call stack corresponds to the JavaScript language, and the second function call stack corresponds to the C++ language. The first function call stack includes stack frames #1, #2, #3, #4, #5, and #6. Among them, stack frame #1 is the stack frame corresponding to JavaScript function #1, stack frame #2 is the stack frame corresponding to JavaScript function #2, stack frame #3 is the inner and outer boundary stack frame corresponding to the inner call of the outer boundary function #1, stack frame #4 is the stack frame corresponding to JavaScript function #3, stack frame #5 is the stack frame corresponding to JavaScript function #4, and stack frame #6 is the inner and outer boundary stack frame corresponding to the inner call of the outer boundary function #2. Looking from the bottom to the top of the first function call stack, they are stack frame #1, stack frame #2, stack frame #3, stack frame #4, stack frame #5, and stack frame #6 in sequence. The second function call stack includes stack frames #7, #8, #9, #10, and #11. Among them, stack frame #7 is the outer and inner boundary stack frame corresponding to the outer call of the inner boundary function #1, stack frame #8 is the stack frame corresponding to C++ function #1, stack frame #9 is the stack frame corresponding to C++ function #2, stack frame #10 is the outer and inner boundary stack frame corresponding to the outer call of the inner boundary function #2, and stack frame #11 is the stack frame corresponding to C++ function #3. Looking from the bottom to the top of the second function call stack, they are stack frame #7, stack frame #8, stack frame #9, stack frame #10, and stack frame #11 in sequence.

[0084] It can be understood that in Figure 5 , the second function call stack can also include the stack frames corresponding to the main function and the engine internal C++ function.

[0085] Continue to refer to Figure 5, stack frame #3 is a first type of boundary stack frame, and stack frame #3 is pushed onto the function call stack #1 when JavaScript function #2 calls C++ function #1. This stack frame #3 may include the identification information of stack frame #8. Therefore, stack frame #3 and stack frame #8 can be understood to have a corresponding relationship. Stack frame #6 is a first type of boundary stack frame, and stack frame #6 is pushed onto the function call stack #1 when JavaScript function #4 calls C++ function #3. Stack frame #6 may include the identification information of stack frame #11. Therefore, stack frame #6 and stack frame #11 can be understood to have a corresponding relationship.

[0086] In some embodiments, the identification information included in the first type of boundary stack frame may be a function pointer, and the function pointers corresponding to each stack frame in the second function call stack are different. Therefore, the corresponding stack frame can be found through the function pointer of the stack frame included in the first type of boundary stack frame. In some embodiments, the identification information may further include a program counter (pc) value.

[0087] It should be noted that only the function pointer is taken as an example of the identification information in the above text, but the embodiments of the present application do not make specific limitations on this. For example, in some other embodiments, a new parameter may be defined such that the new functions corresponding to each stack frame in the second function call stack are different, and then the corresponding stack frame can be found through the new parameter included in the first type of boundary stack frame.

[0088] S303, determine a third function call stack according to the first function call stack, the second function call stack, and the corresponding relationship. The third function call stack includes stack frames corresponding to M first language functions and stack frames corresponding to N second language functions.

[0089] Specifically, determining the third function call stack can be understood as determining the arrangement relationship of the stack frames corresponding to M first language functions and the stacks corresponding to N language functions. When determining the third function call stack, the corresponding relationship between the first type of boundary stack frame in the first function call stack and the stack frame in the second function call stack can be determined, that is, the position where the function of the first language calls the function of the second language is determined. Furthermore, combining the position of the first type of boundary stack frame in the first function call stack, the first function call stack and the second function call stack can be spliced to determine the third function call stack, and the first function call stack includes stack frames corresponding to M first language functions and stack frames corresponding to N second language functions.

[0090] It can be understood that since the first-type boundary function indicates that a function in the first language calls a function in the second language, when splicing stack frames, the stack frames corresponding to the functions in the first language with a call relationship can be spliced below the stack frame corresponding to the function in the second language. That a stack frame described in an embodiment of the present application is below another stack frame can be understood as that the stack frame below is closer to the stack bottom.

[0091] Assume that during the actual running process of the program, JavaScript function #1 calls C++ function #1 through an internal-to-external boundary function, and the first function call stack and the second function call stack can be generated. During the running process of the program, the first function call stack and the second function call stack as shown in Figure 6 can be generated.

[0092] As Figure 6 shown, the first function call stack includes stack frame #1 and stack frame #2, and the second function call stack includes stack frame #3 and the stack frame of the engine internal C++ function. Among them, stack frame #1 corresponds to JavaScript function #1, stack frame #3 corresponds to C++ function #1, and stack frame #2 includes the identification information of stack frame #3, that is, stack frame #2 and stack frame #3 have a corresponding relationship.

[0093] When determining the third function call stack, the first function call stack and the second function call stack can be traversed respectively from the top to the bottom of the stack. When traversing the first function call stack and the second function call stack, the first-type boundary stack frame in the first function call stack and the stack frames in the second function call stack with a corresponding relationship can be determined, that is, stack frame #2 and stack frame #3. Since stack frame #1 is below stack frame #2, and stack frame #2 and stack frame #3 have a corresponding relationship, it indicates that JavaScript function #1 corresponding to stack frame #1 calls C++ function #1 corresponding to stack frame #3, then stack frame #1 can be spliced below stack frame #3. Since stack frame #1 is already at the stack bottom, and there is no stack frame corresponding to a C++ function other than stack frame #3 and the engine internal C++ function in the second function call stack, the splicing can be ended to generate the third function call stack. From the bottom to the top of the third function call stack, stack frame #3 is above stack frame #1.

[0094] It should be noted that the third function call stack can only include the stack frames corresponding to M first-language functions and the stack frames corresponding to N second-language functions, or it can also include the first-type boundary stack frame and / or the stack frame of the engine internal C++ function.

[0095] It should also be noted that the above takes traversing the first function call stack and the second function call stack from the top to the bottom of the stack as an example, but the embodiments of the present application are not limited thereto. In the embodiments of the present application, the first function call stack and the second function call stack can also be traversed from the bottom to the top of the stack.

[0096] In the embodiments of the present application, during the execution of a program written in a mixed language, function call stacks of different languages can be captured separately, and then the corresponding relationship between the boundary stack frames in the first language function call stack and the stack frames in the second language function call stack can be identified and determined. Furthermore, based on this corresponding relationship and the function call stacks of different languages, a mixed function call stack can be determined. This mixed function call stack can truly reflect the function call situation and can help developers judge performance bottlenecks.

[0097] In some embodiments, the second function call stack may further include one or more second-type boundary stack frames. In these embodiments, S303, determining a third function call stack according to the first function call stack, the second function call stack, and the corresponding relationship includes: determining the third function call stack according to the first function call stack, the second function call stack, the corresponding relationship, and the position of the second-type boundary stack frame in the second function call stack.

[0098] Specifically, when a function in the second language calls a function in the first language, a second-type boundary stack frame will be pushed onto the second function call stack, that is, the position where the function in the second language calls the function in the first language is determined. Furthermore, in combination with the corresponding relationship between the first-type boundary stack frame and the stack frames in the second function call stack, and the position of the second-type boundary stack frame in the second function call stack, the first function call stack and the second function call stack can be spliced to determine the third function call stack. The first function call stack includes stack frames corresponding to M functions in the first language and stack frames corresponding to N functions in the second language.

[0099] It can be understood that since the second-type boundary function indicates that a function in the second language calls a function in the first language, when splicing the stack frames, the stack frames corresponding to the functions in the first language with a call relationship can be spliced above the stack frames corresponding to the functions in the second language. That a stack frame described in the embodiments of the present application is above another stack frame can be understood as that the stack frame above is closer to the stack top.

[0100] For example, during the actual running of the program, the main function is the entry point of the program. The main function calls JavaScript function #1 through an external call to an internal boundary function, and then JavaScript function #1 calls C++ function #1 through an internal call to an external boundary function. During the running of the program, the first function call stack and the second function call stack as shown in Figure 7 can be generated.

[0101] As shown in Figure 7As shown, the first function call stack includes stack frame #1 and stack frame #2, and the second function call stack includes stack frame #3, stack frame #4, the stack frame of the main function, and the stack frame of the internal C++ function of the engine. Among them, stack frame #1 corresponds to JavaScript function #1, stack frame #2 is the first type of boundary stack frame, stack frame #2 includes the identification information of stack frame #4, stack frame #3 is the second type of boundary stack frame, and stack frame #5 corresponds to C++ function #1.

[0102] Continue to refer to Figure 7 , when determining the third function call stack, the first function call stack and the second function call stack can be traversed separately from the top to the bottom of the stack to find the first type of boundary stack frame in the first function call stack, that is, stack frame #2, and then determine a stack frame in the second function call stack according to the identification information in stack frame #2, that is, stack frame #4. After finding stack frame #4 in the second function call stack, the first second type of boundary stack frame located below stack frame #4 can be continued to be searched, that is, stack frame #3, and then stack frame #1 located below stack frame #2 can be spliced between stack frame #3 and stack frame #4, that is, stack frame #1 is located below stack frame #4. Since stack frame #1 is already at the bottom of the stack and there is no stack frame corresponding to a C++ function other than the internal C++ function of the engine in the second function call stack, the splicing can be ended to generate the third function call stack. From the bottom to the top of the third function call stack, stack frame #4 is located above stack frame #1.

[0103] For another example, during the actual running process of the program, the main function is the entry point of the program. The main function calls JavaScript function #1 by calling the external-internal boundary function #1, then JavaScript function #1 calls JavaScript function #2, then JavaScript function #2 calls C++ function #1 by calling the internal-external boundary function, and then C++ function #1 calls JavaScript function #3 by calling the external-internal boundary function #2. During the running process of the program, the first function call stack and the second function call stack as shown in Figure 8 can be generated.

[0104] Such as Figure 8As shown in the figure, the first function call stack includes stack frames #1, #2, #3, and #4, and the second function call stack includes stack frames #5, #6, #7, the stack frame of the main function, and the stack frame of the internal C++ function of the engine. Among them, stack frame #1 corresponds to JavaScript function #1, stack frame #2 corresponds to JavaScript function #2, stack frame #3 is the first type of boundary stack frame corresponding to the internal call external boundary function, stack frame #3 includes the identification information of stack frame #6, stack frame #4 corresponds to JavaScript function #3, stack frame #5 is the second type of boundary stack frame corresponding to the external call internal boundary function #1, stack frame #6 corresponds to C++ function #1, and stack frame #7 is the second type of boundary stack frame corresponding to the external call internal boundary function #2.

[0105] Continue to refer to Figure 8 , when determining the third function call stack, the first function call stack and the second function call stack can be traversed separately from the top to the bottom of the stack to find the first type of boundary stack frame in the first function call stack, that is, stack frame #3, and then determine a stack frame in the second function call stack according to the identification information in stack frame #3, that is, stack frame #6. After finding stack frame #6 in the second function call stack, the first second type of boundary stack frame located below stack frame #6 can be continued to be searched, that is, stack frame #5, and since stack frame #1 is already at the bottom of the stack, stack frames #1 and #2 located below stack frame #3 can be spliced between stack frames #6 and #5, that is, stack frames #1 and #2 are located below stack frame #6.

[0106] Continue to refer to Figure 8 , since the second function call stack also includes a second type of boundary stack frame, that is, stack frame #7, and the first function call stack still has an unspliced stack frame #4 and stack frame #4 is at the top of the stack, indicating that C++ function #1 corresponding to stack frame #6 calls JavaScript function #3 corresponding to stack frame #4, then according to the position of stack frame #7 in the second function call stack, stack frame #4 can be continued to be spliced above stack frame #6 to generate the third function call stack. Looking from the bottom to the top of the third function call stack, they are stack frame #1, stack frame #2, stack frame #6, and stack frame #4 in sequence.

[0107] In the examples introduced above, it is assumed that the first function call stack and the second function call stack include 1 first type of boundary stack frame, but the embodiments of the present application are not limited thereto. In other embodiments of the present application, the first function call stack may include the first type of boundary stack frame. The first function call stack includes multiple first type of boundary stack frames, indicating that the function of the first language calls the function of the second language multiple times in the program. Then, when splicing the stack frames, the stack frames between two adjacent first type of boundary stack frames can be taken as a whole for splicing with the first type of boundary stack frame as the boundary. The following combines Figure 9Introduce it in detail.

[0108] For example, during the actual operation of the program, the main function is the entry point of the program. The main function calls JavaScript function #1 by invoking the inner-to-outer boundary function #1, then JavaScript function #1 calls JavaScript function #2, then JavaScript function #2 calls C++ function #1 by invoking the outer-to-inner boundary function #1, then C++ function #1 calls C++ function #2, then C++ function #2 calls JavaScript function #3 by invoking the outer-to-inner boundary function #2, then JavaScript function #3 calls JavaScript function #4, and then JavaScript function #4 calls C++ function #3 by invoking the outer-to-inner boundary function #2. During the operation of the program, the first function call stack and the second function call stack as shown in Figure 9 can be generated.

[0109] As Figure 9 shown, the first function call stack includes stack frames #1, #2, #3, #4, #5, and #6, and the second function call stack includes stack frames #7, #8, #9, #10, and #11. Among them, stack frame #1 is the stack frame corresponding to JavaScript function #1, stack frame #2 is the stack frame corresponding to JavaScript function #2, stack frame #3 is the first-type boundary stack frame corresponding to the inner-to-outer boundary function #1, stack frame #3 includes the identification information of stack frame #8, stack frame #4 is the stack frame corresponding to JavaScript function #3, stack frame #5 is the stack frame corresponding to JavaScript function #4, stack frame #6 is the first-type boundary stack frame corresponding to the inner-to-outer boundary function #2, stack frame #6 includes the identification information of stack frame #11, stack frame #7 is the second-type boundary stack frame corresponding to the outer-to-inner boundary function #1, stack frame #8 is the stack frame corresponding to C++ function #1, stack frame #9 is the stack frame corresponding to C++ function #2, stack frame #10 is the second-type boundary stack frame corresponding to the outer-to-inner boundary function #2, and stack frame #11 is the stack frame corresponding to C++ function #3.

[0110] Continue to refer to Figure 9, when determining the third function call stack, the first function call stack and the second function call stack can be traversed respectively from the top to the bottom of the stack. After finding the first type of boundary stack frame in the first function call stack, that is, stack frame #6, then stack frame #11 can be determined according to the identification information of stack #6. The first type of boundary stack frame below stack frame #11 can be continuously searched, that is, stack frame #10. And since there is also a first type of boundary stack frame below stack frame #6, that is, stack frame #3, indicating that the JavaScript function has called the C++ function twice, then the stack frames #4 and #5 between stack frame #3 and stack frame #6 can be spliced between stack frame #11 and stack frame #10, that is, stack frames #5 and #4 are below stack frame #11 and above stack frame #10.

[0111] And so on, continue to search downward for the stack frame in the second function call stack that has a corresponding relationship with stack frame #3, that is, stack frame #8, and the first type of boundary stack frame below stack frame #8, that is, stack frame #7. And since stack frame #1 is already at the bottom of the first function call stack, stack frames #1 and #2 can be spliced between stack frame #8 and stack frame #7, that is, stack frames #1 and #2 are below stack frame #8. Since stack frame #1 is already at the bottom of the first function call stack, and there is no stack frame corresponding to the C++ function other than the engine internal C++ function in the second function call stack, the third function call stack can be generated. From the bottom to the top of the third function call stack, they are stack frame #1, stack frame #2, stack frame #8, stack frame #9, stack frame #4, stack frame #5, and stack frame #11 in turn.

[0112] In the embodiment of the present application, during the execution of a program using mixed language programming, the function call stacks of different languages can be captured respectively, and then the corresponding relationship between the first type of boundary stack frame in the function call stack of the first language and the stack frames in the function call stack of the second language can be identified and determined. Furthermore, according to this corresponding relationship and the function call stacks of different languages, the mixed function call stack can be determined. The mixed function call stack can truly reflect the function call situation and can help developers judge the performance bottleneck.

[0113] Figure 10 The schematic flowchart of another method for determining the function call situation provided by the embodiment of the present application is shown, as Figure 10 shown, the method includes:

[0114] S1001, execute the first program.

[0115] Among them, the first program is a program written in the first language and calling the second language function. The first program includes M functions of the first language and N functions of the second language, M≥1, N≥1, and M and N are integers. <00, when determining the third function call stack, the first function call stack and the second function call stack can be traversed respectively from the top to the bottom of the stack. After finding the first type of boundary stack frame in the first function call stack, that is, stack frame #6, then stack frame #11 can be determined according to the identification information of stack #6. The first type of boundary stack frame below stack frame #11 can be continuously searched, that is, stack frame #10. And since there is also a first type of boundary stack frame below stack frame #6, that is, stack frame #3, indicating that the JavaScript function has called the C++ function twice, then the stack frames #4 and #5 between stack frame #3 and stack frame #6 can be spliced between stack frame #11 and stack frame #10, that is, stack frames #5 and #4 are below stack frame #11 and above stack frame #10.

[0111] And so on, continue to search downward for the stack frame in the second function call stack that has a corresponding relationship with stack frame #3, that is, stack frame #8, and the first type of boundary stack frame below stack frame #8, that is, stack frame #7. And since stack frame #1 is already at the bottom of the first function call stack, stack frames #1 and #2 can be spliced between stack frame #8 and stack frame #7, that is, stack frames #1 and #2 are below stack frame #8. Since stack frame #1 is already at the bottom of the first function call stack, and there is no stack frame corresponding to the C++ function other than the engine internal C++ function in the second function call stack, the third function call stack can be generated. From the bottom to the top of the third function call stack, they are stack frame #1, stack frame #2, stack frame #8, stack frame #9, stack frame #4, stack frame #5, and stack frame #11 in turn.

[0112] In the embodiment of the present application, during the execution of a program using mixed language programming, the function call stacks of different languages can be captured respectively, and then the corresponding relationship between the first type of boundary stack frame in the function call stack of the first language and the stack frames in the function call stack of the second language can be identified and determined. Furthermore, according to this corresponding relationship and the function call stacks of different languages, the mixed function call stack can be determined. The mixed function call stack can truly reflect the function call situation and can help developers judge the performance bottleneck.

[0113] Figure 10 The schematic flowchart of another method for determining the function call situation provided by the embodiment of the present application is shown, as Figure 10 shown, the method includes:

[0114] S1001, execute the first program.

[0115] Among them, the first program is a program written in the first language and calling the second language function. The first program includes M functions of the first language and N functions of the second language, M≥1, N≥1, and M and N are integers.

[0116] S1002. Construct a first function call stack and a second function call stack according to the first program. When constructing the first function call stack, generate M first-type stack frames and M second-type stack frames. The M first-type stack frames and the M second-type stack frames are associated and correspond to the functions of the M first languages. The M first-type stack frames are pushed onto the first function call stack. When constructing the second function call stack, generate N second-type stack frames. The N second-type stack frames correspond to the functions of the N second languages. The M second-type stack frames and the N second-type stack frames are pushed onto the second function call stack.

[0117] Specifically, when executing the first program, a first function call stack and a second function call stack can be constructed. The first function call stack corresponds to the first language, and the second function call stack corresponds to the second language. In other words, when executing the first program, stack frames corresponding to M functions of the first language are constructed and pushed onto the first function call stack, and stack frames corresponding to N functions of the second language are constructed and pushed onto the second function call stack. In the embodiments of the present application, the stack frames corresponding to the functions of the first language can be referred to as first-type stack frames, and the stack frames corresponding to the functions of the second language can be referred to as second-type stack frames.

[0118] In the embodiments of the present application, when constructing the first function call stack, M second-type stack frames associated with the M first-type stack frames can also be formed. It can be understood that the M second-type stack frames also correspond to the M functions of the first language. The M second-type stack frames will also be pushed onto the second function call stack. In other words, the second function call stack includes the M second-type stack frames and the N second-type stack frames, where the M second-type stack frames correspond to the M functions of the first language, and the N second-type stack frames correspond to the N functions of the second language.

[0119] In some embodiments, each of the M second-type stack frames includes identification information, which is used to indicate the first-type stack frame associated with it, or the identification information is used to indicate the function of the first language corresponding to it.

[0120] It can be understood that when pushing the M second-type stack frames and the N second-type stack frames onto the second function call stack, they are pushed in the call order between the functions. The following is combined with Figure 11 for a detailed introduction.

[0121] For example, as Figure 11As shown, during the actual operation of the program, the main function is the entry point of the program. The main function calls JavaScript function #1 by invoking the inner boundary function #1 externally. Then, JavaScript function #1 calls JavaScript function #2. Subsequently, JavaScript function #2 calls C++ function #1 by invoking the outer boundary function #1 internally. Then, C++ function #1 calls C++ function #2. Next, C++ function #2 calls JavaScript function #3 by invoking the inner boundary function #2 externally. Then, JavaScript function #3 calls JavaScript function #4. Finally, JavaScript function #4 calls C++ function #3 by invoking the outer boundary function #2 internally.

[0122] During the execution of the above program, stack frames corresponding to each function will be generated. In addition, for each JavaScript function, it will be divided into two stack frames, namely the first type of stack frame and the second type of stack frame, and they will be pushed onto the first function call stack and the second function call stack respectively to generate the first function call stack and the second function call stack.

[0123] Continue to refer to Figure 11 , the first function call stack includes stack frames #1, #2, #3, #4, #5, and #6. Among them, stack frame #1 is the first type of stack frame corresponding to JavaScript function #1, stack frame #2 is the first type of stack frame corresponding to JavaScript function #2, stack frame #3 is the first type of boundary stack frame corresponding to the inner call outer boundary function #1, stack frame #4 is the first type of stack frame corresponding to JavaScript function #3, stack frame #5 is the first type of stack frame corresponding to JavaScript function #4, and stack frame #6 is the first type of boundary stack frame corresponding to the inner call outer boundary function #2. The second function call stack includes stack frames #7, #8, #9, #10, #11, #12, #13, #14, and #15. Stack frame #7 is the second type of boundary stack frame corresponding to the outer call inner boundary function #1, stack frame #8 is the second type of stack frame corresponding to JavaScript function #1, stack frame #9 is the second type of stack frame corresponding to JavaScript function #2, stack frame #10 is the stack frame corresponding to C++ function #1, stack frame #11 is the stack frame corresponding to C++ function #2, stack frame #12 is the second type of boundary stack frame corresponding to the outer call inner boundary function #2, stack frame #13 is the second type of stack frame corresponding to JavaScript function #3, stack frame #14 is the second type of stack frame corresponding to JavaScript function #4, and stack frame #15 is the stack frame corresponding to C++ function #3.

[0124] S1003. Determine a third function call stack according to the positional relationship between the M second-type stack frames and the N second-type stack frames in the second function call stack.

[0125] Specifically, since the second function call stack includes the second-type stack frames corresponding to the functions in the first language and the second-type stack frames corresponding to the functions in the second language, the second function call stack can be traversed. When a second-type stack frame corresponding to a function in the first language is traversed, since the second-type stack frame corresponding to a function in the first language includes identification information, the information of the first-type stack frame associated therewith can be obtained through the identification information to determine the function in the first language associated therewith, or the function in the first language corresponding thereto can be directly determined through the identification information. Therefore, the third function call stack can be determined according to the positional relationship between the M second-type stack frames and the N second-type stack frames in the second function call stack. The third function call stack can include the stack frames corresponding to the M functions in the first language and the stack frames corresponding to the N functions in the second language.

[0126] For example, continuing to refer to Figure 11 , after pushing the second-type stack frames corresponding to the M functions in the first language onto the second function call stack, the second function call stack includes the second-type stack frames corresponding to the M functions in the first language and the second-type stack frames corresponding to the N functions in the second language. According to the second function call stack, a third function call stack can be finally generated. From the bottom to the top of the third function call stack, they are, in sequence, stack frame #1, stack frame #2, stack frame #10, stack frame #11, stack frame #4, stack frame #5, stack frame #15.

[0127] In some embodiments, the third function call stack may further include a first-type boundary stack frame, a second-type boundary stack frame, and / or a stack frame of an engine internal C++ function.

[0128] In the embodiments of the present application, when constructing the first-type stack frames in the first function call stack, the second-type stack frames associated with the first-type stack frames can be synchronously generated and pushed onto the second function call stack. When it is necessary to determine the function call situation, only the second function call stack can be captured, and the functions corresponding to the second-type stack frames associated with the first-type stack frames can be obtained through the second function call stack, and then the mixed function call stack can be determined. The mixed function call stack can truly reflect the function call situation and can help developers judge the performance bottleneck.

[0129] Figure 12 shows a schematic structural diagram of a device for determining a function call situation provided by an embodiment of the present application. As Figure 12 shown, the device 1200 includes:

[0130] An execution unit 1210, configured to execute a first program.

[0131] The sampling unit 1220 is configured to capture the first function call stack and the second function call stack when executing the first program.

[0132] The processing unit 1230 is configured to determine a correspondence between the first-type boundary stack frame and stack frames in the second function call stack according to the identification information of the first-type boundary stack frame in the first function call stack.

[0133] The processing unit 1230 is further configured to determine a third function call stack according to the first function call stack, the second function call stack, and the corresponding relationship.

[0134] In some embodiments, the second function call stack also includes a second type boundary stack frame, and the processing unit 1230 is specifically used to determine the third function call stack based on the first function call stack, the second function call stack, the correspondence and the position of the second type boundary stack frame in the second function call stack.

[0135] In some other embodiments, the execution unit 1210 is configured to execute the first program.

[0136] Processing unit 1230 is used to construct a first function call stack and a second function call stack according to the first program, wherein, when constructing the first function call stack, M first-type stack frames and M second-type stack frames are generated, the M first-type stack frames and the M second-type stack frames are associated and correspond to the M functions of the first language, and the M first-type stack frames are pushed into the first function call stack; when constructing the second function call stack, N second-type stack frames are generated, the N second-type stack frames correspond to the N functions of the second language, and the M second-type stack frames and the N second-type stack frames are pushed into the second function call stack.

[0137] The processing unit 1230 is further configured to determine a third function call stack according to the second function call stack, where the third function call stack includes M stack frames corresponding to the first language functions and N stack frames corresponding to the second language functions.

[0138] Specifically, the specific execution process of the device 1200 can be found in the description above and will not be repeated here.

[0139] Figure 13 FIG. 1 shows a schematic diagram of the hardware structure of a computer device in an embodiment of the present application. Figure 13 As shown, device 1300 includes a processor 1301, a memory 1302, an interface circuit 1303, and a bus 1304. The processor 1301, memory 1302, and interface circuit 1303 perform data transmission via bus 1304. Memory 1302 stores instructions. When the instructions are executed by processor 1301, processor 1301 implements the technical solutions described in the above embodiments. The implementation principles and technical effects are similar to those of the above-mentioned method embodiments and will not be further elaborated here.

[0140] An embodiment of the present application provides a computer program product. When the computer program product runs on a computer device, the computer device is caused to execute the technical solutions in the above embodiments. Its implementation principle and technical effects are similar to those of the related embodiments of the above method, and will not be elaborated here.

[0141] An embodiment of the present application provides a readable storage medium. The readable storage medium contains instructions. When the instructions run on a computer device, the computer device is caused to execute the technical solutions of the above embodiments. Its implementation principle and technical effects are similar, and will not be elaborated here.

[0142] An embodiment of the present application provides a chip. The chip is used to execute instructions. When the chip runs, it executes the technical solutions in the above embodiments. Its implementation principle and technical effects are similar, and will not be elaborated here.

[0143] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiments of the present application.

[0144] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated here.

[0145] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling, direct coupling, or communication connection can be through some interfaces. The indirect coupling or communication connection of the devices or units can be in an electrical, mechanical, or other form.

[0146] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0147] In addition, in each embodiment of the present application, each functional unit may be integrated into one processing unit, may exist physically alone for each unit, or two or more units may be integrated into one unit.

[0148] If the above-mentioned function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.

[0149] As described above, the above are only the specific implementation manners of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed in the embodiments of the present application can easily think of changes or substitutions, which should all be covered by the protection scope of the embodiments of the present application. Therefore, the protection scope of the embodiments of the present application should be subject to the protection scope of the claims.

Claims

1. A method for determining function call situations, characterized in that, The method includes: Executing a first program to capture a first function call stack and a second function call stack, where the first program is a program written in a first language and calls a second language function, the second function call stack corresponds to the second language, the first function call stack includes stack frames corresponding to M first language functions, the second function call stack includes stack frames corresponding to N second language functions, the first function call stack further includes a first type of boundary stack frame, and the first type of boundary stack frame is used to indicate the position where a function in the first language calls a function in the second language, M≥1, N≥1, and M and N are integers; Determining the correspondence between the first type of boundary stack frame in the first function call stack and the stack frames in the second function call stack according to the identification information of the first type of boundary stack frame in the first function call stack; Determining a third function call stack according to the first function call stack, the second function call stack, and the correspondence, where the third function call stack includes the stack frames corresponding to the M first language functions and the stack frames corresponding to the N second language functions.

2. The method according to claim 1, characterized in that The second function call stack further includes a second type of boundary stack frame, and the second type of boundary stack frame is used to indicate the position where a function in the second language calls a function in the first language. Determining the third function call stack according to the first function call stack, the second function call stack, and the correspondence includes: Determining the third function call stack according to the first function call stack, the second function call stack, the correspondence, and the position of the second type of boundary stack frame in the second function call stack.

3. The method according to claim 1 or 2, characterized in that, The identification information is a function pointer.

4. The method according to claim 3, wherein The identification information further includes a program counter PC value.

5. The method according to any one of claims 1 to 4, characterized in that The first language is the JavaScript language, and the second language is the C++ language or the C language.

6. A device, characterized in that, The apparatus includes an execution unit, a sampling unit, and a processing unit. The execution unit is used to execute a first program, where the first program is a program written in a first language and calls a second language function; The sampling unit is used to capture a first function call stack and a second function call stack, the second function call stack corresponds to the second language, the first function call stack includes stack frames corresponding to M first language functions, the second function call stack includes stack frames corresponding to N second language functions, the first function call stack further includes a first type of boundary stack frame, and the first type of boundary stack frame is used to indicate the position where a function in the first language calls a function in the second language, M≥1, N≥1, and M and N are integers; The processing unit is used to determine the correspondence between the first type of boundary stack frame in the first function call stack and the stack frames in the second function call stack according to the identification information of the first type of boundary stack frame in the first function call stack; The processing unit is further used to determine a third function call stack according to the first function call stack, the second function call stack, and the correspondence, where the third function call stack includes the stack frames corresponding to the M first language functions and the stack frames corresponding to the N second language functions.

7. The device according to claim 6, characterized in that, The second function call stack further includes second-type boundary stack frames, where the second-type boundary stack frames are used to indicate the positions where functions of the second language call functions of the first language. The processing unit is specifically configured to determine the third function call stack according to the first function call stack, the second function call stack, the corresponding relationship, and the positions of the second-type boundary stack frames in the second function call stack.

8. The device according to claim 6 or 7, characterized in that, The identification information is a function pointer.

9. The device according to claim 8, characterized in that, The identification information further includes the program counter PC value.

10. The device according to any one of claims 6 to 9, characterized in that, The first language is the JavaScript language, and the second language is the C++ language or the C language.

11. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and when the computer program is executed by a computer, the method according to any one of claims 1 to 5 is implemented.

12. A chip, characterized in that, The chip includes a processor and a data interface, and the processor reads instructions stored on a memory through the data interface to execute the method according to any one of claims 1 to 5.

13. A computer device, characterized in that, It includes one or more processors; one or more memories; one or more computer programs are stored in the one or more memories, and the one or more computer programs include instructions, and when the instructions are executed by the one or more processors, the method according to any one of claims 1 to 5 is executed.

14. A computer program product, characterized in that, When the computer program product runs on a computer, the computer is caused to execute the method according to any one of claims 1 to 5.