Bytecode execution method, operating system, virtual machine, electronic equipment and terminal

By optimizing the virtual machine stack structure and retaining only the local variable area and operand stack, the problems of large memory consumption and low execution efficiency caused by the complex virtual machine stack frame structure are solved, achieving concise and efficient bytecode execution, which is suitable for various devices.

CN121636042APending Publication Date: 2026-03-10BEIJING CEC HUADA ELECTRONIC DESIGN CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

The existing virtual machine stack has a complex stack frame structure, which results in a large virtual machine memory footprint and low bytecode interpretation and execution efficiency, especially on resource-constrained devices.

Method used

The virtual machine stack structure is optimized to include only the local variable area and operand stack, complex function structures and branch block structures are removed, a stack frame structure corresponding to the target function is generated, and the bytecode generated by compiling the target function is executed sequentially.

Benefits of technology

It simplifies the virtual machine stack frame structure, reduces memory footprint, improves read/write performance and bytecode interpretation and execution efficiency, is suitable for both resource-constrained and non-resource-constrained devices, and ensures the security of function call processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121636042A_ABST
    Figure CN121636042A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a byte code execution method, an operating system, a virtual machine, electronic equipment and a terminal. The byte code execution method comprises the following steps: in response to calling of a target function, generating a stack frame structure corresponding to the target function in a virtual machine stack; wherein the virtual machine stack comprises a local variable region, an operand stack and a frame context, or the virtual machine stack comprises a local variable region and an operand stack; and according to the stack frame structure of the target function, executing byte codes formed by compiling the target function in sequence. According to the technical scheme provided by the embodiment of the invention, the simplicity of a stack structure of the virtual machine and the convenience of read-write operation are improved, and the memory space occupation of the virtual machine can be reduced, so that the memory space utilization rate of the virtual machine and the read-write performance of the virtual machine are improved, and the byte code interpretation execution efficiency of the virtual machine is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer software application technology, and in particular to a bytecode execution method, apparatus, operating system, virtual machine, electronic device, terminal, medium and program. Background Technology

[0002] For resource-constrained devices, the virtual machine stack can be used to store method call and return information of AOS (Multi-Application Smartcard Operation System) applications, including local variables, method parameters, intermediate execution results, return values, and method call information, and is also known as the virtual machine (running) call stack.

[0003] Currently, the stack frame structure of a commonly used virtual machine stack contains data such as the operand stack, the current PC (Program Counter) pointer, the current function structure variable, and the stack frame pointer of the previous function. Its operand stack contains pointers related to the top and bottom of the operand stack and pointers related to branch blocks. The pointers related to branch blocks and jump-related instructions are related to bytecode execution.

[0004] In the process of implementing this application, the inventors discovered the following defects in the related technology: The current virtual machine stack frame structure is relatively complex, such as the structure of function structure variables and branch block structure variables, which are very complex. For resource-constrained devices, the virtual machine memory space required is very large, and the efficiency of virtual machine bytecode interpretation and execution is also relatively low. Summary of the Invention

[0005] This application provides a bytecode execution method, apparatus, operating system, virtual machine, electronic device, terminal, medium, and program, which improves the simplicity of the virtual machine stack structure and the convenience of read and write operations, reduces the virtual machine memory space occupation, thereby improving the virtual machine memory space utilization and virtual machine read and write performance, and improving the efficiency of virtual machine bytecode interpretation and execution.

[0006] According to one aspect of this application, a bytecode execution method is provided, applied to a virtual machine, comprising:

[0007] In response to the invocation of the target function, a stack frame structure corresponding to the target function in the virtual machine stack is generated; wherein, the virtual machine stack includes a local variable area, an operand stack, and a frame context, or, the virtual machine stack includes a local variable area and an operand stack;

[0008] The bytecode compiled from the target function is executed sequentially according to the stack frame structure of the target function.

[0009] According to another aspect of this application, a bytecode execution device is provided, configured in a virtual machine, comprising:

[0010] A stack frame structure generation module is used to generate a stack frame structure corresponding to the target function in the virtual machine stack in response to the target function being called; wherein, the virtual machine stack includes a local variable area, an operand stack, and a frame context, or, the virtual machine stack includes a local variable area and an operand stack;

[0011] The bytecode execution module is used to execute the bytecode compiled from the target function sequentially according to the stack frame structure of the target function.

[0012] According to another aspect of this application, an operating system is provided, wherein a runtime environment is executed in the operating system, and the operating system executes the bytecode execution method described in any embodiment of this application through the runtime environment.

[0013] According to another aspect of this application, a virtual machine is provided, which runs on an operating system, and the operating system executes a runtime environment, through which the operating system executes the bytecode execution method described in any embodiment of this application.

[0014] According to another aspect of this application, an electronic device is provided, on which the operating system described above is installed, the electronic device comprising:

[0015] At least one processor; and

[0016] A memory communicatively connected to the at least one processor; wherein,

[0017] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to execute the bytecode execution method described in any embodiment of this application.

[0018] According to another aspect of this application, a terminal is provided, including the electronic device described above.

[0019] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute the bytecode execution method described in any embodiment of this application.

[0020] According to another aspect of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the bytecode execution method described in any embodiment of this application.

[0021] This application embodiment generates a stack frame structure corresponding to the target function in the virtual machine stack in response to the target function being called, and executes the bytecode compiled from the target function sequentially according to the stack frame structure of the target function. Since the virtual machine stack in this embodiment includes a local variable area, an operand stack, and a frame context, or only includes a local variable area and an operand stack, the stack frame structure of the virtual machine stack is optimized. This solves the problem of poor virtual machine read / write performance due to the complex stack frame structure of existing virtual machine stacks, improves the simplicity of the virtual machine stack structure and the convenience of read / write operations, reduces virtual machine memory space usage, thereby improving virtual machine memory space utilization and virtual machine read / write performance, and improving the efficiency of virtual machine bytecode interpretation and execution.

[0022] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 This is a flowchart of a bytecode execution method provided in an embodiment of this application;

[0025] Figure 2 This is a schematic diagram of a virtual machine stack structure provided in an embodiment of this application;

[0026] Figure 3 This is a flowchart of another bytecode execution method provided in the embodiments of this application;

[0027] Figure 4 This is a schematic diagram illustrating the effect of changes in the virtual machine stack structure before and after a function call, provided in an embodiment of this application.

[0028] Figure 5 This is a schematic diagram of a virtual machine interpreter execution flow provided in an embodiment of this application;

[0029] Figure 6 This is a schematic diagram of a virtual machine performing exception handling according to an embodiment of this application;

[0030] Figure 7 This is a schematic diagram of another virtual machine exception handling process provided in an embodiment of this application;

[0031] Figure 8 This is a schematic diagram of a bytecode execution device provided in an embodiment of this application;

[0032] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0033] Figure 10 This is a structural diagram of a terminal provided according to an embodiment of this application. Detailed Implementation

[0034] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0035] It should be noted that the terms "first," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0036] Figure 1 This is a flowchart of a bytecode execution method provided in an embodiment of this application. This embodiment is applicable to situations where a virtual machine executes bytecode based on a structure-optimized virtual machine stack. This method can be executed by a bytecode execution device, which can be implemented in software and / or hardware, and is generally integrated into an electronic device. This electronic device can be a terminal device; however, this application does not limit the specific type of electronic device. Correspondingly, as... Figure 1 As shown, the method includes the following operations:

[0037] S110. In response to the target function being called, generate the stack frame structure corresponding to the target function in the virtual machine stack; wherein, the virtual machine stack includes a local variable area, an operand stack, and a frame context, or, the virtual machine stack includes a local variable area and an operand stack.

[0038] The target function can be the function currently called by the virtual machine. The virtual machine stack stores stack frames, including parameters, local variables, intermediate results, return values, and method call information. The local variable area stores function-related local variable information. Optionally, the local variable area can store function parameters and local variables. The operand stack is a temporary data storage area within the virtual machine stack used for computation. Specifically, the operand stack is a stack-like structure used to store the operands required for instruction execution. The frame context can be used to store information about the function containing the instruction before the function call, including the function structure address, PC pointer, execution domain, and bottom of the function stack frame. This information ensures the normal return of the function call.

[0039] Function calls in the virtual machine create a stack frame structure and push it onto the virtual machine stack. In the virtual machine, the stack frame is a data structure used to support method calls and execution; it is a stack element in the virtual machine stack within the runtime data area. Each function call, from initiation to completion, corresponds to a stack frame being pushed onto and popped off the virtual machine stack. When a function returns, the corresponding stack frame is popped from the call stack and destroyed. A function call is essentially the process of creating and destroying stack frames. However, at any given time, only the stack frame at the top or bottom of the call stack is active; this is known as the current stack frame. Therefore, when the virtual machine calls a target function, it needs to generate a corresponding stack frame structure for that function on the virtual machine stack.

[0040] In this embodiment, the virtual machine stack may include three data types: a local variable area, an operand stack, and a frame context. Alternatively, the virtual machine stack may only include the local variable area and the operand stack. That is, the frame context may be stored in the virtual machine stack space or in other locations, such as in other separate memory spaces, as long as the virtual machine's need for fast read and write access to the frame context is met. This embodiment does not limit the storage location of the frame context. In addition, the virtual machine stack may also include control block information, which is used during the execution of control instructions.

[0041] Therefore, it can be seen that the virtual machine stack structure in this embodiment does not contain complex structure structures such as function structure variables and branch block structure variables, thus optimizing the virtual machine stack structure. The optimized virtual machine stack structure is clear, removing control block structures related to control instructions, making the virtual machine stack frame structure simpler, requiring less storage space, and allowing for more direct read and write operations, thereby improving read and write performance. Furthermore, the aforementioned virtual machine stack has greater applicability, suitable for both resource-constrained and non-resource-constrained devices, and features enhanced security and efficiency.

[0042] In an optional embodiment of this application, the local variable area may include at least one of the following: function parameters and local variables. The operand stack may include operands required to execute instructions. The frame context may include at least one of the following: the function structure address of the function containing the instruction before the function call, the PC pointer, the execution domain, and the bottom of the function stack frame.

[0043] Each function has its own local variable area and operand stack. Each function corresponds to a stack frame (simply called a frame). Each function call generates a new stack frame, which is located above or below the frame containing the calling function. Figure 2 This is a schematic diagram of a virtual machine stack structure provided in an embodiment of this application. In a specific example, such as... Figure 2 As shown, function 1 corresponds to frame 1 in the virtual machine stack. When function 1 calls function 2, function 2 corresponds to frame 2 in the virtual machine stack. Each stack frame structure in the virtual machine stack stores the parameters (Func Args) and local variable information (Func Local) of the corresponding function. These constitute the local variable area of ​​the corresponding frame. Above the local variable area is the operand stack of the function, which is the space required for operands during the execution of the function body instructions. Optionally, the frame context in the virtual machine stack space can grow from top to bottom, or it can grow from bottom to top. This embodiment does not limit the data filling order of the frame context in the virtual machine stack space. Specifically, each frame context can store some context information of the function corresponding to that frame, so that the function executed before the call can be correctly returned after the function call.

[0044] Optional, such as Figure 2As shown, the information in the frame context may include, but is not limited to: Module ID, the function structure address of the function containing the instructions before the function call (i.e., the current function address), the bottom of the function stack frame, the current execution domain, and the PC pointer. The Module ID identifies the module to which the function belongs, allowing you to find the module it belongs to. The current function address helps obtain function-related information such as the number of parameters and local variables, including but not limited to function size, the starting address of the function code, the ending address of the function code, and the size of other memory spaces used by the function. The bottom of the function stack frame is the starting address of the function frame. The current execution domain identifies the execution domain to which the current function belongs, used for access control security. For resource-constrained devices, the execution domain is also called the Virtual RunDomain, referring to the virtual memory space where the application running on the logical channel resides. The execution domain records information about the application running on the current logical channel, module information, and virtual memory space information, used to check the security access policies for application data access on the current logical channel. The PC pointer is the position where the function execution reached when the function call occurred, used to return to this position to continue execution after the function call ends. Figure 2 As shown, `top` during initialization can be the top of the frame context in the initialization state (when the frame context is empty). `Frame_sp` refers to the stack pointer `SP` (StackPointer), used to point to the top of the stack. Here, `Frame_1p` refers to the bottom of frame 1. `Frame_sp` refers to the top of frame s, `Frame_sp_boundary` refers to the upper boundary of frame s, and `Frame_sp_bottom` refers to the lower boundary of frame s. `frame_context_top` refers to the top of the frame context.

[0045] Optionally, the frame context may also include the function size, the number of function parameters, the number of function local variables, whether the function has a return value, the function bytecode start offset (or address), and the function bytecode end offset (or address). This information can help return to the function position before the call more quickly after the function is called, and can be used for security checks to prevent function address out-of-bounds or exceptions caused by security attacks.

[0046] It should be noted that, Figure 2 This illustration only shows that the frame context can grow in a top-down direction, while the virtual machine's stack frame can grow in a bottom-up direction. Optionally, the frame context can also grow from bottom to top, while the virtual machine's stack frame can grow from top to bottom; this embodiment does not impose any limitations on this.

[0047] In related technologies, virtual machines do not restrict function calls between different modules, thus failing to guarantee the security of cross-module function calls and making them unsuitable for use scenarios with higher security requirements.

[0048] In an optional embodiment of this application, functions in different runtime domains can call each other under authorized conditions. That is, in this embodiment, functions in different runtime domains cannot call each other unless authorized between the different runtime domains. The advantage of this setting is that by configuring the stack frame structure of the virtual machine stack to determine the runtime domain to which a module function belongs, security during function calls can be ensured, preventing unauthorized function calls.

[0049] S120. Execute the bytecode compiled from the target function sequentially according to the stack frame structure of the target function.

[0050] Understandably, after the target function is compiled, it will form a series of bytecode. When the virtual machine calls the target function, the internal interpreter can execute the bytecode compiled from the target function sequentially according to the stack frame structure of the virtual machine stack created for the target function.

[0051] This application embodiment generates a stack frame structure corresponding to the target function in the virtual machine stack in response to the target function being called, and executes the bytecode compiled from the target function sequentially according to the stack frame structure. Since the virtual machine stack in this embodiment includes a local variable area, operand stack, and frame context, or only includes a local variable area and operand stack, without complex structures such as function structure variables and branch block structure variables, the structure of the virtual machine stack is optimized. The optimized virtual machine stack has a clear structure, removing control block structures related to control instructions, making the virtual machine stack frame structure simpler, requiring less storage space, and allowing for more direct read and write operations, thereby improving read and write performance. Simultaneously, the above virtual machine stack has greater applicability, suitable for both resource-constrained and non-resource-constrained devices, and is more secure and efficient. Therefore, the above technical solution can solve the problem of poor virtual machine read and write performance due to the complex stack frame structure of existing virtual machine stacks, improving the simplicity of the virtual machine stack structure and the convenience of read and write operations, reducing virtual machine memory space occupation, thereby improving virtual machine memory space utilization and virtual machine read and write performance, and improving the efficiency of virtual machine bytecode interpretation and execution.

[0052] Figure 3This is a flowchart of another bytecode execution method provided in this application embodiment. This embodiment is based on the above embodiment and is further specified. In this embodiment, various specific optional implementation methods are given for generating the corresponding stack frame structure in the virtual machine stack for different types of target functions, and for sequentially executing the bytecode compiled from the target functions according to the stack frame structure of the target functions. Accordingly, as Figure 3 As shown, the method in this embodiment may include:

[0053] S210. In response to the target function being called, generate the stack frame structure corresponding to the target function in the virtual machine stack; wherein, the virtual machine stack includes a local variable area, an operand stack, and a frame context, or, the virtual machine stack includes a local variable area and an operand stack.

[0054] In an optional embodiment of this application, the target function may include an entry function, and generating the stack frame structure corresponding to the target function in the virtual machine stack may include: creating a new virtual machine stack that matches the entry function; and generating the stack frame structure corresponding to the entry function in the first function frame structure of the new virtual machine stack that matches the entry function.

[0055] The entry point function is the point at which the virtual machine starts, used to enter the virtual machine environment from the native environment. The native environment primarily refers to an environment developed using a specific programming language such as C or C++. Modules can define application entry points. Specifically, modules that do not contain application entry points are called library modules, and library modules cannot create applications. Modules with entry points are called application modules, and application modules can create applications. The function frame structure is the stack frame structure generated on the virtual machine stack after a function is called.

[0056] Function calls in a virtual machine can occur in several ways. One such situation is when a module's entry point function is called from the native environment to enter the virtual machine environment. When the entry point function is called from the native environment for the first time to enter the virtual machine environment, a new virtual machine stack can be created for the entry point function, and the stack frame structure corresponding to the entry point function can be generated in the first function frame structure of the new virtual machine stack that matches the entry point function.

[0057] Figure 4 This is a schematic diagram illustrating the effect of changes in the virtual machine stack structure before and after a function call, as provided in an embodiment of this application. In a specific example, such as... Figure 4 As shown, the first frame of the virtual machine stack corresponds to the entry function. Since the entry function is the first function entered into the virtual machine environment, there is no need to generate frame context information when generating the stack frame structure corresponding to the entry function in the virtual machine stack.

