The debugger and runtime should not try to deoptimize 'force-optimized'
functions. This fixes#38108.
Change-Id: I74e24d8fb4793e4560267c2cb32ac40caa95bf35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115014
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
The mutator has to ensure all writes to the ICData are flushed before we set the
megamorphic bit.
Similarly the BG compiler has to ensure (during cloning of ICData) that all
loads from the ICData happen after we've determined whether the megamorphic
bit has been set.
This allows us to maintain the invariant that if the ICData is marked as
megamorphic, the entries in it will have reached FLAG_max_polymorphic_checks.
Issue https://github.com/dart-lang/sdk/issues/37595
Change-Id: Idec7aef8ca1369668f5c9c57b7b32759acbd270d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114322
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Removes all ICData from bytecode, avoding the need to clear bytecode when CIDs are reassigned.
Change-Id: I185f9f7acef6a32ef46adb73c6d2652bc1231bab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114053
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
The original revision is in patchset 1.
Three bugs are fixed:
1. Fix SIMARM_X64 build: no need to generate trampolines for AOT or simulated JIT.
2. Hot-reload: Fix hot-reload: don't invalidate Code for force-optimized functions.
3. Windows: Provide shadow space to runtime routines.
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-mac-debug-simarm_x64-try,vm-kernel-precomp-mac-release-simarm_x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-release-ia32-try,vm-kernel-win-release-x64-try
Change-Id: I326009cfacb51a84e9de4ddf9ff2d6d415460f91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113829
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Saves 10ms from non-empty reloads of Flutter Gallery.
Change-Id: If9a1f9970d562f8fd7996de875dfe231350efaa9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113282
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Previously, InlineCacheMissHandler forced foreground compilation of a target
even if interpreter is enabled. This might cause excessive compilation of
functions which are executed only a few times, as well as simultaneous
compilation of a function in background and foreground.
Change-Id: If716370d408cf9cff1b72123ab24d609246961a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112200
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This change introduces two new pragmas:
* `@pragma('vm:never-inline')`
* `@pragma('vm:prefer-inline')`
These replaces the old way of specifying AlwaysInline or NeverInline
annotations when the (now removed) --enable-inlining-annotations flag
was used.
Bug: https://github.com/dart-lang/sdk/issues/36571
Change-Id: Iee152c1d67abde8d58c58fa967449d36e77c8c93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110440
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
the recent regression seen in flutter hot reload benchmarks
after the roll of Dart BE into flutter post 1.7 release.
Change-Id: I188fa4aafdd7cdfa6b793de9d7ab00c9dae05409
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109361
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This reverts commit 629f38cf87.
Reason for revert: This CL seems to depend on constant_update_2018 flag being turned on by default. The CL that turns on constant_update_2018 has been reverted, so this CL is also being reverted.
Original change's description:
> [vm/compiler] Implement new inlining pragmas.
>
> This change introduces two new pragmas:
>
> * `@pragma('vm:never-inline')`
> * `@pragma('vm:prefer-inline')`
>
> These replaces the old way of specifying AlwaysInline or NeverInline
> annotations when the (now removed) --enable-inlining-annotations flag
> was used.
>
> Bug: https://github.com/dart-lang/sdk/issues/36571
> Change-Id: I2495c72819d94e43cefc837d4eb454b7b3d4140c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99148
> Commit-Queue: Teagan Strickland <sstrickl@google.com>
> Reviewed-by: Samir Jindel <sjindel@google.com>
TBR=sjindel@google.com,sstrickl@google.com
Change-Id: Idc8e8344adb026a308af20c8b0d0224edb891d9c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/36571
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109320
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This change introduces two new pragmas:
* `@pragma('vm:never-inline')`
* `@pragma('vm:prefer-inline')`
These replaces the old way of specifying AlwaysInline or NeverInline
annotations when the (now removed) --enable-inlining-annotations flag
was used.
Bug: https://github.com/dart-lang/sdk/issues/36571
Change-Id: I2495c72819d94e43cefc837d4eb454b7b3d4140c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99148
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
Previously, in rare cases it was possible that interpreter would trigger
optimizing compilation (if function usage counter reached threshold
in the interpreter once again after unoptimized compilation finished).
This results in producing optimized code without any feedback (as
unoptimized code hasn't executed).
Change-Id: Ibd52b7dfe3a808ade97c02e743b40aa466b1e3c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108687
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Previously, core snapshot was generated from AST
(because --enable-interpreter/--use-bytecode-compiler was not specified
when building core snapshot).
As the result, CL
https://dart.googlesource.com/sdk/+/da8cb470cc94830a98d49532e8d5d1a5b3d80f8b
which declared libraries in bytecode also removed bytecode entirely from
core snapshot in Dart SDK.
This CL enables bytecode by default if --bytecode argument is
specified for gn.py. This enables JIT compiler from bytecode
(interpreter is still disabled by default but can be enabled
using --enable-interpreter). Core snapshot and other
snapshots now have bytecode.
This change revealed a bunch of bugs which are fixed in this CL:
* _Closure fields were treated as unboxing candidates which triggered
assertion in LoadFieldTOS in interpreter.
* Several places should load class declarations if they are not loaded yet.
* Canonicalization of TypeRef objects which are not fully initialized
may cause duplicate entries in the hash table of canonical
TypeArguments. This triggers assertions when hash table is rehashed.
The solution is to avoid canonicalization of non-root recursive types
and recursive type arguments. Also, TypeRef::Canonicalize and
TypeRef::Hash are reverted to assert and work only if type was set.
* Native wrapper classes are eagerly stamped as type-finalized
which caused assertion failures when reading their class declarations
from bytecode.
* When building flow graph for FFI trampolines kernel offset of library
(which is now declared in bytecode) was queried. Added special case
to Function::KernelDataProgramOffset().
* In interpreter-only mode with simulator (e.g. SIMARM64) if simulator
is not called before code is interrupted with stack overflow check,
simulator returns get_sp() = 0, which was treated as stack overflow.
* test standalone_2/io/platform_resolved_executable_test.dart
spawns sub-process but it didn't pass VM options.
Change-Id: I81bc4f1a4c6725cfa246a435ebe5d8abe43abc67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107199
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Instead, we set a bit on force-optimized code so that deoptimization knows to skip it and exception
handling will execute catch-entry moves.
In addition we don't throw away deoptimization info for these codes, so that exception handling
works.
Bug: dartbug.com/37311
Change-Id: If5bcff41a98c0053c581648a9ee22b3302ceea04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106740
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Size of a large application:
Before: 26628600
After: 21480120 (-19.3%)
Size of snapshots:
isolate_snapshot_framework.bin
Before: 9322496
After: 6782976 (-27.2%)
isolate_snapshot_product_framework.bin
Before: 9166848
After: 6602752 (-27.9%)
Regressions in tests:
1) Test language_2/type_alias_equality_test/04 fails similarly to default mode, as VM
does not implement comparison of function types according to the specification.
Previously this test was passing as function types were canonicalized in bytecode,
which was not always correct. This CL fixes the problem with canonicalization of
function types in bytecode and the test starts failing again.
2) Tests standalone_2/entrypoints_verification_test, standalone_2/io/test_extension_test,
standalone_2/io/test_extension_fail_test fail as native extensions are not supported
in bytecode yet. These tests start passing after df5e7aac17,
which switched bytecode tests to kernel service (on x64), because kernel service doesn't
drop ASTs. This CL switches from reading AST library declarations to bytecode even if
AST is not removed, so tests fail again.
Change-Id: I8b7ba44bfa49d0b1599b2509553ff7c831a4e244
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104700
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
dart-bytecode, arm64: +4.742% geomean
dart-bytecode-jit-unopt, arm64: +12.73% geomean
dart2js-compile, x64: +3.635% geomean
In the polymorphic and unlinked cases, call to a stub the does a linear scan against an ICData.
In the monomorphic case, call to a prologue of the expected target function that checks the expected receiver class. There is additional indirection in the JIT version compared to the AOT version to also tick a usage counter so the inliner can make good decisions.
In the megamorphic case, call to a stub that does a hash table lookup against a MegamorphicCache.
Megamorphic call sites face a loss of precision in usage counts. The call site count is not recorded and the usage counter of the target function is used as an approximation.
Monomorphic and megamorphic calls sites are reset to the polymorphic/unlinked state on hot reload.
Monomorphic and megamorphic calls sites do not check the stepping state, so they are reset to the polymorphic/unlinked state when stepping begins and disabled.
Back-edges now increment the usage counter in addition to checking it. This ensures function with loops containing monomorphic calls will eventually cross the optimization threshold.
Fixed backwards use of kMonomorphicEntryOffset and kPolymorphicEntryOffset.
Fixed C stack overflow when bouncing between the KBC interpreter and a simulator.
Bug: https://github.com/dart-lang/sdk/issues/26780
Bug: https://github.com/dart-lang/sdk/issues/36409
Bug: https://github.com/dart-lang/sdk/issues/36731
Change-Id: I78a49cccd962703a459288e71ce246ed845df474
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102820
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
The list of bytecodes that are checked for debug breaks and single stepping
can be tuned later (as well as performance if needed).
Fix identification of Dart top activation frame in debugger.
Change-Id: Ieab804ba25f84efe173531431c6d311005163433
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104922
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
There are minor fixes for dartkb and windows.
The original revision is in patchset 1.
Change-Id: I9ab6e5fdb33fb4e84ea520c283fe94323616a8ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103129
Commit-Queue: Samir Jindel <sjindel@google.com>
Auto-Submit: Samir Jindel <sjindel@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
This reverts commit fde6a5917e.
Reason for revert: This commit looks to be causing new test failures on dart2js. While there are some odd results on some builders that look like infra failures, some builders (for example, dart2js-minified-strong-linux-x64-d8) show the new failing tests clearly.
Original change's description:
> [vm, compiler] Unoptimized megamorphic calls.
>
> When an instance call in unoptimized code creates more than FLAG_max_polymorphic_checks cases, switch the call to use a MegamorphicCache instead of ICData. The prevents unbounded collection of type feedback, and gives improvements on microbenchmarks in the 3-8% range for unoptimized code.
>
> It also leads to a loss of target frequency information for the optimizer, leading to different ordering for range checks in polymorphic inlining. This leads to changes on megamorphic microbenchmarks from -31% to +60%, weighted toward the negative end.
>
> In practice the frequency information seems unimportant, as dart2js has 4.01% geomean improvement.
>
> This is a step toward direct monomorphic calls in unoptimized code, which will also make use of the patching and type feedback extraction added here.
>
> Bug: https://github.com/dart-lang/sdk/issues/26780
> Bug: https://github.com/dart-lang/sdk/issues/36409
> Bug: https://github.com/dart-lang/sdk/issues/36731
> Change-Id: I29f53f23b6794c5f5f0db8b8184788cee16fd9c5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99270
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
TBR=rmacnak@google.com,alexmarkov@google.com,ajcbik@google.com
Change-Id: Icad46b93cdf8541a00563f49da6b4ac0a4df1ba1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/26780, https://github.com/dart-lang/sdk/issues/36409, https://github.com/dart-lang/sdk/issues/36731
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103440
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
When an instance call in unoptimized code creates more than FLAG_max_polymorphic_checks cases, switch the call to use a MegamorphicCache instead of ICData. The prevents unbounded collection of type feedback, and gives improvements on microbenchmarks in the 3-8% range for unoptimized code.
It also leads to a loss of target frequency information for the optimizer, leading to different ordering for range checks in polymorphic inlining. This leads to changes on megamorphic microbenchmarks from -31% to +60%, weighted toward the negative end.
In practice the frequency information seems unimportant, as dart2js has 4.01% geomean improvement.
This is a step toward direct monomorphic calls in unoptimized code, which will also make use of the patching and type feedback extraction added here.
Bug: https://github.com/dart-lang/sdk/issues/26780
Bug: https://github.com/dart-lang/sdk/issues/36409
Bug: https://github.com/dart-lang/sdk/issues/36731
Change-Id: I29f53f23b6794c5f5f0db8b8184788cee16fd9c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99270
Reviewed-by: Alexander Markov <alexmarkov@google.com>
The slow patch code of allocation stubs goes to runtime to allocate
objects/contexts/arrays. Those native calls seemingly guaranteed that
an object is new-or-remembered.
Though the runtime can actually allocate a new object and it can get
moved to old space right before returning to the continuation of slow
path allocation.
This causes us to have a newly allocated object which is not in the
remembered set.
This CL moves the code for "new-or-remembered guarantee" from
runtime_entry.cc to the call-sites in allocation stubs.
Issue https://github.com/dart-lang/sdk/issues/36369
Change-Id: Ieef9232b4c50fdd84ad81dd8f77697bf0c4775ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99143
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This reverts commit d79787771e.
Reason for revert:
This caused significant performance regressions on our protobuf_decode* benchmarks (probably on more benchmarks, but we don't yet have results due to some perf infra issue).
To avoid letting the regressions land for downstream users we'll revert it.
We should measure performance impact before landing this again.
Original change's description:
> [vm] Repair the resolver abstraction, take 2.
>
> - Move resolution logic that accumulated in the runtime entries into Resolver.
> - Improve NoSuchMethodError for closures when --no-lazy-dispatchers
> - Fix concurrent modification of Null class by nullability propagation.
>
> Change-Id: Ib05b431a289d847785032dda46e1bbcb524b7343
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98428
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Régis Crelier <regis@google.com>
TBR=rmacnak@google.com,alexmarkov@google.com,regis@google.com
Change-Id: I4f0f0a0d7c6018fc5968aafdce30f6d2e7495059
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99140
Reviewed-by: Martin Kustermann <kustermann@google.com>
This reverts commit 2f0dfd6124.
Reason for revert:
Need to revert this CL in order to revert [0] which had performance regressions.
[0] https://dart-review.googlesource.com/c/sdk/+/98428
Original change's description:
> [vm] Cache method resolution.
>
> Change-Id: I5b3a9764b6932548ee25823b7dc42011ac292427
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98640
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Régis Crelier <regis@google.com>
TBR=rmacnak@google.com,alexmarkov@google.com,regis@google.com
Change-Id: I2b3367e38103437a74124d129ff0b357058a5a57
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99160
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
- Move resolution logic that accumulated in the runtime entries into Resolver.
- Improve NoSuchMethodError for closures when --no-lazy-dispatchers
- Fix concurrent modification of Null class by nullability propagation.
Change-Id: Ib05b431a289d847785032dda46e1bbcb524b7343
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98428
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>