Skip to content

Conversation

@kjarosh
Copy link
Member

@kjarosh kjarosh commented Oct 14, 2025

This is a performance optimization, as it gets rid of range checks when operating on values. Since we already implement value normalization, we don't have to make sure the value is the proper type at all times, only when differentiating between Number and Integer. This allows us to drop range checks and allow any Integer and any Number even if they are not representable in Flash Player.

This should improve performance in most cases, where we don't need a range check. This introduces overflow checks in op_add and op_subtract, but they should be faster than range checks which happened after each op anyway.

  • TODO benchmarks

@kjarosh kjarosh added A-avm2 Area: AVM2 (ActionScript 3) T-perf Type: Performance Improvements labels Oct 14, 2025
@kjarosh kjarosh force-pushed the value-any-i32 branch 2 times, most recently from 5838932 to 81fd313 Compare October 15, 2025 08:36
@kjarosh
Copy link
Member Author

kjarosh commented Oct 15, 2025

Using https://github.com/joelgwebber/bench2d/tree/master/as3:

Benchmark Before After
Bench2dNape (ms/frame) 60.61328125 57.19921875
60.828125 57.35546875
62.2890625 57.81640625
62.30078125 57.609375
61.48046875 59.1484375
Bench2dNape (avg) 61.50234375 57.82578125 (-5.9%)
Bench2d (ms/frame) 147.84765625 148.12109375
145.1875 151.08203125
144.90234375 148.09375
146.26171875 147.44921875
145.08984375 147.76953125
Bench2d (avg) 145.8578125 148.503125 (+1.8%)

This is a performance optimization, as it gets rid of range checks
when operating on values. Since we already implement value
normalization, we don't have to make sure the value is the proper type
at all times, only when differentiating between Number and Integer.
This allows us to drop range checks and allow any Integer and any Number
even if they are not representable in Flash Player.

This should improve performance in most cases, where we don't need a
range check. This introduces overflow checks in op_add and op_subtract,
but they should be faster than range checks which happened after each op
anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-avm2 Area: AVM2 (ActionScript 3) T-perf Type: Performance Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants