CN-122019016-A - Maintenance method of function stack, access method of function stack and electronic hardware
Abstract
The application provides a maintenance method of a function stack, an access method of the function stack and electronic hardware, wherein the method comprises the steps of distributing hot stack space when executing stack space distribution statement in a function preamble; and in the follow-up of the function, when executing a stack space release statement, releasing the allocated hot stack space. The method provided by the application improves the random access speed of the thermal data through the thermal stack storage area in the CPU.
Inventors
- LIANG XIAOLONG
- TAN JILAI
- HUANG TAO
- LIU YUTING
- ZHANG JIAN
- YAN PENG
Assignees
- 上海思朗科技股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260212
Claims (10)
- 1. A method for maintaining a function stack, the method comprising: In the function preamble, when executing a stack space allocation statement, allocating a hot stack space, wherein the hot stack space is positioned in a hot stack storage area inside a Central Processing Unit (CPU); in the function successor, when the stack space release statement is executed, the allocated hot stack space is released.
- 2. The method of claim 1, wherein a page table entry or physical memory attribute PMA corresponding to the hot stack storage region is formulated as Uncacheable.
- 3. The method according to claim 1, wherein in the function preamble, after allocating hot stack space when executing the stack space allocation statement, further comprises: And if the proportion of the data quantity stored in the hot stack storage area to the total quantity of the hot stack storage area exceeds a first proportion threshold value, moving the data at the bottommost part of the hot stack storage area to a cold stack storage area in a burst transmission mode.
- 4. The method of claim 1, wherein in the function successor, when executing the stack space release statement, after releasing the allocated hot stack space, further comprises: And if the proportion of the data quantity stored in the hot stack storage area to the total quantity of the hot stack storage area is lower than a second proportion threshold value, moving the data at the top of the cold stack storage area to the hot stack storage area in a burst transmission mode.
- 5. The method of claim 3 or 4, wherein the cold stack storage area is located in a double data rate synchronous dynamic random access memory DDR.
- 6. The method of claim 5, wherein a page table entry or PMA corresponding to the cold stack storage region is formulated as a Cacheable.
- 7. The method of claim 5, wherein the amount of data per move is determined based on the CPU and DDR.
- 8. The method according to claim 3 or 4, characterized in that the method further comprises: recording the data migration condition of the running function; when the CPU executes the function call statement, a hot stack space is reserved in a hot stack storage area according to the data migration condition of the called function, or the data to be accessed is loaded in the hot stack storage area.
- 9. A method for accessing a function stack, wherein the function stack is maintained by the method for maintaining a function stack according to any one of claims 1 to 8; The access method of the function stack comprises the following steps: when the access data of the function is the data of other functions, arbitrating the address of the access data; If the access data address is in the hot stack storage area, directly accessing the access data in the hot stack storage area; And if the access data address is in the cold stack storage area, accessing the access data through a data cache.
- 10. An electronic hardware, wherein the electronic hardware comprises a processor; The processor being adapted to perform the method of any one of claims 1-8 or to perform the method of claim 9.
Description
Maintenance method of function stack, access method of function stack and electronic hardware Technical Field The present application relates to the field of computer technologies, and in particular, to a method for maintaining a function stack, a method for accessing a function stack, and electronic hardware. Background Currently, the function stacks of the CPU (Central Processing Unit ) all use software stacks, i.e. a memory area is allocated and managed by a program on the DDR (Double Data Rate Synchronous Dynamic Random Access Memory ). Usually, the Data stored in the stack Top (Top) of the software stack is the local variable of the Top calling function of the current running function, and the Data stored in the stack Bottom (Bottom) of the software stack is the local variable of the Top calling function of the current running function, and is basically rarely accessed, thus belonging to Cold Data (Cold Data). The Hot Data (Hot Data) at the top of the frequently accessed software stack often has low access efficiency, CACHELINE MISS, and other situations even if a modern cache structure such as DATACACHE is used. Disclosure of Invention In order to solve one of the technical defects, the application provides a maintenance method of a function stack, an access method of the function stack and electronic hardware. In a first aspect of the present application, a method for maintaining a function stack is provided, where the method includes: In the function preamble, when executing a stack space allocation statement, allocating a hot stack space, wherein the hot stack space is positioned in a hot stack storage area inside a Central Processing Unit (CPU); in the function successor, when the stack space release statement is executed, the allocated hot stack space is released. Optionally, the page table entry or physical memory attribute PMA corresponding to the hot stack storage region is formulated as Uncacheable. Optionally, in the function preamble, when executing the stack space allocation statement, after allocating the hot stack space, the method further includes: and if the proportion of the data quantity stored in the hot stack storage area to the total quantity of the hot stack storage area exceeds a first proportion threshold value, moving the data at the bottommost part of the hot stack storage area to the cold stack storage area in a burst transmission mode. Optionally, in the function continuation, when executing the stack space release statement, after releasing the allocated hot stack space, the method further includes: And if the proportion of the data quantity stored in the hot stack storage area to the total quantity of the hot stack storage area is lower than a second proportion threshold value, moving the data at the top of the cold stack storage area to the hot stack storage area in a burst transmission mode. Optionally, the cold stack storage area is located in the double data rate synchronous dynamic random access memory DDR. Alternatively, the page table entry or PMA corresponding to the cold stack storage region is formulated as a Cacheable. Alternatively, the amount of data transferred each time is determined based on the CPU and DDR. Optionally, the method further comprises: recording the data migration condition of the running function; when the CPU executes the function call statement, a hot stack space is reserved in a hot stack storage area according to the data migration condition of the called function, or the data to be accessed is loaded in the hot stack storage area. The second aspect of the present application provides a method for accessing a function stack, which is characterized in that the function stack is maintained by the method for maintaining a function stack according to the first aspect; The access method of the function stack comprises the following steps: when the access data of the function is the data of other functions, arbitrating the address of the access data; if the access data address is in the hot stack storage area, directly accessing access data in the hot stack storage area; and if the access data address is in the cold stack storage area, accessing the access data through the data cache. In a third aspect of the present application, there is provided electronic hardware comprising a processor; A processor for performing the method as described in the first aspect above or for performing the method as described in the second aspect above. The application provides a maintenance method of a function stack, an access method of the function stack and electronic hardware, wherein the method comprises the steps of distributing hot stack space when executing stack space distribution statement in a function preamble; and in the follow-up of the function, when executing a stack space release statement, releasing the allocated hot stack space. The method provided by the application improves the random access speed of the thermal data through the thermal sta