Commit Graph

269 Commits

Author SHA1 Message Date
Alexander Markov 8445424db4 [vm/nnbd] Fix marking static fields as late
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>
2020-03-27 17:08:52 +00:00
Alexander Markov 8c4909aa8f [vm/nnbd] Mark static fields in opted-in libraries as late
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>
2020-03-24 22:22:57 +00:00
Alexander Markov fa54a92970 [vm/nnbd] NNBD fixes for bytecode
* Take nullability of type parameters into account.
* Handle CheckNull instruction with null selector name.

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

Change-Id: I0ff4c2790ea63e8f23ead6c9f479b8806045f012
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140800
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-03-24 21:50:57 +00:00
Liam Appelbe 318b42572e [vm] Mark member signatures as not reflectable
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>
2020-03-19 17:54:19 +00:00
Alexander Markov d850801691 [vm] Cleanup code related to interface calls through fields/getters from TFA and bytecode generator
Since https://dart-review.googlesource.com/c/sdk/+/129702 CFE desugars
interface calls through fields/getters, so there is no need to handle
them in the TFA and bytecode generator.

Note that VM can still see such calls if they are dynamic, so
handling of such calls is not removed entirely from TFA or VM.
Also, VM should support those as long as it supports older kernel
binary versions.

Issue: https://github.com/dart-lang/sdk/issues/34497
Change-Id: Ic49f109b0e9264f0e20a7e1a3b7a46011fa76c86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137700
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-03-03 22:36:23 +00:00
Régis Crelier 5701c4fd3b [VM/nnbd] Remove propagation of library mode to runtime after spec change.
On 1/27/20, the nnbd specification changed weak and strong mode instance checks
to make them behave uniformly across legacy and opted-in libraries.
Therefore, it is not necessary anymore to propagate the library mode in
generated code to the runtime.

Change-Id: I42d3ddc6e9a921899aeac21be6374c7893a6d27c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138111
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-03-03 20:30:32 +00:00
Liam Appelbe f5a830a087 [vm] Update late final fields with init to match new spec
Spec was updated here: https://github.com/dart-lang/language/pull/720

Bug: https://github.com/dart-lang/sdk/issues/40204
Change-Id: Id4f5bc9a62d9cf5c0b3e4d12a13b3049cbe07a56
Fixed: https://github.com/dart-lang/sdk/issues/40204
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132408
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2020-01-17 23:51:59 +00:00
Johnni Winther d08f070b28 [cfe] Add canonical way to detect the synthesized redirecting factory field
Change-Id: Ied5ffe786558856c4e63881880cbd19fa0bd6c68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131620
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-01-14 09:42:45 +00:00
Régis Crelier b92fefdfe9 [VM/nnbd] Pass nnbd mode from compiler via generated code or bytecode to runtime functions performing type checks or type reification.
This continues the work started in https://dart-review.googlesource.com/c/sdk/+/124105
The nnbd mode is now part of the type arguments instantiation cache,
since the resulting vector depends on the mode.

Change-Id: I803c07fa9473024557db8585e87286f16681169a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128307
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2019-12-20 03:26:29 +00:00
Régis Crelier f2618b0077 [VM/nnbd] Make type Never a regular type.
This is a follow-up CL to https://dart-review.googlesource.com/c/sdk/+/128001
 Type Never now also accepts legacy and nullable nullabilities.

Change-Id: I52c270bdca9afdad8193f797011774afae618b7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128566
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-12-16 22:25:43 +00:00
Johnni Winther 818ec6db92 [cfe] Implement nnbd-top-merge
+ and use nnbd-top-merge and legacy erasure in hierarchy computation

Change-Id: I4bf06ce8d3c68a9926865ebf84b24b4029828d73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128065
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-12-13 17:19:59 +00:00
Régis Crelier 8caaf3b7fd [VM/nnbd] Map nullable Never type to Null type.
Map nullable Never type to Null type when reading kernel files and also during
type parameter instantiation.

Change-Id: Iea2d895631661fc01adac65bfd6234e9adeecb1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128001
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-12-10 23:22:46 +00:00
Alexander Markov b57e10ad28 [vm/nnbd] Fix nullability of types in inferred types attribute
VM doesn't expect legacy nullability for Null type, so nullability
should be adjusted when writing AOT-specific inferred types attribute in
bytecode.

Change-Id: I58b09c9931f3cce6e70f661f1ba3e7e015e7f739
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127985
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-12-10 22:03:16 +00:00
Alexander Markov c74a8ec2c4 [vm/bytecode] Fix handling of contravariant parameters in isUncheckedCall
Fixes language_2/variance/variance_in_method_test.dart when bytecode is
enabled in AOT mode.

Change-Id: I2d1338f2d68ab3a91127cdbeb60c71597d4da718
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127981
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-12-10 20:28:46 +00:00
Samir Jindel 1d4c45d2d0 Re-land "[vm/cfe] Elaborate for-in statements during async transform"
This removes the component of the change which updates the kernel binary
format.

Change-Id: I86dbfe0ea61453bbea6eee200743961d0d0c3814
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127002
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Teagan Strickland <sstrickl@google.com>
2019-12-05 14:06:08 +00:00
Alexander Markov f56b0f6907 [vm/aot/tfa] Whole-program constant propagation
Size:
flutter_gallery total size -2.48% (arm), -2.3% (arm64)
flutter_gallery instructions size -2.91% (arm), -2.77% (arm64)
velocity_tracker_bench total size -7.5% (arm), -7.1% (arm64)

Performance:
SkeletalAnimation +46.02% (Intel Core i5), +37.75% (Intel Xeon), +24.86% (arm), +39.75% (arm64).
FfiMemory.Pointer* +44-64% (x64)
FfiMemory.PointerPointer +436-465% (x64), +443% (arm64).

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

Change-Id: I6221bfa02b165ccc17d4ee8b857bb89212febaff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125936
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-12-04 19:19:29 +00:00
Clement Skau f9327d3bac [SDK] Adds --lazy-async-stack support for async*.
Bug: https://github.com/dart-lang/sdk/issues/39525
Change-Id: I53cd334243649901ea8e0f9799d9f41c126e3627
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126729
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-04 12:47:48 +00:00
Clement Skau 89e31069e8 Revert "[vm/cfe] Elaborate for-in statements during async transform"
This reverts commit 63333deed6.

Reason for revert: Causes failures on Flutter HHH CI in the "flutter test hostonly_devicelab_tests" step due to kernel binary format version mismatch.

Original change's description:
> [vm/cfe] Elaborate for-in statements during async transform
> 
> This allows us TFA to analyze the iterator calls and we generate much tighter
> code in AOT.
> 
> However, due to the increased inlining opportunities, we end up emitting 0.5%
> more code. Inlining of the _GrowableList iterator specifically also includes the
> concurrent modification check and error handling.
> 
> Calls to get:iterator, moveNext and get:current account for 7.12% of all InstanceCall
> instructions in Flutter Gallery.
> 
> Fixes https://github.com/dart-lang/sdk/issues/39516
> Issue https://github.com/dart-lang/sdk/issues/39566
> Issue https://github.com/dart-lang/sdk/issues/39565
> 
> Change-Id: I8dcc08b7571137e869a16ceea8cc73539eb02a5a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126381
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,sjindel@google.com,johnniwinther@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I89b88c3d9f7c743fc340ee73a45c3f57059bcf30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126734
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2019-12-03 12:29:35 +00:00
Samir Jindel 63333deed6 [vm/cfe] Elaborate for-in statements during async transform
This allows us TFA to analyze the iterator calls and we generate much tighter
code in AOT.

However, due to the increased inlining opportunities, we end up emitting 0.5%
more code. Inlining of the _GrowableList iterator specifically also includes the
concurrent modification check and error handling.

Calls to get:iterator, moveNext and get:current account for 7.12% of all InstanceCall
instructions in Flutter Gallery.

Fixes https://github.com/dart-lang/sdk/issues/39516
Issue https://github.com/dart-lang/sdk/issues/39566
Issue https://github.com/dart-lang/sdk/issues/39565

Change-Id: I8dcc08b7571137e869a16ceea8cc73539eb02a5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126381
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-29 16:42:36 +00:00
Clement Skau d5dbf10672 [SDK] Adds non-eager async stack frame collector.
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>
2019-11-26 11:51:27 +00:00
Aske Simon Christensen 18f23124ad [cfe] Print nullability on types in messages for opt-in libraries.
This CL changes the message template generator to add an extra
'isNonNullableByDefault' parameter to 'withArguments' for all
messages that include types, thus forcing the reporter to specify
whether the library that the message belongs to is opted in to NNBD.

When the message is formatted, a '?' is added to all nullable types
if the message is reported for an opt-in library.

Change-Id: I4e1861eba48043c570afad3f40bc3dccfd2e5668
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124984
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-11-25 14:58:45 +00:00
Alexander Markov 5b5f34f2e6 [vm] Cleanup try-catch blocks around Expression.getStaticType
Expression.getStaticType was fixed in https://github.com/dart-lang/sdk/commit/970c164826d67fc2cd29ff596e5a103e9ee05ff2
Now we can remove try-catch blocks around getStaticType.

Issue: https://github.com/dart-lang/sdk/issues/38597
Issue: https://github.com/dart-lang/sdk/issues/34496
Change-Id: Ib68d6203875b8731fedf7017347004b06fad19de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125996
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-11-22 16:48:04 +00:00
Régis Crelier af541cd0dd [VM/nnbd] Ignore nullability of type Never provided by CFE.
Although the type Never is always non-nullable, the CFE writes a nullability
byte in kernel files that was not properly skipped by the VM.

This fixes issues
https://github.com/dart-lang/sdk/issues/39466
and
https://github.com/dart-lang/sdk/issues/39461.

Change-Id: I93c44ed99173789fb19ddf9995f440d08e1c944b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125929
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-11-21 21:04:15 +00:00
Liam Appelbe 09d22a0509 [vm] Wrap late local var initializers in a closure.
This fixes the case where a late local var initializer allocates
variables or temporaries. It's not clear where they should be
allocated, since the initializer could be called anywhere the late
variable is accessed. So we wrap the initializer in a closure, since
calling a closure only requires a single temporary.

So then we just need to allocate that temp everywhere the late var is
accessed. Since temporaries are associated with specific AST nodes,
we also need to add the ability to swap out the temporaries associated
with a node, so that we can use the getter's temp when the getter
visits the initializer.

This will also reduce code bloat for large initializers.

Bug: https://github.com/dart-lang/sdk/issues/38841
Change-Id: Ice8c16babc0e56368657088edf1b51b422ee0241
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125762
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-11-21 20:39:36 +00:00
Jens Johansen 2e32972929 [pkg/vm] Remove usage of Library.isExternal
Change-Id: I014184e2324ab0379653cb8c23cb7eed52677aeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124985
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-11-21 08:36:54 +00:00
Liam Appelbe bde92ca34a [vm] Late modifier for final local variables.
Bug: https://github.com/dart-lang/sdk/issues/38841
Change-Id: Ia99a3441b4175bb16097766d57133c6d83a0e3f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125542
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-11-18 23:12:48 +00:00
Martin Kustermann aceeba7567 [vm/async] Encode the yield index -> token position in PcDescriptors.
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>
2019-11-18 11:50:13 +00:00
Johnni Winther 4b5589e0cb Reland "[cfe] Use StaticTypeContext for getStaticType" and more"
This relands commits
 "[cfe] Use StaticTypeContext for getStaticType"
 45033c6ad9

 "[cfe] Move caching of thisType to CoreTypes"
 fab25cbe0c

 "[vm/bytecode] Notify static type context when entering/leaving library"
 c9f88ae253

Change-Id: I407d6b0e3b3df503cedc9fcb2c834d835cf083f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125343
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-11-16 05:50:58 +00:00
Liam Appelbe 329d0913ca [vm] Late modifier for non-final local variables.
I also added a test for top level late variables (they already worked).

