Commit Graph

96 Commits

Author SHA1 Message Date
Jens Johansen 5215ec6ef2 Revert "Non-format-changing kernel offset changes"
The commit breaks package:compiler.

This reverts commit 5edca8c4d3.

BUG=

Review-Url: https://codereview.chromium.org/2614663007 .
2017-01-05 14:19:23 +01:00
Jens Johansen 5edca8c4d3 Non-format-changing kernel offset changes
Updates to kernel that sets more offsets (and introduces end offests
and 'debuggability') - but doesn't necessarily persist them,
i.e. the format doesn't change and no C++ changes are neccessary yet.

This is step #1 in introducing these things, next step(s) will be
persisting the new stuff and using it on the C++ side.

R=asgerf@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2610133002 .
2017-01-05 13:25:46 +01:00
Asger Feldthaus 0546f6b4b7 Support generic method syntax in kernel pipeline.
Closes https://github.com/dart-lang/sdk/issues/28231
Closes https://github.com/dart-lang/sdk/issues/28238

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2613683003 .
2017-01-04 14:25:36 +01:00
Jens Johansen aecb572d76 Include source in kernel.
- For now include source uncompressed.
- When running from kernel, use token position 0
  (i.e. dummy, but 'real' position) as start and end on functions
  and classes to enable Observatory to run with the dill file.
- Debugging does not work, but one can browse the source in
  Observatory.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2587673004 .
2017-01-03 14:33:16 +01:00
Asger Feldthaus 456f9b50b6 Allocate fewer objects in dartk frontend.
TypeAnnotationBuilder and InterfaceType were being allocated
a bit aggressively.

It makes no measurable difference on runtime, but it rules out
some of these objects as potential culprits.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2581693002 .
2016-12-15 13:44:25 +01:00
Sigmund Cherem 02d557d134 Use sdk summaries in front_end/kernel_generator.
This CL adds support for using sdk summaries when building kernel using the
front_end entrypoint. I didn't expose this functionality in the dartk binary,
I'm hoping we can delay doing so until we integrate dartk and front_end.

I also switched front_end/tool/perf.dart to use kernel_generator directly.

This makes some observable difference for small scripts, but not so much with large apps like dart2js. Makes sense considering that the sdk is about 2Mb, and dart2js is 6Mb of sources.

The most interesting number I got is building the a library kernel file (not the whole program) for a small hello-world script on a warmed up vm:
no summaries: 500ms
with summaries: 30ms

R=asgerf@google.com, paulberry@google.com

Review-Url: https://codereview.chromium.org/2562923002 .
2016-12-09 13:29:41 -08:00
Paul Berry ae6fd961a1 Prepare for decoupling analyzer ASTs from element model.
This CL creates top level accessor functions which may be used to map from AST data structures to their corresponding elements and types, and begins using those accessor functions throughout the SDK.  It also adds empty interfaces ResolutionTarget and ResolutionType, which are implemented by Element and DartType respectively.

In a future CL, I will change the types stored in the AST to ResolutionTarget and ResolutionType, rather than specific element types; this will decouple the ASTs from the element model.  The presence of the accessor functions will allow clients to continue accessing elements and types in a type-safe way.

R=asgerf@google.com, brianwilkerson@google.com, scheglov@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/2551023005 .
2016-12-07 11:08:14 -08:00
Sigmund Cherem f315ae1c00 dartk: remove uses of .computeNode
As a result, this changes the order in which declarations appear in the generated output. The new order is more consistent with the textual order in the original file.

Calling .computeNode() is sort of an anti-pattern for using analyzer. This was
however used very sparsely in dartk. The few places where it was used,
computeNode was practically called immediately after resolving the library
element, so I don't expect this to make almost any difference in performance.

R=asgerf@google.com, paulberry@google.com

Review URL: https://codereview.chromium.org/2553303002 .
2016-12-07 07:42:30 -08:00
Asger Feldthaus 709c1e0b75 Store library paths relative to a given application root folder.
In kernel, library import URIs now support an "app" scheme as an
alternative to the "file" scheme, representing a path relative to
the application root.

dartk takes an --app-root flag giving the application root. If none
is given, file URIs are used instead.

The intention is that kernel binaries should not carry irrelevant
path information, such as the path to the home directory of the
user who compiled a given file.

It is not the intention that end-users should see an app URI.
Import paths are currently not shown to users at all, and if we need
to do this, they should be translated to file paths first.

In theory we could stick to file URIs with relative paths, but the Uri
class from dart:core makes this difficult, as certain operations on it
assume that file paths should be absolute.

Source mapping URIs are not yet affected by this change.

R=kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/60adb852ad706ecf9424c77d47fa05583d543def

Review URL: https://codereview.chromium.org/2532053005 .

Reverted: https://github.com/dart-lang/sdk/commit/bb540416f27c39d75ee7f243899939fc37a2cd03
2016-11-30 10:39:48 +01:00
Asger Feldthaus 440813c67b Check that invocations have well-formed targets in kernel verifier.
This also fixes some issues in the frontend and transformers that
generated calls without the correct number of type arguments.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2533793005 .
2016-11-30 08:24:03 +01:00
Asger Feldthaus bb540416f2 Revert "Store library paths relative to a given application root folder."
This reverts commit 60adb852ad.

BUG=

Review URL: https://codereview.chromium.org/2539783002 .
2016-11-29 14:55:57 +01:00
Asger Feldthaus 60adb852ad Store library paths relative to a given application root folder.
In kernel, library import URIs now have the "app" scheme instead of
the "file" scheme, representing a path relative to the application root.

dartk takes an --app-root flag giving the application root. This
defaults to the current working directory.

The intention is that kernel binaries should not carry irrelevant
path information, such as the path to the home directory of the
user who compiled a given file.

It is not the intention that end-users should see an app URI.
Import paths are currently not shown to users at all, and if we need
to do this, they should be translated to file paths first.

In theory we could stick to file URIs with relative paths, but the Uri
class from dart:core makes this difficult, as certain operations on it
assume that file paths should be absolute.

Source mapping URIs are not yet affected by this change.

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2532053005 .
2016-11-29 12:40:17 +01:00
Asger Feldthaus 963e1ebc55 Do not sort named parameters on FunctionNode.
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 .
2016-11-25 11:22:37 +01:00
Asger Feldthaus f13881ac08 Fix the pubspec and warnings in pkg/kernel.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2530543002 .
2016-11-23 14:36:22 +01:00
Asger Feldthaus acc8975cab [kernel] Store named parameters in sorted lists instead of using maps.
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 .
2016-11-16 15:16:24 +01:00
Asger Feldthaus e63a33717e [kernel] Fix some strong mode issues.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2464843002 .
2016-11-14 10:23:37 +01:00
Asger Feldthaus 37c5809ccc [kernel] Always store the type of a conditional expressions on the node.
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 .
2016-11-01 16:04:10 +01:00
Asger Feldthaus f764b34682 [kernel] Introduce Substitution class and Supertype class.
Type annotations in the supertype clauses of a class are now Supertypes
instead of InterfaceTypes. In the current version, the two classes
contain the same information, but they are about to diverge in the
following ways:

- An InterfaceType may be nullable, whereas a supertype cannot.

- An InterfaceType may represent the exact class, a subclass, or
  a subtype of the given class.

- The type arguments to an interface type represent bounds, whereas
  the arguments to a supertype are always exact.

We also introduce a class Substitution that represents an operator
that replaces type parameters with types, depending on the variance
of their use site.

A substitution can be applied to a DartType or a Supertype, and can
be generated independently of how it will be applied.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2439043002 .
2016-10-24 16:21:52 +02:00
Asger Feldthaus becc43a03c [kernel] Add null initializers to fields that have no initializer.
That is, if a field has no declaration-site initializer and at least
one constructor in the class does not initialize it, then we add an
explicit null initializer for it.

BUG=
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/527827014 .

Committed: https://github.com/dart-lang/kernel/commit/63c241ee69fb41710b66df106626461539ce0187
2016-10-18 12:55:10 +02:00
Asger Feldthaus d90deb1491 [kernel] Revert "Add null initializers to fields that have no initializer."
This reverts commit 63c241ee69fb41710b66df106626461539ce0187.

BUG=

Review URL: https://codereview.chromium.org/2431623002 .
2016-10-18 12:26:08 +02:00
Asger Feldthaus 8f836aef2e [kernel] Add null initializers to fields that have no initializer.
That is, if a field has no declaration-site initializer and at least
one constructor in the class does not initialize it, then we add an
explicit null initializer for it.

BUG=
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/527827014 .
2016-10-18 12:14:33 +02:00
Jens Johansen 1048f55a29 [kernel] Don't emit InvalidExpression on invalid super in binaryexpression
Don't emit invalidexpression on invalid super call --- a correct call will be created later

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/524077013 .
2016-10-14 13:49:51 +02:00
Asger Feldthaus 5f31eff8bd [kernel] Type parameter bounds default to Object instead of dynamic.
This also affects the textual output in most cases, since the bound
is now shown explicitly.

