Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,22 @@ runs:
brew update
brew install autoconf autoconf-archive automake bash ccache coreutils libtool llvm@20 nasm ninja pkg-config qt unzip

- name: 'Install wabt'
- name: 'Install wasm-tools'
shell: bash
run: |
VERSION=1.243.0
if ${{ inputs.os == 'Linux' }} ; then
curl -f -L -o wabt-1.0.35.tar.gz https://github.com/WebAssembly/wabt/releases/download/1.0.35/wabt-1.0.35-ubuntu-20.04.tar.gz
NAME="wasm-tools-$VERSION-x86_64-linux"
else
curl -f -L -o wabt-1.0.35.tar.gz https://github.com/WebAssembly/wabt/releases/download/1.0.35/wabt-1.0.35-macos-14.tar.gz
NAME="wasm-tools-$VERSION-aarch64-macos"
fi

tar -xzf ./wabt-1.0.35.tar.gz
rm ./wabt-1.0.35.tar.gz
curl -f -L -o "${NAME}.tar.gz" "https://github.com/bytecodealliance/wasm-tools/releases/download/v${VERSION}/${NAME}.tar.gz"

echo "${{ github.workspace }}/wabt-1.0.35/bin" >> $GITHUB_PATH
tar -xzf "./${NAME}.tar.gz"
rm "./${NAME}.tar.gz"

echo "${{ github.workspace }}/${NAME}" >> $GITHUB_PATH

- name: 'Set required environment variables'
if: ${{ inputs.os == 'Linux' && inputs.arch == 'arm64' }}
Expand Down
2 changes: 1 addition & 1 deletion Documentation/AdvancedBuildInstructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ There are some optional features that can be enabled during compilation that are
- `ENABLE_ALL_THE_DEBUG_MACROS`: used for checking whether debug code compiles on CI. This should not be set normally, as it clutters the console output and makes the system run very slowly. Instead, enable only the needed debug macros, as described below.
- `ENABLE_COMPILETIME_FORMAT_CHECK`: checks for the validity of `std::format`-style format string during compilation. Enabled by default.
- `LAGOM_TOOLS_ONLY`: Skips building libraries, utiltis and tests for [Lagom](../Meta/Lagom/ReadMe.md). Mostly only useful for cross-compilation.
- `INCLUDE_WASM_SPEC_TESTS`: downloads and includes the WebAssembly spec testsuite tests. In order to use this option, you will need to install `prettier` and `wabt`. wabt version 1.0.35 or higher is required to pre-process the WebAssembly spec testsuite.
- `INCLUDE_WASM_SPEC_TESTS`: downloads and includes the WebAssembly spec testsuite tests. In order to use this option, you will need to install `prettier` and `wasm-tools`.
- `INCLUDE_FLAC_SPEC_TESTS`: downloads and includes the xiph.org FLAC test suite.
- `LADYBIRD_CACHE_DIR`: sets the location of a shared cache of downloaded files. Should not need to be set manually unless managing a distribution package.
- `ENABLE_NETWORK_DOWNLOADS`: allows downloading files from the internet during the build. Default on, turning off enables offline builds. For offline builds, the structure of the LADYBIRD_CACHE_DIR must be set up the way that the build expects.
Expand Down
11 changes: 7 additions & 4 deletions Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Optional<FunctionAddress> Store::allocate(HostFunction&& function)

