Commit Graph

4153 Commits

Author SHA1 Message Date
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 bbd22cb8ff Changes that slipped through rebasing
Change-Id: I7d40fe0c5bc360fb154d3490e134125265ab366d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103132
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-05-22 06:32:26 +00:00
Johnni Winther 09b46aa084 Support in-memory CodegenResult serialization/deserialization
The serialization/deserialization is performed in test-mode.

Change-Id: I90f31a6a88dbdf2c38beb9b5409ce3c52557e227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102740
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-20 08:57:39 +00:00
Johnni Winther c69d0c6e30 Flatten DynamicUse and StaticUse class hierarchies
Change-Id: Ib325425dfab7d7001a1a6133df1d50dddfadcbab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102700
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-20 08:57:39 +00:00
Johnni Winther 6757d0c6d9 Use ModularNamer/ModularEmitter to generate code separate from codegen enqueuing
Change-Id: I35dc4c0370622c63f2100e22517149cb0629423e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102367
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-20 08:57:39 +00:00
Johnni Winther a9827a0c05 Refactor OneShotInterceptorData to prepare for modular codegen
Change-Id: I52d47c28978c0d935d07b438520728a304d311d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102365
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-20 08:57:39 +00:00
Johnni Winther c0b967d7da Refactor Namer and ConstantEmitter to prepare for modular compilation
Change-Id: I2fa8928d7c7d845df2507c9ad034107ec4bc21de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102364
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-20 08:57:39 +00:00
Johnni Winther 670ac1aca8 Prepare js_ast for more advanced use of DeferredExpression
Change-Id: I008dc7ce21437475c2fa1d5505b42f9d4a4aa166
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102363
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-20 07:46:58 +00:00
Johnni Winther 0db620a2a5 Decouple Namer from RuntimeTypesEncoder and Tracer
Change-Id: I1c52b6740b590b1089201c3d0d8286d8e0912c48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101824
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-05-10 08:58:29 +00:00
Johnni Winther 5ce8402b0d Handle let variable like normal variables in static type computation
Change-Id: Ie6eb1eafd5677207163e22c2f428487b4e55b090
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101522
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-08 12:12:40 +00:00
Johnni Winther 27d806b5a2 Add CodegenResult as the result of FunctionCompiler.compile
+ delete CodegenWorkItem
+ remove use of WorkItem in the compilation pipeline

Change-Id: I035fb8428b7bbdea9411c087e80c81e3d46d00c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101662
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-08 08:15:59 +00:00
Johnni Winther 0e2e186262 Add ModularNamerImpl
To use for modular codegen. Creates ModularName and ModularVariableUse
for naming decisions that need to be deferred to world-impact application
time.

The class is still unused, awaiting refactoring of world-impact application.

Change-Id: I7d4d30da587ccf814b2d879b26f76de2eb3ca276
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101525
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-08 08:15:59 +00:00
Johnni Winther 25213cdc1e Extract ModularEmitterImpl superclass from EmitterImpl
Change-Id: I7e7a87743d24e5da6401937b3983a358062a2296
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101523
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-08 08:15:59 +00:00
Johnni Winther 6c6954c1ee Add ModularNamer and ModularEmitter super-interfaces
- to use in ssa builder, optimization and codegen pipeline.

Change-Id: I214c17d5994aa0afa86007b2c3add1491c000b08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101521
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-08 08:15:59 +00:00
Johnni Winther 9e90424749 Decouple startup emitter from compiler/backend
Change-Id: I5220cbf6c6ce6369787b2eed33e952dc694128a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101294
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-07 07:57:06 +00:00
Johnni Winther 3d7405f198 Separate CodegenImpl from JavaScriptBackend
Change-Id: I9644ca0cd6cb60bf20142d7fa74a559dc516a22d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101292
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-07 07:57:06 +00:00
Johnni Winther 1c1af2808f Introduce Codegen interface to decouple JavaScriptBackend from the codegen phase
Change-Id: I7effc20d34fa5d5da799c690182eb6f09948c6ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101288
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-07 07:57:06 +00:00
Sigmund Cherem 9ac7bd7855 Ensure we have a scope for variables when visiting fields
Fixes https://github.com/dart-lang/sdk/issues/36864

Change-Id: I66d70cc30b26bd069d4ab5e2b98f0f5954f3ef59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101460
Auto-Submit: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-05-06 21:43:42 +00:00
Johnni Winther 28faf8c7ca Merge GraphBuilder into KernelSsaGraphBuilder
+ avoid use of `compiler` and `backend`
+ make members of KernelSsaGraphBuilder private when possible

Change-Id: Ia069a8c3b4167c1ae55554baadb857975aeff67f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101287
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-06 08:53:24 +00:00
Johnni Winther 5b569a62d2 Remove code for supporting for generating code with compile time error
We don't support that currently and if we want to at some point in the future,
I'd rather implement it from scratch, and the current implementation tightly
couples various parts of the compiler to the `Compiler` object.