BUG=
R=jensj@google.com

Review URL: https://chromereviews.googleplex.com/526827013 .
2016-10-11 15:21:48 +02:00
Asger Feldthaus f8b0846bc5 [kernel] Do not compile patched SDK in strong mode when using VM target.
The VM patch files are not strong mode clean, so we're using a hybrid
approach where the SDK is internally unchecked, and is trusted to
satisfy the types on its interface.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/516487014 .
2016-10-07 15:40:46 +02:00
Asger Feldthaus 9b25e445ed [kernel] Follow redirecting factories to their effective targets.
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 .
2016-10-07 13:34:14 +02:00
Asger Feldthaus ad049ce479 [kernel] Ignore fields inserted through error recovery.
Fields without names often arise when the analyzer fails to parse a
union type in a type argument inside a comment. For example:
  Future/*<Foo|Bar>*/ future;

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/519077015 .
2016-10-06 12:59:52 +02:00
Asger Feldthaus ea2ddd0882 [kernel] Fix canonicalization of mixin classes.
A mixin application C<T1 ... Tm> with D<T1 ... Tn> is canonicalized if
the Ts are distinct, unbound type variables. In all other cases, a new
class is created per mixin application.

Previously, all mixin applications were canonicalized in an overly
general way, causing type checking issues, and excessive duplication of
type parameters.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/511567015 .
2016-10-04 17:45:24 +02:00
Asger Feldthaus 120c8c3998 [kernel] Erase function type parameters to fake strong mode on the VM.
The VM does not support function type parameters at the moment, but we
can erase them at the last minute, to enable testing of other parts of
strong mode.

This also disables error checking in the SDK since the VM's
patch files are not in strong mode.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/518647013 .
2016-10-04 17:28:45 +02:00
Asger Feldthaus 564970c10e [kernel] Refactor frontend to allow modular compilation.
The concept of a binary library file no longer exists.

A kernel file can contain any number of libraries, and some of these
libraries can be "external".  To reference a class or member from
another build, the class or member must be declared in an external
library.

Members in an external library contain all their type information,
but have no body.

Classes in an external library have their hierarchy information
present, but are not guaranteed to contain all their actual members.

The idea is that references themselves don't really cross module
boundaries, but rather refer to a local definition whose body is
contributed from elsewhere, much like 'external' members in Dart.

A modular backend such as DDC should be able to compile from one of
these kernel files without needing to load auxiliary information from
summaries or other kernel files.

For whole program transformations or backends, a linking step, which
is not yet implemented, must merge classes and members in external
libraries based on their name.

External libraries share the same IR and binary format as ordinary
libraries.  Transformations that affect the interface for a member
or class should transform the external libraries alongside with the
internal ones, ideally without needing to treat them any different.

R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/516847013 .
2016-10-04 13:30:46 +02:00
Asger Feldthaus 91febfc627 [kernel] Insert break or throw at the end of a switch case that may fall through.
BUG=https://github.com/dart-lang/kernel/issues/12
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/510567013 .
2016-09-30 12:25:07 +02:00
Jens Johansen 43b8443f0d [kernel] Dill source file and source position inclusion
For now the focus is on getting stacktraces to look right.
What that basically means is to include source positions for throws,
calls (in many forms).

Includes source file uri for libraries, field, classes and methods.
Methods and fields for instance needs it because of top-level
procedures that might be included via 'parts'.

Corresponding kernel-sdk change in review at
https://chromereviews.googleplex.com/516617014

R=asgerf@google.com, kasperl@google.com

Review URL: https://chromereviews.googleplex.com/509247013 .
2016-09-29 11:26:40 +02:00
Asger Feldthaus fe5a26f264 [kernel] Treat an arrow body in a void method as void context.
BUG=https://github.com/dart-lang/kernel/issues/31
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/511307014 .
2016-09-29 11:08:28 +02:00
Martin Kustermann 44a70d3534 [kernel] Mixin desugaring: Clone constructors from base classes, rewrite super initializers
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/510377013 .
2016-09-27 12:19:42 +02:00
Asger Feldthaus 6fec4ee7a5 [kernel] Fix a bug in DartOptions.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/515767013 .
2016-09-23 17:51:00 +02:00
Asger Feldthaus cd60bb203f [kernel] Ensure class type parameters are not referenced from static context.
BUG=https://github.com/dart-lang/kernel/issues/16
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/510207013 .
2016-09-23 16:33:12 +02:00
Asger Feldthaus 795ce44ec7 [kernel] Refactor the frontend classes.
dartk and other command-line tools no longer rely on analyzer classes
like AnalysisContext or DartSdk, and instead use only the interface
defined in loader.dart.

