Use Vector<UniquePtr> instead of Vector<Scoped> for tracking heap edge names

RESOLVED FIXED in mozilla33

Status

()

defect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: Waldo, Assigned: Waldo)

Tracking

unspecified
mozilla33
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

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.
Posted patch PatchSplinter Review
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 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+
> 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?
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.
https://hg.mozilla.org/mozilla-central/rev/9c2d9347e6ea
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.