Commit graph

473 commits

Author SHA1 Message Date
Konstantin Shcheglov 4ef7fd14c1 Record Typedef reference into Kernel FunctionType and resynthesyze typedefs in Analyzer.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2986393002 .
2017-08-04 12:02:26 -07:00
Konstantin Shcheglov 60a576108c Store parts in Kernel Library, resynthesize parts in Analyzer.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2988373002 .
2017-08-03 10:36:29 -07:00
Zhivka Gucevska 115232ada2 Add support for finalizer of TryFinally in labeled statements
When a break is encountered in the body of a TryFinally statement to an
enclosing label, the finalizer statement of the TryFinally is executed.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2991113002 .
2017-08-03 16:17:17 +02:00
Zhivka Gucevska 72ba4f6c1c Add partial support for TryFinally and TryCatch statements
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2985383002 .
2017-08-03 12:51:39 +02:00
Zhivka Gucevska 5e241d86b2 Add support for 'throw' expression
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2987153002 .
2017-08-03 12:36:03 +02:00
Zhivka Gucevska dde7ce2ab0 Add components for handling of exceptions
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2988153002 .
2017-08-03 11:35:49 +02:00
Samir Jindel 454ab91576 Fix duplicate context creation when closures appear in initializers.
Summary:

Previously, when a function parameter was captured both in an initializer and in
the body of a constructor, we would create two contexts: one created in a local
initializer and used by other initializers, and another in the body of the
function. This is incorrect, as it means that changes to the parameter in the
initializer's closure won't be visible in the body.

Now, to work around this problem we re-use the context created for the
initializers in the body of the constructor by moving the body into a new
constructor, and redirecting the original constructor to that one, passing the
context as an additional argument. This dance is necessary because local
initializers aren't visible in the body of a constructor.

Test Plan:

A few of the existing closure conversion tests were changed or fixed by this
revision. We also modify the 'closure_in_initializer.dart' test to hit this case
directly.

R=dmitryas@google.com

Reviewers: dmitryas@google.com
Review-Url: https://codereview.chromium.org/2991853002 .
2017-08-03 11:33:40 +02:00
Zhivka Gucevska a04c14da7d Add support for redirecting constructors
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2984423002 .
2017-08-03 11:12:16 +02:00
Zhivka Gucevska 4aab6a4a49 Add support for super initializers in constructor initializer list
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2990943002 .
2017-08-03 09:00:16 +02:00
Zhivka Gucevska 66426a2b1c Add support for initializers in constructor invocation
This adds support for field and local initialziers
for constructor invocation.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2986973002 .
2017-08-02 12:57:23 +02:00
Sigmund Cherem e1bccfc857 FE: let targets override whether imports to internal platform
libraries (dart:_foo) are allowed.

Override this in Dart2jsTarget to allow it in the dart2js_native test suite.

R=sra@google.com

Review-Url: https://codereview.chromium.org/2992073002 .
2017-07-31 15:23:12 -07:00
Konstantin Shcheglov 66663f7fd6 Add optional FunctionType.positionalParameterNames and use them to resynthesize function-type formal parameters in Analyzer.
This will be also used as an alternative approach to support of
typedefs in Analyzer. The previous one was reverted in
e431e93e87, because it caused problems
during storing parameters of generic Function(s).

R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2985293002 .
2017-07-31 14:09:21 -07:00
Konstantin Shcheglov e64115f93f Add Class.isEnum to Kernel and use it to resynthesize enums in Analyzer.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2988113002 .
2017-07-31 10:35:03 -07:00
Konstantin Shcheglov ea876bd780 Reapply 47ecf72 after it was reverted in e431e93e87.
There was a conflict with the problematic afc392b, so it was reverted
too. But 47ecf72 per se does not cause dartk failures. This runs
without failures.

python tools/test.py -m release -c dartk --builder-tag no_ipv6 language/

R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2991993002 .
2017-07-28 09:48:51 -07:00
Erik Corry e431e93e87 Revert two Kernel changes that were causing test failures.
Example failure:
python tools/test.py -m release -c dartk --builder-tag no_ipv6 \
    language/function_type/function_type63_test

Revert "Serialize typedef parameters (including function typed ones) to Kernel and use it to resynthesize typedefs from Kernel."
This reverts commit afc392b66d.
Reverts https://codereview.chromium.org/2990783002

Revert "Add Member.documentationComment and use it to resynthesize documentation from Kernel."
This reverts commit 47ecf72272.
Reverts https://codereview.chromium.org/2990873002

Also reverts some attempts to fix test files:
302b410364
https://codereview.chromium.org/2984343002
05ccf27015
https://codereview.chromium.org/2992683002
f71dcd7834
https://codereview.chromium.org/2984363003

Also had to revert some test changes that were committed on top of a red buildbot, in order to try to get back to a place where bots were green:

23952fdf56
https://codereview.chromium.org/2990773002
557cab2a3e
https://codereview.chromium.org/2985173002

R=johnniwinther@google.com, karlklose@google.com
BUG=

Review-Url: https://codereview.chromium.org/2986093002 .
2017-07-28 14:08:23 +02:00
Konstantin Shcheglov 47ecf72272 Add Member.documentationComment and use it to resynthesize documentation from Kernel.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2990873002 .
2017-07-27 15:22:48 -07:00
Konstantin Shcheglov afc392b66d Serialize typedef parameters (including function typed ones) to Kernel and use it to resynthesize typedefs from Kernel.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2990783002 .
2017-07-27 11:53:15 -07:00
Konstantin Shcheglov f603889766 Store dependency libraries canonical names during limited store.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2991873002 .
2017-07-27 11:22:05 -07:00
Zhivka Gucevska 2331199968 Add support for field initialization in objects
Fields declared as T f = E are now initialized to the value
expression E evaluates to.
Fields without initalizer expression are intialized with null.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2985883002 .
2017-07-27 13:47:12 +02:00
Samir Jindel ff0c3936a1 Revert "Revert "Preserve type variables in closure conversion.""
This reverts commit fd4a0c658f.
2017-07-26 13:27:35 +02:00
Samir Jindel fd4a0c658f Revert "Preserve type variables in closure conversion."
This reverts commit 4d7490c609.
2017-07-26 12:44:15 +02:00
Samir Jindel 4d7490c609 Preserve type variables in closure conversion.
Summary:

Previously, we filled in all occurrences of captured type variables with either
"dynamic" or their bound, if they had one.

Now, we add extra type parameters to the top-level function corresponding to the
closure, and pass in the corresponding arguments as type arguments to the
"MakeClosure" operation.

Test Plan:

Updated [type_variables.dart] and added a new test case to it.

R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2989563002 .
2017-07-26 12:43:02 +02:00
Konstantin Shcheglov e0658b18a3 Resynthesize constructor initializers from Kernel.
We don't resynthesize assert initializers yet, because they are
compiled into an unholy mess.

R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2983413002 .
2017-07-25 09:24:13 -07:00
Zhivka Gucevska 43cf49a717 Add support for running constructors with new
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2984903002 .
2017-07-25 17:24:15 +02:00
Konstantin Shcheglov ebd3ed5ade Resynthesize mixins from Kernel.
This adds Class.isSyntheticMixinImplementation flag which is set
to 'true' for synthetic X&Y classes.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2982373002 .
2017-07-21 10:29:46 -07:00
Konstantin Shcheglov 2289ce12ae Add import dependencies to Kernel libraries and use them to resynthesize ImportElement(s) in Analyzer.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2987553002 .
2017-07-21 09:21:57 -07:00
Zhivka Gucevska 3e563c6e9e Modify class definition in interpreter according to spec:
- Populate implicit getters and setters.
 - Populate instance methods, getters and setters.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2987573002 .
2017-07-21 12:37:11 +02:00
Dmitry Stefantsov 5475240725 Add support for converted closures with explicit contexts to VM
The closure-conversion transformation is not enabled yet.  This commit
only adds the support for it to FlowGraphBuilder and
StreamingFlowGraphBuilder.  More work should be done before enabling the
transformation; most mportantly, the 'platform.dill' file that is used
in the Kernel isolate and is loaded by VM for linking with executed
programs should be separated.  The former should receive a file not
touched by the transformation, and the latter should receive a
transformed one.

BUG=
R=jensj@google.com, karlklose@google.com, kustermann@google.com

Review-Url: https://codereview.chromium.org/2891053003 .
2017-07-21 11:45:15 +02:00
Konstantin Shcheglov 1170b117c9 Remember isFieldFormal informative flag in VariableDeclaration(s).
It is informative in the same way as documentation.