Bug: https://github.com/dart-lang/sdk/issues/38841
Change-Id: I6720e6476a067c7f8b21a34b87b23ab14fc866a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125224
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-11-15 23:03:16 +00:00
Johnni Winther ef5fb7d3f4 Revert "[cfe] Use StaticTypeContext for getStaticType" and more
This reverts commits
 "[cfe] Use StaticTypeContext for getStaticType"
 45033c6ad9

 "[cfe] Move caching of thisType to CoreTypes"
 fab25cbe0c

 "[vm/bytecode] Notify static type context when entering/leaving library"
 c9f88ae253

Change-Id: I6171f6a74b97f2f4a77a36c242330fc2db94c82f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125341
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
Auto-Submit: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
2019-11-14 22:51:43 +00:00
Alexander Markov c9f88ae253 [vm/bytecode] Notify static type context when entering/leaving library
Issue: https://github.com/dart-lang/sdk/issues/39388
Change-Id: I8f9933df46e8667432ebf0167313993e5c2caa72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125230
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-11-14 21:39:28 +00:00
Dmitry Stefantsov fab25cbe0c [cfe] Move caching of thisType to CoreTypes
Closes #38225.

Bug: http://dartbug.com/38225
Change-Id: I0274bc390ca2d098896f578ea7ddf65527d82027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124325
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-11-14 16:01:26 +00:00
Johnni Winther 45033c6ad9 [cfe] Use StaticTypeContext for getStaticType
Change Expression.getStaticType to take a StaticTypeContext instead
of a TypeEnvironment.

The StaticTypeContext provides access to the TypeEnvironment and the
current 'this type' as well as determining the nullability state of the
enclosing library.

This change is needed to support nnbd types for getStaticType and also
serves as a step towards supporting caching during static type
computations to avoid repeated computations of the same (complex)
expressions.

Change-Id: Ied974dff7f6f7c3c8f262aa80c8dea5c674662f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124683
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-11-14 09:09:26 +00:00
Liam Appelbe a0bb025024 [vm] Late static final fields
Bug: https://github.com/dart-lang/sdk/issues/38841
Change-Id: Ic40002ab0e6ded6d525ee5e1c218a589b9406c8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125005
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-11-13 17:56:08 +00:00
Liam Appelbe 2a9af7d953 [vm] Late modifier for non-final static fields.
Bug: https://github.com/dart-lang/sdk/issues/38841
Change-Id: I8e6feef2c0ee8021bec2f849e9729516532ca91a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124641
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-11-12 17:27:39 +00:00
Alexander Markov da561313c6 [vm/bytecode] Erase promoted bounds of type parameter types
Promoted bounds are not reified and don't make any difference at run
time. However, promoted bounds are taken into account when comparing
DartType nodes (since 75dc8483ab).
As a result, types which are different only in promoted bounds are
treated as not equal and reusing of type arguments doesn't work for
such types, which results in failed assertions in the VM.

The solution is to erase promoted bounds from type parameter types in
bytecode generator.

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

Change-Id: Ifc39592aa4e87d6273dd7ccf3129a381791609ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124900
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-11-12 00:44:39 +00:00
Alexander Markov b4ab28fef1 [vm/bytecode] Do not declare receiver variable in closures
While 'this' variable (receiver) is in scope in closures inside
instance methods, closures do not take it as a parameter and they
shouldn't declare a local variable for receiver unless it's captured.

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

Change-Id: Ic5c735fd50457a5fb39acb3ec3590964e4dddba3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124825
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-11-11 21:51:57 +00:00
Alexander Markov fa43799461 [vm/bytecode] Check number of type arguments in non-generic closures
Fixes https://github.com/dart-lang/sdk/issues/39283

Change-Id: I5a5fdf158c6a7ce068be36754ea0487cb754584b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124470
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-11-08 17:16:37 +00:00
Dmitry Stefantsov b4554c1215 [cfe] Make nullability a required parameter for types
Change-Id: Id787291294cafb15cf4ecad4a9db9da4c6066638
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124135
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Auto-Submit: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-11-07 13:24:47 +00:00
Liam Appelbe c154677699 [vm] Handle trivial initializers for late fields
Bug: https://github.com/dart-lang/sdk/issues/38841
Change-Id: I9db9d4815ad27f3f97d43a7a9f1fb74f08673528
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124201
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-11-06 17:46:32 +00:00
Liam Appelbe 1f8ef384d9 [vm] First pieces of late modifier implementation.
This implements the logic for initializing, getting, and setting
non-final instance fields that have initializers. It doesn't address
statics, finals, local variables, or the no-initializer case, and is
only implemented for bytecode.

Bug: https://github.com/dart-lang/sdk/issues/38841
Change-Id: I3b9e2772abdc04e3bfede56d2fcf06738f234cbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122489
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-11-05 19:48:03 +00:00
Jens Johansen f91ef3afd7 [kernel] Deprecate Library.isExternal
We're deprecating kernels Library.isExternal as it wasn't used for
what it was originally intended. It will hopefully go away entirely
soon.

Change-Id: If363c50af5607febae68865875af452c106fff85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123721
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-11-04 09:24:02 +00:00
Régis Crelier df678dbec0 [VM/nnbd] Introduce type Never in VM and bytecode.
Introduce enum NNBDMode for subtype test checking mode.

Change-Id: Id9c39ee8c975c664ac58e313b7dd05e6e219dfc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123557
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-11-01 00:43:59 +00:00
Alexander Markov 8a09d7ab5a [vm/bytecode] Remove alignment of sections in bytecode
Previously, before switching to compact encoding of bytecode
instructions, we had to align bytecode instructions by 4.
Since that time sections of bytecode binary were aligned.

However, this alignment doesn't work well in AOT mode if dill file
contains both bytecode and AST, as other metadata (such as obfuscation
prohibitions) may precede bytecode metadata and may make the whole
bytecode binary misaligned.

This results in incorrect calculation of section offsets,
failed assertion

  assert(writer.offset - start == section.offset);

and VM may fail to load bytecode binary with error

  bytecode_reader.cc: 1368: error: unreachable code

In order to fix these problems, extra alignment of bytecode
sections is removed.

Change-Id: Iaa3b7c46999615aaa446781a7018db409261ead8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123686
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-31 21:37:44 +00:00
Régis Crelier efb4511916 [VM/nnbd] Propagate nullability info on types from kernel to VM and bytecode.
Change-Id: I2f2b5819a58d55b60aaf82418e0d2feaad4aaa32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121414
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-10-29 23:39:36 +00:00
Samir Jindel c885bdde1d [vm] DBC is obsolete. Remove dead code.
Change-Id: Ica33af158cca53c8e951e4b2582de83660e8a60d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121851
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-27 18:18:29 +00:00
Alexander Markov 6432d26a52 [vm/bytecode] Avoid excessive memory copying when generating bytecode
Change-Id: Id20cfd19621027d829bdf4c3a14f3c9699b90ab3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122681
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-10-23 23:31:07 +00:00
Alexander Markov 7ac22ac28f [vm/bytecode] Omit null stores into context when declaring a captured variable
Change-Id: I35c0de039021dd627e8d2604d37675d24c5ec089
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122481
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-22 21:01:11 +00:00
Alexander Markov 6de2f92033 [vm,bytecode] Allocate objects lazily in bytecode generator
Previously, bytecode generator was allocating a bunch of objects
eagerly when starting bytecode generation for a member. Most of these
objects are maps and lists which are needed only under certain
circumstances. With this change these objects are allocated more lazily,
only when needed.

Also, this CL fixes crash in LinkReader.setOffset when reading/dumping
bytecode.

Change-Id: I11c561e4f00c456e92f42530d3d4e6008b5f5daf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122407
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-22 00:30:32 +00:00
Alexander Markov e8fa489242 [vm/bytecode] Store generated bytecodes more efficiently, add inline pragmas
Change-Id: Iae69f28e8ff66be60a1780182b247d870575c891
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122180
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-10-21 21:33:38 +00:00