Use tail call elimination where possible in == for tag unions

This commit is contained in:
Brian Carroll 2021-12-27 14:06:43 +00:00
parent 65a9464d98
commit 0d8a2c8a49
2 changed files with 220 additions and 38 deletions

View file

@ -956,7 +956,17 @@ impl<'a> WasmBackend<'a> {
NonRecursive(tags) => tags[tag_index],
Recursive(tags) => tags[tag_index],
NonNullableUnwrapped(layouts) => *layouts,
NullableWrapped { other_tags, .. } => other_tags[tag_index],
NullableWrapped {
other_tags,
nullable_id,
} => {
let index = if tag_index > *nullable_id as usize {
tag_index - 1
} else {
tag_index
};
other_tags[index]
}
NullableUnwrapped { other_fields, .. } => *other_fields,
};