Asking for implementations of 'ToJsonable' from
package:analysis_server/lsp_protocol/protocol_special.dart takes
8+ seconds both on first request and on subsequent requests.
Turns out most of that is spent on getting line info data for each
result via `server.getLineInfo`.
This CL rewrites how the search is performed, getting all subtypes
directly via `searchAllSubtypes`, from which one can cheaply get the
line info.
On my machine, the call that always took 8+ seconds before now takes
<2 seconds (at least on subsequent runs).
Notice that the time also depends on how much is open by the editor and
that calls from my editor with many folders open still takes ~6 seconds.
This CL furthermore adds more performance measurements that's available
via the "Analysis Server Diagnostics" page "Timing" for
"textDocument/implementation" requests.
Change-Id: I2e5ef20238901fb4734cc182aeb53adfc96f79b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272360
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
I don't remeber anymore *why* I implemented it.
And it causes a failure in https://dart-review.googlesource.com/c/sdk/+/272387
because we started dropping some tokens, so we cannot restore the
same source code.
Change-Id: I886122e488715ba35347662268b207a99945cd90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This will be used from DynamicCallSiteTypeInformation nodes to get a list of receivers for dynamic calls. The InferrerEngine will also use it to calculate overrides of a given function and mark them as called.
Change-Id: I5738e393ae2de4cb93fd55c60e944a2db067b448
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266422
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
The new name, `looksLikeOuterPatternEquals`, is a more precise
description of what it does.
This helps prepare for adding parser support for pattern assignments,
which require the same functionality.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: Ibfcc4c37faac1770c98a427facdffda5c40e6d08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272344
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Normally, listener methods call `LogEvent`. This helps find bugs
where a listener that extends `Listener` doesn't implement a necessary
callback.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: Ideac739d8d63cda2244572f7d1deb83dceeced37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272346
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This hashCode is rarely used today so there shouldn't be any significant change from this. But in terms of code health it's better to remove this now.
Change-Id: Iff3ea93a4d82c3977ca7903888def7cbcb2f138f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272401
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Fixes https://github.com/dart-lang/sdk/issues/50542
One primary principle is keeping the cost for _most code_
extremely low. Most code does not have an `examples/api`
directory. Most comments do not have `{@tool`.
Looking for directories on disk is expensive. Walking tokens
in comment text is cheap. So we can pay the price of walking all comments, prowling for `{@tool` text which we won't likely find,
and skip the work of looking for `examples/api` in _all_ parent
directories, until we find a comment with `{@tool`.
Don't check if `$parent/examples` exists before checking if `$parent/examples/api` exists. We don't care if `$parent/examples`
exists.
Don't create an `AanlyzerConverter` instance for _every element_
in a compilation unit while we are editing it. Instead, refactor
some of the `AnalyzerConverter` methods to be extension methods.
Change-Id: I812a1a435ee075e921782c1a57e9ed77325f9387
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271863
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Special syntax for mixin applications should be also abstract if we add the sealed modifier.
Change-Id: I3af3e997734f4bc762dc29bfc3f61f2e691ca41b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
* Stop using `implicit-casts: false`
* Don't list rules which are found in package:lints
* Fix strict-inference issues
Change-Id: Ibe350548e3d6bef486ef2ef82430cda23d684baf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271780
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Currently a File is created to make a lookup in a map with the key
being looked up being "file.path". I've seen examples where creating
this File - because of the call `FileSystemEntity._toUtf8Array(path)` in
`_File` (from the SDK) - adds 1+ seconds to a request.
Specifically, asking for implementations of 'ToJsonable' from
package:analysis_server/lsp_protocol/protocol_special.dart goes from
taking ~12.8 seconds to taking ~11.5 seconds (with enough workspace
folders open).
Change-Id: I838f7fb15f39f95b63697530336d930319961a40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271700
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
With a06f10c we started to generate direct calls in dynamic invocations
so we no longer need dispatch table entries for members that are only
invoked in dynamic invocations.
Change-Id: I29efd7f1486126c91f4286c84878b16db9c36a05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271880
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
...more consistent sorting of holdings (improves diffing)
Change-Id: I2f2c418edea1f2dec6b8cc26e8058a5e3855ceb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271820
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
This is mostly* a no-op refactor. This code handler had grown quite messy and all of the quick-fixes code only ran for Dart files (and assumed it had a resolved unit) which complicates fixing https://github.com/dart-lang/sdk/issues/50306 (quick-fixes for non-Dart files).
This change splits the handling into separate classes for each source of code actions (currently just "server Dart" and "plugins" but soon there will be pubspec/analysis_options producers too), then merges each group and sorts that group by priority.
* the one minor change is a code-path that was producing CodeAction literals where the client had not advertised supported this. This is now fixed and the related test updated.
Change-Id: I8837610c64aba3f2c3dcb2f1eb0bc9bf5c43ad62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
At the moment, we always use an in-memory store for computed units and
elements. By persisting this to file and re-using it across builds, we
can speed up subsequent build runs.
Change-Id: I6fca9d96f6961a3a802eb1d4cb21682fc0fcc469
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270400
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Simon <oss@simonbinder.eu>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Doing .contains on a list of n items takes O(n) time.
While - with the ~1600 files in the list when having the analyzer
looking at pkg/analysis_server - going a lookup for all entries will
only take ~10 ms I see no reason not to use a Set.
Change-Id: I2a0848616381203c9b86fc9da8b4d065e391175f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271363
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
The behaviour `skipOuterPattern` needs to be kept in sync with that of
`parsePrimaryPattern`. To reduce the risk of these to going out of
sync, I've added logic to `parsePrimaryPattern` so that after parsing
an `outerPattern`, it asserts that `skipOuterPattern` would have
behaved appropriately.
This required adding some logic to `parser_test_parser.dart` so that
these calls to `skipOuterPattern` don't show up in front_end parser
expectations files. (If they did show up, they would lead to
failures, since the bots run the front_end parser tests with
assertions both enabled and disabled).
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: Ida3a37532bb9a86837e70b5ec1aa2e557e3cb769
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271163
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Currently we use two `hasTearOffUses` and `tornOff` when deciding
whether to generate a tear-off getter for a member.
These metadata are undocumented so it's unclear how they are supposed to
be used, but `hasTearOfUses` seems to be what we need when generating
references for tear-off getters. For example, in this code:
class A {
void f() => print('A.f called');
}
void main() {
dynamic x = A();
final f = x.f;
f();
}
`hasTearOffUses` of `A.f` is true, `tornOff` is false. So the current
condition `hasTearOffUses && tornOff` incorrectly skips the reference.
In addition, I realized in my testing that when `tornOff` is true,
`hasTearOffUses` is true as well. So just using `hasTearOffUses` seems
to do the right thing.
New passing tests:
- corelib/map_unmodifiable_cast_test
- language/closure/bound_closure_equality_test
- language/closure/closure7_test
- language/closure/tearoff_bounds_instantiation_test
- language/function/type3_test
- language/nosuchmethod_forwarding/nosuchmethod_forwarding_test/06
- language/prefix/prefix15_test
- language/unsorted/fast_method_extraction_test
- lib/async/stream_event_transformed_test
- lib/convert/chunked_conversion1_test
- lib/convert/streamed_conversion_json_decode1_test
- lib/convert/streamed_conversion_json_utf8_decode_test
Fixes#50485
Change-Id: Id130649d6e175b84430f9bf967ea01c4d471cd92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271320
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Also removes an old TODO about handling null receivers in dynamic
invocations.
Change-Id: I08e14e19084e7186259375b6ac99cde19587dc27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271322
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
This merges the initialization of kernel `Class` and `Procedure`
fields with their definitions, resulting in more concise declarations.
Change-Id: Id7835edb9a29b4ad47ecce06d337f00738063891
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271083
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
It's more robust to refer to the actual field directly.
Change-Id: I8947fdd11070f71645671ee1df9efa10a994f138
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271103
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
In WasmGC MVP, the `array.new_data` instruction will not be a constant
instruction. This means we can't implement the option that places
eager string constants in data segments and reads them using
`array.new_data`. We can still do this for lazy strings.
Also clean out the string function generator (which is dead since we
started using `array.new_data` for lazy strings) and the special case
for the empty string (which is obsolete since we started using
`array.new_fixed` for eager strings).
Change-Id: If28bdf6913ae0cd0f4faf7d87d64cb9412e56bb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271120
Reviewed-by: Ömer Ağacan <omersa@google.com>
Add AwaitExpression.runtimeTypeCheck to support easy backend
implementation of runtime type check.
In response to https://github.com/dart-lang/sdk/issues/49396
TEST=pkg/front_end/testcases/general/issue49396.dart
Change-Id: I13b9b14566ebc34cdb0811c16a262421417b68e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270723
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
The desugaring is presented as a series of nested if-statements
interleaved with intermediate variable declarations that cache the
results of accessing the members of the scrutinee object. Among other
things, it prevents double access to a list element when checking the
pattern conditions on it and then assigning it into a variable pattern.
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: I5bf0b040c44d150eacef9a727a8a66fd3a9a568d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270701
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This normalizes the handling of record access to use the
ObjectAccessTarget interfaces. The extension handling of getter/setter
shadowing is now computed in terms of ObjectAccessTargets which
now handles shadowing for functions and records.
Closes#50157Closes#50513
Change-Id: Ib35ca9f7459016688eecc6d05019b0384f37ab76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271084
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
I encountered these errors while trying the log_viewer on some recent
log files.
Change-Id: If0207659eae717e4fbba28455ceee8815671f081
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270801
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
- Remove the dynamic 'apply' operation from `constant_system.operation`.
- Create all range expressions from ValueRangeInfo.
Change-Id: I008d941141e2b91056173a317f387f0986fce4fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270321
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This reverts commit e6f779bcdd.
Reason for revert: Broke expression compilation in google3
Original change's description:
> Cache expression compilers in incremental DDC mode
>
> - cache expression compilers in expression compiler worker
> to improve performance of exression compilation.
> - pass module format in expression compiler worker
> (the ddc format tests were not running!)
> - fix an issue where the same library was imported twice
> in module_builder.dart
> - add verbose mode timeline logging to ProgramCompiler.
> - update tests.
>
> Closes: https://github.com/dart-lang/sdk/issues/49944
> Change-Id: Ie7408dcd42e757b1eb5e7f5ccbc1b078b6417011
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268361
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Mark Zhou <markzipan@google.com>
> Commit-Queue: Anna Gringauze <annagrin@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I6c7209ffb03416dbb8d34c1a6f520f21766d9190
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Adds checks that if the derived class does not have a `@staticInterop`
annotation, none of the classes it implements or immediately extends can
have it either. Also cleans up some redundant abstract class tests for
readability.
Change-Id: I2e8528b0fb02d9ce39003d00ee0b3da88ce75d44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268109
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
These have always been able to return non-Instances.
TEST=ci
Change-Id: I13e46aae8705ea1f79ec0618cdb815a8ed9c0fdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270461
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
The info dump processor ends up deserializing most of the deferred data anyway so there is no benefit to the deferred logic. This saves ~600MB on info dump.
Change-Id: Ib9a1154b38594a3f046d5da96b477de9f2c90b9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271041
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
To prepare for the eventual removal of Observatory, we plan on disabling
Observatory by default while providing an escape hatch to manually serve
the tool for some period of time before completely removing Observatory
from the SDK. This change adds flags that can be used to configure
whether or not Observatory is served.
Currently, '--serve-observatory' is the default behavior, but will be
changed to '--no-serve-observatory' once tooling is ready to support the
escape hatch behavior.
Part of https://github.com/dart-lang/sdk/issues/50233
TEST=run_test.dart
Change-Id: Ib6d1e1587d9fbd3c61d4a4c75d90635052835844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267720
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
In
ce01d330d7,
the patterns spec was changed so that if an object pattern's type
resolves to `dynamic` or `Never`, no getters are looked up during
static analysis, and the getter type is simply presumed to be
`dynamic` or `Never`, respectively.
Also, the parameter `requiredType` of `analyzeObjectPattern` is
removed (is was not needed, and the caller always passed `null`).
Finally, the test artifact `ObjectPatternRequiredType` is removed in
favor of just using a PrimaryType directly. This makes the tests a
little bit more compact.
Change-Id: I6fcef8dab8250905e1d37308bbdc82a4fd65f52c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270982
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The name was misleading because it only models types whose names take
the form `IDENTIFIER` or `IDENTIFIER<ARGS>`; it doesn't model record
types, promoted type variable types, "question"/"star" types, or the
"unknown" type, which aren't function types either.
"PrimaryType" seems like a good name because it's at the base of the
type grammar.
Change-Id: I6e1916931892f2ef670bc89cfebb198b596b0173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270981
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Rename `TypeAnalyzer.analyzeInitializedVariableDeclaration` to
`analyzePatternVariableDeclarationStatement`, since the corresponding
grammar construct is called `patternVariableDeclaration`.
Change-Id: I5819a4434349b85974252f8e4da35adeffbc3d7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270980
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Extend the runtime representation of function types with a list of
type parameter bounds and take these into account when doing subtype
comparisons on function types.
The implementation has a number of limitations for now:
- When converting a function type to a string, the type does not know
its nesting depth. Function types on all nesting levels thus follow
the same naming scheme for their type parameters (`X0`, `X1`, ...),
which can lead to name clashes between type parameters in the case
of nested generic function types.
- When a generic function is instantiated, the type arguments are not
substituted for the function type parameters in the type of the
resulting function object, which therefore has an incorrect type.
- The default types of function type parameters are not explicitly
represented in function types. When we implement automatic
instantiation of missing type arguments in dynamic function calls,
we need to either add the default types to the representation
somehow or compute them from the bounds.
Change-Id: Ib756d9f8f2b6959efd7ef2e6bc79c7e4793ca3e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269761
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Since we normalize types at every step of runtime type construction
(in `Types.makeType` and `ConstantCreator.visitTypeLiteralConstant`)
we don't need to normalize types recursively, except in the case of
`FutureOrType`.
This change avoids creating new type parameters for function types,
which would interfere with construction of generic function types.
Change-Id: I8f7c0ec4348e962ca6e67a9c1224107f73f75474
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270001
Reviewed-by: Joshua Litt <joshualitt@google.com>
Some other changes:
- Variable `id` renamed to `classId` in a few places. In this code there
are two types of IDs: class IDs and selector IDs, and they have the
same type. So just "id" is ambiguous to the reader.
- `SelectorInfo.sortWeight` and `SelectorInfo.isAlive` getters moved to
`DispatchTable.build` as local functions
- Most of the members are made private.
- List of selector IDs of a class is now a Set. These lists used to have
duplicate selector IDs coming from superclasses.
- `DynamicDispatcher.maybeCalledDynamically` special case for
`noSuchMethod` moved to `SelectorInfo.isAlive`, as the only reason why
we had that special case is to keep selector for `noSuchMethod` alive.
`maybeCalledDynamically` inlined in the use site.
Change-Id: Iff650862d57e376913bda67db74bc67466d45e87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269461
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
This makes things nicer to read in places that display implementation names, such as stack traces, debuggers, profilers and inspectors.
TEST=ci
Change-Id: I959f70d9e51be59801c4455f8c5ccac3c214c21a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270502
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Based on Martin Kustermann and Slava Egorov's versions of memory mapped views.
This feature is disabled by default and even if the flag is enabled, it will fall back to the current strategy if the platform is not Linux or the new strategy fails.
Phase 1 stats from 50 runs:
---Before---
Max memory: 8786.766
Median memory: 8116.242
Average memory: 8327.404081632654
---After---=
Max memory: 7805.691
Median memory: 7137.203
Average memory: 7305.301122448978
Phase 2 stats from 50 runs:
---Before---
Max memory: 9273.359
Median memory: 8742.133
Average memory: 8868.929124999999
---After---
Max memory: 9409.672
Median memory: 7500.148
Average memory: 7650.154000000001
Phase 3b stats from 50 runs:
---Before---
Max memory: 8979.367
Median memory: 8705.215
Average memory: 8703.982755102037
---After---
Max memory: 7809.898
Median memory: 7455.609
Average memory: 7449.96102040816
Change-Id: I73d73cfb26218399367c72c886f247836b89925c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269640
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Add annotations
@pragma('dart2js:load-priority:normal')
@pragma('dart2js:load-priority:high')
The test shows that these annotations are scoped.
This CL is just plumbing the annotation through as an argument to the runtime call to the code that implements `loadLibrary()`. Actual prioritization is not yet implemented.
Change-Id: Iff1404baf34192139dab95e2dbb01c2d4e8dae45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270283
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
- Add getters for the top and bottom types of the WasmGC hierarchy
that a type belongs to.
- Rename the internal common supertype from `top` to `common` to avoid
confusion with the top type of each hierarchy.
- Always use a bottom type when emitting a `ref.null` instruction.
- Translate the `Null` and `Never` Dart types to WasmGC `nullref`.
Change-Id: I43ba5da222a848214647980f7b4876940546242a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268463
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Previously for function equality we compared contexts and vtables. This
works for top-level functions, local functions, function literals, and
instance method tear-offs, but not for extension method tear-offs.
Extension method spec specifies extension method tear-offs as never
being equal to any other function object. See #50475 for discussion and
references.
Extension method tear-offs are implemented as function literals
capturing `this`. For example:
class A {
final int i;
A(this.i);
}
extension X on A {
void g() {}
}
void main() {
final a = A(123);
print(a.g == a.g);
}
The tear-off `a.g` compiled to kernel:
static method X|get#g(lowered final self::A #this) → () → void
return () → void => self::X|g(#this);
This CL changes function equality to only consider two closures equal
when their contexts are a receiver (`this`). In all other cases it works
as before.
New comparison code (pseudo code):
bool _equals(f1, f2) {
if (identical(f1, f2) return true;
if (f1.vtable == f2.vtable) {
if (v1.context is #Top && v2.context is #Top) {
// Closures are instance tear-offs, compare receivers
return identical(v1.context, v2.context);
}
}
return false;
}
Because extension method tear-offs are actually closures that capture
`this` (rather than instance methods), their contexts are don't have the
same type as instance tear-off contexts and the new check returns
`false`.
New passing test: co19/LanguageFeatures/Extension-methods/tearoffs_t02
Fixes#50475
Change-Id: Ica57b16301b9276059103cbdbdd6c0730040e844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270380
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Added `_SharedCaseScope`, and added `key` parameters to
`switchStatementSharedCaseScope*` methods, to verify the consistency
of method invocations.
Change-Id: Ia4c552351bf367814f8c5ba645ac7aa0e0af1c94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270320
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
By creating a mixin shared by the `Pattern` and `GuardedPattern`
classes, we can avoid having to explicitly write `.noGuard` in cases
where a pattern doesn't have a corresponding guard.
Change-Id: I9178674306fca1c6517a3c54f27fb2f28cf17716
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270229
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
When I run
`out/ReleaseX64/dart-sdk/bin/dart pkg/analysis_server/benchmark/benchmarks.dart run analysis-server`
locally the process often doesn't finish because of a timing bug.
This fixes the one I'm running in to.
Change-Id: Ie94de8c4bb59211bff39ca2df1f8dd63fc53cc75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
V8 and Binaryen now both accept a function type immediate for the
version of call_ref using the proper opcode value of 0x14.
Change-Id: I1010de82d97df0ff80ff1365e2f827d7fd78eb81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266162
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
This adds a new generated file into _fe_analyzer_shared for the
experimental flags. This is now used by the parser when generating
messages about features not being available.
The default implementation uses whether the feature is enabled by default
or not, to emit different messages. This change will therefore ensure
that when a missing feature changes from 'experimental' to
'enabled by default', the message reported by the parser will be
updated accordingly. Currently errors are only reported from the parser
on features that are enabled by default, so the message for experimental
features is not currently used.
The reporting is performed through the Listener, such that
implementations can override the reporting to improve the messaging.
This is done in the CFE where the message is improved to take into
account whether the language version is explicit in the parsed library.
In response to https://github.com/dart-lang/sdk/issues/46329
Change-Id: Ief812817c7eb4b1e433389f6f49d6a1f77604fa7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269860
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Stop using PromotableElement in analysis_server/.
Change-Id: If543c1e5e73112335634ecab5b275322010b0b66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269203
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Johnni's confirmed that these constants will be sorted by name.
Change-Id: I1d48055d6f80673d64b28c889a1f2015f9e20a73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270222
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Mark Zhou <markzipan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
All callers of TypeAnalyzer.recordType() were packaging the positional
and named fields into a RecordType object, which all implementations
immediately unpacked.
It's more efficient (and straightforward) to just pass the positional
and named fields as separate arguments to TypeAnalyzer.recordType().
Change-Id: I5c7fbdf0d4a2c01abbc157ad63a23d0e1a840f2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269983
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
No standard Dart package creates build directory
.packages is gone
Change-Id: Ib9859a7147f251c0e6422fa75e0d24c7ab3c6070
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270025
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
See patch 2 for failures coming from this new analysis option.
Change-Id: I6bb10c2eb12431f6c503cc817a9c9bb45ba597a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269800
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
_InternalLinkedHashMap => _Map
_InternalImmutableLinkedHashMap => _ConstMap
_InternalLinkedHashSet => _Set
_InternalImmutableLinkedHashSet => _ConstSet
This makes things nicer to read in places that display implementation names, such as stack traces, debuggers, profilers and inspectors.
TEST=ci
Change-Id: Iec851c80ea2086cbe79934565dbf35f04809a836
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266303
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Fixes test language/inference_update_2/field_invocation_promotion_test
on front end configurations.
Note that there is still an outstanding problem with `this.property`
and `super.property` getting treated as synonymous
(https://github.com/dart-lang/sdk/issues/50138). That will be
addressed in a later CL.
Bug: https://github.com/dart-lang/language/issues/2020
Change-Id: Idb95601b47711df5ca7517c83621638783446e45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269743
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
`python3 tools/test.py --write-results ...` fails to run if the default
directory (logs) doesn't exist. Create the directory if it doesn't
exist.
Update .gitignore with the correct default paths of logs.json and
results.json.
Change-Id: Ib1118387195c3bb30b350ef3748e66b4057c57de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269880
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Effects of this change are minimal on a large application:
- ~9100 new members being tracked.
- +500KB closed world serialized output (.3% increase)
- No discernible difference in closed world runtime
- Heap space in global inference after closed world deserialization increase is <1MB.
- No change in JS output
These abstract members will be used by the new hierarchy-based dynamic call type graph linearization.
Change-Id: I4ce56d12e039effe0a855fd23f2a5e69d0847025
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264900
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
The front end synthesizes forwarding stubs in several circumstances.
We only want forwarding stubs of the "no such method" variety to
prevent field promotion. (The others exist just to adjust signatures
or to forward to mixins; they always forward to procedures or fields
with the same name, so they don't need to cause field promotion to be
disabled).
Fixes test
language/inference_update_2/field_promotion_and_no_such_method_test.
Bug: https://github.com/dart-lang/language/issues/2020
Change-Id: Ia45c127a9fd50c958dfa5d2e0bc7844b51c77989
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269603
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
`sealed` and `abstract` modifiers are mutually exclusive. Error when a user tries to use them together on a class declaration.
Implemented in the parser since it's a common error between the analyzer and the CFE.
Change-Id: I9a8835c29ddb430ea0f005630bbdf9348f8b055c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
(The elements were already being populated.)
TEST=ci
Change-Id: I02cfa2f311e7871836f1eddd8ed131c282235d58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269383
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
We were planning on making the `value` property of `BoundField` have
type `@Instance|Sentinel|bool|int|double`, but we have decided to stick
with `@Instance|Sentinel`.
TEST=CI
Issue: https://github.com/dart-lang/sdk/issues/49724
Change-Id: Ia728586e695c14c0597f377e6c110329e553d62c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269440
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
Currently `selectorForTarget` is used for two different things:
1. In `DispatchTable.build` when creating selectors. This process
creates new selectors, and if a selector for a member already exists,
updates the selector's signature and `calledDynamically` field.
2. After `DispatchTable.build`, when generating code. These calls should
never create a new selector and should never change fields of an
existing selector. If this creates a new selector, the selector won't
have a dispatch table entry and we'll have a crash in compile time
when we ask for the new selector's offset. If this updates an
existing selector, that can invalidate the selector's signature after
it's computed.
To avoid accidentally updating selector state in (2) this CL renames
`selectorForTarget` to `_createSelectorForTarget` and uses this in (1).
The original `selectorForTarget` now only returns an existing selector
from the selector map and doesn't update any selector state or create a
new selector.
Change-Id: I7b2a555166d8715a24df285af864c57958d92a07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269680
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
The member is not used outside of `DispatchTable`, and the use in
`DispatchTable` can be refactored to use the member's value directly.
Change-Id: I7f9070740337f88c1f19c3113f16050256b95481
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269660
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
There has been reports of slow analyzer queries that ~locked up VSCode,
and I was given a (reproducable) example by @yousefi.
Turns out that, at least what I could reproduce, wasn't the analyzer
being slow, but rather the analyzer never responding to a query in
certain timing-related situations.
In the concrete example a test-script checks out another copy of the
directory opened by VSCode _inside_ the same directory (say root folder
opened by VSCode was "foo" and now it gets "foo_copy" inside it), this
causes `_destroyAnalysisContext` to be called, effectivley stopping all
in-flight queries via the stopped `AnalysisDriver`s, meaning that a
response is never given.
I can also reproduce the same thing by for instance having
`pkg/analysis_server` open in VSCode and then checking out a many
months old revision (while firering queries).
This CL is a suggestion for how to fix it: When disposing of an
`AnalysisDriver` we finish all waiting `Completer`s with an error,
this means a response is given and that VSCode stops waiting.
Change-Id: Idc04bf1d1d3f86a6d12bb77f5805064c67965209
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269300
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Both the calls to ClassHierarchy.commonSubclasses and UnionTypeMask.flatten (in the worse case) are expensive for large programs. Certain programs can have a type structure that ends up in the UnionTypeMask.flatten case very often which can be especially taxing.
Change-Id: I7799d2f5a7f764162a4ca753bfa37b11f583373f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269221
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
This adds support for looking up injected members though the members
builder. It also changes the duplicate handling to match the invariant
used elsewhere; that the used member is the one declared first and not
any of the subsequent, and the so-called, duplicate members.
Change-Id: If9c06a8e17af482b4365da44798b47b54e5277dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268946
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This version contains a number of updates to WasmGC:
- `dataref` is replaced by `structref`.
- `call_ref` now takes a function type immediate, both with the proper
0x14 opcode and the temporary 0x17 opcode.
- Some of the new type test/cast instructions are implemented,
specifically `ref.test`, `ref.cast`, `ref.test null` and
`ref.cast null`. The new `br_on_cast` and `br_on_cast_fail` are not
yet implemented.
Additionally, the `--wasm-gc-js-interop` flag is removed, and interop
is always enabled.
Change-Id: Ibe7a1d9e8800f89096239ff5afa16e80322e01c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266161
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
This CL implements the following update to the spec
d668c82840
Change-Id: I70b1f12da340a8218f3559adaef60855c378716e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269304
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
* Also, fix missing quotes in message
* Also, do not report CLASS_INSTANTIATION_ACCESS_TO_UNKNOWN_MEMBER
when obviously not a constructor name.
Fixes https://github.com/dart-lang/sdk/issues/50439
Change-Id: Idd78790289068bab1c20314d185a9abce1849ea2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269202
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
For b/254330485
Change-Id: I5a3993753dfe559426ce0517c1527eba27221759
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265120
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>