Closed
Bug 1103368
Opened 11 years ago
Closed 11 years ago
Ban stub getters and setters in most places throughout the engine
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla37
People
(Reporter: jorendorff, Assigned: jorendorff)
References
Details
Attachments
(5 files)
|
12.04 KB,
patch
|
bhackett1024
:
review+
|
Details | Diff | Splinter Review |
|
33.52 KB,
patch
|
bhackett1024
:
review+
|
Details | Diff | Splinter Review |
|
50.31 KB,
patch
|
bhackett1024
:
review+
|
Details | Diff | Splinter Review |
|
8.13 KB,
patch
|
bhackett1024
:
review+
|
Details | Diff | Splinter Review |
|
155.03 KB,
patch
|
bhackett1024
:
review+
|
Details | Diff | Splinter Review |
Shapes are already a "clean spot": a Shape never has a getter value of JS_PropertyStub or a setter value of JS_StrictPropertyStub.
In this bug, I want to grow the clean spot to cover most of the engine.
In the end, the stubs have to go.
Comment 1•11 years ago
|
||
The only reason to really have the stubs right now is to differentiate "nothing special" and "class-default", right?
Could we perhaps flip the API boundary indication there, so null means "nothing special" and you have to go out of your way to ask for the class default thing?
| Assignee | ||
Comment 2•11 years ago
|
||
| Assignee | ||
Comment 3•11 years ago
|
||
(In reply to [:bz] from comment #1)
> The only reason to really have the stubs right now is to differentiate
> "nothing special" and "class-default", right?
And only in the JS_Define* APIs, right.
> Could we perhaps flip the API boundary indication there, so null means
> "nothing special" and you have to go out of your way to ask for the class
> default thing?
Yep, that's my intent. Not in this bug; it'll be the last thing to change before deleting the stubs entirely. It'll involve paying a short visit to all 500 JS_Define* call sites. Big fun.
| Assignee | ||
Comment 4•11 years ago
|
||
Attachment #8527846 -
Flags: review?(bhackett1024)
| Assignee | ||
Updated•11 years ago
|
Assignee: nobody → jorendorff
Status: NEW → ASSIGNED
| Assignee | ||
Comment 5•11 years ago
|
||
Attachment #8527847 -
Flags: review?(bhackett1024)
| Assignee | ||
Comment 6•11 years ago
|
||
Attachment #8527848 -
Flags: review?(bhackett1024)
| Assignee | ||
Comment 7•11 years ago
|
||
Attachment #8527849 -
Flags: review?(bhackett1024)
| Assignee | ||
Comment 8•11 years ago
|
||
Attachment #8527851 -
Flags: review?(bhackett1024)
Updated•11 years ago
|
Attachment #8527846 -
Flags: review?(bhackett1024) → review+
Comment 9•11 years ago
|
||
Comment on attachment 8527847 [details] [diff] [review]
part 2 - Ban stub getter/setter arguments to js::baseops::Define{Property,Generic,Element}, DefineNativeProperty, and DefinePropertyOrElement
Review of attachment 8527847 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/jsobj.cpp
@@ -2247,5 @@
> if (!xdr->codeConstValue(&tmpValue))
> return false;
>
> if (mode == XDR_DECODE) {
> - if (!DefineNativeProperty(cx, obj, id, tmpValue, NULL, NULL, JSPROP_ENUMERATE))
Huh, do we have a way to keep uses of NULL from leaking back into the code base?
Attachment #8527847 -
Flags: review?(bhackett1024) → review+
Updated•11 years ago
|
Attachment #8527848 -
Flags: review?(bhackett1024) → review+
Updated•11 years ago
|
Attachment #8527849 -
Flags: review?(bhackett1024) → review+
Updated•11 years ago
|
Attachment #8527851 -
Flags: review?(bhackett1024) → review+
| Assignee | ||
Comment 10•11 years ago
|
||
(In reply to Brian Hackett (:bhackett) from comment #9)
> > - if (!DefineNativeProperty(cx, obj, id, tmpValue, NULL, NULL, JSPROP_ENUMERATE))
>
> Huh, do we have a way to keep uses of NULL from leaking back into the code
> base?
Nope. A quick grep shows dozens of hits for NULL, plus another 200 or so in vm/Opcodes.h.
Comment 11•11 years ago
|
||
(In reply to Brian Hackett (:bhackett) from comment #9)
> Huh, do we have a way to keep uses of NULL from leaking back into the code
> base?
You could add a template overload that's MOZ_DELETEd:
template<typename N1, typename N2>
bool
js::DefineNativeProperty(ExclusiveContext *cx, HandleNativeObject obj, HandleId id,
HandleValue value, N getter, N2 setter, unsigned attrs,
typename mozilla::EnableIf<mozilla::IsNullPointer<N1>::value ||
mozilla::IsNullPointer<N1>::value,
int>::Type dummy = 0) MOZ_DELETE;
Only works for functions where no user should ever call providing literal nullptr. Not useful for JSAPI entry points where nullptr is supposed to mean the default behavior. Also, a bit of a mess to get right, but maybe worth it as one-time pain (and then only pain for people who get it wrong afterward).
Comment 12•11 years ago
|
||
...which of course assumes people are using nullptr only. We could more or less guarantee that in our codebase, and indeed I don't know how it is that we still have any NULL uses -- I thought they'd all been converted to nullptr.
| Assignee | ||
Comment 13•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/64aa4c4d0691
https://hg.mozilla.org/integration/mozilla-inbound/rev/e737de5b209b
https://hg.mozilla.org/integration/mozilla-inbound/rev/ba1d6ece1bc6
https://hg.mozilla.org/integration/mozilla-inbound/rev/d201babc2e84
https://hg.mozilla.org/integration/mozilla-inbound/rev/b4b619628d1d
b2g build bustage https://treeherder.mozilla.org/ui/logviewer.html#?job_id=4173512&repo=mozilla-inbound
https://hg.mozilla.org/integration/mozilla-inbound/rev/c80672f72db6
https://hg.mozilla.org/integration/mozilla-inbound/rev/56ebb99d774e
https://hg.mozilla.org/integration/mozilla-inbound/rev/ae31d2669511
https://hg.mozilla.org/integration/mozilla-inbound/rev/cabeb902de6d
https://hg.mozilla.org/integration/mozilla-inbound/rev/6daa62f15a63
| Assignee | ||
Comment 15•11 years ago
|
||
| Assignee | ||
Comment 16•11 years ago
|
||
| Assignee | ||
Comment 17•11 years ago
|
||
| Assignee | ||
Comment 18•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/f57597056a60
https://hg.mozilla.org/integration/mozilla-inbound/rev/5814a1723842
https://hg.mozilla.org/integration/mozilla-inbound/rev/f654193f2c2e
https://hg.mozilla.org/integration/mozilla-inbound/rev/8d0fdbf77f28
https://hg.mozilla.org/integration/mozilla-inbound/rev/65e82280a4be
https://hg.mozilla.org/mozilla-central/rev/f57597056a60
https://hg.mozilla.org/mozilla-central/rev/5814a1723842
https://hg.mozilla.org/mozilla-central/rev/f654193f2c2e
https://hg.mozilla.org/mozilla-central/rev/8d0fdbf77f28
https://hg.mozilla.org/mozilla-central/rev/65e82280a4be
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
You need to log in
before you can comment on or make changes to this bug.
Description
•