Commit Graph

95 Commits

Author SHA1 Message Date
Ryan Macnak ed2bca33a3 Roll Clang from 637e9bc0f763 to 26697f4d07eb
TEST=ci
Change-Id: I3087eac61590edd0aa79e940146345d6370ff39f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493840
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-08 14:31:16 -07:00
Ryan Macnak 737888b223 [vm] Make Dart Zones more similar to V8 Zones.
This eases the porting of Irregexp.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/56573
Change-Id: If31a0585ced3eabaf2dac6af04f83d387a8eab5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478080
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-04 10:16:41 -08:00
Ryan Macnak 1dc4277e5b [vm] Remove dead code.
TEST=ci
Change-Id: Ic162deea4a39869a158726616e5c8dc0ff058817
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475781
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-27 09:14:39 -08:00
Alexander Aprelev b759d096cb [vm/shared] Enforce pragma('vm:shared') annotations for captured local vars.
Fixes https://github.com/dart-lang/sdk/issues/61287
TEST=ffi/isolate_group_bound_captured_local_test

Change-Id: I9dc1e8aaf9e99d8ec9ad730cf1cd89ae3b4ed148
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444923
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-08-13 08:46:24 -07:00
Alexander Aprelev 4093bdaf5a [vm] Change try-catch IL representation.
Previously catch blocks were hanging off the function entry blocks being effectively an alternative entry-point into the function. Now catch blocks are hanging off the try-entry blocks.
  Previously all the variables that are used in the catch block and beyond were declared as parameters to catch block. Now only those that have their definitions not dominating catch entry will become parameters (for example, if a variable is assigned in the try-block, it becomes a parameter to catch block).
  During OSR, if OSR target entry point is inside some try-blocks, then all of corresponding try-entry/catch-blocks are pulled up to the OSR entry forming a chain that ends with a jump to the OSR target entry.

TEST=vm/dart/trycatch*, ci
Change-Id: Iae20c6548d5d65c63be6d7a53c1b0d2adac7ac31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356311
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-12-18 09:30:10 -08:00
Daco Harkes 6378a26212 [vm] Variable scoping fixes
This CL fixes two bugs related to scoping:
1. Empty variable name lookup in outer functions failing.
2. Let expressions not pushing and popping contexts.

Additionally, this CL introduces a `--print-scoping` debug flag to
ease debugging scoping issues in the future.

Variable lookup is now only using kernel offset, unless the offset
is `kNoKernelOffset`. In that case, the names are used.
All synthetic variables in the VM now use `kNoKernelOffset` as their
offset.

The let expressions not pushing contexts is fixed by pushing context.
The context is only pushed if the scope captures variables. So this
should not lead to performance regressions. (Any lacking pushing of
scopes should have lead to crashes.)

TEST=tests/ffi/regress_56412_2_test.dart
TEST=tests/ffi/regress_56412_test.dart

Closes: https://github.com/dart-lang/sdk/issues/56412
Change-Id: I85fc4a161b833df80ce8f2911d618aa2ac9797eb
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380983
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-08-23 07:03:15 +00:00
Tess Strickland d71837a316 [vm/compiler] Remove dead code in LocalScope/bitfield in LocalVariable.
There are no callers of CaptureLocalVariables(), and only
CaptureLocalVariables() checks the IsForcedStackBit bitfield of
LocalVariables, so remove that and its setter/getter as well.

TEST=ci (dead code removal)

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

Change-Id: I8032ff8f8cd7a43d3d30f1a4ec4e37cbfcee0a82
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379802
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-08-09 14:16:49 +00:00
Ivan Inozemtsev e005326c86 Mark operator== const to avoid ambiguity in C++20.
C++20 will automatically generate an operator== with reversed operand order, which is ambiguous with the written operator== when one argument is marked const and the other isn't.

TEST=ci
Change-Id: Ie4f7b293c1e68462f08335f4d4e9a8146dcc0e15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329105
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-10-04 13:18:55 +00:00
Alexander Markov 9f40ce6e3d [vm/aot] Use inferred types of captured local variables
On a micro-benchmark from https://github.com/dart-lang/sdk/issues/48764
in AOT mode, 'for-in' case:
Before: 0.556557s
After: 0.166579s (3.3x faster)

TEST=runtime/tests/vm/dart/regress_48764_il_test.dart

Issue https://github.com/dart-lang/sdk/issues/48764
Fixes https://github.com/dart-lang/sdk/issues/51102

Change-Id: I591739b8c2154931f6c535db57c0c11ba0eeb4a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321543
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-08-24 15:21:51 +00:00
Alexander Markov 47bc86cdc6 [vm] Cleanup handling of const local variables
All constants including const local variables are evaluated
in the front-end.

TEST=ci

Change-Id: I0062f5ac021b335ceb60c93ef8c230b49ec11a07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321540
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-08-17 19:50:48 +00:00
Martin Kustermann 587e6308bf [vm] Fix expression evaluation in context of closures
When evaluating an expressino at a breakpoint that's inside a closure,
the closure may refer to anything it closes over. That includes the
`this` from an enclosing method.

So depending on whether a closure's parent chain is an instance method
or a static method, the expression evaluation function is going to be an
instance method or a static method.

=> We walk up the parent chain to determine the correct enclosing class.
=> This avoids making a Type object with a cid from a top-level class (see [0])

Handling this correctly will now try to get the `this` when invoking an
eval function that has an enclosing instance method. Though we may often
have "<optimized out>" the `this` (e.g. due to not capturing it in
closure context chain).

=> We still allow running the expression evaluation function in this
case, but only if the expression being evaluated doesn't access `this`.

A similar issue occurs when trying to use variables in the eval
expression that the closure didn't capture. This results in a confusing
CFE compile-time error. This is a separate issue and tracked in [1].

=> We update the test to distinuish the cases that this CL makes passing
and those that are failing due to [1].

Fixes [0] https://github.com/dart-lang/sdk/issues/53061
See also [1] https://github.com/dart-lang/sdk/issues/53087

TEST=Fixes part of service/evaluate_activation_test failures

Change-Id: I3bb24e7338c7b2f12d5340311d944cb59a455641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317540
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-08-04 11:07:46 +00:00
Vyacheslav Egorov a52f2b9617 [vm] Rework awaiter stack unwinding.
The main contribution of this CL is unification of disparate
handling of various functions like `Future.timeout`,
`Future.wait`, `_SuspendState.createAsyncCallbacks` and
`_SuspendState._createAsyncStarCallback` into a single
`@pragma('vm:awaiter-link')` which allows Dart developers
to specify where awaiter unwinder should look for the next
awaiter.

For example this allows unwinding to succeed for the code like this:

    Future<int> outer(Future<int> inner) {
      @pragma('vm:awaiter-link')
      final completer = Completer<int>();

      inner.then((v) => completer.complete(v));

      return completer.future;
   }

This refactoring also ensures that we preserve information
(including Function & Code objects) required for awaiter
unwinding across all modes (JIT, AOT and AOT with DWARF stack
traces). This guarantees users will get the same information
no matter which mode they are running in. Previously
we have been disabling awaiter_stacks tests in some AOT
modes - which led to regressions in the quality of produced
stacks.

This CL also cleans up relationship between debugger and awaiter
stack returned by StackTrace.current - which makes stack trace
displayed by debugger (used for stepping out and determinining
whether exception is caught or not) and `StackTrace.current`
consistent.

Finally we make one user visible change to the stack trace:
awaiter stack will no always include intermediate listeners
created through `Future.then`. Previously we would sometimes
include these listeners at the tail of the stack trace,
which was inconsistent.

Ultimately this means that code like this:

    Future<int> inner() async {
      await null;  // asynchronous gap
      print(StackTrace.current); // (*)
      return 0;
    }

    Future<int> outer() async {
      int process(int v) {
        return v + 1;
      }

      return await inner().then(process);
    }

    void main() async {
      await outer();
    }

Produces stack trace like this:

    inner
    <asynchronous suspension>
    outer.process
    <asynchronous suspension>
    outer
    <asynchronous suspension>
    main
    <asynchronous suspension>

And when stepping out of `inner` execution will stop at `outer.process`
first and the next step out will bring execution to `outer` next.

Fixes https://github.com/dart-lang/sdk/issues/52797
Fixes https://github.com/dart-lang/sdk/issues/52203
Issue https://github.com/dart-lang/sdk/issues/47985

TEST=ci

Bug: b/279929839
CoreLibraryReviewExempt: CL just adds @pragma to facilitate unwinding
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-dwarf-linux-product-x64-try
Change-Id: If377d5329d6a11c86effb9369dc603a7ae616fe7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311680
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-30 14:03:03 +00:00
Ryan Macnak 2bfecc160b [vm] Update to constexpr in runtime/vm.
TEST=build
Change-Id: I2dd8ae69764af27f480a19995b491e98f52476ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293902
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-04-12 22:18:54 +00:00
Ryan Macnak f9a6a5bdd2 [vm] Update NULL to nullptr in runtime/vm.
TEST=build
Change-Id: I2834ef7cf7cb7c8770f8167a2438cbedcee5c623
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292063
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-04-10 18:15:12 +00:00
Alexander Markov 9703692a85 [vm] Hide local variables synthesized in the front-end from debugger
TEST=pkg/vm_service/test/patterns_local_vars_test.dart

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

Change-Id: I5a59d454b005740427610fab46892d63df1310dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288262
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-03-13 20:37:03 +00:00
Alexander Markov 9be13288b0 [vm] Support multiple local variables with the same name in the same scope
When lowering patterns, front-end can add multiple distinct local
variables with the same name into the same local scope.
Previously, VM identified local variables in a local scope by name.
However, this no longer works with patterns.

With this change, local variables are now identified by pair (name,
kernel offset). Name is still taken into account as compiler can add
extra variables which do not correspond to kernel variables,
such as 'this'.

TEST=runtime/tests/vm/dart/regress_51091_test.dart
Fixes https://github.com/dart-lang/sdk/issues/51091
Issue https://github.com/dart-lang/sdk/issues/49755

Change-Id: I0263769cb31f3f8d9652f5d6534800510ac882fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279650
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-01-31 18:47:46 +00:00
Josh Soref 1ab011a2a7 Spelling tests web
Closes https://github.com/dart-lang/sdk/pull/50879

TEST=only changes to spelling to comments and internal string messages
GitOrigin-RevId: 3fa4104fa17054ea2247118a1b6213c62f2749e0
Change-Id: I776120bb2492c662dd32612dd2f6a670b5891e42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278060
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-01-05 01:26:52 +00:00
Ryan Macnak 715866aed3 [vm, compiler] Remove quadratic time spent verifying handle lifetime.
Instead of checking whether a handle is a zone handle rather than a scoped handle by iterating the zone handle blocks, reserve an extra slot in debug mode to record the handle's lifetime.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/50408
Change-Id: I121c76d02b03e5d2141450077bc6e9da3cb60a5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268801
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-11-11 18:37:44 +00:00
Alexander Markov dc8f487bae [vm] Cleanup unused SourceLabel and NameReference
TEST=ci

Change-Id: Iffe90eca5b84f76ec2a1d22a31939b51f726909b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235862
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-03-08 18:06:14 +00:00
Alexander Markov 907c7fde19 [vm] Remove hardcoded context index of _future variable in _Future.timeout and Future.wait
Previously VM had a hardcoded constant values for context indices of
_future variables in _Future.timeout and Future.wait (used while
collecting stack traces). As those variables are allocated in
the context after captured parameters, their indices depend on
whether the parameters are captured.

I'd like to improve tree shaking so that it will remove
part of Future.wait method and make one of the parameters
not captured, which changes the context index (and it may vary
between modes and for different programs).

So, instead of hardcoding those indices, they are now calculated
at compile time and stored in ObjectStore. This is more flexible
and accommodates for future changes in tree shaker.

