dibyendumajumdar / dmr_c

dmr_C is a C parser and JIT compiler with LLVM, Eclipse OMR and NanoJIT backends
Other
52 stars 2 forks source link

Work out how to avoid global allocator for ptr_list nodes #1

Closed dibyendumajumdar closed 7 years ago

dibyendumajumdar commented 7 years ago

The Sparse library uses a pointer linked list implementation called ptr_list. The list is maintained as a circular list and there is no defined head or tail - any node can be treated as the head. The library relies upon this feature. The list is represented simply by a pointer to one of the nodes. The problem is that there is no way to associate an allocator with a list, so the ptr_list nodes are managed via a global allocator. Unfortunately the lists created by the parser are not "destroyed" individually - the entire allocator can be destroyed but because this is global, then the issue is that there must not be any active dmr_C instances.

dibyendumajumdar commented 7 years ago

If we add a pointer to the allocator in each node then we can use this to avoid the global allocator. This will mean every list node will have an extra pointer but it seems to me that the trade off is good - i.e. - we avoid global state.

dibyendumajumdar commented 7 years ago

Fixed