CN114201266A - File execution method and device - Google Patents

File execution method and device Download PDF

Info

Publication number
CN114201266A
CN114201266A CN202111517456.1A CN202111517456A CN114201266A CN 114201266 A CN114201266 A CN 114201266A CN 202111517456 A CN202111517456 A CN 202111517456A CN 114201266 A CN114201266 A CN 114201266A
Authority
CN
China
Prior art keywords
execution
target
file
code object
execution container
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.)
Pending
Application number
CN202111517456.1A
Other languages
Chinese (zh)
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.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology 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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202111517456.1A priority Critical patent/CN114201266A/en
Publication of CN114201266A publication Critical patent/CN114201266A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances

Landscapes

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

Abstract

The present disclosure provides a file execution method and apparatus, wherein the method first responds to an execution instruction for a target file, and detects whether an object code object corresponding to the target file is created; then, under the condition that the target code object is created, acquiring the target code object; finally, an execution container is created under the current thread, and the object code object is executed by using the execution container. According to the method and the device, the execution container is established under the current thread, the target code object is directly executed under the execution container of the current thread, tasks are not required to be allocated by a main thread, the data transmission times under a multi-thread concurrent scene are reduced, the target code object is multiplexed, each thread does not need to carry out byte coding of files, and the execution efficiency of the multi-thread concurrent scene is effectively improved.

Description

File execution method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a file execution method and apparatus.
Background
A Virtual Machine (VM) refers to a complete computer system having complete hardware system functions and operating in a completely isolated environment, which is simulated by software, and can run various programs. The CPython VM is a virtual machine for executing CPython, the CPython is a Python interpreter implemented by C language, and the Python is a computer programming language. CPython initializes various data structures required by Python operation, then interprets the source code into an intermediate code, and finally executes the intermediate code to realize the operation of the program. Due to the architecture problem of CPython, the multi-thread concurrent execution of CPython needs to send a file to the main parser, and then the main parser sends the file to the sub parsers of other threads, and the sub parsers perform parsing and execution, data needs to be transferred between different threads, and when different threads execute the same file, each thread needs to perform an initialization step to obtain a bytecode-based code object, and many repetition steps are performed, so that the operating efficiency is low.
Disclosure of Invention
The embodiment of the disclosure at least provides a file execution method and device.
In a first aspect, an embodiment of the present disclosure provides a file execution method, including:
detecting whether an object code object corresponding to an object file is created or not in response to an execution instruction for the object file;
acquiring the object code object under the condition that the object code object is created;
and creating an execution container under the current thread, and executing the target code object by using the execution container.
In an optional embodiment, before creating an execution container and executing the object code object using the execution container, the method further comprises:
under the condition that the target code object is not created, creating a target code object corresponding to the target file according to the target file; wherein the created object code object can be acquired by other threads except the current thread.
In an alternative embodiment, said executing said object code object with said execution container includes:
under the condition that a creating requirement for a target object exists, creating the target object through the execution container, and configuring a grade label corresponding to the execution container for the target object;
the method further comprises the following steps:
when the execution container detects that an object to be destroyed with the referenced times of 0 exists, determining whether a grade label carried by the object to be destroyed is consistent with a grade label corresponding to the execution container;
and under the condition that the grade label carried by the object to be destroyed is consistent with the grade label corresponding to the execution container, destroying the object to be destroyed by using the execution container.
In an optional implementation manner, the creating, according to the object file, an object code object corresponding to the object file includes:
and compiling the object file into byte codes to obtain the object code object.
In an alternative embodiment, the target file is a Python file.
In an alternative embodiment, said executing said object code object with said execution container includes:
calling a Python interpreter by utilizing the execution container;
and analyzing the target code object by utilizing the Python interpreter, and executing an analysis result of the target code object.
In an optional implementation manner, the created target code object carries identification information corresponding to the current thread;
after executing the object code object with the execution container, the method further comprises:
when the current thread detects that the number of times of the target code object being referred is 0, determining whether identification information carried by the target code object corresponds to the current thread;
and under the condition that the identification information carried by the target code object corresponds to the current thread, destroying the target code object.
In a second aspect, an embodiment of the present disclosure further provides a file execution apparatus, including:
the detection module is used for responding to an execution instruction aiming at a target file and detecting whether a target code object corresponding to the target file is created or not;
an obtaining module, configured to obtain the target code object when the target code object is created;
and the execution module is used for creating an execution container under the current thread and executing the target code object by utilizing the execution container.
In an optional implementation manner, the execution module is further configured to:
under the condition that the target code object is not created, creating a target code object corresponding to the target file according to the target file; wherein the created object code object can be acquired by other threads except the current thread.
In an alternative embodiment, the execution module, when executing the object code object using the execution container, is configured to:
under the condition that a creating requirement for a target object exists, creating the target object through the execution container, and configuring a grade label corresponding to the execution container for the target object;
the apparatus further comprises a destruction module for:
when the execution container detects that an object to be destroyed with the referenced times of 0 exists, determining whether a grade label carried by the object to be destroyed is consistent with a grade label corresponding to the execution container;
and under the condition that the grade label carried by the object to be destroyed is consistent with the grade label corresponding to the execution container, destroying the object to be destroyed by using the execution container.
In an optional implementation manner, when creating, according to the object file, an object code object corresponding to the object file, the execution module is configured to:
and compiling the object file into byte codes to obtain the object code object.
In an alternative embodiment, the target file is a Python file.
In an alternative embodiment, the execution module, when executing the object code object using the execution container, includes:
calling a Python interpreter by utilizing the execution container;
and analyzing the target code object by utilizing the Python interpreter, and executing an analysis result of the target code object.
In an optional implementation manner, the created target code object carries identification information corresponding to the current thread;
the destruction module is further configured to:
when the current thread detects that the number of times of the target code object being referred is 0, determining whether identification information carried by the target code object corresponds to the current thread;
and under the condition that the identification information carried by the target code object corresponds to the current thread, destroying the target code object.
In a third aspect, an embodiment of the present disclosure further provides an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the electronic device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect described above, or any possible implementation of the first aspect.
In a fourth aspect, this disclosed embodiment also provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps in the first aspect or any one of the possible implementation manners of the first aspect.
The file execution method and the file execution device provided by the embodiment of the disclosure firstly respond to an execution instruction aiming at a target file and detect whether a target code object corresponding to the target file is created or not; then, under the condition that the target code object is created, acquiring the target code object; finally, an execution container is created under the current thread, and the object code object is executed by using the execution container. According to the method and the device, the execution container is established under the current thread, the target code object is directly executed under the execution container of the current thread, tasks are not required to be allocated by a main thread, the data transmission times under a multi-thread concurrent scene are reduced, the target code object is multiplexed, each thread does not need to carry out byte coding of files, and the execution efficiency of the multi-thread concurrent scene is effectively improved.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly described below, and the drawings herein incorporated in and forming a part of the specification illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the technical solutions of the present disclosure. It is appreciated that the following drawings depict only certain embodiments of the disclosure and are therefore not to be considered limiting of its scope, for those skilled in the art will be able to derive additional related drawings therefrom without the benefit of the inventive faculty.
FIG. 1 is a flow chart illustrating a file execution method provided by an embodiment of the present disclosure;
FIG. 2 is a schematic diagram illustrating the operation of threads provided by embodiments of the present disclosure;
FIG. 3 is a diagram illustrating an object invocation relationship provided by an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a file execution apparatus provided by an embodiment of the present disclosure;
fig. 5 shows a schematic diagram of an electronic device provided by an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making creative efforts, shall fall within the protection scope of the disclosure.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The term "and/or" herein merely describes an associative relationship, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
Research shows that when an existing CPython virtual machine carries out a multi-thread concurrent task, a main interpreter and a thread are bound with each other, a subsequent task must be submitted on the thread of the main interpreter, so that the subsequent task must be distributed to other sub-interpreters through the main interpreter, the performance is poor, in the process of transferring the task from the main interpreter to the sub-interpreters, because the main interpreter and the sub-interpreters are located in different threads, in order to guarantee the safety among different threads, the transfer of parameters needs to execute copy operation, the performance consumption in task execution is further increased, the private data of different threads need to be isolated, and the isolated data access also consumes more performance.
Based on the above research, the present disclosure provides a file execution method, which directly executes a target code object under an execution container of a current thread by creating the execution container under the current thread, without allocating a task by a main thread, reduces the number of data transmission times in a multi-thread concurrent scenario, and reuses the target code object, thereby effectively improving the execution efficiency in the multi-thread concurrent scenario.
To facilitate understanding of the present embodiment, first, a document execution method disclosed in the embodiments of the present disclosure is described in detail, where an execution subject of the document execution method provided in the embodiments of the present disclosure is generally a computer device with certain computing capability, and the computer device includes, for example: terminal equipment or servers or other processing devices. In some possible implementations, the file execution method may be implemented by a processor calling computer readable instructions stored in a memory.
Referring to fig. 1, a flowchart of a file execution method provided in the embodiment of the present disclosure is shown, where the method includes steps S101 to S103, where:
s101, responding to an execution instruction aiming at a target file, and detecting whether a target code object corresponding to the target file is created or not.
In this step, the computer device serving as the execution subject of the method may run a virtual machine, where the virtual machine may be configured to execute an application program written in a Python language, that is, the target file, the virtual machine may load and initialize the target file, and compile the target file into a bytecode, that is, the target code object, and the virtual machine may run a plurality of threads, and when one thread, that is, when the current thread detects an execution instruction of the target file, may detect whether the target code object corresponding to the target file is created.
The object code object is an executable file obtained by analyzing an object file, the object file can be a Python file, and the object code object corresponding to the object file can be obtained by compiling and analyzing.
In this step, after the current thread receives the task of running the target file, it may be determined first whether the target code object corresponding to the target file has been created by another thread, and if so, the target code object may be directly obtained, thereby omitting the step of analyzing the target file.
After being created, the target code object may be stored in an area accessible by each thread, such as a shared memory, and the current thread may search from the shared memory to search for the target code object, and when querying the target code object, the query may be performed according to information such as a mapping relationship between the target code object and a target file, or identification information of both.
S102, under the condition that the target code object is created, acquiring the target code object.
In this step, in the case that the target code object is found, the target code object may be obtained in a manner including, but not limited to, reading, copying, and the like.
Further, if the target code object cannot be found or is not created, the target code object corresponding to the target file may be created according to the target file, and the created target code may be acquired by a thread other than the current thread.
Therefore, when the target file is executed by other threads, the target code object can be directly obtained, and the step of analysis is omitted.
S103, creating an execution container under the current thread, and executing the target code object by using the execution container.
In this step, an execution container may be created under the current thread, where the execution container may provide an execution environment for the object code object, and may perform tasks such as creating, releasing, caching, and the like on various objects required for executing the object code object, and the creation and destruction of the execution container is light-weight, and consumes less computing resources, and after the object code object is executed by using the execution container, the execution container may be destroyed, thereby implementing mutual isolation between different execution tasks, and ensuring security between multiple threads, thereby reducing computing resources consumed for executing the object file.
For example, in the execution container, context data required for executing the target code object may be provided, and the execution container may obtain objects at multiple levels, such as task level, code level, global level, etc., and variables at the task level are usually temporary variables required for executing operations, and may be created and destroyed by the execution container.
For example, a code-level variable may generally refer to a target code object, which is a variable compiled from a target file; the variables of the global level may be some common objects created when the virtual machine is initialized, and are the highest global level since they are frequently used. Typically, the global level is the highest level and the task level is the lowest level, with the code level between the global and task levels.
Similar to the target code object at the code level, the common variables at the global level and the temporary variables at the task level can be created by other threads and shared.
When the target code object is executed based on the execution container, the execution container may first obtain various common objects required in the global level and the target code object in the code level, create some variables in the required task level, call a Python interpreter using the obtained various variables, analyze the target code object using the Python interpreter to obtain an executable intermediate code, and finally execute the intermediate code, that is, the analysis result of the target code object, to obtain the execution result of the target code object.
After the execution result of the object code object is obtained, the execution container may be destroyed, and when the execution container is destroyed, each object may be released or destroyed according to the level of the execution container and the level of each object called by the execution container.
Referring to fig. 2, a schematic diagram of a thread running provided in the embodiment of the present disclosure is shown. Fig. 2 includes a thread a and a thread B, where the thread a detects whether an object code object CodeObject corresponding to main.py is created when receiving the execution object file main.py, and if it is found that main.py is executed for the first time and the CodeObject is not created, the thread a directly compiles main.py to obtain a CodeObject, stores the CodeObject in a shared memory or a cache, then establishes an execution container Context, executes the CodeObject, and outputs an execution result; py, when the thread B detects the previously created CodeObject, it directly calls the CodeObject, creates a Context, executes the CodeObject, and outputs the execution result.
Therefore, since the thread B can use the CodeObject compiled by the thread a, it is not necessary to compile main.py again, which saves the computing resources, and because of the existence of the execution container, the execution process and the execution result of main.py between the thread a and the thread B are isolated, and a better isolation effect is realized with less computing resources.
Caching and sharing the target code file can reduce the computing resources consumed by multithread execution of the same file, but if the target code file is cached continuously, the problems of memory shortage, slow program response and the like can be caused, so that the life cycle management needs to be carried out on the target code file and other level objects, and unnecessary objects are destroyed.
Firstly, for objects at task level, when an object code object is executed by using an execution container, some temporary objects may need to be created, and these temporary objects may be used as target objects, and in the case that there is a need to create target objects, these target objects may be created by using the execution container, and a level label corresponding to the execution container is configured for the target objects, such as the label at task level as described above; when the execution container detects that the number of times of reference of the object is 0, the object is considered not to be necessary to exist continuously, the grade tags carried by the objects to be destroyed can be determined, and if the grade tags are consistent with the grade tags of the execution container and are task grade, the objects to be destroyed can be destroyed.
Secondly, for a code-level target code object, when a current thread or other threads create the target code object, the target code object may be given identification information corresponding to the current thread, such as the identification information corresponding to the code level, after the target code object is executed by using the execution container, if it is detected that the number of times the target code object is referred to is 0, it may be determined whether the identification information carried by the target code object corresponds to the current thread, and if the identification information carried by the target code object corresponds to the current thread, the target code object may be destroyed.
That is, the thread and the execution container can destroy the corresponding object only when the thread and the execution container have the same level or the level is higher than the other.
In this way, the execution container is prevented from destroying objects in an overriding manner, thereby avoiding system errors caused by missing objects.
Exemplarily, as shown in fig. 3, a schematic diagram of an object invocation relationship provided in the embodiment of the present disclosure is shown. In fig. 3, in the process of executing the target file by the thread a and the thread B, a Code Level container Code Level Context may be called to parse the target file to obtain a Code object (rectangle), then a Task Level Context of the Task Level is established, the Code Level object and Global Level object Global Level Objects (circles) may be called by the Task Level Context, some temporary Objects (triangles) are created, and the execution result is output according to the called object execution Code object, and accordingly, the Code Level Context may destroy the Code object, and the Task Level Context may destroy the temporary Objects.
The file execution method provided by the embodiment of the disclosure includes firstly responding to an execution instruction for a target file, and detecting whether a target code object corresponding to the target file is created; then, under the condition that the target code object is created, acquiring the target code object; finally, an execution container is created under the current thread, and the object code object is executed by using the execution container. According to the method and the device, the execution container is established under the current thread, the target code object is directly executed under the execution container of the current thread, tasks are not required to be allocated by a main thread, the data transmission times under a multi-thread concurrent scene are reduced, the target code object is multiplexed, each thread does not need to carry out byte coding of files, and the execution efficiency of the multi-thread concurrent scene is effectively improved.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
Based on the same inventive concept, a file execution device corresponding to the file execution method is also provided in the embodiments of the present disclosure, and as the principle of solving the problem of the device in the embodiments of the present disclosure is similar to the file execution method in the embodiments of the present disclosure, the implementation of the device may refer to the implementation of the method, and repeated details are not repeated.
Referring to fig. 4, a schematic diagram of a file execution apparatus provided in an embodiment of the present disclosure is shown, where the apparatus includes:
a detection module 410, configured to detect, in response to an execution instruction for a target file, whether an object code corresponding to the target file is created;
an obtaining module 420, configured to obtain the target code object if the target code object is created;
and the execution module 430 is configured to create an execution container under the current thread, and execute the object code object by using the execution container.
In an optional implementation, the executing module 430 is further configured to:
under the condition that the target code object is not created, creating a target code object corresponding to the target file according to the target file; wherein the created object code object can be acquired by other threads except the current thread.
In an alternative embodiment, the execution module 430, when executing the object code object using the execution container, is configured to:
under the condition that a creating requirement for a target object exists, creating the target object through the execution container, and configuring a grade label corresponding to the execution container for the target object;
the apparatus further comprises a destruction module for:
when the execution container detects that an object to be destroyed with the referenced times of 0 exists, determining whether a grade label carried by the object to be destroyed is consistent with a grade label corresponding to the execution container;
and under the condition that the grade label carried by the object to be destroyed is consistent with the grade label corresponding to the execution container, destroying the object to be destroyed by using the execution container.
In an optional implementation manner, when creating the object code object corresponding to the object file according to the object file, the execution module 430 is configured to:
and compiling the object file into byte codes to obtain the object code object.
In an alternative embodiment, the target file is a Python file.
In an alternative embodiment, the execution module 430, when executing the object code object using the execution container, includes:
calling a Python interpreter by utilizing the execution container;
and analyzing the target code object by utilizing the Python interpreter, and executing an analysis result of the target code object.
In an optional implementation manner, the created target code object carries identification information corresponding to the current thread;
the destruction module is further configured to:
when the current thread detects that the number of times of the target code object being referred is 0, determining whether identification information carried by the target code object corresponds to the current thread;
and under the condition that the identification information carried by the target code object corresponds to the current thread, destroying the target code object.
The description of the processing flow of each module in the device and the interaction flow between the modules may refer to the related description in the above method embodiments, and will not be described in detail here.
Corresponding to the file execution method in fig. 1, an embodiment of the present disclosure further provides an electronic device 500, and as shown in fig. 5, a schematic structural diagram of the electronic device 500 provided in the embodiment of the present disclosure includes:
a processor 51, a memory 52, and a bus 53; the storage 52 is used for storing execution instructions and comprises a memory 521 and an external storage 522; the memory 521 is also referred to as an internal memory, and is configured to temporarily store operation data in the processor 51 and data exchanged with an external memory 522 such as a hard disk, the processor 51 exchanges data with the external memory 522 through the memory 521, and when the electronic device 500 operates, the processor 51 communicates with the memory 52 through the bus 53, so that the processor 51 executes the following instructions:
detecting whether an object code object corresponding to an object file is created or not in response to an execution instruction for the object file;
acquiring the object code object under the condition that the object code object is created;
and creating an execution container under the current thread, and executing the target code object by using the execution container.
In an alternative embodiment, before creating the execution container and executing the object code object using the execution container, the processor 51 is further configured to:
under the condition that the target code object is not created, creating a target code object corresponding to the target file according to the target file; wherein the created object code object can be acquired by other threads except the current thread.
In an alternative embodiment, the executing the object code object by the execution container in the instructions executed by the processor 51 includes:
under the condition that a creating requirement for a target object exists, creating the target object through the execution container, and configuring a grade label corresponding to the execution container for the target object;
the processor 51 is further configured to perform:
when the execution container detects that an object to be destroyed with the referenced times of 0 exists, determining whether a grade label carried by the object to be destroyed is consistent with a grade label corresponding to the execution container;
and under the condition that the grade label carried by the object to be destroyed is consistent with the grade label corresponding to the execution container, destroying the object to be destroyed by using the execution container.
In an alternative embodiment, in the instructions executed by the processor 51, the creating, according to the object file, an object code object corresponding to the object file includes:
and compiling the object file into byte codes to obtain the object code object.
In an alternative embodiment, the target file is a Python file.
In an alternative embodiment, the executing the object code object by the execution container in the instructions executed by the processor 51 includes:
calling a Python interpreter by utilizing the execution container;
and analyzing the target code object by utilizing the Python interpreter, and executing an analysis result of the target code object.
In an optional implementation manner, the created target code object carries identification information corresponding to the current thread;
after executing the object code object using the execution container, the processor 51 is further configured to:
when the current thread detects that the number of times of the target code object being referred is 0, determining whether identification information carried by the target code object corresponds to the current thread;
and under the condition that the identification information carried by the target code object corresponds to the current thread, destroying the target code object.
The embodiments of the present disclosure also provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program performs the steps of the file execution method described in the above method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.
The embodiments of the present disclosure also provide a computer program product, where the computer program product carries a program code, and instructions included in the program code may be used to execute steps of the file execution method in the foregoing method embodiments, which may be referred to specifically in the foregoing method embodiments, and are not described herein again.
The computer program product may be implemented by hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK), or the like.
It is clear to those skilled in the art that, for convenience and brevity of description, the above description and the specific working process of the apparatus may refer to the corresponding process in the foregoing method embodiment, and will not be described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present disclosure. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used for illustrating the technical solutions of the present disclosure and not for limiting the same, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive of the technical solutions described in the foregoing embodiments or equivalent technical features thereof within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present disclosure, and should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (10)

1. A file execution method, comprising:
detecting whether an object code object corresponding to an object file is created or not in response to an execution instruction for the object file;
acquiring the object code object under the condition that the object code object is created;
and creating an execution container under the current thread, and executing the target code object by using the execution container.
2. The method of claim 1, wherein prior to creating an execution container and executing the object code object using the execution container, the method further comprises:
under the condition that the target code object is not created, creating a target code object corresponding to the target file according to the target file; wherein the created object code object can be acquired by other threads except the current thread.
3. The method of claim 1, wherein executing the object code object using the execution container comprises:
under the condition that a creating requirement for a target object exists, creating the target object through the execution container, and configuring a grade label corresponding to the execution container for the target object;
the method further comprises the following steps:
when the execution container detects that an object to be destroyed with the referenced times of 0 exists, determining whether a grade label carried by the object to be destroyed is consistent with a grade label corresponding to the execution container;
and under the condition that the grade label carried by the object to be destroyed is consistent with the grade label corresponding to the execution container, destroying the object to be destroyed by using the execution container.
4. The method according to claim 2, wherein the creating an object code object corresponding to the object file according to the object file comprises:
and compiling the object file into byte codes to obtain the object code object.
5. The method according to claim 1, wherein the target file is a Python file.
6. The method of claim 5, wherein executing the object code object using the execution container comprises:
calling a Python interpreter by utilizing the execution container;
and analyzing the target code object by utilizing the Python interpreter, and executing an analysis result of the target code object.
7. The method of claim 2, wherein the created object code object carries identification information corresponding to the current thread;
after executing the object code object with the execution container, the method further comprises:
when the current thread detects that the number of times of the target code object being referred is 0, determining whether identification information carried by the target code object corresponds to the current thread;
and under the condition that the identification information carried by the target code object corresponds to the current thread, destroying the target code object.
8. A file execution apparatus, comprising:
the detection module is used for responding to an execution instruction aiming at a target file and detecting whether a target code object corresponding to the target file is created or not;
an obtaining module, configured to obtain the target code object when the target code object is created;
and the execution module is used for creating an execution container under the current thread and executing the target code object by utilizing the execution container.
9. An electronic device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the electronic device is operating, the machine-readable instructions when executed by the processor performing the steps of the file execution method of any of claims 1 to 7.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the file execution method according to any one of claims 1 to 7.
CN202111517456.1A 2021-12-13 2021-12-13 File execution method and device Pending CN114201266A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111517456.1A CN114201266A (en) 2021-12-13 2021-12-13 File execution method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111517456.1A CN114201266A (en) 2021-12-13 2021-12-13 File execution method and device