TEST=existing tests

Change-Id: I47629b41e497843fe3e998e813e793cf77c18bdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207202
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-07-19 17:11:29 +00:00
Ryan Macnak b1c09ecd8f [vm] Make naming more consistent when converting between handles, tagged and untagged pointers.
Currently we have things called XPtr which are not what you get from ptr().

Old world:
handle->raw() returns RawObject* (tagged)
raw_obj->ptr() returns RawObject* (untagged)

After 6fe15f6df9:
handle->raw() returns ObjectPtr
obj_ptr->ptr() returns ObjectLayout*

New world:
handle->ptr() returns ObjectPtr
obj_ptr->untag() returns UntaggedObject*

TEST=ci
Change-Id: I6c7f34014cf20737607caaf84979838300d12df2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149367
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-01-15 23:32:02 +00:00
Aske Simon Christensen 68fd2a9d52 [vm/jit] Pessimize type assumption in LoadLocal of covariant parameter.
This avoids unsound optimizations that could arise from loading a
parameter before its type had been checked.

Affects only unoptimized code.

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

Some considerations for a cleaner fix are described in
https://github.com/dart-lang/sdk/issues/43654

Change-Id: I05872e46495313e82e9c516e5f283e1bc4612300
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164500
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-10-02 16:17:58 +00:00
Clement Skau 6ca00d12c0 [VM] Adds Future.wait support for --lazy-async-stacks.
- Makes Future.wait a recognised function, and asserts its chained
future, _future is allocated at a known index in the context.
- Adds logic to locate, extract the chained future during lazy async
stack unwinding.
- Adds tests for the Future.wait async case.
- Minor consistency nits, comments.

This change is similar to a previous CL, adding Future.timeout support:
https://dart-review.googlesource.com/c/sdk/+/152328

Change-Id: I7439750968595d25d7bbac0068ad64fcc891e176
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155420
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-28 05:41:01 +00:00
Clement Skau 219935a48f [VM] Adds Future.timeout stack unwinding support for --lazy-async-stacks.
Bug: https://github.com/dart-lang/sdk/issues/40815
Change-Id: I1603e1effe67b727d5dc47c0830b4758c764cf4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152328
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-08 06:50:40 +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
Alexander Markov dd2d040ccb [vm] Cleanup flags which disable argument type checks and strong mode types
The following options are removed:
--use_strong_mode_types
--experimental_unsafe_mode_use_at_your_own_risk

The following flags and predicates are removed:

Dart_IsolateFlags::unsafe_trust_strong_mode_types
Isolate::argument_type_checks()
Isolate::can_use_strong_mode_types()
Isolate::should_emit_strong_mode_checks()

Also, everything depending on these flags is cleaned up.

Change-Id: I9328009ad5a42ea2173842386d612c465e3ebec1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147325
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-05-08 15:53:09 +00:00
Ryan Macnak 6fe15f6df9 [vm] Represent tagged pointers as C++ value types instead of C++ pointer types.
This works around bugs in UndefinedBehaviorSanitizer and Clang.

Bug: b/28638298
Change-Id: I6be595f9664516019d28017d24559583a1ae3a21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144354
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-04-25 05:21:27 +00:00
Vyacheslav Egorov a41a1dc917 [vm/compiler] Split compiler sources out of normal VM sources.
Make them form its own source set (libdart_compiler) and completely exclude
them from AOT runtime targets.

Previously we had some inconsistencies, with some files were using
DART_PRECOMPILED_RUNTIME to fully or partially exclude either contents
from their headers or from implementation, while other files did nothing
and relied on linker to throw their contents away.

This change tries to address this inconsistency.

A follow up change would include a check in most compiler headers which
would prohibit to use them while building AOT runtime.

Change-Id: Ief11b11cbc518b301d3e93fce80580a31bbad151
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142993
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-16 22:59:03 +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
Alexander Markov f56b0f6907 [vm/aot/tfa] Whole-program constant propagation
Size:
flutter_gallery total size -2.48% (arm), -2.3% (arm64)
flutter_gallery instructions size -2.91% (arm), -2.77% (arm64)
velocity_tracker_bench total size -7.5% (arm), -7.1% (arm64)

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

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

