Giter VIP home page Giter VIP logo

Comments (7)

kripken avatar kripken commented on August 18, 2024

Is it possible for JS objects to cross the FFI boundary?

No, in asm.js code there are just ints and doubles basically. No JS objects at all. That's how it is possible to avoid all possible causes of bailouts. So likely for a compiler that generates JS objects like yours, asm.js isn't directly relevant, except perhaps for library code.

(This doesn't mean C# can't use asm.js though, an AOT might generate C or LLVM IR and be compiled to asm.js.)

from validator.

kg avatar kg commented on August 18, 2024

I was assuming it could operate at the function level where as long as a function only interacts with ints and floats and things that live in typed arrays, it can "use asm". It sounds like the entire application has to "use asm", then?

EDIT: I don't understand how JS objects crossing the FFI causes bailouts. I can understand how interacting with JS objects would cause bailouts. Why can't they have the semantics of void *? Is it because the GC rooting can cause bailouts?

from validator.

kripken avatar kripken commented on August 18, 2024

You can do "use asm" in a function scope, but lots of little asms won't be a good idea probably, the ffi path is not fast.

JS objects crossing ffi don't cause bailouts. JS objects in general cause bailouts. If you don't know at every point that no variable is a JS object, then you need to check a lot more stuff and possibly deoptimize. asm code avoids that.

from validator.

kripken avatar kripken commented on August 18, 2024

Btw, all of this is still a work in progress, don't take anything i said as a final answer. But what I said is true of the prototype implementation so far.

from validator.

curiousdannii avatar curiousdannii commented on August 18, 2024

In the example you have this. It would be good to explain why the sign must be forced etc.

        log(x|0);     // call into FFI -- must force the sign
        log(y);       // call into FFI -- already know it's a double

from validator.

kripken avatar kripken commented on August 18, 2024

The assumption in asm.js variables is that they are 32-bit values, neither signed nor unsigned. This makes it very easy to optimize them. But it also means that when the sign matters - like when calling an ffi - you must specify the sign.

Put another way, inside asm.js, variables have no sign, operations determine the sign (again, to make it easy to optimize). When going outside of asm.js, you need to specify the sign because a concrete value is being sent into JS, not just 32 bits of uncertain interpretation.

from validator.

 avatar commented on August 18, 2024

I think FFIs are fully specified now (it is well-defined exactly what you can pass to them and get from them).

from validator.

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.