Commit Graph

133 Commits

Author SHA1 Message Date
Johnni Winther f889bd7067 Delete JavaScriptBackend
* move names to Identifiers
* move resolution parts to front end strategy
* move codegen parts to backend strategy
* remove now unneeded methods from FrontendStrategy and BackendStrategy

Change-Id: I0675d56045dd212ad195177ecd23b27b0d849a80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105742
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-06-13 10:09:46 +00:00
Sam Rawlins b22cd05c51 Reland fix for #28233: add hint for missing returns to function expressions
The bulk of this change is actually correcting missing returns in the Dart SDK.

Bug: https://github.com/dart-lang/sdk/issues/28233
Change-Id: I52bcbc6c6f4a129d3fc22003f4448a7c3d4487ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100301
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-05-22 18:12:30 +00:00
Johnni Winther 394f88d5cf Create source information from ConstantExpression
(now that it has a fileOffset)

Change-Id: I057ca3cf04a941ccdb03a6d8ca58947650b1cbec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99161
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-04-12 07:37:17 +00:00
Nate Bosch f2579a8ede Add override annotations in dart2js tests
In preparation of enforcing these in the analysis options.

Change-Id: I316f2efea510ecc8ff1b975e96d166a5f8c0286c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96834
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-03-14 00:15:46 +00:00
Johnni Winther ea6e83004b Use @pragma instead of package:meta/dart2js in tests
Change-Id: I16c0ed6f391a417d8faa55e68cde902d91e3db32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95220
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2019-03-06 08:32:05 +00:00
Johnni Winther 204651f3ab Replace package:expect annotations with @pragma
Change-Id: Ib43d0d71a3ee8b0f0e6d676e6a3e448a107b7ca5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95180
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2019-03-05 11:00:17 +00:00
Johnni Winther 013cf68624 Replace js_helper annotations with @pragma
@ForceInline is still used by dart:html, will be removed in a later CL.

Change-Id: I480325fe91cc6baefb17ead49f839442e023d441
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95160
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2019-03-05 08:56:18 +00:00
Johnni Winther 60e4f194b0 Recognize and inline effectively constant fields
Change-Id: I243ee80ebc45d9cdab2f7c944cf5eceb26185b2c
Reviewed-on: https://dart-review.googlesource.com/c/93436
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2019-02-22 14:06:05 +00:00
Johnni Winther 33bc628235 Treeshake unread fields
Change-Id: I188df5fd18163e5b32213a364d0fc163300db7b9
Reviewed-on: https://dart-review.googlesource.com/c/92130
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-02-07 09:58:19 +00:00
Johnni Winther c591454dd3 Inline unprovided optional parameters
Change-Id: I61c82216965062feee8e01ba2533d0ea7c0052ef
Reviewed-on: https://dart-review.googlesource.com/c/90700
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-02-07 08:44:49 +00:00
Sigmund Cherem a1ff5f7cd5 Ensure inlining of getter/setters is recorded in our source-map extension
Change-Id: I6eac59f756b2a6a87842e5a4b1d8aa47df619042
Reviewed-on: https://dart-review.googlesource.com/c/88580
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-01-10 23:40:28 +00:00
Sigmund Cherem 6c2d8bc8c1 Record getter and setter names in the minified-name table
Change-Id: I373babecdf3ccece386483d5aa4fcde320675b80
Reviewed-on: https://dart-review.googlesource.com/c/87480
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-12-18 22:05:18 +00:00
Sigmund Cherem b484aada21 Remove library-root option - replace it with a libraries-spec option instead
Change-Id: Ie1df52cdaa7ab4381a4c1b94c61a1210f0f31b5f
Reviewed-on: https://dart-review.googlesource.com/c/83641
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2018-11-09 22:40:28 +00:00
Sigmund Cherem 61df5fdec8 Encode dart2js source-map extensions in strings.
This reduce the memory footprint and cost of parsing these extensions.  Another
advantage is a reduction on the size of the .map files.  On a large customer
app, this was a 11% reduction, and the frames section was about 1Mb (excluding
the extra names and uris added on the existing tables).

The encoding works as follows:
 - minified names are written as a list of names and indices, in pairs.

    {'n1': 1, 'n2': 2} => 'n1,1,n2,2'

 - frames are encoded using a sequence of values with markers for the different
   kind of frames. Numbers are encoded using VLQ deltas. We use VLQ because it's
   already available to any parser that deals with the mappings).

This change also uses the dart2js_tools parser implementation for all unit tests.

Change-Id: Iacc2833c6517eb473955cc618adec501c610870f
Reviewed-on: https://dart-review.googlesource.com/c/82780
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2018-11-05 18:24:33 +00:00
Johnni Winther 73eadf53c2 Move JsClosedWorld and JsClosedWorldBuilder to their own libraries.
Change-Id: I5bf75fcb443a591d460fd9e0f7c2258e345fff40
Reviewed-on: https://dart-review.googlesource.com/c/82640
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-11-02 17:34:33 +00:00
Johnni Winther 556dd9a345 Add support for serialization on command-line
Change-Id: I4fa85c3e06e1f142265cecff83ff1b8db74bfe65
Reviewed-on: https://dart-review.googlesource.com/c/82445
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-11-02 14:12:18 +00:00
Johnni Winther 843b4c9c23 Refactoring to prepare for serialization
- pipes GlobalLocalsMap, ClosureData and OutputUnitData through JClosedWorld

Change-Id: Id1d8353a9c75217aab7e06a276bfb503f50a5811
Reviewed-on: https://dart-review.googlesource.com/c/79683
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-10-17 12:05:05 +00:00
Stephen Adams f96362ccfd [dart2js] Smaller code by caching values
- Move more that one assignment into var-list
- Move 'this' to a local variable
- Move repeated large 'fast' constants to local variable

Currently under flag --experiment-code-1


Change-Id: I091cab47f498b4ec3759b9ed358bcc0f2e73fdb1
Reviewed-on: https://dart-review.googlesource.com/c/77025
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-10-08 17:40:19 +00:00
Johnni Winther cf5cdea808 Add J/K versions CommonElements and ElementEnvironment
This is a step towards separating the element map implementations.

Change-Id: Iaf8cee48bd0c127a981b1661773d9036b419fecf
Reviewed-on: https://dart-review.googlesource.com/75300
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-09-20 07:37:32 +00:00
Johnni Winther db1570bdcd Split element maps for J/K further
* The J model is in the /js_model/ folder and KernelToElementMapForBuilding is renamed
  to JsToElementMap.
* The K model is in the /kernel/ folder and KernelToElementMapForImpact is renamed
  to KernelToElementMap.
* Code shared between JsToElementMap and KernelToElementMap is in the /ir/ folder using
  the interface IrToElementMap internally.
* KernelToElementMap and JsToElementMap do _not_ implement IrToElementMap so all code
  that is not part of the implementation must explicitly use one or the other.
* Both KernelToElementMap and JsToElementMap extend KernelToElementMapBase
  but this will be changed in a follow-up.

Change-Id: Id6b762984d25354477cb099dc2f8301b83a7ba07
Reviewed-on: https://dart-review.googlesource.com/73382
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-11 11:10:37 +00:00
Johnni Winther 6616ddeb88 Move dart2js unittests to subfolders
* All helpers in /helpers/
* Tests of user-facing behavior in /end_to_end/
* Tests of internal models and unittests of internal classes in /model/

Change-Id: Ic7a7e58aa01f92f8572514ae81230804f36af67e
Reviewed-on: https://dart-review.googlesource.com/72644
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-10 08:22:53 +00:00
Johnni Winther 3af2f793ac Remove --no-preview-dart-2 from dart2js
Change-Id: I17a18ebe905fa60ba2a1b41af2f444cfe58a38a2
Reviewed-on: https://dart-review.googlesource.com/70512
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-08-20 09:18:02 +00:00
Johnni Winther e4bd67028f Make minified test work on Windows
Change-Id: If484387147aa7b60915238f9fff4f11973ac941e
Reviewed-on: https://dart-review.googlesource.com/69940
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-08-16 14:46:57 +00:00
Keerti Parthasarathy b99e41ac6f Revert "fix #28233, add hint for missing returns to function expressions"
This reverts commit 058510eeab.

This causes a lot of missing_return failures internally and requires time to fix.

Change-Id: I2c7a79c6e838bbd9f101f53919b1db2c0d4a2594
Reviewed-on: https://dart-review.googlesource.com/70024
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2018-08-14 21:10:27 +00:00
Stephen Adams 4196c0e2f5 Fix dart2js/sourcemaps/minified_names_test
TBR=sigmund@google.com

Change-Id: Ie48333f2bfa9352c7ff787acc00dc12aa5c97cd5
Reviewed-on: https://dart-review.googlesource.com/68846
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-08-08 00:01:57 +00:00
Sigmund Cherem cb7341fceb Initial support for inlining-data in source-maps.
This starts tracking inlining data and records it as an extension
to source-map files so we are able to expand inlined calls when
deobfuscating production stack traces.


