Commit graph

1890 commits

Author SHA1 Message Date
Martin Kustermann 142e15c2af [vm/compiler] Use unboxed index/length for GenericCheckBoundInstr on 64-bit architectures
flutter-release:

  * flutter_app_so_size: -0.47%
  * flutter_app_so_brotli_size: -0.48%
  * flutter_app_so_gzip_size: -0.57%

flutter-release-sizeopt:

  * flutter_app_so_size: -0.45%
  * flutter_app_so_brotli_size: -0.64%
  * flutter_app_so_gzip_size: -0.65%

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

Change-Id: If63b71e5d52f6ddb55fe05668a6480eb00a13303
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150300
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-22 19:55:36 +00:00
Martin Kustermann 0cc64fcc7d [vm/compiler] Ensure list index is integer in inliner
The inliner code is called from AOT/JIT call specializer on functions
where it knows the target. The callsite might be dynamic, in which case
the target function is a dyn:* forwarder (for calls which have one or
more non-implicit arguments).

The dyn:* forwarders inherit the recognized kind from their target. That
means the inliner has to take special care when trying to inline
functions: It can only rely on the static type safety for interface
calls, not for dynamic calls.

This CL fixes an existing bug where the call specializer knows the
target is a list and method recognizer builds custom graph for the list
indexing operator without ensuring that the index is actually an
integer.

The existing test will start failing on a dependent CL:

  tests/language_2/list/double_index_in_loop2_test.dart

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

Change-Id: Ic107fe736c1b6151562880919c39d1c650c119fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151849
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2020-06-22 13:25:35 +00:00
Alexander Markov 48fbdf8408 [vm/compiler] Fix vm/cc/Inliner_List_generate on simarm and dartkb
Fixes https://github.com/dart-lang/sdk/issues/42402

Change-Id: Id0403c1974d71f21f6f5dcfad8ffebe4f41f2e91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151782
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-06-19 16:02:43 +00:00
Alexander Markov 7bbf2921db [vm/nnbd] Non-null assertions in NNBD weak mode
Fixes https://github.com/dart-lang/sdk/issues/42357

Change-Id: I07341ba02361201ec2130fb7b6cb87a25b9b5f51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151662
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-06-18 20:02:42 +00:00
Alexander Markov 411272691c [vm/compiler] Add extra call specialization pass during inlining
After constant propagation is performed on the callee function body
during inlining, there are extra opportunities for specializing
calls. Unspecialized calls are not inlined, so it is important to
specialize those calls during inlining to open further opportunities
for inlining.

With this extra pass inliner is able to inline get:length after
specializing inlined List.generate constructor, and eliminate
bounds check from the initialization loop.

This change improves micro-benchmark creating 100,000 lists using

      List<int>.generate(1000, (int x) => x, growable: false);

in AOT mode on x64 from 308ms to 167ms.

This makes it on par with pre-NNBD fixed-size list initialization:

  var result = List<int>(1000);
  for (var i = 0; i < 1000; i++) {
    result[i] = i;
  }

In fact, after all optimizations final flow graph (and generated
code) for List.generate and explicit loop become very similar.

This change has no effect on Flutter gallery size in release mode.

Issue: https://github.com/dart-lang/sdk/issues/42283
Change-Id: I3566386608733226e1c11cb5d6892cd869e564d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151466
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-06-18 15:46:40 +00:00
linzj 54481776c9 Fix redundant comparison for InstantiateTypeArgumentsInstr.
Fixes #42389.

R=vegorov@google.com

Change-Id: Iba187e191ee2115d03d3846b58b0955581839d7b
Bug: https://github.com/dart-lang/sdk/issues/42389
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151680
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-06-18 11:08:03 +00:00
Vyacheslav Egorov 025d256658 Remove divisive terms
Based on guidance in https://developers.google.com/style/

Related to https://github.com/dart-lang/sdk/issues/42247

Change-Id: Iaf37f3372b2b5882738cfa63339dd7b032cdbba9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150630
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-17 14:01:54 +00:00
Ryan Macnak 62893f9b00 Reland "[vm] Check prefix.loadLibrary is called and returns before prefix members are used."
This reverts commit 9a87cf9174.

Reason for revert: Broken test disabled

Original change's description:
> Revert "[vm] Check prefix.loadLibrary is called and returns before prefix members are used."
> 
> This reverts commit b0484ecbde.
> 
> Reason for revert: timeouts on Flutter integration tests
> (https://github.com/dart-lang/sdk/issues/42350).
> 
> Original change's description:
> > [vm] Check prefix.loadLibrary is called and returns before prefix members are used.
> > 
> > Restore checks against reloading a library with deferred prefixes.
> > 
> > No loading is actually deferred.
> > 
> > Bug: https://github.com/dart-lang/sdk/issues/26878
> > Bug: https://github.com/dart-lang/sdk/issues/41974
> > Change-Id: Iec2662de117453d596cca28dd9481a9751091ce9
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149613
> > Commit-Queue: Ryan Macnak <rmacnak@google.com>
> > Reviewed-by: Alexander Markov <alexmarkov@google.com>
> > Reviewed-by: Siva Annamalai <asiva@google.com>
> 
> TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com
> 
> # Not skipping CQ checks because original CL landed > 1 day ago.
> 
> Bug: https://github.com/dart-lang/sdk/issues/26878, https://github.com/dart-lang/sdk/issues/41974
> Change-Id: I78709650e91d206b84a8ddd9171ef66d6cf1b008
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151169
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com

# Not skipping CQ checks because this is a reland.

Bug: https://github.com/dart-lang/sdk/issues/26878, https://github.com/dart-lang/sdk/issues/41974
Change-Id: Ife76bd51db65ca58e08655a9b8406c8ca483447f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151326
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-06-16 21:11:40 +00:00
Alexander Markov 9a87cf9174 Revert "[vm] Check prefix.loadLibrary is called and returns before prefix members are used."
This reverts commit b0484ecbde.

Reason for revert: timeouts on Flutter integration tests
(https://github.com/dart-lang/sdk/issues/42350).

Original change's description:
> [vm] Check prefix.loadLibrary is called and returns before prefix members are used.
> 
> Restore checks against reloading a library with deferred prefixes.
> 
> No loading is actually deferred.
> 
> Bug: https://github.com/dart-lang/sdk/issues/26878
> Bug: https://github.com/dart-lang/sdk/issues/41974
> Change-Id: Iec2662de117453d596cca28dd9481a9751091ce9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149613
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com

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

Bug: https://github.com/dart-lang/sdk/issues/26878, https://github.com/dart-lang/sdk/issues/41974
Change-Id: I78709650e91d206b84a8ddd9171ef66d6cf1b008
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151169
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-06-15 19:35:06 +00:00
Aske Simon Christensen 755686e5b2 [vm] Simplify RemoveRedefinitions.
Instead of having identical cases for every instruction that implements
RedefinedValue, just have one generic piece of code.

Change-Id: If3f4905a578eb345ae3d740d1f539d346c6223af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150985
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2020-06-15 08:59:35 +00:00
Aske Simon Christensen 99bd9d7db5 [vm, gardening] Initialize target array in movs tests to satisfy msan.
Fixes https://github.com/dart-lang/sdk/issues/42289

Change-Id: I13630b44d0c5bf5ec51256fb1fac41f812dd3e7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150984
Auto-Submit: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-12 12:03:02 +00:00
Daco Harkes 6544c69e23 [vm/ffi] Convert Objects to Dart_Handles in FFI calls
This includes support for calling Dart_PropagateError in native code
when doing FFI calls, and catching uncaught exceptions with Dart_IsError
when doing FFI callbacks.

The support for Dart_PropagateError adds a catch entry to the FFI
trampoline, which prevents inlining these trampolines in AOT. This
regresses the FfiCall benchmarks by 1-2% in AOT.

In addition, Dart_PropagateError requires maintaining a bit whether we
entered native/VM code from generated code through FFI or not. That way
we can do the proper transition on the exception path. When entering
generated code, we store this bit on the stack, right after the entry
frame.

Design: http://go/dart-ffi-handles

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

Change-Id: Idfd7ff69132fb29cc730931a4113d914d4437396
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-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-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,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145591
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-12 11:14:22 +00:00
Alexander Markov f0ea02bc51 [vm/nnbd] Do not trust non-nullable Object for parameter of operator==
Operator== has parameter type Object, which is non-nullable in NNBD
strong mode. This is useful, as null should be handled magically by
the implementation, and the body of operator== should never receive
null.

However, VM handles comparison of an object with null inside
operator==, so its parameter type should not be taken into account
when inferring type of ParameterInstr. Otherwise implicit null
handling code is removed by the optimizer.

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

Change-Id: I856a2ce47a11309e8c32d4d9bb481d7cc03bab85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151021
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-06-11 21:49:39 +00:00
Regis Crelier f46efc71c2 [VM/nnbd] Do not apply legacy erasure to type literals.
See issue #42262.

Change-Id: I326eff8ca836c345caab266f5d27991b251e77ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151020
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-06-11 20:00:08 +00:00
Ryan Macnak b0484ecbde [vm] Check prefix.loadLibrary is called and returns before prefix members are used.
Restore checks against reloading a library with deferred prefixes.

No loading is actually deferred.

Bug: https://github.com/dart-lang/sdk/issues/26878
Bug: https://github.com/dart-lang/sdk/issues/41974
Change-Id: Iec2662de117453d596cca28dd9481a9751091ce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149613
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-06-11 16:33:21 +00:00
Aske Simon Christensen e35ca30ca5 Reland "[vm] MemoryCopy instruction for copying between typed data and strings."
This is a reland of 6ecd8a10ea

Original change's description:
> [vm] MemoryCopy instruction for copying between typed data and strings.
> 
> Used for copying the bytes from the Uint8List to the _OneByteString in
> String.fromCharCodes and the pure-ASCII case of UTF-8 decoding.
> 
> Issue https://github.com/dart-lang/sdk/issues/42072
> Closes https://github.com/dart-lang/sdk/issues/41703
> 
> Change-Id: I1ae300222877d1c6e64e32c2f40b8fb187a584c0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149500
> Commit-Queue: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: Ia231c521e5f2db168cfc6094dfc7322327dedc6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150925
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2020-06-11 12:29:19 +00:00
Regis Crelier c0c66ab10f Reland "[VM/nnbd] Canonicalize TypeParameter objects in the VM."
This is a reland of 6a98e2719e

Original change's description:
> [VM/nnbd] Canonicalize TypeParameter objects in the VM.
> 
> Prior to this CL, type parameters were all assumed canonical, even duplicate ones.
> 
> Per a new convention introduced in this CL, the type parameter array in generic classes and generic functions contains canonical type parameters. As these type parameters get cloned with a different nullability, they are inserted in a new hash table of canonical type parameters.
> 
> This fixes performance issue https://github.com/dart-lang/sdk/issues/41421
> 
> Change-Id: I9086158fa6b6261e9997bb50edec6d7c54abbfa1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148223
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: I4a42d0f9d53c2244b1a638432ed2cd6a055fa72a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150266
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-06-11 00:44:05 +00:00
Ryan Macnak d1b0713e8b Revert "[vm] MemoryCopy instruction for copying between typed data and strings."
This reverts commit 6ecd8a10ea.

Reason for revert: Breaks ABI

Original change's description:
> [vm] MemoryCopy instruction for copying between typed data and strings.
> 
> Used for copying the bytes from the Uint8List to the _OneByteString in
> String.fromCharCodes and the pure-ASCII case of UTF-8 decoding.
> 
> Issue https://github.com/dart-lang/sdk/issues/42072
> Closes https://github.com/dart-lang/sdk/issues/41703
> 
> Change-Id: I1ae300222877d1c6e64e32c2f40b8fb187a584c0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149500
> Commit-Queue: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,askesc@google.com

Change-Id: I5fc0b58da80dca23c91b57ec2833492e9d0885a8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150802
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-06-10 18:41:55 +00:00
Aske Simon Christensen 6ecd8a10ea [vm] MemoryCopy instruction for copying between typed data and strings.
Used for copying the bytes from the Uint8List to the _OneByteString in
String.fromCharCodes and the pure-ASCII case of UTF-8 decoding.

Issue https://github.com/dart-lang/sdk/issues/42072
Closes https://github.com/dart-lang/sdk/issues/41703

Change-Id: I1ae300222877d1c6e64e32c2f40b8fb187a584c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149500
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-10 14:40:17 +00:00
Vyacheslav Egorov 45310394a6 [vm] Exclude class name from function name in instruction sizes json.
Issue https://github.com/dart-lang/sdk/issues/41249

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: Idf2bb9c9d6392c7a95aa09a2cc1f2190adcf782d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150522
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-10 10:18:37 +00:00
Aske Simon Christensen cf6f8903a5 [vm] IL instruction for UTF-8 scan.
Speeds up decoding across the board, with medium-length pure ASCII
strings seeing about 2x on X64 and IA32.

Closes https://github.com/dart-lang/sdk/issues/41702

Change-Id: I1c8e0bc69baaaeb6755d4c775e6fa0e6d18e1c57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148762
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-08 15:03:34 +00:00
Régis Crelier c48263e901 Revert "[VM/nnbd] Canonicalize TypeParameter objects in the VM."
This reverts commit 6a98e2719e.

Reason for revert: Unexpected test failures

Original change's description:
> [VM/nnbd] Canonicalize TypeParameter objects in the VM.
> 
> Prior to this CL, type parameters were all assumed canonical, even duplicate ones.
> 
> Per a new convention introduced in this CL, the type parameter array in generic classes and generic functions contains canonical type parameters. As these type parameters get cloned with a different nullability, they are inserted in a new hash table of canonical type parameters.
> 
> This fixes performance issue https://github.com/dart-lang/sdk/issues/41421
> 
> Change-Id: I9086158fa6b6261e9997bb50edec6d7c54abbfa1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148223
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com,regis@google.com

Change-Id: I0ca3b6b66e2281c285eba6b564f78c0e6b2f2217
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150265
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-06-05 23:36:45 +00:00
Regis Crelier 6a98e2719e [VM/nnbd] Canonicalize TypeParameter objects in the VM.
Prior to this CL, type parameters were all assumed canonical, even duplicate ones.

Per a new convention introduced in this CL, the type parameter array in generic classes and generic functions contains canonical type parameters. As these type parameters get cloned with a different nullability, they are inserted in a new hash table of canonical type parameters.

This fixes performance issue https://github.com/dart-lang/sdk/issues/41421

Change-Id: I9086158fa6b6261e9997bb50edec6d7c54abbfa1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148223
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-06-05 22:56:50 +00:00
Regis Crelier a5f8ddac99 [VM/runtime] Introduce a trail in IsSubtypeOf() to avoid cycles.
Clean up signatures of runtime functions in object.{cc,h} using the trail to avoid cycles. Move the trail to the last parameter of these functions.
Introduce a trail in IsSubtypeOf() to avoid cycles introduced by bounds of F-bounded types. Issue uncovered by the new normalization tests.

Change-Id: I3241c7e4023a09c122e1594b7aff90b5b103f4f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150180
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-05 19:57:46 +00:00
Alexander Markov b42aa2df68 [vm] Properly synchronize EnsureInitializerFunction
Initializer functions are created lazily at compile time when generating
LoadField which calls initializer. This may happen in the background
compiler thread, where Field objects are cloned.
EnsureInitializerFunction should be called from original field, and it
should be properly synchronized to make sure there are no races with
mutator thread.

Change-Id: Icc339afa2ee410385019c72c717737719767d367
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150166
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-05 17:55:14 +00:00
Martin Kustermann 10df757a49 [vm/ffi] Fix issue due to unspecified argument evaluation order in C++
We already have tests that exercise this, namely:

  - ffi_2/regress_39044_test
  - ffi_2/vmspecific_send_port_id_test

Though the bug only appears if C++ compiler decides to evaluate arguments
in a different order. This happens to be only the case on Windows.

We don't have Windows hardware with Android phones on our CI, which is
why this was not caught earlier.

We have manually confirmed (via building app on windows with this fix
and running on android) that the issue is fixed by this change.

Fixes https://github.com/flutter/flutter/issues/54948

Change-Id: I51109cf1062964a5fb77948cffb9e2ba8fe2055f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149980
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2020-06-04 10:46:11 +00:00
Alexander Markov 1d14868685 [vm/nnbd] Finish migration of vm/cc tests to NNBD
Also, vm/cc tests are enabled on NNBD bots.

Issue: https://github.com/dart-lang/sdk/issues/41314
Change-Id: Iddfa68de3de041436a009dd3426431211471b4dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149780
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-03 18:09:39 +00:00
Vyacheslav Egorov 10c5dd0f06 [vm/compiler] Handle phis specially in TryCreateConstantReplacementFor.
When replacing an unboxed phi with its contant value we should not
try to insert unboxing instruction before the phi - as phis exist
outside of the normal stream of instructions and InsertBefore does
not work on them.

Instead we should insert unboxing into the block which contains
the phi.

Original test is expanded to cover this case as well now.

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

TEST=vm/cc/ConstantPropagator_Regress35371

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try
Fixed: 42164
Change-Id: I53f984216e53195206fb8247b0ed8999590415a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149842
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2020-06-03 15:00:49 +00:00
Alexander Markov 50f1f1459e [vm/nnbd] Support NNBD weak mode in vm/cc tests
Change-Id: Ia49c64bf8461b8acf019c398635e27b11fe6d25e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149666
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-06-02 20:40:03 +00:00
Alexander Aprelev 13ea0b3e9f [vm/deterministic] When sorting CallTargets by frequency, sort by id in case of ties.
This addresses an issue that AOT snapshot, disassembly and flowgraph are different when generated on Windows vs Linux.
Difference is caused by different order of targets in CallTargets, caused by the fact that qsort doesn't have to preserve the order of equal elements in the original list.
While qsort on Linux preserves original (by id) order, on Windows it does not.

See https://github.com/flutter/flutter/issues/44425 for context.

Change-Id: I74c17fd83e5ae21f9733712a87de8f55a1ba94fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149496
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-06-01 23:55:08 +00:00
Alexander Aprelev 164948ab0a [vm/aot] Fix aot cross-compilation scenario when gen_snapshot runs on Windows targets android x64.
At present calling convention code is guarded by _WIN64 macro, which indicates that compiler is running on Windows, doesn't take into account target os. This causes problems when one attempts to generate aot snapshot for Android os.

Fixes https://github.com/flutter/flutter/issues/44425.

Change-Id: I8b21d9e9c357071f29632826dd7bbedc19be00a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149497
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-06-01 23:21:38 +00:00
Alexander Markov 1618fd965b [vm/compiler] Optimize lazy field initialization
Load*Field and Init*Field IL instructions are fused into load
instructions with 'calls_initializer' flag.

A new, more powerful elimination of lazy initializer calls uses
data flow analysis and load forwarding (place numbering).

In addition to improved elimination of initializer calls,
fusing instructions avoids extra load after field is already
loaded for lazy initialization check.

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

Change-Id: Ibb2a63f84b9b0c970db67b3d6684ec15384a64e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148283
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-01 21:28:18 +00:00
Alexander Markov f57c99fc31 [vm/compiler] Fix crash in inliner when receiver is dead
Fixes https://github.com/dart-lang/sdk/issues/42065

Change-Id: Ib66163a41a13f02cfa9df9bcb1cf505e934fea93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149370
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-05-29 16:34:45 +00:00
Aske Simon Christensen bbf34035dd Revert "[vm] Check prefix.loadLibrary is called and returns before prefix members are used."
This reverts commit f049a410e5.

Reason for revert: Broke reload bots.

Original change's description:
> [vm] Check prefix.loadLibrary is called and returns before prefix members are used.
> 
> Not loading is actually deferred.
> 
> Bug: https://github.com/dart-lang/sdk/issues/41974
> Change-Id: I62688007bd36dbcb2e8ffb4a1fd2dceb1775b1c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149053
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com

Change-Id: I923e339465fdf13199efc11a9cef4a842abebd67
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/41974
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149423
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2020-05-29 09:04:02 +00:00
Martin Kustermann a2b5373eaa [vm/concurrency] Avoid stopping mutators when updating subtype test cache
To avoid stopping all mutators when updating subtype test caches, we
ensure that any updates to the subtype test cache will be visible in a
consistent way to mutators by adding a store-release barrier when
updating the backing array of the STC.

Since STCs are always grown by allocating a new array with size+1, there
is no need to actually add barriers when accessing the individual
entries of the backing store.

To prevent multiple writers creating STCs and patching the pool or
updating a STC we add a mutex.

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

Change-Id: Ic705619fe16772565ac11438fd15d3977cbb49c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149164
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-05-29 04:47:22 +00:00
Alexander Markov 4f3293c70e [vm/compiler] Recognize List.filled factory
Recognized factories have known result type and its type arguments
and length are automatically forwarded (length is forwarded only for
fixed-size lists).

List.filled factory is recognized only if optional 'growable' parameter
is not passed.

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

Change-Id: I0d63428f1c4667f3981447a939dbef67170e542e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149385
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-05-29 03:12:48 +00:00
Ryan Macnak f049a410e5 [vm] Check prefix.loadLibrary is called and returns before prefix members are used.
Not loading is actually deferred.

Bug: https://github.com/dart-lang/sdk/issues/41974
Change-Id: I62688007bd36dbcb2e8ffb4a1fd2dceb1775b1c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149053
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-05-28 23:13:12 +00:00
Vyacheslav Egorov 6ab62add0d [vm/compiler] Use unboxed constants when folding away unboxed ops.
Before this change we would replace unboxed definitions (those with
representation not equal to kTagged) which is too loose and causes issues
in subsequent passes, which assume that replacements have normalised
representation.

After this change we make sure that replacement has a matching
representation.

Closes https://github.com/dart-lang/sdk/issues/35371
Fixes https://github.com/dart-lang/sdk/issues/41971

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try
Change-Id: I48543893562acf4f8516651196eba7c0c0769a22
Fixed: 35371,41971
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103139
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-05-28 11:30:49 +00:00
Martin Kustermann 4cf584d4fe [vm/concurrency] Move locks up from Isolate to IsolateGroup
In --enable-isolate group is

  * turned off, then we have 1<->1 mapping between isolate and isolate
    group, so moving the locks should have no impact

  * turned on, then we have N<->1 mapping between isolates and isolate
    group, mutators need to use the same locks to guarantee exclusive
    access (e.g. to symbol table, type canonicalization, type arguments
    canonicalization, ...)

This is a follow-up to share the program structure in AOT mode across
multiple isoltes.

In order to move the existing `Isolate::type_canonicalization_mutex_` to
`IsolateGroup` (and thereby make all mutators use the same lock), we need
to remove the `RunWithMutatorsStopped()` usage in the runtime entry.

  => Without this it can lead to deadlocks.

In order to remove usage of `RunWithMutatorsStopped()` we will change
access to the cached type arguments array to use load-acquire barriers
in generated code and store-release barriers in runtime code.

A nice side effect is that it reduces `sizeof(dart::Isolate)`.

Closes https://github.com/dart-lang/sdk/issues/41912
Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: Ifd42691524fe41ffe8bb4e2623c5b8c1151de973
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148539
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-05-27 17:04:30 +00:00
Vyacheslav Egorov b95a1bd567 [vm/aot] Clean static fields handling in precompiler.cc
Instead of maintaining separate list of static fields which
needs to be flushed into list of retained fields in Iterate()
keep track of which precompilation phase we are in - and add static
fields into the retained set only if we are in the fixpoint
code generation (aka Iterate()) phase.

Apply the same treatment to selectors as well.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try
Change-Id: I2c7c7bdf268eaee9623ab1be5cf3eb022991a7c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148403
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-05-27 10:22:19 +00:00
Vyacheslav Egorov 7175ab7329 [vm/compiler] Fix code determining if object can be a smi in LoadClassId.
Previous variant of the code did not handle FutureOr<T> and Comparable<U>
correctly - variables of these types can contain a smi value if T can be a
subclass of num or if U can be num.

Rename HasNonSmiAssignableInterface to CanReceiverBeSmiBasedOnInterfaceTarget
to better conway its meaning.

Fixes https://github.com/flutter/flutter/issues/57398

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try
Change-Id: I67b29908e057632e62c46fb327a5c805fcc78d74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149063
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-27 10:06:49 +00:00
Ben Konyi c4b7097e97 [ VM ] Migrate VM tests to support null safety and return errors from Dart_GetType and Dart_NewListOf when --null-safety is enabled
These methods return legacy types, which aren't valid with null safety
enabled.

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

Change-Id: I1181f0f3b9a8df156dea4dc4c82fef8afdf97ab9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148685
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-26 22:40:52 +00:00
Alexander Markov db063ea6d0 [vm/compiler] Remove redundant phis during canonicalization
It might be too late to remove redundant phis in EliminateDeadPhis
because EliminateDeadPhis runs after OptimizeBranches, and
OptimizeBranches may be able to eliminate more branches if redundant
phis are cleaned up.

This change moves elimination of redundant phis into canonicalization
pass which is repeated more frequently.

Fixes recent regressions on several micro-benchmarks after
https://dart-review.googlesource.com/c/sdk/+/139314

Change-Id: Ib0148564615dbd0adb88e93b938ca9f3f59cabfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148792
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-05-26 17:59:38 +00:00
Alexander Markov 572905d1e9 [vm] Fix crash in disassembler on trampolines
Fixes https://github.com/dart-lang/sdk/issues/42017

Change-Id: I7d9f2694907be2ba673f35c82ce65a4ee8bc77b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148942
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-26 17:31:58 +00:00
Aske Simon Christensen 81ad24322c [vm/compiler] Check BoxInt64 overflow via the overflow flag on ARM64.
This saves one instruction for every BoxInt64 overflow check, reducing
the instructions size for Flutter benchmarks by between 0.26% and 1.03%
(0.26% for Flutter Gallery).

Also add OVERFLOW and NO_OVERFLOW condition aliases to arm and arm64.

Change-Id: I82990419b448f21a22ea2cc7a15a9497d3275943
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145860
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-20 14:05:40 +00:00
linzj d2ee73b251 [vm/compiler] Fix liveness analysis for unboxed parameters on 32-bit.
Fixes https://github.com/dart-lang/sdk/issues/41977

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-debug-simarm_x64-try
Change-Id: Ifcba1aac8e23aa382bdafe7506ce1725b8f2221d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148602
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2020-05-20 08:42:21 +00:00
Regis Crelier 19f49509b0 [VM/nnbd] The equivalent of dynamic as bound is Object? and not Object.
This is a partial fix for https://github.com/dart-lang/sdk/issues/41939

Let's take one step at a time, but later, we should be able to leave the bound as dynamic, since mutual subtyping of bounds is now implemented.

Change-Id: I57f725ba5b02237a64ae77593f340438f7159ab7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148515
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-05-19 18:10:54 +00:00
Ryan Macnak 2fa4d3e4d8 [vm, gc] Account for AllocateArray or CloneContext returning objects that have already been added to the remembered set.
Bug: b/156940113
Change-Id: Id212f9826b83981346ea4fbb1ef80a115e831a10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148506
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-19 17:47:11 +00:00
Ryan Macnak 6b91f92154 [vm] Move megamorphic miss handling into the megamorphic call stub.
This removes the only stub code with a function owner.

Change-Id: I629eb3a1b231430afaf0a2777032bba8eaddd2aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148124
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-05-15 20:28:21 +00:00
Tess Strickland 7aae1f6032 [vm] Relax AssertSubtype to allow non-constant sub and super types.
Previously, AssertSubtype instructions could only be created with a
compile-time AbstractType value for sub_type and super_type. Relax this
so that AssertSubtype instructions can be created with possibly
non-constant Values instead.

Currently, all AssertSubtype uses still have constant sub- and
supertypes, so for now we check at code generation that we indeed
have constants for these values and only handle the constant case. Thus,
there should be no impact on size or speed of the generated code from
these changes. Follow-up work will add code generation for non-constant
sub- and supertypes and add uses the generalized form.

Bug: https://github.com/dart-lang/sdk/issues/40813

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-release-simarm64-try
Change-Id: Ib1512b3e07a016d68a8e0c670ce857b8ac1b2777
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147520
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-15 11:51:32 +00:00