Publications (1)

Publication Number Publication Date
CN114201266A true CN114201266A (en) 2022-03-18

Family

ID=80652963

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111517456.1A Pending CN114201266A (en) 2021-12-13 2021-12-13 File execution method and device

Country Status (1)

Country Link
CN (1) CN114201266A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116185497A (en) * 2023-01-06 2023-05-30 格兰菲智能科技有限公司 Command analysis method, device, computer equipment and storage medium
CN116755805A (en) * 2023-08-18 2023-09-15 北京融为科技有限公司 Resource optimization method and device applied to C++, and resource optimization device applied to C++

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116185497A (en) * 2023-01-06 2023-05-30 格兰菲智能科技有限公司 Command analysis method, device, computer equipment and storage medium
CN116185497B (en) * 2023-01-06 2024-05-07 格兰菲智能科技有限公司 Command analysis method, device, computer equipment and storage medium
CN116755805A (en) * 2023-08-18 2023-09-15 北京融为科技有限公司 Resource optimization method and device applied to C++, and resource optimization device applied to C++
CN116755805B (en) * 2023-08-18 2024-02-02 北京融为科技有限公司 Resource optimization method and device applied to C++, and resource optimization device applied to C++

Similar Documents

Publication Publication Date Title
US10514929B2 (en) Computer instruction processing method, coprocessor, and system
US10761905B2 (en) Enhanced code callback
CN102165431B (en) On-the-fly replacement of physical hardware with emulation
US8868848B2 (en) Sharing virtual memory-based multi-version data between the heterogenous processors of a computer platform
US11354159B2 (en) Method, a device, and a computer program product for determining a resource required for executing a code segment
US9092237B2 (en) Serialization of pre-initialized objects
CN114201266A (en) File execution method and device
US10466985B2 (en) Hybrid deoptimization mechanism for class hierarchy analysis
US9336125B2 (en) Systems and methods for hardware-assisted type checking
US9239706B2 (en) Selective speculative class-based optimization
US20200267071A1 (en) Traffic footprint characterization
US8302082B2 (en) Methods and apparatus to provide a managed runtime environment in a sequestered partition
US11294791B2 (en) Code optimization for connected managed runtime environments
CN105849698B (en) Protection is executed in dynamic programming
US20140245260A1 (en) Distributed implementation of sequential code that includes a future
US20180081651A1 (en) Enhanced local commoning
Chen et al. Design and implementation of high-level compute on Android systems
CN114706586A (en) Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium
Bieniusa et al. The architecture of the DecentVM: Towards a decentralized virtual machine for many-core computing
CN105242978A (en) Method and device for processing failure of cache lines of CPU under multi-thread condition
US20130042235A1 (en) Dynamic bootstrap literal processing within a managed runtime environment
Binder Secure and reliable java-based middleware-challenges and solutions
US20240231847A9 (en) Java bytecode injection methods and apparatuses, electronic devices, and storage media
US20240134659A1 (en) Java bytecode injection methods and apparatuses, electronic devices, and storage media
CN116010100A (en) Contract calling method, device, equipment and storage medium in block chain system

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
CB02 Change of applicant information

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Douyin Vision Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: Tiktok vision (Beijing) Co.,Ltd.

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Tiktok vision (Beijing) Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information