Integrated generational garbage collector

The integrated generational garbage collector addresses the inefficiencies and security concerns of existing garbage collection methods by dynamically partitioning the heap and using metadata handles to manage memory efficiently and securely.

WO2025093873A1PCT designated stage expired Publication Date: 2025-05-08VYPERCORE LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
PCT/GB2024/052763
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-10-31
Filing Date
2024-10-31
Publication Date
2025-05-08

AI Technical Summary

Technical Problem

Existing garbage collection methods are resource-intensive, impact application performance significantly, and introduce determinism issues in real-time systems, making them prone to cyberattacks.

Method used

An integrated generational garbage collector that dynamically partitions the heap into young and old generations, using a directory with metadata entries and handles to efficiently manage memory and reduce concurrency issues during marking and compaction phases.

Benefits of technology

The solution minimizes the impact on application performance, maintains deterministic behavior, and reduces the risk of cyberattacks by efficiently managing memory and handling intergenerational references.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure GB2024052763_08052025_PF_FP_ABST
    Figure GB2024052763_08052025_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure relates to an integrated generational garbage collector comprising a processing circuit configured to: dynamically partition the heap memory into a young generation comprising young objects and an old generation comprising old objects relative to the young objects, and maintaining a directory comprising entries corresponding to each object of the young and old objects, update, during a collection cycle, a Remembered Set List in the directory, wherein the Remembered Set List comprises entries corresponding to the old objects that have been promoted from the young generation and that have been determined to comprise one or more pointers to young objects. Also disclosed is an integrated circuit comprising the integrated generational garbage collector, and an associated method of generational garbage collection.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] INTEGRATED GENERATIONAL GARBAGE COLLECTOR

[0002] FIELD OF INVENTION

[0003] The present disclosure is in the field of garbage collection, and relates in particular to an integrated generational garbage collector, an integrated circuit implementing such a garbage collector, and a corresponding method of generational garbage collection.

[0004] BACKGROUND TO INVENTION

[0005] Memory management is a necessary feature of most software-based processing systems. Memory, e.g. program and / or data storage, is a finite resource, and in deeply embedded systems may even be a scarce resource, and therefore careful management of memory usage may be required to avoid known application issues, such as heap overrun.

[0006] It is known in the art to recover memory that has been assigned to and / or used by an application that is no longer required. Such memory recovery may be known in the art as “garbage collection”.

[0007] An example of a typical, simplified garbage collection process is as follows.

[0008] In a typical application processing system, an operating system may support execution of one or more applications. A main memory of the processing system is typically used to store a heap. The heap may be used for dynamic allocation of memory to application processes.

[0009] The application may execute processes, wherein objects, e.g. data structures, may be used by said processes. A memory allocation routine of the OS may assign heap in the main memory to store the objects.

[0010] As more objects are stored in the heap, an available remaining space in the heap is reduced. As such, reclaiming unused memory, e.g. heap that is no longer required by an application, becomes necessary.

[0011] Various garbage collection schemes are known. One known scheme is “tracing” garbage collection, which comprises determining which objects should be freed by tracing which objects are reachable by a chain of references from "root" objects. That is, garbage collection may be based on a principle that that a pointer to an object cannot be found by tracing pointers starting from the root objects, then the object cannot be reached by the application and therefore the memory assigned to the object can be freed. The tracing process may involve marking all objects identified as being reachable, and subsequently freeing objects that are not marked in a process termed “sweeping”.

[0012] Garbage collection may be a resource intensive process, requiring significant processing capabilities and software overhead, and may severely impact the execution of applications. In examples, memory management code may account for up to -40% of runtime, in typical applications.

[0013] Furthermore, an optimum timing and extent of execution of garbage collection routines may be difficult to determine, and may vary significantly for different applications.

[0014] Furthermore, execution of memory management software to handle garbage collection may also introduce a lack of determinism in embedded real-time systems, which may make an application prone to cyberattacks. Indeed, software reliant on memory management routines may generally be prone to common cyberattack vectors, such as buffer overflows and memory leaks.

[0015] It is therefore desirable to provide a method and / or system for efficiently implementing a garbage collection scheme, wherein said system / method has minimal impact upon application performance. Furthermore, it is preferable that such a system and / or method is does not significantly impact a deterministic behaviour of an underlying application, nor provide scope for cyberattacks.

[0016] It is therefore an aim of at least one embodiment of at least one aspect of the present disclosure to obviate or at least mitigate at least one of the above identified shortcomings of the prior art.

[0017] SUMMARY OF INVENTION

[0018] The present disclosure is in the field of garbage collection, and relates in particular to an integrated generational garbage collector and a corresponding method of generational garbage collection.

[0019] According to a first aspect of the disclosure, there is provided an integrated generational garbage collector. The integrated generational garbage collector comprises a processing circuit.

[0020] The processing circuit may be configured to dynamically partition a heap memory into a young generation comprising young objects and an old generation comprising old objects relative to the young objects. The processing circuitry may be configured to maintain a directory comprising entries corresponding to each object of the young and old objects.

[0021] The processing circuit may be configured to update, during a collection cycle, e.g. a marking phase of the collection cycle, a Remembered Set List in the directory, wherein the Remembered Set List comprises entries corresponding to the old objects that may have been promoted from the young generation and that may have been determined to comprise (or at least may have been determined to be likely to comprise) one or more pointers to young objects.

[0022] Each entry in the directory may comprise metadata. Said metadata may comprise a list parameter selectively configurable between an End-of-List handle (EOL), a Null handle and a Valid handle. The End-of-List handle may indicate that a / the corresponding object is a final entry in a list of entries, the Valid handle indicates that the corresponding object is a non-final entry in a / the list of entries and the Null handle indicates that the corresponding object is not included in any list.

[0023] The list of entries may be a list of entries in the directory. The list of entries may be a list of entries in the Remembered Set List.

[0024] The term “young” in the context of young objects will be understood to refer to objects that are younger than objects referred to as “old” objects. Such relative ages may be based, for example, on a number of collection cycles the object has already survived, as describe further below.

[0025] Advantageously, having a clear distinction between the Null and End-of-List handle enables a determination of whether an object is in a list or not (e.g. the Remembered Set List, or the below described Free List or Next List), thereby advantageously solving a concurrency problem. That is, when marking is underway, the distinct handles may enable an efficient determination of whether an object is one that has yet to be marked, or whether it is an object that has for example, already been added to the Remembered Set list.

[0026] For example, if only a Null handle was to be implemented to represent an end of a list, then it may not be possible to read the respective directory entry and determine whether said entry was part of a list or not. As such, by having a distinction between the Valid handle (which may be any value other than a value reserved for the End-of-List handle or a value reserved for the Null handle), then that entry may be clearly identifiable as part of a list, and if the list parameter corresponds to the Null handle then it may indicate that the entry is clearly not part of any list. In a non-limiting example, all-zero-bits may be used for the Null handle, and used to represent objects which are not part of any list.

[0027] In another non-limiting example, all-one-bits may be used for the End-of-List handle, and used to represent an object that is a member of a list, where it is the end element of the list.

[0028] In other examples, the End-of-List and Null handles may be given any practical value.

[0029] In examples, if the list parameter field is neither of the values reserved for the End-of-List handle and the Null handle, then the value may be a Valid handle and may represents that the object is a member of a list.

[0030] The processing circuit may comprise a state machine, e.g. a finite state machine. The processing circuit may comprise logic, such as a combinatorial logic circuit. The processing circuit may comprise a processing core, e.g. a central processing unit (CPU), such as a CPU having a RISC architecture, CISC architecture, or the like. The processing circuit may comprise one or more memory and / or data storage structures. The processing circuit may be configured to execute instructions. Said instructions may be stored in the one or more memory and / or data storage structures. The processing circuit may be provided as a hard-macro or as a synthesized design, e.g. a sea-of-gates. The processing circuit may comprise an embedded circuit, e.g. a CMOS circuit.

[0031] The processing circuit may be configured to process, during a marking phase of the collection cycle, a Next List that may be stored in the directory. Said processing may comprise: starting at a first entry at the front of the Next List, sequentially popping each entry from the Next List and scanning the corresponding object for pointers based on an address and a size of the object stored in the metadata; and marking any pointers referenced by said objects and adding their handles to the Next List. The marking phase may be completed when the Next List is empty, which occurs when all reachable objects have been marked and scanned.

[0032] Advantageously, the Next List may effectively provide a working list of objects to be scanned.

[0033] When an object is popped from the Next List, the list parameter for that object may be configured to the Null handle.

[0034] The processing circuit may be configured to update, during a / the compaction phase of the collection cycle, a Free List in the directory. The Free List may comprise entries corresponding to the valid handles for which no object has been allocated in the heap.

[0035] The Next List, the Remembered Set List and the Free List may be linked lists.

[0036] The Next List, the Remembered Set List and the Free List may collectively be a partial partition of all valid handles.

[0037] The Next List and the Remembered Set List may collectively be a partial partition of all reachable objects.

[0038] During an initialisation phase at the start of the collection cycle, the list parameter in the first entry of at least the Next List and the Remembered Set List may be initialised to the End-of-List handle.

[0039] During an initialisation phase at start-up, the list parameter in the first entry of at least the Next List may be initialised to the End-of-List handle.

[0040] Advantageously, by initializing the lists to the End-of-List handle, it may clearly be determined that it may also not be part of any other list. That is, the Null handle effectively indicates that should the object be encountered again during the current or a future collection cycle, said object can be added to another list.

[0041] The integrated generational garbage collector may comprise a Young Generation Address register. A value stored in said Young Generation Address register may define an address of a pre-compaction partition in the heap memory between the young generation and the old generation.

[0042] That is, the processing circuit may be configured to determine an address of a pre-compaction partition in the heap memory between the young generation and the old generation based on the value stored in said Young Generation Address register.

[0043] The term pre-compaction partition will be understood to be the address of the partition between the young generation and the old generation before the compaction phase of the collection cycle commences.

[0044] The processing circuit may be configured to determine an age of an object at the beginning of the collection cycle based on a value of the Young Generation Address.

[0045] Advantageously, if an object has yet to be compacted / moved, the age of the object may be determined by comparing its address to the young generation address. That is, the young generation address effectively defines the partition between old generation and the young generation in a pre-compaction address space.

[0046] The integrated generational garbage collector may comprise a Next Young Generation Address register. A value stored in said Next Young Generation Address may define an address of a post-compaction partition in the heap memory between the young generation and the old generation.

[0047] The value stored in Young Generation Address register may be updated to the value of the Next Young Generation Address register following completion of the collection cycle.

[0048] That is, the processing circuit may be configured to update the value stored in Young Generation Address register to the value of the Next Young Generation Address register following completion of the collection cycle.

[0049] Advantageously, the Next Young Generation Address register stores the young generation address as it will be when compaction completes, thereby providing the position of the young generation within the compacted part of the heap memory.

[0050] That is, promoting an object may result in the implicit promotion of one or more objects below the (targeted) object. All such implicitly promoted objects will be older than the (target) object being promoted, even if they are yet to meet a predefined promotion criteria (described in more detail below). That is, an object may be promoted from the young generation to the old generation even if the objects are implicitly not old enough to be promoted.

[0051] As such, selectively promoting young objects from the young generation to the old generation may additionally comprise promoting one or more further objects that are lower down the memory map, irrespective of whether a promotion criteria for said further objects has been met.

[0052] The integrated generational garbage collector may comprise a Promotion Address register. Said Promotion Address may hold a pre-compaction phase address of a word following the end of the highest-addressed object in the heap memory which will be promoted during the collection cycle.

[0053] In use, during the marking phase of the collection cycle the list of all currently- old objects that contain pointers to young objects is accumulated. The Promotion Address is also accumulated. During the subsequent compaction phase of the collection cycle, objects are moved as normal. If, prior to moving an object, the object resides below the Promotion Address, and the object’s Deep flag is set, then the object is added to the Remembered Set.

[0054] Advantageously, implementation of the above-described Young Generation Address register and Promotion Address registers effectively enable management and tracking of implicitly promoted objects. The above-described “collection cycle” may be a young-generation only collection. Less frequently than every collection cycle, a full collection of both the young generation and the old generation may be run.

[0055] In example embodiments, the system may start by running a full collection cycle to initialise the Remembered Set, followed by combinations of full and young-only collections, as described in more detail below.

[0056] In non-limiting examples, a determination of when to perform a full collection of both the young generation and the old generation may be based on one or more of: absolute thresholds based on a time measured, e.g. 1 full collection for every 3 young generation collections; a memory allocation rate, e.g. objects or bytes allocated to the heap memory per time measure; a birth rate, e.g. creation of objects or bytes per time measure, and possibly measured for each generation; a death rate (objects or bytes per time measure; possibly measured per-generation); a churn ratio, e.g. a ratio per time measure of deaths to births plus deaths; and / or a promotion rate, e.g. a rate of promotion of objects or bytes from the young generation into the old generation, per time measure.

[0057] In non-limiting examples, a determination of when to perform a full collection of both the young generation and the old generation may be additionally or alternatively based on one or more of: a total heap memory size, e.g. in bytes, based upon one or more absolute thresholds or percentages of available memory; a size of the old generation, e.g. in bytes, based upon one or more absolute thresholds or percentages of available memory or percentage of total heap memory size; a size of the young generation, e.g. in bytes, based upon one or more absolute thresholds or percentage of available memory or percentage of total heap memory size.

[0058] In non-limiting examples, a determination of when to perform a full collection of both the young generation and the old generation may be additionally or alternatively based on one or more of: a size of the Remembered Set, e.g. the Remembered Set List, in terms of a number of objects or a total size of remembered objects in bytes; and / or a remembered portion, e.g. a ratio of the Remembered Set size (e.g. the Remembered Set List size) to the old generation size.

[0059] The processing circuit may be configured such that during the marking process an object is added to the Remembered Set List when the object is marked and not already in the Next List or Remembered Set List.

[0060] The processing circuit may be configured such that during a / the compaction phase of the collection cycle, an object is added to the Remembered Set List when it is not already in the Remembered Set List and when the object is not yet compacted and is old based on a comparison of its address with the young generation address.

[0061] The processing circuit may be configured such that during a / the compaction phase of the collection cycle, an object is added to the Remembered Set List when it is not already in the Remembered Set List and when the object is already compacted and is old based on a comparison of its address with the next young generation address.

[0062] Advantageously, the above scenarios cover a situation where, during collection, the mutator program may still be operating, meaning that the mutator program may write a pointer to a young object into any other object in memory. If the object that the pointer was written into is an old object (by the end of collection), then we need to make sure that the old object is added to the Remembered Set.

[0063] The processing circuit may be configured such that an object is promoted from the young generation to the old generation based, at least, on an age of the object, wherein the age of the object may be based on a count of full and / or young-only collection cycles survived.

[0064] The term “collection cycles survived” will be understood to refer to collection cycles wherein said object has not been freed e.g. added to the Free List, and / or promoted.

[0065] The processing circuit may comprise an interface for coupling the processing circuit to a memory bus, e.g. a memory bus between a CPU and a main memory of an embedded system and / or integrated microprocessor or microcontroller. As such, the processing circuit may be able to read the main memory, and thus identify and / or mark and / or compact objects as described above. In some examples, the directory may be stored in the main memory or in a dedicated memory also coupled to the memory bus, thereby enabling read / write access to the directory by the processing circuit.

[0066] In some examples, the directory may be stored in a dedicated memory, e.g. a high-speed, low latency memory such as a tightly-coupled memory. In such examples, the processing circuitry may have a dedicated memory interface for accessing the dedicated memory.

[0067] The processing circuitry may comprise a register set. The register set may comprise, for example, at least one of the above described: Promotion Address Register; Young Generation Address Register; and Next Young Generation Address Register. The register set may comprise, for example, a Remembered Set Register, a Next Register and a Free Register. In use each of the Remembered Set Register, Next Register and Free Register may store the head of a linked list for the Remembered Set, a head of a linked list for the Next List and a head of a linked list for the Free List respectively. The register set may comprise a Heap Point Register which may, in use, store the address of the limit of the heap.

[0068] The integrated generational garbage collector may be a hardware integrated generational garbage collector. That is, some or all of the generational garbage collector may be implemented in hardware (e.g. CMOS circuitry or the like).

[0069] According to a second aspect of the disclosure, there is provided an integrated circuit, e.g. an integrated circuit die, comprising: at least one processing core, e.g. a CPU; and the integrated generational garbage collector according to the fist aspect.

[0070] The integrated generational garbage collector may be configured with read-only access to a register file of the at least one processing core.

[0071] Advantageously, the integrated generational garbage collector may have readonly access to the register file to obtain the root pointers for marking, yet remain generally unobtrusive to operation of the processing core.

[0072] Advantageously, the integrated generational garbage collector may be configured to operate concurrently with the at least one processing core. In examples, the integrated generational garbage collector may be configured to run in the background independently from the at least one processing core.

[0073] In example embodiments, the integrated generational garbage collector may have access to a memory bus of the at least one processing core. The integrated generational garbage collector may implement a tracing algorithm fully in the hardware.

