Coder Social home page Coder Social logo

Comments (9)

rossberg avatar rossberg commented on May 29, 2024 2

To expand on what @titzer wrote, to support shared references in the most general fashion we will need to extend the shared attribute that the threads proposal introduced for memories to tables, globals, functions, and reference types themselves. The type system will then ensure that only shared things are transitively reachable through other shared things. We have this generalised type system written out in a submitted research paper. We will make it public once it's through the double-blind review process next month or so.

As far as JS interop is concerned, regular JS values would continue to have non-shared reference type, so cannot be passed between threads.

from reference-types.

rossberg avatar rossberg commented on May 29, 2024 1

@chicoxyzzy, good question. The typed object proposal might potentially be enriched with a similar attribute for defining types, which may allow respective objects to be shared. But there are a number of subtle problems to solve, e.g., what to do with prototypes or type identity.

from reference-types.

chicoxyzzy avatar chicoxyzzy commented on May 29, 2024

Reference types are basis for GC types and interaction with threads is one of requirements for GC types

from reference-types.

titzer avatar titzer commented on May 29, 2024

Agreed, we will eventually want to have references across threads. For the web embedding, however, it will not be possible initially, since tables and globals are not currently shared across web workers. The current thinking is to add a "shared" bit to both globals and tables which would indicate whether they would be duplicated or shared across threads, which would be supported in other embeddings of WASM.

from reference-types.

chicoxyzzy avatar chicoxyzzy commented on May 29, 2024

@rossberg will this remain true with presence of JS Typed Objects?

from reference-types.

titzer avatar titzer commented on May 29, 2024

Typed objects will have null prototypes in JS, but there @rossberg is right. There are a number of subtleties here that I suspect will cause more problems for JS, so it is reasonable to expect they will lag behind "pure" wasm objects for sharing. Which reminds me of a V8 implementation gotcha here...ergh

from reference-types.

rossberg avatar rossberg commented on May 29, 2024

Typed objects will have null prototypes in JS

@titzer, I'm afraid that's not what the TO proposal currently intends.

from reference-types.

lukewagner avatar lukewagner commented on May 29, 2024

Typed objects will have null prototypes in JS

@titzer, I'm afraid that's not what the TO proposal currently intends.

As currently proposed, type objects would have a null prototype when created from an internal type definition. (See also the examples that show this difference.) So I think the abovementioned shared-ness rules in the type system, combined with instantiation-time checks, could indeed prevent shared type objects pointing to (necessarily un-shared) JS objects via __proto__.

from reference-types.

rossberg avatar rossberg commented on May 29, 2024

I think this has been answered.

from reference-types.

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.