Unnecessary roots: Rooted can self-justify its need for rooting
Categories
(Core :: JavaScript: GC, task, P5)
Tracking
()
People
(Reporter: sfink, Unassigned, Mentored)
References
(Blocks 1 open bug)
Details
(Whiteboard: [lang=js])
(From bug 1968290):
Rooted<CollatorObject*> collator(cx, ...);
auto* coll = GetOrCreateCollator(cx, collator);
...no further uses of collator...
}
collator should be marked as an unnecessary root because it's not live after the call to GetOrCreateCollator, but it is seen as live because ~Rooted uses it at the end of the scope.
Calls to ~Rooted for a variable should not extend that variable's live range.
| Reporter | ||
Comment 1•1 year ago
|
||
I'm not sure if I should mark this as a good first bug, but it's at least a fine mentored bug.
To fix, you would add Rooted destructors to ignoreEdgeUse and then add a test to https://searchfox.org/mozilla-central/source/js/src/devtools/rootAnalysis/t/hazards/source.cpp and https://searchfox.org/mozilla-central/source/js/src/devtools/rootAnalysis/t/hazards/test.py (sorry, that makes the language a bit of a lie; the bugfix is in JS, the source being tested is C++, and the test script is Python!)
Test with:
% mach hazards bootstrap
% mach hazards build-shell
% mach hazards self-test
This will only work in a linux64 environment.
| Reporter | ||
Comment 2•1 year ago
|
||
The test will be a little tricky. I can help as needed. The basic idea is to create a Rooted, pass it into another function, and then never use it again. The problem is that the existing test setup only looks at whether something creates a hazard or not, and this will not, with or without the fix. The test will have to check whether it shows up as an unnecessary root or not.
Updated•1 year ago
|
Description
•