Data interaction method and device and storage medium
By setting the same structure and memory layout between the operating system and the low-level bytecode format application, data interaction is directly carried out, and the problem of low data interaction performance in the prior art is solved and efficient data transmission is achieved.
Patent Information
- Application Number
- CN202311170431.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-11
- Publication Date
- 2025-03-11
AI Technical Summary
When data interactions between low-level bytecode format applications and operating systems, prior art requires serializing complex data structures into binary data, resulting in increased performance overhead and execution time.
By determining the same structure and memory layout between the operating system and the low-level bytecode format application, data interaction is performed directly between the operating system and the low-level bytecode format application, avoiding the serialization and deserialization process.
Direct data transmission is realized, avoiding the overhead of serialization and deserialization, and improving the efficiency of data transmission.
Smart Images

Figure CN119597291A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a data interaction method, device and storage medium. Background Art
[0002] The low-level bytecode format is an intermediate representation that is often used to interact or transfer code between different programming languages, platforms, or execution environments. It is a representation that is closer to the underlying machine language than the source code, and contains lower-level instructions, data, and opcodes, as well as corresponding operands. For example, WebAssembly is a low-level bytecode format for executing high-performance binary code in web browsers. It enables developers to run applications in browsers in a way that is closer to native code than traditional JavaScript.
[0003] In the related art, low-level bytecode format applications run in a secure sandbox execution environment isolated from the operating system and cannot directly access the operating system's application programming interface (API). When data interaction is required between low-level bytecode format applications and the local compilation environment, complex data structures need to be serialized into binary data, then passed to the operating system through the application programming interface, and then deserialized by the operating system into a data structure that the operating system can understand. However, this method will bring some additional performance overhead and increase the execution time of the program. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a data interaction method, device and storage medium.
[0005] According to a first aspect of an embodiment of the present disclosure, a data interaction method is provided, the method comprising: in response to determining that data interaction is performed between an operating system of an electronic device and a low-level bytecode format application, determining an identical structure between a compilation system of the operating system and the low-level bytecode format application, the identical structure indicating that the operating system and the low-level bytecode format application have an identical data structure in their respective memory layouts; based on the structure, performing data interaction between the operating system and the low-level bytecode format application.
[0006] In one embodiment, the identical structure is determined in the following manner: determining structure member information of a compilation system in the operating system, the structure member information comprising at least one of the following: structure member type, structure member arrangement order, structure member alignment, padding bytes between structure members, and a total size of the structure; setting the same structure member information for the low-level bytecode format application and the compilation system to obtain the same structure.
[0007] In one embodiment, setting the same structure member information for the low-level bytecode format application and the compilation system includes: in response to the structure member information including the alignment mode of the structure members and / or the padding bytes between the structure members, using alignment control instructions to set the number of alignment bytes of the compilation system; using byte operation instructions to access the structure members of the low-level bytecode format application, and aligning the structure members of the low-level bytecode format application with the structure members of the compilation system according to the number of alignment bytes, and / or performing byte padding between the structure members.
[0008] In one embodiment, the method further comprises: detecting the consistency of the memory layout of the structure set at the low-level bytecode format application and the structure at the compilation system through the static checking function of the compilation system.
[0009] In one embodiment, data interaction is performed between the operating system and the low-level bytecode format application based on the structure, including: determining the address pointer and offset of the data to be interacted in the memory; converting the address pointer and offset into a target memory address, and performing data interaction through the target memory address; the data to be interacted is sent by the operating system, and the target memory address is the memory address of the low-level bytecode format application; the data to be interacted is sent by the low-level bytecode format application, and the target memory address is the memory address of the operating system.
[0010] According to a second aspect of an embodiment of the present disclosure, a data interaction device is provided, comprising: a determination unit, for determining, in response to determining that data interaction is performed between an operating system of an electronic device and a low-level bytecode format application, an identical structure between a compilation system of the operating system and the low-level bytecode format application, wherein the identical structure indicates that the operating system and the low-level bytecode format application have an identical data structure in their respective memory layouts; and a processing unit, for performing data interaction between the operating system and the low-level bytecode format application based on the structure.
[0011] In one embodiment, the determination unit determines the same structure in the following manner: determining structure member information of the compilation system in the operating system, the structure member information including at least one of the following: structure member type, structure member arrangement order, structure member alignment, padding bytes between structure members, and the total size of the structure; setting the same structure member information for the low-level bytecode format application and the compilation system to obtain the same structure.
[0012] In one embodiment, the determination unit sets the same structure member information for the low-level bytecode format application and the compilation system in the following manner: in response to the structure member information including the alignment of the structure members and / or the padding bytes between the structure members, the alignment control instruction is used to set the number of alignment bytes of the compilation system; the byte operation instruction is used to access the structure members of the low-level bytecode format application, and the structure members of the low-level bytecode format application and the structure members of the compilation system are aligned according to the alignment byte number, and / or bytes are filled between the structure members.
[0013] In one embodiment, the device further includes: a detection unit, configured to detect the consistency of the memory layout of the structure set at the low-level bytecode format application and the structure at the compilation system through a static checking function of the compilation system.
[0014] In one embodiment, the processing unit uses the following method to perform data interaction between the operating system and the low-level bytecode format application based on the structure: determine the address pointer and offset of the data to be interacted in the memory; convert the address pointer and offset into a target memory address, and perform data interaction through the target memory address; the data to be interacted is sent by the operating system, and the target memory address is the memory address of the low-level bytecode format application; the data to be interacted is sent by the low-level bytecode format application, and the target memory address is the memory address of the operating system.
[0015] According to a third aspect of the present disclosure, a data interaction device is provided, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to: execute the data interaction method described in the aforementioned first aspect or any one of the embodiments of the first aspect.
[0016] According to a fourth aspect of the present disclosure, a storage medium is provided, characterized in that instructions are stored in the storage medium, and when the instructions in the storage medium are executed by a processor of a terminal, the terminal is enabled to execute the data interaction method described in the aforementioned first aspect or any one of the embodiments of the first aspect.
[0017] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: by setting the operating system of the electronic device and the low bytecode format application to use the same structure and memory layout, it is possible to directly transmit complex structure data between the operating system and the low bytecode format application, avoiding the serialization and deserialization overhead, thereby improving the efficiency of data transmission.
[0018] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0020] Figure 1 The present invention is a flow chart of a data interaction method according to an exemplary embodiment.
[0021] Figure 2 The present invention is a flowchart of a method for determining identical structures according to an exemplary embodiment.
[0022] Figure 3 The present invention is a flowchart of a method for setting member information of the same structure according to an exemplary embodiment.
[0023] Figure 4 The invention is a flow chart showing a method for detecting consistency of memory layout according to an exemplary embodiment.
[0024] Figure 5 The invention is a flowchart showing a method for detecting consistency of memory layout according to an exemplary embodiment.
[0025] Figure 6 The present invention is a block diagram of a data interaction device according to an exemplary embodiment.
[0026] Figure 7 It is a block diagram of a device 200 for data exchange according to an exemplary embodiment. DETAILED DESCRIPTION
[0027] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure.
[0028] The data interaction method provided in the embodiments of the present disclosure can be applied to a scenario where data interaction is performed between an operating system of an electronic device and a low-bytecode format application, for example, data interaction is performed between operating system Webassembly applications.
[0029] In the embodiments of the present disclosure, the low-level bytecode format is an intermediate representation, which is generally used to interact or transmit code between different programming languages, platforms or execution environments. It is a representation that is closer to the underlying machine language than the source code, and contains lower-level instructions, data and opcodes, as well as corresponding operands. For example, WebAssembly is a low-level bytecode format for executing high-performance binary code in a web browser. It enables developers to run applications in a browser in a way that is closer to native code than traditional JavaScript.
[0030] In the related art, applications in low bytecode format similar to WebAssembly usually run on virtual machines. These virtual machines are designed to interpret and execute these bytecodes to achieve application portability across different platforms and environments. A virtual machine is a software platform that runs on top of a host operating system, which can simulate an independent computing environment so that different applications can run on it, and an operating system can refer to the actual operating environment of the host operating system. Data exchange may be required between the two to achieve purposes such as information transfer, collaboration, and resource sharing.
[0031] Low-level bytecode format applications usually run in a secure virtual machine environment that is isolated from the operating system and cannot directly exchange operating system APIs. When data interaction is required between low-level bytecode format applications and the local compilation environment, complex data structures need to be serialized into binary data, then passed to the operating system through the API, and then deserialized by the operating system into a data structure that the operating system can understand.
[0032] Serialization and deserialization is a process of converting data structures into binary data. It can convert complex data structures into a series of bytes, which is convenient for transmission over the network or storage in files. In low-level bytecode format applications, serialization and deserialization can be implemented using byte operation instructions. These instructions can convert data structures in low-level bytecode format applications into binary data, and can transfer data between low-level bytecode format applications and operating systems. A serialization library is a library used to convert data into a format for transmission and storage between different systems and languages. It can convert complex data structures into byte streams for transmission over the network or storage on disk. Common serialization libraries include JSON, Protocol Buffers, MessagePack, and BSON.
[0033] The embodiments of the present disclosure are described below with examples to illustrate the data interaction method of serialization and deserialization involved above, wherein the Webassembly application is used as the low-level bytecode format application and Protocol Buffers is used as the serialization library.
[0034] Before transmitting data, complex data structures need to be serialized. The message type, including the message fields and types, needs to be defined in the .proto file. Use the Protocol Buffers compiler to compile the .proto file into the corresponding code. In the Webassembly application, call the program interface provided by Protocol Buffers to serialize the data. In the operating system, call the program interface provided by Protocol Buffers to convert the data into raw data.
[0035] Serializing and deserializing data may bring some performance overhead, because serialization and deserialization are additional operations that increase the execution time of the program. In addition, serialization and deserialization may also cause the size of the data structure to change, thereby increasing the bandwidth and storage overhead of data transmission.
[0036] In view of this, a data interaction method is proposed in an embodiment of the present disclosure. In the data interaction method provided by the present disclosure, by setting the operating system and the low bytecode format application to use the same structure and memory layout, it is possible to directly transmit structure data between the operating system and the low bytecode format application.
[0037] The data interaction method provided in the embodiments of the present disclosure may be performed by an electronic device, wherein the electronic device may be any device that uses electronic components and technologies to perform specific functions or tasks. For example, examples of electronic devices may include: computers, mobile phones, laptops, tablet computers, PDAs, mobile Internet devices (MIDs), digital cameras, audio players, televisions, routers, sensors, controllers, etc.
[0038] Figure 1 is a flow chart of a data interaction method according to an exemplary embodiment. Figure 1 As shown, the method includes steps S11 to S12.
[0039] In step S11 , in response to determining that data is exchanged between the operating system of the electronic device and the low-level bytecode format application, the same structure between the operating system and the low-level bytecode format application is determined.
[0040] The same structure indicates that the operating system and the low-level bytecode format application have the same data structure in their respective memory layouts. The operating system of the electronic device can be the software and configuration of the computer system, for example, an operating system, a file system, a device driver, a web browser, etc.
[0041] Data exchange may be required between the operating system and the low-level bytecode format application to pass information between different execution environments. This may be calling functions, passing parameters, returning results, etc. The need for data exchange may vary depending on the application type and execution environment.
[0042] In step S12, data interaction is performed between the operating system and the low-level bytecode format application based on the structure.
[0043] Since the same structure is used between the operating system and the low-level bytecode format application, data can be directly exchanged between the operating system and the low-level bytecode format application, thereby eliminating the process of data serialization and deserialization.
[0044] For example, data exchange between the operating system and the low-level bytecode format application can be performed by defining the same structure in the operating system and the low-level bytecode format application, and direct memory access can be achieved through memory address pointers and offsets. It can also be performed by directly passing the structure as a function parameter or return value, so that data exchange between the operating system and the low-level bytecode format application is performed through function calls.
[0045] In the disclosed embodiments, by determining the same structure and memory layout between the operating system and the low-level bytecode format application, direct data interaction between the operating system and the low-level bytecode format application is achieved without the need for serializing and deserializing the data, thereby avoiding additional overhead and improving the efficiency of data transmission.
[0046] Figure 2 is a flowchart of a method for determining identical structures according to an exemplary embodiment. Figure 2 As shown, the method includes steps S21 to S22.
[0047] In step S21, the structure member information of the compilation system in the operating system is determined, and the structure member information includes at least one of the following: structure member type, structure member arrangement order, structure member alignment, padding bytes between structure members, and total size of the structure.
[0048] In an operating system, a compiler system generally refers to a set of tools and programs that convert source code written in a high-level programming language (such as C, C++, etc.) into executable machine code to run on a computer.
[0049] In the compilation system of the operating system, structure member information refers to the relevant information of the members of the structure type defined in the source code, including the member's data type, name, offset, and alignment, etc. This information is used to determine the memory layout of the structure during the compilation process to ensure that its members can be correctly accessed and operated when the same structure is used in different environments.
[0050] In step S22, the same structure member information is set for the low-level bytecode format application and the compilation system to obtain the same structure.
[0051] When using the same structure in the low-level bytecode format application and the compiler system in the operating system, ensure that the structure has the same memory layout between the two, including structure member types, arrangement order, alignment, padding bytes, and total size of the structure.
[0052] The members of a structure can have different data types, such as integers, floating-point numbers, characters, etc. Each member has its own data type, and the structure member type indicates the type of data that the structure can store. The member order of a structure refers to how the members of the structure are stored in order in memory. The member order may affect the layout of the structure in memory.
[0053] Computer memory alignment means that when data is stored in memory, the offset of the starting address of the data in memory should be a multiple of a specific value. The alignment of structure members stipulates that the starting address of the member in memory must be a multiple of a specific value. This is to optimize memory access speed and hardware alignment requirements. Structures usually need to be arranged in memory according to the alignment to ensure efficient access. However, sometimes in order to align members, additional padding bytes are inserted between members so that the starting address of the structure members meets the alignment requirements.
[0054] The total size of a structure refers to the number of bytes that the entire structure occupies in memory. It includes the actual data of the structure members and possible padding bytes.
[0055] In the disclosed embodiment, the same structure is obtained by setting the same structure member information for the low-level bytecode format application and the compilation system. The memory layout of this same structure can make data exchange between the low-level bytecode format application and the operating system more direct and efficient without the need for additional serialization and deserialization processes.
[0056] Figure 3 is a flowchart of a method for setting member information of the same structure according to an exemplary embodiment. Figure 3 As shown, the method includes steps S31 to S32.
[0057] In step S31 , in response to the structure member information including the alignment mode of the structure member and / or the padding bytes between the structure members, the alignment control instruction is used to set the number of alignment bytes of the compilation system.
[0058] The alignment control directive is a preprocessing directive that controls the alignment and padding bytes of structure members of the compiler system. For example, in a C language program, you can use the #pragma pack directive to specify the alignment and padding bytes of the structure. For example, you can use the #pragma pack(4) directive to specify a 4-byte alignment, and use the #pragma pack() directive to cancel the alignment setting.
[0059] In step S32, byte operation instructions are used to access structure members of the low-level bytecode format application, and the structure members of the low-level bytecode format application are aligned with the structure members of the compilation system according to the number of alignment bytes, and / or bytes are filled between the structure members.
[0060] In low-level bytecode format applications, you can use byte manipulation instructions to manually set the memory layout of structure members to achieve the same memory layout as the operating system's compilation system. For example, in a Webassembly application, you can use byte manipulation instructions such as i32.store, i32.store8, and f64.store to store int, char, and double values in specified memory locations, respectively, to achieve the same memory layout of the structure set by the compilation system.
[0061] In the disclosed embodiment, an alignment control instruction is used to set the number of alignment bytes of the compilation system, and the memory storage location and spacing of structure members are simulated by operating bytes to make them consistent with the memory layout generated by the local compiler in the operating system.
[0062] Figure 4 is a flow chart of a method for detecting consistency of memory layout according to an exemplary embodiment. Figure 4 As shown, the method includes step S41.
[0063] In step S41, the static checking function of the compiling system is used to detect the consistency of the memory layout of the structure set at the low-level bytecode format application and the structure at the compiling system.
[0064] The static checking function of the compilation system refers to the analysis of the syntax, structure, type and other characteristics of the source code before the code is compiled into an executable program to check for potential errors, inconsistencies and problems. The static checking function of the compilation system can analyze the definition of the structure at compile time, including member types, alignment and padding bytes, and then calculate the total size of the structure at the compilation stage.
[0065] In the disclosed embodiment, by executing the static checking function of the compilation system at compile time, it can be ensured that the compilation system uses the same structure as the low-level bytecode format application at runtime and sets the same memory layout.
[0066] In one embodiment, the definition file of the structure can also be shared between the operating system compiler system and the low-level bytecode format application, and the structure definition version in the two environments can be kept matching to ensure that the two use the same structure and memory layout. For example, the definition sharing of the structure is achieved through a header file. The header file usually contains the definition of the structure and other necessary declarations and macro definitions. The definition of the structure can be placed in a header file, and it can be ensured that the header file can be correctly referenced and included by both the operating system compiler system and the low-level bytecode format application.
[0067] Figure 5is a flow chart of a method for detecting consistency of memory layout according to an exemplary embodiment. Figure 5 As shown, the method includes steps S51 to S52.
[0068] In step S51, the address pointer and offset of the data to be exchanged in the memory are determined.
[0069] The operating system or low-level bytecode format application needs to determine the address pointer and offset of the data to be exchanged in memory. The address pointer indicates the starting position of the data in memory, and the offset indicates the offset of the data based on the address pointer position. These two values together determine the specific location of the data to be exchanged in memory.
[0070] In step S52, the address pointer and the offset are converted into a target memory address, and data interaction is performed through the target memory address.
[0071] Based on the determined address pointer and offset, they are converted to the target memory address. The target memory address refers to the specific location where data is stored in the operating system or low-level bytecode format application. Through the target memory address, data interaction can be performed, for example, reading and writing operations can be performed on data.
[0072] Among them, in this process, there are two different situations: the data to be exchanged can be sent by the operating system, and the target memory address is the memory address of the low-level bytecode format application. The operating system determines the address pointer and offset of the data to be exchanged, converts it to the target memory address, and then writes the data to the memory address of the low-level bytecode format application. This realizes the sending of data from the operating system to the low-level bytecode format application.
[0073] The data to be exchanged can also be sent by a low-level bytecode format application, and the target memory address is the memory address of the operating system. The low-level bytecode format application determines the address pointer and offset of the data to be exchanged, converts it into the target memory address, and then writes the data to the memory address of the operating system environment. This realizes sending data from the low-level bytecode format application to the operating system.
[0074] In the disclosed embodiment, the address pointer and offset of the data to be exchanged in the memory are determined, the address pointer and the offset are converted into the target memory address, and the data exchange is performed through the target memory address. The overhead of serialization and deserialization is avoided, thereby improving the performance of data exchange. Direct reading and writing of data can be performed faster, reducing additional data conversion steps.
[0075] In one embodiment, data exchange between the operating system and the low-level bytecode format application can be performed by defining the same structure in the operating system and the low-level bytecode format application, and direct memory access can be achieved through memory address pointers and offsets. Alternatively, the structure can be directly passed as a function parameter or return value, so that data exchange between the operating system and the low-level bytecode format application is performed through function calls.
[0076] The data interaction method involved in the embodiment of the present disclosure is described below with examples. The local compiler of the operating system is used as the compilation system, and the Webassembly application is used as the low-level bytecode format application.
[0077] Webassembly is a new low-level bytecode format, a binary instruction format based on a stack-based virtual machine that can run in modern web browsers and other environments. Its purpose is to provide an efficient compilation target for low-level source languages such as C, C++, and Rust. It provides a way for client applications to run code written in multiple languages at near-native speeds on network platforms. It is designed as a portable, high-performance execution format that can be used in areas such as web applications, desktop applications, mobile applications, and embedded systems. Webassembly applications are applications built using WebAssembly technology.
[0078] In WebAssembly, the basic parameter types supported include integers and floating-point numbers. Webassembly applications need to serialize complex data structures into binary data, and then pass them to the operating system through a shared memory mechanism, which is then deserialized by the operating system into a data structure that the operating system can understand, thereby enabling data interaction between the Webassembly application and the operating system.
[0079] In the related art, methods for performing data interaction between an operating system and a Webassembly application without using serialization and deserialization methods include:
[0080] Split the data structure into multiple function parameters or return values, and then transmit them between the operating system and the WebAssembly application. This method can avoid the overhead of serialization and deserialization, but it requires manual splitting and merging of data structures, and the code implementation is cumbersome.
[0081] TCP / IP or other network protocols can be used to transmit data between the operating system and the WebAssembly application. This method can achieve cross-network data exchange, but it needs to consider network latency and bandwidth issues, and the code implementation is relatively complex.
[0082] The data structure can be written to a file and then transferred between the operating system and the WebAssembly application. This method can achieve cross-platform data exchange, but the performance and security of file reading and writing need to be considered, and the code implementation is relatively cumbersome.
[0083] Based on the data interaction method in the embodiment of the present disclosure, it is determined that the operating system and the WebAssembly application use the same structure. As long as the data structure inside the WebAssembly application and the data structure provided by the runtime use the same structure and maintain the same memory layout, these data structures can be directly and transparently accessed between the WebAssembly application and the operating system, thereby avoiding the additional overhead caused by serialization and deserialization and improving data transmission efficiency.
[0084] Among them, the memory layout of the WebAssembly application after compilation is the same as that of the native compiler of the operating system, including:
[0085] The types and order of the structure members are the same as the native compiler's implementation. For example, if the native compiler uses little-endian byte order, then use little-endian byte order in the WebAssembly application as well.
[0086] The alignment of structure members is the same as the native compiler's implementation. For example, if the native compiler uses 4-byte alignment, then the WebAssembly application should also use 4-byte alignment.
[0087] The padding bytes between structure members are the same as the native compiler's implementation. For example, if the native compiler inserts padding bytes between structure members, the WebAssembly application should also insert the same padding bytes.
[0088] The total size of the structure is the same as the native compiler's implementation. For example, if the native compiler inserts padding bytes at the end of the structure, the WebAssembly application should also insert the same padding bytes to ensure that the total size of the structure is the same.
[0089] After defining the structure, the compiler's static check function is used to ensure that the structure has the same size at runtime and on the Wasm application side.
[0090] In the disclosed embodiment, by making the data structure inside the WebAssembly application and the data structure provided at runtime use the same structure and maintain the same memory layout, direct interaction of data between the WebAssembly application and the operating system is achieved, avoiding the overhead caused by serialization and deserialization, and improving the efficiency of data transmission. In addition, since the same structure memory layout is used between the operating system and the WebAssembly application, the structure can be directly passed as a function parameter or return value, avoiding the manual serialization and deserialization process, thereby simplifying the code implementation. Using the same structure memory layout between the operating system and the WebAssembly application avoids the problem of duplicate definitions, thereby improving the readability and maintainability of the code, and the same code can also be used on different platforms, thereby improving the portability of the code.
[0091] Based on the same concept, an embodiment of the present disclosure also provides a data interaction device.
[0092] It is understandable that the data exchange device provided by the embodiment of the present disclosure includes hardware structures and / or software modules corresponding to the execution of each function in order to realize the above functions. In combination with the units and algorithm steps of each example disclosed in the embodiment of the present disclosure, the embodiment of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiment of the present disclosure.
[0093] Figure 6 is a block diagram of a data interaction device according to an exemplary embodiment. Figure 6 The device includes a determining unit 101, a processing unit 102 and a detecting unit 103.
[0094] A determining unit 101 is used to determine the same structure between the compilation system of the operating system and the low-level bytecode format application in response to determining that data is exchanged between the operating system of the electronic device and the low-level bytecode format application, where the same structure indicates that the compilation system and the low-level bytecode format application have the same data structure in their respective memory layouts;
[0095] The processing unit 102 is used for performing data exchange between the operating system and the low-level bytecode format application based on the structure.
[0096] In one embodiment, the determination unit 101 determines the same structure in the following manner: determining structure member information of a compilation system in an operating system, the structure member information including at least one of the following: structure member type, structure member arrangement order, structure member alignment, padding bytes between structure members, and a total size of the structure; setting the same structure member information for a low-level bytecode format application and a compilation system to obtain the same structure.
[0097] In one embodiment, the determination unit 101 sets the same structure member information for the low-level bytecode format application and the compilation system in the following manner: in response to the structure member information including the alignment of the structure members and / or the padding bytes between the structure members, the alignment control instruction is used to set the number of alignment bytes of the compilation system; the byte operation instruction is used to access the structure members of the low-level bytecode format application, and the structure members of the low-level bytecode format application and the structure members of the compilation system are aligned according to the number of alignment bytes, and / or bytes are padding is performed between the structure members.
[0098] In one embodiment, the device further includes: a detection unit 103, which is used to detect the consistency of the memory layout of the structure set at the low-level bytecode format application and the structure at the compilation system through the static checking function of the compilation system.
[0099] In one embodiment, the processing unit uses the following method to perform data exchange between the operating system and the low-level bytecode format application based on the structure: determine the address pointer and offset of the data to be exchanged in the memory; convert the address pointer and offset into a target memory address, and perform data exchange through the target memory address; the data to be exchanged is sent by the operating system, and the target memory address is the memory address of the low-level bytecode format application; the data to be exchanged is sent by the low-level bytecode format application, and the target memory address is the memory address of the operating system.
[0100] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0101] Figure 7 2 is a block diagram of a device 200 for data exchange according to an exemplary embodiment. For example, the device 200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0102] Reference Figure 7, the device 200 may include one or more of the following components: a processing component 202 , a memory 204 , a power component 206 , a multimedia component 208 , an audio component 210 , an input / output (I / O) interface 212 , a sensor component 214 , and a communication component 216 .
[0103] The processing component 202 generally controls the overall operation of the device 200, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 202 may include one or more processors 220 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 202 may include one or more modules to facilitate interaction between the processing component 202 and other components. For example, the processing component 202 may include a multimedia module to facilitate interaction between the multimedia component 208 and the processing component 202.
[0104] The memory 204 is configured to store various types of data to support operations on the device 200. Examples of such data include instructions for any application or method operating on the device 200, contact data, phone book data, messages, pictures, videos, etc. The memory 204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0105] The power component 206 provides power to the various components of the device 200. The power component 206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 200.
[0106] The multimedia component 208 includes a screen that provides an output interface between the device 200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 208 includes a front camera and / or a rear camera. When the device 200 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0107] The audio component 210 is configured to output and / or input audio signals. For example, the audio component 210 includes a microphone (MIC), and when the device 200 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 204 or sent via the communication component 216. In some embodiments, the audio component 210 also includes a speaker for outputting audio signals.
[0108] I / O interface 212 provides an interface between processing component 202 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0109] The sensor assembly 214 includes one or more sensors for providing various aspects of the status assessment of the device 200. For example, the sensor assembly 214 can detect the open / closed state of the device 200, the relative positioning of components, such as the display and keypad of the device 200, the sensor assembly 214 can also detect the position change of the device 200 or a component of the device 200, the presence or absence of user contact with the device 200, the orientation or acceleration / deceleration of the device 200 and the temperature change of the device 200. The sensor assembly 214 can include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 214 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 214 can also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.
[0110] The communication component 216 is configured to facilitate wired or wireless communication between the device 200 and other devices. The device 200 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 216 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 216 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0111] In an exemplary embodiment, the apparatus 200 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.
[0112] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 204 including instructions, and the instructions can be executed by the processor 220 of the device 200 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0113] It is to be understood that in the present disclosure, "plurality" refers to two or more than two, and other quantifiers are similar. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. The singular forms "a", "the" and "the" are also intended to include plural forms, unless the context clearly indicates other meanings.
[0114] It is further understood that the terms "first", "second", etc. are used to describe various information, but such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other, and do not indicate a specific order or degree of importance. In fact, the expressions "first", "second", etc. can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information.
[0115] It can be further understood that, unless otherwise specified, “connection” includes a direct connection without other components between the two, and also includes an indirect connection with other components between the two.
[0116] It is further understood that, although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood as requiring the operations to be performed in the specific order shown or in a serial order, or requiring the execution of all the operations shown to obtain the desired results. In certain environments, multitasking and parallel processing may be advantageous.
[0117] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modifications, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.
[0118] It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the scope of the appended claims.
Claims
1. A data interaction method, characterized in that: include: In response to determining that data is exchanged between an operating system of the electronic device and a low-level bytecode format application, determining a common structure between the operating system and the low-level bytecode format application, wherein the common structure indicates that the operating system and the low-level bytecode format application have a common data structure in their respective memory layouts; Based on the structure, data interaction is performed between the operating system and a low-level bytecode format application.
2. The data interaction method according to claim 1, characterized in that: The same structure is determined in the following manner: Determine structure member information of the compilation system in the operating system, wherein the structure member information includes at least one of the following: structure member type, structure member arrangement order, structure member alignment, padding bytes between structure members, and total size of the structure; The same structure member information is set for the low-level bytecode format application and the compilation system to obtain the same structure.
3. The data interaction method according to claim 2, characterized in that: The setting the same structure member information for the low-level bytecode format application and the compilation system includes: In response to the structure member information including the alignment mode of the structure member and / or the padding bytes between the structure members, using the alignment control instruction to set the number of alignment bytes of the compilation system; The structure members of the low-level bytecode format application are accessed using byte operation instructions, and the structure members of the low-level bytecode format application are aligned with the structure members of the compilation system according to the alignment byte number, and / or bytes are filled between the structure members.
4. The data interaction method according to claim 2 or 3, characterized in that: The method further comprises: The consistency of the memory layout between the structure set at the low-level bytecode format application and the structure at the compilation system is detected through the static checking function of the compilation system.
5. The data interaction method according to claim 1, characterized in that: The data interaction between the operating system and the low-level bytecode format application based on the structure includes: Determine the address pointer and offset of the data to be interacted with in the memory; Convert the address pointer and the offset into a target memory address, and perform data exchange through the target memory address; The data to be interacted is sent by the operating system, and the target memory address is the memory address of the low-level bytecode format application; The data to be interacted with is sent by the low-level bytecode format application, and the target memory address is the memory address of the operating system.
6. A data interaction device, characterized in that: include: a determining unit, configured to determine, in response to determining that an operating system of an electronic device and a low-level bytecode format application perform data interaction, a common structure between the operating system and the low-level bytecode format application, wherein the common structure indicates that the operating system and the low-level bytecode format application have a common data structure in their respective memory layouts; A processing unit is used for performing data exchange between the operating system and a low-level bytecode format application based on the structure.
7. The data interaction device according to claim 6, characterized in that: The determining unit determines the same structure in the following manner: Determine structure member information of the compilation system in the operating system, wherein the structure member information includes at least one of the following: structure member type, structure member arrangement order, structure member alignment, padding bytes between structure members, and total size of the structure; The same structure member information is set for the low-level bytecode format application and the compilation system to obtain the same structure.
8. The data interaction device according to claim 7, characterized in that: The determining unit sets the same structure member information for the low-level bytecode format application and the compiling system in the following manner: In response to the structure member information including the alignment mode of the structure member and / or the padding bytes between the structure members, using the alignment control instruction to set the number of alignment bytes of the compilation system; The structure members of the low-level bytecode format application are accessed using byte operation instructions, and the structure members of the low-level bytecode format application are aligned with the structure members of the compilation system according to the alignment byte number, and / or bytes are filled between the structure members.
9. The data interaction device according to claim 7 or 8, characterized in that: The device also includes: The detection unit is used to detect the consistency of the memory layout of the structure set at the low-level bytecode format application and the structure at the compilation system through the static checking function of the compilation system.
10. The data interaction device according to claim 6, characterized in that: The processing unit performs data exchange between the operating system and the low-level bytecode format application based on the structure in the following manner: Determine the address pointer and offset of the data to be interacted in the memory; Convert the address pointer and the offset into a target memory address, and perform data exchange through the target memory address; The data to be interacted is sent by the operating system, and the target memory address is the memory address of the low-level bytecode format application; The data to be interacted with is sent by the low-level bytecode format application, and the target memory address is the memory address of the operating system.
11. A data interaction device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: execute the method described in any one of claims 1 to 5.
12. A storage medium, characterized in that: The storage medium stores instructions, and when the instructions in the storage medium are executed by a processor of the terminal, the terminal is enabled to execute the method according to any one of claims 1 to 5.