[0058] In an optional embodiment of this application, the target function may include the module function called by the current function, and generating the stack frame structure corresponding to the target function in the virtual machine stack may include: determining the stack frame structure corresponding to the current function in the virtual machine stack; generating the stack frame structure corresponding to the module function called by the current function in the adjacent stack frame structure of the current function's stack frame structure; the method may further include: updating the frame context information corresponding to the current function in the frame context region.

[0059] In an optional embodiment of this application, the adjacent stack frame structure of the current function's stack frame structure may include the stack frame structure above or below the stack frame structure of the previous function's stack frame structure.

[0060] The current function can be the entry point function or a function from another module called by the virtual machine. The adjacent stack frame structure can be the stack frame structure adjacent to the current function's stack frame structure. A module is a container of code in binary format; it is the unit of compilation, loading, and execution of an application. Modules can define functions, global variables, local variables, and other information. Initial data in memory can be defined within a module; this initial data is organized into data segments and can be copied to memory at specified offsets, such as the initialization data for global variables. Module functions can be functions defined within the module.

[0061] Another scenario for function calls in a virtual machine is when the current function calls another module function within the virtual machine environment. In this embodiment, when the current function calls another module function in the virtual machine, a new stack frame structure is created in the virtual machine stack. Specifically, the stack frame structure corresponding to the module function called by the current function can be generated in the adjacent stack frame structure of the current function's stack frame structure. Simultaneously, the frame context information corresponding to the current function needs to be updated in the frame context region to ensure a normal return to the current function after the module function called by the current function has finished.

[0062] Optionally, the current function can be the entry function. In a specific example, such as Figure 4As shown, when another module function is called from the entry function, a new stack frame structure is created based on the adjacent stack frame structure of the entry function. If the local variable area and operand stack in the virtual machine stack space grow from bottom to top, the stack frame structure of the module function called by the entry function can be generated above the stack frame structure of the entry function. If the local variable area and operand stack in the virtual machine stack space grow from top to bottom, the stack frame structure of the module function called by the entry function can be generated below the stack frame structure of the entry function. Simultaneously, the frame context information corresponding to the entry function can be recorded in the frame context area of ​​the virtual machine stack frame, so that after the module function call ends, execution can return to the entry function based on the information recorded in the frame context to continue execution.

[0063] Optionally, the current function can also be a module function. In a specific example, such as Figure 4 As shown, assuming the current function is function 2, when function 2 calls other module functions such as function 3... Figure 4 When (not shown in the diagram), a new stack frame structure is created based on the adjacent stack frame structure of function 2. If the local variable area and operand stack in the virtual machine stack space grow from bottom to top, the stack frame structure of function 3 can be generated above the stack frame structure of function 2. If the local variable area and operand stack in the virtual machine stack space grow from top to bottom, the stack frame structure of function 3 can be generated below the stack frame structure of function 2. Simultaneously, the frame context information corresponding to function 2 can be recorded in the frame context area of ​​the virtual machine stack frame so that after the function 3 call ends, execution can return to function 2 based on the information recorded in the frame context.

[0064] It should be noted that the frame contexts of different functions can be recorded in the frame context area in the order of function calls to ensure the correct return of each function.

[0065] In an optional embodiment of this application, the target function may include a native function, and generating the stack frame structure corresponding to the target function in the virtual machine stack may include: determining the stack frame structure corresponding to the current function in the virtual machine stack; and generating the stack frame structure corresponding to the native function in the adjacent stack frame structure of the current function's stack frame structure.

[0066] In an optional embodiment of this application, the adjacent stack frame structure of the current function's stack frame structure may include the stack frame structure above or below the current function's stack frame structure.

[0067] Native functions, also known as native functions, refer to functions implemented in a programming language different from the one used in the development system.

[0068] Another scenario for function calls in a virtual machine is when a current function calls a native function within the virtual machine environment. In this embodiment, when a native function is called within a module function in the virtual machine environment, the system transitions from the virtual machine environment to the native environment. At this point, the stack frame structure corresponding to the current function that called the native function can be determined, and the stack frame structure corresponding to the native function can be generated in the adjacent stack frame structure of the current function's stack frame structure, such as the stack frame structure above or below it.

[0069] It's important to note that since calling native functions from a virtual machine doesn't involve switching runtime domains, and native functions aren't executed by the virtual machine interpreting bytecode, there's no need to record the program counter (PC) pointer. Therefore, for native function calls, a corresponding stack frame structure can be built in the virtual machine stack, or it can be left unbuilt, continuing to use the operand stack space of the calling function. The only requirement is that after the native function call, the top of the operand stack must be returned to its original position before the call; that is, it's sufficient to ensure that the call to the native function can return to the original module function within the virtual machine environment.

[0070] In an optional embodiment of this application, the target function may include an entry function that re-enters the virtual machine environment, and generating the stack frame structure corresponding to the target function in the virtual machine stack may include: creating a new virtual machine stack that matches the entry function; and generating the stack frame structure corresponding to the entry function in the first stack frame structure of the new virtual machine stack that matches the entry function.

[0071] Another scenario for function calls in a virtual machine is when a module's entry point function is called after entering the native environment from the virtual machine environment, thus re-entering the virtual machine environment. This is understandable; when a native function is called in the virtual machine environment to enter the native environment, and then the module's entry point function is called again to enter the virtual machine environment, it's a re-entry into the virtual machine. In this case, following the process of creating the stack frame structure corresponding to the entry point in the virtual machine stack when the entry point function is first called to enter the virtual machine environment, a new matching virtual machine stack can be created for the re-entering entry point function. The stack frame structure corresponding to the re-entering entry point function is then generated within the first stack frame structure of this new matching virtual machine stack.

[0072] In an optional embodiment of this application, the target function may include an entry function for re-entering the virtual machine environment, and generating the stack frame structure corresponding to the target function in the virtual machine stack may include: determining the current stack frame structure of the original virtual machine stack; generating the stack frame structure corresponding to the entry function in the adjacent stack frame structures of the current stack frame structure of the original virtual machine stack; and marking the starting position of the stack frame structure corresponding to the entry function.

[0073] In an optional embodiment of this application, the adjacent stack frame structure of the current stack frame structure of the original virtual machine stack includes the stack frame structure above or below the current stack frame structure of the original virtual machine stack.

[0074] The original virtual machine stack can be the virtual machine stack created by the virtual machine before entering the native environment from the virtual machine environment. The current stack frame structure of the original virtual machine stack can be the stack frame structure corresponding to the module function before the virtual machine calls the native function. Alternatively, the current stack frame structure of the original virtual machine stack can also be the corresponding stack frame structure generated for the native function when the virtual machine calls the native function.

[0075] In this embodiment, when a module's entry function is called again after entering the native environment from the virtual machine environment, a new stack frame structure for the entry function can be generated using the original virtual machine stack. Specifically, the current stack frame structure of the original virtual machine stack can be determined first, and the stack frame structure corresponding to the entry function re-entering the virtual machine environment can be generated in the adjacent stack frame structures of the current stack frame structure of the original virtual machine stack, such as the stack frame structure above or below. Since the stack frame structure corresponding to the entry function re-entering the virtual machine environment is not in the first function frame structure of the original virtual machine stack, it is necessary to mark the starting position of the stack frame structure corresponding to the entry function re-entering the virtual machine environment in the original virtual machine stack. The marking method can include, but is not limited to, pointer marking methods. This embodiment does not limit the specific marking method for the starting position of the stack frame structure corresponding to the entry function.

[0076] S220. Read the currently executed bytecode based on the PC pointer of the current bytecode.

[0077] The bytecode PC pointer can be used to point to the memory address where the bytecode is located in order to read the bytecode. The bytecode to be executed can be the bytecode of the module function that needs to be interpreted and executed by the virtual machine.

[0078] S230. Parse the currently executed bytecode to determine the bytecode processing function that matches the currently executed bytecode.

[0079] Among them, the bytecode processing function can be the processing function of the interpreter in the virtual machine, which is used to process the bytecode to realize the bytecode execution process.

[0080] S240. Execute the currently executed bytecode according to the bytecode processing function matched by the currently executed bytecode and the stack frame structure of the target function.

[0081] Specifically, the interpreter inside the virtual machine is responsible for interpreting and executing the bytecode of the target function called by the virtual machine. After each target function is compiled, a series of bytecodes are generated, and the interpreter has a corresponding processing function for each bytecode. When the virtual machine calls the target function, the interpreter will execute the bytecode generated by the compilation of the target function in sequence according to the information such as the local variable area and operand stack of the target function saved in the stack frame structure of the created virtual machine stack, and enter the processing function inside the interpreter corresponding to different bytecodes.

[0082] Accordingly, before executing bytecode, the interpreter can first read the currently executable bytecode from a series of bytecode instructions compiled from the target function using the current bytecode PC pointer. Then, it parses the currently executable bytecode to determine the bytecode processing function within the interpreter that matches it. The interpreter increments the current bytecode PC pointer value for each bytecode instruction executed. When the virtual machine calls the target function and creates a new stack frame structure on the virtual machine stack, the virtual machine saves the PC pointer value before the function call and sets the bytecode PC pointer to the first bytecode instruction within the called target function. The interpreter can then begin execution from the first bytecode instruction within the target function. When the called target function returns, its stack frame is popped from the virtual machine stack, and the virtual machine returns to the module function before the target function call to continue execution. The bytecode PC pointer then points to the bytecode of the current module function to continue execution.

[0083] In an optional embodiment of this application, determining the bytecode processing function that matches the currently executed bytecode may include: determining the bytecode identifier that matches the currently executed bytecode; and querying a function pointer table based on the bytecode identifier that matches the currently executed bytecode to obtain the bytecode processing function that matches the currently executed bytecode.

[0084] The bytecode identifier is used to uniquely identify each bytecode, with each bytecode having a different identifier. The function pointer table is used to index and find the bytecode processing function corresponding to each bytecode.

[0085] In this embodiment, the interpreter within the virtual machine can maintain the index information of bytecode processing functions through a function pointer table. Once the interpreter determines the bytecode to be executed, it can identify the bytecode identifier of the bytecode to be executed, and then use the bytecode identifier as a basis to query the function pointer table within the interpreter to obtain the bytecode processing function matching the bytecode to be executed.

[0086] In an optional embodiment of this application, the bytecode execution method may further include: if a runtime exception occurs during the execution of the currently executed bytecode, checking for the exception in the execution process of the currently executed bytecode; if it is determined that there is an exception in the execution process of the currently executed bytecode, entering an exception handling phase; and if it is determined that the stack frame structure in the virtual machine stack is popped, stopping the bytecode execution operation.

[0087] Figure 5 This is a schematic diagram of a virtual machine interpreter execution flow provided in an embodiment of this application. In a specific example, such as... Figure 5 As shown, during the virtual machine's execution, if a runtime exception is thrown during bytecode execution, the process returns to the exception handling module in the interpreter's main flow. At this point, the exception handling module checks for exceptions during the execution of the currently executing bytecode. If an exception is found, the exception handling process begins. If the stack frame structure in the virtual machine stack is determined to be empty, it indicates that all calls to module functions have ended, and the system has switched back to the native environment from the virtual machine environment. Figure 5 In this context, `while(1)` represents an infinite loop. `while` is a basic loop pattern in computer programming that allows a program to repeatedly execute a block of code while a specific condition is met. In `while(1)`, the number 1 represents a condition that is always true, so the loop will execute indefinitely unless there is code within the loop body that changes the loop condition or the program is terminated by external factors.

[0088] In an optional embodiment of this application, entering the exception handling phase may include: if it is determined that the program exception point is in the TRY (exception handling keyword) code block, jumping the program PC to the TRY bytecode address corresponding to the TRY code block to run; if it is determined that the program exception point is not in the TRY code block, returning to the set status word.

[0089] The `TRY` block can be used to identify code segments where exceptions may occur. The `TRY` block is a structure used to catch and handle exceptions. The main purpose of the `TRY` block is to provide a mechanism for handling errors that may occur during program execution. By catching and handling these exceptions, the robustness and stability of the program can be improved. Setting a status word can be used to identify exceptions where the program's exception point is not located within the `TRY` block.

[0090] Figure 6 This is a schematic diagram illustrating a virtual machine exception handling process provided in an embodiment of this application. In a specific example, such as... Figure 6 As shown in the embodiments of this application, the virtual machine can support application-defined exception monitoring segments and exception handling logic, support exception nesting, and support applications using the TRY and CATCH keywords to capture exceptions. When an exception occurs during virtual machine operation, it can be confirmed whether the program exception point is within the TRY code block. If the exception point is determined to be within the TRY code block, the program's program counter (PC) can be jumped to the TRY bytecode address corresponding to the TRY code block for execution. If the exception point is not within the TRY code block, a 6F00 status word can be returned, and the virtual machine's execution process can be terminated.

[0091] Figure 7 This is a schematic diagram of another virtual machine exception handling process provided in an embodiment of this application. In a specific example, such as Figure 6 and Figure 7 As shown, if an exception occurs during program execution, it is necessary to backtrack the virtual machine stack frame information to find the stack frame of the virtual machine stack that most recently contained the execution state of the TRY code block, and set it as the stack frame of the virtual machine stack at the exception handling point. If found, the latest exception handling stack frame information is read. Further, it is determined whether the nested try-catch level in the read exception handling stack frame information is the first level. If the nested try-catch level is the first level, the execution state of the TRY code block in the exception handling virtual machine stack frame information is cleared. If the nested try-catch level is not the first level, the program PC information from the read exception handling stack frame information is assigned to the current program PC, which is then the location of the TRY instruction in the TRY code block program. The operand stack depth indicated by the TRY instruction is obtained from the current program PC, and the operand stack depth of the virtual machine stack frame at the exception handling point is restored to before the execution of the TRY instruction, restoring the virtual machine runtime environment to the location of the TRY instruction to begin execution. If not found, the virtual machine execution is terminated. When a program encounters an exception and executes the TRY instruction, it pushes the program's execution state 1 onto the operand stack. When a program encounters an exception and executes the catch instruction, it pops the latest exception handling stack frame and pushes the program's execution state 0 onto the operand stack.

[0092] The aforementioned technical solution optimizes the stack frame structure of the virtual machine stack. The optimized stack frame structure is clearer and removes the control block structure related to control instructions, making the stack frame structure simpler and read / write operations more direct. This improves virtual machine performance and, consequently, the efficiency of virtual machine bytecode interpretation and execution. Because the virtual machine stack's stack frame structure is simple, it occupies little space, making it suitable for both resource-constrained and unresource-constrained devices. Furthermore, the stack frame structure contains information to determine the execution domain of module functions, ensuring security during function calls and preventing unauthorized function calls.

[0093] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information in this technical solution comply with relevant laws and regulations and do not violate public order and good morals.

[0094] It should be noted that any arrangement or combination of the technical features in the above embodiments also falls within the protection scope of this application.

[0095] Figure 8 This is a schematic diagram of a bytecode execution device provided in an embodiment of this application, such as... Figure 8 As shown, the device includes: a stack frame structure generation module 310 and a bytecode execution module 320, wherein:

[0096] The stack frame structure generation module 310 is used to generate a stack frame structure corresponding to the target function in the virtual machine stack in response to the target function being called; wherein, the virtual machine stack includes a local variable area, an operand stack, and a frame context, or, the virtual machine stack includes a local variable area and an operand stack.

[0097] The bytecode execution module 320 is used to execute the bytecode compiled from the target function sequentially according to the stack frame structure of the target function.

[0098] This application embodiment generates a stack frame structure corresponding to the target function in the virtual machine stack in response to the target function being called, and executes the bytecode compiled from the target function sequentially according to the stack frame structure of the target function. Since the virtual machine stack in this embodiment includes a local variable area, an operand stack, and a frame context, or only includes a local variable area and an operand stack, the stack frame structure of the virtual machine stack is optimized. This solves the problem of poor virtual machine read / write performance due to the complex stack frame structure of existing virtual machine stacks, improves the simplicity of the virtual machine stack structure and the convenience of read / write operations, reduces virtual machine memory space usage, thereby improving virtual machine memory space utilization and virtual machine read / write performance, and improving the efficiency of virtual machine bytecode interpretation and execution.

[0099] Optionally, the target function includes an entry function, and the stack frame structure generation module 310 is further configured to: create a new virtual machine stack matching the entry function; and generate a stack frame structure corresponding to the entry function in the first function frame structure of the new virtual machine stack matching the entry function.

[0100] Optionally, the target function includes the module function called by the current function, and the stack frame structure generation module 310 is further configured to: determine the stack frame structure corresponding to the current function in the virtual machine stack; generate the stack frame structure corresponding to the module function called by the current function in the adjacent stack frame structure of the current function's stack frame structure; the above device further includes a frame context update module, configured to: update the information of the frame context corresponding to the current function in the frame context region.

[0101] Optionally, the target function includes a native function, and the stack frame structure generation module 310 is further configured to: determine the stack frame structure corresponding to the current function in the virtual machine stack; and generate the stack frame structure corresponding to the native function in the adjacent stack frame structures of the current function's stack frame structure.

[0102] Optionally, the adjacent stack frame structure of the current function's stack frame structure includes the stack frame structure above or below the current function's stack frame structure.

[0103] Optionally, the target function includes an entry function for re-entering the virtual machine environment, and the stack frame structure generation module 310 is further configured to: create a new virtual machine stack matching the entry function; and generate a stack frame structure corresponding to the entry function in the first stack frame structure of the new virtual machine stack matching the entry function.

[0104] Optionally, the target function includes an entry function for re-entering the virtual machine environment, and the stack frame structure generation module 310 is further configured to: determine the current stack frame structure of the original virtual machine stack; generate the stack frame structure corresponding to the entry function in the adjacent stack frame structures of the current stack frame structure of the original virtual machine stack; and mark the starting position of the stack frame structure corresponding to the entry function.

[0105] Optionally, the adjacent stack frame structure of the current stack frame structure of the original virtual machine stack includes the stack frame structure above or below the current stack frame structure of the original virtual machine stack.

[0106] Optionally, the bytecode execution module 320 is further configured to: read the currently executable bytecode based on the current bytecode PC pointer; parse the currently executable bytecode to determine the bytecode processing function that matches the currently executable bytecode; and execute the currently executable bytecode based on the bytecode processing function that matches the currently executable bytecode and the stack frame structure of the target function.

[0107] Optionally, the bytecode execution module 320 is further configured to: determine the bytecode identifier that matches the currently executed bytecode; and query the function pointer table based on the index of the bytecode identifier that matches the currently executed bytecode to obtain the bytecode processing function that matches the currently executed bytecode.

[0108] Optionally, the bytecode execution module 320 is further configured to: check for abnormalities in the execution process of the currently executed bytecode if a runtime exception occurs during the execution process; enter the exception handling stage if it is determined that there is an exception in the execution process of the currently executed bytecode; and stop the bytecode execution operation if it is determined that the stack frame structure in the virtual machine stack is empty.

[0109] Optionally, the bytecode execution module 320 is also configured to: if it is determined that the program exception point is in the exception handling keyword TRY code block, jump the program PC to the TRY bytecode address corresponding to the TRY code block for execution; if it is determined that the program exception point is not in the TRY code block, return the set status word.

[0110] Optionally, the bytecode execution module 320 is further configured to: read the most recent exception handling stack frame information; if it is determined that the try-catche nesting state in the exception handling stack frame information is the first level, clear the execution state in the TRY code block of the virtual machine stack at the exception handling point, restore the execution context of the TRY instruction, and return to the state of finding the exception handling code; if it is determined that the try-catche nesting state in the exception handling stack frame information is not the first level, restore the execution context of the TRY instruction, and return to the state of finding the exception handling code.

[0111] Optionally, the local variable area includes at least one of the following: function parameters and local variables.

[0112] Optionally, the operand stack includes the operands required to execute the instructions.

[0113] Optionally, the frame context includes at least one of the following: module ID, function structure address of the function containing the instruction before the function call, PC pointer, current execution domain, and function stack frame bottom.

[0114] Optionally, functions in different runtime domains can call each other if authorized.

[0115] The bytecode execution device described above can execute the bytecode execution method provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects of the execution method. Technical details not described in detail in this embodiment can be found in the bytecode execution method provided in any embodiment of this application.

[0116] Since the bytecode execution device described above is an apparatus capable of executing the bytecode execution method in the embodiments of this application, those skilled in the art can understand the specific implementation methods and various variations of the bytecode execution device in this embodiment based on the bytecode execution method described in the embodiments of this application. Therefore, how the bytecode execution device implements the bytecode execution method in the embodiments of this application will not be described in detail here. Any apparatus used by those skilled in the art to implement the bytecode execution method in the embodiments of this application falls within the scope of protection of this application.

[0117] This application also provides an operating system that has a runtime environment running in it. The operating system executes the bytecode execution method provided in any embodiment of this application through the runtime environment.

[0118] This application also provides a virtual machine that runs on an operating system. The operating system has a runtime environment, and the operating system executes the bytecode execution method provided in any embodiment of this application through the runtime environment.

[0119] Figure 9 A schematic diagram of the structure of an electronic device 10 that can be used to implement embodiments of this application is shown.

[0120] like Figure 9 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0121] The I / O interface 15 in the electronic device 10 may include eSPI (Enhanced Serial Peripheral Interface) and SPI (Serial Peripheral Interface), etc.

[0122] Processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, central processing unit (CPU), graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, for example, performing a bytecode execution method as described in the embodiments of this application, executed by a runtime environment in an operating system installed in an electronic device, the method comprising:

[0123] In response to the invocation of the target function, a stack frame structure corresponding to the target function in the virtual machine stack is generated; wherein, the virtual machine stack includes a local variable area, an operand stack, and a frame context, or, the virtual machine stack includes a local variable area and an operand stack;

[0124] The bytecode compiled from the target function is executed sequentially according to the stack frame structure of the target function.

[0125] In some embodiments, a bytecode execution method as described in the various embodiments of this application can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 16. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the bytecode execution method described above in the various embodiments of this application can be performed. Alternatively, in other embodiments, processor 11 can be configured to execute a bytecode execution method as described in the various embodiments of this application by any other suitable means (e.g., by means of firmware).

[0126] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0127] Optionally, electronic devices include resource-constrained devices. Resource-constrained devices include smart cards, SEs (Secure Elements), security chips, or embedded devices.

[0128] Computer programs used to implement the methods of this application may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0129] In the context of this application, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0130] Figure 10 This is a structural diagram of a terminal provided according to an embodiment of this application. For example... Figure 10 The terminal includes the electronic device 10 as described in any embodiment of this application.

[0131] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this application can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this application can be achieved, and this is not limited herein.

