avm2: Add some comments for clarification

This commit is contained in:
Lord-McSweeney 2024-05-18 16:35:22 -07:00 committed by Lord-McSweeney
parent c93873a7a2
commit 78e9426ba9
3 changed files with 12 additions and 0 deletions

View File

@ -785,6 +785,8 @@ pub fn optimize<'gc>(
stack.push_any(); stack.push_any();
} }
} else { } else {
// If `get_entry_for_multiname` returned `Some(None)`, there was
// a `with` scope in the outer ScopeChain- abort optimization.
stack_push_done = true; stack_push_done = true;
stack.push_any(); stack.push_any();
} }

View File

@ -253,6 +253,8 @@ impl<'gc> ScopeChain<'gc> {
} }
} }
// Nothing was found, and we can be sure that nothing will be
// found here at all (there were no `with` scopes).
None None
} }

View File

@ -331,6 +331,14 @@ pub fn verify_method<'gc>(
)?)); )?));
} }
// Split this `GetLex` into a `FindPropStrict` and a `GetProperty`.
// A `GetLex` is guaranteed to take up at least 2 bytes. We need
// one byte for the opcode and at least one byte for the multiname
// index. Overwrite the op registered at the opcode byte with a
// `FindPropStrict` op, and register a non-jumpable `GetProperty`
// op at the next byte. This isn't the best way to do it, but it's
// simpler than actually emitting ops and rewriting the jump offsets
// to match.
assert!(bytes_read > 1); assert!(bytes_read > 1);
byte_info[previous_position as usize] = byte_info[previous_position as usize] =
ByteInfo::OpStart(AbcOp::FindPropStrict { index }); ByteInfo::OpStart(AbcOp::FindPropStrict { index });