Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary extend instructions #1147

Merged
merged 2 commits into from
Aug 1, 2024
Merged

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Aug 1, 2024

The Wasm i64_extend_i32_u and i64_extend_i32_s instructions are unnecessary in Wasmi bytecode.

  • The i64_extend_i32_u instruction is essentially a no-op in an untyped bytecode.
  • The i64_extend_i32_s instruction can be replaced by the i64_extend32_s instruction since Wasmi bytecode is untyped and the only difference between these two instructions is their effect on the type system.

Technically the i32_wrap_i64 x instruction could be replaced by i64.and x 0xFFFF_FFFF but due to Wasmi's current bytecode encoding this replacement representation would require substantially more encoding space and was less efficient.

The Wasm i64_extend_i32_u and i64_extend_i32_s instructions are unnecessary in Wasmi bytecode since they can be replaced entirely by the sign-extension instructions. This is possible since Wasmi bytecode is untyped during execution and the only different between those instructions is their effect on the type system.
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Project coverage is 79.80%. Comparing base (0a6a083) to head (9f90837).

Files Patch % Lines
crates/wasmi/src/engine/translator/mod.rs 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1147      +/-   ##
==========================================
+ Coverage   79.78%   79.80%   +0.01%     
==========================================
  Files         296      296              
  Lines       25422    25424       +2     
==========================================
+ Hits        20284    20289       +5     
+ Misses       5138     5135       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Robbepop Robbepop merged commit 8d0f733 into main Aug 1, 2024
18 checks passed
@Robbepop Robbepop deleted the rf-remove-unnecessary-casts branch August 1, 2024 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant