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

Fixed a problem with super and nested lambdas #1838

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

andreabergia
Copy link
Contributor

We discovered this problem in our fork, where we disable the "function peeling optimization", but we have managed to reproduce it with a unit test that mixes compiled and interpreted functions.

The problem is that nested lambda does not have the homeObject set correctly. In the interpreter we pick it up from the containing NativeCall (the activation), but in some situations, like without function peeling or when going from a compiled function to an interpreted one, it might not be set.

The fix we came up with is just to propagate the home object on the nested closure function, that gets wrapped in the ArrowFunction. It's not particularly elegant, but it seems to fix the problem, does not cause any regression, and it's pretty cheap at runtime.

We discovered this problem in our fork, where we disable the "function
peeling optimization", but we have managed to reproduce it with a unit
test that mixes compiled and interpreted functions.

The problem is that nested lambda does not have the `homeObject` set
correctly. In the interpreter we pick it up from the containing
`NativeCall` (the activation), but in some situations, like without
function peeling or when going from a compiled function to an
interpreted one, it might not be set.

The fix we came up with is just to propagate the home object on the
nested closure function, that gets wrapped in the `ArrowFunction`.
It's not particularly elegant, but it seems to fix the problem, does
not cause any regression, and it's pretty cheap at runtime.

Co-authored-by: Satish Srinivasan <satish.srinivasan@servicenow.com>
@andreabergia andreabergia marked this pull request as ready for review February 19, 2025 13:56
@gbrail
Copy link
Collaborator

gbrail commented Feb 20, 2025

Looks good to me and simple enough. Thanks!

@gbrail gbrail merged commit 94ff59e into mozilla:master Feb 20, 2025
3 checks passed
@andreabergia andreabergia deleted the fix-super-mix-interpret-compile branch February 20, 2025 10:07
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.

2 participants