dbanay/Smalltalk

Question about snapshot code hitting asserts :-)

acf opened this issue · 2 comments

acf commented

Hi Dan,

This is most assuredly not an issue with this codebase but seemed like a decent way to get in touch. I've been working with a friend on trying to implement a blue book Smalltalk in C for the Amiga computer. I confess I have joined the project late and have been cargo-culting a bit over there and occasionally looking to your excellent project for a clue when I get confused. I recently started working on a way to load and save an image (we have a mostly functional ObjectMemory but no interpreter really yet). I've pretty much been trying to work from your code and I think I have it basically working - loading and saving the ST80 image you linked to.

One question I have though... I hit the assert ( https://github.com/dbanay/Smalltalk/blob/master/src/objmemory.cpp#L119 ) that's designed to stop a zero-counted object being loaded, and I hit it a few times. If I disable that assert and just load the image anyway, it all seems to work fine (as I say, no interpreter, so all I can really say is we end up with a basically intact ObjectMemory).

Screenshot 2020-12-23 at 21 44 28

So I guess my question is if you load that tape image with your code, I'm puzzled why the assert doesn't fire and I wonder if I've done something wrong somewhere. 🤔

Thanks for your time,

Alan

Hi Alan,
Super excited to hear you are making a Smalltalk for the Amiga!

So, that assert is NOT firing for me. I don't know much about programming on the Amiga or the C compiler used, but hope I can help.

The image I am loading from is the one named "snapshot.img" in the "files" folder. The original Xerox image was in big endian format, so I wrote a small tool to byteswap the image as necessary for work on my little endian intel system. Your system is most likely BIG endian, so you will need to use the original Xerox snapshot and sources files located in the "org" folder (the image VirtualImageLSB, which you can rename to snapshot.im). The good news is all the loading code on ObjectMemory.cpp "should" still work fine when run on a big endian machine. NB, I am assuming an int is 32 bits. I am not sure what your compiler treats it as.

Some unsolicited advice:

  1. You will want to head over to http://www.wolczko.com/st80/ and grab the original Xerox distribution and the porting guide. The trace files will be invaluable when debugging your VM and verifying you are loading objects correctly.

  2. When you get the interpreter up and running, you might find some of the debugging tools I used in Interpreter::sendSelector_argumentCount to be helpful.

  3. I don't know how good your C compiler is, but clang is really good at optimizing and inlining things, so I could get away with not having to write macros to inline stuff like we had to back in the day. You will probably need to do so, but I am sure you know that already. :-)

Good luck, and feel free to send any future questions to dbanay@gmail.com!

acf commented

Hi Dan,

Just wanted to follow up and say thanks for all this. I finally got it working last week based largely on your code and spotted some errors in ours. To start with we had the ObjectTable in segment 0 and also tried to load objects into segment 0, so that's where the asserts were hitting, loading OOP n+2 was corrupting there OT entry for OOP n. I also had extracted a method or two as I was trying to understand how the code worked and so I ended up doing things like checking the size bits on a free OOP instead of only doing that for non-free OOPs when writing out the objects. Anyhoo, all good, and thanks again for blazing the trail in a way that's very useful to those following :-)