diff options
author | Alon Zakai <azakai@google.com> | 2024-08-12 12:30:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-12 12:30:23 -0700 |
commit | a4f9128f94b540fa04b67610eb501cb32ea203b4 (patch) | |
tree | 8ae772674ca1e90b40e9cde9fe5ad6be5d945415 /scripts/test/shared.py | |
parent | e729e012c50eb118be09f6a8005f0c9090fff3a0 (diff) | |
download | binaryen-a4f9128f94b540fa04b67610eb501cb32ea203b4.tar.gz binaryen-a4f9128f94b540fa04b67610eb501cb32ea203b4.tar.bz2 binaryen-a4f9128f94b540fa04b67610eb501cb32ea203b4.zip |
GlobalTypeOptimization: Reorder fields in order to remove them (#6820)
Before, we only removed fields from the end of a struct. If we had, say
struct Foo {
int x;
int y;
int z;
};
// Add no fields but inherit the parent's.
struct Bar : Foo {};
If y is only used in Bar, but never Foo, then we still kept it around, because
if we removed it from Foo we'd end up with Foo = {x, z}, Bar = {x, y, z} which
is invalid - Bar no longer extends Foo. But we can do this if we first reorder
the two:
struct Foo {
int x;
int z;
int y; // now y is at the end
};
struct Bar : Foo {};
And the optimized form is
struct Foo {
int x;
int z;
};
struct Bar : Foo {
int y; // now y is added in Bar
};
This lets us remove all fields possible in all cases AFAIK.
This situation is not super-common, as most fields are actually used both
up and down the hierarchy (if they are used at all), but testing on some
large real-world codebases, I see 10 fields removed in Java, 45 in Kotlin,
and 31 in Dart testcases.
The NFC change to src/wasm-type-ordering.h was needed for this to
compile.
Diffstat (limited to 'scripts/test/shared.py')
0 files changed, 0 insertions, 0 deletions