Closed
Bug 1164602
Opened 10 years ago
Closed 10 years ago
Replace NullPtr hack with nullptr_t
Categories
(Core :: JavaScript: GC, defect)
Core
JavaScript: GC
Tracking
()
RESOLVED
FIXED
mozilla41
Tracking | Status | |
---|---|---|
firefox41 | --- | fixed |
People
(Reporter: terrence, Assigned: terrence)
References
(Blocks 2 open bugs)
Details
Attachments
(1 file, 1 obsolete file)
213.62 KB,
patch
|
sfink
:
review+
|
Details | Diff | Splinter Review |
When we implemented Handle, nullptr_t was still a typedef to 0 on some platforms. Now that it is a real thing everywhere, we should be able to replace our NullPtr workaround with a constructor taking std::nullptr_t. The only remaining issue is that some platforms do not have a modern libstdc++, so do not have std::nullptr_t. Luckily we can get around that by using decltype(nullptr) instead. This patch appears to work locally; try run is below to check the other platforms:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=3b845f5801f5
The attached patch was generated with:
$ find . -name "*.cpp" -o -name "*.h" -exec sed -i 's/JS::NullPtr()/nullptr/g' \{\} \;
$ find . -name "*.cpp" -o -name "*.h" -exec sed -i 's/js::NullPtr()/nullptr/g' \{\} \;
$ find . -name "*.cpp" -o -name "*.h" -exec sed -i 's/NullPtr()/nullptr/g' \{\} \;
With a bit of hand tweaking afterwards to fix up Codegen.py and JS::GCCellPtr::NullPtr.
Assignee | ||
Comment 1•10 years ago
|
||
Whoops! Forgot that the null needs to be at the second level of indirection. Easy enough to solve.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=a53f9c3cec0b
Attachment #8605433 -
Attachment is obsolete: true
Assignee | ||
Updated•10 years ago
|
Attachment #8605513 -
Flags: review?(sphink)
Assignee | ||
Comment 2•10 years ago
|
||
Try run looks green.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=a53f9c3cec0b
Comment 3•10 years ago
|
||
Comment on attachment 8605513 [details] [diff] [review]
use_nullptr_t_instead_of_NullPtr-v1.diff
Review of attachment 8605513 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/public/RootingAPI.h
@@ +120,5 @@
>
> template <typename T>
> class PersistentRootedBase {};
>
> +static void*const ConstNullValue = nullptr;
static void* const ConstNullValue = nullptr;
assuming this is still needed?
@@ +407,3 @@
> static_assert(mozilla::IsPointer<T>::value,
> + "nullptr_t overload not valid for non-pointer types");
> + ptr = reinterpret_cast<const T*>(&js::ConstNullValue);
Wouldn't this be better with just a static nullptr declared right here? Or do we compare these pointers somehow?
Attachment #8605513 -
Flags: review?(sphink) → review+
Assignee | ||
Comment 4•10 years ago
|
||
InternalHandle's constructor also needed an &nullptr and I thought it would be simpler to share them. I mean, it would be weird for null handle != null handle, even if we never actually use the feature.
Assignee | ||
Comment 5•10 years ago
|
||
Assignee | ||
Comment 6•10 years ago
|
||
Comment 8•10 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in
before you can comment on or make changes to this bug.
Description
•