diff options
author | Alon Zakai <azakai@google.com> | 2021-03-12 06:46:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-12 06:46:14 -0800 |
commit | b98dce24827e006e9527ec50642ba77dfada662a (patch) | |
tree | 9f546c1e6b35e4d85c27c2cdb2fead9a5acefb09 /test/example | |
parent | 32be343d217781045572da274eb4d63f4ead86c5 (diff) | |
download | binaryen-b98dce24827e006e9527ec50642ba77dfada662a.tar.gz binaryen-b98dce24827e006e9527ec50642ba77dfada662a.tar.bz2 binaryen-b98dce24827e006e9527ec50642ba77dfada662a.zip |
[Wasm GC] Optimize struct stores like stores to memory, ignore unneeded bits (#3680)
When storing to an i8, we can ignore any higher bits, etc.
Adds a getByteSize utility to Field to make this convenient.
Diffstat (limited to 'test/example')
-rw-r--r-- | test/example/cpp-unit.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/example/cpp-unit.cpp b/test/example/cpp-unit.cpp index 9552473ce..49893d1d2 100644 --- a/test/example/cpp-unit.cpp +++ b/test/example/cpp-unit.cpp @@ -569,11 +569,24 @@ void test_literals() { } } +void test_field() { + // Simple types + assert_equal(Field(Type::i32, Immutable).getByteSize(), 4); + assert_equal(Field(Type::i64, Immutable).getByteSize(), 8); + + // Packed types + assert_equal(Field(Field::PackedType::i8, Immutable).getByteSize(), 1); + assert_equal(Field(Field::PackedType::i16, Immutable).getByteSize(), 2); + assert_equal(Field(Field::PackedType::not_packed, Immutable).getByteSize(), + 4); +} + int main() { test_bits(); test_cost(); test_effects(); test_literals(); + test_field(); if (failsCount > 0) { abort(); |