Viewing a single comment thread. View all comments

TheLogicMaster OP t1_j5dbkl9 wrote

Yep, Java constructors and finalizers have to be treated as normal methods completely separate from C++ constructors and destructors, which is reasonable, anyway, with how Java objects are normally constructed. Trying to merge the Java and C++ constructors would definitely present issues, and destructors would be worse. Virtual inheritance is definitely a pain, requiring a number of workarounds to get everything compiling, plus sketchy behavior like needing a shared pointer to the object that's been partially destructed while calling the finalizer, or calling the finalizer to begin with, since the virtual function table changes during destruction. Everything has been working quite reliably so far, though, not running into any issues with the thousands of generated classes that I've tested.

Yeah, it's primarily the issue of debugging it. I've considered what would be required to implement one here, and it wouldn't be too bad to implement a similar one, but I've just spent so long debugging GC bugs in the C version, I opted for peace of mind and the performance hit, knowing that it may have been a decision I would regret later. It basically resolved all of the memory bugs, though, and the performance is still sufficient for now, so I'm quite happy with it. It's also nice not having to worry accidental collection in native code, though that could be mitigated with convenient C++ features.

1

shai_almog t1_j5dc8n4 wrote

Interesting. Good luck with the project and keep us posted. I'm surprised you didn't post about it to /r/cn1 which admittedly isn't a huge sub. But its nice to see new projects.

I'm also considering writing a new AoT VM. More for the backend than mobile. I have some ideas that I need to explore in that direction but I'm pretty busy with other tasks at the moment.

1

TheLogicMaster OP t1_j5ddrfk wrote

Thanks. Yeah, this is really my first time posting about the project since it's in a working state, and I wasn't aware of that sub, I mostly perused the source code.

That's always fun. I've considered doing something with LLVM, but I opted instead to make something that's a bit more unique in some of the design choices, prioritizing that over pure performance.

1