Change-Id: I46daf21c2f42305b2bd6ca17fbafb65226355096
Reviewed-on: https://dart-review.googlesource.com/67083
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2018-07-31 21:41:50 +00:00
Jenny Messerly 058510eeab fix #28233, add hint for missing returns to function expressions
If a function expression is used in a context that expects a return type
other than dynamic/void/Null, issue a hint if that function has a block
body and is missing a `return` statement.

Change-Id: Ia55212abd84f5718343cf7401b87aba2891d6446
Reviewed-on: https://dart-review.googlesource.com/66340
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-07-28 01:50:31 +00:00
Sigmund Cherem 1566b0dbc1 Add tests for nsm errors
Change-Id: Ib215299c4229641d0b62edc099f5834c5d894d99
Reviewed-on: https://dart-review.googlesource.com/66080
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2018-07-23 17:10:49 +00:00
Sigmund Cherem e3b5bfd854 Store original names in the minified name map
Change-Id: I411125aebe08fee10f1eeee4e6f30623cb0d7854
Reviewed-on: https://dart-review.googlesource.com/65795
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2018-07-20 23:50:45 +00:00
Sigmund Cherem 35b08dec12 Add minified names to sourcemaps
This change:

* introduces a sourcemap extension to store minified names from the global and
instance namespaces.

* adds a test suite to test that this information is accurate

This is just an initial step: at this time names come from proposed names, which
include extra stuff we don't want. On a later CL I plan to change this to be
able to get the original name instead.

For example, I want to add a test for translating an instance method, right now
we would get "@method@0@" or "method$0" instead of "method".

Change-Id: I411c3bea96446e29e80581750250349799332b9a
Reviewed-on: https://dart-review.googlesource.com/65660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2018-07-19 18:50:27 +00:00
Peter von der Ahé 389b8997b3 Update dart2js extra test wrt. void rules
Change-Id: Ic83252a27fc90dd2d19b799d09c0bc4b111a1caf
Reviewed-on: https://dart-review.googlesource.com/65501
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2018-07-18 09:48:19 +00:00
Mike Fairhurst 21258299d7 Reland "Fix #32227 export dynamic from dart:core in analyzer."
This reverts commit d3b4ba3a0b.

Reason for revert: Previous breakage was related to overly strict tests.

Original change's description:
> Revert "Fix #32227 export dynamic from dart:core in analyzer."
> 
> This CL caused a breakage in angular code generation.
> 
> This reverts commit 6f965a94e2.
> 
> Change-Id: Id066661930b9531cdd32a0d38e71f70fe73ece75
> Reviewed-on: https://dart-review.googlesource.com/63680
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,scheglov@google.com,brianwilkerson@google.com,mfairhurst@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: If0a03148db5e88724f3498a1fa2d46a9c42d7f1f
Reviewed-on: https://dart-review.googlesource.com/64120
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2018-07-09 22:30:49 +00:00
Johnni Winther 5dbf6da529 Remove generics where only ir.Node is used
Change-Id: I500b237a871ee21aca1a800806cdc95828713b5c
Reviewed-on: https://dart-review.googlesource.com/63944
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-07-06 22:02:57 +00:00
Johnni Winther da9705b356 Split compileLoadedLibraries
- into computeClosedWorld, performGlobalTypeInference and generateJavaScriptCode
+ pass closed world and inference results directly
+ this prepares for (de)serialization after global inference

Change-Id: I1180de35eea78a107c9e95fc6e904084b63ba0f2
Reviewed-on: https://dart-review.googlesource.com/63943
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-07-06 22:02:57 +00:00
Paul Berry d3b4ba3a0b Revert "Fix #32227 export dynamic from dart:core in analyzer."
This CL caused a breakage in angular code generation.

This reverts commit 6f965a94e2.

Change-Id: Id066661930b9531cdd32a0d38e71f70fe73ece75
Reviewed-on: https://dart-review.googlesource.com/63680
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-07-03 19:50:26 +00:00
Mike Fairhurst 6f965a94e2 Fix #32227 export dynamic from dart:core in analyzer.
Assign dynamic to dart:core in NamespaceBuilder & LibraryScope

This seems to be the best two places to hit up all cases. We need two to
handle the case of where code imports dart:core, vs code that is itself
the definition of dart:core.

Includes a member sort of compile_time_error_code_kernel_test, so that
pollutes the diff a bit, but not importantly so and its good to get that
sorted.

Bug: 32227
Change-Id: Ibe620f4b66a35d088355f36da042a5d82380772c
Reviewed-on: https://dart-review.googlesource.com/62730
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-06-29 19:24:41 +00:00
Johnni Winther 7c6211b1d8 Make unittests work with Dart 2
Change-Id: Ic2c105747dfba067464fc15e158f58417c8636a8
Reviewed-on: https://dart-review.googlesource.com/61922
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-06-22 20:25:05 +00:00
Stephen Adams 5ccc497678 Inline constructor bodies that are called once
Change-Id: I74b2518fed543a78f1531b54510f4dcbe3a57192
Reviewed-on: https://dart-review.googlesource.com/60324
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-06-20 22:12:02 +00:00
Sigmund Cherem c96f23243b Enable Dart2 in dart2js by default
Change-Id: Id197fc734bcb45f0805e49e89c0d03419384bb0b
Reviewed-on: https://dart-review.googlesource.com/60448
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2018-06-19 19:20:36 +00:00
Sigmund Cherem 0cf860f361 Remove pub_build_validity test
Now that `pub-build` is gone, this is no longer needed.

Change-Id: Ie3b7e6c3e2e50fc43bcf6601387e9e839d3b6ff8
Reviewed-on: https://dart-review.googlesource.com/60321
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2018-06-14 22:57:35 +00:00
Stephen Adams 2c8c05f877 [dart2js] merge generator body into empty entry function
Change-Id: I99a5f16f9a22d3c3cbb4989151a8d3c7bfda16ef
Reviewed-on: https://dart-review.googlesource.com/56037
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-05-22 21:17:44 +00:00
Johnni Winther 54331b1c4b Delete elements.dart and resolution_types.dart
Change-Id: Ib50dabdbeec72ebf443e85b51b818d9ed0602b4f
Reviewed-on: https://dart-review.googlesource.com/55221
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-05-16 09:54:18 +00:00
Johnni Winther 47a67b2b8f Delete AST nodes
Change-Id: Iab9396b3a21cd9502c455fb73633216faed777ef
Reviewed-on: https://dart-review.googlesource.com/55126
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-05-16 09:54:18 +00:00
Sigmund Cherem c25a9fd46b Remove support for dart:isolate in dart2js.
Change-Id: I1216a0ac91d8a1d13b441809596e1a8b5e51bb34
Reviewed-on: https://dart-review.googlesource.com/54526
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-05-10 01:20:17 +00:00
Stephen Adams 6efd3b3654 Refactor output code for generators
sync*/async/async* generators have two parts: an entry, which does
checks and computes the element type of the result, and a body, which
is transformed after lowering to JavaScript.

The split ensures that the code for checks is done at function call
time, rather than e.g. in the moveNext method of a sync* iterator.

A following CL with optimize the split to generate one function when
there are no checks and the type argument is simple enough for textual
substitution.

Change-Id: I5414109ca851f9267871aa113a2e29b16236986d
Reviewed-on: https://dart-review.googlesource.com/54308
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2018-05-09 18:22:07 +00:00
Johnni Winther 4c7926107e Remove support for --use-old-frontend option
Change-Id: Ia6e7ded5e312cce4841ded8170fc01a51f07b098
Reviewed-on: https://dart-review.googlesource.com/54229
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-05-09 09:11:01 +00:00
Johnni Winther 17e22dfcd3 Remove unneeded kernel tests and sourcemap old-frontend tests
Change-Id: Iaf9533a812df5c872f223bce17ec7127f0b46318
Reviewed-on: https://dart-review.googlesource.com/54200
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-05-09 07:55:08 +00:00
Johnni Winther 831a6ba598 Remove useOldFrontend testing from various tests
Change-Id: Iff97dd60756ae18cb0a3203cffd87c8da9e53757
Reviewed-on: https://dart-review.googlesource.com/53944
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-05-08 08:31:43 +00:00
Johnni Winther 235b81d045 Remove MockCompiler
Change-Id: I476cb39f8fed068d7c47a15486419783f599a285
Reviewed-on: https://dart-review.googlesource.com/53806
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-05-07 10:07:40 +00:00
Johnni Winther 794fe1e14f Add stacktrace tests for synchronous async
Change-Id: Iafd66528f9ea3d7a301dc4845118ca16517e235f
Reviewed-on: https://dart-review.googlesource.com/53206
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-05-03 08:09:33 +00:00