Coder Social home page Coder Social logo

Comments (7)

codefrau avatar codefrau commented on June 12, 2024 2

So ca63f69 checks the stack after every primitive.
And 4e152a6 fixes an embarrassing number of primitives that left the stack imbalanced or at least did not check argCount.
Released as 1.0.1.

from squeakjs.

fniephaus avatar fniephaus commented on June 12, 2024 1

No sure what's going on, but the implementation of primitiveStringHash is generated and looks ok:

function primitiveStringHash() {
var rcvr;
var aByteArray;
var speciesHash;
var byteArraySize;
var hash;
var low;
var pos;
rcvr = interpreterProxy.stackValue(2);
aByteArray = interpreterProxy.stackBytes(1);
speciesHash = interpreterProxy.stackIntegerValue(0);
if (interpreterProxy.failed()) {
return null;
}
byteArraySize = aByteArray.length;
hash = speciesHash & 268435455;
for (pos = 1; pos <= byteArraySize; pos++) {
/* Begin hashMultiply */
hash += aByteArray[pos - 1];
low = hash & 16383;
hash = ((9741 * low) + ((((9741 * (hash >>> 14)) + (101 * low)) & 16383) * 16384)) & 268435455;
}
if (interpreterProxy.failed()) {
return null;
}
interpreterProxy.popthenPush(3, hash);
return null;
}

from squeakjs.

codefrau avatar codefrau commented on June 12, 2024 1

OMG this must have been wrong since 2014. I just tried it with

primitiveStringHash(argCount) { 
   ... 
   interpreterProxy.popthenPush(argCount + 1, hash);
}

and metacello.sar continues installing fine.

However, that means some other generated primitives are likely wrong too 🤔 I have not committed a fix yet.

Thank you for the test case!

from squeakjs.

codefrau avatar codefrau commented on June 12, 2024 1

@LinqLover please use the vm-dev list for this kind of question/discussion. Nobody’s gonna read through closed tickets ;)

from squeakjs.

codefrau avatar codefrau commented on June 12, 2024

That primitive looks buggy, because it is called with argCount = 1 so it should pop 2 (string+arg) but actually pops 3.

What does it do in other VMs? Are they using argCount? This was generated many years ago, but I don't think the primitive changed?

from squeakjs.

krono avatar krono commented on June 12, 2024

So ca63f69 checks the stack after every primitive.
And 4e152a6 fixes an embarrassing number of primitives that left the stack imbalanced or at least did not check argCount.
Released as 1.0.1.

This is always fun :D

from squeakjs.

LinqLover avatar LinqLover commented on June 12, 2024

Great, thanks for fixing! :D

So ca63f69 checks the stack after every primitive.

Out of curiosity, how large is the performance impact of such "assertions in production"? :-)

from squeakjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.