Skip to content

Conversation

@moulins
Copy link
Contributor

@moulins moulins commented Oct 26, 2025

Keep local registers and activation names as bare references in Activation, leaving the caller responsible for allocating them if necessary.

As many activations have static names and/or no local registers (and as such don't need to allocate), this improves performance (up to a 5% reduction in wall-time in AVM1 benchmarks).

Possible further improvements (which would require unsafe code, probably):

  • Use a preallocated stack for local registers (like in AVM2);
  • Also use references instead of Gcs for the scope linked-list; this would require some way of lazily allocating scopes when they get captured by DefineFunction closures.

@moulins moulins added A-avm1 Area: AVM1 (ActionScript 1 & 2) T-perf Type: Performance Improvements waiting-on-review Waiting on review from a Ruffle team member labels Oct 26, 2025
@moulins moulins force-pushed the avm1-activation-refs branch from 6f967e3 to d1c1d5f Compare October 27, 2025 20:06
…tion`

This avoid a `Rc::clone` call on rescopes (e.g. for `with` or `try/catch`)
and simplifies `Activation`'s drop glue.
`Some(&[])` could never happen, and allocating an empty `Box<[_]>` is free,
so we can treat `&[]` as "has no local registers".

Also remove a misleading comment concerning local register #0 (which *does*
exist, even though most AS2 compilers don't like to use it for some reason).
We can instead always store a `&'a str`.
@moulins moulins force-pushed the avm1-activation-refs branch from d1c1d5f to a958f43 Compare October 27, 2025 21:39
@moulins moulins merged commit 1aad9ba into ruffle-rs:master Oct 27, 2025
26 checks passed
@moulins moulins deleted the avm1-activation-refs branch October 27, 2025 22:20
@Lord-McSweeney Lord-McSweeney removed the waiting-on-review Waiting on review from a Ruffle team member label Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-avm1 Area: AVM1 (ActionScript 1 & 2) T-perf Type: Performance Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants