summaryrefslogtreecommitdiff
path: root/test/example
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-03-12 06:46:14 -0800
committerGitHub <noreply@github.com>2021-03-12 06:46:14 -0800
commitb98dce24827e006e9527ec50642ba77dfada662a (patch)
tree9f546c1e6b35e4d85c27c2cdb2fead9a5acefb09 /test/example
parent32be343d217781045572da274eb4d63f4ead86c5 (diff)
downloadbinaryen-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.cpp13
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();