Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

Rebase this proposal on top of Module Linking #122

Merged
merged 8 commits into from
Nov 10, 2020
Merged

Conversation

lukewagner
Copy link
Member

In the current explainer, the mechanism by which (@interface func)s and (@interface implement)s link with the core module's imports and exports is rather magical and limited. This linking can be explained and generalized in terms of the concepts introduced by Module Linking. Doing so also makes it much clearer what exactly is imported and exported in the final adapted module: it's the same story for when one module nests another.

This "rebase" also pulls in a ton of discussion and iteration with @fgmccabe and @eqrion about the proposal in general. In particular:

  • adapter functions are now a full superset of core functions, allowing arbitrary core wasm control flow and computation, while still preserving the original optimization goals by making interface types affine
  • the proposal now gives a full account of strings, lists, records and variants which, combined with the previous generalization, enables a much wider range of representations to be lifted and lowered efficiently w/o serialization
  • as a test and demonstration of the new generality of lists, the string type is now just an abbreviation for (list char) (with char being added as a new scalar interface type)

Lastly, use cases and additional requirements are updated to reflect our updated understanding. Happy to get feedback on this new draft!

@lukewagner lukewagner force-pushed the linking-rebase branch 2 times, most recently from 767e57b to 43fc088 Compare October 5, 2020 23:53
@mijamo
Copy link

mijamo commented Oct 10, 2020

I just want to say that I read the full overview in this pull request and I love it. Until now interface types were not super clear to me, I understood the basic idea but not the instructions nor the architecture, in particular with non-string types.

The current explanation is well explained and seems to cover most of the needs I had identified for such a feature. Examples are clear and relevant, so congratulations for such a wonderful job!

For me the part that really made it click was the list lifting explanation and example, this is where I suddenly understood the whole laziness and uniqueness problem, because it relates to traditionnal iterator problems. I think that actually the possibility to use list for iterators is very interesting and could be mentionned more prominently rather than being just a side note.

All in all it just sounds great and I can't wait playing with it!

@taralx
Copy link

taralx commented Oct 10, 2020

Rendered version for the lazy like me.

@taralx
Copy link

taralx commented Oct 11, 2020

  (adapter_func (export "run")
    call $core.$run
  )

Can this be an exported alias instead?

@lukewagner
Copy link
Member Author

@mijamo Thanks! I added two sentences to call out the iterator use cases a bit more prominently.

@taralx That's right. I added a note to make this a bit more clear.

@zakbaig
Copy link

zakbaig commented Oct 20, 2020

@lukewagner Are we close to a phase 2 stage with this PR?!

@lukewagner
Copy link
Member Author

@zakbaig We're closer, but still several TODOs left, I believe.

@lukewagner lukewagner requested a review from fgmccabe October 26, 2020 23:09
@lukewagner
Copy link
Member Author

lukewagner commented Nov 3, 2020

In the last commit, I merged and rewrote the last two use cases into a single one that I think more clearly states the high-level use case of "maximizing reuse" and how the proposals helps achieve that. Credit to @fgmccabe for the suggestions on how this could be improved.

Copy link
Contributor

@fgmccabe fgmccabe left a comment

Choose a reason for hiding this comment

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

Not finished.
Pretty sure we need destructors on lowering. E.g., exporting a function that takes a list as an argument: need to release the local space allocated for the list argument.

)
)
```
Imports can also be adapted, although doing so requires a bit more plumbing due
to the acyclic nature of instantiation:
Copy link
Contributor

Choose a reason for hiding this comment

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

I had to read this a couple of times before I fully grokked it.

Copy link
Member Author

@lukewagner lukewagner Nov 4, 2020

Choose a reason for hiding this comment

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

Anything you'd add to clarify? (Note also the paragraph right under the code snippet that also adds some explanation.)

(alias (memory $libc $memory)) ;; make $libc.$memory the default memory

(adapter_func $growingLowerByte (param u8 i32 i32 i32) (result i32 i32 i32)
(let (param u8) (result i32 i32 i32)
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we were not going to use let

Copy link
Member Author

Choose a reason for hiding this comment

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

The only problem is locals (let- or function-level); the param used here is fine b/c it's a nameless operand on the stack.

)
(adapter_func $lowerArray (param (list s32)) (result i32 i32)
list.has_count
if (param (list s32) i32)
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs explaining.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, yeah. I added a paragraph under this code explaining the high points, lmkwyt.

Copy link
Contributor

@fgmccabe fgmccabe left a comment

Choose a reason for hiding this comment

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

LGTM

@lukewagner
Copy link
Member Author

Thanks for the review!

@lukewagner lukewagner merged commit 936ebf1 into master Nov 10, 2020
@lukewagner lukewagner deleted the linking-rebase branch November 10, 2020 22:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants