A new AST node 'ClosureCreation' is added. It takes a name of a
top-level function, a context, and a closure function type and creates a
closure of the given type. The effect of this closure invocation is the
same as of the invocation of the given top-level function with the
contexts as the first argument.
In order to use 'ClosureCreation', the closure conversion pass now
transforms closures into top-level functions, not closure classes. These
functions receive the context as the first argument.
The type of the expression represented by 'ClosureCreation' is its third
parameter. It its the responsibility of closure conversion pass to
create the correct types for 'ClosureCreation' nodes based on types of
closures transformed into top-level functions.
R=asgerf@google.com
Review-Url: https://codereview.chromium.org/2778223002 .
There are four operations that work on Vectors: Vector creation, looking
up an item in a Vector, assigning a value to an item in a Vector, and
copying a Vector. The first three operations are allowed to only use
integer literals as number operands (length for Vector creation, index
for item lookup and assignment). Corresponding AST nodes are created for
these operations.
Vectors are used to represent contexts in Closure Conversion. The parent
context is stored as item 0 in its children contexts. The "golden" tests
for this transformation are adjusted accordingly.
The support for Vectors is added to ast-to-text, ast-to-binary, and
binary-to-ast transformations.
R=asgerf@google.com, kmillikin@google.com
Review-Url: https://codereview.chromium.org/2767773004 .
All generic methods are equipped with one extra named parameter for
passing type arguments as a list of type values.
Additinally, this change forces strong mode usage for 'dartk' in
'reified_dart'. Strong mode is required for loader to not strip away
type arguments from generic methods. In future, a command line argument
may be implemented for that (e.g. --generic-methods), if generic method
support will land before the strong mode.
R=karlklose@google.com
Review-Url: https://codereview.chromium.org/2713163002 .
This CL adds the work done at https://github.com/dart-lang/reify to SDK.
The commit that is used for the merge is
a2066a68374d49de92ff75f5e1ffc36335fd9451 (Nov 23, 2016). The code is
adjusted to respect the changes of the kernel package in SDK since that
commit.
The reify transformation is run by specifying 'vmreify' target to
'dartk'. The transformation requires its runtime library to present in
the program being transformed. The library is found in its default
location in SDK checkout if 'dartk' is run from its default location in
SDK checkout. To preserve the library in the output, TreeShaker is
disabled in 'vmreify' target.
The "golden" set of tests is also copied from 'dart-lang/reify'
repository, and the appropriate test suite is defined for it.
The bash script 'bin/reified_dart' from 'dart-lang/reify' is rewritten
as Dart script 'pkg/kernel/bin/reified_dart.dart'. It requires path to
'dartk' and path to SDK. Those are taken from their default locations in
SDK if 'reified_dart.dart' is run from its default location in SDK.
The added files were formatted using 'dartfmt' with default settings.
Additionally, the files were checked with 'dartanalyzer --strong'. The
necessary changes were made to fix the error messages. There are some
'hint' and 'error' messages left for some .dart files from the added
test cases, but they reflect intentional errors or conventions in those
files.
R=asgerf@google.com, karlklose@google.com
Review-Url: https://codereview.chromium.org/2697873007 .
The redirecting factory List:: is currently removed and replaced with the actual target at the callsites during construction of kernel, but referencing the actual target here would make the transformation platform specific.
R=asgerf@google.com
Review-Url: https://codereview.chromium.org/2637083002 .
"Covariance checks" are checks on certain parameters, necessary due to
the unsafe covariant subtyping rule for interface types.
The new pass generates a checked entry point for each method with
covariance checks. This entry point checks the parameters whose type
cannot be trusted, and then calls the actual method implementation.
Every typed call is then redirected to the checked entry point if the
interface taget declares any parameters with unsafe types, unless the
receiver is 'this'.
Dynamic calls and covariant overrides are not addressed by this CL,
these are still unchecked.
BUG=
R=kmillikin@google.com
Review-Url: https://codereview.chromium.org/2618393002 .
This is the result of:
- taking the diff of the branch closure_conversion to master in the kernel
repository
- updating the file paths
- applying the diff to the Dart SDK
- fixing conflicts between the changes to pkg/kernel in the Dart SDK and the master branch in the kernel repository
R=asgerf@google.com
Review-Url: https://codereview.chromium.org/2561723003 .
This was originally done to be consistent with FunctionType,
where the named parameters are sorted, but for FunctionNode
it is not necessary.
It causes issues for natives that expect parameters to be
declared in a certain order. It is also an issue if we
ever want to reuse the kernel format for summaries, where
it is also preferable to present the named parameters in
their original order.
BUG=
R=kmillikin@google.com
Review URL: https://codereview.chromium.org/2527933002 .
FunctionType now has a List<NamedType> which must be sorted by name.
Previously, named parameters were stored in a Map<String, DartType>.
FunctionNode still has a List<VariableDeclaration>, but this list must
now be sorted by name.
BUG=
R=ahe@google.com
Review URL: https://codereview.chromium.org/2502343002 .
Previously, the type of a conditional expression could be omitted if
one of the arms was just a null literal. This was meant to simplify
translation into kernel, but wasn't really worth it in terms of
complexity, and it does not work well for types that carry nullability
information.
BUG=
R=ahe@google.com
Review URL: https://codereview.chromium.org/2465263002 .
This is a piece of the upcoming strong mode-based type propagation.
The new type propagator will build its inference graph based on the
subtyping constraints found during type checking.
This type checker is not intended to report type errors to end-users.
In its current form, it is quite redundant with the front end's type
checker, but this will not be the case once we augment kernel's type
system.
The internals of "dart:" libraries are not type checked -- they are
simply assumed to satisfy the type annotations on their interfaces.
BUG=
R=kmillikin@google.com
Review URL: https://codereview.chromium.org/2465893002 .
Previously, we would generate a stub for a redirecting factory, but
the default parameter values were not correctly forwarded.
This could have been fixed by copying the default parameter values into
the stub, but this conflicts with modular compilation, since the
element model does not expose default parameter values, and we should
not rely on the AST of libraries not part of the current build unit.
Apart from fixing this bug, this is also more aligned with how all the
backends actually work.
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/513577013 .
A single suite of test files is now shared among these configurations,
each with their own expected outputs:
- spec mode
- strong mode
- spec mode w/ type propagation
Although some tests are going to focus on a specific configuration,
for now it seems easier to maintain a single set of tests.
No additional tests have been added in this CL, but the intention
is to start adding more tests.
The baseline tests no longer contain any checked-in dill files.
To simplify dependencies, these tests do not rely on a patched SDK,
which means the async transformer cannot currently be tested with
this framework.
BUG=
R=kmillikin@google.com
Review URL: https://chromereviews.googleplex.com/507347013 .