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

support dynamic function calls in component model #4442

Merged
merged 10 commits into from
Jul 25, 2022

Commits on Jul 21, 2022

  1. support dynamic function calls in component model

    This addresses bytecodealliance#4310, introducing a new `component::values::Val` type for
    representing component values dynamically, as well as `component::types::Type`
    for representing the corresponding interface types. It also adds a `call` method
    to `component::func::Func`, which takes a slice of `Val`s as parameters and
    returns a `Result<Val>` representing the result.
    
    Note that I've moved `post_return` and `call_raw` from `TypedFunc` to `Func`
    since there was nothing specific to `TypedFunc` about them, and I wanted to
    reuse them.  The code in both is unchanged beyond the trivial tweaks to make
    them fit in their new home.
    
    Signed-off-by: Joel Dice <joel.dice@fermyon.com>
    dicej committed Jul 21, 2022
    Configuration menu
    Copy the full SHA
    68f7786 View commit details
    Browse the repository at this point in the history
  2. order variants and match cases more consistently

    Signed-off-by: Joel Dice <joel.dice@fermyon.com>
    dicej committed Jul 21, 2022
    Configuration menu
    Copy the full SHA
    eb18b7a View commit details
    Browse the repository at this point in the history
  3. implement lift for String, Box<str>, etc.

    This also removes the redundant `store` parameter from `Type::load`.
    
    Signed-off-by: Joel Dice <joel.dice@fermyon.com>
    dicej committed Jul 21, 2022
    Configuration menu
    Copy the full SHA
    3c8d25a View commit details
    Browse the repository at this point in the history
  4. implement code review feedback

    This fixes a few issues:
    
    - Bad offset calculation when lowering
    - Missing variant padding
    - Style issues regarding `types::Handle`
    - Missed opportunities to reuse `Lift` and `Lower` impls
    
    It also adds forwarding `Lift` impls for `Box<[T]>`, `Vec<T>`, etc.
    
    Signed-off-by: Joel Dice <joel.dice@fermyon.com>
    dicej committed Jul 21, 2022
    Configuration menu
    Copy the full SHA
    b2644c1 View commit details
    Browse the repository at this point in the history

Commits on Jul 22, 2022

  1. move new_* methods to specific types structs

    Per review feedback, I've moved `Type::new_record` to `Record::new_val` and
    added a `Type::unwrap_record` method; likewise for the other kinds of types.
    
    Signed-off-by: Joel Dice <joel.dice@fermyon.com>
    dicej committed Jul 22, 2022
    Configuration menu
    Copy the full SHA
    c0f36c4 View commit details
    Browse the repository at this point in the history
  2. make tuple, option, and expected type comparisons recursive

    These types should compare as equal across component boundaries as long as their
    type parameters are equal.
    
    Signed-off-by: Joel Dice <joel.dice@fermyon.com>
    dicej committed Jul 22, 2022
    Configuration menu
    Copy the full SHA
    6c7c10b View commit details
    Browse the repository at this point in the history
  3. improve error diagnostic in Type::check

    We now distinguish between more failure cases to provide an informative error
    message.
    
    Signed-off-by: Joel Dice <joel.dice@fermyon.com>
    dicej committed Jul 22, 2022
    Configuration menu
    Copy the full SHA
    66271ba View commit details
    Browse the repository at this point in the history
  4. address review feedback

    - Remove `WasmStr::to_str_from_memory` and `WasmList::get_from_memory`
    - add `try_new` methods to various `values` types
    - avoid using `ExactSizeIterator::len` where we can't trust it
    - fix over-constrained bounds on forwarded `ComponentType` impls
    
    Signed-off-by: Joel Dice <joel.dice@fermyon.com>
    dicej committed Jul 22, 2022
    Configuration menu
    Copy the full SHA
    b414cd2 View commit details
    Browse the repository at this point in the history

Commits on Jul 25, 2022

  1. rearrange code per review feedback

    - Move functions from `types` to `values` module so we can make certain struct fields private
    - Rename `try_new` to just `new`
    
    Signed-off-by: Joel Dice <joel.dice@fermyon.com>
    dicej committed Jul 25, 2022
    Configuration menu
    Copy the full SHA
    47ef3c1 View commit details
    Browse the repository at this point in the history
  2. remove special-case equality test for tuples, options, and expecteds

    Instead, I've added a FIXME comment and will open an issue to do recursive
    structural equality testing.
    
    Signed-off-by: Joel Dice <joel.dice@fermyon.com>
    dicej committed Jul 25, 2022
    Configuration menu
    Copy the full SHA
    7289687 View commit details
    Browse the repository at this point in the history