Yesterday I tried to make Analyzer and Analysis Server stop using
FieldFormalParameterElement(s) and found one important use case requested
by the Flutter team. We need to show documentation of a field when
user requests documentation on the corresponding field formal named
parameter. This happens outside of the file that declares the parameter
and the field, so we don't have AST available. Of course we could
resolve the unit, but it would cost us something. And if we decide
that it is OK, then maybe we don't need to have documenation comments
in elements at all.

This is of course more convenience, and we could store documentation
and parameter to field mappings outside, like we store index. Just a
compromise - convenience vs. purity.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2983173002 .
2017-07-20 09:53:04 -07:00
Samir Jindel 239e044874 Remove dead code for closure-converting tearoffs.
This review scraps the (currently disabled) code for converting tearoffs in the
closure conversion pass.

The closure conversion pass can only ever do a partial job with tearoffs, due to
the possibility of an unconverted library tearing off a method from any object
it likes. Partially converting [PropertyGet]s makes the closure conversion pass
slower and introduces a new method for any field or method anywhere with a name
used in any [PropertyGet], inflating code size and potentially regressing
performance. As it provides no concrete value in return we've decided to scrap
this aspect of the transformation. Anyway, creating closures for tearoffs is
much easier for a backend than converting anonymous or nested functions, since
there is only one object ("this") captured. Thus ignoring tear-offs does not
undermine the value of the transformation.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2986553002 .
2017-07-20 16:47:09 +02:00
Zhivka Gucevska 0e07361eb5 Store field locations instead of values in objects
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2979293002 .
2017-07-20 10:35:26 +02:00
Zhivka Gucevska cbafc38513 Remove unused private methods in interpreter
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2978193002 .
2017-07-18 13:48:09 +02:00
Zhivka Gucevska d62ff42f0e Add support for binding 'this'
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2978893002 .
2017-07-18 13:18:54 +02:00
Zhivka Gucevska 1288ece5c8 Introduce statement continuations following the specification
The next statement to be executed is captured by a statement
continuation.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2975173002 .
2017-07-18 13:03:39 +02:00
Vyacheslav Egorov c6815e8522 Reapply 0489249d29 with a fix for front_end tests.
Proper sequencing of _asyncStackTraceHelper in Kernel

This helper function was being called before its argument was
initialized so it was passing null.  Instead, it should be called
after its argument is initialized.

Because the initialization happens in Kernel code, it is simplest to
insert the call explicitly in Kernel code as well as part of the async
transformation.  This has the consequence that we now call the helper
function even when the flag causal_async_stacks is false.

Fixes issue #29771.
Fixes issue #30178
Fixes issue #30058

BUG=
R=aam@google.com, asiva@google.com

Review-Url: https://codereview.chromium.org/2936793003 .
Review-Url: https://codereview.chromium.org/2982943002 .
2017-07-17 20:56:28 +02:00
Konstantin Shcheglov a9fbe224bc Add documentationComment for Class to Kernel. Parse it. Resynthesize in Analyzer.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2977133002 .
2017-07-15 09:53:48 -07:00
Samir Jindel a459f73fac Convert closures in all initializers, and share the context between them.
Summary:

Previously, we only handled `FieldInitializer` and `LocalInitializer`.

Now we handle all initializers.

Previously, we would create separate contexts for each initializers, which was
incorrect because it changes made to an argument from a closure within one
initializer would not be seen by a closure within another.

Now, we create the context in a `LocalInitializer` so all initializers will see
the same copy of the argument variables.

There is still an outstanding issue where variables introduced as local
initializers and later captured by closures in subsequent initializers are not
placed into the context. However, this will at least trigger an assert in the closure conversion pass.

Test Plan:

'closures_initializers/initializers.dart(.expect)' has been updated with very
simple test cases for super and redirecting initializers. The second bug
mentioned (captured local initializers) has not been reproduced yet.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2981603002 .
2017-07-14 10:59:17 +02:00
Zhivka Gucevska 77ae919a46 Rename continuations according to Kernel semantics specification
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2979843002 .
2017-07-13 10:48:08 +02:00
Zhivka Gucevska 76ff97880b Rename configurations according to specification
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2975893002 .
2017-07-13 10:09:35 +02:00
Zhivka Gucevska 8e52eea681 Modify environment binding to bind variable declarations to locations
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2980483002 .
2017-07-13 09:54:43 +02:00
Sigmund Cherem c720c776e0 Add native extension to flutter targets (this was removed accidentally in an
earlier CL, I had assumed flutter targets simply extended the VM targets).

