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)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: Waldo, Assigned: Waldo)

Details

Attachments

(1 file)

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.
Attached 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.
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.

Attachment

General

Created:
Updated:
Size: