Use worklist inside analyze_class
Summary:
Inside analyze_class(), we loop until all private properties have
reached a fixed point. However we don't use a worklist, we re-analyze
every method over and over. This is inefficient, since most methods
will not be accessing that property. Reduce the number of re-analyzes
by using an explicit worklist. If we access a private property during
analyze, we record a dependency on that property by that
function. Whenever the property's type changes, we re-schedule any
function with a dependency on it. We keep analyzing until the worklist
is empty.
Note: these dependencies are different than the one in the Index. This
dependencies only related methods on the particular class being
analyzed, to private properties on the same class. Once
analyze_class() is over, these dependencies are thrown away.
As another optimization, do a pass over all properties before
analysis. Compute whether their initial values can violate their
type-hint initially. This is superior to defaulting to "true" and
letting normal analysis update it. The vast majority of properties
will have a "false" value initially, so it just causes another round
of analysis. This is similar to how we pre-compute return types (for
the same reason).
Differential Revision:
D28024817
fbshipit-source-id:
bf071fcc4d8f271c74cc66629b36a3a7bbc1036f