This change removes one traversal in the backend and it is one step in the direction of recording more inforamtion in resolution; the compuation of DartCapturedVariables, for example, could also be done during resolution and stored in the TreeElements.
The disadvantage is that resolution may look at more code than TypePropagation, but in this specific case I do not think that we are realisticly able to eliminate try statements in functions that are small enough to be inlined.
R=kmillikin@google.com
Review URL: https://codereview.chromium.org//1311403003 .
Interceptor sharing/hoisting now takes places much later.
ShareInterceptors is now responsible for replacing interceptor calls
with constants, although determining if it CAN be replaced with a
constant is determined during type propagation where precise types are
available.
LetSinking has been removed; it was a leftover from when interceptors
were generated at definition-site.
As a follow-up on deleting LetSinking, creation expressions are now
considered effectively constant during assignment propagation. This is
safe because such expressions are not propagated into loops (this was
not always the case).
BUG=
R=kmillikin@google.com
Review URL: https://codereview.chromium.org//1322403002 .
Functions are unreachable if their parameters have an empty type. We would generate bogus code for the function due to the empty type so we might as well generate a throw. This can prevent spurious inclusion of more code referenced only in the unreachable code.
It is usually a bug if we generate unreachable methods but it can happen for legitimate reasons. One is that type inference is sometimes more precise than type propagation in the optimizer. Another is that we call a function that has an uninstantiated parameter type. This usually happens due the infeasibility of the path being hidden by a correlation between the type and some variable's value.
There is a tail of bugs that need to be flushed out before we can enable this by default.
Enable with:
DART_VM_OPTIONS=-Dunreachable-throw=true <compile>
language/cyclic_default_values_test fails, with foo and foo2 falsely unreachable:
DART_VM_OPTIONS=-Dunreachable-throw=true tools/test.py -mrelease -cdart2js -rd8 language/cyclic_default_values_test
I have added a test for the cause - a type inference bug with default argument values.
DART_VM_OPTIONS=-Dunreachable-throw=true tools/test.py -mrelease dart2js/simple_inferrer_const_closure_default_test
R=sigmund@google.com
Review URL: https://codereview.chromium.org//1320673004 .
Refinement nodes are inserted after an InvokeMethod, refining the type
of the receiver to those that can respond to the selector.
Refinements are also inserted in the arms of a branch with a condition
of form 'x is T' or 'x == null'.
R=kmillikin@google.com
Review URL: https://codereview.chromium.org//1330503003 .
The plan:
Move ElementListener from listener.dart to element_listener.dart
Move NodeListener from listener.dart to node_listener.dart
Move MemberListener from class_element_parser.dart to member_listener.dart
Move PartialElement, PartialFunctionElement etc from listener.dart and class_element_parser.dart to partial_elements.dart
Move PrecedenceInfo from token.dart to precedence.dart
Move *_INFO constants from token.dart to precendence_constants.dart
Move *_TOKEN constants from token.dart to token_constants.dart
BUG=
R=karlklose@google.com
Review URL: https://codereview.chromium.org//1325053003.
Aggregates which do not escape can be replaced with local variables.
This applies to regular objects, closures and boxes. Closures need
their body inlined first.
Fields that are written are replaced with a MutableVariable. Fields
that are only initialized have the reads replaced with references to
the initial value.
R=asgerf@google.com
Review URL: https://codereview.chromium.org//1319303002 .
Updated js_backend_cps_ir_closures_test.dart
Made two variants of tests that were changed by inlining:
1. Same source, showing inlined code.
2. Source with escaping closure to avoid inlining.
Review URL: https://codereview.chromium.org//1310483004 .
The unsugar pass no longer inserts `identical(_, true)` around every
branching condition. Insead, the Branch node has a flag isStrictCheck
denoting whether that check should be there.
The `identical(_, true)` check is now inserted by the Tree IR builder.
The identical nodes obstructed reasoning about branching conditions, in
particular in redundant joint elimination and insertion of type
refinement nodes.
BUG=
R=kmillikin@google.com
Review URL: https://codereview.chromium.org//1311353008 .
Previously, interceptors were generated at the definition-site to ensure
sharing, and sometimes sunk to its use-site if desirable.
Now they are (again) generated at use-site, then pulled out of loops,
and replaced by dominating calls to getInterceptor.
This means interceptors are only computed if they really are needed,
but on the other hand, they are sometimes computed more than once, when
there are uses that don't have a common dominator.
Interceptor constants are currently not shared/hoisted as it is not
clear when this is beneficial.
R=kmillikin@google.com
Review URL: https://codereview.chromium.org//1313783003 .
After type propagation, avoid transforming unreachable branches by
explicitly replacing them with Unreachable. Also use the abstract boolean
value rather than the concrete constant value for branches, just as was
already done for type tests and casts.
R=asgerf@google.com
BUG=
Review URL: https://codereview.chromium.org//1309813009 .
Constants would typically fail to propagate into an argument of a method
call in cases where the receiver of the call might be null. Constants
can safely propagate across the unsafe method lookup.
BUG=
R=kmillikin@google.com
Review URL: https://codereview.chromium.org//1315333002 .
This gives almost 30x compile-time speedup on ImagingGaussianBlurOnce.
Based on profiling with Observatory, it seems to be a performance bug
in how hash codes are stored on objects. The majority of time is spent
in Object_GetHash, which does not compute a hash, but looks it up in a
weak hash table in the VM.
R=kmillikin@google.com
Review URL: https://codereview.chromium.org//1311673009 .
Inline static functions whose bodies are a single Dart expression that
just calls a foreign (native) function. This eliminates a lot of
overhead from the code in the JavaScript runtime library.
R=asgerf@google.com
BUG=
Review URL: https://codereview.chromium.org//1318453003 .