[0132] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method of bytecode execution, characterized by, The application is applied to a virtual machine, comprising: in response to a target function being called, generating a corresponding stack frame structure of the target function in a virtual machine stack; wherein the virtual machine stack comprises a local variable area, an operand stack and a frame context, or the virtual machine stack comprises a local variable area and an operand stack; in accordance with the stack frame structure of the target function, executing bytecode formed by compiling the target function in sequence.

2. The method of claim 1, wherein, The target function comprises an entry function, and the generating of the corresponding stack frame structure of the target function in the virtual machine stack comprises: creating a new virtual machine stack matched with the entry function; generating the corresponding stack frame structure of the entry function in a first frame function frame structure of the new virtual machine stack matched with the entry function.

3. The method of claim 2, wherein, The target function further comprises a module function called by a current function, and the generating of the corresponding stack frame structure of the target function in the virtual machine stack comprises: determining the corresponding stack frame structure of the current function in the virtual machine stack; generating the corresponding stack frame structure of the module function called by the current function in a neighboring stack frame structure of the stack frame structure of the current function; The method further comprises updating information of the frame context corresponding to the current function in a frame context area.

4. The method of claim 3, wherein, The target function further comprises a native function, and the generating of the corresponding stack frame structure of the target function in the virtual machine stack comprises: determining the corresponding stack frame structure of the current function in the virtual machine stack; generating the corresponding stack frame structure of the native function in a neighboring stack frame structure of the stack frame structure of the current function.

5. The method of claim 4, wherein, The neighboring stack frame structure of the stack frame structure of the current function comprises an upper stack frame structure or a lower stack frame structure of the stack frame structure of the current function.

6. The method of claim 4, wherein, The target function further comprises an entry function for re-entering a virtual machine environment, and the generating of the corresponding stack frame structure of the target function in the virtual machine stack comprises: creating a new virtual machine stack matched with the entry function; generating the corresponding stack frame structure of the entry function in a first frame stack frame structure of the new virtual machine stack matched with the entry function.

7. The method of claim 6, wherein, The target function further comprises an entry function for re-entering a virtual machine environment, and the generating of the corresponding stack frame structure of the target function in the virtual machine stack comprises: determining a current stack frame structure of an original virtual machine stack; generating the corresponding stack frame structure of the entry function in a neighboring stack frame structure of the current stack frame structure of the original virtual machine stack; marking a starting position of the corresponding stack frame structure of the entry function.

8. The method of claim 7, wherein, The neighboring stack frame structure of the current stack frame structure of the original virtual machine stack comprises an upper stack frame structure or a lower stack frame structure of the current stack frame structure of the original virtual machine stack.

9. The method according to any of claims 1 to 8, characterized in that, The executing of the bytecode formed by compiling the target function in accordance with the stack frame structure of the target function comprises: reading a current bytecode to be executed according to a current bytecode PC pointer; analyzing the current bytecode to be executed to determine a bytecode processing function matched with the current bytecode to be executed; executing the current bytecode to be executed according to the bytecode processing function matched with the current bytecode to be executed and the stack frame structure of the target function.

10. The method of claim 9, wherein, The determining of the bytecode processing function matched with the current bytecode to be executed comprises: determining a bytecode identifier matched by the current bytecode to be executed; indexing a function pointer table according to the bytecode identifier matched by the current bytecode to be executed, to obtain a bytecode processing function matched by the current bytecode to be executed.

11. The method of claim 9, wherein, Further comprising: in case of occurrence of a runtime exception during execution of the current bytecode to be executed, checking an exception condition of the current bytecode to be executed; in case of determining that the current bytecode to be executed has an exception, entering an exception handling section; in case of determining that a stack frame structure in the virtual machine stack is popped, stopping bytecode execution.

12. The method of claim 11, wherein, The entering of the exception handling section comprises: in case of determining that the program exception point is in a TRY code block, jumping the program PC to a TRY bytecode address corresponding to the TRY code block; in case of determining that the program exception point is not in the TRY code block, returning a set state word.

13. The method of claim 9, wherein: The local variable area comprises at least one of the following: parameters and local variables of a function.

14. The method of claim 9, wherein: The operand stack comprises operands required by an execution instruction.

15. The method of claim 9, wherein: The frame context comprises at least one of the following: a module ID, a function structure address of a function before an instruction is called, a PC pointer, a current running domain, and a function stack frame bottom.

16. The method of claim 15, wherein: Functions between different running domains call each other under authorization.

17. A bytecode execution apparatus, characterized by comprising: Configured in a virtual machine, comprising: a stack frame structure generation module, configured to generate a stack frame structure corresponding to a target function in a virtual machine stack in response to the target function being called, wherein the virtual machine stack comprises a local variable area, an operand stack, and a frame context, or the virtual machine stack comprises a local variable area and an operand stack; a bytecode execution module, configured to execute bytecodes formed by compiling the target function according to the stack frame structure of the target function.

18. An operating system, characterized by The operating system executes a runtime environment, and the operating system executes the bytecode execution method in any one of claims 1-16 through the runtime environment.

19. A virtual machine, comprising: The virtual machine runs in an operating system, and the operating system executes a runtime environment, and the operating system executes the bytecode execution method in any one of claims 1-16 through the runtime environment.

20. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory in communication connection with the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the bytecode execution method in any one of claims 1-16.

21. The electronic device of claim 20, wherein, The electronic device comprises a resource-constrained device.

22. The electronic device of claim 21, wherein, The resource-constrained device comprises a smart card, a secure element SE, a secure chip, or an embedded device.

23. A terminal, characterized by The electronic device comprises the electronic device in any one of claims 20-22.

24. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling a processor to execute the bytecode execution method in any one of claims 1-16 when executed by the processor. The computer readable storage medium stores computer instructions for enabling a processor to execute the bytecode execution method in any one of claims 1-16 when executed by the processor.

25. A computer program product, characterised in that, The computer program product comprises a computer program which, when executed by a processor, implements the bytecode execution method according to any one of claims 1-16.