codefrau / SqueakJS

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

Fix bitShift for non-positive results #158

Closed LinqLover closed 3 months ago

LinqLover commented 3 months ago

Note that the new implementation still fails for negative receivers just like all other bit manipulation primitives (OSVM does support this). I'm not sure why this has been designed this way, but even though the primitive is marked as essential, the fallback code seems to handle negative receivers correctly.

However, the following example failed and simulated an infinite recursion without this fix:

Context runSimulated: [-256 - -2130444284].

I was not able to find a simpler way to reproduce this.

codefrau commented 3 months ago

I committed a simpler fix. Thanks though!

codefrau commented 3 months ago

Oh this broke stuff. Committing a real fix ...

BTW the reason I did not want to use null to indicate failure was so that the code stays monomorphic from the POV of the JS JIT.