Coder Social home page Coder Social logo

Comments (5)

rossberg avatar rossberg commented on June 9, 2024

Good catch! The reference interpreter allows this [edit: with the fix @jakobkummerow points out below], since it just assumes the operand can be (the subtype of) any function type. But as you correctly point out, that is not actually supported by the typing rule, which requires the type to exist in the current module.

In the absence of a type annotation, there is no simple solution to this within the current type system, where type indices are not substituted by definitions. To avoid a crazy algorithm, we'd need to introduce an additional special-case rule for Bottom to achieve more relaxed typing – and similarly for other instructions with reference operands, if we remove their annotations. That would be half a step in the direction of @conrad-watt's relaxed dead code typing proposal, though handling this kind of case would actually require way more changes/additions than what is currently described in that proposal's overview.

So this definitely is an argument for having type annotations.

from function-references.

jakobkummerow avatar jakobkummerow commented on June 9, 2024

FWIW, V8 is fine with the call_ref + f64.add in this example, but complains at the end:
Compiling function #0 failed: expected 2 elements on the stack for fallthru, found 3 @+38
When I add a drop after the f64.add, the module validates in V8. Checking for too many stack values in unreachable code may well be a bug.

Binaryen's wasm-dis and wasm-opt accept the module without any changes; I'm not sure whether this implies that Binaryen ran proper validation on it.

So this definitely is an argument for having type annotations.

I don't think anything about unreachable code is an argument for adding bytes to non-unreachable code.

from function-references.

tlively avatar tlively commented on June 9, 2024

Binaryen's wasm-dis and wasm-opt accept the module without any changes; I'm not sure whether this implies that Binaryen ran proper validation on it.

Binaryen's validation algorithm is already similar to the one in the relaxed dead code typing proposal, so proper validation was definitely not run.

from function-references.

rossberg avatar rossberg commented on June 9, 2024

@jakobkummerow:

When I add a drop after the f64.add, the module validates in V8. Checking for too many stack values in unreachable code may well be a bug.

No, I think you and V8 are correct, as written, this particular example has to be rejected regardless.

from function-references.

rossberg avatar rossberg commented on June 9, 2024

Closing via #76.

from function-references.

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.