Perform a depth-first postorder traversal of the call graph of known
functions. Make an inlining decision based on the vector of argument
types at the call site, and cache inlining decisions. For positive
inlining decisions, cache the optimized function body specialized to
the receiver and argument types at the call site.
Future work:
* Real inlining heuristics.
* Propagate result types of inlined calls.
* Specialized for constant arguments when it makes sense.
* Performance improvements.
R=asgerf@google.com, sra@google.com
Review URL: https://codereview.chromium.org/1537663002 .
1. Help type inference infer constant maps have a .length that is a non-null subtype of int. On some programs this means dynamic.length can be inferred as non-null int.
2. Make arity dispatch interceptor free by comparing constants-first (via a switch statement).
R=sigmund@google.com
Review URL: https://codereview.chromium.org/1539033002 .
- short-circuit cases where join yields dynamic
- improve performance of some queries like `hasOnlySubclasses` and how `contains` is implemented in `flatten`. We could also add caching for `length`, but not sure if we want to just have a static map or precompute the data in the class-hierarchy nodes.
On my experiments this reduces inference times more than 50% on a large customer app, while small apps have almost no change.
R=johnniwinther@google.com, sra@google.com
Review URL: https://codereview.chromium.org/1528953002 .
If the index/key is not a number it is unlikely that the receiver is an Array-like JavaScript object.
This suggests that we should have a version of the one-shot with no fast-path to use at call sites where we can prove the (receiver, argument) combination does not benefit from the fast path.
BUG=
R=sigmund@google.com
Review URL: https://codereview.chromium.org/1531453004 .
In response to dartbug.com/18661 and dartbug.com/21651.
Dart2js doesn't know pubspec.yaml or the directory structure but pub does. Next step is to pass arguments from pub.
BUG=
R=sigmund@google.com
Review URL: https://codereview.chromium.org/1513263002.
- Choose between single and double quotes to reduce number of escapes.
- With "uft8: true", leave most characters for the file encoding.
- LINE SEPARATOR and PAGE SEPARATOR must always be \uXXXX encoded.
- Unpaired surrogates must be encoded as \uXXXX.
- Use \xXX rather than \u00XX where possible.
R=sigmund@google.com
Review URL: https://codereview.chromium.org/1520033002 .
Refinement nodes are retained throughout the optimization pipeline.
GVN can improve refinements, so a new pass after GVN updated references
to use the best refinement in scope. For example:
x.f.g();
x.f.h();
==>
v0 = x.f;
v0.g();
v0.h();
The receiver of h() is known to be non-null after GVN because the two
uses of x.f were proven to be the same value.
BUG=
R=sra@google.com
Review URL: https://codereview.chromium.org/1519513002 .
The new instruction is expanded into low-level operations
in a new pass Finalize. The Finalize pass is mandatory.
The BoundsCheck returns the indexable object being checked
so it can be used to restrict code motion.
BUG=
R=sra@google.com
Review URL: https://codereview.chromium.org/1512303002 .
Currently we only instantiate the instruction for the null
checks inserted for numeric operators.
The corresponding instruction also exists in the tree IR,
partly because there is no way to say "x.toString" with the
current instruction set.
BUG=
R=sra@google.com
Review URL: https://codereview.chromium.org/1507313006 .
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 .