jdeans289 / icg2

Interface Code Generator 2: Electric Boogaloo
Other
0 stars 2 forks source link

Static Member Variables #1

Open jdeans289 opened 1 year ago

jdeans289 commented 1 year ago

Currently, the Memory Manager and checkpoint algorithms do not correctly handle static member variables of classes.

There is an assumption that all of the memory for an object is in a contiguous region that can be tracked by a single AllocInfo object, and therefore that every "name" under a root alloc info object is within the region specified by alloc.start to alloc.end. This is not true for static member variables, since they do not belong to any particular object.

Problems that need to be solved:

  1. Tracking and searching - static variable addresses are tracked via the DataTypes in StaticMemberVariable, but they are not registered as an AllocInfo. Therefore, trying to search for an address that contains a static class member would require searching everything and hoping to come across the class that contains a member at that address (rather than being able to immediately find the alloc with the address ranges in AllocInfo). I think the solution to this is to give static class members their own AllocInfo.
  2. Naming - These need a naming convention in checkpoints and such that is different from normal variables.
jdeans289 commented 12 months ago

Some more thoughts on this -

Registering statics is something that the MemoryManager should be responsible for. I think traversing the types and looking for static fields should be implemented as a Visitor. The memory manager should use this visitor to get a list of static members referenced by an allocation, and then check to see if any of them are not registered yet. This might be slow, so maybe the visitor itself should take a reference to the memory manager and do this checking and registration along the way, so that we can prune the traversal.

I want the memory manager and allocinfo classes to track datatypes, but have NO special case code for different types. All of that should be handled elsewhere, like in Visitor classes.