Commit graph

69133 commits

Author SHA1 Message Date
Sigmund Cherem d735f1f12d (dart2js): enable new-rti by default
This change:
* adds the `--use-old-rti` flag to revert to the old behavior
* enables the new behavior by default
* changes the -rti- builders to run the old rti instead of the new rti
* documents the change in CHANGELOG.md

I've kept around the logic as `useNewRti` to avoid swapping all the conditions
in the compiler.

Change-Id: I773ac33b658cb60f72e0b6beef83375abec31bad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127492
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2020-01-04 00:44:25 +00:00
Mike Fairhurst 6e7a900283 [nnbd_migration] Fix ConditionalModification on IfElement
Change-Id: I1e8ec4bead2aaa9147850d27cd5ac4d9c2a700be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130137
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-01-03 23:47:50 +00:00
Konstantin Shcheglov be4acb4cd5 Remove duplication in checking elements in TypeNameResolver.
R=brianwilkerson@google.com

Change-Id: I36b81e80057cab05e5c12818cc19edd53f5071c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130135
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-01-03 23:39:55 +00:00
Mike Fairhurst 2f453dcf5a [nnbd_migration] handle yoda conditions with null literals
Change-Id: Id848e71e22c2adb2e96a372dde1e1d8fffe87805
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130136
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-01-03 23:39:47 +00:00
Mike Fairhurst 610c1e41a0 [nnbd_migration] handle Object better, to fix void -> Object assignments
Change-Id: Ibd2fa86578e76dc79f402cae2a21b01223af90aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130127
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-01-03 22:02:31 +00:00
Mayank Patke 4bc01d0dd4 [dart2js] Treat type variable bounds checks as implicit is-tests.
Change-Id: I19e26c1d16f9515b9307073318532c6467af5cf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130126
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-01-03 21:47:29 +00:00
Konstantin Shcheglov 4f2a9e083d Resolve MethodInvocation fully in MethodInvocationResolver.
So, it is not separated into ElementResolver and StatisTypeAnalyzer.

Change-Id: I413a71b703ab93304760e1f912c3d55585411397
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130132
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-01-03 21:40:19 +00:00
Konstantin Shcheglov c913b01ec0 Report error during constant evaluation for ForElement.
R=brianwilkerson@google.com, pquitslund@google.com

Change-Id: Ic87094ed1dcfb4e630e3e62b9ed7e7ec8feab2c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130133
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-01-03 21:18:59 +00:00
Alexander Markov 0380d3a90e [vm/compiler] Do not use specualtive unboxing for Phi instructions in AOT
When inserting Unbox instructions in SelectRepresentations pass, their
speculative mode depends on the instruction which uses corresponding
value. Phi instructions were using default kGuardInputs mode, which may
cause insertion of speculative Unbox instructions in AOT mode.
Such Unbox instructions may need deoptimization if type of an argument
changes during optimizations. Generating code for such Unbox
instructions causes assertion failure (in debug mode), or crash in
release mode.

The fix is to change speculative mode of Phi instructions in AOT, so
they won't cause speculative Unbox instructions.

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

Change-Id: Ic9c9957875fd775fe1c02f3666829f26dad64937
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130063
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-01-03 21:15:19 +00:00
Mike Fairhurst 0e0bc8e1a6 [nnbd_migration] Save enum index getter in the node builder
Change-Id: I1714244a18471f0ac489a2bf7a4de2e6b5c0c3cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130102
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-01-03 20:21:49 +00:00
Johnni Winther 969fa962da [analyzer,cfe,dart2js] Do not generate annotations for empty values.
Change-Id: I0efa6287a44e340f9dc242b4ffc84fc8723e1049
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129718
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-01-03 20:12:39 +00:00
Mike Fairhurst 44e3627f29 [nnbd_migration] Support mixins, specifically super on a mixin.
Change-Id: Ia0d61b8faebfba22933af8d8f902e272b27d4f6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130060
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-01-03 19:21:49 +00:00
Ben Konyi bba2bed3a4 [ package:vm_service ] Export dart:io service extensions through package_vm_service
Change-Id: I62bbd8b73bc92a748c23d26eaa6f9c063b927661
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130125
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-01-03 18:47:59 +00:00
Mark Zhou a0393edd6a Inlining list copy in Queue.toList.
Change-Id: I2fdf9a780365b52ebea9810752e053cd94b5bfe0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130100
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2020-01-03 18:26:59 +00:00
Alexander Markov ff43a04d77 [vm/compiler] Fix crash in StringInterpolateInstr::Canonicalize
If OSR happens while calculating an argument of string interpolation,
array of arguments may be Phi and not CreateArray instruction.
In this case, canonicalization of StringInterpolate should gracefully
return instead of crashing. Such OSR may happen due to control flow
collections.

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