Fixes #30118

R=ahe@google.com, zra@google.com

Review-Url: https://codereview.chromium.org/2980513002 .
2017-07-10 10:55:34 -07:00
Samir Jindel 4df146dd9a Revert "Fix closure conversion in field and local initializers."
This reverts commit a49dcb6bb1.

Committed: a7d1837d3d
Review-Url: https://codereview.chromium.org/2974673002 .
2017-07-10 10:12:45 +02:00
Sigmund Cherem b71bd543a9 Reapply "Tweak public APIs and use them in patch_sdk, dart2js, and kernel-service.""
Original CL had a bug that wasn't visible unless you delete your
out/ReleaseX64/patched_sdk folder.

Patchset #1 is the original CL, patchset #2 shows the fix.

This reverts commit 4aadfe09df.

BUG=

Review-Url: https://codereview.chromium.org/2976543002 .
2017-07-07 15:32:24 -07:00
Sigmund Cherem 4aadfe09df Revert "Tweak public APIs and use them in patch_sdk, dart2js, and kernel-service."
Reason: broke VM bots, still investigating.

This reverts commit 610d081947.

TBR= paulberry@google.com

Review-Url: https://codereview.chromium.org/2979463002 .
2017-07-07 15:21:37 -07:00
Sigmund Cherem 610d081947 Tweak public APIs and use them in patch_sdk, dart2js, and kernel-service.
This CL tweaks the public APIs in package:front_end, and
starts using those APIs outside the package. For example, this
removes 9 uses of DillTarget, so it is not longer mentioned
outside pkg/front_end and the analyzer_target.

Actual changes:
 - in package:front_end

   * added kernel_generator_impl: new file contains code that
     used to be in kernel_generator. Code has some modifications:
     it uses a single canonical-root when loading summaries, and
     it supports generating both outlines and kernel in one go.

   * removed code that didn't belong here:
     a. most of calculating deps for .GN moved to patch_sdk
     b. vm-specific outcomes moved to kernel-service

   * updated how `native` is implemented, so we can more easily
     support dart2js and ddc

   * updated how we check where `int`, `bool`, etc can be implemented.

   * added support "hermetic mode" in modular builds
     ('chaseDependencies = false' option)

   * moved `trim` step out of fasta, and for now call it only within
     the public API. This is not yet exposed, and I stopped covering it in
     most tests (now only covered in shaker tests). The plan is to add
     tests for the public API covering this in the future.

   * removed `uriToSource` when serializing outlines

   * added unit tests for public APIs

 - patch_sdk
   * use the public API to craete platform.dill, outline.dill (now
     500K insted of 3Mb because it excludes sources), and vmservice_io.dill
   * moved here logic internal to .GN

 - kernel service
   * use the public API
   * moved here logic that depends on VM internals (e.g. status enum,
     compilation results)

 - package:compiler
   * use the public API in tools and unit tests
   * simplified patched-sdk generation: no more extending fasta's internals

 - package:kernel
   * fix bug in deserialization: initializers and other lists were
     overwritten accidentally with external definitions.
   * updated unit tests, moved shared logic to frontend/src/fasta/testing

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

Review-Url: https://codereview.chromium.org/2953703002 .
2017-07-07 15:14:22 -07:00
Samir Jindel a7d1837d3d Revert "Fix closure conversion in field and local initializers."
This reverts commit a49dcb6bb1.

Review-Url: https://codereview.chromium.org/2974673002 .
2017-07-07 18:42:51 +02:00
Samir Jindel a49dcb6bb1 Fix closure conversion in field and local initializers.
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2971293002 .
2017-07-07 17:48:38 +02:00
Konstantin Shcheglov 09a5d31ec4 Add fileEndOffset to Class.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2971903006 .
2017-07-06 10:28:07 -07:00
Dmitry Stefantsov b1e629f078 Add tests for handling closures in LocalInitializers
BUG=https://github.com/dart-lang/sdk/issues/29887
R=sjindel@google.com

Review-Url: https://codereview.chromium.org/2944433002 .
2017-07-06 16:39:25 +02:00
Peter von der Ahé 6bb89e4fbf Use type variables on Typedef correctly.
R=johnniwinther@google.com, paulberry@google.com

Review-Url: https://codereview.chromium.org/2967923002 .
2017-07-05 13:12:27 +02:00