[0074] The integrated circuit may comprise a memory accessible by the integrated generational garbage collector. The directory may be stored in the memory.

[0075] In examples, the memory may be a dedicated memory, such as a tightly coupled volatile memory, thereby providing low-latency access to the directory, e.g. object metadata, by the integrated generational garbage collector

[0076] According to a third aspect of the disclosure, there is provided a method of generational garbage collection. The method comprising: dynamically partitioning a heap memory into a young generation comprising young objects and an old generation comprising old objects relative to the young objects, and maintaining a directory comprising entries corresponding to each object of the young and old objects. The method further comprises updating, during a collection cycle, e.g. a marking phase of the collection cycle, a Remembered Set List in the directory, wherein the Remembered Set List comprises entries corresponding to the old objects that have been promoted from the young generation and that have been determined to comprise (or at least determined to be likely to comprise) one or more pointers to young objects. Each entry in the directory comprises metadata, said metadata comprising a list parameter selectively configurable between an End-of-List handle, a Null handle and a Valid handle, and wherein the End-of-List handle indicates that the corresponding object is a final entry in a list of entries, the Valid handle indicates that the corresponding object is a non-final entry in a / the list of entries and the Null handle indicates that the corresponding object is not included in any list.

[0077] The method may comprise processing, during a marking phase of the collection cycle, a Next List that is stored in the directory, wherein said processing may comprise: starting at a first entry at the front of the Next List, sequentially popping each entry from the Next List and scanning the corresponding object for pointers based on an address and a size of the object stored in the metadata; and marking any pointers referenced by said objects and adding their handles to the Next List, wherein the marking phase is completed when the Next List is empty which occurs when all reachable objects have been marked and scanned.

[0078] When an object is popped from the Next List, the list parameter for that object may be configured to the Null handle.

[0079] The method may comprise updating, during a / the compaction phase of the collection cycle, a free list in the directory, wherein the Free List comprises entries corresponding to the objects that are valid handles for which no object has been allocated in the heap.

[0080] The Next List, the Remembered Set List and the Free List may be linked lists.

[0081] The Next List, the Remembered Set List and the Free List may collectively be a partial partition of all valid handles.

[0082] The Next List and the Remembered Set List may collectively be a partial partition of all reachable objects.

[0083] During an initialisation phase at the start of the collection cycle, the list parameter in the first entry of at least the Next List and the Remembered Set List may be initialised to the End-of-List handle.

[0084] During an initialisation phase at start-up, the list parameter in the first entry of at least the Next List may be initialised to the End-of-List handle.

[0085] The method may comprise storing a Young Generation Address, wherein said Young Generation Address may define an address of a pre-compaction partition in the heap memory between the young generation and the old generation. The method may comprise determining an age of an object at the beginning of the collection cycle based on a value of the Young Generation Address.

[0086] The method may comprise storing a Next Young Generation Address, wherein: said Next Young Generation Address may define an address of a post-compaction partition in the heap memory between the young generation and the old generation; and the young generation address may be updated to the value of the next young generation address following completion of the collection cycle.

[0087] The method may comprise storing a Promotion Address, wherein said Promotion Address may hold a pre-compaction phase address of a word following the end of the highest-addressed object in the heap memory which will be promoted during the collection cycle.

[0088] The collection cycle described above with respect to the third aspect may be a young-generation only collection. Less frequently than every collection cycle, a full collection of both the young generation and the old generation may be run.

[0089] During the marking process an object may be added to the Remembered Set List when the object is marked and not already in the Next List or Remembered Set List.

[0090] During a / the compaction phase of the collection cycle, an object may be added to the Remembered Set List when it is not already in the Remembered Set List and when: the object is not yet compacted and is old based on a comparison of its address with the young generation address; or the object is already compacted and is old based on a comparison of its address with the next young generation address.

[0091] The method may comprise promoting an object from the young generation to the old generation based, at least, on an age of the object, wherein the age of the object is based on a count of full and / or young-only collection cycles survived.

[0092] According to a fourth aspect of the disclosure, there is provided a garbage collector. The garbage collector may be a generational garbage collector. The garbage collector may be provided as an integrated garbage collector, e.g. implemented in hardware integrated into an integrated-circuit die. The garbage collector may comprise a processing circuit. Said processing circuit may be configured to partition a heap memory into a young generation comprising young objects and an old generation. Said processing circuit may be configured to dynamically partition the heap memory into the young generation the old generation, e.g. perform partitioning during a run-time of one or more applications, kernels or operating systems or the like on a processing device or system upon which the garbage collector may be implemented. The old generation may refer to a partition of the heap comprising old objects relative to the young objects. The young generation may refer to a partition of the heap comprising young objects relative to the old objects. The processing circuit may be configured to administer and / or maintain a directory. Said directory may comprise entries corresponding to each object of the young and old objects, e.g. each object in the heap that has been assigned to the old or young generation.

[0093] The processing circuit may be configured to administer and / or maintain a Remembered Set List.

[0094] The processing circuit may be configured to update, during a collection cycle, the Remembered Set List in the directory.

[0095] The Remembered Set List may comprises entries corresponding to the old objects that have been promoted from the young generation into the old generation and that may have been determined to comprise, or to be likely to comprise, one or more pointers to one or more young objects.

[0096] Each entry in the directory may comprise metadata.

[0097] The metadata may comprise a list parameter selectively configurable between (at least) an End-of-List handle, a Null handle and a Valid handle. In some examples the metadata may comprise a list parameter selectively configurable between an End- of-List handle, a Null handle and a Valid handle exclusively.

[0098] The End-of-List handle may indicate that a corresponding object, e.g. an object to which the handle relates, is a final entry in a list of entries.

[0099] The Valid handle may indicate that the corresponding object may be a non-final entry in a / the list of entries.

[0100] The Null handle may indicate that the corresponding object may not be included in any list.

[0101] Features described above as optional features corresponding to the first aspect will be understood to also be optional features of the fourth aspect of the disclosure.

[0102] According to a fifth aspect of the disclosure, there is provided a garbage collector comprising a processing circuit. The processing circuit may be configured to: maintain a directory comprising entries corresponding to objects. Each entry in the directory may comprise metadata comprising a list parameter selectively configurable between an End-of-List handle, a Null handle and a Valid handle. The End-of-List handle may indicate that a corresponding object is a final entry in a list of entries.

[0103] The Valid handle may indicate that the corresponding object is a non-final entry in the list of entries.

[0104] The Null handle may indicate that the corresponding object is not included in any list.

[0105] The garbage collector may be configured an integrated generational garbage collector.

[0106] The directory may comprise entries corresponding to young objects and old objects relative to the young objects.

[0107] The garbage collector may be configured as an integrated generational garbage collector.

[0108] The processing circuit may be configured to dynamically partition a heap memory into a young generation comprising the young objects and an old generation comprising the old objects.

[0109] The processing circuit may be configured to update, during a collection cycle, a Remembered Set List in the directory, wherein the Remembered Set List comprises entries corresponding to the old objects that have been promoted from the young generation and that have been determined to comprise, or to be likely to comprise, one or more pointers to young objects.

[0110] Features described above as optional features corresponding to the first and fourth aspects will be understood to also be optional features of the fifth aspect of the disclosure.

[0111] The above summary is intended to be merely exemplary and non-limiting. The disclosure includes one or more corresponding aspects, embodiments or features in isolation or in various combinations whether or not specifically stated (including claimed) in that combination or in isolation. It should be understood that features defined above in accordance with any aspect of the present disclosure or below relating to any specific embodiment of the disclosure may be utilized, either alone or in combination with any other defined feature, in any other aspect or embodiment or to form a further aspect or embodiment of the disclosure.

[0112] BRIEF DESCRIPTION OF DRAWINGS These and other aspects of the present disclosure will now be described, by way of example only, with reference to the accompanying drawings, wherein:

[0113] Figure 1 depicts a block diagram of an example implementation of an integrated generational garbage collector, according to an embodiment of the disclosure;

[0114] Figure 2 depicts a representation of a sub-set of a register set of the integrated generational garbage collector of Figure 1, together with a block diagram of a memory map, showing an example of an intergenerational pointer;

[0115] Figure 3 depicts a block diagram of a memory map, showing an example of an object implicitly promoted by the integrated generational garbage collector, according to an embodiment of the present disclosure;

[0116] Figure 4 depicts an example register set of an integrated generational garbage collector, according to an embodiment of the disclosure;

[0117] Figure 5 depicts an example of memory resources used by the integrated generational garbage collector described by Figure 4;

[0118] Figure 6 depicts a state diagram of an example integrated generational garbage collector, according to an embodiment of the present disclosure; and

