Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component comments #1

Open
wants to merge 390 commits into
base: components-initial
Choose a base branch
from
Open

Component comments #1

wants to merge 390 commits into from

Conversation

rossberg
Copy link
Owner

No description provided.

lukewagner and others added 30 commits July 25, 2022 19:13
Add 'outer' case to <core:alias> to match Binary.md
Fix size_flags for the zero-flags case
Switch (back) to multi-return, remove unit, s/expected/result/
I noticed a couple spots in Explainer.md where canonical-ABI functions return multiple values. This fixes those spots to return a pointer to those values instead, properly following the canonical ABI.
Respect `MAX_FLAT_RESULTS` in Explainer.md
…import

Fix example which used one-level imports in a core module type
Add explicit result arity to start definitions
Fix inline aliases used in 'memory' examples
Tweak variant/result mangling to produce valid wit
lukewagner and others added 26 commits August 12, 2023 14:18
* Add support for implementation imports

* Rename <export> to <projection> to avoid clash

* Change , separator to space for consistency

* Add semver range note

* Fix semver range ordering text

* Add naked integrity hash import name

* Fill in missing OCI Registry reference
* Point users to docs instead of this spec

* Link to docs from explainer
* add use-path grammar

* re-use interface rule instead of use-path

* Rename interface production to use-path
This commit commit is an implementation of #142 where semicolons are now
required as delimiters between items in the WIT text format. All items
in the WIT format are now delimited with either curly braces (`{}`) or
semicolons except for the `package` statement where it subjectively felt
a bit weird to require a semicolon. I've updated the various examples in
`WIT.md` as an example of the new syntax.

My plan on implementing this would be along the lines of:

* Implement the semicolon syntax in `wit-parser`
* Add a parser mode which requires semicolons. This means that the same
  `wit-parser` crate can either or either not require semicolons.
* Update all tests in the `wasm-tools` repository to require semicolons.
* Publish `wit-parser` and `wasm-tools`, integrating the
  semicolon-supporting-mode into all existing tools.
* Wait for Wasmtime to get published with this support. At this point
  everything in the ecosystem should have a point where semicolons are
  optionally supported.
* Remove the parser mode which doesn't require semicolons, meaning
  semicolons are now required.
* Push this update through the tooling, fixing any issues that arise.

The hope is to create a period of time where both syntax forms are
accepted. This provides a transitionary means from one syntax to the
other while proposals are updated. This transitionary period is finite
in length, however.

Closes #142
* Clarify what's in Preview 2

Resolves #229

* Split out package and interface id cases in the grammar

* Require the 'refines' immediate to be 0
This is a follow-up to #249 and discussion in today's component model
meeting to require semicolons after the `package` statement to ensure
it's consistent with all other "single line things" in the WIT format.
* Add subsection describing Index Spaces

Resolves #261

* Distinguish the core index spaces in WebAssembly 1.0

* Remove angle brackets in production names for consistency
* Change encoding of WIT definitions into Component Model types

* Fix explanation of world encoding

* Export interfaces and worlds as instances/components, not types

* Update dangling use of 'instance type' to 'instance' missed by last commit
… string (#263)

* Move structured import/export name information into the string

Resolves #253

* Replace the junk byte with a fixed 0x00 byte
design/mvp/Explainer.md Show resolved Hide resolved
design/high-level/Choices.md Show resolved Hide resolved
design/mvp/Explainer.md Show resolved Hide resolved
design/mvp/Explainer.md Show resolved Hide resolved
design/mvp/Explainer.md Show resolved Hide resolved
cx = CallContext(opts, inst)
trap_if(not inst.may_enter)

assert(inst.may_leave)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really an assert? Can't it be triggered by invalid user code, e.g., a realloc doing something wrong?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's not possible for user code to trigger this based on this reasoning:

  • our base case is that may_leave starts as true
  • we set may_leave to false only when lowering values (params of a lift, results of a lower)
    • during lowering, arbitrary core wasm may indeed be invoked (through realloc) but:
      • we're in core wasm, so we can't directly call canon_lift
      • we can directly call canon_lower, but then we'll immediately hit the trap_if(not may_leave) before we can successfully get out of core wasm (so that we can attempt to call canon_lift)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds plausible. It's been a while, so I don't remember what scenario I had in mind, but the fact that core Wasm cannot directly call canon_lift is key.

cx = CallContext(opts, inst)
trap_if(not inst.may_leave)

assert(inst.may_enter)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above.

Copy link

@lukewagner lukewagner Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same sort of argument as I gave above applies here, but in reverse:

  • may_enter starts true
  • we set may_enter to false during an import call that leaves the component, during which time:
    • we can't be reentered by the other component, since doing so will necessarily need to go through canon_lift, which will immediately trap at the trap_if(not may_enter)
    • we can run core wasm in the caller's component, but only while lowering the import results, which is bracketed by clearing may_leave, which will cause us to trap if we attempt to call canon_lower from realloc.

Comment on lines +1571 to +1574
Because `may_enter` is not cleared on the exceptional exit path taken by
`trap()`, if there is a trap during Core WebAssembly execution of lifting or
lowering, the component is left permanently un-enterable, ensuring the
lockdown-after-trap [component invariant].
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That definitely suggests that the above check on may_enter is not an assertion but can fail due to ill-behaved user code.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, but let me know if you still see a case not covered by the above arguments.

design/mvp/CanonicalABI.md Show resolved Hide resolved
design/mvp/Binary.md Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet