Letting isolate go seems to be problematic. If this native messaging api is used during runtime call, then original isolate might end up on a different worker os thread causing remembered frame pointer(remembered as part of entering runtime call) to become invalid due to different stack bounds of this new thread. Invalid frame pointer causes immediate assertion failures during stack walk done for GC purposes or for exception handling.
TEST=ci, https://dart-review.git.corp.google.com/c/sdk/+/486522/comments/ee54d99f_a5c2a9d4
Change-Id: If69076bb9e107502dfef819de73829d9682bb134
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Discard memory-expensive driver data only when a driver first reaches
the idle work priority, instead of doing it on every scheduler loop
while it remains idle.
Track drivers whose idle discard has already run, and clear that state
when a driver gets more work or is removed. This preserves the
fine-dependency idle cleanup while avoiding repeated calls during long
idle periods.
Change-Id: If480e473fe2a1e8b6c4725cdd4ac4359afdba4a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500500
Reviewed-by: Paul Berry <paulberry@google.com>
It's possible that there are nested paths in LSP workspace folders, such as:
/foo
/fooBar
/bar/foo
We shouldn't just replace each path we were given, as it might replace the wrong parts of other parts. Instead, require the path to be surrounded by quotes, or prefixed by a quote and followed by the appropriate path separator.
I also tweaked the benchmark test a little to report the time for the first call separately from the others, since that one triggers the regex build.
On my machine, timings currently are:
```
Replacing 250 paths in payload of 2097152 bytes
Iteration #1, First: 43ms, Rest: 30ms
Iteration #2, First: 38ms, Rest: 30ms
Iteration #3, First: 33ms, Rest: 30ms
Iteration #4, First: 37ms, Rest: 30ms
Iteration #5, First: 31ms, Rest: 29ms
```
Change-Id: I75de1fb36a16636e0f50099cced1d5386318d589
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Remove the `reportScannerErrors` option from `Scanner.tokenize`. The
parser handles scanner error tokens directly, so the scanner no longer
needs a mode that translates and reports them before parsing.
Update all callers to use the simplified `tokenize()` API. Adjust parser
recovery expectations where diagnostics are now reported at the
synthetic token location chosen by parser.
Change-Id: Ia2d479ba57b3156f1a4bab47c32444892c9d0aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500361
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
On 32-bit arm, when generating subtype test cache stub,
[delayed_type_args_reg] could be the same as [TypeTestABI::kInstanceReg]
(due to lack of registers).
As a result, when loading delayed type arguments from an instantiated
generic closure, [TypeTestABI::kInstanceReg] is eagerly overwritten,
which results in garbage delayed type arguments.
With the linear probe cache this would cause repeated cache misses.
With the hash-based cache this would cause a crash.
Bug: b/507666702
Change-Id: I1093f9277d874154a121ef644ecd7aa76320f789
TEST=runtime/tests/vm/dart/regress_b_507666702_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500842
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This adds an AsyncModifier class that holds both the AsyncMarker, used in the kernel encoding, and the file offset of the async modifier. This is used throughout the front end and ensures that the correct offset is used for errors reported on the async modifier.
Change-Id: If16d293ffb9b2e8fa8eca8c65f7548d920c5d56b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
The test_runner skips test runs on all but front-end-only configurations
in the case where the test contains expectations that there will be
a compile-time error. This CL changes the "front-end-only"
classification such that the spec parser is included.
Before this CL, this implies that a test with a syntax error and an
expectation that this syntax error will be reported is simply skipped
when using `tools/test.py -c spec_parser ...`. With this CL, the
spec parser will be executed on that test, as it should.
Change-Id: I32ed313b5da20c189ca2f9b6b9ea3bb45f5072c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500721
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Adds logic to the `RemoveTypeName` correction producer to ensure that
after the correction is applied, the spacing matches what `dart
format` would do. For example, `C()` is changed to `new()` rather than
`new ()`, and `factory C()` is changed to `factory()` rather than
`factory ()`.
This will make it easier for me to visually inspect intermediate
results when transitioning the SDK and google3 to language version
3.13. It also should provide a (marginally) nicer user experience.
Change-Id: I30babde38e58438ea39279ed0d5859ce6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Replace the positional Scanner constructors with a single constructor
that takes the input text and error reporting callback as named required
arguments.
Remove the unused fasta forwarding constructor, reader offset handling,
and stored first token. The scanner now keeps only the input text and
returns the token stream directly from tokenize.
Update analyzer, analysis server, plugin, CLI, scrape, and scanner test
call sites to use the named constructor arguments.
Change-Id: Ieabb7b28570d4a963563fb2d1c5ef5ac0c89032a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Broaden search candidate selection to consider all names that can
syntactically denote an element, instead of only the element's own name.
Let the analysis driver answer reference-name queries for a set of
names. Use that to search for constructor references through declaring
type names, type aliases, and alias chains, including unnamed
constructors whose source spelling may omit the constructor name. Also
keep the declaring libraries in the candidate set so local references
are not filtered out before indexing.
Record super formal parameter names as referenced names. These names can
denote parameters from the selected super constructor, so they must be
available when narrowing files for search.
This improves reference search for constructor calls through type
aliases, dot-shorthand constructor invocations and tear-offs, and static
members used with dot shorthand or through an alias.
Fixes: https://github.com/dart-lang/sdk/issues/62219
Change-Id: Ia50ed3fd2e97f99d4aaf350314d08b930f86062c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500280
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Keep each executable fragment's formal parameter list complete across an
augmentation chain by adding synthetic missing parameters both to
earlier fragments and to the current fragment. Link matching positional
parameters by position and named parameters by name, preserving
duplicate named parameters in declaration order.
This lets every formal parameter element have a fragment in each
executable fragment, while still allowing consumers that need only
written parameters to filter by `isOriginDeclaration`.
Update type building so synthetic fragments from other executable
fragments do not prevent the first real declaration from initializing
the parameter element type. Keep later real declarations from
overwriting a type that was already established by a previous real
fragment.
Add small collection helpers used by the new linking logic, and expand
augmentation element-model expectations to cover regular, field-formal,
and super-formal parameters with missing, reordered, duplicated, and
shape-changing parameters.
Change-Id: Ie4c959744385cb8dcc46bbbb5c5e9e4e5c30d461
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500220
Reviewed-by: Johnni Winther <johnniwinther@google.com>
When we call out to JS and the function type is declared as `void` we
don't observe the result from JS. That means we can import the JS
function as a wasm function type without results.
We then synthesize a `null` value, in case a caller of the external JS
function uses/observes the `void` result value.
=> This CL does the same for `JS<void>(...)` calls.
We also remove the "inline" replacement optimization in the js interop
transformer. That makes all `JS<...>()` calls to be handled in a uniform
way.
=> Our backend's inliner should inline it iff beneficial for size.
Change-Id: I78032aae0dcdcaaf52701c628cea71af1de0d5e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499880
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
This CL enables the primary constructors feature by default in Dart 3.13.
The primary constructors feature is a brevity feature. There are no new semantics, but it allows us to express declarations in a less verbose way.
This feature allows one constructor and a set of instance variables to be specified in the header of a declaration.
Currently a declaration with a constructor and some fields is written as:
```dart
// Current syntax.
class Point {
int x;
int y;
Point(this.x, this.y);
}
```
With a primary constructor, we would write the above as:
```
class Point(var int x, var int y);
```
If a primary constructor needs an initializer list or a body, they can be
specified inside the class using the `this` body syntax:
```dart
class Point(var int x, var int y) {
this : assert(x >= 0) {
print('Point created at $x, $y');
}
}
```
As part of this feature, you can also use the `new` and `factory` keywords to
declare constructors in the class body without repeating the class name:
```dart
class Point {
int x, y;
// Equivalent to Point(this.x, this.y)
new(this.x, this.y);
// Equivalent to Point.origin()
new origin() : x = 0, y = 0;
// Equivalent to factory Point.clone(Point other)
factory clone(Point other) => Point(other.x, other.y);
}
```
To learn more about the feature, check out the feature specification located here: https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md
Tested: Has existing language, CFE, analyzer, analysis server tests.
Bug: https://github.com/dart-lang/sdk/issues/61524
Change-Id: I296f2fcd918b87bf2a1dd00256340759866c2423
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489241
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Require the embedder to place a blob containing the FFI callback stub at pkg/lib/ffi_callback_stub.bin. All blobs in the package can be loaded as executable VMOs.
Also reapply "Remove special case for simulator FFI callback thunks."
TEST=ci
Change-Id: I6ab4a73fc28fb750e45e67797b0bf9deee9d8b53
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495840
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This reverts commit 3eb697c0af.
Reason for revert: Internal Google3 breakages
Original change's description:
> [flow analysis] Fix unsound type promotion in inner async/generator functions.
>
> An `await` expression or `yield` statement suspends the current
> function and allows other code in the same isolate to execute. In the
> case of nested functions, an `await` or `yield` in the inner function
> can allow the outer function to continue executing. That means that if
> the inner function promotes a local variable belonging to the outer
> function, then it isn't sound to carry that promotion past an `await`
> or `yield`.
>
> This change fixes the unsoundness by adding a flow analysis method
> `suspension`, which the shared type analysis logic uses to tell flow
> analysis that an `await` or `yield` has been found. The `suspension`
> method un-does the promotions of any variables that might be written
> to while the inner function is suspended.
>
> Fixes https://github.com/dart-lang/sdk/issues/62889.
>
> Change-Id: I77eaf997159819a7c50f44b67174d2aa6a6a6964
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499382
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Bob Nystrom <rnystrom@google.com>
Change-Id: I187ba9a347394946ecc8749d35dc7914d271b90a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500540
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The new @pragma('external-effect') causes the removal of invocations, including arguments, of any annotated member. This means the codegen builder shouldn't see any calls to these methods.
In a normal dart2js compilation this would mean we don't try to build bodies for the members. However, when running codegen in sharded mode, we have to be more conservative and assume another shard may need the member. Therefore one shard will still try to generate these methods.
We can just emit an empty member as the linker will exclude the unused method from the final JS code.
Change-Id: I28a82267f692f6a4921fe3b5207a7284f3fc8e0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500001
Reviewed-by: Stephen Adams <sra@google.com>
`List.unmodifiable` and `Map.unmodifiable` is as badly typed
as `List.from` and `Map.from`, but does not have a better-typed
`.of` constructor. This adds such, to give a migration target
when deprecating the badly typed constructors.
The `Future.delayed` with no second argument is also unsafely
typed, it fails if the type argument is not nullable.
The `Future.pause` creates `Future<void>` instead.
CoreLibraryReviewExempt: No new or platform specific behavior.
Change-Id: Iba101b3dc62f412003abd501fa042aca0ce63116
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499280
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>