[0119] Figures 7-22 depict sub-state diagrams of salient states of the state diagram of Figure 6.

[0120] DETAILED DESCRIPTION OF DRAWINGS

[0121] Known garbage collectors may be “single-generation collectors”. That is, said collectors may be configured to mark and compact an entire memory space, e.g. heap, in each collection cycle. This is known to be inefficient as a result of the Weak Generational Hypothesis, which states that “most objects die young”.

[0122] That is, most objects are allocated, used for a short period of time, and can then be freed. Relatively few objects survive for a substantially longer period. Those that do, tend to survive for a much longer period of time. Typically, relatively long-lived objects are also relatively large objects.

[0123] The aim of generational collection is to focus the collector’s effort on objects which are more likely to be unused. This means focusing the collector on the “young” objects, and only relatively infrequently checking older objects. This is achieved using "generations". Generations may be partitions of memory, wherein each partition is for storing a generation of objects, e.g. relatively young or relatively old objects.

[0124] Although the embodiments described herein are based on two generations - one for relatively young objects and one for relatively old objects, it will be appreciated that the concepts disclosed herein may be extended to three, four or even more generations.

[0125] As described in more detail below, in disclosed embodiments the collector may be configured to scan the young generation on every collection cycle, and less frequently (for example one in every 10 cycles) the collector may also be configured to scan the old generation to identify older objects which are no longer in use.

[0126] New objects are allocated in the young region. When one or more predefined criteria are met, a young object may be "promoted" (i.e. moved) into the old region. In one example, a criterion may be an "age" of the object, e.g. an indication of how many collection cycles the object has already survived. If the object becomes unused before the criterion is met, then it is freed and the garbage collector has avoided the work of moving the object into the old region. Further example predefined criteria are described in more detail below.

[0127] In some instances a program (mutator) may decide to store into an old object a reference (“pointer”) to a young object. This creates an inter-generational reference that must be tracked, so that when collecting only the young generation, the collector knows to retain said young object. In the disclosed embodiments, a set of such tracked objects is known as the "Remembered Set", and is used as an additional set of root objects when collecting only the young generation.

[0128] Thus, an implementation in hardware of an integrated generational garbage collector requires careful design and implementation of: (i) A partitioning scheme for the memory, e.g. to identify the generations; (ii) One or more promotion criteria for deciding when to promote an object from the young generation to the old generation; (iii) Means to capture and store the Remembered Set for tracking old-into-young references; and (iv) One or more criteria for determining when to run a “full collection” of the entire heap memory, i.e. a collection of both young and old generations.

[0129] Example embodiments of an integrated hardware garbage collection are now described in more detail with reference to Figures 1 to 22. Figure 1 depicts a block diagram of an example implementation of an integrated generational garbage collector, according to an embodiment of the disclosure.

[0130] The example implementation is of an integrated hardware generational garbage collector. That is, the integrated generational garbage collector, or at least key components of said collector, are physical components, e.g. implemented as a hard- macro or as a synthesized design, e.g. a sea-of-gates, and generally formed as an embedded circuit, e.g. a CMOS circuit.

[0131] The example implementation, depicts a processor architecture 100. The example architecture 100 depicts a core 105, e.g. a processing unit. The core 105 may, for example, comprise a central processing unit (CPU), such as a CPU having a RISC architecture, CISC architecture, or the like.

[0132] Although the depicted processor architecture 100 comprises only a single core 105, it will be appreciated that the disclosure may be applicable to processors architecture comprising two or more cores, e.g. multicore or many core architectures.

[0133] The example processor architecture 100 comprises features that are typical of known processor architectures, e.g. a Memory Protection Unit (MPU) 110, a Memory Management Unit (MMU) 120, physical caches 125 (which may be implemented as a Harvard architecture, unified architecture, or any combination thereof, and / or may comprise more than one layer) and memories 130.

[0134] Also depicted are virtual caches 135, which in this instance comprises any / all of instruction, data and / or object caches, wherein the object cache is for storing a directory of object metadata as described in more detail below with reference to Figure 2.

[0135] It will be appreciated that the example processor architecture 100 is a simplified depiction, and other typical features such as crossbars, switch fabrics, network interfaces, interrupt and exception handlers, and the like, are not depicted.

[0136] Also depicted is a hardware, integrated generational garbage collector 145. The integrated generational garbage collector 145 comprises one or more processing circuits (or may be implemented as a processing circuit), enabling the integrated generational garbage collector 145 to carry out garbage collection (marking and compacting) as described in detail throughout. Examples of said processing circuits may comprise one or more of: a state machine; a processor core; a register set; local memory storage and / or caches; interfaces to other memories; bus snooping logic; network interconnects. The example integrated generational garbage collector 145 is tightly coupled to the processor architecture through a memory cycle governor 140. In example embodiments, the memory cycle governor 140 may be configured to select, on a cycle- by-cycle basis, transactions coming from the integrated generational garbage collector 145 or from the core 105 that are to be interleaved as memory access requests, e.g. loads or stores, going to the memories 130. Also depicted is a snapshot accumulator 150 configurable to capture a snapshot of registers of the core 105 to provide roots for subsequent garbage collection. The snapshot accumulator 150 may be synchronised to execution of load / store queue of the core 105, and / or may be configured to snoop any caches and / or busses extending between the core 105 and the system memories 130.

[0137] Figure 2 depicts a representation of a sub-set of a register set of the integrated generational garbage collector 145 of Figure 1, together with a block diagram of a memory map, showing an example of an intergenerational pointer.

[0138] The sub-set of the register set comprises a register denoted “Next” which, in use, holds a handle to the head of a “Next List”. Maintenance and use of the Next List is described in more detail below.

[0139] The sub-set of the register set comprises a register denoted “Current” or “Current Handle” which, in use, holds a handle of an object currently being marked or compacted.

[0140] The sub-set of the register set comprises a register denoted “Free” which, in use, holds a handle to the head of a “Free List”, which is described in more detail below.

[0141] The sub-set of the register set comprises a register denoted “Remembered Set” which, in use, holds a handle to the head of a “Remembered Set”, e.g. the linked list for the Remembered Set, which is described in more detail below.

[0142] The sub-set of the register set comprises a register denoted “Young Generation Address” which, in use, holds the physical address of the first young-generation object in the heap. (If no such object exists, the Young Generation Address equals the Heap Point.)

[0143] The sub-set of the register set comprises a register denoted “Promotion Address” which, in use, holds the physical address pre-compaction of the word following the end of the highest object in the heap which will be promoted in the current cycle. The sub-set of the register set comprises a register denoted “Next Young Generation Address” which, in use, hold the new physical address of the first younggeneration object in the heap after compaction completes.

[0144] The sub-set of the register set comprises a register denoted “Heap Point” which, in use, holds a total size of the heap, i.e. the address at which to allocate the next new object.

[0145] Also depicted is an example of a series of entries in a directory. Each entry comprises several fields or flags holding metadata associated with a particular object. In the example embodiment, each entry comprises the following fields and flags / parameters: Address; Size; Mark; Deep and List.

[0146] The Address field holds an object’s base address in physical memory.

[0147] The Size filed holds an object’s size in bytes.

[0148] The Mark flag indicates whether an object is live during a collection.

[0149] The Deep flag indicates that a pointer has been stored into the object. Said pointer may or may not be an intergenerational pointer.

[0150] The List parameter (also referred to herein as the “List Field” or “List Value”) that holds a handle and is used to chain directory records into linked lists. The list field is selectively configurable between an End-of-List (EOL) handle, a Null handle and a Valid handle, and wherein the End-of-List handle indicates that the corresponding object is a final entry in a list of entries, the Valid handle indicates that the corresponding object is a non-final entry in a / the list of entries and the Null handle indicates that the corresponding object is not included in any list.

[0151] Advantageously, having a clear distinction between the Null and End-of-List handle enables a determination of whether an object is in a list or not (e.g. the Remembered Set List, or the below described Free List or Next List), thereby advantageously solving a concurrency problem. That is, when marking is underway, the distinct handles may enable an efficient determination of whether an object is one that has yet to be marked, or whether it is an object that has for example, already been added to the Remembered Set list.

[0152] For example, if only a Null handle was to be implemented to represent an end of a list, then it may not be possible to read the respective directory entry and determine whether said entry was part of a list or not. As such, by having a distinction between the Valid handle (which maybe any value other than a value reserved for the End-of-List handle or a value reserved for the Null handle), then that entry is clearly identifiable as part of a list, and if the list parameter corresponds to the Null handle then it means the entry is clearly not part of any list.

[0153] In a non-limiting example, all-zero-bits may be used for the Null handle, and used to represent objects which are not part of any list.

