Mark DOM getters as pure when they are

RESOLVED FIXED in mozilla21

Status

()

defect
RESOLVED FIXED
6 years ago
a month ago

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Tracking

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

unspecified
mozilla21
x86
macOS
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]
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+
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+
Component: DOM → DOM: Core & HTML
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.