Change-Id: Ibf35a0f0ebb20d5a44102f7ddfd4e91925d7c6ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129900
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-01-03 18:26:19 +00:00
Konstantin Shcheglov b94bad1fca Check for MigrationResolutionHooks directly in StaticTypeAnalyzer and ResolverVisitor.
I want to extract invocation inference into a separate helper, and
perform MethodInvocation resolution as a single step inside
MethodInvocationResolver. So, I want to set `Expression.staticType`
in several places. Using special subclass of StaticTypeAnalyzer does
not fit this intention.

I think `is` check is JIT optimizable well, and during analysis
we will have just one type of ElementTypeProvider.

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

Change-Id: Ie718db35ac9426b35b538b92a2e2177828ae7ad8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-01-03 17:40:19 +00:00
Nicholas Shahan 02369211cc [tests] Update test expectations
- Migrated test now expects `null is Object` to be false.
- Added expectations for `is! Object`.

Change-Id: I99c5dc76d2ccfa5a9fd853b7745b58edfff07085
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129309
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-01-03 17:32:29 +00:00
Martin Kustermann addd5eea00 [vm/compiler] Consistently use pc-offsets of pointing to instruction after call in static calls table, to ensure unique offsets
The pc-relative calls were recorded with pc-offsets pointing to the start of the
call instruction, where as code-based calls were recorded with
pc-offsets pointing to the next instruction (i.e. return address).

This is inconsistent and caused us to hit an assert in
`Code::set_static_calls_target_table`. The assert was benign, but it is
good to maintain the uniqueness guarantee in the static calls table, so
we'll unify the encoding to use offsets to the instruction after the
call in both cases.

Closes https://github.com/dart-lang/sdk/issues/39811

Change-Id: Id0305befd78f09ed0b0e100f39641bca9e764442
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129717
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-01-03 17:17:59 +00:00
Ben Konyi a3be4afe8d [ package:vm_service ] Added methods to allow for HttpClient.enableTimelineLogging to be set via package:vm_service
Change-Id: Ice35290cfafbd29e4d47c75ce73030fb82d1b7dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130123
Reviewed-by: Kenzie Schmoll <kenzieschmoll@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-01-03 16:28:29 +00:00
Konstantin Shcheglov 3e961f4e91 Stop using assertHasTestErrors() where possible.
R=brianwilkerson@google.com

Change-Id: I0ab8d2afd27c3a18d4fd49cb0e3864078cc163ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130121
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-01-03 16:12:49 +00:00
Danny Tuppeny becc97c8a2 Show parens in LSP workspace symbols for methods/functions
Change-Id: I7f428eefbc4783dcd0ec3c2f16ed1e9d1ef7a903
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129714
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-01-03 15:49:39 +00:00
Danny Tuppeny 2678ee01ac Don't include end of comment markers in TODO range
Fixes https://github.com/Dart-Code/Dart-Code/issues/2181.

Bug: https://github.com/Dart-Code/Dart-Code/issues/2181
Change-Id: I670f8f46ef60d09ec3f1fd743084734048f3cfc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129440
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-01-03 15:48:09 +00:00
Konstantin Shcheglov a23a3db99c Remove unnecessary climbing up when reporting non-type element.
R=brianwilkerson@google.com

Change-Id: Icfbd1feec08fb0ff2e988e70a4aa5112cf3f6ae5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130101
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-01-03 15:30:39 +00:00
Konstantin Shcheglov 91341dd0b7 Remove _checkElementOfType().
I think we don't need it anymore.

Change-Id: I50b9cc4c0bd3693a7172a2e71cd24096708fd0db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130122
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-01-03 15:29:49 +00:00
Johnni Winther 679705faf6 [cfe] Include nullability in implicit tearoff
Change-Id: If350915c13840c06d9fb2191972edf52758de252
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129287
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-01-03 15:19:29 +00:00
Johnni Winther fdf362e9bb [cfe] Replace isImplicitCall with ExpressionInvocation node
Change-Id: I05ebe260b9f35cacf59390963da9d0c39ede2096
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129286
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-01-03 15:19:29 +00:00
Samir Jindel 445ae73b32 [vm/tfa] Use pragma to pass type arguments to exact return types.
Change-Id: Ie2a1de07653c53e8b9506c54a0a66a5fe6503b9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129160
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-01-03 14:08:19 +00:00
Johnni Winther e3a20bf361 [analyzer,cfe,dart2js] Support annotated code generation
Add support for generating annotations from actual data using
option -g

Change-Id: I88d9cdb62a38d579234b15097c9e9bb3d81ebe8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129708
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-01-03 13:57:39 +00:00
Alexander Markov c33405bb47 [vm/tfa] Cleanup unused entry points json files
Entry points json files were replaced with pragma annotations a while
ago. This change removes these unused files.

Change-Id: Ib7d80b79f1afb63a05aca9a25e8ec6fc9ba72941
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130040
Commit-Queue: Samir Jindel <sjindel@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2020-01-03 12:17:19 +00:00
Sigmund Cherem 4eae39672a (dart2js) release some data-structures after resolution.
The resolution-world-builder and impact transformer were holding onto a
class-hierarchy-builder in dart2js, which uses a lot of space.

On a some artificial sample apps with thousands of classes this
reduces the overall memory capacity by 25%. On a large internal app
this reduced the overall memory capacity from 13G to 11G.

Change-Id: I5d0d40764649364f2cd2411ef1346812beb411c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129544
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-01-03 00:24:08 +00:00
Mayank Patke b5bf014eb1 [dart2js] Add redirections for unneeded native classes in ruleset.
Change-Id: Ic29686447c87b7707480a161e76ab500c1455617
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130011
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-01-03 00:11:27 +00:00
Mayank Patke a62e63f0cc [dart2js] Add new RTI impact for is-tests and type checks.
Change-Id: Ib93def2db9b4f0d4ee5aab843c0a894129e773e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130082
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2020-01-02 23:58:17 +00:00
Nicholas Shahan 98635636d7 [dartdevc] Cleanup violations of always_declare_return_types lint
This change does not enable the lint yet because there are many more violations
in the test and tool directories. I'm going to clean those up in a separate
change.

Change-Id: I8a7f9a9004d329db5ba34030cc8aa8e20d07f3ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130012
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2020-01-02 23:23:06 +00:00
Ryan Macnak 5804537b83 [vm, timeline] Following switch from Duration events to Begin-End event pairs, avoid separate native call transitions to query the monotonic and thread clocks.
Bug: https://github.com/dart-lang/sdk/issues/39727
Change-Id: Ie38947c63845f13d660cb4a367681fed31796473
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128564
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-01-02 23:13:06 +00:00
pq 2d7235c14d typos
Change-Id: Idbbd0ad4d6097f7c1c5a70de5f3fa4c2d13ff2c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2020-01-02 23:09:17 +00:00
asiva 01c9c18d24 [VM/Runtime] Propagate error from Loader::InitForSnapshot instead of asserting
Change signature of Loader::InitForSnapshot to return an error and check
for this error when initializing an isolate. This should fix the flaky
crashes reported in https://github.com/dart-lang/sdk/issues/39950

Bug:39950
Change-Id: I564b2f8f924378c156f5bb22238a760be187f8b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130041
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-01-02 23:00:36 +00:00
Nicholas Shahan 2f57602411 [dartdevc] Update is, as, and _check methods for null safety
Change-Id: I67e97c988a0c7a0e9d04e84e85c07152f8f35306
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129202
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-01-02 22:29:16 +00:00
Mark Zhou 3aa23f8091 [dartdevc] Removing nullability wrappers from const __proto__ fields.
Change-Id: Id56a082f8077ab16080d7ad3450075a858777527
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129812
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2020-01-02 22:14:56 +00:00
pq d35e94c8ae Validate incompatible lint rules
Change-Id: Ic57cdf7c7264c7d4da266f73a63b0b47e4a1d65a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130007
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-01-02 22:07:56 +00:00
Mike Fairhurst 29e89f512d [nnbd_migration] Fix return Bottom from async function.
Change-Id: I4de22568a5540d9796f4668ad3d69dfb2a15109c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129818
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-01-02 21:58:16 +00:00
Ryan Macnak f6677c3862 [vm, service] Account for image pages in the capacity reported by heap snapshots.
The VM does not include image pages in its usual accounting of heap usage and capacity because they are immortal and don't contribute to marking or sweeping work. The heap snapshot does include objects on these pages, so it should include the pages in its notion of usage and capacity, otherwise the heap-snapshot can effectively claim it has more usage than capacity.

Fixes negative fragmentation reported by the heap snapshot page.

Change-Id: Ib9f3c395ee5a6e51ee9b4c9a834843851426910d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128565
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-01-02 21:26:59 +00:00
Mike Fairhurst c89c373e87 [nnbd_migration] handle enum values getter
Change-Id: I268ced7d3a002ff41dc1e75b6a376acb3af88fa0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129541
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-01-02 21:18:11 +00:00
Konstantin Shcheglov 219282fe5b Extract individual assists / fixes into separate classes.
I noticed that assist_internal and fix_internal have 3500+ and 5000+
lines, and base_processor seems doomed to repeat their fate. If we
could keep separate assists and fixes in separate classes and libraries,
we could isolate their specific machinary of helper classes and methods.
And maybe even improve code with time.

This CL is a proposal for a way to do this.

We share CorrectionBuilderContext across multiple producers, so overhead
is small - only creating producer instances and setting the context.

