When deferred loading was enabled the dynamic dispatch class ID table
was incorrectly assigning class IDs to the wrong module. If a contiguous
target segment included classes/targets from different modules, all of
them were getting assigned to the module of the first class/target in
that segment.
This was causing spurious NSM exceptions as the necessary rows in the
table might not be populated for a dynamic call if the module the
segment was assigned to wasn't loaded yet.
To fix this we end the segment if the next target does not belong to the
same module as the active segment.
The new test fails with an NSM exception prior to this fix.
Change-Id: I07bc4fdb5a8bff1bfad5fe17f45c8076a965a775
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502860
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Populates the `kind` on the Document Highlights we return. This allows colouring reads and writes differently (which it turns out VS Code does by default).
The options are a bit limited (Read/Write/Text) and using Read/Write for things like type names feels slightly odd, but the spec does seem to encourage this and it's what TypeScript is doing.
Fixes https://github.com/dart-lang/sdk/issues/62929
Change-Id: I6a53450038cde31b399b5b1aca5f964083106763
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503060
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
This is another step toward being able to maximally convert a body of
code to using the primary_constructors features.
This CL does two things:
- Changes `convert_to_declaring_parameter` to also be a fix and applies
that fix to the `use_declaring_parameters` lint.
- Updated the `use_declaring_parameters` lint to also flag field formal
parameters.
Change-Id: I8b584186658abc73c025b166c145efbab95acd8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502740
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This CL adds a lint as part of the collection of lints used to automate
converting code to use the features under the primary constructors flag.
The lint flags initializers in a primary constructor body that
initialize a field in such a way that the initialization could be done
in the field declaration's initializer.
It only flags assignments to fields where the right-hand side of the
assignment includes a reference to one or more of the constructor's
parameters. Expressions that don't reference a parameter would have
been valid to move before primary constructors, so flagging them
wouldn't help find bugs in the impementation of the feature.
If we were going to ship this lint, then we might want to extend it to
find initializers that don't reference parameters, whether they are in
the primary constructor body's initializer list or in the initializer
list of a secondary constructor.
This doesn't include a fix. Once again, I wanted to make sure the lint
was covering all the important cases before implementing the lint.
Change-Id: Id4b1e02ec160af50af8f4fe7b8c675213e41abc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502202
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
With the removal of the VM isolate and less bootstrapping being repeated in the AOT runtime, ApiError cannot be instantiated until after snapshot loading succeeds.
TEST=ci
Change-Id: I5be295e87e6d6351ada40d2837825b1f93672ac7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501262
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Add checks to create enclosing directory before writing any files. If
the directory does not exist, these file creations will end up in an IO
exception.
Since dart2wasm might be writing many files to the same directory, keep
track of directories we know exist in memory to skip the extra file I/O.
Change-Id: If2d4a4973fe58f12c26d98578418420d964c3f84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502600
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
This CL only adds the option and appropriate uses of it. Followup
CLs will use it to actually generate appropriate instructions and
metadata for collecting coverage information.
TEST=ci (just adding flag)
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try
Change-Id: I194154ef926abe7dae8bb93f397fb68029e2db3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501500
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
In the VM, factory constructors always had an extra "type arguments"
parameter, even if class is not generic. Factory constructor bodies
were using class type parameters instead of function type parameters.
This results in extra code when calling non-generic factories
which is slightly inefficient in terms of code size and performance.
Also, it creates an additional complexity throughout the system as
factories should be special cased in many places.
This change removes artificial "type arguments" parameter, treating
factory constructors basically as static methods. This matches
kernel AST representation.
TEST=ci
Change-Id: I957583cb2ce9a3c408699880a04036e06b01dd31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501762
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This test verifies how deoptIds and environments are set
when inlining force-optimized functions.
The problem is that it looks at the chain of inlined calls:
foo() {
call1 -> Pointer.fromAddress
}
Pointer.fromAddress() {
call2 -> _fromAddress
}
// force-optimized
_fromAddress() { ... }
During inlining of force-optimized callee, its instructions
should receive deoptId/env from inlined call site.
In this case, the call site is 'call2'.
However, the test has been matching deoptId/env with 'call1'.
It was a mere coincidence that deoptIds of call1 and call2
were the same. Any attempt to make a change which would
affect deoptIds within Pointer.fromAddress breaks this test.
In order to fix this, a simpler setup is now used:
foo() {
call1 -> newHash()
}
// force-optimized
newHash() { ... }
Also, the check for deoptId of outermost environment is dropped as
in this case there are no multiple environments.
In addition, also remove the duplicate pragma from _fromAddress.
TEST=vm/cc/Inliner_InlineForceOptimized
Change-Id: I1f592a74dfb8b7c2f67f3b0a51e7f7b74bf358eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502801
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
When checking number of arguments passed by the caller against
number of parameters in the callee, inliner was not taking
"type arguments" argument into account which resulted in
the rejected inline if all optional parameters are passed.
TEST=runtime/tests/vm/dart/inline_generic_functions_il_test.dart
Change-Id: I38d1fd2a1a4aadfb0196e5a472d224e3da3a1562
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502800
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Adds two new getters to int for bit-counting: trailingZeroBitCount
(ctz) and oneBitCount (popcount). On native platforms they operate
on the full 64-bit two's-complement representation; on the web they
operate on the least-significant 32 bits.
Implementations:
- VM: unified C++ natives Integer_trailingZeroBitCount /
Integer_oneBitCount on _IntegerImplementation, using
Utils::CountTrailingZeros64 and Utils::CountOneBits64. The receiver
may be _Smi or _Mint at runtime.
- dart2js / DDC: clz32-based ctz and a SWAR popcount.
- dart2wasm: inlined i64.ctz and i64.popcnt intrinsics.
leadingZeroBitCount (clz) is intentionally excluded from this CL: its
result depends on the platform integer width (e.g. 1.leadingZeroBitCount
is 31 on web, 63 on native), and the same value can be derived from
the existing bitLength getter when needed.
Asm intrinsification on native architectures is intentionally left for
a separate follow-up CL.
Work towards https://github.com/dart-lang/sdk/issues/6486 (this CL
covers popcount and ctz from the bit-twiddling list; clz, rotate,
reverse, and others remain).
Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
BitSet implementation).
Bug: https://github.com/dart-lang/sdk/issues/52673
Bug: https://github.com/dart-lang/sdk/issues/38346
TEST=tests/corelib/int_bit_count_test
Change-Id: I8a5cdb5c91360478f47bbd6b9c84ca1c477aa8c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498041
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Since extension type constructors are lowered to top level procedures, the occurrence of `return;` must be lowered to `return #this;` where `#this` is the variable holding the this value.
Closes#63361
Change-Id: Ia9b444509767693107a911526de989e6a3c51180
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502900
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Previously the getter VariableBase.context was redirecting to
VariableBase.parent, effectively requiring a change of the ownership
over the variable. This CL makes VariableBase.context a field of
VariableBase, allowing for the previously existing ownership structure
of the AST tree nodes.
The change allows to avoid workarounds for the existing
ownership-restoring logic, such as the assignments to the `parent`
pointer made in the constructors of the AST nodes and their
`transformChildren` and `transformOrRemoveChildren` methods.
Part of https://github.com/dart-lang/sdk/issues/61572
Change-Id: I307c9d2b23c8201f8d7d2a100acf9fb8f3af2572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494441
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Move the creation of
* name of a lambda to `translator.functions.getLambdaFunctionName`
* type of a lambda to `translator.functions.getLambdaFunctionType`
Removes dependency on `w.FunctionBuilder` in the lambda code generators
- as they don't need access to the wasm function. This may allow
inlining closure calls in the future.
Avoid creating `w.FunctionBuilder` eagerly when analyzing closures and
instead create it only when there's a call to it (or the closure object
gets instantiated).
Use `CallTarget` abstraction when invoking lambdas.
Avoid carrying around
`(lambda, enclosingMember, enclosingMemberClosures)` throughout
the codebase and instead store this information on `Lambda`.
=> All these changes make the codebase more uniform between
lambdas and normal functions and also is net code removal.
Change-Id: Ib69566ea9580827be0ed52c0c179884e84599d88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501983
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
This removes the LegacyVariableDeclaration and VariableInitializationBase classes to create a simpler hierarchy. This is done preparation for splitting variables from statements.
TEST=existing
Change-Id: If29c9eee1e3d8bed819ce53ed178c3efa3bffaea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501961
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Add a compile-time diagnostic for augmentations that declare an explicit
return type different from the introductory declaration. Check top-level
functions, methods, and getters by comparing the augmentation annotation
against the introductory element return type using normal type equality.
Keep executable element return types initialized from the first fragment
only, so later augmentation fragments cannot overwrite the introductory
signature before validation. This also keeps synthetic getter/setter
variables based on the introductory declaration.
Change-Id: I08d55497e235ed2619a6915e0060bd5d8c8a45b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502200
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This CL adds code such that web compilers can recognize that `Let` nodes
can have a non-temporary variable as parameter. Before this CL, ddc
configurations fail in many anonymous method tests because the given
explicitly declared parameter isn't made available to the body of the
anonymous method.
Bug: https://github.com/dart-lang/sdk/issues/63184
Change-Id: I308c89e91e3856a06fa8f003d213cda0d93ae261
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498060
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Use the collection-wide OwnedFiles map as the single source of truth for
deciding which analysis driver should process each file during search.
This replaces the per-query SearchEngineCache and SearchedFiles
ownership tracking with ownership recorded as files are discovered.
Store file paths, rather than URIs, in the analysis index so that
indexed element and subtype identifiers use the same File resources that
OwnedFiles tracks. Skip non-file sources when building or querying these
identifiers.
This lets search operations discover available files up front and then
search only files owned by the current driver. It avoids duplicate work
and duplicate results across drivers while keeping search ownership
consistent for references, subtypes, member declarations, top-level
declarations, and workspace symbols.
Bug: https://github.com/dart-lang/sdk/issues/63276
Bug: https://github.com/dart-lang/sdk/issues/63310
Change-Id: I27feed534cb84f52bffbd4da0c53e5c669910b1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500300
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Report augmentationModifierExtra and augmentationModifierMissing when an
augmenting class or mixin does not use the same modifiers as the
introductory declaration.
Check class augmentations for abstract, base, final, interface, sealed,
and mixin modifiers. Check mixin augmentations for the base modifier.
Keep the explicit syntactic abstract modifier on class fragments
separate from the semantic abstract state in the class. This lets sealed
declarations continue to produce abstract class elements without making
their fragments appear to have an explicit abstract modifier, so
augmentation modifier checks can distinguish sealed from abstract
sealed.
Change-Id: I169e16c7b7363802d91882759550264f1c96f026
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502183
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Set up a cancellation Completer that we forward errors to if the stream
has been cancelled.
Also add `isDone` which will avoid forwarding registering the
cancellation logic if the stream has already finished.
Fixes test
co19/Language/Expressions/Function_Invocation/async_generator_invokation_t10.dart
on wasm targets. This test already passes for all other backends.
Fixes: https://github.com/dart-lang/sdk/issues/63123
Change-Id: I8a3d87c3ea7b4ebb3a7b82ab064fb57034aa6f4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495200
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
The purpose of this lint is to be used with other lints to maximally
convert code to using the new features introduced by the primary
contructors feature. This one is targeted at finding container bodies
the could be replaced by a semicolon.
This CL does not include a fix. That will be added in a separate CL.
We will need to decide whether this lint is worth supporting beyond
the testing period.
Change-Id: I5d2d05117c9f1efc8c71279d5cde549eb48b480c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502182
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>