[0154] In another non-limiting example, all-one-bits may be used for the End-of-List handle, and used to represent an object that is a member of a list, where it is the end element of the list.

[0155] In other examples, the End-of-List and Null handles may be given any practical distinct values.

[0156] In examples, if the list parameter field holds neither a value reserved for the End-of-List handle nor a value reserved for the Null handle, then the value is a Valid handle and represents that the object is a member of a list.

[0157] In the depicted example, a Remembered Set List comprises an object described by a fourth entry in the directory. The list parameter of the fourth entry comprises a Valid Handle indicating that the corresponding object is a non-final entry in a linked list. In the example, the Valid Handle of the fourth entry in the directory holds a pointer handle to the eighth entry in the directory.

[0158] The list parameter of the eighth entry in the directory comprises an End-of-List handle indicating that the eighth entry is a final entry in the Remembered Set List.

[0159] For purposes of example, a Next List is also depicted, wherein the List Parameter of the first directory entry comprises a valid handle pointing to the fifth entry, which in turn comprises a valid handle pointing to the sixth entry, which in turn comprises an End-of-List handle indicating that the sixth entry is a final entry in the Next List.

[0160] During a marking phase of a collection cycle, the above-described Next List may effectively provide a working list of objects to be scanned. For example, the garbage collector may start at a first entry at the front of the Next List, sequentially popping each entry from the Next List and scanning the corresponding object for pointers based on an address and a size of the object stored in the metadata; and marking any pointers referenced by said objects and adding their handles to the Next List. The marking phase may be completed when the Next List is empty, which occurs when all reachable objects have been marked and scanned. When an object is popped from the Next List, the list parameter for that object may be configured to the Null handle. Also depicted is a Free List, which in use may comprise entries corresponding to the valid handles for which no object has been allocated in the heap. In the depicted example of the Free List, the List Parameter of the third directory entry comprises a valid handle pointing to the seventh entry, which in turn comprises an End-of-List handle indicating that the seventh entry is a final entry in the Free List.

[0161] Also depicted in Figure 2 is a memory map showing how generations may be implemented within the heap, and in particular implementation of an intergenerational pointer.

[0162] In the example, the address space starts at address 0x0. The allocated memory space for the heap extends from 0x0 to an address defined by the heap point, e.g. the address at which to allocate the next new object.

[0163] The heap is partitioned by a dynamic position (physical address) within the allocated memory space. This position is called the Young Generation Address. Objects below this position may be considered “old” and objects above the position may be considered “young”. The Young Generation Address is stored in the abovedescribed Young Generation Address register. The address in the Young Generation Address register always points to a word in memory such that the word is the word immediately after the end of the highest-addressed old object in the heap. The position may move up or down in physical memory as objects are allocated, promoted and freed.

[0164] To promote an aging object from the young generation to the old generation, the Young Generation Address is moved higher to above the end of the object’s memory, meaning the promoted object now resides in the old generation (or partition).

[0165] As described above, in some instances a program may decide to store into an old object a reference (“pointer”) to a young object. This creates an inter-generational reference that must be tracked, so that when collecting only the young generation, the collector knows to retain said young object.

[0166] To address this, the disclosed integrated generational garbage collector store procedure is configured to maintain the Remembered Sets and other state, as described in more detail below.

[0167] Figure 3 depicts a block diagram of a memory map, showing an example of an object implicitly promoted by the integrated generational garbage collector, according to an embodiment of the present disclosure.

[0168] That is, promoting an object (as described above) may result in the implicit promotion of objects below the target object. All such implicitly promoted objects will be older than the object being promoted, even if they are yet to meet the pre-defined promotion criteria.

[0169] The disclosed integrated hardware generational garbage collector is configured to handle such implicitly promoted objects.

[0170] During compaction phase of a full collection cycle, when old objects become unused and are freed by the collector, a total size of objects in the old generation may decrease.

[0171] In a simplified example, (ignoring that during collection young objects may be promoted at the same time that old objects are freed) when old objects are freed the young generation address will move downwards (according to the example diagram which has address zero at the top) to ensure it continues to point to the word after the last old object in the heap.

[0172] During a collection the young generation address must be available to identify the age (old or young generation) of an object as it was at the beginning of the collection. Furthermore, as objects are compacted, a rift appears in the heap where objects above the current compaction point are still in the position and state that they were when collection began, meaning they exist in a different global state to objects which have been compacted.

[0173] The above-described Next Young Generation Address provides a necessary split of state. This register stores the young generation address as it will be when compaction completes, thereby providing the position of the young generation within the compacted part of the heap.

[0174] For completeness, Figure 4 depicts an example register set of the integrated generational garbage collector 145, according to an embodiment of the disclosure, and Figure 5 depicts an example of memory resources used by the integrated generational garbage collector 145 described by Figure 4.

[0175] In addition to the registers already described above, example embodiments of the disclosed integrated generational garbage collector may comprise: a “State” register, comprising a current state of the garbage collector; a “Register Index” register, comprising an integer value of a current index into the snapshot of the core registers; a “Current Offset” register, comprising an integer value of an offset within the object currently being marked or compacted; a “Current Size” register, comprising an integer value of a size of the object currently being marked or compacted; a “Buffer” register, comprising a word corresponding to a word of data currently being marked or compacted; a “Source” register, comprising a physical address of the source of the buffer word; a “Destination” register comprising, during compaction, a physical address of the new location of the buffer word; a “Live size” register, comprising an integer value of the total size of live (i.e. marked) data in the heap; and a “Prediction Row” register, comprising a current index of the row of the prediction table to evaluate, as described in more detail below.

[0176] Also depicted are the memories and memory structures used by the integrated generational garbage collector. In examples, each word in memory has an associated 1-bit tag that may indicate whether the word is marked or not. In the non-limiting example a word is set to 64 bits.

[0177] For completeness, a directory entry is also depicted, wherein the directory entry may correspond to the entries depicted in Figure 2. As described above, the example directory entry comprises the following fields and flags / parameters: Address; Size; Marl; Deep and List. Also depicted is an “Age” field, use of which will be described in more detail below.

[0178] In some embodiments, the directory may be implemented in the main memory. In other examples, embodiments of the directory may be implemented in a cache, tightly-coupled-memory, or internal memory of the integrated generational garbage collector 145.

[0179] Finally, a prediction table entry also depicted, wherein each entry in a prediction table comprises: an “Expected Minimum Lifetime” field; a “Total Death Count” field; an “Early Death Count” field; and a “Late Death Count” field. Operation and use of the prediction table is described in more detail below.

[0180] Figure 6 depicts a state diagram of an example integrated generational garbage collector, according to an embodiment of the present disclosure.

[0181] Note that states indicated using dashed lines may not be actual states per se, but are provided solely for illustrative purposes to highlight at a high level what the states (to the right) are going to implement.

[0182] An initialization phase, denoted “Init”, indicates the start of a collection cycle. Figures 7 and 8 depict in more detail the subs-steps taken from reset to the end of the “Init” state. Reset may be, for example, a hardware reset e.g. what happens at the point when the hardware powers on or the reset signal is sent through the hardware. As described in Figures 7 and 8, an initial step includes initialising the content of various registers of the garbage collector. Not all registers depicted in Figure 4 require initialization, as some registers are initialised during each cycle of the garbage collector. Notably, the handles stored in the Next and Remembered Set registers are initialised to End-of-List. That is, a key part of initialising the directory in the disclosed example embodiments is forming the free list as a complete chain of all entries in the directory, terminated by the End-of-List handle

[0183] A snapshot of the core registers is also initiated. This effectively starts a collection cycle. The snapshot involves capturing content of the register file of the (at least one) processing core that the generational garbage collector is coupled to. This snapshot of the processing core’s registers provides the roots of the garbage collection.

[0184] Also depicted in Figure 8 are decision points for determining whether the collection is a young-generation only collection or a full collection. A determination of whether a collection should be a young-generation only collection or a full collection may be based on various factors.

[0185] A primary purpose of splitting young-collections from full-collections is to reduce the time spent collecting the long-lived objects where no change has taken place. As such, a frequency of collections of the old generation may be optimized to avoid collection too often, thereby wasting time / energy / etc., or too infrequently, thereby holding on to large amounts of data (also caused by Remembered Sets) that may lead to heap overrun or heap exhaustion.

[0186] In some examples, one criterion may be that two full collections in a row must be run if an allocation request is pending, before the collector can conclude that the heap is exhausted.

[0187] A frequency at which full-collections may be run may be, for example, based on at least one of:

[0188] - absolute thresholds based on a time measure, e.g. 1 full collection for every 3 young generation collections;

[0189] - allocation rate (objects or bytes per time measure)

