In the CPS backend's type propagation, try to avoid eliminating calls
whose receiver can be null.
This fixes a bug in the constant folding of indexed access. e0[e1]
would be folded away if e0 could be null but type inference told us
that the elements had a known (specifically null) type.
tests/language/inference_list_or_null_test triggers the bug.
R=asgerf@google.com
BUG=
Review URL: https://codereview.chromium.org/1515833003 .
In the CPS backend, when a for-in loop has an erroneous variable (interpreted
as an unresolved static setter), then we should call NoSuchMethod and not try
to call the setter. This is what the SSA backend does.
BUG=
R=asgerf@google.com
Review URL: https://codereview.chromium.org/1518473002 .
When a method is invoked directly the target is known. Normalize the
arguments based on the known target at CPS-translation time. If this is not
done, then the call may go indirectly through a stub which is not actually
generated.
R=asgerf@google.com
BUG=
Review URL: https://codereview.chromium.org/1510193003 .
When translating to CPS, call arguments are normalized. For known
targets, this means default values are passed for missing optional
arguments and named arguments are in a canonical order. For unknown
targets, this means that passed named arguments are in a canonical
order.
However, the CallStructure recorded is one that describes the original
call. This may have an incorrect number of passed argument or an
incorrect order for named arguments. With this change, a new call
structure is created describing the call as it appears in the CPS IR.
R=johnniwinther@google.com
Review URL: https://codereview.chromium.org/1491973002 .
This makes it possible to concatenate commonly used fragments in front of the main fragment. For example, if an application knows that it will immediately load a fragment, it can prefix its main fragment with that fragment.
R=sra@google.com
Review URL: https://codereview.chromium.org/1508543003 .
We get extra precision from including argument types that produce errors.
e.g. {int} + {int,null} --> {int}.
Nice improvement on some numerical benchmarks where the result is used as an index where we can now use the builtin indexer.
Review URL: https://codereview.chromium.org/1493673003 .
For some reason html.Element's static const _tagsForWhichCreateContextualFragmentIsNotSupported is inferred to dynamic instead of a ContainerTypeMask.
This change will also 'do the right thing' if we turn off type inference.
R=asgerf@google.com
Review URL: https://codereview.chromium.org/1490923003 .
- renames the existing AbstractValue in cps_ir/type_propagation.dart to AbstractConstant
- introduces AbstractValue as an empty superinterface of TypeMask, and
- lift the interface of TypeMaskSystem to the superinterface AbstractValueDomain.
In follow-ups:
- change simple uses from TypeMask(System) to AbstractValue(Domain)
- update names and comment in AbstractValueDomain to more precisely reflect the abstraction
- update the complex uses (mainly type_propagation.dart) to use AbstractValue(Domain)
R=asgerf@google.com
Review URL: https://codereview.chromium.org/1415883005.
The sign of a +/- operation is computed, which can help in cases where
the result could not be proven to be within 53-bit range.
Also added rules for ~/, %, >>, &, and unary negation operators.
BUG=
R=sra@google.com
Review URL: https://codereview.chromium.org/1479193002 .
Primitives now have a getter 'hasValue' to distinguish primitives that
don't return a value, such as SetField.
The interceptor for TypeTestViaFlag is now inserted on-demand.
Non-instantiated intercepted classes are removed the set of
intercepted classes. This avoids an assertion failure, although it
would be better to avoid adding them in the first place.
The type of closure fields for boxes and type variables no longer go
through the global type inference.
A test fails because the type inference infers an empty type for a
closure field for a torn-off `.call` method. It's an existing problem
that we now have at least one failing test for.
CreateFunction has been removed from CPS and Tree.
BUG=
R=sra@google.com
Review URL: https://codereview.chromium.org/1474713002 .
Calls to numeric operators where the receiver might be null will now
insert a specialized null check, like this:
if (typeof x !== 'number') return x.$lt();
BUG=
R=sra@google.com
Review URL: https://codereview.chromium.org/1474373002 .
The cycle detection assumed that positive-weight cycles could safely be
ignored while searching for a negative-weight cycle, but this broke the
memoization in the DFS.
Do not try to use DFS to find shortest paths in cyclic graphs.
BUG=
R=kmillikin@google.com
Review URL: https://codereview.chromium.org/1474133002 .
This test fails:
tools/test.py -mrelease -cdart2js -rd8 --cps-ir language/invocation_mirror_invoke_on2_test
The reason is unrelated: because String.codeUnitAt, the only reference
is the call on Proxy. There appears to be a bug with recognizing this.
TBR=asgerf@google.com
Review URL: https://codereview.chromium.org/1475513009 .
There is a new pass for doing GVN and LICM.
The 'share interceptors' pass previously GVN'ed and LICM'ed interceptors
but now only constifies them and lets GVN handle the rest. The pass
has been renamed to optimize_interceptors.
The 'share final fields' pass has been removed since GVN does the same.
A new pass 'remove redundant refinements' removes some refinement nodes
that contribute no information. These would sometimes block code motion
for no good reason. This pass is should go away once GVN is able to
hoist expressions across refinement guards.
BUG=
R=sra@google.com
Review URL: https://codereview.chromium.org/1444363002 .
(Work-in-progress, but mostly done)
InvokeMethod and friends no longer take a continuation, but are instead
primitives bound by LetPrim.
This touches a lot of code. Some general housekeeping came along in the
process.
InvokeMethod has a "calling convention" enum on it to enable
dartReceiver and getDartArgument convenience methods.
There is a new UnsafePrimitive class to help type propagation
constant-fold InvokeMethods. I expect the class will go away after
some changes to type propagation.
Most optimizations work exactly as before, but not all are 100%
consistent. The consecutive push rewrite was removed entirely because
V8 does not like that.
BUG=
R=kmillikin@google.com, sra@google.com
Review URL: https://codereview.chromium.org/1458703007 .