This change adds merging of cid ranges into Cids::Create if there are
gaps with the same target function. Previously, this optimization was
performed only when calculating targets via CallTargets::CreateAndExpand.
However, Cids::Create is widely used to check receiver type if there is
only one targets (e.g. in CallSpecializer::AddReceiverCheck /
CallSpecializer::AddChecksForArgNr).
This optimization is needed to shrink huge code for CheckClass instructions
in Flutter RenderObject.layout() method in JIT mode.
Issue: https://github.com/dart-lang/sdk/issues/36428
Change-Id: I97051b4213066b252ac3238df55ab4ed5c98f412
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103402
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@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>
Until now we often leaked kernel buffers (e.g. hot reload buffers) because various
objects were referencing ExternalTypedData objects pointing into the middle of
c-allocated memory. This made it impossible for the GC to determine when the last
reference is gone.
This CL ensures that the actual buffers are *always* made available via
ExternalTypedData and any inner pointers into it are created via TypedDataViews.
The embedder guarantees to the free kernel buffers it has provided to:
- Dart_CreateIsolateFromKernel
- Dart_LoadScriptFromKernel
- Dart_LoadLibraryFromKernel
- Dart_SetDartLibrarySourcesKernel
on isolate shutdown.
All other kernel buffers will get a finalizer attached, which ensures the
kernel buffers get freed by the GC once they are no longer referenced:
- Kernel blobs for expression evaluation
- Kernel blobs for Hot-Reload
- Kernel blobs for cc tests
Fixes https://github.com/dart-lang/sdk/issues/33973
Fixes https://github.com/dart-lang/sdk/issues/36857
Issue https://github.com/dart-lang/sdk/issues/37030
Change-Id: I1cc410c94c0f4b229413e793728a261afcb10aaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103130
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@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>
Rationale:
A basic peephole optimizer with window size one that avoids
redundant push-pop sequences already results is substantial
savings in code size and runtime, without any noticeable impact
on compile time (the peephole is very, very fast).
Performance:
Golem unoptimized code (which typically runs -90% compared to
optimized code, sees 5-60% improvements
https://github.com/dart-lang/sdk/issues/36409
Change-Id: I08db4b3dbc92377d89340a4969db6e664e54bceb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102980
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Type propagator adds Redefinition instructions to provide more accurate
type information only for dominated uses (for example, to mark receiver
as non-nullable after instance calls). However, adding Redefinition
instructions may interfere with branch simplification, which looks only
at empty join blocks. This change avoids adding unused Redefinition
instructions (if there are no dominated uses).
This particular situation happens in Flutter in RenderObject.layout() where
constraints.isTight is inlined with multiple polymorphic targets, including
SliverConstraints.isTight which returns false.
Branch simplification was not happening due to Redefinition instruction
for 'constraints'. That Redefinition instruction is not used.
Change-Id: I15082bacd7cc6ea1445a4dadc8ef97853142ba74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103023
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
When a mixin class is created, there might be anonymous closures copied over to the other script.
Previously the script of closure function is the script of its parent function, which is not true in that case.
The solution is to create a patch class as the owner if parent function has a different script object. Return script of owner when query for script of closure function.
Bug: https://github.com/dart-lang/sdk/issues/34841
Change-Id: I53065cbf13f2d0dc8da320993fd3cd425e5c9714
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102226
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Previously we would generate the prologue in FunctionEntryInstr or OsrEntryInstr
on X64/ARM, and in CompileGraph on ARM64/IA32/DBC. This caused a confusing asymmetry
in the code.
Now we generate it in FunctionEntryInstr/OsrEntryInstr on all backends.
Partially addresses dartbug.com/34162.
This also fixes a regression on a protobuf benchmark due to ICDatas not being saved.
Change-Id: Ie270d759234b197141025dde07a27546d221f6c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101297
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
In many cases, the Mutexes and Monitors have to be marked "mutable"
because they're used to synchronize const accessor methods.
Small text segment improvement for Product builds:
$ size dart.{arm,x64}.{before,after}
text data bss dec hex filename
19726069 409960 392332 20528361 1393ce9 dart.arm.before
19725525 409960 392332 20527817 1393ac9 dart.arm.after
22576021 600376 1782824 24959221 17cd8f5 dart.x64.before
22574821 600376 1782824 24958021 17cd445 dart.x64.after
Change-Id: I68f5cd5ad452044df8bfebd160910496036a3e6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101745
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Move SpawnCount logic into SpawnIsolateTask, where it logically makes
more sense. This eliminates some code and also prevents
IsolateSpawnState from having lingering pointers to the parent
Isolate's fields after it might have been reclaimed.
Change-Id: If8d827f299ee90dd54faf896609a7acdfbb87608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101628
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
const objects that are declared in .h files are supposed to have
out-of-line definitions in their corresponding .cc file. It seems like
CL 101222 happened to expose this for Message::kIllegalPort.
Change-Id: I9656037581eb6406eaf3289dfcf705db90862a26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102122
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
There were rare crashes
../../runtime/vm/compiler/call_specializer.cc: 1393: error: expected: call->MatchesCoreName(Symbols::_simpleInstanceOf())
version=2.3.0-edge.796ebc6069bde3a59475a9b45075f49e50b0cc34 (Thu May 9 09:38:28 2019 -0700) on "linux_x64"
thread=82540, isolate=vm-service(0x558748c5d200)
pc 0x000055874635dd6c fp 0x00007fa94dd3bf30 dart::Profiler::DumpStackTrace(void*)
pc 0x0000558745f90332 fp 0x00007fa94dd3c010 dart::Assert::Fail(char const*, ...)
pc 0x000055874653909b fp 0x00007fa94dd3c0a0 dart::CallSpecializer::ReplaceWithInstanceOf(dart::InstanceCallInstr*)
pc 0x0000558746496ed6 fp 0x00007fa94dd3c0f0 dart::FlowGraphVisitor::VisitBlocks()
when running
tools/test.py --repeat 5000 -n dartkb-mixed-linux-debug-x64 language_2/null_test
at the rate ~1-3 crashes per 30,000 test cases.
The problem is that in function
bool InstanceCallInstr::MatchesCoreName(const String& name) {
return function_name().raw() == Library::PrivateCoreLibName(name).raw();
}
'function_name().raw()' is evaluated before PrivateCoreLibName(name) is called
and saved in a temporary (register). PrivateCoreLibName may trigger GC and
relocate objects. In such case, 'PrivateCoreLibName(name).raw()' results in a
moved object, which is compared to a stale object address.
This CL fixes InstanceCallInstr::MatchesCoreName and other similar places
by introducing Library::IsPrivateCoreLibName, which is also a little bit more
efficient as it avoids extra symbol table lookup.
Change-Id: I4dc91c586b0c595a3e85d6da13b98fc2248fb8fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102120
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
The stack slot in question may contain a stale value, but it could
be scanned by GC, so the fix is to clean it up even if it looks
unused.
While debugging I saw bytecode PCs in that stack slot.
So it is likely that compact bytecode instructions (68de477535)
increased the probability of these crashes, as with compact bytecodes
PCs could be unaligned and treated as Dart objects by GC, while
previously PCs were always aligned and treated as Smis by GC,
effectively masking the failure.
Fixes https://github.com/dart-lang/sdk/issues/36909
Change-Id: I82ccaa2bd87aca4ca4b44c9db69b0efd18dad955
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102061
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
document.registerElement is going away soon, and dart2js never implemented window.customElements.define.
Replace the inheritance with composition for each FooElement.
When used to create a DOM tree, replace `new FooElement()` with `new FooElement().element`.
In CSS, replace each custom element selector with a class selector, i.e. `foo-element` with `.foo-element`.
Bug: https://github.com/dart-lang/sdk/issues/34107
Change-Id: Id5ab5b6104a6165a8ad3b01d73ee9d76e46024ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101061
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
While adding support for new compact bytecode instructions,
VM also keeps support for old bytecode instructions to preserve
backwards compatibility and allow soft transition.
This change is separate from bytecode generator changes in order
to test VM with old bytecode generator.
Corresponding bytecode generator changes:
https://dart-review.googlesource.com/c/sdk/+/99400
Change-Id: Icf5ceee7d51f27ffe3f79d0eae81e0ddc0a7e855
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101062
Reviewed-by: Ryan Macnak <rmacnak@google.com>