Closed
Bug 1149397
Opened 10 years ago
Closed 9 years ago
JS::ubi::Node::edges should return a mozilla::UniquePtr
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla41
People
(Reporter: fitzgen, Assigned: fitzgen)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
9.65 KB,
patch
|
jimb
:
review+
|
Details | Diff | Splinter Review |
It is less than awesome in that the docs say you have to free it with js_free, but that is hard to remember and there are no guarantees. Instead, we should just hand out mozilla::UniquePtr instances with JS::FreePolicy so that this stuff happens automatically.
Assignee | ||
Updated•10 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 1•10 years ago
|
||
Attachment #8586450 -
Flags: review?(jimb)
Comment 2•10 years ago
|
||
Comment on attachment 8586450 [details] [diff] [review]
bug-1149397-edges-return-UniquePtr.patch
Review of attachment 8586450 [details] [diff] [review]:
-----------------------------------------------------------------
Great stuff. I have a suggestion, though:
::: js/public/UbiNode.h
@@ +195,5 @@
> // on |cx| and return nullptr.
> //
> // If wantNames is true, compute names for edges. Doing so can be expensive
> // in time and memory.
> + virtual UniquePtr<EdgeRange, JS::DeletePolicy<EdgeRange>> edges(JSContext* cx, bool wantNames)
Let's do this instead:
namespace mozilla {
template<>
class DefaultDelete<EdgeRange> : public JS::DeletePolicy<EdgeRange> { };
}
somewhere in this file to establish that as the default deleter for EdgeRange. Note that that default gets picked up here:
https://hg.mozilla.org/mozilla-central/file/c20f8549d631/mfbt/UniquePtr.h#l22
Then just using UniquePtr<EdgeRange> would do the right thing.
It would also improve legibility, without resorting to a typedef.
::: js/src/vm/UbiNode.cpp
@@ -8,5 @@
>
> #include "mozilla/Assertions.h"
> #include "mozilla/Attributes.h"
> #include "mozilla/Scoped.h"
> -#include "mozilla/UniquePtr.h"
Let's do
using mozilla::UniquePtr;
within this file, too.
@@ +47,5 @@
> // All operations on null ubi::Nodes crash.
> const char16_t* Concrete<void>::typeName() const { MOZ_CRASH("null ubi::Node"); }
> +mozilla::UniquePtr<EdgeRange, JS::DeletePolicy<EdgeRange>> Concrete<void>::edges(JSContext*,
> + bool) const {
> + MOZ_CRASH("null ubi::Node");
If this is still too long even after we establish the default deleter, then let's move it out of the specially-formatted block, as we did for ::size, since we can't helpfully show off its symmetry this way anyway.
@@ +215,5 @@
>
> if (!r->init(cx, ptr, ::js::gc::MapTypeToTraceKind<Referent>::kind, wantNames))
> return nullptr;
>
> + mozilla::UniquePtr<EdgeRange, JS::DeletePolicy<EdgeRange>> p(mozilla::Move(r));
*sigh* Yep.
Attachment #8586450 -
Flags: review?(jimb) → review+
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
status-firefox40:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
Comment 6•10 years ago
|
||
sorry had to backout this changes in https://hg.mozilla.org/mozilla-central/rev/0b202671c9e2 since one of this changes seems to have caused a Linux PGO Bustage like:
https://treeherder.mozilla.org/logviewer.html#?job_id=1380632&repo=mozilla-central
Status: RESOLVED → REOPENED
Flags: needinfo?(nfitzgerald)
Resolution: FIXED → ---
Assignee | ||
Updated•10 years ago
|
Flags: needinfo?(nfitzgerald)
Comment 8•9 years ago
|
||
Status: REOPENED → RESOLVED
Closed: 10 years ago → 9 years ago
status-firefox41:
--- → fixed
Resolution: --- → FIXED
Target Milestone: mozilla40 → mozilla41
You need to log in
before you can comment on or make changes to this bug.
Description
•