Closed Bug 835417 Opened 10 years ago Closed 10 years ago

Mark DOM getters as pure when they are


(Core :: DOM: Core & HTML, defect)

Not set





(Reporter: bzbarsky, Assigned: bzbarsky)


(Blocks 1 open bug)


(Keywords: dev-doc-complete)


(4 files, 1 obsolete file)

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 gives me,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]:

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/
@@ +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
You need to log in before you can comment on or make changes to this bug.