I considered separating assists and fixes into corresponding directories,
but when we have shared builders, we would need to put builders into
yet another directory, and have three libraries that are named
similarly - xyz_builder.dart, xyz_assist.dart, xyz_fix.dart... Not nice.
So, hopefully we don't have accidential name collisions.

R=brianwilkerson@google.com, pquitslund@google.com

Change-Id: Iacf0b27a40227645f249e69921f2b8d9bfe1d5ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129820
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-01-02 21:06:33 +00:00
Ben Konyi f3d5be08f1 [ package:vm_service ] Fix issue where TimelineEvent.toJson always returned an empty map
Change-Id: I009fbbc23a9decf344a9cfd0873c9e8a54c8a7ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130010
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Kenzie Schmoll <kenzieschmoll@google.com>
2020-01-02 20:28:48 +00:00
Nate Bosch 113ff6c993 Enforce that allowInterop is used in DDC
Fixes #39074

DDC emits Dart code that can usually be called with the same semantics
as JS there is no guarantee that a function passed to JS and then
invoked successfully was wrapped with `allowInterop`. The wrapping is
always required in Dart2JS. To make DDC more strict, add interceptors
that check for the usage of `allowInterop`.

Whenever a JS interop function or setter is passed an argument which is
statically typed as a Function, but not wrapped with `allowInterop` at
the call site, wrap it with `assertInterop` which will check the
argument at call time and fail with a clear error if it was not wrapped.

Whenever a JS interop function is torn off, either at the top level or
from an instance, wrap it with a function that will also inject these
checks at runtime.

There are still holes where we can't catch the mistake:
- An argument which is statically dynamic and a Function at runtime
  won't be caught.
- A Function which is stored in a collection won't be caught.
- A JS interop definition where a getter returns a Function which takes
  a Function as an argument is not checked.
- A dynamic call through to javascript is not checked.

Changes:

- Refactor `_isJsLibrary` and add `isJsMember`, and `isAllowInterop`
  utilities to determine what needs wrapping.
- Update `assertInterop` to give a more clear error when it fails, and
  to ignore non function arguments.
- Add `tearoffInterop` to wrap a function an ensure that any function
  typed arguments are wrapped.
- Inject `assertInterop` around Function arguments passed to JS methods.
- Inject `assertInterop` around Function arguments passed to static or
  instance JS setters.
- Inject a runtime wrapper around static or instance Function tearoffs.
- Add a test covering all flavors of checks that are supported.
- Change the interop expando to an `Expando<dynamic>` in the NNBD SDK to work
  around a stricter type check. https://github.com/dart-lang/sdk/issues/39971

Potential improvements:

If the `tearoffInterop` turns out to be too heavy, we could loosen it so
that we only wrap methods if any of their argument types are statically
declared to be a Function.

Change-Id: Ibc92df5b54e1a041b4102a07b8398b774b6bd1d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128462
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-01-02 20:24:26 +00:00
Konstantin Shcheglov df98317c42 Report unchecked nullable for explicit / implicit 'this' in extensions.
R=brianwilkerson@google.com

Bug: https://github.com/dart-lang/sdk/issues/39875
Change-Id: Ia0e5b9ea736428cd40d8898e48e0db605deebacd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130042
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-01-02 20:17:07 +00:00
Konstantin Shcheglov dbaeb9a6d9 Use NullableDereferenceVerifier in ErrorVerifier.
R=brianwilkerson@google.com

Change-Id: I0adc88b5e6874d2834f904da175757bdbd78772c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130009
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-01-02 19:45:24 +00:00
Konstantin Shcheglov d5c4099d1b Remove BUILT_IN_IDENTIFIER_AS_TYPE error code for 'addAsync' quick fix.
We report UNDEFINED_IDENTIFIER_AWAIT instead.

R=brianwilkerson@google.com

Change-Id: I9950e4a332b2a4f28232a36631f2f809d14068cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130008
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-01-02 19:44:09 +00:00
Alexander Markov ad12931304 [vm/compiler] Remove PushArguments from ThrowInstr, ReThrowInstr
Issue: https://github.com/dart-lang/sdk/issues/39788
Change-Id: Ic47d3b57a35182162848df61495f8963afd55fc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129321
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-01-02 19:41:46 +00:00
Alexander Markov 2477378537 [vm/compiler] Refactor PolymorphicInstanceCallInstr
This change hides InstanceCallInstr inside PolymorphicInstanceCallInstr
and makes sure that PolymorphicInstanceCallInstr owns its arguments
(which would become critical once call arguments become instruction
inputs).

Also, PolymorphicInstanceCallInstr now extends TemplateDartCall which
makes it possible to avoid duplication of methods related to all calls.

Issue: https://github.com/dart-lang/sdk/issues/39788
Change-Id: Ie3d4ff46a8e99a0988ba88a88ca9a60be8503ce0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129307
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-01-02 19:09:36 +00:00