So I was thinking... since
Store
and we don't drop instances, for example, until the store is dropped at which point they're all dropped at once, and runtime
and jit
,what do folks think of making Instance
into Instance<'store>
and plumbing that through everywhere, so that when you ask for a module's memory for example, you get a VMMemoryDefinition<'store>
rather than a thing that contains an unsafe raw pointer. This would clean up a lot of the unsafe pointer dereferences we have internally, and we could also remove a bunch of internal refcounting, I think.
I would need to dig in a bit further to see how feasible this really is, but figured it was worth getting feedback about the idea first. +cc @Alex Crichton
Usually 'a
means some sort of stack lifetime, so would that work here? I think it makes sense that conceptually everything lives as part of the same Store
, but the actual lifetime I feel may be best dynamic rather than stack-based
I can't quite envision this, though, so I'm not entirely sure how it would work out
Making the raw pointers safer though would indeed be nice!
yeah, I think you're right in that we wouldn't want to force Store
to be on main
's frame and never move or be boxed up into a structure...
we could do a "dynamic borrow" type thing where you provide the &'a Store
when accessing some method to get back a &'a Instance
, but this is seeming less and less appealing. It might even require dynamic checks that this is the right store, at which point we might as well just keep our refcounting.
Last updated: Dec 23 2024 at 13:07 UTC