[0190] - birth rate (objects or bytes per time measure; possibly measured per- generation);

[0191] - death rate (objects or bytes per time measure; possibly measured per- generation);

[0192] - churn ratio (ratio per time measure of deaths to births plus deaths);

[0193] - promotion rate (objects or bytes promoted into the old generation per time measure); - total heap size (in bytes; absolute thresholds or percentage of available memory);

[0194] - old generation size (in bytes; absolute thresholds or percentage of available memory or percentage of total heap size);

[0195] - young generation size (in bytes; absolute thresholds or percentage of available memory or percentage of total heap size);

[0196] - Remembered Set size (in terms of number of objects or total size of remembered objects in bytes); and / or

[0197] - remembered portion (ratio of the Remembered Set size to the old generation size).

[0198] Referring again to Figure 6, following completion of the “I nit” state, the garbage collector enters a phase of marking roots and objects.

[0199] This involves scanning, checking and marking the roots, and is depicted in more detail in Figures 9 and 10. Effectively, this involves going through the abovedescribed snapshot of the ISA registers and picking out any pointers that are not nil pointers and then, if they are not already marked, marking them and adding those objects to the Next List. That is, the mark flag is set in the directory and that handle is added to the Next List - effectively adding to the head of the linked list. Note the referenced “buffer” is the current word that has been read out of the object, e.g. a piece of data that has been established to be a non-nil pointer.

[0200] Note that when marking the roots, if the object is determined not to contain pointers, e.g. the deep field is not equal to zero, the list field is set it to nil. This is important because it indicates the object is not added to the Next List, and also that it is not part of any other list. The nil handle effectively indicates that if the object is encountered again during this collection cycle, it could be added to a different list.

[0201] Marking the objects is depicted in more detail in Figures 11 to 14. Marking objects includes scanning for all other pointers that can be found, and therefore all other objects that can be found, and is managed using the Next List. The process of marking starts by popping the head of Next List, scanning through each word of the referenced object searching for pointers. If a pointer is found, it is marked, e.g. checked if it is already marked and if not then it is added to the Next List. Note, if it is already marked then it either already exists in the Next List (so no immediate action is required) or has already been marked and scanned (so no further action is required.)

[0202] Once this marking process is complete, the entire reachable memory has been traversed. The allocated memory at this stage is effectively partitioned into three groups: a first group of free objects; a second group of marked objects; and a third group of unmarked objects that were unreachable and so are available to be freed.

[0203] Referring again to Figure 6, following completion of the “Mark Roots” and “Mark Objects” states, the garbage collector enters a series of states including: an “Evaluate age prediction row” state, e.g. a state of updating row(s) in the above-described prediction table; a “Remember Object” state; and (during subsequent compaction) a “Promote object” and “Age object” state, e.g. literally increasing an age entry in the directory of the number of collection cycles the object has survived, which are described in more detail in Figures 15 to 19.

[0204] With regard to promotion of an object (depicted in Figure 16), a predefined criteria may be used to determine whether an object is to be promoted.

[0205] Notably, the disclosed garbage collector does not promote objects out of order. That is to say, if two objects X and Y exist in the young generation, where Y was allocated before X (so Y is lower in the heap), and X is predicted to survive a long time (and therefore it is desirable to promote X earlier into the old generation), it may not be possible to do so without also promoting Y (even if we predict Y will live a shorter amount of time). That is, Y becomes an example of the above-described implicitly promoted object.

[0206] The age of objects will be measured as a count of collection cycles survived, both full and young-only collections. This may be stored in the directory as a saturating counter, initialised to zero on allocation, e.g. the above-described “Age” field. Each time an object is compacted and found to be marked, the counter will be incremented. For purposes of example only, in the embodiments described herein, the counter is a 3-bit counter. The size of the counter may be predicated on the idea that one full collection will run for every three young generation collections. As such, objects will survive at least 1 full collection before saturating their count. Note, if the criterion for ensuring a full collection is changed, then the size of the counter in the directory may be changed accordingly.

[0207] In example embodiment, a prediction table might be constructed as follows: Under this example scheme, the minimum lifetime of an object within a given size range may be predicted. The size ranges (also referred to as “object size buckets”) may be fixed at design-time.

[0208] In the example, the total / early / late death counts may be stored as saturating 10- bit counters. In examples, the size of the counter may be based on observation of real programs, e.g. an amount of objects allocated / freed over the course of a few collection cycles.

[0209] The expected minimum lifetime may be a counter sized and operated in the same way as each object’s lifetime counter in the directory.

[0210] As objects are freed, the Death count of the corresponding size bucket may be incremented. When an object is freed: if its lifetime is less than the current expected lifetime for its size bucket, the early death count may be incremented; or if its lifetime is greater than the current expected lifetime for its size bucket, the late death count may be incremented.

[0211] At the start of compaction, each row of the prediction table may be evaluated as follows: for purposes of non-limiting example, in an embodiment if the Death count is greater than a predefined value, such as 31 or the like, then:

[0212] If the Early Death count exceeds half the Total Death count, the Expected Lifetime is reduced by 1 step (according to the operation of the lifetime counter, allowing for bottoming-out.) The counts for this row are reset.

[0213] Else if the Late Death count exceeds half the Total Death count, the Expected Lifetime is increased by 1 step (according to the operation of the lifetime counter, allowing for saturation.) The counts for this row are reset.

[0214] Else if the Total Death count is fully saturated, the counts for this row are reset.

[0215] Else no change is made.

[0216] The condition for an object to be considered promotable may be as follows:

[0217] The object’s lifetime is greater than or equal to: the maximum expected lifetime (determined by the saturation value of the lifetime counters) minus the Expected Minimum Lifetime for its size, and the object’s current lifetime is greater than 4 collection cycles (i.e. it already survived at least one full-collection cycle), and the T otal Death count is greater than 31. It will be understood that the threshold of “31” is merely an example and any other sensible value based on observations of real programs may be implemented.

[0218] A process of remembering an object, e.g. constructing the Remembered Set, is depicted in Figures 13 and 15. “Remembering” an object may occur in parallel, or as part of the process of checking an object word during marking of objects.

[0219] As described above, old objects which may contain pointers to young objects may be “remembered”, e.g. tracked, by means of a linked list termed the Remembered Set List which describes the Remembered Set and is stored in the directory.

[0220] To determine whether an object should be added to the Remembered Set, it may be required to determine whether the object is likely to contain a pointer to a young object.

[0221] In some examples, the above-described Deep flag may provide an approximation, because the Deep flag provides and indicates that a pointer has been stored into the object (although does not necessarily distinguish between a pointer to an old or young object).

[0222] In some example embodiments, a further flag (or an extension of the Deep flag) may be implemented, where said further bit (hereafter termed a “Child Pointer Flag”) may indicate that the object contains a pointer to a young object. Such a Child Pointer Flag would be cleared when an object is compacted, initialised to zero at allocation, and set during marking. If, during compaction, an object is to be implicitly promoted, the Child Pointer Flag could be checked instead of (or in addition to) the Deep Flag.

[0223] In the described example embodiment, the Remembered Set is specifically a mathematical “set” because each object is only listed once and there’s no ordering requirement. Lists may represent a set if items are added only once to the list.

[0224] To fulfil this requirement, it is necessary to determine, upon encountering an object that is to be added to the Remembered Set, whether said object is already a member of the list.

[0225] This may be achieved by use of the above-described handle to represent the End of List (EOL). The EOL handle is distinct from the Null (or Nil) handle, which instead indicates that an object is not part of any list. If the list field for an object described in the directory is neither EOL nor Null, then the value is a valid handle and represents that the object is a member of a list.

[0226] At start up, the Next and Remembered Set lists may be initialised to the End of List handle. The Next and Remembered Set registers are also initialised at the beginning of each collection cycle. The Free List may be initialised to the “first” handle, which forms the head of the linked list which comprises every entry in the directory.

[0227] Note that at all times, the Next List and Remembered Set lists are a partial partition of all allocated objects. The Next, Remembered Set and Free lists are, collectively, a partial partition of all valid handles.

[0228] An example of construction, maintenance and use of the Remembered Set is now described in more detail.

[0229] The Remembered Set is constructed during a collection cycle, ready for use as root objects in the next cycle. If the next collection cycle is a full collection, then the Remembered Set doesn’t matter as it will be discarded. Otherwise, the next collection cycle is a young-only collection which will require the Remembered Set.

[0230] In examples, the system starts by running a full collection cycle to initialise the Remembered Set, followed by combinations of full and young-only collections.

[0231] As described above, collection has two phases: marking and compaction. During marking, the list of all currently-old objects that may contain pointers to young objects is accumulated. The Promotion Address is also accumulated. During marking, any promoted objects which may contain pointers to young objects are added to the accumulated Remembered Set.

[0232] During marking, when an object is taken off the Next List, its list field is set to the Null handle, to indicate the object is not part of any list. If the object is currently an old object then it may need to be added to the Remembered Set. As scanning of the object proceeds, if a pointer to a currently-young object is encountered, then the current (old) object is added to the Remembered Set.

[0233] An object is added to the Remembered Set as follows: if the object’s list field in the directory is not the Null handle, then no action is taken, since the object is indicated as already being a member of a list; and if the object’s list field in the directory is the Null handle, the object’s handle is set to the current value of the Remembered Set register. The Remembered Set register is set to the value of the object’s handle.

[0234] Note that during compaction, objects are moved (compacted) as normal. However, if prior to moving an object it resides below the Promotion Address and the object’s Deep flag is set, then the object is added to the Remembered Set (as per above). As such, both implicitly and explicitly promoted objects that may contain pointers to the young generation may be detected.

[0235] With regard to young-only collections, said young-only collections proceed as per full-collection. This is valid because the Remembered Set will be used to include all old objects which may contain pointers to young objects in the marking process. When mark-scanning encounters such objects, they will be re-added to the Remembered Set. Any young objects which are promoted will also be remembered (added to the Remembered Set) as a result of the above-described compaction-stage construction of the Remembered Set.

[0236] Maintenance of the Remembered Set is as follows.

[0237] When an object is allocated, its list field is initialised to the Null handle. During collection, a mutator program may still be operating. This means that the mutator program may write a pointer to a young object into any other object in memory. If the object that the pointer was written into is an old object (by the end of collection), then it is desirable to ensure that old object is added to the Remembered Set. There are several scenarios:

[0238] If, during marking, the object is not marked, not in the Next List and not in the Remembered Set, then the object will be marked and added to the Next List as part of the existing store procedure.

[0239] If, during marking, the object is marked and in the Next List, then no action with regard to the Remembered Set is required because the object is already in the Next List, as detectable by the value of the list field being any value other than the Null handle.

[0240] If, during marking, the object is marked but not in the Next List nor in the Remembered Set, then if the object is currently being marked and scanning has already progressed past the word being stored into, the object is added to the Remembered Set.

[0241] If, during marking, the object is marked but not in the Next List nor in the Remembered Set, then if the object is currently being marked and scanning is yet to reach the word being stored into, no action with regard to the Remembered Set is required. Note that, in some alternative embodiments, the object may be added to the Remembered Set.

[0242] If, during marking, the object is marked but not in the Next List nor in the Remembered Set, if the object is not currently being marked, the object is added to the Remembered Set.

[0243] If, during marking, the object is marked and not in Next List, but is already in the Remembered Set, then no action with regard to the Remembered Set is required because the object is already remembered. If, during compaction, the object is not yet compacted, and is “Old” (as measured by young generation address), and not in the Remembered Set, then the object is added to the Remembered Set.

[0244] If, during compaction, the object is not yet compacted, and is “Old” (by young generation address), and already in Remembered Set, the no action with regard to the Remembered Set is required because the object is already remembered.

[0245] If, during compaction, the object is not yet compacted, and is “Young” (by the Young Generation Address), but located below the Promotion Address, and not in the Remembered Set, then no action with regard to the Remembered Set is required, because the compactor will add the object to the Remembered Set when it is promoted.

[0246] If, during compaction, the object is compacted, and is “Old” (by the Next Young Generation Address), and not already in the Remembered Set, then the object is added to the Remembered Set.

[0247] If, during compaction, the object is compacted, and is “Old” (by the Next Young Generation Address), and already in the Remembered Set, then no action with regard to the Remembered Set is required, because the object is already remembered.

[0248] In use, at the beginning of a young-only collection, the Remembered Set register may be copied to the Next Register, and the Remembered Set register is set to the End of List handle

[0249] In use, at the beginning of a full collection, the Next and Remembered Set registers may be initialised to the End of List handle, effectively discarding the Remembered Set, as it is not used for a full collection.

[0250] Accumulation of the next Young Generation Address is now described, with reference to the above-described register denoted “Promotion Address”.

[0251] During marking, the Promotion Address is determined. During compaction, the next young generation address is accumulated. When a collection cycle completes, the young generation address is updated to the value of the next young generation address.

[0252] The Promotion Address register enables detection of both implicitly and explicitly promoted objects during compaction.

[0253] During marking, when a young object is scanned, a determination is made (based on the Promotion criterion describe above) whether the object will promoted into the old generation in this cycle. If so, and if the object’s address plus its size (in words) plus the number of header words (in the example embodiment, one header word) is greater than the current value of the Promotion Address, then the Promotion Address is set to match the aforementioned value.

[0254] During compaction, after compacting an object, if it is an old object, the next young generation address is set to be the address of the word immediately after the end of the object. This results in the next young generation address being the address of the beginning of the lowest young object in the heap.

[0255] A frequency at which full-collections may be run may be, for example, based on at least one of:

[0256] - one or more absolute thresholds based on a time measure, e.g. 1 full collection for every 3 young generation collections;

[0257] - an allocation rate (objects or bytes per time measure)

[0258] - a birth rate (objects or bytes per time measure; possibly measured per- generation);

[0259] - a death rate (objects or bytes per time measure; possibly measured per- generation);

[0260] - a churn ratio (ratio per time measure of deaths to births plus deaths);

[0261] - a promotion rate (objects or bytes promoted into the old generation per time measure);

[0262] - a total heap size (in bytes; absolute thresholds or percentage of available memory);

[0263] - an old generation size (in bytes; absolute thresholds or percentage of available memory or percentage of total heap size);

[0264] - a young generation size (in bytes; absolute thresholds or percentage of available memory or percentage of total heap size);

[0265] - a Remembered Set size (in terms of number of objects or total size of remembered objects in bytes); and / or

[0266] - a remembered portion (ratio of the Remembered Set size to the old generation size).

[0267] For completeness, Figures 19 to 22 depict in more detail a selection of further states of the compacting phase of the garbage collector, namely, the “Load Object Metadata”, “Load Word”, “Clear Word”, “Store Word” “Store Zero Word” and “End” states.

[0268] Although the disclosure has been described in terms of preferred embodiments as set forth above, it should be understood that these embodiments are illustrative only and that the claims are not limited to those embodiments. Those skilled in the art will be able to make modifications and alternatives in view of the disclosure, which are contemplated as falling within the scope of the appended claims. Each feature disclosed or illustrated in the present specification may be incorporated in any embodiments, whether alone or in any appropriate combination with any other feature disclosed or illustrated herein.

Claims

CLAIMS1. An integrated generational garbage collector comprising a processing circuit configured to: dynamically partition a heap memory into a young generation comprising young objects and an old generation comprising old objects relative to the young objects, and maintain a directory comprising entries corresponding to each object of the young and old objects, update, during a collection cycle, a Remembered Set List in the directory, wherein the Remembered Set List comprises entries corresponding to the old objects that have been promoted from the young generation and that have been determined to comprise, or to be likely to comprise, one or more pointers to young objects, wherein each entry in the directory comprises metadata, said metadata comprising a list parameter selectively configurable between an End-of-List handle, a Null handle and a Valid handle, and wherein the End-of-List handle indicates that a corresponding object is a final entry in a list of entries, the Valid handle indicates that the corresponding object is a non-final entry in a / the list of entries and the Null handle indicates that the corresponding object is not included in any list.

2. The integrated generational garbage collector of claim 1 , wherein the processing circuit is configured to process, during a marking phase of the collection cycle, a Next List that is stored in the directory, wherein said processing comprises: starting at a first entry at the front of the Next List, sequentially popping each entry from the Next List and scanning the corresponding object for pointers based on an address and a size of the object stored in the metadata; and marking any pointers referenced by said objects and adding their handles to the Next List, wherein the marking phase is completed when the Next List is empty, which occurs when all reachable objects have been marked and scanned.

3. The integrated generational garbage collector of claim 2 wherein, when an object is popped from the Next List, the list parameter for that object is configured to the Null handle.

4. The integrated generational garbage collector of any preceding claim, wherein the processing circuit is configured to update, during a compaction phase of the collection cycle, a free list in the directory, wherein the Free List comprises entries corresponding to the objects that are valid handles for which no object has been allocated in the heap.

5. The integrated generational garbage collector of claim 4, when dependent upon claim 2 or 3, wherein at least one of: the Next List, the Remembered Set List and the Free List are linked lists; the Next List, the Remembered Set List and the Free List are collectively a partial partition of all valid handles; the Next List and the Remembered Set List are collectively a partial partition of all reachable objects; during an initialisation phase at the start of the collection cycle, the list parameter in the first entry of at least the Next List and the Remembered Set List is initialised to the End-of-List handle; and / or during an initialisation phase at start-up, the list parameter in the first entry of at least the Next List is initialised to the End-of-List handle.

6. The integrated generational garbage collector of any preceding claim, comprising a Young Generation Address register, wherein a value stored in said Young Generation Address register defines an address of a precompaction partition in the heap memory between the young generation and the old generation.

7. The integrated generational garbage collector of claim 6, wherein the processing circuit is configured to determine an age of an object at the beginning of the collection cycle based on a value of the Young Generation Address.

8. The integrated generational garbage collector of claim 6 or 7 comprising a Next Young Generation Address register, wherein: a value stored in said Next Young Generation Address defines an address of a post-compaction partition in the heap memory between the young generation and the old generation; and the value stored in Young Generation Address register is updated to the value of the Next Young Generation Address register following completion of the collection cycle.

9. The integrated generational garbage collector of any preceding claim, comprising a Promotion Address register, wherein said Promotion Address holds a pre-compaction phase address of a word following the end of the highest-addressed object in the heap memory which will be promoted during the collection cycle.

10. The integrated generational garbage collector of any preceding claim, wherein the collection cycle is a young-generation only collection, and wherein less frequently than every collection cycle, a full collection of both the young generation and the old generation is run.

11. The integrated generational garbage collector of any preceding claim, wherein the processing circuit is configured such that during the marking process an object is added to the Remembered Set List when the object is marked and not already in the Next List or Remembered Set List.

12. The integrated generational garbage collector of any preceding claim, wherein the processing circuit is configured such that during a / the compaction phase of the collection cycle, an object is added to the Remembered Set List when it is not already in the Remembered Set List and when: the object is not yet compacted and is old based on a comparison of its address with the young generation address; or the object is already compacted and is old based on a comparison of its address with the next young generation address.

13. The integrated generational garbage collector of any preceding claim, wherein the processing circuit is configured such that an object is promoted from the young generation to the old generation based, at least, on an age of the object, wherein the age of the object is based on a count of full and / or young-only collection cycles survived.

14. The integrated generational garbage collector of any preceding claim, wherein the processing circuit is configured to make a determination of when to perform a full collection of both the young generation and the old generation is based on one or more of: absolute thresholds based on a time measured; a memory allocation rate; a birth or death rate or objects, or a ratio of said birth or death rate; a rate of promotion of objects from the young generation into the old generation, per time measure; a total heap memory size based upon one or more absolute thresholds or percentages of available memory; a size of the old generation based upon one or more absolute thresholds or percentages of available memory and / or a percentage of total heap memory size; a size of the young generation based upon one or more absolute thresholds or percentage of available memory or percentage of total heap memory size; a size of a Remembered Set List, in terms of a number of objects or a total size of remembered objects in bytes; and / or a ratio of a Remembered Set List size to the old generation size.

15. An integrated circuit comprising: at least one processing core; and the integrated generational garbage collector of any of claims 1 to 14.

16. The integrated circuit of claim 15, wherein the integrated generational garbage collector is configured with read-only access to a register file of the at least one processing core.

17. The integrated circuit of claim 15 or 16, comprising a memory accessible by the integrated generational garbage collector, wherein the directory is stored in the memory.

18. The integrated circuit of any of claims 15 to 17, implemented as a CMOS integrated circuit.

19. A method of generational garbage collection, the method comprising: dynamically partitioning a heap memory into a young generation comprising young objects and an old generation comprising old objects relative to the young objects, and maintaining a directory comprising entries corresponding to each object of the young and old objects, the method further comprising updating, during a collection cycle, a Remembered Set List in the directory, wherein the Remembered Set List comprises entries corresponding to the old objects that have been promoted from the young generation and that have been determined to comprise, or at to be likely to comprise, one or more pointers to young objects, wherein each entry in the directory comprises metadata, said metadata comprising a list parameter selectively configurable between an End-of-List handle, a Null handle and a Valid handle, and wherein the End-of-List handle indicates that the corresponding object is a final entry in a list of entries, the Valid handle indicates that the corresponding object is a non-final entry in a / the list of entries and the Null handle indicates that the corresponding object is not included in any list.

20. The method of claim 19 comprising processing, during a marking phase of the collection cycle, a Next List that is stored in the directory, wherein said processing comprises: starting at a first entry at the front of the Next List, sequentially popping each entry from the Next List and scanning the corresponding object for pointers based on an address and a size of the object stored in the metadata, and marking any pointers referenced by said objects and adding their handles to the Next List,wherein the marking phase is completed when the Next List is empty, which occurs when all reachable objects are marked and scanned.

21. The method of claim 19 or 20 wherein, when an object is popped from the Next List, the list parameter for that object is configured to the Null handle.

22. The method of any of claims 19 to 21 comprising updating, during a / the compaction phase of the collection cycle, a free list in the directory, wherein the Free List comprises entries corresponding to valid handles for which no object has been allocated in the heap.

23. The method of claim 22, when dependent upon claim 20 or 21 , wherein at least one of: the Next List, the Remembered Set List and the Free List are linked lists; the Next List, the Remembered Set List and the Free List are collectively a partial partition of all valid handles; the Next List and the Remembered Set List are collectively a partial partition of all reachable objects; during an initialisation phase at the start of the collection cycle, the list parameter in the first entry of at least the Next List and the Remembered Set List is initialised to the End-of-List handle; and / or during an initialisation phase at start-up, the list parameter in the first entry of at least the Next List is initialised to the End-of-List handle.

24. The method of any of claims 19 to 23, comprising storing a Young Generation Address, wherein said Young Generation Address defines an address of a precompaction partition in the heap memory between the young generation and the old generation.

25. The method of claim 24, comprising determining an age of an object at the beginning of the collection cycle based on a value of the Young Generation Address.

26. The method of claim 24 or 25, comprising storing a Next Young Generation Address, wherein: said Next Young Generation Address defines an address of a postcompaction partition in the heap memory between the young generation and the old generation; and the young generation address is updated to the value of the next young generation address following completion of the collection cycle.

27. The method of any of claims 19 to 26, comprising storing a Promotion Address, wherein said Promotion Address holds a pre-compaction phase address of a word following the end of the highest-addressed object in the heap memory which will be promoted during the collection cycle.

28. The method of any of claims 19 to 27, wherein the collection cycle is a younggeneration only collection, and wherein less frequently than every collection cycle, a full collection of both the young generation and the old generation is run.

29. The method of any of claims 19 to 28, wherein during the marking process an object is added to the Remembered Set List when the object is marked and not already in the Next List or Remembered Set List.

30. The method of any of claims 19 to 19, wherein during a / the compaction phase of the collection cycle, an object is added to the Remembered Set List when it is not already in the Remembered Set List and when: the object is not yet compacted and is old based on a comparison of its address with the young generation address; or the object is already compacted and is old based on a comparison of its address with the next young generation address.

31. The method of any of claims 19 to 30, comprising promoting an object from the young generation to the old generation based, at least, on an age of the object, wherein the age of the object is based on a count of full and / or young-only collection cycles survived.

32. A garbage collector comprising a processing circuit configured to:maintain a directory comprising entries corresponding to objects, wherein each entry in the directory comprises metadata comprising a list parameter selectively configurable between an End-of-List handle, a Null handle and a Valid handle, and wherein: the End-of-List handle indicates that a corresponding object is a final entry in a list of entries; the Valid handle indicates that the corresponding object is a nonfinal entry in the list of entries; and the Null handle indicates that the corresponding object is not included in any list.

33. The garbage collector of claim 32, configured an integrated generational garbage collector.

34. The garbage collector of claim 32 or 33, wherein the directory comprises entries corresponding to young objects and old objects relative to the young objects,35. The garbage collector of claim 34, configured as an integrated generational garbage collector, and wherein the processing circuit is configured to dynamically partition a heap memory into a young generation comprising the young objects and an old generation comprising the old objects.

36. The garbage collector of any of claims 32 to 34, wherein the processing circuit is configured to update, during a collection cycle, a Remembered Set List in the directory, wherein the Remembered Set List comprises entries corresponding to the old objects that have been promoted from the young generation and that have been determined to comprise, or to be likely to comprise, one or more pointers to young objects.SUBSTITUTE SHEET (RULE 26)

Citation Information

Patent Citations

  • Methods and apparatus for information storage and retrieval using a caching technique with external-chain hashing and dynamic resource-dependent data shedding

    US9081672B1

  • Train-algorithm-based garbage collector employing farthest-forward-car indicator

    WO2001013238A1