Change-Id: I6221bfa02b165ccc17d4ee8b857bb89212febaff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125936
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-12-04 19:19:29 +00:00
Martin Kustermann a64b06ec83 [gardening] Migrate most files to be implicit-bool-conversion free
Issue https://dart-review.googlesource.com/c/sdk/+/115701

Change-Id: Ib579f0bbc8d694aec74afd837217316a10baf910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115707
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2019-09-05 21:41:42 +00:00
Alexander Markov 449446571f [vm/bytecode] Collect context levels for compiled code generated from bytecode
Change-Id: Ia2047440e05fce3263f8feb38be4cedd4357ab10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112920
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-13 20:32:49 +00:00
Samir Jindel 7929e1c714 [vm/ffi] Remove LocalVariable references from Allocate/CloneContext instructions
Also some other cleanups from https://dart-review.googlesource.com/c/sdk/+/107407,
and exclude scopes.cc from the precompiled runtime.

Change-Id: If14e46d44e6114a123a1eae3c85b63519b2863ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108274
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-07-08 17:11:34 +00:00
Régis Crelier c6c0e5bf40 [vm/debugger] Make use of variable descriptors in bytecode debugger.
Change-Id: Ibf4c8f638065c8173c5c21c8fa9c40ee5cecb587
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106427
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-06-18 19:47:27 +00:00
Ryan Macnak e48ad45fbd [vm, interpreter] Enable field guards.
Bug: https://github.com/dart-lang/sdk/issues/36131
Change-Id: I8aa538bc96d10d14322c875228dbd7a97ddf114b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95491
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-03-07 00:19:40 +00:00
Alexander Markov 51a334caa7 [vm] Remove kernel reading from BuildArgumentTypeChecks
This change is a preparation for decoupling flow graph building of
special functions from kernel reading.

Change-Id: Ied90bc6894cdfa48f49c71e980079967c8c4fbb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95061
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-03-05 18:48:51 +00:00
Vyacheslav Egorov ddbe22190c [vm/compiler] Refactor representation of stores and loads in IL.
Make StoreIntanceField and LoadField instructions use a single uniform
abstraction: Slot (used to be called NativeFieldDesc), which represents
either a real Dart field (i.e. a field that has a corresponding Field object)
or a native VM field that does not have a corresponding Field object.

This refactoring eliminates raw stores/loads that were just using offsets
before - now we always know what kind of slots we are accessing and
this yields better aliasing information.

Change-Id: I2f48332d58258219565bd961764e8cc9dd4d75ce
Reviewed-on: https://dart-review.googlesource.com/c/74582
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-11-16 17:57:29 +00:00
Samir Jindel 5ef1465c55 [vm] Attach type to parameters on unchecked entry.
This is especially important for multiple entry-points in AOT mode, since without the type
information we can't inline certain intrinsics (because they would have to de-opt).

Change-Id: I62352234c95a1211ff7cdabb9cefc48990427a6f
Reviewed-on: https://dart-review.googlesource.com/c/82999
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-11-12 12:57:00 +00:00
Vyacheslav Egorov 325a8fee4d [vm] Fix experimental_unsafe_mode_use_at_your_own_risk mode.
Turn it into an isolate specific flag so that Kernel isolate continues
to run from app-jit snapshot without trusting any types.

Change-Id: I627a40025d53c23586da5a207eb096886ca98bc4
Reviewed-on: https://dart-review.googlesource.com/72040
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-08-30 12:04:37 +00:00
Alexander Markov 6bc1cdb5b1 [vm] Add unsafe mode to VM
This CL adds experimental --experimental-unsafe-mode-use-at-your-own-risk
VM option which does the following:
* Dart 2 strong mode type and bool checks are omitted.
* VM compiler optimizations which rely on strong mode types are disabled.