Change-Id: I6934df41bb363ea9a693a8181b5a0355774ba4b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101286
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-06 08:53:24 +00:00
Johnni Winther ba3dba3a00 Remove JavaScriptConstantTask and JavaScriptConstantCompiler
Change-Id: I85faab292604b977de2812a6530f7e3403d870bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101285
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-06 08:53:24 +00:00
Johnni Winther 102f4addda Include the static type in the receiver type of dynamic invoke
- and preserve the original receiver type information during type propagation updates.

Change-Id: I20087b282a3d018947043d7a3ab7c45f003eaee6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100966
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-03 07:52:22 +00:00
Johnni Winther 8053c43dde Compute static types for for-in loops
Change-Id: I47e98eaf6df7d04286cb737bfdff135e6c0d34d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100843
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-01 14:06:39 +00:00
Johnni Winther 8d4816b7ff Reimplement member usage tracking
We now track member usage in terms of static, dynamic and super access
for reads, writes and invocations. The information collected during
closed world computation is now the basis for the potential member usage
in codegen, thus ensuring that we cannot conclude in codegen that for
instance a field is read dynamically when the closed world knows that
it is never read dynamically.

Closes #36516

Change-Id: I3a1cb87c71268c34bcd67e14a035d9d1be324ab0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100840
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-05-01 08:58:34 +00:00
Johnni Winther 7e0d76c5dd Compute BuiltWorld properties from member usage
Change-Id: I8a58d303c1c699aae2d6fe3a6dfdc43547b003a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100640
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-04-27 13:47:06 +00:00
Johnni Winther a1dd732ec6 Extract WorldBuilder results into an immutable BuiltWorld object
For resolution this is the KClosedWorld and for codegen this is the new
CodegenWorld object. This change removes the use of the world builders
after the world building has ended. It prepares for computing more of the
result data from the collected member usages.

Change-Id: I80032e3fc0e29179137b8c0380f09f68ab6fa03b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100540
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-04-26 07:52:58 +00:00
Johnni Winther 5fc8029587 Remove StaticMemberUsage and cleanup codegen world builder
Change-Id: I4fdc6148af671010d1aca55c05d08e55e9c1e9fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100245
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-04-25 08:45:20 +00:00
Johnni Winther c4ab0d2014 Inline create methods in JsKernelToElementMap
Change-Id: I911c7c81056f07dd15c23162489bbcd8bda5d05b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100221
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-04-24 06:57:16 +00:00
Johnni Winther 58ff41ad33 Add test for static tear-off
- to document the change (for the better) with CFE constant

Change-Id: I9b6673497fe07ccd4f92fc4c22df0ae3205f72a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99152
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-04-16 07:06:12 +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
Mayank Patke b9cbb679f3 [dart2js] Add --experiment-new-rti flag.
This flag doesn't affect any behavior yet, but we can start implementing
the new RTI system behind it.

Change-Id: I8c6ae6c60a97394c628f68876e086d455a815ca1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98925
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2019-04-11 18:38:48 +00:00
Mayank Patke 919461badd Ensure boolified SSA nodes are non-null first.
Fixes https://github.com/dart-lang/sdk/issues/34147.

The Dart language specification says we should ensure booleans are
non-null in the following (non-exhaustive) situations:
* (ternary) conditional expressions - this includes the `!` operator
since `!x` is equivalent to `x ? false : true`
* arguments to logical boolean expressions (`||` and `&&`), modulo
short-circuiting
* `if` conditions
* `for` loop conditions
* `while` conditions
* `do`/`while` conditions

With control-flow-collections enabled, this CL will also cover
conditions in `if` elements and `for` elements. Tests for these already
exist in
language_2/control_flow_collections/{if,for}_null_condition_test.dart.

Change-Id: I2ce9a30adeb16a0a68411f358f69aeca08656dab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98780
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-04-10 00:28:10 +00:00
Johnni Winther 45a5349175 Track constant field initializers for field analysis.
Change-Id: I536975d235cbf7722b03aa7b0e2c9edd7c206484
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98852
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-04-09 16:30:27 +00:00
Johnni Winther 4fc0e1f13d Use .nullType as type of null and fix null type handling in getStaticTypeAsInstanceOf
The .getStaticType results for NullLiteral and NullConstant are inconsistent. The former returns `const BottomType()` and the latter return `TypeEnvironment.nullType`.

To avoid this inconsistency and since `const BottomType()` is really the "unreachable" type, used for instance of for the type of a throw expression, the implementation is changed to consistently use the .nullType.

For this to work, getStaticTypeAsInstanceOf (and the equivalent dart2js implementation), and the `Type.fromStaticType` constructor in the VM type flow analysis have to special case the .nullType.

