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

[emval] Transfer ownership of handles to JS when moveable. #21436

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mrolig5267319
Copy link
Contributor

This is a proof-of-concept that we can reduce the C++ -> JS function call overhead for val temporaries by signaling the decref as part of each of the internal emval functions defined in JS.

This takes advantage of how we currently only use even handles to encode the transfer as an odd handle and centrallying handling this in Emval.toValue.

Without this change a snippet likeval::global()["a"].as<int>() will end up with a pattern like:

handle10 = global
handle12 = "a"
handle14 = 12
decref(14)
decref(12)
decref(10)

With this change we end up reusing handles of the arguments in the results.
handle10 = global
decref(10)
handle10 = "a"
decref(10)
handle10 = 12
decref(10)

The downside is there will be a tedious amount of code expansion to have both lvalue and rvalue reference versions of each method.

@brendandahl @RReverser

@RReverser
Copy link
Collaborator

I think @brendandahl fixed some issue related to inconsistent ownership in val calls recently, need to be careful here to make sure we don't regress.

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