Skip to content

closure (and trampoline): Reimplement to be a C++ class with custom heap allocator

Marco Trevisan requested to merge 3v1n0/gjs:closures-cleanup into master

To create closures we used to create an internal closure structure that for which we were handling construction and destruction manually.

C++ allows us to use some nicer features though, and we can take advantage of them once we leave the role of allocating and deallocating the memory to GClosure functions.

This can be nicely done overriding the new and delete operators that will give us the size to allocate exactly as the closure creator function expects to receive.

As per this we can reduce a bit the base size of the all the GjsMaybeRooted (and so object's) size other than of the trampoline closures themselves.


This branch has some prerequisites in common with !615 (merged) (to adapt testing) and !624 (merged) (the one merging first wins).

Merge request reports