The default bug view has changed. See this FAQ.

Mark DOM getters as pure when they are

RESOLVED FIXED in mozilla21

Status

()

Core
DOM
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: bz, Assigned: bz)

Tracking

(Blocks: 1 bug, {dev-doc-complete})

unspecified
mozilla21
x86
Mac OS X
dev-doc-complete
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(4 attachments, 1 obsolete attachment)

This is similar to bug 747289 but promises less.  A pure getter promises that calling it has no side-effects (e.g. it doesn't flush and will never run script), but does not promise that the value returned is the same no matter what.  So it can be reordered wrt slot sets, but not wrt DOM methods or setters.

A preliminary attempt at this for Element.id gives me http://dromaeo.com/?id=189130,189131 because it makes Dromaeo's .id test completely useless....  But I expect this to help in real-life code that touches things like .className too.

Now one issue is that _most_ DOM getters are pure, but to be safe-by-default we should probably explicitly mark them so.  That means an unfortunate lot of annotation.  :(
Assignee: nobody → bzbarsky
Whiteboard: [need review]
Created attachment 707154 [details] [diff] [review]
part 1.  Mark Node.namespaceURI as not throwing, since [Constant] things aren't allowed to throw (though we were not enforcing that).
Attachment #707154 - Flags: review?(peterv)
Created attachment 707167 [details] [diff] [review]
part 2.  Implement WebIDL parser and codegen support for marking things pure.
Attachment #707167 - Flags: review?(peterv)
Created attachment 707171 [details] [diff] [review]
part 3.  Add the notion of aliasing DOM stuff to MIR and flag MGetDOMProperty with the right alias set if it's pure.
Attachment #707171 - Flags: review?(jdemooij)
Created attachment 707172 [details] [diff] [review]
part 4.  Flag a bunch of DOM getters as [Pure].
Attachment #707172 - Flags: review?(peterv)
Oh, and I'm not doing methods yet because jandem tells me there are complications with trying to move around MCalls.  But I really want to sort those out, and then we can do this for a bunch of methods too.
Keywords: dev-doc-needed
Comment on attachment 707171 [details] [diff] [review]
part 3.  Add the notion of aliasing DOM stuff to MIR and flag MGetDOMProperty with the right alias set if it's pure.

Review of attachment 707171 [details] [diff] [review]:
-----------------------------------------------------------------

Nice!
Attachment #707171 - Flags: review?(jdemooij) → review+
Created attachment 707342 [details] [diff] [review]
part 1.  Mark Node.namespaceURI as not throwing, since [Constant] things aren't allowed to throw (though we were not enforcing that).
Attachment #707342 - Flags: review?(peterv)
Attachment #707154 - Attachment is obsolete: true
Attachment #707154 - Flags: review?(peterv)
Attachment #707342 - Flags: review?(peterv) → review+
Comment on attachment 707167 [details] [diff] [review]
part 2.  Implement WebIDL parser and codegen support for marking things pure.

Review of attachment 707167 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/bindings/Codegen.py
@@ +4682,5 @@
>                  sig = sigs[0]
> +                if (len(sig[1]) != 0 or
> +                    not infallibleForMember(self.member, sig[0], self.descriptor)):
> +                    # We have arguments or our return-value boxing can fail
> +                    methodInfal = False

I think you should just do the |methodInfal = "infallible" in self.descriptor.getExtendedAttributes(self.member)| bit here in an else block.
Attachment #707167 - Flags: review?(peterv) → review+
Attachment #707172 - Flags: review?(peterv) → review+
   https://hg.mozilla.org/integration/mozilla-inbound/rev/fce9b4a08399
   https://hg.mozilla.org/integration/mozilla-inbound/rev/f0bd3d538233
   https://hg.mozilla.org/integration/mozilla-inbound/rev/0a21a1eeda35
   https://hg.mozilla.org/integration/mozilla-inbound/rev/d8a95f5b67d7
Flags: in-testsuite+
Whiteboard: [need review]
Target Milestone: --- → mozilla21
Documented at https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#.5BPure.5D
Keywords: dev-doc-needed → dev-doc-complete
https://hg.mozilla.org/mozilla-central/rev/fce9b4a08399
https://hg.mozilla.org/mozilla-central/rev/f0bd3d538233
https://hg.mozilla.org/mozilla-central/rev/0a21a1eeda35
https://hg.mozilla.org/mozilla-central/rev/d8a95f5b67d7
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.