Applications which do not fail any strong mode checks at run time
should behave exactly the same in strong and weak modes.
Applications with failing strong mode checks will not see corresponding
errors but VM should not crash.

This option can be used for experiments, or as a temporary remedy for
regressions caused by expensive strong mode type checks.

Change-Id: I042cbccba83c105b61b3e11c659a35c20e0329cd
Reviewed-on: https://dart-review.googlesource.com/65484
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-20 20:31:19 +00:00
Martin Kustermann 0a8b236159 [VM] Make the encoding of variable descriptors use variable indices
This decouples the scope building from knowing about frame layout.

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

Change-Id: I9058b242fb24f859f54d6e3660a5972df86d39e6
Reviewed-on: https://dart-review.googlesource.com/59093
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-06-11 09:55:54 +00:00
Martin Kustermann a603635b85 [VM] Decouple frontend from frame layout
So far the frontend (parser, flow graph builder, ssa construction) were
aware of the actual frame layout.

This CL makes the indices we assign to [LocalVariable]s logical
indices, assigning:

  * M parameters the indices      1 ... M
  * N local variables the indices 0 -1 ... -(N-1)

The scope building, flow graph builder and ssa construction operate on
those logical indices.

When emitting actual code, the backend will translate those indices into
actual FP relative indices. This allows us to be more flexible in the
backend which frame layout we choose.

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

Change-Id: I9a504bf97821c257aafd2b3430df9f4c9da4b442
Reviewed-on: https://dart-review.googlesource.com/57321
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-06-07 11:35:58 +00:00
Alexander Markov 6ed2ebf6b0 [vm/kernel/aot] Infer parameter types in type flow analysis
Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: Iea1480ce2f20b6cb08b4eb57eef5ca14a002e6e0
Reviewed-on: https://dart-review.googlesource.com/40400
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-02-13 01:11:18 +00:00
Vyacheslav Egorov d117760ba6 [vm/kernel/aot] Skip unnecessary type checks on parameters of instance methods.
This relands 75a9579ea0.

The approach works as follows:

Step 1: Kernel transform. Under the closed world assumption compute the
set of selectors dispatched dynamically, then mark all procedures that don't
match any of those selectors as 'not-dispatched-dynamically'.

Step 2: VM backend. When building IR for a function if this function was
marked as not-dispatched-dynamically then omit type checks for any parameter
that is not marked as generic-covariant-impl, as such arguments are guaranteed
to be checked on the caller side (by front-end).


+------------------------+------------+----------+-----------+--------------+
|       benchmark        |  baseline  |  current |  with opt |  improved by |
+------------------------+------------+----------+-----------+--------------+
| stock_layout_iteration |  2366.3786 |   2724.3 |   2562.75 |  -5.93%      |
| stock_build_iteration  |     3824.3 |   4914.8 |      4681 |  -4.76%      |
+------------------------+------------+----------+-----------+--------------+

* Flutter gallery Instructions size is reduced by 11% (8748720 bytes to 7846368 bytes).
Baseline is at 6196496 bytes.


Alternatively to annotating individual procedures, I considered annotating Program node
with a set of dynamically dispatched selectors. Decoding and passing this information
around proved to be quite cumbersome in the "streaming" world, so I opted for a simpler
approach where all individual procedures are annotated.

Bug: https://github.com/dart-lang/sdk/issues/3179
Change-Id: I2f32a609e3872c74d5ae7bbd97555453aaedf15f
Reviewed-on: https://dart-review.googlesource.com/38125
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-02-02 11:43:55 +00:00
Vyacheslav Egorov 7078f6be58 Revert "[vm/kernel/aot] Skip unnecessary type checks on parameters of instance methods."
This reverts commit 75a9579ea0.

Reason for revert: function_subtype_bound_closure7_test fails in darkp

