codefrau / SqueakJS

A Squeak Smalltalk VM in Javascript
https://squeak.js.org
MIT License
365 stars 75 forks source link

Method hacking fails loading Pharo images #113

Closed luque closed 3 years ago

luque commented 3 years ago

Loading a Pharo 8 image with SqueakJS version 1.0 (as patched by Pavel Krivanek for loading on SqueakJS: https://github.com/pavel-krivanek/pavel-krivanek.github.io/tree/master/pharo8) results in the following error:

Uncaught TypeError: Cannot read property '1' of undefined at subclass.<anonymous> (vm.interpreter.js:163) at Array.forEach (<anonymous>) at subclass.hackImage (vm.interpreter.js:153) at subclass.initialize (vm.interpreter.js:33) at new subclass (globals.js:64) at startRunning (squeak.js:938) at mapSomeObjectsAsync (vm.image.js:344)

It seems like the hacking of image methods in the hackImage function does not work for Pharo.

The same Pharo8 image loads successfully with the SqueakJS version 0.9.7 interpreter.

I'd like to be able to debug the hackImage function, but I should know more about Smalltalk bytecodes and VM. Could you recommend some resources to study? Is the Blue Book's part 4 still relevant?

codefrau commented 3 years ago

hackImage makes some assumptions about the image that goes beyond what a VM normally does. I think the right thing would be simply to catch the error right there and just not do the hacks.

codefrau commented 3 years ago

Merged a4e2d121d2197