Commit graph

21558 commits

Author SHA1 Message Date
Sam Rawlins c0b5d99d82 Do not report BODY_MIGHT_COMPLETE_NORMALLY for setters
Fixes https://github.com/dart-lang/sdk/issues/42303
Change-Id: I4b0f6ac1f446c22eec278b3421a41e4176864e13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212720
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-09-08 16:07:13 +00:00
Erik Ernst 02b2e6c23f Adjust explicit_instantiation_syntax_test
This test used `..` as a continuationToken (that is, it did not expect
a syntax error for `g(C<int, int> .. toString())`). This CL changes the
test to expect that to be a syntax error, and also eliminates the
static warning caused by using `?.` on a receiver with a known non-null
value (that's not relevant to the topic of this test, I just didn't
avoid it when the tests were written).

Change-Id: I275de6423710c3a598bedd2f54f4e9e7463a6d04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212587
Auto-Submit: Erik Ernst <eernst@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-09-08 06:51:34 +00:00
Alexander Markov 16e8dc257e [vm] Faster double.floor()/ceil()/truncate() in AOT mode (x64, arm64)
1) double.truncate() now simply calls toInt(), omitting
truncateToDouble() call.

2) double.floor() and ceil() are now intrinsified on arm64 and AOT/x64
and generated using DoubleToInteger instruction.

3) DoubleToInteger instruction is extended to support floor and ceil.
On arm64 DoubleToInteger is implemented using fcvtms and fcvtps
instructions. On x64 DoubleToInteger is implemented using roundsd
under a check if it is supported (with a fallback to a stub and a
runtime call).

AOT/x64:
Before: BenchFloor(RunTime): 318.82148549569655 us.
After:  BenchFloor(RunTime): 133.29430189936687 us.

TEST=ci
Closes https://github.com/dart-lang/sdk/issues/46876
Closes https://github.com/dart-lang/sdk/issues/46650