Original change's description:
> [vm/kernel/aot] Skip unnecessary type checks on parameters of instance methods.
> 
> The approach works as follows:
> 
> Step 1: Kernel transform. Under the closed world assumption compute the
> set of selectors dispatched dynamically, then mark all procedures that don't
> match any of those selectors as 'not-dispatched-dynamically'.
> 
> Step 2: VM backend. When building IR for a function if this function was
> marked as not-dispatched-dynamically then omit type checks for any parameter
> that is not marked as generic-covariant-impl, as such arguments are guaranteed
> to be checked on the caller side (by front-end).
> 
> # Performance Impact
> 
> +------------------------+------------+----------+-----------+--------------+
> |       benchmark        |  baseline  |  current |  with opt |  improved by |
> +------------------------+------------+----------+-----------+--------------+
> | stock_layout_iteration |  2366.3786 |   2724.3 |   2562.75 |  -5.93%      |
> | stock_build_iteration  |     3824.3 |   4914.8 |      4681 |  -4.76%      |
> +------------------------+------------+----------+-----------+--------------+
> 
> * Flutter gallery Instructions size is reduced by 11% (8748720 bytes to 7846368 bytes).
> Baseline is at 6196496 bytes.
> 
> # Alternative Implementations
> 
> Alternatively to annotating individual procedures, I considered annotating Program node
> with a set of dynamically dispatched selectors. Decoding and passing this information
> around proved to be quite cumbersome in the "streaming" world, so I opted for a simpler
> approach where all individual procedures are annotated.
> 
> Change-Id: I363db6d5dd1138fe25917646313c16d0b213c3b4
> Reviewed-on: https://dart-review.googlesource.com/37822
> Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Samir Jindel <sjindel@google.com>

TBR=vegorov@google.com,alexmarkov@google.com,sjindel@google.com

Change-Id: I0fd6bf3e6edfc3e605da2b996f9a0da6c409d01c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/37802
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-02-01 20:41:19 +00:00
Vyacheslav Egorov 75a9579ea0 [vm/kernel/aot] Skip unnecessary type checks on parameters of instance methods.
The approach works as follows:

Step 1: Kernel transform. Under the closed world assumption compute the
set of selectors dispatched dynamically, then mark all procedures that don't
match any of those selectors as 'not-dispatched-dynamically'.

Step 2: VM backend. When building IR for a function if this function was
marked as not-dispatched-dynamically then omit type checks for any parameter
that is not marked as generic-covariant-impl, as such arguments are guaranteed
to be checked on the caller side (by front-end).

# Performance Impact

+------------------------+------------+----------+-----------+--------------+
|       benchmark        |  baseline  |  current |  with opt |  improved by |
+------------------------+------------+----------+-----------+--------------+
| stock_layout_iteration |  2366.3786 |   2724.3 |   2562.75 |  -5.93%      |
| stock_build_iteration  |     3824.3 |   4914.8 |      4681 |  -4.76%      |
+------------------------+------------+----------+-----------+--------------+

* Flutter gallery Instructions size is reduced by 11% (8748720 bytes to 7846368 bytes).
Baseline is at 6196496 bytes.

# Alternative Implementations

Alternatively to annotating individual procedures, I considered annotating Program node
with a set of dynamically dispatched selectors. Decoding and passing this information
around proved to be quite cumbersome in the "streaming" world, so I opted for a simpler
approach where all individual procedures are annotated.

Change-Id: I363db6d5dd1138fe25917646313c16d0b213c3b4
Reviewed-on: https://dart-review.googlesource.com/37822
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-02-01 18:07:38 +00:00
Martin Kustermann cf1de7d46c [VM] Replace hand-written assembly prologues with IR
As part of the prologue changes we get rid of the empty context as well.

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

Change-Id: I707e23c631bcfbbad6c91c4963d0c10f7a0be625
Reviewed-on: https://dart-review.googlesource.com/25320
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-13 16:04:34 +00:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Ryan Macnak 2109cc53bf Remember deopt-id -> context-level mappings in var descriptors.
- Add deopt ids to DebugStepInstr and StrictCompareInstr since the debugger can stop there.
 - Add missing pc descriptor in DBC's StringInterpolateInstr.

Re-enable async_debugger, which had been crashing flakily from context mismatches.

R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2903993002 .
2017-06-01 12:33:33 -07:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00