Commit Graph

244 Commits

Author SHA1 Message Date
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
Alexander Markov 4e8d517f40 [vm,bytecode] Store offsets in bytecode declarations, remove putIfAbsent
Instead of keeping offsets of bytecode declarations in a map,
offset is now stored in a field of a base class for all declarations.
This saves certain number of map lookups while serializing bytecode.
Also, calls to a rather expensive Map.putIfAbsent are removed.

Change-Id: I036fbb0e1d8afc6e402709a0a1eafb0e50a2c25a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122170
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-21 18:46:04 +00:00
Alexander Markov 2423ffead6 [vm,bytecode] Correct assertion for source positions of yield points
Front-end sometimes generates synthetic awaits (yield points) which
don't have a source position. This change fixes assertion in bytecode
generator to account for that.

Issue: https://github.com/dart-lang/sdk/issues/38979
Change-Id: I64ded6a2e3bb9678ac3a7ddc73b117bdd52c3305
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122177
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-21 18:22:50 +00:00
Alexander Markov 73dd5f766a [vm,aot,bytecode] Do not depend on presence of _AsyncAwaitCompleter
In AOT mode tree shaker can remove _AsyncAwaitCompleter class, so
bytecode generator should not crash if it can't find this class in
the core library.

The only use of _AsyncAwaitCompleter in bytecode generator is to
mark _AsyncAwaitCompleter.get:future as non-debuggable.

This change fixes crash when building Flutter engine in
host/release configuration with unreachable code elimination
(https://dart-review.googlesource.com/c/sdk/+/121901).

Change-Id: I7724ef6ae51b2b2039bb113c5c7328956bf6e99d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122167
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-21 17:39:37 +00:00
Alexander Markov 9220890dc7 [vm/bytecode] Do not emit inferred type if unreachable
Closes: https://github.com/dart-lang/sdk/issues/38965

Change-Id: Id74ed952f2f632fe8028a765d0cf717e04830954
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-dartkb-linux-debug-simarm64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-dartkb-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-precomp-mac-release-simarm_x64-try,dart-sdk-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122147
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-10-18 18:29:02 +00:00
Liam Appelbe 45358c5834 [vm] Implementation of NullCheck for bytecode
Bug: https://github.com/dart-lang/sdk/issues/38840
Change-Id: I56af108096355a0486d45f88e795908ce712db4b
Fixes: https://github.com/dart-lang/sdk/issues/38840
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121904
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2019-10-17 19:18:26 +00:00
Alexander Markov 20f9d4d456 [vm,bytecode] Omit initialization of delayed type arguments for non-generic closures
Delayed type arguments are only used by generic closure functions, so
their initialization can be omitted for non-generic closures.

This is the follow-up for 1f58504ee6.

Change-Id: I61b05a4a4e2af4d2d8a543f6eec985a47b811761
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121924
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-17 17:53:50 +00:00
Alexander Markov 882a6b57d2 Enable bytecode in AOT compilation pipeline
Change-Id: I3f1bb7d56522cf5dfedf68c022fbed59c3d04717
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118103
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-10-17 17:22:12 +00:00
Alexander Markov 4dc1901cdb [vm,bytecode] Write closure attributes separately
There are could be conflicts in inferred types attributes between
function and its closures, so attributes for closures should be
written separately.

Change-Id: Iae395d73fdc2dfcb6b55137176f198f02e9b079b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121907
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-17 17:07:32 +00:00
Alexander Markov 9e2ce9a773 [vm,bytecode] Avoid duplicated initializing StoreFieldTOS
This is the follow-up for 46cef9bfdd.
After that change, VM's optimizer (canonicalization) removes
initializing stores which store null, even if they're overwriting the
result of another initializing store. This causes incorrect behavior
in cases like this:

class A {
  int x = 3;
  A() : x = null {}
}

To accomodate for this change in the VM's optimizer, bytecode generator
should elide duplicate stores, similarly to AST-based flow graph
builder.

Fixes language_2/field_parameter_test in AOT mode with bytecode.

Change-Id: I9b1e25840f639d88bf62dc990f183878ecf1b59b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121649
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-15 18:57:19 +00:00
Alexander Markov 3c3bd8d7c9 [vm,aot,bytecode] Support obfuscation
In order to support obfuscation, string constants are decoupled
from public names in bytecode (names are obfuscated, but string
constants aren't). List of protected names is written in a separate
section in bytecode component.

Obfuscator is extended to support getter and setter
names coming from bytecode.

Change-Id: I8e8d820d1a8b97e32e8ad1b064b827bdb017430b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121261
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-10-14 18:12:29 +00:00
Alexander Markov 8f679ab9f9 [vm,bytecode] Swap == operands in switch cases
For a switch statement

  switch(foo) {
    case c_1: ...
    ...
    case c_N: ...
  }

Bytecode was calling foo.operator==(c_i). This is less efficient than
c_i.operator==(foo), as c_i is a constant with a known actual type
and operator== can be always devirtualized and inlined.

Change-Id: I786ea193de1fa1830854602318e436f601296f5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121405
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-11 21:11:40 +00:00
Alexander Markov 62ee78eeec [vm,bytecode] Generate calls for causal-async-stacks more consistently
In order to support causal-async-stacks, the following synthetic calls
are inserted: _asyncStackTraceHelper, _setAsyncThreadStackTrace and
_clearAsyncThreadStackTrace.

_asyncStackTraceHelper is always generated in the async transformation.
_setAsyncThreadStackTrace and _clearAsyncThreadStackTrace are inserted
during bytecode generation (or in the flow graph builder in case of AST
pipeline). If bytecode generation options are set inconsistently with
--causal-async-stacks VM option, then it was possible that
_asyncStackTraceHelper was generated but other calls were not generated,
causing incorrect (full, non-truncated) async stack traces. This also
causes performance regression as collecting full stack traces takes
much more time.

This change makes generation of all these calls more consistent: if
causal async stacks are disabled during bytecode generation, then all
three calls are omitted. Also, in case these calls were generated and
present in bytecode, but VM option --causal-async-stacks is disabled,
then bytecode flow graph builder turns all these three calls into no-ops.

Change-Id: I93eb1d83c675ee093799bb8e37ca3d60a3c5c19d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120927
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-10-09 22:10:21 +00:00
Alexander Markov 3bb32f6778 [vm/bytecode] Generate complex conditions more efficiently in bytecode
Change-Id: I7cbf3a91dc96843f10af9560a58269badbe31bac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109729
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-09 19:32:54 +00:00
Alexander Markov 2ca6bc29b3 [vm,bytecode] More efficient bytecode for calls through fields/getters
Previously, calls through field/getter were generated as dynamic calls
because InterfaceCall with field/getter target doesn't correctly
represent what such call should do. This results in a quite inefficient
code in AOT mode.

With this change, calls through fields/getters are decomposed into two
calls, while keeping the same order of evaluation.

Change-Id: Ieb33927c1b39d1b4d8eafb7bd542675820474068
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120628
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-10-08 22:27:10 +00:00
Régis Crelier 735d8b7c64 [VM/nnbd] Propagate nnbd flag on Library from kernel to VM and bytecode.
Also fix a few obsolete comments.

Change-Id: Ice4d36abb950575316db02c3dad2b94a505d7e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120743
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-10-08 22:25:20 +00:00
Alexander Markov ae251757a9 [vm,aot,bytecode] Performance fixes
* AOT call specializer handles devirtualized static calls to integer
  and double operations more efficiently, so direct call metadata
  should be preferred over specialized bytecode instructions.

* Avoid clearing 'inferredTypeMetadata', which contains inferred-type
  metadata for all members. Previously it was cleared after generating
  the first member by mistake.

Change-Id: Ieaa6ad74cc2168c30b0c9865d17b195c49f85744
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120627
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-07 23:06:09 +00:00
asiva 01ebf92dde [VM] Consume extension member/is late flag setting when reading kernel file.
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>
2019-10-07 22:43:19 +00:00
Alexander Markov c77c2728dd [vm,aot,bytecode] Handle inferred-type metadata when generating bytecode
Change-Id: Ifadb25c782db5c95025e7275daf0676abd73cf49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120341
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-06 16:51:43 +00:00
Alexander Markov 59e00e69be [vm,bytecode] Fix canonicalization of type arguments of recursive types
Previously, it was possible that type arguments of recursive types are
shared between unrelated recursive types if they have exactly the same shape
(e.g. Foo extends Base<Foo> and Bar extends Base<Bar> both have
type arguments <recursive-ref#0>).

Fixes ffi/structs_test in AOT+bytecode mode.

Change-Id: I516bc34c3b5797d76e1bf087ac3c8f075f1b6424
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120380
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-06 16:50:42 +00:00
Zichang Guo 28f21d4e99 [vm/bytecode] correct source position of clearAsyncThreadStackTrace
source position of clearAsyncThreadStackTrace should not have a valid source position.
This fixes code coverage regression.

Bug: https://github.com/dart-lang/sdk/issues/38628
Change-Id: I41b1822a07b9d4becdda58bb810f03733289cd2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120002
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-10-04 03:12:53 +00:00
Ryan Macnak c1f691c797 [vm, bytecode] Saturate context ids instead of issuing a compile-time error.
The bytecode encoding allows for 8-bits of context id, but this limit is exceeded in Flutter test code. Context ids are as yet unused, but will be used to disambiguate variables at the same position in different contexts.

Change-Id: I64130c11ddf04495b2719aa6f4809fa64ff135c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119728
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-10-03 16:57:33 +00:00
Alexander Markov 07a63a17a4 [vm,aot,bytecode] Handle procedure-attributes metadata when generating bytecode
Change-Id: I26e1a15d979ce13ca60298de28ced49b6882cf52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119765
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-10-03 16:27:33 +00:00
Alexander Markov 1ed707703d [vm/bytecode] Mark try blocks generated for try/finally as synthetic
This matches behavior of AST-based flow graph builder. Debugger ignores
synthetic (is_generated) try blocks when it figures out if thrown
exception is unhandled, so in order to ignore all try/finally blocks
they should be marked as synthetic.

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

Change-Id: I06840362a255b500e1e9317af90a61bbdea2a310
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119726
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-02 23:15:11 +00:00
Dmitry Stefantsov bdf6b9505e [cfe] Ask for subtype checking mode explicitly
The interpretation of the subtype check result depends on the mode.  In partial
NNBD mode all type errors that wouldn't be errors in non-NNBD programs should
become warnings.  In full NNBD mode all such errors are errors.  This CL adds
the mode explicitly to the interface of the subtype check as a parameter.

Bug: http://dartbug.com/38673
Change-Id: I14bcdd260618530cfdd8189c01abba7469a16679
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119545
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2019-10-02 11:30:29 +00:00
Alexander Markov 5920048fa2 [vm,aot,bytecode] Handle direct-call metadata when generating bytecode
AOT transformations add vm.direct-call.metadata with devirtualization
information to AST nodes.

Bytecode generator should take this information into account when
generating bytecode in case of AOT. Bytecode format is extended with
CheckReceiverForNull and UncheckedDirectCall instructions, and
DirectCallViaDynamicForwarder constant pool entry in order to represent
devirtualized calls.

Change-Id: I697432ddd0b58d2d0413715132ba5e90eb606ec1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119201
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-01 00:20:48 +00:00