Closed
Bug 1037152
Opened 11 years ago
Closed 11 years ago
Use Vector<UniquePtr> instead of Vector<Scoped> for tracking heap edge names
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla33
People
(Reporter: Waldo, Assigned: Waldo)
Details
Attachments
(1 file)
|
4.80 KB,
patch
|
jimb
:
review+
|
Details | Diff | Splinter Review |
Interestingly, this is currently an allocator mismatch -- js_strdup uses cx->malloc which is supposed to be js_free'd, not free'd, as mozilla::ScopedFreePtr does. No effect except for embedders that override js_free.
| Assignee | ||
Comment 1•11 years ago
|
||
Note how nicely forgetName() works -- it returns a temporary UniquePtr that Vector painlessly adopts without any special effort needed. Go rvalue references!
Attachment #8454020 -
Flags: review?(jimb)
Comment 2•11 years ago
|
||
Comment on attachment 8454020 [details] [diff] [review]
Patch
Review of attachment 8454020 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/builtin/TestingFunctions.cpp
@@ -1688,5 @@
>
> public:
> BackEdge() : name_(nullptr) { }
> - // Construct an initialized back edge. Take ownership of |name|.
> - BackEdge(JS::ubi::Node predecessor, jschar *name)
Could you not delete the "Take ownership of |name|" comment? I grant that passing a UniquePtr *always* takes ownership, but I think it should be called out here.
Attachment #8454020 -
Flags: review?(jimb) → review+
Comment 3•11 years ago
|
||
> Note how nicely forgetName() works -- it returns a temporary UniquePtr that
> Vector painlessly adopts without any special effort needed. Go rvalue
> references!
Right, that's the same way that the ScopedFreePtr was handling it, wasn't it?
| Assignee | ||
Comment 4•11 years ago
|
||
Almost, but not quite. forgetName was returning a raw pointer. Someone who did this (or something not nearly so obviously dumb) would leak:
(void) bedge.forgetName();
whereas now, someone who does that will *not* leak. If you forget the name, the returned value owns the name, and when it's destroyed (or anything else it hands off the name to) it'll handle things.
| Assignee | ||
Comment 5•11 years ago
|
||
Target Milestone: --- → mozilla33
Comment 6•11 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•