Re:A JVM in Rust part 5 – Executing instructions
by skitter on Monday August 28, 2023 @05:53PM
(#37300878)
VM creation is using unsafe (the line I pointed out above). You're right, I can't find any deallocation either – but weirdly it /does/ segfault (or sometimes have other memory related errors) if I drop the VM while it's heap is still referenced.
The thing with a tighter bound on the lifetime is that VM carrying a lifetime for itself is fundamentally flawed. A solution would be to remove said lifetime, and have all methods on VM that return lifetimed objects take said lifetime from the reference to the VM.
Re:A JVM in Rust part 5 – Executing instructions
by andreabergia on Tuesday August 29, 2023 @02:06AM
(#37304017)
That sounds reasonable (and way better than what I have implemented).
I am not sure I am going to try it though - it probably is a bit too much code to change for something that I consider "done" and I am not working on. :)
As for where the static lifetime gets into play, VM creation doesn't use unsafe & compiler is happy about it, even though ISTM that there could be a tighter bound on the lifetime? https://github.com/andreabergia/rjvm/blob/93e7e48db085e780b0...