Change-Id: If6b806d4a39ef7b906275c43fa2089b9d140523b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98563
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-04-09 06:49:17 +00:00
Aske Simon Christensen a069ddda21 [CFE] Produce InstanceCreation from unevaluated constructor invocation.
Thread assert enable flag through in dart2js to make the dart2js cfe
constant evaluation unit test properly pass the flag.

Fixes https://github.com/dart-lang/sdk/issues/36454

Change-Id: Ie4ac86ce96feda1548120fed54ece9ca03387496
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98570
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-04-04 12:22:50 +00:00
Mayank Patke 2f77af1c6f Fold identical(double.nan, double.nan) => false in dart2js.
Change-Id: Idc6b064e330af71bbc8525a48874d332d84f404a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98607
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2019-04-03 21:14:31 +00:00
Sigmund Cherem 35f45cf3f1 Remove _mainLibraryUri, replace with user-code-locations
This prepares the compiler to accept a modular mode that contains several
libraries as user-code locations

Change-Id: I04f6c1fe36eea23de79b3573855896c560996fe1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98457
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2019-04-03 19:34:41 +00:00
Sigmund Cherem 5fffa99993 Add helper method to clear batch-mode state
This is minor clean up step before adding modular support.

Change-Id: If06333d89c0484e76bfe51e60e344791c3a61be3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98456
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-04-03 19:34:41 +00:00
Johnni Winther 93d0e8279a Include liveness of type arguments in supertypes in RTI needed checks computation
Including supertypes (and not just superclasses) this time.

Change-Id: Ib398f6f2fab0ae502dd754727b482641793dd225
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98569
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-04-03 15:03:46 +00:00
Johnni Winther 78fca5b2fa Include liveness of type argument in supertypes in RTI needed checks computation
Change-Id: Ifdde3e8694f8d39ccf10cac0d5dc2cb3cb9225bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98560
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-04-03 10:23:53 +00:00
Mayank Patke 335a854696 Implement JavaScript semantics for frontend constant folding.
Change-Id: I8232d0f5875d8471d8110582c44fc9d9b8a735f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98240
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-04-02 22:37:46 +00:00
Sigmund Cherem c26f1c6bf7 Do not assume stack trace is not null
Change-Id: Ib795cfdbcf9599f7e4bc2688b9a965f50c0b7c3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98421
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2019-04-02 00:02:53 +00:00
Johnni Winther 1a3e8dda3b Handle nested unevaluated constants in constant evaluator
The constant evaluator assumed that any ConstantExpression met during evaluation of a sub expression was not an unevaluated constant. This do occur, for instance when a field is initialized to an unevaluated constant. With the change, unevaluated constants met during evaluation are themselves evaluated.

This change also fixed handling of assert initializers in unevaluated constants.

Change-Id: Id9e676f40bc829c4d234f34a74ef0ca5c4c6ec48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98348
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-04-01 14:29:32 +00:00
Johnni Winther 05dd851566 Test late CFE constant evaluation.
Tests that dart2js can handle evaluation of unevaluated constants from CFE, including handling of potential compile-time errors found during evaluation.

The CL fixes a bug in the constant evaluator where it created map literals that were not marked as constant as needed.

Change-Id: I7df77a3c68e52392a143478b3567d19e09ebe6bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98347
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-04-01 13:05:52 +00:00
Johnni Winther 7ef28f0b03 Handle constant field init registration correctly.
+ avoid side-effects of checking enqueuer invariants

Change-Id: Id327371bc70e4b1b5fd4d326b8c8cf8caf50ea0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98142
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-03-29 16:44:15 +00:00
Johnni Winther da0de0a867 Handle native field impact correctly from ir constants
Change-Id: I0393fd57b78c7cb417888ec3e0ff139b888bf3a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98322
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-03-29 16:41:55 +00:00
Johnni Winther 05f3b12960 Add test for native declarations
Change-Id: Iea9d8d27e6fdefa6f47471a459cdb4363aab65e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98011
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-03-28 10:29:11 +00:00
Johnni Winther b978fdd142 Move experimental flag defaults to CFE
Change-Id: I9f1890f349fb19bbd792af071adc14ad4e50c364
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98010
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-03-28 10:19:51 +00:00
Johnni Winther 7baae76480 Always use ir constants in annotations when constant-update-2018 is enabled
Change-Id: Ib5ba6a908904c36a8580f6f47424b6982800dddd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98002
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-03-28 09:34:21 +00:00
Johnni Winther 10abacba10 Use hasOnlyNonDeferredImportPathsToConstant to add deferred constants
Change-Id: Ifd8b733c526fe4e7ae837a7d17c682e91717feb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98013
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-03-28 09:17:31 +00:00