WebAssembly data execution method, device, equipment and medium
By integrating multiple analytical execution tools and shared memory management mechanisms in the WASM parsing execution layer, the problem of WebAssembly technology being less used in non-Web environments is solved, and multi-language support and complex data processing for non-Web clients is realized, which improves the ease of use and application efficiency of WASM.
Patent Information
- Application Number
- CN202111538332.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-15
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2041-12-15
AI Technical Summary
The existing WebAssembly technology has fewer applications in non-Web-side environments, mainly due to limited support for data types and lack of effective non-Web-side implementations.
By integrating multiple parsing execution tools in the WASM parsing execution layer, and using the shared memory management mechanism, the data passed by non-Web clients is passed into the WASM parsing execution layer, the corresponding WASM instance is generated, the WASM instance is called to process the data, and the result is returned to the non-Web client.
It extends the application of WebAssembly technology in non-Web environments, solves the problem that non-Web clients cannot effectively transmit complex data, realizes multi-language access, and improves the ease of use and application efficiency of WASM.
Smart Images

Figure CN114168269B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of WebAssembly, and in particular to a WebAssembly data execution method, apparatus, device, and medium, which can be used for processing and executing data of non-web clients in the financial field, and can also be used for processing and executing data of non-web clients in any field other than the financial field. Background Art
[0002] WebAssembly (hereinafter referred to as WASM) adopts the mechanism of "stack-based virtual machine", that is, all the values required by an operator are stored in the stack before the operation. All operators, such as addition, know how many values they need. If two values are needed, it can take two values from the top of the stack. Then the addition instruction can become shorter (single byte) because the instruction does not need to specify the source register and the destination register. This also makes the ".wasm" file smaller, which makes loading the ".wasm" file faster.
[0003] In the existing technical solutions, due to the limited support of WASM for data types and the good support of WASM for the Web side, there is a lack of effective implementation for non-Web scenarios, which also leads to the less application of WebAssembly technology in non-Web environments. Summary of the invention
[0004] In view of the above problems, the present disclosure provides a WebAssembly data execution method, apparatus, device, medium and program product for extending WebAssembly technology for application in non-Web environments.
[0005] According to a first aspect of the present disclosure, a WebAssembly data execution method is provided, including: integrating multiple parsing execution tools through a WASM parsing execution layer; transferring data transmitted by a non-web client to the WASM parsing execution layer by applying for shared memory; selecting a corresponding WASM instance generated by a corresponding parsing execution tool through the data; calling the WASM instance to process the data to obtain an output parameter result; and transferring the output parameter result and returning it to the non-web client by applying for shared memory and releasing the shared memory.
[0006] According to an embodiment of the present disclosure, the data execution method also includes: constructing a WASM instance management layer according to the WASM instance name, WASM instance content and WASM compilation prediction; loading, calling and deleting the WASM instance through the WASM instance management layer.
[0007] According to an embodiment of the present disclosure, integrating multiple parsing execution tools through the WASM parsing execution layer includes: writing a preset interface of the WASM parsing execution layer, wherein the preset interface includes creating an instance interface, calling a method interface, releasing an instance interface, writing a shared memory interface, obtaining a shared memory interface, and releasing a shared memory interface; connecting at least one parsing execution tool that meets the conditions of creating an instance interface, calling a method interface, releasing an instance interface, writing a shared memory interface, obtaining a shared memory interface, and releasing a shared memory interface to the WASM parsing execution layer to obtain multiple parsing execution tools.
[0008] According to an embodiment of the present disclosure, passing data transmitted by a non-web client to a WASM parsing execution layer by applying for shared memory includes: receiving data transmitted by a non-web client and parsing it into byte stream data; applying for a first memory block in the shared memory and writing the byte stream data into the first memory block; passing the memory index of the first memory block and the length of the byte stream data to the WASM parsing execution layer.
[0009] According to an embodiment of the present disclosure, selecting a corresponding WASM instance generated by a corresponding parsing execution tool through data includes: generating multiple WASM instances through multiple parsing execution tools and accessing the WASM instance management layer with the WASM instance name, WASM instance content and WASM compilation prophecy contained in the multiple WASM instances; obtaining the language and calling method of the non-web client through data; matching the WASM compilation language of multiple WASM instances in the WASM instance management layer according to the language, matching the WASM instance names of multiple WASM instances in the WASM instance management layer according to the calling method, and obtaining a matching WASM instance; loading the WASM instance.
[0010] According to an embodiment of the present disclosure, applying for shared memory to transmit the output parameter result and return it to the non-web client and releasing the shared memory includes: calling a WASM instance to add an end marker to the output parameter result and convert it into output parameter byte stream data; applying for a second memory block in the shared memory and writing the output parameter byte stream data into the second memory block; transmitting the memory index of the second memory block and the length of the output parameter byte stream data to the data processing layer; parsing the output parameter byte stream data and sending the output parameter result to the non-web client; releasing the first memory block and the second memory block according to the end marker.
[0011] According to an embodiment of the present disclosure, at least one parsing execution tool includes at least one of wasmer, wasmer-go, wasmer-python, wasmer-java and wasmtime.
[0012] A second aspect of the present disclosure provides a WebAssembly data execution device, including: an integration module, used to integrate multiple parsing execution tools through a WASM parsing execution layer; a transfer module, used to transfer data passed by a non-web client to the WASM parsing execution layer by applying for shared memory; a matching module, used to select a corresponding WASM instance generated by a corresponding parsing execution tool through the data; a processing module, used to call the WASM instance to process data to obtain an output parameter result; and a return module, used to return the output parameter result to the non-web client by applying for shared memory and releasing the shared memory.
[0013] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned WebAssembly data execution method.
[0014] A fourth aspect of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above-mentioned WebAssembly data execution method.
[0015] A fifth aspect of the present disclosure further provides a computer program product, including a computer program, which implements the above-mentioned WebAssembly data execution method when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0017] Figure 1 The application scenario diagram of the WebAssembly data execution method, apparatus, device, medium, and program product according to the embodiment of the present disclosure is schematically shown;
[0018] Figure 2 A flowchart of a WebAssembly data execution method according to an embodiment of the present disclosure is schematically shown;
[0019] Figure 3 A flowchart of a data transmission method according to an embodiment of the present disclosure is schematically shown;
[0020] Figure 4 A flowchart of a data return method according to an embodiment of the present disclosure is schematically shown;
[0021] Figure 5 A flowchart schematically shows a method for integrating multiple parsing execution tools according to an embodiment of the present disclosure;
[0022] Figure 6 A flowchart of a method for matching WASM instances according to an embodiment of the present disclosure is schematically shown;
[0023] Figure 7 The following schematically shows the architecture of the data processing layer according to an embodiment of the present disclosure;
[0024] Figure 8 The schematic diagram shows the architecture of the parsing execution layer according to the embodiment of the present disclosure;
[0025] Fig. 9 A structural block diagram schematically shows a data execution device of WebAssembly according to an embodiment of the present disclosure; and
[0026] Fig.10 A block diagram of an electronic device suitable for implementing a data execution method of WebAssembly according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0027] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0028] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0029] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0030] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0031] It should be noted that the WebAssembly data execution method and device provided in the present disclosure can be used to support non-web clients in the financial field, and can also be used to support non-web clients in any field other than the financial field. The application field of the WebAssembly data execution method and device provided in the present disclosure is not limited.
[0032] Figure 1 An application scenario diagram of a WebAssembly data execution method according to an embodiment of the present disclosure is schematically shown.
[0033] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a client on a terminal device passing in data to call a WASM on a server, and the server executes a data execution method of WebAssembly to process the data. The network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0034] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various financial product applications can be installed on the terminal devices 101, 102, 103.
[0035] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0036] The server 105 may be a server that provides various services, such as calculating the real-time exchange rate called by the user using the terminal devices 101, 102, and 103. The background management server may execute the WebAssembly data execution method disclosed in the present invention to process the incoming calculation parameters and the called implementation exchange rate calling method, and generate the parameter result from the processing result and return it to the terminal devices 101, 102, and 103.
[0037] It should be noted that the data execution method of WebAssembly provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the data execution device of WebAssembly provided in the embodiment of the present disclosure can generally be set in the server 105. The data execution method of WebAssembly provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Correspondingly, the data execution device of WebAssembly provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0038] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0039] The embodiments of the present disclosure provide a data execution method for WebAssembly, wherein WebAssembly (WASM for short) adopts a "stack-based virtual machine" mechanism, that is, all values required by an operator are stored in the stack before the operation is performed. For example, for all operators, such as addition, it is known that several values are required. If addition requires two values, it can be operated by taking two values from the top of the stack. Therefore, the addition instruction can become shorter, and it does not need to specify the source register and the destination register. This makes the file in the ".wasm" format smaller, and thus makes loading the file in the ".wasm" format faster. In the solution in the prior art, due to the limited support of WASM for data types, and the lack of effective implementation for non-Web-side and non-Javascript language scenarios, this also leads to the less application of WebAssembly technology in non-Web-side environments. A WebAssembly data execution method provided in the embodiment of the present disclosure improves WASM's support for non-web environments by transmitting complex data transmitted by non-web clients, utilizing a shared memory management mechanism, and integrating multi-language parsing and execution tools to support corresponding non-web environments. At the same time, WASM is a bytecode, similar to assembly language, and its binary format is highly compact, which can greatly reduce the size of target code files and improve application distribution efficiency. The non-web client in the embodiment of the present disclosure refers to a program running in a non-web environment. For example, a software is developed in Python or Java. If the software calls the WASM provided in the embodiment of the present disclosure by passing in data, it is the non-web client in the present disclosure. The client can be a program installed on a personal computer or an APP installed on a tablet or mobile device.
[0040] The following will be based on Figure 1 The scene described by Figure 2 to Figure 6 The data execution method of WebAssembly of the disclosed embodiment is described in detail.
[0041] Figure 2 The flowchart of the WebAssembly data execution method according to an embodiment of the present disclosure is schematically shown.
[0042] like Figure 2 As shown, the WebAssembly data execution method of this embodiment includes operations S201 to S205 , and the WebAssembly data execution method can be executed by the data processing layer of the server 105 .
[0043] In operation S201, a variety of parsing execution tools are integrated through the WASM parsing execution layer.
[0044] In operation S202, the data transmitted by the non-web client is transferred to the WASM parsing execution layer by applying for shared memory.
[0045] In operation S203, a corresponding WASM instance generated by a corresponding parsing execution tool is selected according to the data.
[0046] In operation S204, the WASM instance is called to process the data to obtain the output parameter result.
[0047] In operation S205, the parameter output result is returned to the non-web client by applying for shared memory and the shared memory is released.
[0048] In a specific embodiment of the present disclosure, the method can be executed by a data processing layer in a server, and the data processing layer includes a WASM parsing execution layer. First, the WASM parsing execution layer integrates parsing execution tools in multiple different languages. The parsing execution tool corresponds to different language environments of non-web clients, and provides service support to non-web clients through parsing execution tools in matching languages. When a non-web client transmits data, such as a financial APP in a mobile phone, the user transmits data including calculation parameters and the method for calculating the deposit business income called to the data processing layer through the APP, and the data processing layer then transmits the data to the WASM parsing execution layer by applying for shared memory; in the WASM parsing execution layer, by matching the language corresponding to the non-web client that transmits the data, the corresponding multi-language execution tool is used for processing, for example, if the writing language environment corresponding to the APP is java, the matching parsing execution tool can be wasmer-java; through the corresponding parsing execution tool, a WASM instance of the corresponding language is generated; the WASM instance is called to process the data, and the output parameter result of the deposit business income in the above example is obtained; finally, a shared memory is applied to return the output parameter result to the APP on the mobile phone of the non-web client.
[0049] The data execution method of WebAssembly disclosed in the present invention utilizes a memory management mechanism to pass data to WASM, solving the problem that non-web clients cannot pass complex data, and implements multi-language access through WASM parsing execution layer parsing execution, which solves the problem of multi-language parsing for non-web clients, expands the application of WASM, and improves the usability of WASM. At the same time, WASM is a bytecode, similar to assembly language, and its binary format is highly compact, which can greatly reduce the size of the target code file, improve the efficiency of application distribution, and reduce the cost pressure of the server segment.
[0050] The WASM instance in the present disclosure is an instantiation code that can be run in WASM and execute the corresponding business logic created by the parsing execution tool. The various parsing execution tools disclosed in the present disclosure include at least one of wasmer, wasmer-go, wasmer-python, wasmer-java and wasmtime. The present disclosure creates multiple instances by integrating multiple parsing execution tools to cope with different non-web client environments. Taking wasmer as an example, it is an open source project written in Rust language. It can be used as a parsing executor to support WebAssembly to run in an ultra-lightweight manner outside the web. In the Rust language, after being compiled into a WASM instance, it can be exposed through methods such as the "#[no_mangle]' tag, so that the instance can be directly called externally through the method name, so that the user does not need to pay attention to the specific operation and implementation of the memory, and directly implements it in the traditional way, such as passing the method and parameters to be executed and getting the corresponding return result.
[0051] In one embodiment of the present disclosure, the WebAssembly data execution method further includes: constructing a WASM instance management layer according to the WASM instance name, WASM instance content, and WASM compilation prediction; and loading, calling, and deleting the WASM instance through the WASM instance management layer. Figure 8 , which schematically shows the architecture diagram of the parsing execution layer according to an embodiment of the present disclosure. The WASM parsing execution layer loads, calls and deletes the WASM instance through the WASM instance management layer, wherein the WASM instance management layer manages through WASM information, and the WASM information includes the WASM instance name, WASM instance content and WASM compilation prediction.
[0052] The WASM instance management layer in the WASM parsing execution layer manages the WASM instances generated by the multi-language parsing execution tools in a targeted manner, and manages them from the perspective of WASM information, including the WASM instance name, WASM instance content, and WASM compilation language. The WASM instance name is the name of the method exposed to the outside, which can be called by non-web clients; the WASM instance content is the specific business execution logic of WASM, which is used to process data; the WASM compilation language is the language of the multi-language parsing execution tool that generates the WASM instance, such as java for wasmer-java. By building WASM instance management in the WASM parsing execution layer, multi-language WASM instances can be managed to improve execution efficiency.
[0053] Figure 3 The flowchart of the data transmission method according to the embodiment of the present disclosure is schematically shown.
[0054] like Figure 3 As shown, the WebAssembly data execution method of this embodiment includes operations S301 to S303.
[0055] In operation S301, data transmitted by a non-web client is received and parsed into byte stream data.
[0056] In operation S302, a first memory block in a shared memory is requested and byte stream data is written into the first memory block.
[0057] In operation S303, the memory index of the first memory block and the length of the byte stream data are passed to the WASM parsing execution layer.
[0058] In one embodiment of the present disclosure, the WebAssembly data execution method operation S202 is implemented by operations S301 to S303. In WASM, a binary bytecode is used, and the data needs to be parsed and converted into byte stream data before transmission.
[0059] See also Figure 7 , which schematically shows an architecture diagram of the data processing layer according to an embodiment of the present disclosure. Among them, the client is a non-web client, which refers to any client that can call this method to execute WASM except for a web page client implemented in a web manner. The data processing layer receives data from a non-web client, parses the data into byte stream data, writes the byte stream data to the first memory block applied for in the shared memory, and passes the memory index of the memory block and the length of the byte stream data to the WASM parsing execution layer in the data processing layer.
[0060] This method converts the data transmitted by the non-web client into byte stream data and uses the memory management mechanism to pass it to the WASM parsing execution layer, solving the problem that the complex data of the non-web client cannot be transmitted to the WASM parsing execution layer.
[0061] Figure 4 The flowchart of the data returning method according to an embodiment of the present disclosure is schematically shown.
[0062] like Figure 4 As shown, the data returning method of this embodiment includes operations S401 to S405.
[0063] In operation S401, the WASM instance is called to add an end mark to the output parameter result and convert it into output parameter byte stream data.
[0064] In operation S402, a second memory block in the shared memory is requested and the output parameter byte stream data is written into the second memory block.
[0065] In operation S403, the memory index of the second memory block and the length of the output parameter byte stream data are passed to the data processing layer.
[0066] In operation S404, the reference byte stream data is parsed and the reference result is sent to the non-web client.
[0067] In operation S405, the first memory block and the second memory block are released according to the end marker.
[0068] In one embodiment of the present disclosure, the data execution method operation S205 of WebAssembly is implemented by operations S401 to S405. The parsing execution layer writes the output parameter byte stream data into the second memory block by applying for shared memory, and passes the memory index of the second memory block and the length of the output parameter byte stream data to the data processing layer. The data processing layer continues to parse the output parameter byte stream data, obtains the output parameter result and returns the output parameter structure to the non-web client, and finally releases the first memory block and the second memory block using the end mark of writing the output parameter byte stream data. In the present disclosure, the first memory block and the second memory block are two memory blocks with different memory addresses, which are used to transmit byte stream data and output parameter byte stream data, respectively.
[0069] This method uses the memory management mechanism to pass the output results of the WASM parsing execution layer to the data processing layer and returns it to the non-web client, uses the end marker to release the requested memory block, and improves the memory management mechanism.
[0070] Figure 5 The flowchart of a method for integrating multiple parsing execution tools according to another embodiment of the present disclosure is schematically shown.
[0071] like Figure 5 As shown, the multiple parsing execution tool integration method of this embodiment includes operations S501 to S502.
[0072] In operation S501, a preset interface of the WASM parsing execution layer is written, wherein the preset interface includes creating an instance interface, calling a method interface, releasing an instance interface, writing a shared memory interface, obtaining a shared memory interface, and releasing a shared memory interface.
[0073] In operation S502, at least one parsing execution tool that meets the preset interface conditions is connected to the WASM parsing execution layer, that is, at least one parsing execution tool that meets the conditions of creating an instance interface, calling a method interface, releasing an instance interface, writing a shared memory interface, obtaining a shared memory interface, and releasing a shared memory interface is connected to the WASM parsing execution layer to obtain multiple parsing execution tools.
[0074] In one embodiment of the present disclosure, the present disclosure integrates multi-language parsing execution tools through a WASM parsing execution layer. First, a preset interface of the WASM parsing execution layer is written, wherein the preset interface includes creating an instance interface, calling a method interface, releasing an instance interface, writing a shared memory interface, obtaining a shared memory interface, and releasing a shared memory interface; finally, at least one parsing execution tool that meets the conditions of creating an instance interface, calling a method interface, releasing an instance interface, writing a shared memory interface, obtaining a shared memory interface, and releasing a shared memory interface is connected to the WASM parsing execution layer.
[0075] The present disclosure provides access and registration services for various third-party parsing execution tools in an interface-oriented manner. In actual applications, the interface specifications can be expanded according to functional requirements to support access to different third-party parsing tools according to different language environments. Among them, each preset interface implements the following functions: create instance interface: create a WASM instance through the specified parsing execution tool, which is used to parse and call WASM files; use method interface: call the specified method exposed in the WASM file through the WASM instance; release instance interface: release the specified WASM instance and the memory it uses; write shared memory interface: write the specified byte stream data to the shared memory in the WASM instance and return the memory index; get shared memory interface: get the byte stream data in the shared memory through the memory index and the byte stream length; release shared memory interface: receive the memory index and length, and release the memory block in the shared memory. The present disclosure realizes the integration of multi-language parsing execution tools by writing preset interfaces corresponding to the shared memory management mechanism of this application.
[0076] Figure 6 A flowchart of a method for matching WASM instances according to yet another embodiment of the present disclosure is schematically shown.
[0077] like Figure 6 As shown, the method for matching WASM instances in this embodiment includes operations S601 to S603.
[0078] In operation S601, the language and calling method of the non-web client are obtained through data.
[0079] In operation S602, a WASM compilation language of a WASM instance in the WASM instance management layer is matched according to the language, and a WASM instance name of a WASM instance in the WASM instance management layer is matched according to the calling method to obtain a matching WASM instance.
[0080] In operation S603 , a WASM instance is loaded.
[0081] In one embodiment of the present disclosure, the method for matching WASM instances of the present disclosure obtains the language environment and the called method of the non-web client through data. The language environment is the compilation language of the non-web client, such as java and python. The called method is the method corresponding to the operation logic that the user needs to execute using the non-web client, such as the method corresponding to the calculation of the income of the deposit business. The parsing execution layer of the present disclosure includes a WASM instance management layer, which is managed by WASM information. The WASM information includes the WASM instance name, WASM instance content and WASM compilation prediction. The language obtained from the above data and the called method are matched with the WASM instance of the WASM instance management layer and loaded. The present disclosure matches and loads the corresponding WASM instance according to the language included in the data and the information of the calling method, thereby solving the problem of multi-language parsing of non-web clients.
[0082] The present disclosure also proposes a system framework diagram of a data execution method based on WebAssembly, such as Figure 7 , Figure 8 As shown. The system framework includes a client and a data processing layer. The client refers to the non-web client in the present disclosure, and its transmission includes calling methods and parameters into the data processing layer. The data processing layer needs to pass the data to the WASM parsing execution layer in the data processing layer. By applying for shared memory and writing data, and returning the location index of the shared memory, the location index and the length of the data are passed to the WASM parsing execution layer for execution according to the corresponding business logic. The obtained execution result, that is, the parameter output result, is transmitted to the WASM parsing execution layer by applying for shared memory. After parsing by the data processing layer, the parameter output result is returned to the client, and the memory is released to end the call.
[0083] In the WASM parsing execution layer, it includes the WASM instance management layer and the parsing execution engine management layer. Among them, the parsing execution engine is the parsing execution tool, which includes at least one of wasmer, wasmer-go, wasmer-python, wasmer-java and wasmtime. The WASM parsing execution layer is written through the parsing execution engine, including: creating instance interface, calling method interface, releasing instance interface, writing shared memory interface, releasing shared memory interface, and obtaining shared memory interface. Through these interfaces, various third-party parsing execution tools are connected. The various WASM instances generated by the access of various parsing execution tools are managed through the WASM instance management layer, including loading instances, calling instances, and deleting instances.
[0084] Based on the above-mentioned WebAssembly data execution method, the present disclosure also provides a WebAssembly data execution device. Fig. 9 The device is described in detail.
[0085] Fig. 9 The structural block diagram of the WebAssembly data execution device according to an embodiment of the present disclosure is schematically shown.
[0086] like Fig. 9 As shown, the WebAssembly data execution device 900 of this embodiment includes an integration module 901, a transfer module 902, a matching module 903, a processing module 904 and a return module 905.
[0087] The integration module 901 is used to integrate the multi-language parsing execution tool through the WASM parsing execution layer. In one embodiment, the integration module 901 can be used to perform the operation S201 described above, which will not be repeated here.
[0088] The transfer module 902 is used to transfer the data transferred by the non-web client to the WASM parsing execution layer by applying for shared memory. In one embodiment, the transfer module 902 can be used to perform the operation S202 described above, which will not be repeated here.
[0089] The matching module 903 is used to select a multi-language parsing execution tool of a corresponding language through a language of a non-web client to generate a WASM instance of the corresponding language. In one embodiment, the matching module 903 can be used to perform the operation S203 described above, which will not be repeated here.
[0090] The processing module 904 is used to call the WASM instance to process the data and obtain the parameter output result. In one embodiment, the processing module 904 can be used to perform the operation S203 described above, which will not be repeated here.
[0091] The return module 905 is used to return the parameter output result to the non-web client by applying for shared memory and release the shared memory. In one embodiment, the return module 905 can be used to perform the operation S203 described above, which will not be repeated here.
[0092] According to an embodiment of the present disclosure, any multiple modules of the integrated module 901, the transfer module 902, the matching module 903, the processing module 904 and the return module 905 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the integrated module 901, the transfer module 902, the matching module 903, the processing module 904 and the return module 905 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware and firmware or by a suitable combination of any of them. Alternatively, at least one of the integration module 901, the transfer module 902, the matching module 903, the processing module 904 and the return module 905 may be at least partially implemented as a computer program module, and when the computer program module is executed, the corresponding function may be performed.
[0093] Fig.10 A block diagram of an electronic device suitable for implementing a data execution method of WebAssembly according to an embodiment of the present disclosure is schematically shown.
[0094] like Fig.10 As shown, the electronic device 1000 according to an embodiment of the present disclosure includes a processor 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. The processor 1001 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 1001 may also include an onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0095] In RAM 1003, various programs and data required for the operation of electronic device 1000 are stored. Processor 1001, ROM 1002 and RAM 1003 are connected to each other via bus 1004. Processor 1001 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 1002 and / or RAM 1003. It should be noted that the program can also be stored in one or more memories other than ROM 1002 and RAM 1003. Processor 1001 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0096] According to an embodiment of the present disclosure, the electronic device 1000 may further include an input / output (I / O) interface 1005, which is also connected to the bus 1004. The electronic device 1000 may further include one or more of the following components connected to the I / O interface 1005: an input portion 1006 including a keyboard, a mouse, etc.; an output portion 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 1008 including a hard disk, etc.; and a communication portion 1009 including a network interface card such as a LAN card, a modem, etc. The communication portion 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage portion 1008 as needed.
[0097] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0098] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 1002 and / or RAM 1003 described above and / or one or more memories other than ROM 1002 and RAM 1003.
[0099] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program includes a program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the WebAssembly data execution method provided by the embodiment of the present disclosure.
[0100] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 1001. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0101] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 1009, and / or installed from the removable medium 1011. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0102] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the processor 1001, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0103] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0104] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0105] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0106] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A WebAssembly data execution method, comprising: Integrate multiple parsing and execution tools through the WASM parsing and execution layer; The data transmitted by the non-web client is transferred to the WASM parsing execution layer by applying for shared memory; Select the corresponding WASM instance generated by the corresponding parsing execution tool according to the data; Call the WASM instance to process the data and obtain the output result; as well as The parameter output result is transmitted and returned to the non-web client by applying for the shared memory and the shared memory is released.
2. The data execution method according to claim 1, further comprising: Construct the WASM instance management layer based on the WASM instance name, WASM instance content, and WASM compilation language; The WASM instance is loaded, called and deleted through the WASM instance management layer.
3. The data execution method according to claim 1 or 2, wherein: The integration of multiple parsing execution tools through the WASM parsing execution layer includes: Write a preset interface of the WASM parsing execution layer, wherein the preset interface includes creating an instance interface, calling a method interface, releasing an instance interface, writing a shared memory interface, obtaining a shared memory interface, and releasing a shared memory interface; connect at least one parsing execution tool that meets the conditions of creating an instance interface, calling a method interface, releasing an instance interface, writing a shared memory interface, obtaining a shared memory interface, and releasing a shared memory interface to the WASM parsing execution layer to obtain the multiple parsing execution tools.
4. According to the data execution method of claim 1 or 2, the transferring of data transmitted by the non-web client to the WASM parsing execution layer by applying for shared memory comprises: Receiving the data transmitted by the non-web client and parsing it into byte stream data; Applying for a first memory block in the shared memory and writing the byte stream data into the first memory block; The memory index of the first memory block and the length of the byte stream data are passed into the WASM parsing execution layer.
5. The data execution method according to claim 2, wherein: The corresponding WASM instance generated by the parsing execution tool corresponding to the data selection includes: Generate multiple WASM instances through multiple parsing execution tools, and connect the WASM instance names, WASM instance contents and WASM compilation languages contained in the multiple WASM instances to the WASM instance management layer; Obtain the language and calling method of the non-web client through the data; Matching the WASM compilation languages of the multiple WASM instances in the WASM instance management layer according to the language, and matching the WASM instance names of the multiple WASM instances in the WASM instance management layer according to the calling method, to obtain the matched WASM instance; Load the WASM instance.
6. According to the data execution method of claim 4, the step of transferring the parameter output result and returning it to the non-web client by applying for the shared memory and releasing the shared memory comprises: Call the WASM instance to add an end mark to the output parameter result and convert it into output parameter byte stream data; Applying for a second memory block in the shared memory and writing the output parameter byte stream data into the second memory block; The memory index of the second memory block and the length of the output parameter byte stream data are transmitted to the data processing layer; Parse the output parameter byte stream data and send the output parameter result to the non-web client; The first memory block and the second memory block are released according to the end identifier.
7. The data execution method according to claim 3, wherein: The at least one parsing execution tool includes at least one of wasmer, wasmer-go, wasmer-python, wasmer-java and wasmtime.
8. A WebAssembly data execution device, comprising: Integration module, used to integrate multiple parsing execution tools through the WASM parsing execution layer; A transfer module, used to transfer data transmitted by non-web clients to the WASM parsing execution layer by applying for shared memory; A matching module, used to select a corresponding WASM instance generated by a corresponding parsing execution tool through the data; A processing module, used for calling the WASM instance to process the data and obtain a parameter output result; as well as The return module is used to return the output parameter result to the non-web client by applying for the shared memory and release the shared memory.
9. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are enabled to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
NVMe equipment debugging function implementation method and device, equipment and storage medium
CN113342590A
WebAssembly-based vector space data analysis method
CN113779168A