Closed
Bug 781070
Opened 13 years ago
Closed 12 years ago
make NullPtr public
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla22
People
(Reporter: Benjamin, Assigned: jonco)
References
Details
(Whiteboard: [js:t])
Attachments
(1 file, 1 obsolete file)
5.80 KB,
patch
|
terrence
:
review+
|
Details | Diff | Splinter Review |
The other rooting stuff works outside of JS by virture of being templates. NullPtr is concrete, though, so it needs JS_PUBLIC_API.
Reporter | ||
Comment 1•13 years ago
|
||
Assignee: general → bpeterson
Attachment #649919 -
Flags: review?(luke)
![]() |
||
Comment 2•13 years ago
|
||
Will this make normal use inside the JS engine slower (requiring reading the GOT to find &NullPtr::constNullValue)?
If so, one alternative is to have the NullPtr provide the NULL-holding memory location as a member variable, although this has hazards like:
HandleObject h = NullPtr();
// NullPtr() has been destroyed, h still points at address
Reporter | ||
Comment 3•13 years ago
|
||
Luke and I talked about this and came to the conclusion that browser code can use Rooted* (cx, NULL) for now.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WONTFIX
![]() |
||
Updated•13 years ago
|
Attachment #649919 -
Flags: review?(luke)
Comment 4•12 years ago
|
||
This makes me :-(
I don't think it would be acceptable to finalize a handle API without a convenient way for consumers to pass null. Given that, I think we might as well solve this problem now.
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
The handle API is not at all finalized. Where do you need this Bobby? Right now the only place where you might need to call a function that takes a handle is if you're calling a callback.
Comment 6•12 years ago
|
||
(In reply to Bill McCloskey (:billm) from comment #5)
> The handle API is not at all finalized. Where do you need this Bobby? Right
> now the only place where you might need to call a function that takes a
> handle is if you're calling a callback.
http://mxr.mozilla.org/mozilla-central/source/dom/base/nsJSEnvironment.cpp#1330
(In reply to Bobby Holley (:bholley) from comment #6)
> http://mxr.mozilla.org/mozilla-central/source/dom/base/nsJSEnvironment.
> cpp#1330
Oh yeah. Those handles should not have been added. We decided to leave them in rather than convert them back to raw pointers. Maybe that was a mistake, though.
Comment 8•12 years ago
|
||
Polyfilling std::nullptr_t per bug 806546 would also solve this problem, and probably better than by exposing NullPtr. That said, I'm not totally sure it's possible to have both nullptr and std::nullptr_t at once, without compiler support, but I could easily be wrong.
Comment 9•12 years ago
|
||
(In reply to Bill McCloskey (:billm) from comment #7)
> Oh yeah. Those handles should not have been added. We decided to leave them
> in rather than convert them back to raw pointers. Maybe that was a mistake,
> though.
Ah I see. I probably had an inflated view of how much the handles have leaked out into the DOM because I see them everywhere in XPConnect (with all the JSClass hooks and such). If I'm not supposed to be using them I'm happy to forget about this bug for the time being (so long as there is eventually a solution).
![]() |
||
Comment 10•12 years ago
|
||
When it does become relevant, we could add a JS_PUBLIC_API JS::NullHandle which would be separate from and thus avoid penalizing the engine-internal js::NullHandle.
Comment 11•12 years ago
|
||
(In reply to Luke Wagner [:luke] from comment #10)
> When it does become relevant, we could add a JS_PUBLIC_API JS::NullHandle
> which would be separate from and thus avoid penalizing the engine-internal
> js::NullHandle.
sgtm.
Updated•12 years ago
|
Whiteboard: [js:t]
Reporter | ||
Updated•12 years ago
|
Assignee: benjamin → general
Assignee | ||
Updated•12 years ago
|
Assignee: general → jcoppeard
Assignee | ||
Comment 12•12 years ago
|
||
Attachment #649919 -
Attachment is obsolete: true
Attachment #726677 -
Flags: review?(terrence)
Comment 13•12 years ago
|
||
Comment on attachment 726677 [details] [diff] [review]
Introduce separate public JS::NullPtr
Review of attachment 726677 [details] [diff] [review]:
-----------------------------------------------------------------
Nicely done!
::: js/public/RootingAPI.h
@@ +118,5 @@
> template <typename T>
> class MutableHandleBase {};
>
> +/*
> + * Pass a NULL handle, internal version.
Lets expand on this a bit to give more context. Something like:
"js::NullPtr acts like a NULL pointer in contexts that require a Handle. This is the SpiderMonkey internal variant. js::NullPtr should be used in preference to JS::NullPtr to avoid the GOT access required for JS_PUBLIC_API symbols."
@@ +149,5 @@
> CheckStackRoots(JSContext *cx);
> #endif
>
> /*
> + * Pass a NULL handle, public version.
The same comment as above, but we can stop after the first sentence.
Attachment #726677 -
Flags: review?(terrence) → review+
Assignee | ||
Comment 14•12 years ago
|
||
Comment 15•12 years ago
|
||
Status: REOPENED → RESOLVED
Closed: 13 years ago → 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
You need to log in
before you can comment on or make changes to this bug.
Description
•