Previously, we were crashing when trying to report a compile-time
error via H.ReportError when loading a bootstrap library from kernel.
That happened because we didn't have LongJumpScope set up.
This change sets up LongJumpScope and makes sure compile-time
errors during kernel loading can be reported and propagated up.
This also removes the need to use FATAL error when detecting
a dill file which is incompatible to the current runtime mode,
so we can use less severe compile-time error for that.
Fixes https://github.com/dart-lang/sdk/issues/41870
Change-Id: Ib3690f7812c20e5529f3066ed37fdb9052dd559b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148683
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Snapshots which contain code are compiled with a particular null-safety
mode and it is not possible to change their mode at run time.
When running from such snapshot, VM now reads null-safety mode from
the snapshot if it is not specified at the command line.
This avoids the need for embedders to pass null-safety flag
used during snapshot generation also to the runtime, similarly to
other VM flags listed in VM_GLOBAL_FLAG_LIST (such as use_bare_instructions).
In addition, error for incompatibility of kernel libraries with
current null-safety mode is changed from ReportError (which attempts
to throw an exception) to a FATAL, because throwing an exception
crashes when bootstrapping from a kernel file.
Change-Id: I93a791825c25c2da4e33634f1c71736c17928fea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146460
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Special sentinel values which are used for lazy initialization can be
stored in variables of any type. In NNBD world Null is no longer a
bottom type as null cannot be assigned into variables of non-nullable
types. The new universal bottom type is Never, so type of sentinel
values is changed from Null to Never.
This also allows to make late fields non-nullable in the type
propagation and avoid extra updates to field guards.
This change also adds special handling of comparisons with sentinel
values into constant propagation as it can constant fold comparisons
of values with different cids.
Fixes https://github.com/dart-lang/sdk/issues/40796
Change-Id: I8266cfba0cc434b78ffa9570c30d434d4380d4af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143864
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Make them form its own source set (libdart_compiler) and completely exclude
them from AOT runtime targets.
Previously we had some inconsistencies, with some files were using
DART_PRECOMPILED_RUNTIME to fully or partially exclude either contents
from their headers or from implementation, while other files did nothing
and relied on linker to throw their contents away.
This change tries to address this inconsistency.
A follow up change would include a check in most compiler headers which
would prohibit to use them while building AOT runtime.
Change-Id: Ief11b11cbc518b301d3e93fce80580a31bbad151
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142993
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
In JIT mode, if late static field is already initialized we don't need
to infer nullable type for its LoadStaticField, as sentinel checks
can be removed at that point. This change modifies type propagation to
only force nullable types for late static fields which are not
initialized yet.
Also, this change removes unnecessary RecordStore(Object::null_object())
for late static fields, as guards are not generated for static fields
and guarded_cid for those fields is not be updated.
Fixes https://github.com/dart-lang/sdk/issues/41276
Change-Id: I35c8297a0dbf62bbe3c318fe8944d10136b139d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141940
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Only mark static fields with initializers as late in opted-in
libraries (static fields without initializers should be still
pre-initialized with null and not sentinel).
Change-Id: I1371757c383ca53cc6cc798a31395f039b8719d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141341
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
According to the NNBD feature specification, "a toplevel or static
variable with an initializer is evaluated as if it was marked late".
This change actually marks all static fields in opted-in libraries
as late, in order to make sure that the rest of the VM handles
such fields uniformly as late.
Without this change implicit getters for such fields were generated
as late, but type propagation didn't treat these fields as nullable,
so field initialization checks were removed if field has a non-nullable
type.
Change-Id: I95bc096fb1d304b112369428dbb29d346964383f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140767
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
This fixes some mirrors failures in NNBD legacy mode, since the CFE is
inserting more synthetic functions now, to handle interfacing between
libraries with different NNBD status.
Change-Id: Iad5cb2548ef118f842bf2eadf249d4dca9f38fa7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139740
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
In order to have instance calls with unboxed parameters, all
the possible targets need to be able to those parameters unboxed.
Then, the methods were partitioned according to the class hierarchy,
and the inferred types from TFA are used to determine the parameters
that could be unboxed.
This is done for non-nullable integer and double parameters, and
return value.
dart-aot linux x64:
Bench2D 8.028%
DeltaBlue 4.688%
ParticleSystemPaint 27.79%
Flutter release android-armv8:
velocity_tracker_bench -2.026% (less is better)
flutter_gallery_total_size -0.1460%
flutter_gallery_instructions_size -0.2715%
flutter_gallery_readonlydata_size 0.0539%
Issue https://github.com/dart-lang/sdk/issues/33549
Change-Id: Iedd9b4321c3d78b406ea1708e15c747754433027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138501
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
Static methods and constructors may receive unboxed parameters.
This change adds a bitmap to the RawFunction object indicating
which parameters are unboxed and their types. Also, the stack frame
bitmap was updated to include new bits for those parameters.
The ArgumentsDescriptor object was updated to store not only the number
of arguments, but also their size, since 32-bit platforms would use two
words for each int64 and double value.
In addition, static methods that return non-nullable integers
and doubles may return these values unboxed.
Dart AOT x64:
TypedData.Uint8ClampedListViewVarBench +11.73%
DeltaBlue +9.32%
Meteor (Intel Xeon) +4.64%
Flutter release android-armv8:
velocity_tracker_bench -2.32% (less is better)
flutter_gallery_readonlydata_size +0.18%
flutter_gallery_total_size +0.13%
flutter_gallery_instructions_size +0.12%
Issue https://github.com/dart-lang/sdk/issues/33549
Change-Id: I97e310f8f30213920af2333fbdedf193d03db5c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135313
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Adds 2 bits to RawLibrary flags to encode CFE compilation mode.
If in weak mode, apply legacy erasure to types of constants from agnostic
libraries, i.e.:
- Map Never to Null
- Set nullability to legacy
- Erase 'required' flag on named parameters
Change-Id: I57feeef3fa1689a5cb93b3fa983ea3d65047b8c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137735
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Fix the tests by disabling the optimisation that turns getter calls into
raw gets if the field is late, and by calling recording the null init
store in bytecode mode.
Change-Id: I8f12e3237cd32c890b5cef8d00c32940e937330d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134180
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This reverts commit 9eb531bde4.
Reason for revert: Bots are red. Some tests are failing.
https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-obfuscate-linux-release-x64/6039https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-android-release-arm_x64/957
Original change's description:
> [vm] Add support for real unboxed floating point fields in AOT
>
> Non-nullable floating point fields (double, Float32x4, Float64x2)
> are fully unboxed in their classes.
>
> A bitmap for each class was added to the shared class table in order to keep
> track of the pointers of the classes. Since all classes in Flutter Gallery
> have less than 64 fields, the bitmap is represented by a 64 bit integer and
> fields whose offset is more than 64 words are not unboxed.
>
> The instance sizes and field offsets might change between target and host
> in cross-compilation, since the number of words used to store unboxed fields
> may differ.
>
> dart-aot Xeon
>
> SplayLatency -4.62%
> SplayHarderLatency -4.17%
> NavierStokes -2.20%
> Tracer 8.72%
> ParticleSystemPaint 2.90%
> NBodySIMD 8.35%
> NBody 25.59%
>
> With hack TFA to make doubles in Rect/Offset/Size classes in flutter non-nullable:
>
> flutter arm-v8:
>
> gallery total size: -1%
>
> matrix_utils_transform_rect_perspective -16.70% (less is better)
> matrix_utils_transform_rect_affine -31.82% (less is better)
> matrix_utils_transform_point_perspective -24.90% (less is better)
> matrix_utils_transform_point_affine) -27.26% (less is better)
> rrect_contains_bench -4.719% (less is better)
>
> Change-Id: I9ae09c9c3167d99f9efd071a92937aa51093fd1d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131824
> Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Samir Jindel <sjindel@google.com>
TBR=kustermann@google.com,rmacnak@google.com,sjindel@google.com,victoragnez@google.com
Change-Id: Ic73858f6adb7f55c4129d4f46ff4731b378cb634
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134020
Reviewed-by: Zichang Guo <zichangguo@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
Non-nullable floating point fields (double, Float32x4, Float64x2)
are fully unboxed in their classes.
A bitmap for each class was added to the shared class table in order to keep
track of the pointers of the classes. Since all classes in Flutter Gallery
have less than 64 fields, the bitmap is represented by a 64 bit integer and
fields whose offset is more than 64 words are not unboxed.
The instance sizes and field offsets might change between target and host
in cross-compilation, since the number of words used to store unboxed fields
may differ.
dart-aot Xeon
SplayLatency -4.62%
SplayHarderLatency -4.17%
NavierStokes -2.20%
Tracer 8.72%
ParticleSystemPaint 2.90%
NBodySIMD 8.35%
NBody 25.59%
With hack TFA to make doubles in Rect/Offset/Size classes in flutter non-nullable:
flutter arm-v8:
gallery total size: -1%
matrix_utils_transform_rect_perspective -16.70% (less is better)
matrix_utils_transform_rect_affine -31.82% (less is better)
matrix_utils_transform_point_perspective -24.90% (less is better)
matrix_utils_transform_point_affine) -27.26% (less is better)
rrect_contains_bench -4.719% (less is better)
Change-Id: I9ae09c9c3167d99f9efd071a92937aa51093fd1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131824
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
index to fix VMs coverage issue
This CL fixes the VM not always reporting coverage for mixin usages
properly.
* When asking the VM for coverage you can do it in one of two ways
* Ask the VM for coverage for everything; or
* Ask the VM for coverage for a specific script
* Asking the VM for coverage for everything works perfectly fine.
The VM goes through everything and reports coverage correctly.
* Asking the VM for coverage for a specific script (which is, at least
now, what the flutter tools does) doesn't work in the simple mixin
case described at http://dartbug.com/39779: The VM goes through the
libraries, asking for the list of scripts they "know about",
and checks for matches against what you asked for.
In this case, when asking for 'master.dart', the library for
'lib.dart' says no when it shouldn't --- because of the way the mixin
transformation works the content is actually in lib.dart.
This CL updates the content of the field 'sourceReferences' on Library
to fix the issue.
Fixes#39779
Change-Id: I0c38a323c81d1784ade704837b67ece549fc95d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128585
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
When creating a KernelProgramInfo, we create several logical views into the kernel buffer. These are fresh ExternalTypedDatas, rather than proper TypedDataViews, so they do not automically keep the original ExternalTypedData alive. Create an explicit reference to the orginal ExternalTypedData in the KernelProgramInfo. When creating snapshots, this reference is ignored/null'd and the views are turned into copies, effectively dropping the parts of the original buffer that do not have views.
Fixes a leak with reload and a use-after-free with eval.
Bug: https://github.com/dart-lang/sdk/issues/33973
Bug: https://github.com/dart-lang/sdk/issues/39610
Change-Id: I09d3830133314ccbaa0341d904127c2b6925c4ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126825
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This is done by collecting all frames on the current stack until an async/async* frame is hit
which has yielded before (i.e. is not in sync-async case).
From there on it finds the closure of the async/async* frame and starts traversing the listeners:
while (closure != null) {
yield_index = closure.context[Context::kAsyncJumpVarIndex]
pc = closure.function.code.pc_descriptors.LookupPcFromYieldIndex(yield_index);
<emit pc in frame>
closure = closure.context[Context::kAsyncCompleterVarIndex]._future._resultOrListeners.callback;
}
Bug: https://github.com/dart-lang/sdk/issues/37668
Change-Id: I97030d22e529bf8a74ecd30a8a2589cfe57ad330
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122644
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Right now `Script::yield_positions()` is an array mapping function start
token positions to arrays. Those arrays contain token positions and are
indexed by yield index.
=> This `Script::yield_positions()` is not available in AOT mode.
The fast async stack implementation will need to be able to find out
where an async closure was suspended. It does so by looking at the
":await_jump_var", which contains the yield index. It then needs to
associate the yield index to token position of the yield.
This CL adds an entry into the PcDescriptors for every yield in a
async/async* function and removes `Script::yield_positions()`.
The entry will associate the yield index with the token position.
Flutter gallery total size impact for flutter-release:
- armv7: +0.016%
- armv8: +0.045%
Issue https://github.com/dart-lang/sdk/issues/37668
Change-Id: I0b2ce41e85d8f5d590201bf2fb091578d7379890
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125408
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This paves the way for removing the old constant evaluator from the VM,
by no longer supporting versions without front-end constant evaluation.
For the front-end test that tests old kernel versions on the newest VM,
the dill files for versions before 29 are deleted.
Version 29 is from 2019-08-16: eae781c73e
Change-Id: Icb472bffc764d6e37ed1349a0cb4ff281e0e1b21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123739
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
VM creates Script objects with kKernelTag only, so this CL cleans up
all uses of script tags and Script::kind() along with code
which is no longer reachable.
Change-Id: Ia765e7757264aa614e18eddd16d21937f855c129
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123889
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Consume the extension flag setting for functions and the extension flag and is late
flags for fields when reading kernel file and set bit in Function/Field objects.
Change-Id: I661d30d53e817d968151d2b95474a6daf918de13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118000
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Introduced a new code path to load declaration of a referenced class when
loading bytecode, if referenced class is from the same binary. In such case
it's possible to reuse current BytecodeReaderHelper.
Also, AlternativeReadingScope is simplified to save/restore only reader
offset (which is needed in most cases), while saving/restoring data is
still available in AlternativeReadingScopeWithNewData.
This change fixes stack overflow while reading deep class hierarchies in the
tests co19_2/Language/Types/Interface_Types/subtype_t27 and
co19_2/Language/Types/Interface_Types/subtype_t28 with bytecode in
vm-kernel-linux-debug-ia32 configuration.
Change-Id: Iffb1678286c6926926fab465f70251992d451241
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117204
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>