[emval] Transfer ownership of handles to JS when moveable.#21436
Draft
mrolig5267319 wants to merge 1 commit intoemscripten-core:mainfrom
Draft
[emval] Transfer ownership of handles to JS when moveable.#21436mrolig5267319 wants to merge 1 commit intoemscripten-core:mainfrom
mrolig5267319 wants to merge 1 commit intoemscripten-core:mainfrom
Conversation
Collaborator
|
I think @brendandahl fixed some issue related to inconsistent ownership in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 like
val::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