-
-
Notifications
You must be signed in to change notification settings - Fork 631
[1.0 blocking] Implement Copy for JsValue (or alternative) #5371
Copy link
Copy link
Open
Labels
A-EnhancementNew feature or requestNew feature or requestA-PerformancePerformance related changes and issuesPerformance related changes and issuesC-GCIssue related to garbage collectionIssue related to garbage collectionC-RuntimeIssues and PRs related to Boa's runtime featuresIssues and PRs related to Boa's runtime features
Milestone
Metadata
Metadata
Assignees
Labels
A-EnhancementNew feature or requestNew feature or requestA-PerformancePerformance related changes and issuesPerformance related changes and issuesC-GCIssue related to garbage collectionIssue related to garbage collectionC-RuntimeIssues and PRs related to Boa's runtime featuresIssues and PRs related to Boa's runtime features
Type
Fields
Give feedbackNo fields configured for Feature.
Projects
StatusShow more project fields
To do
Currently, the only way to pass a
JsValueto, say, two different APIs is to clone them. Clones are expensive with the current GC (as it requires a ref count inc/dec on clone/drop, and a mutex lock on drop).This is blocking to 1.0 as it might require a public API breaking change.
This can also be fixed with the new GC. If it is, then this issue becomes a NOOP as
JsValueitself would beCopy.An alternative is to keep
JsValuenon-Copy, and implement aJsValueLite(those two things could be swapped toJsValueOwnedandJsValue). The lite version of value would be akin to a weak ref to the value, and be copy-able but scoped to'_(so you cannot hold a value of it internally without cloning). This would be safe as the GC never collects during API call stacks, only at the end. If a host/API wants to keep a value internally they would need to clone, getting the fully owned version ofJsValue.Since this might be useless work and be obsolete with the new GC, this was never implemented. But it should still gate the 1.0 release, in case the new GC cannot make
JsValuecopy.