Change-Id: I16ca18faf97954f8e8e25f0b72a2bbfac5bdc672
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212381
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-09-07 19:52:04 +00:00
Sergey G. Grekhov c14d66253c [co19] Re-enable fixed tests
This CL re-enables (except on platforms that don't support them):
Language/Libraries_and_Scripts/Scripts/top_level_main_t01
Language/Expressions/Numbers/syntax_t34

Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try,dart2js-nnbd-linux-x64-chrome-try,ddc-nnbd-linux-release-chrome-try,front-end-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I10a1b1c9abc125c000cc9e9ba7d749b8766e193d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212563
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2021-09-06 17:30:57 +00:00
Ahmed Ashour f1ded6af56 Remove import dart:core
Fixes #47092

TEST=existing

Change-Id: I3c5c0a1ec5e0426642a5dc70aa9a0391a143ed93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212298
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-09-06 11:57:40 +00:00
Daco Harkes f21b7cafbc [vm/ffi] Adds param number in trampoline null error
Before: `NoSuchMethodError: The method 'FfiTrampoline' was called on
null.`
After: `Invalid argument(s): argument value for ':ffi_param2' is null`.

Makes the ArgumentNullError RTE lookup the name of the argument in the
code source map when reporting a null argument.

Makes the FFI call arguments and FFI callbacks use kArgumentError
instead of the default kNoSuchMethod so that we target this RTE instead.

This changes the Error type from `NoSuchMethodError` to `ArgumentError`.
Because `Error`s should not be caught [1], this is fine.

Since FFI trampolines are created from type arguments, the arguments do
not have names. The arguments are assigned names programmatically. See
the related bug.

Also, this CL cleans up the SourcePosition of the `CheckNullOptimized`,
it was never passed.

[1] https://dart.dev/guides/language/effective-dart/usage#dont-explicitly-catch-error-or-types-that-implement-it

TEST=tests/ffi/function_test.dart

Closes: https://github.com/dart-lang/sdk/issues/47094
Bug: https://github.com/dart-lang/sdk/issues/36780

Change-Id: I15e7de4d026e034bde0eda3ba7fe3785f0da5057
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,app-kernel-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212462
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-09-04 07:22:03 +00:00
Alexander Aprelev 7495184e2f [vm/gardening] Fix static_function_test to accommodate closure passing.
TEST=lib/isolate/static_function_test

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

Change-Id: I4ad552c35297230123574dee5451ab83b731f406
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212489
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-09-03 22:44:28 +00:00
Martin Kustermann e9b56794fc [vm/compiler] Make closures have no context if no variables are closed over
As a side-effect of making closures without captured variables have an
empty context, we not only avoid a memory leak, but also allow such
closures to be sent across [SendPort]s.

Issue https://github.com/dart-lang/sdk/issues/36983
Issue https://github.com/dart-lang/sdk/issues/45603

TEST=vm/dart{_2,}/isolates/closures_without_captured_variables_test

Change-Id: I5e8845203059ff625f7cff3f072d845b5e48ba36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212297
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-09-03 12:35:58 +00:00
Lasse R.H. Nielsen 9076b6a76a Add test for parsing explicit instantiations.
Change-Id: Ia1c5b6b2365849a6c69b1db2bf1878ca64dfd65b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211420
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-09-03 09:54:49 +00:00
Leaf Petersen 6d741a6e5b Flip constructor-tearoffs experiment flag
Change-Id: I25538772c4b452c647518e5a5696ba79dfb38991
TEST=Existing tests for the feature.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212262
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-09-03 04:19:57 +00:00
Martin Kustermann 177bc7d074 [vm/concurrency] Fix test to always pass --enable-isolate-groups (or the negative flag)
This makes the self-detection of whether isolate groups are enabled work
correctly in the test.

TEST=Fixes lib_2/isolate/message3_test test failures on CI

Change-Id: I71965236444af71e6deb4df6a77911144af9af91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212294
Auto-Submit: Martin Kustermann <kustermann@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-09-02 22:15:55 +00:00
Martin Kustermann 26ef8f6947 [vm] Allow sending closures between isolates of the same isolate group
Closures can be shared if they have no state they capture (i.e. a null
context). Otherwise we copy them by also transitively copying the
parent context chain.

Issue https://github.com/dart-lang/sdk/issues/36097

TEST=Added tests to vm/dart{,_2}/isolates/fast_object_copy{,2}_test

Change-Id: Ie641b97806edd0c21f0a8d5c514f8e850823e165
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209110
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-09-02 19:45:55 +00:00
Vyacheslav Egorov bda70c8489 [vm] Remove support for dart-ext: imports
Per breaking change #45451 we are removing support for dart-ext:
style native extensions from the Dart VM.

This CL removes the associated VM code, tests and samples. It also ports
a single test which used dart-ext: import to use FFI instead.

TEST=ci

Bug: https://github.com/dart-lang/sdk/issues/45451
Change-Id: Iae984bce32baf29a950b5de1323939006a217b94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212050
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-02 14:14:35 +00:00
Erik Ernst 87ccae9e3f Add tests about covariant parameters and inherited methods
Change-Id: Ibf2e4256605c1c479c6b244c44c1c424b0a2e6ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208504
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2021-09-01 23:47:47 +00:00
Sam Rawlins ff2e3c2df0 analyzer: Allow explicit type instantiation of function-typed expressions
This allows local variables and other expressions, as long as the
static type is a generic function type, to be explicitly type
instantiated.

* Expressions with a non-generic function type cannot be type
  instantiated.
* Expressions with a type of `Function` cannot be type instantiated.
* Expressions with other non-function types cannot be type instantiated.

This results in doubling-up of errors in a few situations. I think these
are generally rare occurrences, and tricky to prevent double reporting,
so I've left them for now.

Bug: https://github.com/dart-lang/sdk/issues/46020,
Change-Id: Iad212fd95773f39f3202480b3fa71f6a28c7698f
https://github.com/dart-lang/language/issues/1812
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211941
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-09-01 00:03:56 +00:00
Lasse R.H. Nielsen ed3824a220 Tweaks, refactoring and updates on DoubleLinkedQueue.
It's a badly designed class, but this change makes it slightly better.
(We should consider moving it to package:collection and removing it from
the platform libraries. Eventually.)

The changes decouples the public `DoubleLinkedQueueEntry` class from
the actual queue implementation classes, avoiding the latter having
to share a generic `_Link<DoubleLinkedQueueEntry>` interface
which would force them to do otherwise unnecessary casts.

The public class should have been abstract, but isn't.
It's mainly used as the API of the entries exposed by DoubleLinkedQueue,
but it can also be used by itself to build double-linked lists that are
not part of a Queue, and the class can be extended.
If anyone does either, it should keep working, so it needs to be a concrete,
self-contained class with a generative constructor.

That class is moved to dart:_internal to avoid its private
implementation fields from interfering with the queue implementation classes,
which have similar fields, but can now have them at different types.
That's a hack, but it works.

The internal implementation of the DoubleLinkedQueue and its entries
are updated to better follow current programming idioms, and avoids
having fields on classes which don't need them.

Also fixes #27920
(`clear`ing a list now detaches each entry from the list so later `.contains`
won't give the wrong answer).

And moves queue tests from tests/corelib to tests/lib/collection,
since Queue isn't exposed by `dart:core`.

BUG= https://github.com/dart-lang/sdk/issues/27920

Change-Id: Ia3bb340a75886de160cc0e449947e8e7ee587061
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211265
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-08-31 12:44:39 +00:00
Daco Harkes b294fe59f9 [vm/gardening] Mark bigint_parse_radix_test/3 as slow
Bug: https://github.com/dart-lang/sdk/issues/47050

Change-Id: Ia0496785c5df6c231269ae4ebbb4376beb3a63d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211904
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-08-31 09:56:50 +00:00
Sam Rawlins 873ecfd8fd Suppress redundant tearoff errors when constructor tearoffs not enabled
Fixes https://github.com/dart-lang/sdk/issues/47035

Change-Id: I745da785d80744f84e3582727e423e4caed866c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211720
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-30 17:19:07 +00:00
Jens Johansen 5caa4365d7 [parser] Add beforeSynthetic to SyntheticStringToken
E.g. if reporting a missing ";" after a SyntheticStringToken (e.g. a
inserted identifier) before this CL it would go to the next token and
say we expected the ";" after that, when really we expected it *before*
that token.

Change-Id: I2c358e017edb2f661e307eba03dddaee889086d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205799
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-08-30 11:56:30 +00:00
asiva bc387837c4 [VM/Runtime] Reland : Fix 'File' object leak in async file open operation
The 'File' object created in the async file open method is leaked
if the operation is not completed when the isolate shuts down
with an unhandled exception.
This change adds a finalizable state for the 'File' object so that
the message deletion that happens when ports are closed could run
the callback to clean up the 'File' object.


TEST=new tests added

Change-Id: I64c18a7905261b0fc7bf9f220086791478232d0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211340
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-08-27 17:45:17 +00:00
Paul Berry 1b18e8f5ac Flow analysis: account for initializers of implicitly typed variables.
Previously, initializers of implicitly typed variables did not
contribute to the SSA tracking performed by flow analysis (see
https://github.com/dart-lang/language/issues/1785).  This change fixes
the bug, however the fix is conditioned on the "constructor tearoffs"
language feature to avoid compatibility issues (we don't want someone
to publish a package taking advantage of the fix, without realizing
that it makes their package unusable on older SDKs).

TEST=standard trybots
Bug: https://github.com/dart-lang/language/issues/1785
Change-Id: I1143440c7a9795b059e8f4b84e3f4125cd80732c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211306
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-27 15:01:15 +00:00
Stephen Adams 5c582f82f0 [dart2js, js_runtime, js_dev_runtime] NaN-safe range checks.
`int` variables can attain NaN values because web int arithmetic
implemented by JavaScript numbers (doubles) is not closed under many
operations. It is possible get NaN using only addition:

    int a = 1, b = -1;
    while (a + a != a) { a += a; b += b; }
    int nan = a + b;

On the VM, a, b and nan are all zero.
On the web, a, b and nan are Infinity, -Infinity and NaN, respectively.

Since NaN can leak into int arithmetic, is it helpful if bounds checks
catch NaN indexes. NaN compares false in any comparison, so a test
of the form

   if (index < 0 || index >= a.length) throw ioore(a, index);

fails to detect a NaN value of `index`.
This is fixed by negating the comparisons, and applying De Morgan's law:

   if (!(index >= 0 && index < a.length)) throw ioore(a, index);

These changes have been applied to JSArray.[], JSArray.[]= and String.[]

For dart2js the change is a little more involved. Primitive indexing is
lowered to code with a HBoundsCheck check instruction. The code generated
for the instruction now uses, e.g. `!(i>=0)` instead of `i<0`.
This leads to a small code size regression.

There is no regression at -O4 since bounds checks are omitted at -O4.

At -O3 (where the regression is largest) the regression is
   0.01% for cm
   0.06% for flutter gallery -- array-heavy diff and layout
   0.21% for Meteor          -- array-heavy code
   0.30% for Box2DOctane     -- array-heavy code

I believe the regression can be largely alleviated by determining if
NaN is impossible at the index check, and if so, reverting to the smaller
code pattern. The analysis could be global, incorporating NaN into the
global abstract value domain, or a much simpler a local dataflow
analysis. Many indexes are loop driven and cannot reach infinity because
they are incremented by a small bump and eventually (even without a loop
guard) the index would stop growing when the increment falls below the
rounding error in O(2^53) iterations.


Change-Id: I23ab1eb779f1d0c9c6655e13d69f65d453db9284
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210321
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-08-27 00:37:56 +00:00
Erik Ernst 9b5db137a9 New test: Testing ambiguity management for explicit instantiations
Change-Id: I3ea0be4032c3f9999239f2ae58514d21df9045d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211281
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2021-08-26 17:36:19 +00:00
Johnni Winther ce4e7705f2 [cfe] Handle explicit instantiation in implicit creation syntax
Closes #46719
Closes #46887

Change-Id: I4ad0f1bb4ab847a44f749113c6446f62a474143c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211260
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-26 11:59:48 +00:00
Erik Ernst 054ae83903 Add test for constant factory constructor feature, cf. #46984
Change-Id: I750345600d3b47de44c060511be35aea8744eca3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211140
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2021-08-26 09:27:31 +00:00
Paul Berry d2b313227d Flow analysis: Pin down initialization behaviors before fixing #1785.
https://github.com/dart-lang/language/issues/1785 has a wide enough
impact that its fix will have to be bundled in with a language version
(i.e. future versions of Dart will have to reproduce the old buggy
behavior for code that's not opted in to the latest language version).
Therefore, we'll have to maintain tests of the behavior both before
and after the fix.  This CL is the first step in that process, adding
tests that validate the current (buggy) behavior.

Bug: https://github.com/dart-lang/language/issues/1785
Change-Id: I78f17999ac1cbc096a312ef977db24654e06a263
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210400
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-25 20:32:02 +00:00
Johnni Winther b3af778a38 [cfe] Add UnresolvedKind for fine grained unresolved reporting
- including tests for issues 46719 and 46887

Change-Id: I601fcfcb956e059f502cbece29fb2a6a00f68846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210464
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-08-25 09:51:54 +00:00
William Hesse 637e14006c Revert "[VM/Runtime] Fix 'File' object leak in async file open operation"
This reverts commit b67f45f955.

Reason for revert: This seems to cause a crash on ARMv7 aot compiled code.

Original change's description:
> [VM/Runtime] Fix 'File' object leak in async file open operation
>
> The 'File' object created in the async file open method is leaked
> if the operation is not completed when the isolate shuts down
> with an unhandled exception.
> This change adds a finalizable state for the 'File' object so that
> the message deletion that happens when ports are closed could run
> the callback to clean up the 'File' object.
>
> TEST=new tests added
>
> Change-Id: I4a3cb28370d27306c795c1914aeb5c18a1d85e2b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210761
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

TBR=aam@google.com,rmacnak@google.com,asiva@google.com

Change-Id: Ie91aadd318ef19a0bb4d7f769c9e876e76d719d8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211021
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2021-08-24 12:49:23 +00:00
Johnni Winther ae4543fcb9 [cfe] Report all compile-time errors found during constant evaluation
Closes #46925

Change-Id: I81e97cae05c39c24b24dae82a222f857d4730ac7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210465
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-24 11:42:53 +00:00
Sam Rawlins 419d70afb2 Fix message of RETURN_IN_GENERATOR; stop double reporting.
* This message should only be reported by the parser; the
  error raised in the analyzer was strictly duplicate.
* This message theoretically used to mention "async*" or
  "sync*" depending on the modifier that the function in
  question listed. However, listing one modifier or the
  other is a red herring, and may confuse the user; any
  function declared with one or the other is a "generator",
  and the error applies equally to a "generator" using one
  or the other modifier.

Bug: https://github.com/dart-lang/sdk/issues/43665
Change-Id: I6ef1f5c055473170e7563222f6f0a6c56a4ad5f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210801
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-08-24 01:43:48 +00:00
asiva b67f45f955 [VM/Runtime] Fix 'File' object leak in async file open operation
The 'File' object created in the async file open method is leaked
if the operation is not completed when the isolate shuts down
with an unhandled exception.
This change adds a finalizable state for the 'File' object so that
the message deletion that happens when ports are closed could run
the callback to clean up the 'File' object.

TEST=new tests added

Change-Id: I4a3cb28370d27306c795c1914aeb5c18a1d85e2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210761
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-08-23 20:57:48 +00:00
Sam Rawlins f274c79333 analyzer: Rewrite function tearoff followed by a method call
Today, the parser reads `a<...>.b()` as a constructor call with
explicit type arguments for the class. This could be a method call
on a function tearoff (however unlikely).

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

Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: I16681171a7d99adf3fd080a235fcedc46c5fb1ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210780
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-23 18:10:47 +00:00
Dmitry Stefantsov d3c3e92740 [cfe] Add error on misplaced type arguments in constructor tear-offs
Closes #46890.

Bug: https://github.com/dart-lang/sdk/issues/46890
Change-Id: Idf0c4e5ef6380541aaccba9f74755572b2fa9549
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210460
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-23 14:36:47 +00:00
Sam Rawlins c86bfe3e2c Correct type of CONSTRUCTOR_TEAROFFS_NOT_ENABLED code
Additionally, sort the UNUSED_RESULT_* codes.

This addresses comments in
https://dart-review.googlesource.com/c/sdk/+/209300

Change-Id: I4d3fd25703f6df59f8ad985352c87406e218b544
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-19 22:22:06 +00:00
Konstantin Shcheglov 4d42e73295 Report EXPERIMENT_NOT_ENABLED instead of ANNOTATION_WITH_TYPE_ARGUMENTS.
On one hand this is less precise, OTOH this tells which feature and
the language version it requires.

Change-Id: I1d24a2d7cf2c7b7ca305d5bfc9f094fce0734bc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210644
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-19 20:20:26 +00:00
Nicholas Shahan a899525bdc [tests] Add regression tests
Issue: https://github.com/dart-lang/sdk/issues/46867
Change-Id: I7e2912752ac8c48df233f27869599280e2c322fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209853
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-08-17 17:32:52 +00:00
Paul Berry f5a3bce734 Fix scope resolution of metadata on type parameters
Previously, when encountering identifiers in metadata on a class's
type parameter, the analyzer would resolve them using the type
parameter scope, but then fall back on using implicit `this`.  The CFE
would resolve them using the class body scope.  In both cases, the end
result was that the annotation could refer to static class members.

This change brings the behavior of both the analyzer and the CFE in
line with the spec, by preventing the use of implicit `this` in these
annotations, and resolving them in the type parameter scope.

This is not expected to break any code in practice, because
annotations on type parameters are rare, as are annotations referring
to static class members, and the overlap between these two should be
negligibly small.

Fixes https://github.com/dart-lang/language/issues/1790.

Bug: https://github.com/dart-lang/language/issues/1790
Change-Id: Ibe5a421e04a53d29074a8b1509e1390658ed72e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210040
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-08-17 15:17:02 +00:00
Alexander Markov cfb057ddca Reland "[vm] Hide internal implementation List types and expose them as List"
This is a reland of 824bec596f

Original change's description:
> [vm] Hide internal implementation List types and expose them as List
>
> When taking a type of an instance with x.runtimeType we can map
> internal classes _List, _ImmutableList and _GrowableList to a
> user-visible List class. This is similar to what we do for
> implementation classes of int, String and Type.
> After that, result of x.runtimeType for built-in lists would be
> compatible with List<T> type literals.
>
> Also, both intrinsic and native implementations of _haveSameRuntimeType
> are updated to agree with new semantic of runtimeType.
>
> TEST=co19/LanguageFeatures/Constructor-tear-offs/type_literal_A01_t01
> TEST=runtime/tests/vm/dart/have_same_runtime_type_test
>
> Fixes https://github.com/dart-lang/sdk/issues/46893
> Issue https://github.com/dart-lang/sdk/issues/46231
>
> Change-Id: Ie24a9f527f66a06118427b7a09e49c03dff93d8e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210066
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Tess Strickland <sstrickl@google.com>

TEST=co19/LanguageFeatures/Constructor-tear-offs/type_literal_A01_t01
TEST=runtime/tests/vm/dart/have_same_runtime_type_test
TEST=lib/mirrors/regress_b196606044_test
Fixes https://github.com/dart-lang/sdk/issues/46893
Issue https://github.com/dart-lang/sdk/issues/46231

Change-Id: I79b587540338808bd73a6554f00a5eed042f4c26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210201
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-08-16 22:52:21 +00:00
Irina Arkhipets 79be5898b4 [co19] LibTests/typed_data tests skipped for dart2js
[co19_2] LibTests/typed_data tests skipped for dart2js

Change-Id: I2e8a93f7991b36367b84678bbfebda36babaf96f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209915
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2021-08-16 08:07:34 +00:00
Ryan Macnak e6b05a7a90 [vm, isolate] Also apply fast copying to an isolate's initial message.
Add missing checks for FFI types disallowed in isolate messages.
Align error messages with the other serializer and test expectations.

TEST=ci
Change-Id: I3813dd8f26e5122524bdf41f9ce6e0785fdd260b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209840
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-08-12 20:25:30 +00:00
Alexander Thomas 1c06d14fce [co19] Skip broken tests also in co19_2
https://github.com/dart-lang/co19/issues/1137

Change-Id: I32e81daed87ad8943023ad923fddd686b3b2362e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209961
Reviewed-by: William Hesse <whesse@google.com>
2021-08-12 10:55:21 +00:00
Erik Ernst cc84bb3e28 Adjust type_parameter_test to expect caller-side check on tearoff
language/covariant/type_parameter_test.dart performed a tearoff which
should incur a run-time error (because the dynamic type of the
tearoff is not a subtype of the static type, so it would be a
soundness violation to pass that value on to the next step of
evaluation).

Change-Id: Ia4ec813606e711cab0bdcc68d24bbac3c9a2d8c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209910
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2021-08-11 16:37:51 +00:00
Johnni Winther 3befe682e9 [cfe] Fix message offset on unresolved prefix access
Bug: b/195806584
Change-Id: I0d607ceef8d17433df00f5a71cc5b37d6f5c899f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209907
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-11 16:12:01 +00:00
Erik Ernst ef1f4c78db Remove expectation that instantiated local function tearoffs are notEqual
This CL changes the test
language/generic_methods/explicit_instantiated_tearoff_test.dart
such that it no longer expects a generic instantiation of a local
function tearoff to be notEqual to another function object which is
the same local function, same enclosing invocation, same type
arguments.

The rationale is that we should not preclude an optimization whereby
these function objects are canonicalized (at run time, or if they
can be lifted to the top level even possibly at compile time).

Change-Id: I5845a19ce9ccf931c4d3abe4ab619f3ed2a2fbc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209860
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2021-08-11 16:07:51 +00:00
Alexander Thomas ef850dbdec [co19] Skip flawed tests on latest co19 roll
The top_level_main tests starts themselves via
Platform.resolvedExecutable which causes them to turn into a fork bombs
on AOT. On web, dart:io is not supported.

https://github.com/dart-lang/co19/issues/1137

findProxy tests are timing out on all relevant platforms.

https://github.com/dart-lang/co19/issues/1129

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-win-release-x64-try
Change-Id: If1e4d0c26d5d40cd60e5e8a8dd4600b85668da5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209706
Reviewed-by: William Hesse <whesse@google.com>
2021-08-11 13:29:59 +00:00
Sam Rawlins 3393591b3f Rewrite AST w/ Constructor reference w/ explicit type args
This should handle all cases of constructor reference w/ explicit type
args; there aren't too many cases:

* named and unnamed constructors
* referencing class and referencing type alias
* prefixed class names and not-prefixed
* null-aware access (weird)
* bound on type parameter of class, and on type parameter of alias

error cases:

* cascade
* wrong number of type arguments

Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: If257eb561a9ad854709b6e9a7d81faa9d084d6ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209622
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-10 23:54:49 +00:00
Nicholas Shahan 7ff8c6c6be [tests] Remove not-identical expectation for Type values
The instantiation at runtime implies non-constant type expressions
but canonicalization is unspecified so backends should be allowed
to optimize by canonicalizing types.

Change-Id: I2f1cab6ac68a1ce156b15af0b99e02d03b7b3dca
Issue: https://github.com/dart-lang/sdk/issues/46837
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209663
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2021-08-10 18:47:31 +00:00
Martin Kustermann d7c0271ac0 [vm/concurrency] Add missing WeakProperty support to transitive copy
The transitive copy algorithm was missing support for [WeakProperty]s,
thereby ensuring that we only copy the values if the keys are reachable.

Furthermore we might need to re-hash [Expando]s - since the copied
objects start with no identity hash codes.

The CL also makes us avoid calling to Dart for each [Expando]
separately and instead use a list - just as we do in the re-hashing of
maps/sets.

We also move the C++ code to invoke rehashing logic into
DartLibraryCalls::*.

Issue https://github.com/dart-lang/sdk/issues/36097

TEST=vm/dart{,_2}/isolates/fast_object_copy{,2}_test

Change-Id: I836745feef8a6d7573faa94e29a19c1eca0c39f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209106
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-08-09 23:56:19 +00:00
Sam Rawlins 9b586a3da6 analyzer: add constructor references from PrefixedIdentifier
Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: Ifafea6edb6c9ce7fdf1c1f092ff278738c273bb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209300
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-09 15:03:48 +00:00
Clement Skau bf2691c2fe [VM] Moves FfiNative fields to function parent.
Previously the synthetic field that holds the FfiNative
function pointer was injected into the current library.
This change makes sure we instead add the field to the
relevant parent - Class or Library.

TEST=Added regression test for name collision.

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: Ifbf2d70de00e4748c179fe7d626c495675c2b338
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208502
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-08-09 09:13:38 +00:00