The class AnalyzerLoader has been renamed to DartLoader.

The sharing of state in batch mode is now owned by loader.dart, so
dartk.dart does not deal with DartSdk and package_config.

Repository no longer has a package or SDK path. These concepts are
now specific to the Dart frontend. Consequently, loading a binary
file no longer relies on URI resolution.

The Repository class is now more clearly focused on linking symbolic
names to their IR objects, which for the time being is only
URI-to-library bindings, but should be extended to support linking
class and member references across different files and different
loaders.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/512907013 .
2016-09-23 16:11:41 +02:00
Asger Feldthaus a91cae8bb4 [kernel] Remove the ?? operator from the IR and desugar it in the frontend.
Note that this affects the binary format, since a type is no longer
stored on LogicalExpression.

R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/502297014 .
2016-09-23 12:52:00 +02:00
Asger Feldthaus e5423f6251 [kernel] Read in -D defines and pass them on to the frontend.
This also enables configuration-specific imports when using a newer
version of the analyzer (not currently on pub).

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/515727013 .
2016-09-23 12:28:33 +02:00
Asger Feldthaus 492e65b68e [kernel] Support .packages file.
BUG=https://github.com/dart-lang/kernel/issues/27
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/508267014 .
2016-09-22 14:18:18 +02:00
Martin Kustermann 99b1be4d09 [kernel] Add support for passing --url-mapping=<scheme>:<name>::<url> to dartk
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/507527013 .
2016-09-22 13:16:08 +02:00
Martin Kustermann a4a3ad3961 [kernel] Use InvalidInitializer() for initializers with compile-time errors
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/508347013 .
2016-09-22 13:05:16 +02:00
Asger Feldthaus c323d3608a [kernel] Set constructor body to an empty statement if its body was omitted.
BUG=https://github.com/dart-lang/kernel/issues/28
R=johnniwinther@google.com

Review URL: https://chromereviews.googleplex.com/512727013 .
2016-09-22 12:15:42 +02:00
Jens Johansen c6d1d01738 [kernel] Fix of saving expression in function body.
Creating a redirecting factory constructor to an abstract class
creates a throw expression directly in function.body.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/506587013 .
2016-09-21 08:26:35 +02:00
Asger Feldthaus b02cdaccf7 [kernel] Report more errors.
Include up to 100 errors in the output, and print the number
of errors that were truncated.

Also report errors from the SDK and package files.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/506077014 .
2016-09-13 13:16:05 +02:00
Asger Feldthaus 7890404af4 [kernel] Print errors in a nicer format.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/508597013 .
2016-09-13 12:41:22 +02:00
Asger Feldthaus 5711977941 [kernel] Forward scanner and strong mode errors from the analyzer.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/507827013 .
2016-09-13 12:23:51 +02:00
Asger Feldthaus 204a0f9b19 [kernel] Fix unresolved access on class or library prefix.
An unresolved `C.name` would be translate to `this.name` in non-static
contexts.  It is now translated to throw a NoSuchMethodError.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504977014 .
2016-09-09 17:47:31 +02:00
Asger Feldthaus 8ef3abbb09 [kernel] Fix initialization of type parameter bounds on mixin applications.
There was a circularity issue with type parameter bounds being copied
from other classes, while those classes we not yet fully initialized.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/499437013 .
2016-09-09 13:21:29 +02:00
Asger Feldthaus 93299997e3 [kernel] Insert dynamic when type arguments are omitted from redirecting factory.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/500317013 .

Committed: https://github.com/dart-lang/kernel/commit/9d9d61ec4649b159ed3bbe1c2a486d98e7bf07ea
2016-09-08 16:08:43 +02:00
Asger Feldthaus 9a3c54e0e9 [kernel] Revert "Insert dynamic when type arguments are omitted from redirecting factory."
This reverts commit 9d9d61ec4649b159ed3bbe1c2a486d98e7bf07ea.

BUG=

Review URL: https://chromereviews.googleplex.com/502317013 .
2016-09-08 15:35:20 +02:00