File loading method and device and storage medium
By separating the function part and string part of the javascript file and integrating the string into the public string file, the problem of repeated storage and loading in javascript file loading is solved, and a more efficient loading process and faster application startup is achieved.
Patent Information
- Application Number
- CN202311865483.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-07-01
AI Technical Summary
When loading javascript files, in the prior art, since each file generates an independent bytecode file, the strings are repeatedly stored and loaded repeatedly, increasing the system load and extending the application startup time.
Separate the function part and the string part, generate separate files, integrate the strings used in multiple javascript files into the public string file, and allocate them in the target memory. The public string file is directly called during loading, avoiding repeated loading and storage.
Improve file loading efficiency, reduce system load, and speed up application startup speed.
Smart Images

Figure CN120234056A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of file processing, and in particular, to a file loading method, apparatus, and storage medium. Background Art
[0002] With the development of computer technology, various computer programming languages have also developed. Taking JavaScript (an interpreted scripting language) as an example, when executing a JavaScript file, the JavaScript file will first be compiled into a bytecode file, and then the bytecode file will be executed in the way of a stack-based virtual machine; this process of executing the JavaScript file can also be called the loading process of the JavaScript file. Summary of the Invention
[0003] To overcome the problems existing in the related art, the present disclosure provides a file loading method, apparatus, and storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, a file loading method is provided. A common string file is pre-created, and the common string file includes a plurality of strings required by a program code file. The plurality of strings are allocated in a target memory. The file loading method includes: obtaining a bytecode file corresponding to a target program code file, where the bytecode file includes functions used in the target program code file; loading the bytecode file and calling the common string file to complete the loading of the target program code file.
[0005] In an optional implementation manner, the file loading method further includes: creating the common string file; storing the common string file in the target memory so that the plurality of strings are allocated in the target memory.
[0006] In an optional implementation manner, the creating the common string file includes: respectively extracting strings used in a plurality of program code files to obtain a plurality of strings required by the program code files, where the plurality of program code files include the target program code file; creating the common string file according to the plurality of strings.
[0007] In an optional implementation manner, the creating the common string file according to the plurality of strings includes: performing a deduplication process on the plurality of strings to obtain a plurality of strings after the deduplication process; creating the common string file according to the plurality of strings after the deduplication process.
[0008] In an alternative embodiment, the file loading method is applied to a loading engine, and the file loading method further includes: determining string information corresponding to each of the multiple strings, where the string information is the information required by the loading engine to use the strings; correspondingly, creating the common string file according to the multiple strings includes: creating the string file according to the multiple strings and the string information corresponding to each of the multiple strings.
[0009] In an alternative embodiment, the file loading method further includes: saving a snapshot corresponding to the common string file, where the snapshot corresponding to the common string file can be used to create the common string file.
[0010] In an alternative embodiment, the file loading method further includes: creating the common string file according to a preset snapshot of the common string file.
[0011] In an alternative embodiment, the program code file is a program code file of an interpreted scripting language, and the file loading method is applied to the loading engine corresponding to the interpreted scripting language.
[0012] According to a second aspect of the embodiments of the present disclosure, there is provided a file loading device. A common string file is pre-created, where the common string file includes multiple strings required by a program code file, and the multiple strings are allocated in a target memory. The file loading device includes: an acquisition module configured to acquire a bytecode file corresponding to a target program code file, where the bytecode file includes functions used in the target program code file; a loading module configured to load the bytecode file and call the common string file to complete the loading of the target program code file.
[0013] According to a third aspect of the embodiments of the present disclosure, there is provided a file loading device, including: a processor; a memory for storing processor-executable instructions; where the processor is configured to: execute the steps of the file loading method provided in the first aspect of the present disclosure.
[0014] According to a fourth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, on which computer program instructions are stored, and when the program instructions are executed by a processor, the steps of the file loading method provided in the first aspect of the present disclosure are implemented.
[0015] The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects: By pre-creating a common string file, which includes multiple strings required by the program code file, and these multiple strings are allocated in the target memory. When loading the program code file, directly loading the bytecode file and calling the common string file can complete the loading of the program code file; Since the strings in the common string file have been allocated in the target memory, there is no need to load each string into the memory separately, thereby improving the loading efficiency of the file, reducing the system load, and enhancing the application startup speed.
[0016] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.
[0018] Figure 1 is a flowchart of a file loading method shown according to an exemplary embodiment.
[0019] Figure 2A is a schematic diagram of a program code file shown according to an exemplary embodiment.
[0020] Figure 2B is a schematic diagram of a loaded file shown according to an exemplary embodiment.
[0021] Figure 3 is a block diagram of a file loading device shown according to an exemplary embodiment.
[0022] Figure 4 is a block diagram of a file loading device shown according to an exemplary embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0023] Here, the exemplary embodiments will be described in detail, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. On the contrary, they are only examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0024] It should be noted that all actions of obtaining signals, information, or data in the present disclosure are carried out on the premise of complying with the corresponding data protection regulations and policies of the country where the location is located and obtaining the authorization given by the owner of the corresponding device.
[0025] With the development of computer technology, various computer programming languages have also developed. Taking JavaScript (an interpreted scripting language) as an example, when executing a JavaScript file, the JavaScript file will first be compiled into a bytecode file, and then the bytecode file will be executed through a stack-based virtual machine; this process of executing the JavaScript file can also be called the loading process of the JavaScript file.
[0026] JavaScript is a programming language originally designed to add interactivity to web pages in browsers. It is a dynamic, weakly typed, prototype-based language and has the characteristic that functions are first-class objects. JavaScript can run directly in the browser without being compiled into binary code. It is a high-level language, meaning that developers can write code directly without manually managing memory. JavaScript can be used to create dynamic web pages, such as responding to user click events, changing web page content, creating animation effects, etc. It can also be used for server-side programming. JavaScript is a very popular programming language and is widely used in fields such as website development, mobile application development, game development, and desktop application development.
[0027] The loading of JavaScript files can be applied to the loading process of programs. In some application scenarios, in order to speed up the startup speed, the JavaScript file loading engine QuickJS compiles the JavaScript file into a bytecode file in advance and directly loads the bytecode file at startup to achieve the purpose of optimizing the startup speed.
[0028] In related technologies, when QuickJS generates a bytecode file, the entire JavaScript file is compiled into an independent bytecode file. The bytecode file contains two parts: function (i.e., function) code and strings. The string part stores each string separately. When QuickJS runs the bytecode file, it will separately call malloc (a system processing function) for each string to allocate memory and load it until all strings are loaded and then start executing the function code. When QuickJS executes multiple bytecode files, the strings in the bytecode files will be stored and loaded repeatedly, increasing the system load.
[0029] A bytecode file is a binary file containing an executable program, consisting of a sequence of code / data pairs. It is an intermediate code, more abstract than machine code. A bytecode file is usually regarded as a binary file containing an executable program, more like an object model.
[0030] In Java, bytecode files usually have the suffix ".class". These files contain the binary representation of the compiled Java source code and can be run on the Java Virtual Machine (JVM). The magic number (the first 4 bytes of each Class file) of the bytecode file has the value 0xCAFEBABE, which is used to determine whether this file is a Class file acceptable to the virtual machine.
[0031] In related technologies, since each JavaScript file generates a bytecode file, and the bytecode file contains the strings used in the JavaScript file, when multiple JavaScript files generate multiple bytecode files, there are duplicate strings in the bytecode files.
[0032] Moreover, since QuickJS parses and loads each string separately when loading the bytecode file, and there are generally a large number of strings in the JavaScript file, it increases the load of the system's malloc and also increases the startup time of the application.
[0033] Based on this, the embodiments of the present disclosure provide a technical solution. In this technical solution, when generating the bytecode file, the function part and the string part are no longer generated in one bytecode file, but the function part and the string part are separated to generate separate individual files. Thus, the function part is equivalent to using the original bytecode file, and the string part is separated from the original bytecode file. Then, for multiple JavaScript files, the strings used in the multiple JavaScript files can be integrated into a common string file and allocated in the target memory. When loading the file, the strings can be directly called, which can, to a certain extent, avoid the problems of repeated loading and repeated storage of strings, and thus achieve technical effects such as improving the file loading efficiency, reducing the system load, and accelerating the startup speed of the application.
[0034] Figure 1 is a flowchart of a file loading method shown according to an exemplary embodiment, as Figure 1 shown, the file loading method is used in a terminal, wherein a common string file is pre-created, the common string file includes multiple strings required by the program code file, and the multiple strings are allocated in the target memory; the method includes the following steps.
[0035] Step S11, obtain the bytecode file corresponding to the target program code file, and the bytecode file includes the functions used in the target program code file.
[0036] Step S12, load the bytecode file and call the common string file to complete the loading of the target program code file.
[0037] In the embodiments of the present disclosure, steps S11 and S12 describe the loading process of the target program code file. Before executing step S11, it is necessary to pre-create a common string file and allocate multiple strings in the target memory. This target memory can be understood as a kind of dynamic memory, which has two processing procedures of initialization and de-initialization. For initialization, multiple strings are allocated in the target memory; for de-initialization, multiple strings are released from the target memory.
[0038] Therefore, after completion of the initialization, it can be understood that: a common string file has been pre-created, and multiple strings are allocated in the target memory.
[0039] In the embodiments of the present disclosure, the program code file can be a program code file of an interpreted scripting language, that is, a javascript file. It can be understood that the program code file can also be a program code file based on other scripting languages, and the execution process of the program code file of the scripting language is similar to that of the program code file of the interpreted scripting language, both of which first perform compilation of the bytecode file and then execute it through the stack virtual machine method. For example, the Python language, etc.
[0040] Correspondingly, the file loading method can be applied to the loading engine corresponding to the interpreted scripting language, such as the quickjs loading engine for javascript files. This loading engine can be installed on the terminal. For example, when an application is installed on the terminal, for the startup of the application, it is necessary to rely on this loading engine to execute the corresponding javascript file to achieve the startup of the application.
[0041] The program code file can be understood as the file corresponding to the program code, and the program code is included in this file. Further, the program code includes the functions used and the strings used, and both the functions and the strings need to be loaded.
[0042] For example, assuming the js code is: "console.log(\"123\")", then the corresponding strings include: "console", "log", and "123".
[0043] Thus, the bytecode file is a file generated based on the functions used in the program code file, and the common string file is a file generated based on the strings used in the program code file.
[0044] To facilitate understanding of the technical solutions of the embodiments of the present disclosure, the related implementation manners of the common string file will be introduced next.
[0045] In the embodiments of the present disclosure, the common string file can be understood as a string file obtained by integrating the strings required in multiple program code files. Therefore, the multiple strings included therein can be applied to the loading of multiple program code files.
[0046] As an optional implementation manner, the file loading method further includes: creating a common string file; storing the common string file in a target memory so that multiple strings are allocated in the target memory.
[0047] In some embodiments, if the program code file is loaded for the first time, the creation process of the common string file can be executed. The creation process can include: respectively extracting the strings used in multiple program code files to obtain multiple strings required by the program code files, and the multiple program code files include the target program code file; creating a common string file according to the multiple strings.
[0048] In some embodiments, the multiple program code files can be all the program code files that may need to be loaded involved in the loading scenario, and the target program code file is also included therein.
[0049] In some embodiments, the multiple program code files are the program code files that need to be executed currently, and in different application scenarios, they may be files of different types or functions. For example, it can be the program code file required for the startup of an application.
[0050] In this implementation manner, the strings used in multiple program code files are respectively extracted, and then a common string file is created by using the extracted multiple strings.
[0051] In the embodiments of the present disclosure, when creating a common string file by using multiple strings, duplicate removal processing can be performed on the strings so that the strings included in the common string file are all non-duplicate strings. Therefore, as an optional implementation manner, creating a common string file according to multiple strings includes: performing duplicate removal processing on the multiple strings to obtain the multiple strings after duplicate removal processing; creating a common string file according to the multiple strings after duplicate removal processing.
[0052] In some embodiments, when extracting the strings in multiple program code files, a string sub-file can be generated for the strings in each program code file; then, when integrating, after removing duplicates from the multiple string sub-files, they are stored in a common string file pool. The common string file pool can be understood as an integrated file of multiple string sub-files, and the final common string file pool does not contain duplicate strings.
[0053] Exemplarily, assume there are a total of 100 characters, among which 30 characters are duplicate characters that are the same as other characters, and these are called duplicate characters. If the file loading method of the related technology is adopted, all these 100 characters will be loaded along with the corresponding bytecode file. However, when using the file loading method of the present disclosure, these 30 duplicate characters will be processed; during actual loading, only 70 distinct characters need to be loaded. Moreover, these 70 characters are integrated into a common public string file, and during loading, only this common public string file needs to be loaded. That is, it is equivalent to the system function only needing to be executed once to complete the loading of multiple strings. Thus, the loading efficiency of the file is improved.
[0054] In some embodiments, for the loading engine, when loading a string, the string needs to be converted into an object that the loading engine can recognize, and this object can be understood as a data structure. Thus, after the string is loaded into the loading engine, the string is stored in the form of a data structure that the loading engine can recognize. That is, when loading a string, information required by the loading engine to use the string also needs to be generated, such as a hash value.
[0055] To improve the loading speed of strings, when creating the public string file, the string can be converted into the form of a data structure that the loading engine can recognize. Further, when loading the string, the public string file can be directly stored, and there is no longer a need to calculate various information required to use the string.
[0056] Therefore, as an alternative implementation, the file loading method is applied to the loading engine, and the file loading method further includes: determining the string information corresponding to multiple strings, where the string information is the information required by the loading engine to use the string. Correspondingly, according to the multiple strings, a public string file is created, including: creating a string file according to the multiple strings and the string information corresponding to the multiple strings respectively.
[0057] Thus, in the public string file, in addition to including multiple different strings, it also includes the string information corresponding to the multiple different strings respectively, and this string information can be information required by the loading engine such as a hash value calculated according to the string.
[0058] Through this generation method of the loading file, the function part and the string part are separated to generate two separate files. The function part uses the original bytecode file, and the string part is extracted into a common public string file. Thus, the bytecode files generated by multiple program code files are separate, but the string part shares one file, and the public string file performs deduplication on the strings.
[0059] In the embodiments of the present disclosure, if the program code file is loaded for the first time, the common string file can be created according to the common string file creation method introduced in the foregoing embodiments.
[0060] It can be understood that for one-time loading, after the loading is completed, the process of releasing dynamic memory needs to be executed. Thus, when the program code file is loaded next time, the common string file also needs to be created. Therefore, to improve efficiency, a snapshot corresponding to the common string file can be saved during the first loading; thus, when loading after the first time, the snapshot can be used to quickly create the common string file.
[0061] Therefore, as an optional implementation manner, the file loading method further includes: saving a snapshot corresponding to the common string file, and the snapshot corresponding to the common string file can be used to create the common string file.
[0062] Moreover, if data loss or damage occurs to the common string file during subsequent applications, etc., the common string file can be restored using the snapshot.
[0063] A snapshot refers to a fully available copy of a specific data set at a certain point in time, including the image of the corresponding data at the start time point of the copy. It can be a copy of the data or a replica of the data. Snapshots mainly have two functions:
[0064] Online data backup and recovery: When an application failure or file damage occurs to the storage device, the data can be restored through the snapshot, and the data can be restored to the state at the time point when the snapshot was generated.
[0065] Providing a data access channel: When the original data is being processed online, users can access the snapshot data and can also use the snapshot for testing and other work.
[0066] There are three basic forms of snapshots: file system-based, subsystem-based, and volume manager / virtualization-based, and the corresponding form can be selected according to different application scenarios. In addition, snapshots also have two types: write-once copy and split mirror.
[0067] In this implementation manner, since there is only one common string file and the common string file needs to be created each time it is loaded. Therefore, when the common string file is loaded for the first time, the corresponding snapshot can be saved. Thus, when loading for the second time and subsequent times, the common string file can be directly generated based on the saved snapshot, which can accelerate the loading speed.
[0068] Furthermore, as an optional implementation manner, the creation of the common string file can also include: creating the common string file according to a preset snapshot of the common string file.
[0069] In this embodiment, the preset common string file snapshot may be the common string file snapshot saved when the program code file is loaded for the first time.
[0070] In some embodiments, the preset common string file snapshot may also be a preset snapshot, which can be obtained by preloading. Thus, during the actual loading process, the generation of the common string file can be directly implemented based on this snapshot.
[0071] It can be understood that since the common string file may include not only strings but also string information corresponding to the strings, the snapshot technology can be used to quickly generate the common string file and improve the file loading efficiency.
[0072] In some embodiments, after the common string file is created, it can be stored in the target memory so that multiple strings are allocated in the target memory.
[0073] It can be understood that when the string information is already included in the common string file, the common string file can be directly stored in the memory corresponding to the common string file.
[0074] If the related technology is adopted, strings need to be stored one by one in the corresponding memory spaces, and if there are duplicate strings, these duplicate strings will also be stored in the corresponding memory spaces. Moreover, when storing, the relevant information of the strings needs to be calculated to store the strings and string information in the corresponding memory.
[0075] In this embodiment, the entire common string file is directly stored in the allocated memory space, and the rapid loading of the strings can be completed. Thus, it can be seen that by adopting the technical solution of the embodiments of the present disclosure, during loading, not only do we not need to store strings one by one, but we also do not need to calculate the relevant information of the strings, which can greatly accelerate the string loading speed.
[0076] In step S11, the target program code file is the file that needs to be loaded currently, which can be a specified program code file or multiple program code files.
[0077] In some embodiments, for the program code file, the function part in the program code file can be compiled into an independent program code file according to the mature bytecode file compilation method in the art. Thus, one program code file corresponds to one bytecode file.
[0078] Figure 2A is a schematic diagram of a program code file shown according to an exemplary embodiment, such as Figure 2AAs shown, there are program code file A, program code file B, and program code file C. In program code file A, there is function 1; strings A1, A2, and A3. In program code file B, there is function 2; strings B1, B2, and A3. In program code file C, there is function 3; strings C1, B2, and A3.
[0079] Figure 2B is a schematic diagram of a bytecode file and a common string file shown according to an exemplary embodiment, as Figure 2B shown, based on function 1 in program code file A, the corresponding bytecode file Z1 can be generated; based on function 2 in program code file B, the corresponding bytecode file Z2 can be generated; based on function 3 in program code file C, the corresponding bytecode file Z3 can be generated.
[0080] Moreover, by extracting the strings in program code file A, program code file B, and program code file C and performing string deduplication processing, the common string file F is finally obtained. In the common string file F, there are strings A1, A2, A3, B1, B2, and C1.
[0081] It can be understood that Figure 2 is only an exemplary introduction for facilitating the introduction of file relationships, and the number of functions, the number of strings, etc. included therein are not limited to the example in Figure 2.
[0082] In step S12, the bytecode file is loaded and the common string file is called to complete the loading of the target program code file.
[0083] In some embodiments, the process of allocating multiple strings in the common string file to the target memory can be understood as the loading process of the common string file. Therefore, in step S12, the common string file can be directly called.
[0084] For the loading of the bytecode file, store the functions therein in the allocated memory and execute the functions, which is no different from the related technology.
[0085] By loading the bytecode file and calling the common string file, the loading of the target program code file can be completed. Thus, the functions corresponding to the program code file can be implemented, for example: the application startup is completed.
[0086] When applying the technical solution provided by the embodiments of the present disclosure, on the basis of the related technology, the generation logic of the bytecode file can be modified, and the creation logic of the common string file can be added.
[0087] In addition, for bytecode files and common string files, corresponding version control can also be added. Thus, in subsequent application processes, if the bytecode file or common string file corresponding to the program code file is updated, the update needs to be executed. For example, if there are new files in the program code file, new bytecode files are generated based on the new files and added to the originally stored bytecode files; in addition, corresponding strings are extracted from the new files and the corresponding strings are updated to the common string file; similarly, during the update, duplicate removal processing needs to be performed to ensure that the strings in the common string file are all different strings.
[0088] Through the technical solution of the embodiments of the present disclosure, the system load can be reduced and the file loading efficiency can be accelerated. For example, assuming there are a total of 1200 strings, if loaded in the existing technology, the system processing function needs to be executed more than 1200 times. According to the loading method of the embodiments of the present disclosure, the system processing function only needs to be executed once for an overall common string file.
[0089] In addition, in addition to accelerating the file loading speed; since multiple different strings are integrated into a common string file, to a certain extent, the memory consumption for storing the common string file can also be reduced.
[0090] Thus, through the verification of actual application, when this technical solution is used in Internet of Things devices, the memory consumption can be reduced by 40KB, and the startup time can be reduced by 50ms.
[0091] Figure 3 It is a block diagram of a file loading device shown according to an exemplary embodiment. Referring to Figure 3 , the device includes:
[0092] An acquisition module 301, configured to acquire a bytecode file corresponding to a target program code file, where the bytecode file includes functions used in the target program code file.
[0093] A loading module 302, configured to load the bytecode file and call the common string file to complete the loading of the target program code file.
[0094] In an exemplary embodiment, the file loading device further includes: a creation module, configured to: create the common string file; a storage module, configured to store the common string file in the target memory so that the multiple strings are allocated in the target memory.
[0095] In an exemplary embodiment, the creation module is further configured to: extract the strings used in a plurality of program code files respectively, obtain a plurality of strings required by the program code files, where the plurality of program code files include the target program code file; create the common string file according to the plurality of strings.
[0096] In an exemplary embodiment, the creation module is further configured to: perform a deduplication process on the plurality of strings to obtain a plurality of strings after the deduplication process; create the common string file according to the plurality of strings after the deduplication process.
[0097] In an exemplary embodiment, the creation module is further configured to: determine the string information respectively corresponding to the plurality of strings, where the string information is the information required by the loading engine to use the strings; create the string file according to the plurality of strings and the string information respectively corresponding to the plurality of strings.
[0098] In an exemplary embodiment, the file loading device further includes a snapshot module configured to: save a snapshot corresponding to the common string file, and the snapshot corresponding to the common string file can be used to create the common string file.
[0099] In an exemplary embodiment, the creation module is further configured to: create the common string file according to a preset snapshot of the common string file.
[0100] In an exemplary embodiment, the program code file is a program code file of an interpreted scripting language, and the file loading method is applied to the loading engine corresponding to the interpreted scripting language.
[0101] Regarding the device in the above embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated here.
[0102] The present disclosure also provides a computer-readable storage medium, on which computer program instructions are stored, and when the program instructions are executed by a processor, the steps of the file loading method provided by the present disclosure are implemented.
[0103] Figure 4 FIG. 400 is a block diagram of a file loading device 400 shown according to an exemplary embodiment. For example, the device 400 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.
[0104] Refer to Figure 4, the device 400 may include one or more of the following components: a processing component 402, a memory 404, a power component 406, a multimedia component 408, an audio component 410, an input / output interface 412, a sensor component 414, and a communication component 416.
[0105] The processing component 402 generally controls the overall operation of the device 400, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 402 may include one or more processors 420 to execute instructions to complete all or part of the steps of the above file loading method. In addition, the processing component 402 may include one or more modules to facilitate the interaction between the processing component 402 and other components. For example, the processing component 402 may include a multimedia module to facilitate the interaction between the multimedia component 408 and the processing component 402.
[0106] The memory 404 is configured to store various types of data to support the operation of the device 400. Examples of these data include instructions for any application or method operating on the device 400, contact data, phone book data, messages, pictures, videos, etc. The memory 404 may 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, a magnetic disk, or an optical disk.
[0107] The power component 406 provides power to the various components of the device 400. The power component 406 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 400.
[0108] The multimedia component 408 includes a screen that provides an output interface between the device 400 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 touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of the touch or swipe actions, but also detect the duration and pressure associated with the touch or swipe operation. In some embodiments, the multimedia component 408 includes a front camera and / or a rear camera. When the device 400 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0109] The audio component 410 is configured to output and / or input audio signals. For example, the audio component 410 includes a microphone (MIC) that is configured to receive external audio signals when the device 400 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 404 or transmitted via the communication component 416. In some embodiments, the audio component 410 further includes a speaker for outputting audio signals.
[0110] The input / output interface 412 provides an interface between the processing component 402 and a peripheral interface module, and the peripheral interface module can be a keyboard, a click wheel, buttons, etc. These buttons can include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0111] The sensor component 414 includes one or more sensors for providing an assessment of various aspects of the state of the device 400. For example, the sensor component 414 can detect the on / off state of the device 400, the relative positioning of components, such as the display and keypad of the device 400, the sensor component 414 can also detect a change in the position of the device 400 or a component of the device 400, the presence or absence of user contact with the device 400, the orientation or acceleration / deceleration of the device 400, and the temperature change of the device 400. The sensor component 414 can include a proximity sensor that is configured to detect the presence of nearby objects without any physical contact. The sensor component 414 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 414 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0112] The communication component 416 is configured to facilitate communication between the device 400 and other devices in a wired or wireless manner. The device 400 can access a wireless network based on communication standards, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 416 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 416 further 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.
[0113] In an exemplary embodiment, the apparatus 400 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 for performing the above-described file loading method.
[0114] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions, such as a memory 404 including instructions, is also provided. The above instructions may be executed by a processor 420 of the apparatus 400 to complete the above-described file loading method. For example, the non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, or the like.
[0115] In another exemplary embodiment, a computer program product is also provided. The computer program product includes a computer program that can be executed by a programmable device. The computer program has a code portion for performing the above-described file loading method when executed by the programmable device.
[0116] Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the specification and practicing the present disclosure. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include known common knowledge or conventional technical means in the technical field not disclosed by the present disclosure. The specification and embodiments are only to be considered as exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.
[0117] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.
Claims
1. A file loading method, characterized in that, A common string file is pre-created, and the common string file includes a plurality of strings required by a program code file. The plurality of strings are allocated in a target memory. The file loading method includes: Obtain a bytecode file corresponding to a target program code file, where the bytecode file includes functions used in the target program code file; Load the bytecode file and call the common string file to complete the loading of the target program code file.
2. The document loading method according to claim 1, wherein The file loading method further includes: Create the common string file; Store the common string file in the target memory so that the plurality of strings are allocated in the target memory.
3. The document loading method according to claim 2, characterized in that, The creating of the common string file includes: Extract the strings used in a plurality of program code files respectively to obtain a plurality of strings required by the program code files, where the plurality of program code files include the target program code file; Create the common string file according to the plurality of strings.
4. The document loading method according to claim 3, wherein The creating of the common string file according to the plurality of strings includes: Perform deduplication processing on the plurality of strings to obtain a plurality of strings after deduplication processing; Create the common string file according to the plurality of strings after deduplication processing.
5. The document loading method according to claim 3 or 4, characterized in that The file loading method is applied to a loading engine, and the file loading method further includes: Determine the string information respectively corresponding to the plurality of strings, where the string information is the information required by the loading engine to use the strings; Correspondingly, the creating of the common string file according to the plurality of strings includes: Create the string file according to the plurality of strings and the string information respectively corresponding to the plurality of strings.
6. The document loading method according to claim 3, wherein The file loading method further includes: Save a snapshot corresponding to the common string file, and the snapshot corresponding to the common string file can be used to create the common string file.
7. The document loading method according to claim 2, wherein The file loading method further includes: Create the common string file according to a preset snapshot of the common string file.
8. The document loading method according to any one of claims 1-7, characterized in that, The program code file is a program code file of an interpreted scripting language, and the file loading method is applied to a loading engine corresponding to the interpreted scripting language.
9. A file loading device, characterized in that, A common string file is pre-created, and the common string file includes a plurality of strings required by a program code file. The plurality of strings are allocated in a target memory. The file loading device includes: An obtaining module configured to obtain a bytecode file corresponding to a target program code file, where the bytecode file includes functions used in the target program code file; A loading module configured to load the bytecode file and call the common string file to complete the loading of the target program code file.
10. A file loading device, characterized in that, Includes: A processor; A memory for storing instructions executable by the processor; Wherein, the processor is configured to: execute the steps of the method according to any one of claims 1-8.
11. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the program instruction is executed by the processor, it implements the steps of the method according to any one of claims 1-8.