Stream: git-wasmtime

Topic: wasmtime / Issue #2303 wasm->CLIF translation: consistent...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 20 2020 at 16:37):

yurydelendik commented on Issue #2303:

I wonder if we can wrap SmallVec canonicalised initialization logic into function and do it only when needed. Also, I think it is possible to avoid canonicalise_then_XXXX functions.

fn canonicalise<'a>(
    builder: &mut FunctionBuilder,
    values: &[ir::Value],a: &'a [u8]
) -> impl AsRef<[ir::Value]> + 'a {
    enum Result<'a> {
        Ref(&'a [ir::Value]),
        Vec(SmallVec<[ir::Value; 16]>),
    }
    impl<'a> AsRef<[u8]> for Result<'a> {
        fn as_ref(&self) -> &[u8] {
            match self {
                Result::Ref(r) => r,
                Result::Vec(v) => v.as_slice(),
            }
        }
    }

    // do_checks_and_stuff

    if ... {
        Result::Vec(canonicalised)
    } else {
        Result::Ref(values)
    }
}

// do e.g.
builder
  .ins()
  .jump(
    real_dest_block,
    canonicalise(builder, destination_args).as_ref()
  );

It is nice to see fast path for canonicalise when SIMD is not in use too.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 20 2020 at 16:38):

yurydelendik edited a comment on Issue #2303:

I wonder if we can wrap SmallVec canonicalised initialization logic into function and do it only when needed. Also, I think it is possible to avoid canonicalise_then_XXXX functions.

fn canonicalise<'a>(
    builder: &mut FunctionBuilder,
    values: &'a [ir::Value],
) -> impl AsRef<[ir::Value]> + 'a {
    enum Result<'a> {
        Ref(&'a [ir::Value]),
        Vec(SmallVec<[ir::Value; 16]>),
    }
    impl<'a> AsRef<[u8]> for Result<'a> {
        fn as_ref(&self) -> &[u8] {
            match self {
                Result::Ref(r) => r,
                Result::Vec(v) => v.as_slice(),
            }
        }
    }

    // do_checks_and_stuff

    if ... {
        Result::Vec(canonicalised)
    } else {
        Result::Ref(values)
    }
}

// do e.g.
builder
  .ins()
  .jump(
    real_dest_block,
    canonicalise(builder, destination_args).as_ref()
  );

It is nice to see fast path for canonicalise when SIMD is not in use too.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 20 2020 at 16:46):

yurydelendik edited a comment on Issue #2303:

I wonder if we can wrap SmallVec canonicalised initialization logic into function and do it only when needed. Also, I think it is possible to avoid canonicalise_then_XXXX functions.

fn canonicalise<'a>(
    builder: &mut FunctionBuilder,
    values: &'a [ir::Value],
) -> impl AsRef<[ir::Value]> + 'a {
    enum Result<'a> {
        Ref(&'a [ir::Value]),
        Vec(SmallVec<[ir::Value; 16]>),
    }
    impl<'a> AsRef<[u8]> for Result<'a> {
        fn as_ref(&self) -> &[u8] {
            match self {
                Result::Ref(r) => r,
                Result::Vec(v) => v.as_slice(),
            }
        }
    }

    // do_checks_and_stuff

    if ... {
        Result::Vec(canonicalised)
    } else {
        Result::Ref(values)
    }
}

// do e.g.
let params = canonicalise(builder, destination_args);
builder
  .ins()
  .jump(real_dest_block, params.as_ref());

It is nice to see fast path for canonicalise when SIMD is not in use too.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 21 2020 at 09:36):

julian-seward1 commented on Issue #2303:

Thanks all for the various comments/suggestions. I pushed a revised patch that addresses all of them.


Last updated: Dec 23 2024 at 12:05 UTC