Optional<TableAddress> Store::allocate(TableType const& type)
{
if (type.limits().min() > Constants::max_allowed_table_size)
return {};

TableAddress address { m_tables.size() };
Vector<Reference> elements;
elements.ensure_capacity(type.limits().min());
Expand Down Expand Up @@ -460,14 +463,14 @@ Optional<InstantiationError> AbstractMachine::allocate_all_initial_phase(Module

for (auto& table : module.table_section().tables()) {
auto table_address = m_store.allocate(table.type());
VERIFY(table_address.has_value());
module_instance.tables().append(*table_address);
if (table_address.has_value())
module_instance.tables().append(*table_address);
}

for (auto& memory : module.memory_section().memories()) {
auto memory_address = m_store.allocate(memory.type());
VERIFY(memory_address.has_value());
module_instance.memories().append(*memory_address);
if (memory_address.has_value())
module_instance.memories().append(*memory_address);
}

size_t index = 0;
Expand Down
50 changes: 24 additions & 26 deletions Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3688,41 +3688,41 @@ ALIAS_INSTRUCTION(i32x4_relaxed_trunc_f64x2_u_zero, i32x4_trunc_sat_f64x2_u_zero

HANDLE_INSTRUCTION(f32x4_relaxed_madd)
{
auto a = configuration.take_source(0, addresses.sources).to<u128>();
auto b = configuration.take_source(1, addresses.sources).to<u128>();
auto& c_slot = configuration.source_value(2, addresses.sources);
auto c = c_slot.to<u128>();
c_slot = Value { Operators::VectorMultiplyAdd<4> {}(a, b, c) };
auto c = configuration.take_source(0, addresses.sources).template to<u128>();
auto a = configuration.take_source(1, addresses.sources).template to<u128>();
auto& b_slot = configuration.source_value(2, addresses.sources);
auto b = b_slot.template to<u128>();
b_slot = Value { Operators::VectorMultiplyAdd<4> {}(a, b, c) };
TAILCALL return continue_(HANDLER_PARAMS(DECOMPOSE_PARAMS_NAME_ONLY));
}

HANDLE_INSTRUCTION(f32x4_relaxed_nmadd)
{
auto a = configuration.take_source(0, addresses.sources).to<u128>();
auto b = configuration.take_source(1, addresses.sources).to<u128>();
auto& c_slot = configuration.source_value(2, addresses.sources);
auto c = c_slot.to<u128>();
c_slot = Value { Operators::VectorMultiplySub<4> {}(a, b, c) };
auto c = configuration.take_source(0, addresses.sources).template to<u128>();
auto a = configuration.take_source(1, addresses.sources).template to<u128>();
auto& b_slot = configuration.source_value(2, addresses.sources);
auto b = b_slot.template to<u128>();
b_slot = Value { Operators::VectorMultiplySub<4> {}(a, b, c) };
TAILCALL return continue_(HANDLER_PARAMS(DECOMPOSE_PARAMS_NAME_ONLY));
}

HANDLE_INSTRUCTION(f64x2_relaxed_madd)
{
auto a = configuration.take_source(0, addresses.sources).to<u128>();
auto b = configuration.take_source(1, addresses.sources).to<u128>();
auto& c_slot = configuration.source_value(2, addresses.sources);
auto c = c_slot.to<u128>();
c_slot = Value { Operators::VectorMultiplyAdd<2> {}(a, b, c) };
auto c = configuration.take_source(0, addresses.sources).template to<u128>();
auto a = configuration.take_source(1, addresses.sources).template to<u128>();
auto& b_slot = configuration.source_value(2, addresses.sources);
auto b = b_slot.template to<u128>();
b_slot = Value { Operators::VectorMultiplyAdd<2> {}(a, b, c) };
TAILCALL return continue_(HANDLER_PARAMS(DECOMPOSE_PARAMS_NAME_ONLY));
}

HANDLE_INSTRUCTION(f64x2_relaxed_nmadd)
{
auto a = configuration.take_source(0, addresses.sources).to<u128>();
auto b = configuration.take_source(1, addresses.sources).to<u128>();
auto& c_slot = configuration.source_value(2, addresses.sources);
auto c = c_slot.to<u128>();
c_slot = Value { Operators::VectorMultiplySub<2> {}(a, b, c) };
auto c = configuration.take_source(0, addresses.sources).template to<u128>();
auto a = configuration.take_source(1, addresses.sources).template to<u128>();
auto& b_slot = configuration.source_value(2, addresses.sources);
auto b = b_slot.template to<u128>();
b_slot = Value { Operators::VectorMultiplySub<2> {}(a, b, c) };
TAILCALL return continue_(HANDLER_PARAMS(DECOMPOSE_PARAMS_NAME_ONLY));
}

Expand All @@ -3745,12 +3745,10 @@ HANDLE_INSTRUCTION(i16x8_relaxed_dot_i8x16_i7x16_s)

HANDLE_INSTRUCTION(i32x4_relaxed_dot_i8x16_i7x16_add_s)
{
// do i16x8 dot first, then fold back down to i32, then do the final component add.
auto rhs = configuration.take_source(0, addresses.sources).to<u128>();
auto lhs = configuration.take_source(1, addresses.sources).to<u128>(); // bounds checked by verifier.
auto result = Operators::VectorDotProduct<4, Operators::VectorIntegerExtOpPairwise<4, Operators::Add>> {}(lhs, rhs);
auto& c_slot = configuration.source_value(2, addresses.sources);
c_slot = Value { Operators::VectorIntegerBinaryOp<4, Operators::Add, MakeSigned> {}(result, c_slot.to<u128>()) };
auto acc = configuration.take_source(0, addresses.sources).template to<u128>();
auto rhs = configuration.take_source(1, addresses.sources).template to<u128>(); // bounds checked by verifier.
auto& lhs_slot = configuration.source_value(2, addresses.sources);
lhs_slot = Value { Operators::VectorRelaxedDotI8I7AddS {}(lhs_slot.template to<u128>(), rhs, acc) };
TAILCALL return continue_(HANDLER_PARAMS(DECOMPOSE_PARAMS_NAME_ONLY));
}

Expand Down
28 changes: 28 additions & 0 deletions Libraries/LibWasm/AbstractMachine/Operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,34 @@ struct VectorDotProduct {
static StringView name() { return "dot"sv; }
};

struct VectorRelaxedDotI8I7AddS {
auto operator()(u128 lhs, u128 rhs, u128 acc) const
{
using VectorInput = Native128ByteVectorOf<i8, MakeSigned>;
using VectorResult = Native128ByteVectorOf<i32, MakeSigned>;
using VectorAcc = Native128ByteVectorOf<i32, MakeSigned>;

auto v1 = bit_cast<VectorInput>(lhs);
auto v2 = bit_cast<VectorInput>(rhs);
auto accumulator = bit_cast<VectorAcc>(acc);
VectorResult result {};

// Each i32 lane is the sum of 4 i8*i8 products, plus accumulator
for (size_t lane = 0; lane < 4; ++lane) {
i32 sum = 0;
for (size_t i = 0; i < 4; ++i) {
auto const idx = lane * 4 + i;
sum += static_cast<i32>(v1[idx]) * static_cast<i32>(v2[idx]);
}
result[lane] = sum + accumulator[lane];
}

return bit_cast<u128>(result);
}

static StringView name() { return "i32x4.relaxed_dot_i8x16_i7x16_add_s"sv; }
};

template<size_t VectorSize, typename Element>
struct VectorNarrow {
auto operator()(u128 lhs, u128 rhs) const
Expand Down
Loading
Loading