CN113076108A - Code execution method and device for code execution - Google Patents

Code execution method and device for code execution Download PDF

Info

Publication number
CN113076108A
CN113076108A CN202110626194.6A CN202110626194A CN113076108A CN 113076108 A CN113076108 A CN 113076108A CN 202110626194 A CN202110626194 A CN 202110626194A CN 113076108 A CN113076108 A CN 113076108A
Authority
CN
China
Prior art keywords
ciphertext
interpreter
source code
target
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110626194.6A
Other languages
Chinese (zh)
Other versions
CN113076108B (en
Inventor
贾晓丰
高嵩
陈洪博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huakong Tsingjiao Information Technology Beijing Co Ltd
Original Assignee
Huakong Tsingjiao Information Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huakong Tsingjiao Information Technology Beijing Co Ltd filed Critical Huakong Tsingjiao Information Technology Beijing Co Ltd
Priority to CN202110626194.6A priority Critical patent/CN113076108B/en
Publication of CN113076108A publication Critical patent/CN113076108A/en
Application granted granted Critical
Publication of CN113076108B publication Critical patent/CN113076108B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0816Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
    • H04L9/085Secret sharing or secret splitting, e.g. threshold schemes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2209/00Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
    • H04L2209/46Secure multiparty computation, e.g. millionaire problem

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The embodiment of the invention provides a code execution method and device and a device for code execution. The method comprises the following steps: according to a grammar rule defined by a preset tool chain, a ciphertext interpreter source code is realized and is used for interpreting a ciphertext operation source code; interpreting and compiling the cipher text interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function; and executing the ciphertext operation source code by utilizing the target interpreter. The target interpreter has a just-in-time compiling function on the basis of the interpreting function of a common interpreter, and the target interpreter is used for executing the ciphertext operation source code, so that the execution efficiency of the ciphertext operation source code can be improved.

Description

Code execution method and device for code execution
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a code execution method and apparatus, and an apparatus for code execution.
Background
The cipher text operation source code refers to a program code for implementing cipher text operation, and the cipher text operation may be operation based on MPC (Secure Muti-Party Computation). MPC is an algorithm that protects data privacy and security. Under the premise of not leaking self data, a plurality of participants can use a multi-party safety computing technology to carry out cooperative computing to obtain a computing result.
For the ciphertext operation source code realized by the interpreted language, an interpreter is needed to interpret the ciphertext operation source code line by line as a bytecode and operate the bytecode at the same time during execution. The interpreted language is characterized by being executed while interpreting, and therefore, each time the ciphertext operation source code is executed, the ciphertext operation source code needs to be executed while being converted, which results in low execution efficiency.
Disclosure of Invention
The embodiment of the invention provides a code execution method and device and a code execution device, which can improve the execution efficiency of a ciphertext operation source code.
In order to solve the above problem, an embodiment of the present invention discloses a code execution method, where the method includes:
according to a grammar rule defined by a preset tool chain, a ciphertext interpreter source code is realized and is used for interpreting a ciphertext operation source code;
interpreting and compiling the cipher text interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function;
and executing the ciphertext operation source code by utilizing the target interpreter.
In another aspect, an embodiment of the present invention discloses a code execution apparatus, including:
the ciphertext interpreter implementation module is used for implementing ciphertext interpreter source codes according to grammar rules defined by a preset tool chain, and the ciphertext interpreter source codes are used for interpreting ciphertext operation source codes;
the target interpreter acquisition module is used for interpreting and compiling the ciphertext interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function;
and the ciphertext operation source code execution module is used for executing the ciphertext operation source code by utilizing the target interpreter.
In yet another aspect, the present invention discloses an apparatus for code execution, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, and the programs include instructions for performing one or more of the code execution methods described above.
In yet another aspect, an embodiment of the invention discloses a machine-readable medium having stored thereon instructions which, when executed by one or more processors of an apparatus, cause the apparatus to perform a code-implemented method as described in one or more of the preceding.
The embodiment of the invention has the following advantages:
according to the grammar rule defined by a preset tool chain, the invention implements a ciphertext interpreter source code, wherein the ciphertext interpreter source code is used for interpreting a ciphertext operation source code; the preset tool chain is a tool which can convert the ciphertext interpreter source code which accords with the grammar rule into a target interpreter, and the target interpreter with the immediate compiling function can be obtained by interpreting and compiling the ciphertext interpreter source code by using the preset tool chain. That is, the target interpreter has a Just-In-Time Compiler (Just-In-Time Compiler) Just-In-Time compilation function of JIT, In addition to the interpretation function of the general interpreter. Therefore, in the process of executing the ciphertext operation source code by using the target interpreter, the target interpreter can interpret and immediately compile the ciphertext operation source code to generate machine code, and then automatically execute the machine code. Compared with the mode of executing the ciphertext operation source code while converting each time, the efficiency of executing the ciphertext operation source code can be greatly improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a flow chart of the steps of one embodiment of a method of code execution of the present invention;
FIG. 2 is a flow chart of the present invention for generating a target interpreter with just-in-time compilation function through a preset tool chain;
FIG. 3 is a block diagram of an embodiment of a code execution apparatus according to the present invention;
FIG. 4 is a block diagram of an apparatus 800 for code execution of the present invention;
fig. 5 is a schematic diagram of a server in some embodiments of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Method embodiment
Referring to fig. 1, a flowchart illustrating steps of an embodiment of a code execution method according to the present invention is shown, where the method may specifically include the following steps:
step 101, according to a grammar rule defined by a preset tool chain, a ciphertext interpreter source code is realized, and the ciphertext interpreter source code is used for interpreting a ciphertext operation source code;
102, interpreting and compiling the cipher text interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function;
and 103, executing the ciphertext operation source code by using the target interpreter.
The embodiment of the invention realizes the target interpreter with the immediate compiling function based on the preset tool chain, and the execution process of the ciphertext operation source code can be accelerated by utilizing the target interpreter to execute the ciphertext operation source code, so that the efficiency of executing the ciphertext operation source code is improved.
The ciphertext operation source code refers to a program source code for the ciphertext processing system to perform data processing on ciphertext data. The data processing for the ciphertext data includes but is not limited to: and data related operations such as cleaning, calculation, analysis, model training, storage, database query and the like of the data are realized based on the ciphertext. It should be noted that the specific type of data processing is not limited by the embodiments of the present invention. The ciphertext processing system may be implemented in different programming languages, and may perform privacy operations on ciphertext data based on a ciphertext data processing algorithm, for example, the ciphertext processing system may be a multi-party secure computing system.
The privacy operation refers to an operation performed on data based on a ciphertext, and the privacy operation may be implemented by a data processing algorithm based on the ciphertext, where the data processing algorithm may include algorithms such as data calculation, model training, database query, and the like. In the privacy operation process of the data, the data exists in a ciphertext mode, and the plaintext of the data cannot be exposed. Optionally, the privacy operations may include any one or more of: cipher text based computing operations, cipher text based model training, cipher text based database query operations, and the like.
For example, the privacy operations may include: and performing calculation operations such as addition, subtraction, multiplication, division, averaging and the like on the data ciphertext, performing comparison operation on the data ciphertext, performing model training and prediction such as machine learning and artificial intelligence by using the data ciphertext, performing database query operation on the data ciphertext, and the like.
It should be noted that the privacy operation may be implemented by invoking a ciphertext computing system, where the ciphertext computing system may be based on a multi-party secure computing protocol, data participating in the computation includes ciphertext data, and an intermediate result and a final computation result generated in the computation process are also ciphertext data. In the calculation process based on the ciphertext, the data plaintext is not exposed, and the privacy security of the data can be ensured.
The privacy operation may be used for data processing of ciphertext data. In some examples, the ciphertext data is a private data, and the technician stores a program containing a business logic for processing the private data in the task management platform in advance, wherein the business logic describes a processing process of the private data through a computer program language, and the processing process can contain one or more computing tasks. The business logic refers to a process that a technician performs data processing on private data by using one or more computing tasks and obtains the private data according to a natural law. For example, one business logic comprises: under the condition that the clear text of the credit rating values of the enterprises is not known, a group of enterprises which are already ranked according to the credit rating scores and another group of enterprises which are already ranked according to the credit rating scores are merged, and the merging process directly completes the ranking. Another business logic includes: under the condition that the repayment ability score plaintext of each user is not known, a group of users which are sequenced according to the repayment ability score and another group of users which are sequenced according to the repayment ability score are combined, and the sequence is directly completed in the combining process. The scheme of the invention is suitable for any privacy operation scene based on the ciphertext.
For the ciphertext operation source code, a ciphertext interpreter source code needs to be defined and implemented, and the ciphertext interpreter source code is used for interpreting the ciphertext operation source code. In order to solve the problem that the efficiency of executing the ciphertext operation source code by the interpreter is low, the embodiment of the invention realizes the ciphertext interpreter source code according to the grammar rule defined by the preset tool chain. The preset tool chain is a tool which can convert the source code of the ciphertext interpreter which accords with the grammar rule into a target interpreter, and the target interpreter is also provided with a JIT just-in-time compiling function on the basis of the interpreting function of a general interpreter.
Specifically, the ciphertext interpreter source code may be implemented based on an interpreted language, and the ciphertext interpreter source code conforms to the grammar rules defined by the preset toolchain. In the embodiment of the present invention, the interpreted language supported by the preset toolchain is referred to as a front-end language. And interpreting the ciphertext interpreter source code realized by the front-end language through a preset tool chain to obtain a rear-end source code of the target interpreter with the just-in-time compiling function, and compiling the rear-end source code through the preset tool chain to generate the target interpreter with the just-in-time compiling function.
In the embodiment of the present invention, the ciphertext operation source code may be implemented based on an interpreted Language, where the interpreted Language includes, but is not limited to, Python Language, SQL (Structured Query Language), and may also be any one of the interpreted languages newly invented in the future.
The target interpreter generated by the embodiment of the invention can execute the ciphertext operation source code in an interpretation and just-in-time compilation acceleration mode. Specifically, the target interpreter may interpret and compile the ciphertext operation source code in real-time to generate machine code, and then automatically execute the machine code. Compared with the mode of executing the ciphertext operation source code while converting each time, the efficiency of executing the ciphertext operation source code can be greatly improved.
In an optional embodiment of the present invention, the interpreting and compiling the ciphertext interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function includes:
step S11, determining the interpretation type language type of the source code of the ciphertext interpreter;
and step S12, according to the grammar rule of the interpreted language type, the preset tool chain is used for interpreting and compiling the ciphertext interpreter source code to generate a target interpreter which is matched with the interpreted language type and has a just-in-time compiling function.
In the embodiment of the invention, the preset tool chain can convert the source codes of the ciphertext interpreters realized by different interpretation type language types into the target interpreters of the corresponding interpretation type language types. For example, for the ciphertext operation source code a implemented by the interpreted language a, a ciphertext interpreter source code a matching the interpreted language a may be written, and the ciphertext interpreter source code a may be used to interpret the ciphertext operation source code a. And interpreting and compiling the ciphertext interpreter source code A through a preset tool chain to obtain the target interpreter A which is matched with the interpreted language A and has the just-in-time compiling function. The target interpreter a may execute the ciphertext operation source code a.
For another example, for the ciphertext operation source code B implemented by the interpretive language B, a ciphertext interpreter source code B matched with the interpretive language B may be written, and the ciphertext interpreter source code B may be used to interpret the ciphertext operation source code B. And interpreting and compiling the ciphertext interpreter source code B through a preset tool chain to obtain a target interpreter B which is matched with the interpreted language B and has a just-in-time compiling function. The target interpreter B may execute the ciphertext operation source code B.
By the embodiment of the invention, for the ciphertext operation source codes realized by different interpretation type languages, ciphertext interpreter source codes conforming to grammar rules of different interpretation type languages can be compiled, and the ciphertext interpreter source codes realized by different interpretation type languages are converted into target interpreters of corresponding interpretation type language types through the preset tool chain. For the ciphertext operation source code realized by the same type of interpretation type language, the universal ciphertext interpreter source code can be realized, and only a target interpreter needs to be realized once.
For example, the ciphertext interpreter source code a may be used as the ciphertext operation source code C implemented by the interpreted language a. And interpreting and compiling the ciphertext interpreter source code A through a preset tool chain to obtain a target interpreter C which is matched with the interpreted language A and has a just-in-time compiling function. The target interpreter C may execute the ciphertext operation source code C.
Compared with the existing compiler which can only adapt to a specific language, the preset tool chain of the embodiment of the invention can support the front-end source code of any interpretation type language type and generate the target interpreter which accords with the corresponding interpretation type language type. By the embodiment of the invention, the target interpreter of the corresponding interpreted language type can be generated by the preset tool chain only by realizing the front-end source codes of different types of interpreted languages, the application range of the target interpreter can be expanded, and the cost of redevelopment can be reduced.
In an optional embodiment of the present invention, the preset tool chain may include a flowchart analyzer, an annotation generator, a back-end generator, and a static compiler, and the interpreting and compiling the ciphertext interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function includes:
step S21, using the flow chart analyzer to perform syntactic analysis on the ciphertext interpreter source code, and generating a flow chart of the ciphertext interpreter source code;
step S22, analyzing and labeling each element in the flowchart by using the annotation generator to obtain a flowchart with annotation;
step S23, traversing the annotated flowchart by the back-end generator, and translating the flowchart into a back-end source code;
step S24, compiling the back-end source code by using the static compiler to obtain a binary file;
and step S25, linking the binary file with the static compiler to obtain a target interpreter with a just-in-time compiling function.
Referring to fig. 2, a flow diagram of generating an object interpreter with just-in-time compiling function through a preset tool chain according to the present invention is shown. As shown in fig. 2, the preset toolchain includes the following modules: a flow chart analyzer 201, an annotation generator 202, a back-end generator 203, and a static compiler 204. Wherein, the flow chart analyzer, the annotation generator and the back-end generator are used for the interpretation stage of the source code of the ciphertext interpreter; the static compiler is used in the compilation stage of the ciphertext interpreter source code.
The flow chart analyzer is used for carrying out syntactic analysis on the ciphertext interpreter source code and generating the flow chart of the ciphertext interpreter source code. The flow chart is constructed by the flow chart analyzer based on the functions in the source code of the ciphertext interpreter, the flow chart can comprise a function call chart and control flow charts of the functions, and the flow chart describes executable paths and function call relations of the source code of the ciphertext interpreter. The elements in the flow chart include, but are not limited to, sub-flow charts, nodes (used to represent functions in the ciphertext interpreter source code), edges (or called connections), variables, and constants.
And the annotation generator is used for analyzing and labeling each element in the flow chart to obtain the flow chart with annotation. The annotations may be used to describe the object types to which the elements correspond, including but not limited to base objects, certificates, strings, tuples, variables and containers, user-defined classes and instances.
And the back-end generator is used for traversing the annotated flow chart and translating the flow chart into back-end source codes which can be identified by the static compiler. Specifically, the back-end generator may translate the annotated flowchart into a back-end source code through a series of processing flows, such as explicit static type conversion, back-end optimization, explicit exception handling, memory recovery management, and language translation. The annotated flow chart is marked with the data types of all the elements, and the back-end generator can convert the data types of all the elements in the flow chart into the static types which can be identified by the static compiler through static type conversion. The back-end source code may be ANSI C language code. It is to be understood that the language type of the intermediate code is not limited by the embodiments of the present invention.
And the static compiler is used for compiling the back-end source code to obtain a binary file.
After the source code of the ciphertext interpreter is interpreted and compiled, the compiled binary file is linked with the static compiler, so that an executable program of the target interpreter can be generated, the target interpreter has a just-in-time compiling function, and the just-in-time compiling function of the target interpreter can be realized by the static compiler.
In an alternative embodiment of the present invention, the preset toolchain may be implemented in an interpreted language with static data type annotation. The interpreted language with static data type label defines a branch of the interpreted language with data type label. For example, for Python language, no data type needs to be defined in the syntax, but in order to enable the preset tool chain to realize the function of adding a just-in-time compiler in the target interpreter, the preset tool chain is required to forcibly require data type labeling and conversion. That is, the preset tool chain has the functions of marking the data type and performing forced conversion on the marking data type. In particular, the function of annotating data types can be implemented by an annotation generator, which can annotate data types of elements in the flow chart. The forced transformation function may be implemented by a back-end generator that may force transformation of the data types of the elements in the annotated flow-chart into data types recognizable to the static compiler.
In an embodiment of the present invention, the interpreted language with static data type markup may be a Python language branch, and the language branch defines mandatory data type markup.
In an optional embodiment of the present invention, a basic grammar model of a ciphertext computing interpretation type code is defined in the preset tool chain, and a ciphertext algorithm module is loaded based on the basic grammar model; the interpreting and compiling the cipher text interpreter source code by using the preset tool chain to obtain the target interpreter with the just-in-time compiling function, comprising the following steps:
and interpreting the source code of the ciphertext interpreter by using the preset tool chain, converting the source code of the ciphertext interpreter, which contains or calls the ciphertext algorithm module, into a flow chart which accords with the grammar rule of the preset tool chain, and embedding the ciphertext algorithm module in the generated target interpreter through the compiling process of the preset tool chain.
In the embodiment of the invention, a basic grammar model of a ciphertext computing interpretation type code is defined in the preset tool chain. The ciphertext calculation interpreted code refers to a source code of ciphertext calculation realized based on the interpreted code in the ciphertext operation source code. The basic grammar model includes, but is not limited to, a flow model (e.g., constant model, variable model, control model, etc.), an object model (integer, floating point, boolean, string, list, dictionary, function, class, object). Based on the basic grammar model of the ciphertext computing interpretation type code, an extension module can be loaded in a preset tool chain, and the extension module comprises but is not limited to a ciphertext algorithm module.
The ciphertext algorithm module may be used to implement privacy operations. The ciphertext algorithm module comprises a ciphertext algorithm function for calculating the ciphertext data. In one example, the ciphertext algorithm module may include a pnumpy module and a ptorch module. The pnumpy module includes the following ciphertext algorithm functions: array operation functions, mathematical functions, linear algebraic functions, statistical functions, random number generation functions, and the like. The ptorch module comprises the following ciphertext algorithm functions: convolution functions, pooling functions, recursive functions, activation functions, and the like.
In a specific implementation, the ciphertext algorithm module may be loaded in a preset tool chain in a manner of declaration and loading based on the basic grammar model. The embodiment of the invention does not limit the implementation language of the ciphertext algorithm function in the ciphertext algorithm module. For example, the ciphertext algorithm function may be implemented based on a C + + language, and compared with a Python language, the operation speed of the privacy operation may be greatly increased, so that the efficiency of ciphertext processing may be improved.
Since the ciphertext algorithm module is loaded in the preset tool chain, in the process of interpreting the ciphertext interpreter source code through the preset tool chain, as in step S21, when the source code of the ciphertext interpreter includes or calls the source code of the ciphertext algorithm library, the source code may be converted into a flowchart conforming to the grammar rule of the preset tool chain, and then the ciphertext algorithm library is built in the generated target interpreter through a series of processing procedures of the preset tool chain shown in fig. 2.
In the embodiment of the invention, all basic grammar models of the ciphertext computing interpretation type code are defined in the preset tool chain, and the ciphertext algorithm module can expand the grammar model of the ciphertext algorithm function according to the basic grammar models. The preset tool chain converts the cipher text interpreter source code facing the user into a grammar model conforming to the preset tool chain, a target interpreter is finally generated through the interpretation and compilation process of the preset tool chain, and the special cipher text algorithm module is built in the target interpreter, so that the cipher text algorithm module can be hidden from the user, and the information leakage of the cipher text algorithm module can be prevented.
In an optional embodiment of the present invention, the executing the ciphertext operation source code with the target interpreter includes:
step S31, the target interpreter is used for interpreting the ciphertext operation source code, the interpreted language in the ciphertext operation source code is converted into a static language code compatible with a just-in-time compiler, and the static language code is compiled into byte codes;
and step S32, compiling the bytecode into machine code and executing the machine code.
In the embodiment of the invention, the target interpreter can execute the ciphertext operation source code in an interpretation and just-in-time compilation acceleration mode.
Specifically, the target interpreter includes an interpretation stage and a compilation stage when executing the ciphertext operation source code. In the interpretation stage, the target interpreter interprets the ciphertext operation source code, converts an interpretation type language in the ciphertext operation source code into a static language code compatible with a just-in-time compiler, and compiles the static language code into a byte code; in the compiling stage, the target interpreter compiles the bytecode into machine code and automatically executes the machine code.
The bytecode is a binary file containing an execution program and composed of a sequence of opcode/data pairs. Bytecode is an intermediate code that is more abstract than machine code and requires translation by an interpreter before it becomes machine code. Machine code is an instruction that a CPU (Central Processing Unit) can directly interpret. The machine code is related to hardware and the like, and the machine code supported by different CPU architectures is different.
Specifically, in the stage of interpreting the ciphertext operation source code, the target interpreter with the just-in-time compiling function performs syntax analysis on the ciphertext operation source code, constructs a flow chart of the ciphertext operation source code according to functions in the ciphertext operation source code, and analyzes and labels each element in the flow chart to obtain the flow chart with annotations; then, static language analysis is carried out on the flow chart with the annotation, and each element in the flow chart is translated into a static language code to obtain the flow chart with the static language code; and compiling the flow chart with the static language codes, compiling the static language codes in the flow chart into machine codes, and obtaining the flow chart with the byte codes. In the execution stage of the cryptograph operation source code, the target interpreter with the just-in-time compiling function can accelerate the execution of the cryptograph operation source code according to the flow chart with the byte codes.
In an optional embodiment of the invention, the method further comprises:
maintaining a memory mapping table and a counter, wherein the memory mapping table records the mapping relation between the bytecode and the machine code corresponding to each node of the flow chart of the ciphertext operation source code, and the counter is used for recording the execution times of each node of the flow chart of the ciphertext operation source code;
the compiling the bytecode into a machine code and executing the machine code includes:
step S41, determining a target node with the counter value larger than a preset threshold value;
step S42, compiling the byte code corresponding to the target node into a machine code, and updating the memory mapping table;
step S43, when a target node in the flowchart of the ciphertext operation source code is executed, obtaining a target address of a machine code corresponding to a bytecode of the target node by querying the memory mapping table;
and step S44, executing the machine code corresponding to the target address.
In the embodiment of the invention, in the process of executing the ciphertext operation source code by using the target interpreter, the flowchart with the byte code is generated in the interpretation stage, and the flowchart with the byte code is processed and executed by using the operation management rule of the just-in-time compiler in the interpretation stage.
The operation management rule of the just-in-time compiler means: by maintaining a memory mapping table and a counter, when the value of the counter is greater than a preset threshold value, a static compiler in a target interpreter is used for compiling the byte codes of the corresponding nodes in the flow chart to generate machine codes, and the memory mapping table is updated. The memory mapping table is used for recording mapping relations between byte codes and machine codes corresponding to nodes of a flow chart of the ciphertext operation source codes, and the counter is used for recording the execution times of the nodes of the flow chart of the ciphertext operation source codes.
The preset threshold value can be set according to actual requirements, and the counter value of the target node is greater than the preset threshold value, which indicates that the execution times of the target node in the whole ciphertext operation source code are more. In this way, when the target node in the flow chart of the ciphertext operation source code is executed again, the target address of the machine code corresponding to the bytecode of the target node can be obtained by querying the memory mapping table, and then the machine code corresponding to the target address can be directly executed. For the target node, the process of converting the code into the byte code and then converting the byte code into the machine code does not need to be executed again each time, and the execution speed of the ciphertext operation source code can be further accelerated.
In the execution stage of the ciphertext operation source code, the target interpreter with the just-in-time compiling function executes the flow chart with the byte code and maintains a memory mapping table and a counter. The mapping relation between the byte codes and the machine codes corresponding to the nodes of the flow chart of the ciphertext operation source codes is recorded in the memory mapping table, and the counter is used for recording the execution times of the nodes of the flow chart of the ciphertext operation source codes. When the counter of a certain node in the flow chart exceeds a preset threshold value, the node is determined to be a target node, a target interpreter with a just-in-time compiling function compiles the byte code corresponding to the target node to generate a machine code, and the memory mapping table is updated. When the target node in the flow chart is executed again, the machine code can be directly executed by inquiring the target address of the machine code corresponding to the bytecode of the target node in the memory mapping table.
In summary, the present invention implements a ciphertext interpreter source code according to a grammar rule defined by a preset toolchain, where the ciphertext interpreter source code is used to interpret a ciphertext operation source code; the preset tool chain is a tool which can convert the ciphertext interpreter source code which accords with the grammar rule into a target interpreter, and the target interpreter with the immediate compiling function can be obtained by interpreting and compiling the ciphertext interpreter source code by using the preset tool chain. That is, the target interpreter has a JIT just-in-time compiling function in addition to the interpreting function of the general interpreter. Therefore, in the process of executing the ciphertext operation source code by using the target interpreter, the target interpreter can interpret and immediately compile the ciphertext operation source code to generate machine code, and then automatically execute the machine code. Compared with the mode of executing the ciphertext operation source code while converting each time, the efficiency of executing the ciphertext operation source code can be greatly improved.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Device embodiment
Referring to fig. 3, a block diagram of a code execution apparatus according to an embodiment of the present invention is shown, where the apparatus may specifically include:
the ciphertext interpreter implementation module 301 is configured to implement a ciphertext interpreter source code according to a grammar rule defined by a preset tool chain, where the ciphertext interpreter source code is used to interpret a ciphertext operation source code;
a target interpreter obtaining module 302, configured to use the preset tool chain to interpret and compile the ciphertext interpreter source code to obtain a target interpreter with a just-in-time compilation function;
a ciphertext operation source code executing module 303, configured to execute the ciphertext operation source code by using the target interpreter.
Optionally, the preset toolchain includes a flowchart analyzer, an annotation generator, a back-end generator, and a static compiler, and the target interpreter acquiring module includes:
the analysis submodule is used for carrying out syntactic analysis on the ciphertext interpreter source code by using the flow chart analyzer to generate a flow chart of the ciphertext interpreter source code;
the annotation submodule is used for analyzing and annotating each element in the flow chart by using the annotation generator to obtain the flow chart with the annotation;
the translation submodule is used for traversing the annotated flow chart by utilizing the back-end generator and translating the flow chart into back-end source codes;
the compiling submodule is used for compiling the back-end source code by using the static compiler to obtain a binary file;
and the link submodule is used for linking the binary file and the static compiler to obtain a target interpreter with a just-in-time compiling function.
Optionally, the target interpreter obtaining module includes:
the language determination submodule is used for determining the interpretation type language type of the source code of the ciphertext interpreter;
and the interpretation and compilation submodule is used for interpreting and compiling the ciphertext interpreter source code by using the preset tool chain according to the grammar rule of the interpreted language type to generate a target interpreter which is matched with the interpreted language type and has a just-in-time compilation function.
Optionally, a basic grammar model of a ciphertext computing interpretation type code is defined in the preset tool chain, and a ciphertext algorithm module is loaded based on the basic grammar model; the target interpreter acquisition module is specifically configured to interpret the ciphertext interpreter source code by using the preset tool chain, convert the source code included in or calling the ciphertext interpreter source code into a flowchart conforming to a grammar rule of the preset tool chain, and embed the ciphertext algorithm module in the generated target interpreter through a compiling process of the preset tool chain.
Optionally, the preset toolchain is implemented by an interpreted language with static data type annotation.
Optionally, the ciphertext operation source code execution module includes:
the source code interpretation submodule is used for interpreting the ciphertext operation source code by using the target interpreter, converting an interpretation language in the ciphertext operation source code into a static language code compatible with a just-in-time compiler, and compiling the static language code into byte codes;
and the compiling and executing submodule is used for compiling the byte codes into machine codes and executing the machine codes.
Optionally, the apparatus further comprises:
the mapping maintenance module is used for maintaining a memory mapping table and a counter, the memory mapping table records the mapping relation between the bytecode and the machine code corresponding to each node of the flow chart of the ciphertext operation source code, and the counter is used for recording the execution times of each node of the flow chart of the ciphertext operation source code;
the compiling execution submodule comprises:
the target determining unit is used for determining a target node of which the counter value is greater than a preset threshold value;
the target compiling unit is used for compiling the byte codes corresponding to the target nodes into machine codes and updating the memory mapping table;
the mapping query unit is used for obtaining a target address of a machine code corresponding to a bytecode of the target node by querying the memory mapping table when the target node in the flow chart of the ciphertext operation source code is executed;
and the target execution unit is used for executing the machine code corresponding to the target address.
According to the grammar rule defined by a preset tool chain, the invention implements a ciphertext interpreter source code, wherein the ciphertext interpreter source code is used for interpreting a ciphertext operation source code; the preset tool chain is a tool which can convert the ciphertext interpreter source code which accords with the grammar rule into a target interpreter, and the target interpreter with the immediate compiling function can be obtained by interpreting and compiling the ciphertext interpreter source code by using the preset tool chain. That is, the target interpreter has a JIT just-in-time compiling function in addition to the interpreting function of the general interpreter. Therefore, in the process of executing the ciphertext operation source code by using the target interpreter, the target interpreter can interpret and immediately compile the ciphertext operation source code to generate machine code, and then automatically execute the machine code. Compared with the mode of executing the ciphertext operation source code while converting each time, the efficiency of executing the ciphertext operation source code can be greatly improved.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
An embodiment of the present invention provides an apparatus for code execution, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the programs comprising instructions for: according to a grammar rule defined by a preset tool chain, a ciphertext interpreter source code is realized and is used for interpreting a ciphertext operation source code; interpreting and compiling the cipher text interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function; and executing the ciphertext operation source code by utilizing the target interpreter.
Optionally, the preset toolchain includes a flowchart analyzer, an annotation generator, a back-end generator, and a static compiler, and the interpreting and compiling the ciphertext interpreter source code by using the preset toolchain to obtain a target interpreter with a just-in-time compiling function includes:
using the flow chart analyzer to perform syntactic analysis on the ciphertext interpreter source code to generate a flow chart of the ciphertext interpreter source code;
analyzing and labeling each element in the flow chart by using the annotation generator to obtain the flow chart with the annotation;
traversing the annotated flowchart with the back-end generator, translating the flowchart into back-end source code;
compiling the back-end source code by using the static compiler to obtain a binary file;
and linking the binary file with the static compiler to obtain the target interpreter with a just-in-time compiling function.
Optionally, the interpreting and compiling the ciphertext interpreter source code by using the preset toolchain to obtain the target interpreter with a just-in-time compiling function includes:
determining an interpreted language type of the ciphertext interpreter source code;
and according to the grammar rule of the interpreted language type, the preset tool chain is utilized to interpret and compile the source code of the ciphertext interpreter, and a target interpreter which is matched with the interpreted language type and has a just-in-time compiling function is generated.
Optionally, a basic grammar model of a ciphertext computing interpretation type code is defined in the preset tool chain, and a ciphertext algorithm module is loaded based on the basic grammar model; the interpreting and compiling the cipher text interpreter source code by using the preset tool chain to obtain the target interpreter with the just-in-time compiling function, comprising the following steps:
and interpreting the source code of the ciphertext interpreter by using the preset tool chain, converting the source code of the ciphertext interpreter, which contains or calls the ciphertext algorithm module, into a flow chart which accords with the grammar rule of the preset tool chain, and embedding the ciphertext algorithm module in the generated target interpreter through the compiling process of the preset tool chain.
Optionally, the preset toolchain is implemented by an interpreted language with static data type annotation.
Optionally, the executing, by the target interpreter, the ciphertext operation source code includes:
the target interpreter is used for interpreting the ciphertext operation source code, an interpretation type language in the ciphertext operation source code is converted into a static language code compatible with a just-in-time compiler, and the static language code is compiled into byte codes;
compiling the bytecode into a machine code, and executing the machine code.
Optionally, the device is also configured to execute the one or more programs by the one or more processors including instructions for:
maintaining a memory mapping table and a counter, wherein the memory mapping table records the mapping relation between the bytecode and the machine code corresponding to each node of the flow chart of the ciphertext operation source code, and the counter is used for recording the execution times of each node of the flow chart of the ciphertext operation source code;
the compiling the bytecode into a machine code and executing the machine code includes:
determining a target node with the counter value larger than a preset threshold value;
compiling the byte codes corresponding to the target nodes into machine codes, and updating the memory mapping table;
when a target node in the flow chart of the ciphertext operation source code is executed, a target address of a machine code corresponding to a bytecode of the target node is obtained by inquiring the memory mapping table;
and executing the machine code corresponding to the target address.
Fig. 4 is a block diagram illustrating an apparatus 800 for code execution in accordance with an example embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 4, the apparatus 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing elements 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 800 is in an operational mode, such as a call mode, a recording mode, and a voice information processing mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed state of the device 800, the relative positioning of the components, such as a display and keypad of the apparatus 800, the sensor assembly 814 may also detect a change in position of the apparatus 800 or a component of the apparatus 800, the presence or absence of user contact with the apparatus 800, orientation or acceleration/deceleration of the apparatus 800, and a change in temperature of the apparatus 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communications between the apparatus 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on radio frequency information processing (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Fig. 5 is a schematic diagram of a server in some embodiments of the invention. The server 1900 may vary widely by configuration or performance and may include one or more Central Processing Units (CPUs) 1922 (e.g., one or more processors) and memory 1932, one or more storage media 1930 (e.g., one or more mass storage devices) storing applications 1942 or data 1944. Memory 1932 and storage medium 1930 can be, among other things, transient or persistent storage. The program stored in the storage medium 1930 may include one or more modules (not shown), each of which may include a series of instructions operating on a server. Still further, a central processor 1922 may be provided in communication with the storage medium 1930 to execute a series of instruction operations in the storage medium 1930 on the server 1900.
The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input-output interfaces 1958, one or more keyboards 1956, and/or one or more operating systems 1941, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
A non-transitory computer-readable storage medium in which instructions, when executed by a processor of an apparatus (server or terminal), enable the apparatus to perform the code-execution method shown in fig. 1.
A non-transitory computer readable storage medium in which instructions, when executed by a processor of an apparatus (server or terminal), enable the apparatus to perform a code-implemented method, the method comprising: according to a grammar rule defined by a preset tool chain, a ciphertext interpreter source code is realized and is used for interpreting a ciphertext operation source code; interpreting and compiling the cipher text interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function; and executing the ciphertext operation source code by utilizing the target interpreter.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
The present invention provides a code execution method, a code execution device and a device for code execution, which have been described in detail above, and the principles and embodiments of the present invention are explained herein by applying specific examples, and the descriptions of the above examples are only used to help understand the method and the core ideas of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (16)

1. A method of code execution, the method comprising:
according to a grammar rule defined by a preset tool chain, a ciphertext interpreter source code is realized and is used for interpreting a ciphertext operation source code;
interpreting and compiling the cipher text interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function;
and executing the ciphertext operation source code by utilizing the target interpreter.
2. The method of claim 1, wherein the preset toolchain comprises a flow chart analyzer, an annotation generator, a back-end generator, and a static compiler, and the interpreting and compiling the ciphertext interpreter source code by using the preset toolchain to obtain a target interpreter with a just-in-time compiling function comprises:
using the flow chart analyzer to perform syntactic analysis on the ciphertext interpreter source code to generate a flow chart of the ciphertext interpreter source code;
analyzing and labeling each element in the flow chart by using the annotation generator to obtain the flow chart with the annotation;
traversing the annotated flowchart with the back-end generator, translating the flowchart into back-end source code;
compiling the back-end source code by using the static compiler to obtain a binary file;
and linking the binary file with the static compiler to obtain the target interpreter with a just-in-time compiling function.
3. The method of claim 1, wherein the interpreting and compiling the ciphertext interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function comprises:
determining an interpreted language type of the ciphertext interpreter source code;
and according to the grammar rule of the interpreted language type, the preset tool chain is utilized to interpret and compile the source code of the ciphertext interpreter, and a target interpreter which is matched with the interpreted language type and has a just-in-time compiling function is generated.
4. The method according to claim 1, wherein a basic grammar model of the ciphertext computing interpretation type code is defined in the preset tool chain, and a ciphertext algorithm module is loaded based on the basic grammar model; the interpreting and compiling the cipher text interpreter source code by using the preset tool chain to obtain the target interpreter with the just-in-time compiling function, comprising the following steps:
and interpreting the source code of the ciphertext interpreter by using the preset tool chain, converting the source code of the ciphertext interpreter, which contains or calls the ciphertext algorithm module, into a flow chart which accords with the grammar rule of the preset tool chain, and embedding the ciphertext algorithm module in the generated target interpreter through the compiling process of the preset tool chain.
5. The method of claim 1, wherein the preset toolchain is implemented in an interpreted language with static data type annotations.
6. The method of claim 1, wherein executing the ciphertext operation source code with the target interpreter comprises:
the target interpreter is used for interpreting the ciphertext operation source code, an interpretation type language in the ciphertext operation source code is converted into a static language code compatible with a just-in-time compiler, and the static language code is compiled into byte codes;
compiling the bytecode into a machine code, and executing the machine code.
7. The method of claim 6, further comprising:
maintaining a memory mapping table and a counter, wherein the memory mapping table records the mapping relation between the bytecode and the machine code corresponding to each node of the flow chart of the ciphertext operation source code, and the counter is used for recording the execution times of each node of the flow chart of the ciphertext operation source code;
the compiling the bytecode into a machine code and executing the machine code includes:
determining a target node with the counter value larger than a preset threshold value;
compiling the byte codes corresponding to the target nodes into machine codes, and updating the memory mapping table;
when a target node in the flow chart of the ciphertext operation source code is executed, a target address of a machine code corresponding to a bytecode of the target node is obtained by inquiring the memory mapping table;
and executing the machine code corresponding to the target address.
8. A code execution apparatus, characterized in that the apparatus comprises:
the ciphertext interpreter implementation module is used for implementing ciphertext interpreter source codes according to grammar rules defined by a preset tool chain, and the ciphertext interpreter source codes are used for interpreting ciphertext operation source codes;
the target interpreter acquisition module is used for interpreting and compiling the ciphertext interpreter source code by using the preset tool chain to obtain a target interpreter with a just-in-time compiling function;
and the ciphertext operation source code execution module is used for executing the ciphertext operation source code by utilizing the target interpreter.
9. The apparatus of claim 8, wherein the preset toolchain comprises a flow chart analyzer, an annotation generator, a back-end generator, and a static compiler, and wherein the target interpreter acquisition module comprises:
the analysis submodule is used for carrying out syntactic analysis on the ciphertext interpreter source code by using the flow chart analyzer to generate a flow chart of the ciphertext interpreter source code;
the annotation submodule is used for analyzing and annotating each element in the flow chart by using the annotation generator to obtain the flow chart with the annotation;
the translation submodule is used for traversing the annotated flow chart by utilizing the back-end generator and translating the flow chart into back-end source codes;
the compiling submodule is used for compiling the back-end source code by using the static compiler to obtain a binary file;
and the link submodule is used for linking the binary file and the static compiler to obtain a target interpreter with a just-in-time compiling function.
10. The apparatus of claim 8, wherein the target interpreter acquisition module comprises:
the language determination submodule is used for determining the interpretation type language type of the source code of the ciphertext interpreter;
and the interpretation and compilation submodule is used for interpreting and compiling the ciphertext interpreter source code by using the preset tool chain according to the grammar rule of the interpreted language type to generate a target interpreter which is matched with the interpreted language type and has a just-in-time compilation function.
11. The apparatus according to claim 8, wherein a basic grammar model of the ciphertext computing interpretive code is defined in the preset tool chain, and a ciphertext algorithm module is loaded based on the basic grammar model; the target interpreter acquisition module is specifically configured to interpret the ciphertext interpreter source code by using the preset tool chain, convert the source code included in or calling the ciphertext interpreter source code into a flowchart conforming to a grammar rule of the preset tool chain, and embed the ciphertext algorithm module in the generated target interpreter through a compiling process of the preset tool chain.
12. The apparatus of claim 8, wherein the preset toolchain is implemented in an interpreted language with static data type markup.
13. The apparatus of claim 8, wherein the ciphertext operation source code execution module comprises:
the source code interpretation submodule is used for interpreting the ciphertext operation source code by using the target interpreter, converting an interpretation language in the ciphertext operation source code into a static language code compatible with a just-in-time compiler, and compiling the static language code into byte codes;
and the compiling and executing submodule is used for compiling the byte codes into machine codes and executing the machine codes.
14. The apparatus of claim 13, further comprising:
the mapping maintenance module is used for maintaining a memory mapping table and a counter, the memory mapping table records the mapping relation between the bytecode and the machine code corresponding to each node of the flow chart of the ciphertext operation source code, and the counter is used for recording the execution times of each node of the flow chart of the ciphertext operation source code;
the compiling execution submodule comprises:
the target determining unit is used for determining a target node of which the counter value is greater than a preset threshold value;
the target compiling unit is used for compiling the byte codes corresponding to the target nodes into machine codes and updating the memory mapping table;
the mapping query unit is used for obtaining a target address of a machine code corresponding to a bytecode of the target node by querying the memory mapping table when the target node in the flow chart of the ciphertext operation source code is executed;
and the target execution unit is used for executing the machine code corresponding to the target address.
15. An apparatus for code execution, the apparatus comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the programs comprising instructions for performing the code execution method of any of claims 1-7.
16. A machine-readable medium having stored thereon instructions which, when executed by one or more processors of an apparatus, cause the apparatus to perform the code-implemented method of any of claims 1 to 7.
CN202110626194.6A 2021-06-04 2021-06-04 Code execution method and device for code execution Active CN113076108B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110626194.6A CN113076108B (en) 2021-06-04 2021-06-04 Code execution method and device for code execution

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110626194.6A CN113076108B (en) 2021-06-04 2021-06-04 Code execution method and device for code execution

Publications (2)

Publication Number Publication Date
CN113076108A true CN113076108A (en) 2021-07-06
CN113076108B CN113076108B (en) 2021-08-20

Family

ID=76617146

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110626194.6A Active CN113076108B (en) 2021-06-04 2021-06-04 Code execution method and device for code execution

Country Status (1)

Country Link
CN (1) CN113076108B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113722754A (en) * 2021-08-25 2021-11-30 上海阵方科技有限公司 Generation method and device of privacy executable file and server
CN117057640A (en) * 2023-07-26 2023-11-14 广东优翼航空技术有限公司 Method and system for evaluating flight quality based on interpreter

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7093119B2 (en) * 2002-07-16 2006-08-15 International Business Machines Corporation Methods and computer program products for protecting source code of an interpreted programming language
CN103064720A (en) * 2011-09-09 2013-04-24 微软公司 Profile guided jit code generation
CN111142876A (en) * 2020-04-02 2020-05-12 华控清交信息科技(北京)有限公司 Compiling processing method and device and compiling processing device
CN111191250A (en) * 2020-04-09 2020-05-22 华控清交信息科技(北京)有限公司 Verification method and device, verification device, server and terminal
CN111258590A (en) * 2020-05-06 2020-06-09 华控清交信息科技(北京)有限公司 Code execution method and device for code execution
CN112667240A (en) * 2020-12-23 2021-04-16 平安普惠企业管理有限公司 Program code conversion method and related device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7093119B2 (en) * 2002-07-16 2006-08-15 International Business Machines Corporation Methods and computer program products for protecting source code of an interpreted programming language
CN103064720A (en) * 2011-09-09 2013-04-24 微软公司 Profile guided jit code generation
CN111142876A (en) * 2020-04-02 2020-05-12 华控清交信息科技(北京)有限公司 Compiling processing method and device and compiling processing device
CN111191250A (en) * 2020-04-09 2020-05-22 华控清交信息科技(北京)有限公司 Verification method and device, verification device, server and terminal
CN111258590A (en) * 2020-05-06 2020-06-09 华控清交信息科技(北京)有限公司 Code execution method and device for code execution
CN112667240A (en) * 2020-12-23 2021-04-16 平安普惠企业管理有限公司 Program code conversion method and related device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113722754A (en) * 2021-08-25 2021-11-30 上海阵方科技有限公司 Generation method and device of privacy executable file and server
CN117057640A (en) * 2023-07-26 2023-11-14 广东优翼航空技术有限公司 Method and system for evaluating flight quality based on interpreter
CN117057640B (en) * 2023-07-26 2024-04-12 广东优翼航空技术有限公司 Method and system for evaluating flight quality based on interpreter

Also Published As

Publication number Publication date
CN113076108B (en) 2021-08-20

Similar Documents

Publication Publication Date Title
CN111142876B (en) Compiling processing method and device and compiling processing device
CN113076108B (en) Code execution method and device for code execution
CN107423106B (en) Method and apparatus for supporting multi-frame syntax
CN111258590B (en) Code execution method and device for code execution
CN114095405B (en) Vehicle function unit testing method and device, electronic equipment and storage medium
CN111736916A (en) Dynamic expansion method and device based on Java language, electronic equipment and storage medium
WO2023087751A1 (en) Application program development platform and method, electronic device, storage medium, and computer program product
CN111736816B (en) Compiling and linking method and device and compiling and linking device
CN111913756B (en) Application program optimizing method, device and system, electronic equipment and storage medium
CN113157256A (en) Interface code generation method and device, electronic equipment, storage medium and product
CN110163372B (en) Operation method, device and related product
CN107832058B (en) Data processing method and device
CN112988194B (en) Program optimization method and device based on equipment information, electronic equipment and storage medium
CN115982204A (en) Query statement conversion method and device, electronic equipment and storage medium
CN115729529A (en) Information processing method, device, equipment and storage medium
CN111695686A (en) Operation method, device and related product
CN113923517B (en) Background music generation method and device and electronic equipment
CN114691104A (en) Language conversion method and device, electronic equipment and storage medium
CN113420531A (en) Code text conversion method and device and storage medium
CN114020264A (en) Operator processing method and device, electronic equipment and storage medium
CN114219443A (en) Document data processing method, device and equipment
CN111736852B (en) Compiling and linking method and device and compiling and linking device
CN112445484A (en) Register processing method and device, electronic equipment and storage medium
CN114020694B (en) Header file address acquisition method and device, electronic equipment and storage medium
CN111626398A (en) Operation method, device and related product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant