Commit Graph

2925 Commits

Author SHA1 Message Date
Régis Crelier 482ae8cb5b [VM/nnbd] Implement weak and strong mode type checking in runtime.
This does not yet include checking of required named parameters.
Also, inlined type testing code, type testing stubs, and type propagation are
not yet updated.

Change-Id: If6d8996635474e349d28b7fd207d724838d08881
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129922
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-01-06 22:32:19 +00:00
Alexander Aprelev 85e396a1de [vm/fieldtable] Move current field values out of Field object into separate table.
This is to support sharing of Field objects between isolate group's isolates.

Each isolate will have it's own field table with static instances/values.
field_table is stored on isolate, copied over to thread for easier access.

This also removes the write barrier from static field assignments; the field table is a GC root.

Bug: https://github.com/dart-lang/sdk/issues/37835
Bug: https://github.com/dart-lang/sdk/issues/36097
Change-Id: I232a86f059ac4cacc3e9f54bcc31d1d0524f9496
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127582
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-01-06 18:58:11 +00:00
Martin Kustermann addd5eea00 [vm/compiler] Consistently use pc-offsets of pointing to instruction after call in static calls table, to ensure unique offsets
The pc-relative calls were recorded with pc-offsets pointing to the start of the
call instruction, where as code-based calls were recorded with
pc-offsets pointing to the next instruction (i.e. return address).

This is inconsistent and caused us to hit an assert in
`Code::set_static_calls_target_table`. The assert was benign, but it is
good to maintain the uniqueness guarantee in the static calls table, so
we'll unify the encoding to use offsets to the instruction after the
call in both cases.

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

Change-Id: Id0305befd78f09ed0b0e100f39641bca9e764442
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129717
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-01-03 17:17:59 +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
Samir Jindel f134164332 [vm] Enable multiple entry-points on ARM64.
Adresses https://github.com/dart-lang/sdk/issues/34162

Change-Id: I7126f8c9b470041aaa260255293327f67d64d1bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128063
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-19 16:41:24 +00:00
Jens Johansen 8d11c1dce6 [kernel][vm] Add uris only from mixins to libraries sourceReferences
index to fix VMs coverage issue

This CL fixes the VM not always reporting coverage for mixin usages
properly.

* When asking the VM for coverage you can do it in one of two ways
  * Ask the VM for coverage for everything; or
  * Ask the VM for coverage for a specific script
* Asking the VM for coverage for everything works perfectly fine.
  The VM goes through everything and reports coverage correctly.
* Asking the VM for coverage for a specific script (which is, at least
  now, what the flutter tools does) doesn't work in the simple mixin
  case described at http://dartbug.com/39779: The VM goes through the
  libraries, asking for the list of scripts they "know about",
  and checks for matches against what you asked for.
  In this case, when asking for 'master.dart', the library for
  'lib.dart' says no when it shouldn't --- because of the way the mixin
  transformation works the content is actually in lib.dart.

This CL updates the content of the field 'sourceReferences' on Library
to fix the issue.


Fixes #39779

Change-Id: I0c38a323c81d1784ade704837b67ece549fc95d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128585
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-12-19 06:59:28 +00:00
Teagan Strickland 089aeedf56 [vm/compiler] Reland "Add --save-debugging-info flag to gen_snapshot."
Removes an unnecessary change to the names of type testing stubs that
allowed name collisions to happen.

Old commit message:

The flag can be used when creating AOT snapshots. The resulting file can be
used with package:vm/dwarf/convert.dart to convert DWARF-based stack traces
to stack traces with function, file, and line number information.

Currently the saved file will be an ELF file with DWARF debugging information,
but this is subject to change in the future. To avoid being affected by any
changes in format, read the DWARF information from the file using
Dwarf.fromFile() in package:vm/dwarf/dwarf.dart.

Also adds --dwarf-stack-traces to the VM global flag list, so its value at
compilation will be read out of snapshots by the precompiled runtime.

Fixes https://github.com/dart-lang/sdk/issues/39512, which was due to
a missing compiler::target:: prefix for Instructions::HeaderSize() in
BlobImageWriter::WriteText().

Exposes the information suggested in
https://github.com/dart-lang/sdk/issues/39490 so that package:vm/dwarf
can appropriately convert absolute PC addresses to the correct virtual
address for a given DWARF line number program.

Bug: https://github.com/dart-lang/sdk/issues/35851
Change-Id: I6723449dceb0b89c054a1f1e70e7acd7749baf14
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128730
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-18 14:14:41 +00:00
asiva 8a4cac1ddb Reverting a chain of commits related to debug info splitting.
REASON: the first commit in the chain contains a change that breaks internal
Flutter roll due to duplicated symbols for type testing stubs in assembly
snapshots.

Revert "[vm/compiler] Add --save-debugging-info flag to gen_snapshot."

This reverts commit c2b6c2e1db.

Revert "[vm] De-obfuscate function and file names in DWARF sections."

This reverts commit 4b8fd3c412.

Revert "[vm] Add docs for DWARF stack traces and related tools/libraries."

This reverts commit 5543e5ceb8.

Revert "[vm] Weaken dwarf_stack_trace expected stack trace."

This reverts commit 5824d3ed53.

Change-Id: I95ecd16fe493f61ae761dabfdd91a6ec0c2f0ca3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128776
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-12-18 01:02:05 +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
Ryan Macnak 6b5d9f1d1b [vm] Progress toward running without TSAN warnings.
- Ignore all data races on object headers. These are harmless because of higher-level constraints in the GC.
 - Make all concurrent marker tasks check-in with the monitor to indicate they are done marking roots, not just the last one. This establishes synchronization between the which ever task read the handle blocks and the mutator resuming and writing to the handle blocks.
 - When a helper thread exits the isolate, perform clearing of the reusable handles under the thread registry's lock so it doesn't race with the GC visiting thread roots.
 - Disable background compilation when running under TSAN. There are lots of races here. Many are harmless. It's hard to annotate these without effectively disabling TSAN checks for the entire Dart heap, so simply disabling the background compiler will give us the most TSAN coverage for the time being.
 - Fix race in abandoning TLABs during helper thread exit.
 - Remove harmless race between concurrent sweeper and allocation of new heap pages.
 - Suppress TSAN on known race in array truncation.
 - Remove racy access FLAG_stacktrace_every, which is no longer needed as compilation can no longer trigger execution to evaluate constants.

Bug: https://github.com/dart-lang/sdk/issues/39611
Change-Id: Ibaa101b4f12ff5fa30678471fb37e63608ba7f8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128305
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-12-16 18:32:23 +00:00
Teagan Strickland c2b6c2e1db [vm/compiler] Add --save-debugging-info flag to gen_snapshot.
The flag can be used when creating AOT snapshots. The resulting file can be
used with package:vm/dwarf/convert.dart to convert DWARF-based stack traces
to stack traces with function, file, and line number information.

Currently the saved file will be an ELF file with DWARF debugging information,
but this is subject to change in the future. To avoid being affected by any
changes in format, read the DWARF information from the file using
Dwarf.fromFile() in package:vm/dwarf/dwarf.dart.

Also adds --dwarf-stack-traces to the VM global flag list, so its value at
compilation will be read out of snapshots by the precompiled runtime.

Fixes https://github.com/dart-lang/sdk/issues/39512, which was due to
a missing compiler::target:: prefix for Instructions::HeaderSize() in
BlobImageWriter::WriteText().

Exposes the information suggested in
https://github.com/dart-lang/sdk/issues/39490 so that package:vm/dwarf
can appropriately convert absolute PC addresses to the correct virtual
address for a given DWARF line number program.

Bug: https://github.com/dart-lang/sdk/issues/35851
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-mac-release-simarm_x64-try,vm-kernel-precomp-win-release-x64-try
Change-Id: I80d900fd9e5f1e2399ad3f2fd25c85131a7ea43c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121857
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-12 14:18:59 +00:00
Ryan Macnak e29a6d6f8d [vm] Initialize the handle vtable table during VM initialization instead of during class registration in each isolate's initialization.
Removes a (harmless) race initializing this table to appease TSAN.

Bug: https://github.com/dart-lang/sdk/issues/39611
Change-Id: I9f7bdd0edf2be5e87e56e453601641a9550d157a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127965
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-12-11 18:54:08 +00:00
Teagan Strickland f6d433dc5e [vm] Remove the unchecked entry point offset field from RawInstructions.
There's just one case where we can't get the offset for Instructions
from somewhere else, and that's when we reset active_instructions_ to
instructions_ in Code::Enable(). Thus, we add a caching field for the
uncached offset to RawCode, but only when the active_instructions_
field is added (when not running in the precompiled runtime).

We also output the unchecked offset in snapshots for Code objects so
we can recalculate the entry point cache on loading. (For full JIT
snapshots, we output both the cached offset and the offset for
active_instructions_.)

Bug: https://github.com/dart-lang/sdk/issues/38451
Change-Id: I78572ec83d1574b00820df148bccb57e5c79eaaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125400
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
2019-12-11 10:00:29 +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
Régis Crelier b37f391f34 [VM/nnbd] Make runtimeType return a non-nullable type when the NNBD experiment is enabled.
The nullability of runtimeType must be consistent with the nullability of
a class DeclarationType. Currently, it is always kLegacy. However, this
needs to be set to kNonNullable when the NNBD experiment is enabled.
Note that the nullability of the null instance remains kNullable.

Change-Id: I4ba974c2551c3a7fbd190b02175804090f9b48b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125721
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-12-09 18:27:04 +00:00
Régis Crelier 8894b88467 [VM/nnbd] Implement syntactic type equality.
Legacy types are considered equal to their non-nullable variant.
Type hash is modified to be consistent with the new definition.

Change-Id: If90f7f13cf77e519d5b90b57d9dbf4988f71be13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126283
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-12-09 18:18:59 +00:00
Liam Appelbe de53a2c33c [vm] Fix late local variables in AST mode
- Set a flag on LocalVariable if it's late, and store its initializer offset
 - Visit late var init in when visiting var get in scope builder
 - Initialize late vars to the sentinel
 - Check the sentinel and run the initializer in late var get

Bug: https://github.com/dart-lang/sdk/issues/38841
Change-Id: I5500ed133537ab663e2b3d8cfb5cca04233be25e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126982
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-12-06 19:54:42 +00:00
Liam Appelbe e20ff1e054 [vm] Prevent late fields from being unboxed
When unboxed doubles are assigned to late fields, it conflicts with the
late field logic and causes a crash.

Bug: https://github.com/dart-lang/sdk/issues/38841
Bug: https://github.com/dart-lang/sdk/issues/39658
Change-Id: I641f597006114f02473a20f8c2526eeaf4fe813f
Fixes: https://github.com/dart-lang/sdk/issues/39658
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127442
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-12-05 22:19:00 +00:00
Ryan Macnak f4e44dd705 [vm] Make kernel buffers live exactly as long as their derived views.
When creating a KernelProgramInfo, we create several logical views into the kernel buffer. These are fresh ExternalTypedDatas, rather than proper TypedDataViews, so they do not automically keep the original ExternalTypedData alive. Create an explicit reference to the orginal ExternalTypedData in the KernelProgramInfo. When creating snapshots, this reference is ignored/null'd and the views are turned into copies, effectively dropping the parts of the original buffer that do not have views.

Fixes a leak with reload and a use-after-free with eval.

Bug: https://github.com/dart-lang/sdk/issues/33973
Bug: https://github.com/dart-lang/sdk/issues/39610
Change-Id: I09d3830133314ccbaa0341d904127c2b6925c4ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126825
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-03 22:00:48 +00:00
Liam Appelbe fe64ce38e8 [vm] Fix late static fields (both non-final and final) in AST mode
Changes:
 - Initialize late static fields to the sentinel.
 - Mark implicit setters for static fields as static functions.
 - Call the setters and getters in StreamingFlowGraphBuilder.

Bug: https://github.com/dart-lang/sdk/issues/38841
Change-Id: I6b40aa86e44d5cea94bcf22f995ea36e01258197
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126920
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-12-02 23:24:20 +00:00
Samir Jindel 4d95ec1360 [vm] Enable multiple entry-points for unoptimized calls.
This also makes the entrypoints tests less sensitive to the order in which
functions are optimized and removes flaky checks.

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

Change-Id: I5ba23c74769ddb8415e2b635caefc798c2b70500
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109704
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-28 13:55:34 +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
Ryan Macnak ec81b3edf7 Revert "[vm] Avoid holding canonical hashes at rest."
This reverts commit b7de866bee.

Reason for revert: assertion failures on reload stress bots

Original change's description:
> [vm] Avoid holding canonical hashes at rest.
> 
> Canonical hashes are only stored during a round of canonicalization to avoid expontential time in cases such as those in tests/language_2/canonicalization_hasing_*. Clearing them avoids the GC spending time to visit them.
> 
> Bug: https://github.com/dart-lang/sdk/issues/37523
> Change-Id: Icad1fad30dcb7eb95864bea8a26991aeccd7adc6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125760
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

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

Change-Id: I2e6b29fd1b529d6302ab979acd4757f45bf989ef
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/37523
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125935
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-11-21 23:58:30 +00:00
Ryan Macnak b7de866bee [vm] Avoid holding canonical hashes at rest.
Canonical hashes are only stored during a round of canonicalization to avoid expontential time in cases such as those in tests/language_2/canonicalization_hasing_*. Clearing them avoids the GC spending time to visit them.

Bug: https://github.com/dart-lang/sdk/issues/37523
Change-Id: Icad1fad30dcb7eb95864bea8a26991aeccd7adc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125760
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-11-21 21:29:48 +00:00
Clement Skau 28a029102b [SDK] Adds --support-disassembler in PRODUCT.
This CL also addes CodeSourceMap source positions to the disassembler output.

Change-Id: I49f6cb5257394badc8a005167f906e185509a3e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125663
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-21 12:28:45 +00:00
Clement Skau 45569e146e [SDK] Fixes C++ undef. behaviour in Library::Add*Metadata.
- Library::AddFieldMetadata(..)
- Library::AddFunctionMetadata(..)
- Library::AddTypeParameterMetadata((..)

Change-Id: If2ed9a52deddc64aa9780ced74b012fd82f2d1c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125668
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-21 11:42:54 +00:00
Ryan Macnak ee9a640c9d [vm] Allocate temporaries used by Dart_Invoke etc in new-space.
Allocating in new-space allows this objects to be collected quickly during the next scavenge, instead of acculumating in old-space until the next mark-sweep and potentially increasing the process's peak memory footprint.

Change-Id: Id73c4c3934f6d84ba7af9e3333a350b809946ebb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125360
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-11-20 19:57:11 +00:00
Samir Jindel 16af4b7355 [vm] Set all entrypoints when reading JIT snapshots.
Fixes https://github.com/dart-lang/sdk/issues/39397

Change-Id: I328f6707e9f316decb5207cc11872886431fe5f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125410
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-18 14:47:53 +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
Régis Crelier 8617da2bf0 [VM/nnbd] Pass NNBD mode to runtime functions whose semantics depend on it.
Runtime functions do not yet implement the NNBD semantics.
In a next change, generated code will pass NNBD mode to the runtime.
Declare one new VM flags: --strong-non-nullable-type-checks

Change-Id: I050a468e4a6b665ce46c345bafba04a947cf7cb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124105
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-11-16 02:49:48 +00:00
Ryan Macnak 545b10389d [vm, service] Compute allocation stats on demand, instead of during allocation and GC.
Removes support for accumulators, which now repeat the current live values.
Decreases performance difference between release and product modes.
Fixes inaccuracy when counters are queried before the first full GC.

Golem geomean   x64 4.687%
Golem geomean arm64 5.770%

Bug: https://github.com/dart-lang/sdk/issues/37678
Change-Id: I12b26a9834b0f0f911ddcc6e8e5ff4573272607d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116885
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-11-16 00:22:56 +00:00
Ryan Macnak a8b3773054 [vm, reload] Guard against field loads that no longer conform to the field's static type.
Fix incorrect type arguments when noSuchMethod forwarders allocate Invocation's typeArguments.

Change-Id: I0fd2782bc96f500f31dbbdd2aa896c8caf1f0045
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123692
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2019-11-15 22:55:26 +00:00
Alexander Markov 03c3eff5dd [vm] Support JIT exception handling in DART_PRECOMPILER mode
DART_PRECOMPILER define is used when building gen_snapshot and
run_vm_tests. Both gen_snapshot and run_vm_tests support AOT and
JIT modes, selected by FLAG_precompiled_mode.

Before this change, DART_PRECOMPILER always used AOT exception
handling (catch_entry_moves_maps). This works fine even if code is
generated in JIT mode, but it is not compatible with JIT exception
handling. run_vm_tests uses kernel service which comes from app-jit
snapshot (on x64), which is generated in JIT mode with JIT exception
handling. This causes crash if there is a Dart exception in kernel
service.

This change adjusts exception handling in DART_PRECOMPILER mode to
support both AOT and JIT implementations and select one using
FLAG_precompiled_mode.

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

Change-Id: I6c9ce05552a98bd4eeaea18c082a98e9bdbe9460
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125302
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-11-15 16:14:15 +00:00
Martin Kustermann 20962e656b [vm/concurrency] Split up IsolateReloadContext into IsolateReloadContext/IsolateGroupReloadContext
Similar to the split of ClassTable into ClassTable/SharedClassTable,
this CL splits up the IsolateReloadContext into:

  * IsolateGroupReloadContext: Consists of reload-related information across all
    isolates. The [Reload()] method is split up in phases that are
    performed on all isolates before the next phase is started.

    => This allows each isolate to add reasons for rolling back, if no
       reasons are found the reload will be accepted atomically.

  * IsolateReloadContext: Constists of reload-related information for a
    particular isolate (e.g. mappings of old to new classes)

The assumption is that all isolates have the same source (and therefore
the same libraries). For certain things, e.g. discovering which libraries
changed, it is necessary to examine the object store. We use the first
isolate in a group (but could use any of them) to do so, since the
isolate group does not have this information atm.

This is a preparation CL for supporting hot-reloading multiple isolates
within one isolate group. Though the support in this CL stays at having
only a single isolate in a group.

  => This CL turns off FLAG_enable_isolate_groups in JIT mode.

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

Change-Id: I7f4d536d4f5ab4a2a73fb0c7618ba967c9b77234
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123254
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2019-11-15 14:08:45 +00:00
Ryan Macnak b39ab2e6ac [vm] Don't unroll initialization code based on macro lists.
-47k (-0.20%) out/ProductX64/exe.stripped/dart
 -8k (-0.17%) out/ProductX64/exe.stripped/dart_precompiled_runtime

Change-Id: Id3f6c451acf69ba7965ae51a0a3c4a8aa9ab1d73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115775
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-14 19:11:38 +00:00
Samir Jindel 6c5033acac Re-land "[vm/async] Don't add an <asynchronous gap> marker along sync-async calls."
Original change is in patchset 1.

The issue was that the expected "_Closure.call" frame is not always present.

Change-Id: I91116861e785a72536dde300f4771de4f6fa9d3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124988
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-14 15:29:16 +00:00
Clement Skau 7b3aa88ebe [SDK] Adds background compiler skip for annotations.
A similar abort was removed in the refactor in 5cce1e4a.

Change-Id: I9921c3f9f2bbe36c4560388471f93356c2d1f12d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125200
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-14 14:01:16 +00:00
Teagan Strickland dc808f3fcb [vm/compiler] Canonicalize CompressedStackMaps payloads when possible.
When we are writing a snapshot, canonicalize all entries within
CompressedStackMaps payloads. We do this by creating a global table
of stack map information (bit counts + bit payload) that we store
in the isolate object store, and then for each existing CSM, we
replace it with an alternate version that refers to the global table.
This gets back some of the canonicalization we lost when we moved from
individual StackMap objects to per-Code CompressedStackMaps objects.

Here, we also represent the global table as a CompressedStackMaps
object. This means that there are three types of CompressedStackMaps:
 * The original version that directly contains all entry information.
 * The version where each entry is just the PC offset delta and an
   offset into the global table payload.
 * A version representing the global table where the entries are like
   the original version except they don't contain a PC offset delta.

-----

The impact on AOT snapshot size when compiling the Flutter Gallery
in release mode:

   armv7: Total size -0.88% (Isolate RO: -5.05%, Isolate snapshot: +0.00%)
   armv8: Total size -1.04% (Isolate RO: -5.28%, Isolate snapshot: +0.00%)

-----

Bug: https://github.com/dart-lang/sdk/issues/35274
Change-Id: I1ce0f8b3cc58e2f11584f3c218e0fdf8984b799b
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120667
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-14 12:49:06 +00:00
Régis Crelier dc35290111 [VM/nnbd] Reland of 3 reverted CLs and fix for canonicalization of legacy types.
The 3 relanded CLs are:
https://dart-review.googlesource.com/c/sdk/+/124480
https://dart-review.googlesource.com/c/sdk/+/124587
https://dart-review.googlesource.com/c/sdk/+/124920

The additional fix is:
https://dart-review.googlesource.com/c/sdk/+/125128

This fixes https://buganizer.corp.google.com/issues/144304690

Change-Id: Ica5ae249d738cab0b5d1885a01ddef2757c07174
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124906
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-11-14 02:10:15 +00:00
Ryan Macnak 9cd6c01bfd [vm, gc] Add a release barrier to prevent header initialization during promotion from being ordered after publishing stores of that object.
Compare 6354b0b97d, which did the same for direct old-space allocations.

Change-Id: Ifc047b48dfa10891ea7f1b39794f5fdbc7cf2ec8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124841
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-11-14 00:50:46 +00:00
Siva Annamalai 082c10aab7 Revert "[VM/nnbd] Pass nullability when creating Class::DeclarationType."
This reverts commit ea57b1e62c.

Reason for revert: Please see https://buganizer.corp.google.com/issues/144304690

Original change's description:
> [VM/nnbd] Pass nullability when creating Class::DeclarationType.
> 
> Passing nullability rather than forcing kLegacy helps slightly reduce the number
> of Types in the VM and in snapshots.
> This allows to remove the kludge about declaration type of Null being kNullable.
> Also pass nullability when creating a simple type may help.
> 
> Note that CFE is still producing super types and some interface types that are
> non-nullable, even with nnbd features disabled. But this should get fixed and
> further reduce the number of types in the snapshot.
> 
> Change-Id: I397f00902026ee5bc91d36328f4156427702efdb
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124480
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

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

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

Change-Id: Icae0a69cda6cc531bba4d5d12471e7267a277340
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125102
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-11-13 02:06:02 +00:00
Siva Annamalai b4779e8f72 Revert "[VM/nnbd] Make Nullability and NNBDMode class enums to avoid name conflicts."
This reverts commit d45c3d15cb.

Reason for revert: Please see https://buganizer.corp.google.com/issues/144304690
(This CL is dependent on https://dart-review.googlesource.com/c/sdk/+/124480 which caused the regression).

Original change's description:
> [VM/nnbd] Make Nullability and NNBDMode class enums to avoid name conflicts.
> 
> Change-Id: Ic78d3f48964bb61cbd1d90a69fcd68b4f29071e4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124587
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

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

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

Change-Id: I24603236f04bd2ec1ad80789d78cca89e70fb1d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125101
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-11-13 02:01:44 +00:00
Siva Annamalai 82aa7e79af Revert "[VM/nnbd] Force the DeclarationType of a class to have legacy nullability."
This reverts commit 3771dddf43.

Reason for revert: see https://buganizer.corp.google.com/issues/144304690
(This CL is dependent on https://dart-review.googlesource.com/c/sdk/+/124480 which caused the regression).

Original change's description:
> [VM/nnbd] Force the DeclarationType of a class to have legacy nullability.
> 
> This is a workaround to avoid caching a non-legacy type (possibly provided
> by the CFE) as the canonical type of a non-generic class and later returned as
> the runtime type of an instance of this class.
> 
> Hopefully fixes https://buganizer.corp.google.com/issues/144304690
> 
> Change-Id: Iaea364b9b743b05bde600f0aa784d5a8105728d7
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124920
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Régis Crelier <regis@google.com>

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

Change-Id: If8b2671f3cf4b0d080ba9f0472738326fec701d3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125100
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-11-13 01:55:18 +00:00
asiva a7472ba4c6 Cache value of "non-nullable" flag so it can be used in the VM code without having to search through the array of experimental flags array.
Change-Id: I297dca48711ef2bdd80a102086dea1bb075ea357
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125081
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-11-13 01:40:36 +00:00
Régis Crelier 3771dddf43 [VM/nnbd] Force the DeclarationType of a class to have legacy nullability.
This is a workaround to avoid caching a non-legacy type (possibly provided
by the CFE) as the canonical type of a non-generic class and later returned as
the runtime type of an instance of this class.

Hopefully fixes https://buganizer.corp.google.com/issues/144304690

Change-Id: Iaea364b9b743b05bde600f0aa784d5a8105728d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124920
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-11-12 16:26:29 +00:00
Régis Crelier b5110a59a9 Revert "[vm/async] Don't add an <asynchronous suspension> marker along sync-async calls."
This reverts commit f4d930997b.

Reason for revert: Different tests are failing on different bots.

Original change's description:
> [vm/async] Don't add an <asynchronous suspension> marker along sync-async calls.
> 
> This fixes `package:stack_trace` in the sync-start case of async/async* calls.
> 
> Change-Id: I5c41a35283439f533ab19c9fd1cc542931de4b43
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124560
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

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

Change-Id: Ib3e1b303613f0393dac6b1b81e8d1ffb322052b8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124800
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-11-11 19:03:54 +00:00
Samir Jindel f4d930997b [vm/async] Don't add an <asynchronous suspension> marker along sync-async calls.
This fixes `package:stack_trace` in the sync-start case of async/async* calls.

Change-Id: I5c41a35283439f533ab19c9fd1cc542931de4b43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124560
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-11 16:36:43 +00:00
Régis Crelier d45c3d15cb [VM/nnbd] Make Nullability and NNBDMode class enums to avoid name conflicts.
Change-Id: Ic78d3f48964bb61cbd1d90a69fcd68b4f29071e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124587
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-11-08 21:32:48 +00:00
Régis Crelier ea57b1e62c [VM/nnbd] Pass nullability when creating Class::DeclarationType.
Passing nullability rather than forcing kLegacy helps slightly reduce the number
of Types in the VM and in snapshots.
This allows to remove the kludge about declaration type of Null being kNullable.
Also pass nullability when creating a simple type may help.

Note that CFE is still producing super types and some interface types that are
non-nullable, even with nnbd features disabled. But this should get fixed and
further reduce the number of types in the snapshot.

Change-Id: I397f00902026ee5bc91d36328f4156427702efdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124480
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-11-08 18:40:59 +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