codefrau / SqueakJS

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

SqueakJS V2 (WIP) #168

Open codefrau opened 2 weeks ago

codefrau commented 2 weeks ago

Goals of V2: see README

This PR mainly exists as a place for discussion.

LinqLover commented 2 weeks ago

Interesting, thanks for sharing! Am I qualified to ask one or two questions? :-)

  1. About:

    Still need to decide between named inst vars (using inst var names from image) or suffixed (like p0, p1, ...)

    Just curious, are instance variable names a concept that the VM should be aware of at all? Or could I in theory create a new subclass manual in my image, do not assign names to the variables but only address them via indexes, and complain if SqueakJS cannot handle this class? Also, could there be valid Smalltalk variable names that are not allowed in JavaScript (I know the ClassBuilder is pretty restrictive but maybe it would not have to be)?

  2. What order of magnitude of speed-ups do you think each of these design changes will yield? Is there any bottleneck analysis publicly available?

Sorry if this is out of topic ...

codefrau commented 2 weeks ago

are instance variable names a concept that the VM should be aware of at all? Or could I in theory create a new subclass manual in my image, do not assign names to the variables but only address them via indexes, and complain if SqueakJS cannot handle this class?

If no suitable inst var name string can be found, we can easily generate a name like p0, p1 etc. Same when sanitizing names.

  1. What order of magnitude of speed-ups do you think each of these design changes will yield? Is there any bottleneck analysis publicly available?

See here, in particular this section. I haven't done a complete analysis though. This is still a hobby for me ;)

I believe we can overall get a 10x improvement in send speed. That would get us to within a magnitude of Cog.

bpieber commented 2 weeks ago

I love the fact that SqueakJS runs a recent Cuis image. It pauses often when using it, though. I wonder if porting the VectorEnginePlugin would help and be feasible? Juan also mentioned the possibility to implement the VectorCanvas using Web APIs. Maybe that would be easier?

codefrau commented 2 weeks ago

@bpieber This is independent of v2. I just opened #169 for it, please continue this discussion there.

LinqLover commented 2 weeks ago

@codefrau Very interesting read, thank you! :-)

codefrau commented 2 weeks ago

I implemented actual var names, see b6a32befdc537ef28431378b9c1971480be3c086

The VM still works thanks to the .pointers now being a proxy to those explicit inst vars.

I tried it with various images (old, new, 32-bit, 64-bit) but it may be helpful if you could try others too. Everything should work as before, just slower.