Program running method and device, equipment and medium
By generating and performing compilation and decoding on the device side, the problem of low execution efficiency of JavaScript language in devices with poor processor performance and low running memory is solved, and the effect of improving user experience is achieved.
Patent Information
- Application Number
- CN202311403313.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-26
- Publication Date
- 2025-04-29
AI Technical Summary
In devices with poor processor performance and low memory running, the execution efficiency is low when running the JavaScript language, which affects the user experience.
By obtaining the source code of the target program on the device side, generating the corresponding code, and sending it to the device side, so that the device side can run the target program according to the code. Compilation and decoding include executable code and bytecode, which are compiled according to the data type of the source code to ensure that the device can execute code efficiently.
By separating the compilation and operation of the code, the code is compiled on the server, thereby greatly improving the running speed of the code without taking up too much performance, thereby improving the user experience.
Smart Images

Figure CN119902767A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of application frameworks, and in particular to a program running method, device, equipment and medium. Background Art
[0002] The Javascript runtime is a special software that is mainly used in embedded software and devices, such as various watches, bracelets, sensor devices, etc. It reads the JavaScript language, compiles it into an internal format, and runs the code. However, in the above devices, the device size is often limited, resulting in poor processor performance and low operating memory, resulting in low execution efficiency when running the JavaScript language, which in turn affects the user experience. Summary of the invention
[0003] The present invention provides a program running method, device, equipment and medium, which are used to solve the technical problem in the related art that due to the poor processor performance and low running memory of the device, the execution efficiency is low when running the JavaScript language, thereby affecting the user experience.
[0004] In a first aspect, an embodiment of the present invention provides a program running method, the method comprising:
[0005] Determine to obtain the source code of the target program when running the target program on the device side;
[0006] Generate the compiled code corresponding to the target program using the source code;
[0007] The compiled code is sent to the device so that the device runs the target program according to the compiled code.
[0008] In a possible implementation, in the method provided in the embodiment of the present invention, the compiled code includes executable code and bytecode, and the compiled code corresponding to the target program is generated by using the source code, including:
[0009] Determine the data type of the source code;
[0010] Compile the source code of the determined type into executable code, where the executable code is code that can be directly executed by the device end;
[0011] Compiles source code that cannot be typed into bytecode, which is interpreted and executed on the device side.
[0012] In a possible implementation, in the method provided by the embodiment of the present invention, determining the data type of the source code includes:
[0013] Determine the data type of the source code based on its internal variables and external parameters.
[0014] In a possible implementation, in the method provided by the embodiment of the present invention, the bytecode includes an interpretation bytecode and a special bytecode, and compiling the source code whose type cannot be determined into the bytecode includes:
[0015] Compile untyped source code into interpreted bytecode;
[0016] Compile a source code with multiple suspected types into a special bytecode, where the suspected type is a possible data type of the source code.
[0017] In a second aspect, an embodiment of the present invention provides another program running method, the method comprising:
[0018] When determining to run the target program, obtain the compilation code corresponding to the target program from the server;
[0019] Based on the compiled code, run the target program.
[0020] In a possible implementation, in the method provided by the embodiment of the present invention, the compiled code includes executable code and bytecode, and running the target program based on the compiled code includes:
[0021] Execute executable code;
[0022] Interprets and executes the bytecode.
[0023] In a possible implementation, in the method provided by the embodiment of the present invention, the bytecode includes an interpretation bytecode and a special bytecode, and interpreting and executing the bytecode includes:
[0024] Interpret the bytecode in interpreted mode;
[0025] Special bytecodes are interpreted in precompiled mode. The interpretation mode and precompiled mode use the same CPU register allocation rules, the same function call rules, and the same exception handling rules.
[0026] In a possible implementation, in the method provided by the embodiment of the present invention, the compiled code includes executable code and bytecode, and the target is generated using the source code.
[0027] In a third aspect, an embodiment of the present invention provides a program running device, including:
[0028] A first acquisition unit, used to determine to acquire source code of the target program when the target program is run on the device end;
[0029] A processing unit, used to generate a compiled code corresponding to a target program using a source code;
[0030] The sending unit is used to send the encoding code to the device end so that the device end runs the target program according to the encoding code.
[0031] In a possible implementation manner, in the device provided by the embodiment of the present invention, the compiled code includes an executable code and a bytecode, and the processing unit is specifically used for:
[0032] Determine the data type of the source code;
[0033] Compile the source code of the determined type into executable code, where the executable code is code that can be directly executed by the device end;
[0034] Compiles source code that cannot be typed into bytecode, which is interpreted and executed on the device side.
[0035] In a possible implementation manner, in the device provided by the embodiment of the present invention, the processing unit is specifically used for:
[0036] Determine the data type of the source code based on its internal variables and external parameters.
[0037] In a possible implementation manner, in the device provided by the embodiment of the present invention, the bytecode includes an interpretation bytecode and a special bytecode, and the processing unit is specifically used for:
[0038] Compile untyped source code into interpreted bytecode;
[0039] Compile a source code with multiple suspected types into a special bytecode, where the suspected type is a possible data type of the source code.
[0040] In a fourth aspect, an embodiment of the present invention provides another program running device, including:
[0041] The second acquisition unit is used to obtain the compilation code corresponding to the target program from the server when determining to run the target program;
[0042] The running unit is used to run the target program based on the compiled code.
[0043] In a possible implementation manner, in the device provided by the embodiment of the present invention, the compiled code includes an executable code and a bytecode, and the running unit is specifically used for:
[0044] Execute executable code;
[0045] Interprets and executes the bytecode.
[0046] In a possible implementation manner, in the device provided by the embodiment of the present invention, the bytecode includes an interpretation bytecode and a special bytecode, and the execution unit is specifically used for:
[0047] Interpret the bytecode in interpreted mode;
[0048] Special bytecodes are interpreted in precompiled mode. The interpretation mode and precompiled mode use the same CPU register allocation rules, the same function call rules, and the same exception handling rules.
[0049] In a fifth aspect, an embodiment of the present invention provides an electronic device, comprising: at least one processor, at least one memory, and computer program instructions stored in the memory, which, when executed by the processor, implement the methods provided in the first and second aspects of the embodiments of the present invention.
[0050] In a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implement the methods provided in the first and second aspects of the embodiments of the present invention.
[0051] In the embodiment of the present invention, it is first determined that when the target program is to be run on the device side, the source code of the target program is obtained, and then the compiled code corresponding to the target program is generated using the source code, and finally the compiled code is sent to the device side, so that the device side runs the target program according to the compiled code. Compared with the related art, the compilation and running of the code are separated, and the code is compiled on the server, so that the running speed of the code can be greatly improved without occupying too much performance, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A flowchart of a program running method provided by an embodiment of the present invention;
[0053] Figure 2 A flowchart of another program running method provided by an embodiment of the present invention;
[0054] Figure 3 A schematic diagram of the structure of a program running device provided by an embodiment of the present invention;
[0055] Figure 4 A schematic diagram of the structure of another program running device provided by an embodiment of the present invention;
[0056] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] The following are explanations of some of the terms that appear in the text:
[0059] 1. In the embodiments of the present invention, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0060] The Javascript runtime is a special software that is mainly used in embedded software and devices, such as various watches, bracelets, sensor devices, etc. It reads the JavaScript language, compiles it into an internal format, and runs the code. However, in the above devices, the device size is often limited, resulting in poor processor performance and low running memory, resulting in low execution efficiency when running the JavaScript language, which in turn affects the user experience.
[0061] The program running method, device, equipment and medium provided by the present invention are described in more detail below in conjunction with the accompanying drawings and embodiments.
[0062] It should be noted that the server side and the device side in the embodiment of the present invention are relative concepts, which can be a server and a smart phone, or a smart phone and a smart bracelet, etc. The server side is responsible for compiling the source code, and the device side is responsible for interpretation and operation. The specific server side and device side can choose the type of device according to the interaction status and performance status of the device as required, and the embodiment of the present invention does not limit this.
[0063] The embodiment of the present invention provides a program running method, which is applied to a server side, such as Figure 1 As shown, including:
[0064] Step S101, when determining to run the target program on the device side, obtain the source code of the target program.
[0065] In specific implementation, when it is determined that the device needs to run the target program, the source code of the target program is obtained from the database.
[0066] Step S102, generating a compilation code corresponding to the target program using the source code.
[0067] In the specific implementation, the source code is compiled into the compiled code corresponding to the target program, wherein the compiled code includes executable code that can be directly executed by the device side and bytecode that cannot be directly executed by the device side. Specifically, Javascript is a typeless dynamic language. The variables defined by it do not have a clear type, but its type can be inferred based on the context, such as inferring based on the assignment, inferring that the source code is a function or an object based on the context, etc. When its type can be inferred, the compiler will directly generate executable code. When its accurate type cannot be inferred, bytecode can be generated and interpreted and executed at runtime. For bytecode, it includes interpreted bytecode and special bytecode. In JavaScript, function is the basic unit of language. For a function, it consists of two parts: internal variables and external parameters. The data type of internal variables is often the result of the operation of external parameters. Therefore, by establishing an association between internal variables and external parameters, the type of internal variables can be inferred based on the type of external parameters. For the part that can be inferred, it can be compiled into a more efficient code special bytecode based on the type. However, the parameter types passed by external parameters in different calling places are also different, so the type probability of external parameters can only be inferred, and it cannot be accurately judged. The specific inference method is as follows:
[0068] 1. Collect where the function is called, based on the parameters passed by the caller.
[0069] 2. Collect runtime information and write it into the profile file, and make judgments based on the profile file.
[0070] 3. The developer provides additional information to indicate the type of generated parameters.
[0071] 4. Make a rough assessment based on the operations inside the function.
[0072] After obtaining the possible types of the external parameters, one or more types are selected and hypothetical compilation is performed to obtain one or more function implementations for different external parameter types, that is, special bytecodes.
[0073] Step S103, sending the encoded code to the device end.
[0074] During specific implementation, the compiled code is sent to the device end, so that the device end runs the target program according to the compiled code.
[0075] The embodiment of the present invention provides a program running method, which is applied to a device end, such as Figure 2 As shown, including:
[0076] Step S201, when determining to run the target program, obtain the encoding code corresponding to the target program from the server.
[0077] During specific implementation, the encoding code corresponding to the target program sent by the server is received.
[0078] Step S202, running the target program based on the encoding.
[0079] In specific implementation, after obtaining the compiled code, the target program is run according to the compiled code. Specifically, the compiled code contains executable code and bytecode. The executable code part can be run directly, and the bytecode part needs to be interpreted before running. The bytecode contains interpreted bytecode and special bytecode. The interpreted bytecode is interpreted using the interpretation mode, and the special bytecode is interpreted using the pre-compiled AOT mode.
[0080] As shown above, the interpreted mode and AOT mode need to operate in parallel, so the interpreted mode and AOT mode need to maintain the same runtime context. Specifically, the interpreted mode and AOT mode use the same CPU register allocation rules, the same function call rules, and the same exception handling rules. In this way, when the interpreted mode and AOT mode are mixed, they can switch between each other at a minimal cost. For AOT mode, the code is packaged as a special bytecode that specifies the entry of the AOT code and jumps to the entry to execute. When the AOT code finishes executing the special bytecode, it jumps back to execute the next statement.
[0081] Since there are both interpreted bytecodes and special bytecodes when interpreting bytecodes, when executing bytecodes, it is necessary to select the correct code entry to execute based on the input parameters. In the function corresponding to the bytecode, a parameter type information and function entry mapping table is pre-saved, and different functions can be selected according to different parameter types during interpretation. Specifically, the calculation method of parameter type information is as follows:
[0082] 1. Use the T function to extract the parameter type.
[0083] 2. Loop to calculate parameter type value:
[0084] int arg_info = 0;
[0085] For(int I=0;I <argc;I++){
[0086] Arg_info=(Arg_info<<3)^(T(argv[1]));
[0087] }
[0088] 3. A hash table is constructed based on Arg_info. The hash table corresponds to the function entry. Of course, other forms can be selected for correspondence, which is not limited in the embodiment of the present disclosure. When corresponding, in order to ensure that Arg_info is mapped to the correct entry, various combinations are verified during compilation to ensure that the entry is correct. At the same time, the same entry items are merged to reduce the memory space occupied.
[0089] like Figure 3 As shown, based on the same inventive concept as the program running method, the present invention also provides a program running device, comprising:
[0090] A first acquisition unit 301 is used to determine that when the target program is running on the device, the source code of the target program is acquired;
[0091] Processing unit 302, used to generate compiled code corresponding to the target program using the source code;
[0092] The sending unit 303 is used to send the encoding code to the device end, so that the device end runs the target program according to the encoding code.
[0093] In a possible implementation manner, in the device provided by the embodiment of the present invention, the compiled code includes an executable code and a bytecode, and the processing unit 302 is specifically used to:
[0094] Determine the data type of the source code;
[0095] Compile the source code of the determined type into executable code, where the executable code is code that can be directly executed by the device end;
[0096] Compiles source code that cannot be typed into bytecode, which is interpreted and executed on the device side.
[0097] In a possible implementation manner, in the device provided by the embodiment of the present invention, the processing unit 302 is specifically configured to:
[0098] Determine the data type of the source code based on its internal variables and external parameters.
[0099] In a possible implementation, in the device provided by the embodiment of the present invention, the bytecode includes an interpretation bytecode and a special bytecode, and the processing unit 302 is specifically used for:
[0100] Compile untyped source code into interpreted bytecode;
[0101] Compile a source code with multiple suspected types into a special bytecode, where the suspected type is a possible data type of the source code.
[0102] like Figure 4As shown, based on the same inventive concept of the program running method, the present invention also provides another program running device, including:
[0103] The second acquisition unit 401 is used to obtain the encoding code corresponding to the target program from the server when determining to run the target program;
[0104] The running unit 402 is used to run the target program based on the compiled code.
[0105] In a possible implementation, in the device provided by the embodiment of the present invention, the compiled code includes executable code and bytecode, and the running unit 402 is specifically used for:
[0106] Execute executable code;
[0107] Interprets and executes the bytecode.
[0108] In a possible implementation, in the device provided by the embodiment of the present invention, the bytecode includes an interpretation bytecode and a special bytecode, and the execution unit 402 is specifically used for:
[0109] Interpret the bytecode in interpreted mode;
[0110] Special bytecodes are interpreted in precompiled mode. The interpretation mode and precompiled mode use the same CPU register allocation rules, the same function call rules, and the same exception handling rules.
[0111] In addition, combined Figure 1-Figure 4 The program running method and apparatus described in the embodiments of the present invention may be implemented by an electronic device. Figure 5 A schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention is shown.
[0112] The following specific reference Figure 5 , which shows a structural schematic diagram of an electronic device 500 suitable for implementing the embodiments of the present disclosure. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0113] like Figure 5As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 to a random access memory (RAM) 503 to implement the voice control method of the embodiment described in the present disclosure. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0114] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0115] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the voice control method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0116] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0117] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0118] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0119] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0120] Determine to obtain the source code of the target program when running the target program on the device side;
[0121] Generate the compiled code corresponding to the target program using the source code;
[0122] The compiled code is sent to the device so that the device runs the target program according to the compiled code.
[0123] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0124] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0125] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0126] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0127] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0128] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0129] In the embodiment of the present invention, it is first determined that when the target program is to be run on the device side, the source code of the target program is obtained, and then the compiled code corresponding to the target program is generated using the source code, and finally the compiled code is sent to the device side, so that the device side runs the target program according to the compiled code. Compared with the related art, the compilation and running of the code are separated, and the code is compiled on the server, so that the running speed of the code can be greatly improved without occupying too much performance, thereby improving the user experience.
[0130] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0131] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0132] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0133] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0134] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0135] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A program running method, characterized in that: include: Determine that when the target program is run on the device, the source code of the target program is obtained; Generate compiled code corresponding to the target program using the source code; The encoding code is sent to the device end, so that the device end runs the target program according to the encoding code.
2. The program running method according to claim 1, characterized in that: The compiled code includes executable code and bytecode, and the step of using the source code to generate the compiled code corresponding to the target program includes: Determine the data type of the source code; Compiling a source code of a determined type into the executable code, wherein the executable code is a code that can be directly executed by the device end; The source code whose type cannot be determined is compiled into the bytecode, and the bytecode is the code that is interpreted and executed at the device end.
3. The program running method according to claim 2, characterized in that: The determining the data type of the source code includes: The data type of the source code is determined according to the internal variables and external parameters of the source code.
4. The program running method according to claim 3, characterized in that: The bytecode includes an interpreted bytecode and a special bytecode, and compiling the source code whose type cannot be determined into the bytecode includes: Compiling the source code whose type cannot be determined into the interpreted bytecode; A source code having a plurality of suspected types is compiled into the special bytecode, wherein the suspected types are possible data types of the source code.
5. A program running method, characterized in that: include: When determining to run the target program, obtaining the encoding code corresponding to the target program from the server; Based on the compiled code, the target program is run.
6. The program running method according to claim 5, characterized in that: The compiled code includes executable code and bytecode, and running the target program based on the compiled code includes: executing the executable code; The bytecodes are interpreted and executed.
7. The program running method according to claim 6, characterized in that: The bytecode includes an interpretation bytecode and a special bytecode, and the step of interpreting and executing the bytecode includes: interpreting the interpreted bytecode in an interpreted mode; The special bytecode is interpreted in a pre-compilation mode, and the interpretation mode and the pre-compilation mode use the same central processing unit register allocation rule, the same function call rule and the same exception handling rule.
8. A program running device, characterized in that: include: A first acquisition unit, configured to acquire source code of a target program when the target program is run on a device; A processing unit, used to generate a compiled code corresponding to the target program using the source code; The sending unit is used to send the encoding code to the device end, so that the device end runs the target program according to the encoding code.
9. A program running device, characterized in that: include: A second acquisition unit, used to obtain a compilation code corresponding to the target program from a server when determining to run the target program; An operating unit is used to operate the target program based on the compiled code.
10. An electronic device, characterized in that: include: At least one processor, at least one memory and computer program instructions stored in the memory, when the computer program instructions are executed by the processor, implement the method according to any one of claims 1-4 or 5-7.
11. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 4 or 5 to 7 is implemented.