Commit Graph

2345 Commits

Author SHA1 Message Date
Alexander Markov a9abc64613 [vm/bytecode] Add context IDs to disambiguate accesses to distinct contexts
This CL adds context ID operand to AllocateContext, CloneContext,
LoadContextVar and StoreContextVar bytecode instructions.
The context ID will be used to create distinct Slots and disambiguate
accesses to context objects corresponding to different scopes.

Change-Id: I98850ab763017b71c1dcacfccaffc085bd850e00
Reviewed-on: https://dart-review.googlesource.com/c/84681
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-17 00:35:30 +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
Martin Kustermann aad435f45f [VM] Always bailout from constant evaluator if used on the background compiler
Change-Id: Ifa4e86e8e2e681509f63470e23af09f4ee66aced
Reviewed-on: https://dart-review.googlesource.com/c/84608
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-16 16:19:58 +00:00
Martin Kustermann 845310302d Revert "[VM] Add @pragma annotations on Field, make @pragma annotations work generally"
This reverts commit 2de63ac01c.

Reason for revert: This triggers shutdown deadlocks for some reason:

#0  0xf7782cd9 __kernel_vsyscall
#1  0xf7753d0b pthread_cond_wait@@GLIBC_2.3.2
#2  0x0108a515 dart::Monitor::WaitMicros(long long)
#3  0x0108a467 dart::Monitor::Wait(long long)
#4  0x00fe9048 dart::KernelIsolate::Shutdown()
#5  0x00f99ae4 dart::Dart::Cleanup()
#6  0x01278fce Dart_Cleanup
#7  0x00dd347e dart::bin::main(int, char**)
#8  0x00dd3d64 main
#9  0xf745caf3 __libc_start_main
#10 0x00dd2021 _start
TID 30443:
#0  0xf7782cd9 __kernel_vsyscall
#1  0xf7531ee6 epoll_wait
#2  0x00ddab61 dart::bin::EventHandlerImplementation::Poll(unsigned int)
#3  0x00dfb2d4 dart::bin::ThreadStart(void*)
#4  0xf774ff72 start_thread
#5  0xf753143e __clone
TID 30444:
#0  0xf7782cd9 __kernel_vsyscall
#1  0xf7753d0b pthread_cond_wait@@GLIBC_2.3.2
#2  0x0108a515 dart::Monitor::WaitMicros(long long)
#3  0x0108a467 dart::Monitor::Wait(long long)
#4  0x012484d8 dart::BackgroundCompiler::Run()
#5  0x01248a37 dart::BackgroundCompilerTask::Run()
#6  0x0112203a dart::ThreadPool::Worker::Loop()
#7  0x01121efe dart::ThreadPool::Worker::Main(unsigned int)
#8  0x01089e73 dart::ThreadStart(void*)
#9  0xf774ff72 start_thread
#10 0xf753143e __clone

Original change's description:
> [VM] Add @pragma annotations on Field, make @pragma annotations work generally
> 
> Currently the @pramga('vm:exact-result-type') annotation only works if
> the function is a recognized method.  This change changes that to make
> the VM just look if a function has the annotation (no matter if it's
> also in the list of recognized methods or not).
> 
> Furthermore this CL adds a "has_pragma" bit to [Field] objects, similar
> to how we have it on [Function]/[Class]es.  This allows annotating
> fields with types, as we do with function return types.
> 
> Furthermore this CL lets the type propgagator use
> @pragma('vm:exact-result-type') annotations to narrow the [CompileType]
> set on [LoadFieldInstr]s.
> 
> Since the @pragma is a general feature, this CL moves the
> `Function::FindPragma()` to `Library::FindPragma` (which is where any
> other metadata lookup happens).  We also let the `FindPragma` accept any
> of Class/Function/Field objects.
> 
> Furthermore this CL adds a bailout if we try to evaluate metadata in
> the background compiler, since the background compiler is not allowed
> to execute generated code. The bailout should trigger a re-compilation
> on the mutator thread.
> 
> Furthermore the `FindPragma()` function is fixed to handle the case
> when the evaluation of the metadata results in e.g. a language error.
> In this case we simply claim to not have found a pragma annotation.
> 
> Issue https://github.com/dart-lang/sdk/issues/31954
> 
> Change-Id: I0900a80d5ae0f3e8d09baf13cba1b20dd974df31
> Reviewed-on: https://dart-review.googlesource.com/c/84037
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

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

Change-Id: Ic0d22d32b0eea3a76ec245cabab0006f97ca1b05
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/84622
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-11-16 14:50:32 +00:00
Martin Kustermann 2de63ac01c [VM] Add @pragma annotations on Field, make @pragma annotations work generally
Currently the @pramga('vm:exact-result-type') annotation only works if
the function is a recognized method.  This change changes that to make
the VM just look if a function has the annotation (no matter if it's
also in the list of recognized methods or not).

Furthermore this CL adds a "has_pragma" bit to [Field] objects, similar
to how we have it on [Function]/[Class]es.  This allows annotating
fields with types, as we do with function return types.

Furthermore this CL lets the type propgagator use
@pragma('vm:exact-result-type') annotations to narrow the [CompileType]
set on [LoadFieldInstr]s.

Since the @pragma is a general feature, this CL moves the
`Function::FindPragma()` to `Library::FindPragma` (which is where any
other metadata lookup happens).  We also let the `FindPragma` accept any
of Class/Function/Field objects.

Furthermore this CL adds a bailout if we try to evaluate metadata in
the background compiler, since the background compiler is not allowed
to execute generated code. The bailout should trigger a re-compilation
on the mutator thread.

Furthermore the `FindPragma()` function is fixed to handle the case
when the evaluation of the metadata results in e.g. a language error.
In this case we simply claim to not have found a pragma annotation.

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

Change-Id: I0900a80d5ae0f3e8d09baf13cba1b20dd974df31
Reviewed-on: https://dart-review.googlesource.com/c/84037
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-16 11:18:22 +00:00
Régis Crelier 61eea1f416 [VM runtime] Remove unused UnresolvedClass VM class.
Type resolution will be simplified in a later CL.

Change-Id: Ia610a5d06d381511ca48993dcc1cafbf205ca997
Reviewed-on: https://dart-review.googlesource.com/c/84552
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-11-16 00:09:29 +00:00
Martin Kustermann 9e3d3cf765 [VM] Use strict compare instruction only if receiver is nullable int
Since in Dart 1 == 1.0 is true.

Change-Id: I05faebb31c6c725095a54020a9665cf40cc55a4b
Reviewed-on: https://dart-review.googlesource.com/c/84531
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-11-15 15:37:58 +00:00
Martin Kustermann 11af2a6406 [VM] Only use strict comparisons if the receiver has a numeric type
Change-Id: Ic8b13ac45fd9ac71fea96503226f74d52364b90c
Reviewed-on: https://dart-review.googlesource.com/c/84529
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-11-15 14:58:35 +00:00
Martin Kustermann a454b5d564 [VM] Use redefinitions for strenghtening, prefer equality comparison over strict comparison
When strenghtening the types in AOT call specializer, we do it via redefinitions
instead of setting a reachingt type on the Value.  This has the advantage that all
uses will get the new type, which improves e.g. StaticCall(_IntegerImpl.*, v1, v1)
where multiple uses can benefit.

This CL also changes the AOT call specializer to prefer equality comparisons over
strict comparisons, because strict comparisons can force boxing (which causes code bloat).

Change-Id: I803bb09c70ee2f4656062b5ce3cb28ffaf940e9b
Reviewed-on: https://dart-review.googlesource.com/c/84525
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-15 14:39:54 +00:00
Vyacheslav Egorov a1a38da58e [vm] Report an error when illegally accessing class through API in AOT mode.
Move all pragma documentation into runtime/docs and reformat it a bit.

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

Change-Id: I2ab4d6d598f115efaa3192135cb838fb85cbbb01
Reviewed-on: https://dart-review.googlesource.com/c/84435
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Auto-Submit: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-11-15 12:00:57 +00:00
Martin Kustermann aea0aadf41 [VM] Unify AOT optimizations for int/double's
So far we had different optimization logic for int/double's depending on
whether they were [InstanceCallInstr]s or [StaticCalInstr]s.

The de-virtualization by TFA causes instance calls to be turned into static
calls which might cause different optimizations to apply.

This CL unifies the optimizations, so they are applied regardless of
whether the operation is an instance call or a static call.

Change-Id: Id4f229412e4d0f19835635bce8c9e5491cca8cb0
Reviewed-on: https://dart-review.googlesource.com/c/84433
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-15 11:35:42 +00:00
Alexander Markov ed48cfeb47 [vm/bytecode] Support source positions when executing bytecode
This includes both interpreted and compiled bytecode.

Change-Id: I6309ec4f0687f68caf6260cc57dacf94f027177d
Reviewed-on: https://dart-review.googlesource.com/c/84481
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-15 00:48:04 +00:00
Aart Bik 4c683215fc [vm/compiler] induction variable analysis
Rationale:
The more one knows about loops, the better!
This introduces a rigorous framework for detecting
induction variables (more precise "sequence" variables).
Even though this is already pretty general, in the
future we can expand this on a "need to" base, recognizing
more operators (shifts, negate, etc.) and more classes
of induction (perhaps geometric, polynomial, etc.).

Change-Id: I82a14515e8ae946d520ee470cd31046f6a58af7d
Reviewed-on: https://dart-review.googlesource.com/c/81743
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-14 17:02:13 +00:00
Régis Crelier f721d52163 [VM runtime] Introduce a new VM class Bytecode.
Allow pc_marker slot to hold a Code object or a new Bytecode object.

Change-Id: If11c1df6dafc5b1cfcce6f0322c36d1d68e86df9
Reviewed-on: https://dart-review.googlesource.com/c/82526
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-11-14 02:48:03 +00:00
Alexander Markov 8f7a0f400b [vm/bytecode] Emit source positions for bytecode instructions
Change-Id: I83963771db301089317823f6bf14eb4a2728dbfb
Reviewed-on: https://dart-review.googlesource.com/c/81740
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-14 00:27:45 +00:00
Martin Kustermann 600af11045 [VM] When disassembling dump functions seperately from non-function Code
Change-Id: Ic7d7f9746c4f723d3da08b003a943b83b779dad3
Reviewed-on: https://dart-review.googlesource.com/c/84038
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-11-13 10:32:28 +00:00
Alexander Markov 3c32b32d56 [vm/bytecode] Enable OSR for unoptimized code compiled from bytecode
In order to enable OSR, CheckStackOverflow IL instructions are attributed
with a non-zero loop depth. The original loop depth is passed as operand
of CheckStack bytecode instruction.

Change-Id: I771f59ba9f8d071680a3b7156be380e0f606b7b2
Reviewed-on: https://dart-review.googlesource.com/c/84081
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-11-12 19:04:54 +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
Alexander Markov d74f272d78 [vm/bytecode] Enable optimized compilation if running with interpreter
Also, reset usage counter after unoptimized compilation in background
so that function can be optimized.

Change-Id: I7b0fff0bc800345237822b31b176691e8cd132eb
Reviewed-on: https://dart-review.googlesource.com/c/84044
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-09 19:42:47 +00:00
Alexander Markov 4b900fdcc5 [vm] Clarify timeline events for unoptimized background compilation, take 2
Change-Id: Iaeb9fb612e2060a59ba3963402e15ae97e27cb5f
Reviewed-on: https://dart-review.googlesource.com/c/84042
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-11-09 18:36:17 +00:00
Alexander Markov a4dc8cd22e [vm/kernel/bytecode] Make sure bytecode instructions are aligned in kernel
Change-Id: I109123e88b8352b198d5ef9aad9eedc1df7141c8
Reviewed-on: https://dart-review.googlesource.com/c/83543
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-11-09 17:08:46 +00:00
Martin Kustermann 27537b458a [VM] Ensure parameters from unchecked entrypoints have type attached
For functions without optional parameters this is done in the
ParameterInstr::ComputeType directly whereas for optional parameters,
where the prologue is not built 2 times, we use redefinitions.

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

Change-Id: Id6f86610ecbde090ca1596d6fabdf7f2a8bcd5e2
Reviewed-on: https://dart-review.googlesource.com/c/83020
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-09 16:40:21 +00:00
Alexander Markov f9d93f6d4e Revert "[vm] Clarify timeline events for unoptimized background compilation"
This reverts commit 136c013bea.

Reason for revert: broken dartkb bots

Original change's description:
> [vm] Clarify timeline events for unoptimized background compilation
> 
> Change-Id: I919ef5a5a180b47eba31e74d32da4185fff81df9
> Reviewed-on: https://dart-review.googlesource.com/c/83886
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Auto-Submit: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

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

Change-Id: Ifcdd8778f60c25e7b1363538e0f76064dde09556
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/83921
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-11-09 03:08:07 +00:00
Ryan Macnak fa6a1684ef [vm] Introduce a separate VMTag for the interpreter.
Makes time spent in interpreted versus compiled Dart code visible in Observatory's pie chart. Will allow the profiler to know whether to start a stack walk from the machine code FP or the interpreter's FP.

Remove dead Dart 1 frontend tags. Add tag for loading bytecode.

Change-Id: I2c5a580e1581f8ccd5a93bb293899c81f900ef13
Reviewed-on: https://dart-review.googlesource.com/c/83564
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-09 01:58:54 +00:00
Alexander Markov 136c013bea [vm] Clarify timeline events for unoptimized background compilation
Change-Id: I919ef5a5a180b47eba31e74d32da4185fff81df9
Reviewed-on: https://dart-review.googlesource.com/c/83886
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-11-09 01:38:02 +00:00
Aart Bik 8ca05c506f [vm/compiler] Whitelist byteswap inlining
Rationale:
Always inlining byteswaps avoids calling into
the runtime when getInts remain.

https://github.com/dart-lang/sdk/issues/34473
https://github.com/dart-lang/sdk/issues/34969
https://github.com/dart-lang/sdk/issues/32167

Change-Id: I95c0348fa960e08f973a12a2c5304785e76289b3
Reviewed-on: https://dart-review.googlesource.com/c/83884
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-11-08 23:18:53 +00:00
Aart Bik 3ee9f61c8d [vm/compiler] Fix bug in list inclusion test
Rationale:
Although not semantically disastrous, list inclusion
was not properly implemented, which yielded some very
hard to debug recompilations (or lack thereof) due
to speculation.

https://github.com/dart-lang/sdk/issues/34473
https://github.com/dart-lang/sdk/issues/34969
https://github.com/dart-lang/sdk/issues/32167

Change-Id: I54613127bd3ab93820d4a467c75e41f3df16ee7a
Reviewed-on: https://dart-review.googlesource.com/c/83883
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-11-08 23:18:13 +00:00
Aart Bik 9eb1d74881 Reland "[vm/compiler] Fine tune operator and phi handling."
This reverts commit cde479301a.

Reason for revert: the real underlying bug has been fixed

Original change's description:
> Revert "[vm/compiler] Fine tune operator and phi handling."
> 
> This reverts commit 4d5b5bb5a6.
> 
> Reason for revert: We are seeing an AOT compiler issue as a result of this change (please see https://github.com/flutter/flutter/issues/23879)
> 
> Original change's description:
> > [vm/compiler] Fine tune operator and phi handling.
> > 
> > Rationale:
> > Running an extra call specialization pass a bit later
> > in the compiler passes stream (after types are propagated)
> > recognizes more operators, which execute more efficiently.
> > In addition, unboxing phis seems useful on all archs, not
> > just 32-bit. These minor tweeks combined improve the prime
> > number benchmark 3 fold.
> > 
> > https://github.com/flutter/flutter/issues/19677
> > 
> > Change-Id: Ib2102ce807c2f0a9f801542e0c4bc6a7673f552b
> > Reviewed-on: https://dart-review.googlesource.com/69240
> > Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> > Commit-Queue: Aart Bik <ajcbik@google.com>
> 
> TBR=vegorov@google.com,alexmarkov@google.com,asiva@google.com,ajcbik@google.com
> 
> # Not skipping CQ checks because original CL landed > 1 day ago.
> 
> Change-Id: I46e420f9355bfc3c4a3f2fb9274f648e8a596d9a
> Reviewed-on: https://dart-review.googlesource.com/c/83229
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Aart Bik <ajcbik@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

TBR=vegorov@google.com,alexmarkov@google.com,asiva@google.com,ajcbik@google.com

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

Change-Id: I7f9d892a6225c42810e7be52b6845bfee9cc017d
Reviewed-on: https://dart-review.googlesource.com/c/83800
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-11-08 20:58:16 +00:00
Aart Bik a40fd6a976 [vm/compiler] Fix bug in unboxed constant spilling
Rationale:
Subtle but disastrous, spilling unboxed integers
in arm64 and x64 would store the value as smi,
detected as a nasty off by one error in flutter code.

https://github.com/flutter/flutter/issues/23879
https://github.com/dart-lang/sdk/issues/35091

Change-Id: I07d71727de8574ebd7d3ec3610d517d7903972f0
Reviewed-on: https://dart-review.googlesource.com/c/83565
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-11-08 19:03:22 +00:00
Aart Bik 5cfffdbcca Revert "[vm/compiler] Tune AOT inline heuristics"
This reverts commit 74d2c6aa99.

Reason for revert: 

../../runtime/vm/compiler/backend/il.cc: 778: error: unreachable code

Original change's description:
> [vm/compiler] Tune AOT inline heuristics
> 
> Rationale:
> Last experiment left some performance at the table
> (but for an unacceptable 200% code size increase).
> This CL regains that performance for a much better
> trade-off of just 8%. Performance gains vary from
> 10% to 100%, with e.g. 27% for DeltaBlue, 30% for
> MD5 and 100% for SHA256). This is obtained by
> always inlining byteswaps (to avoid calling into
> the runtime when getInts remain) and a bit more
> specific tuning of loop based heuristics. This
> also fixes a bug in a list lookup.
> 
> https://github.com/dart-lang/sdk/issues/34473
> https://github.com/dart-lang/sdk/issues/34969
> https://github.com/dart-lang/sdk/issues/32167
> 
> Change-Id: Id1a64c3930c503546ae2d7f31ca3e597741022bb
> Reviewed-on: https://dart-review.googlesource.com/c/82942
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Aart Bik <ajcbik@google.com>

TBR=vegorov@google.com,kustermann@google.com,rmacnak@google.com,alexmarkov@google.com,ajcbik@google.com

Change-Id: Id0f30f4458a3548af2e573a737e441ca11ae3b11
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/83643
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-11-08 08:51:20 +00:00
Ryan Macnak 30b0b9b723 [vm] Code size reductions:
- Remove dead Isolate::IsTopLevelParsing.
 - Remove dead TraceFunctionEntry/Exit.
 - Migrate more tracing flags to flag_list.h to allow code elimination in non-debug modes.
 - Require an explicit Zone parameter for CheckedHandles.
 - Remove side-effects from RuntimeEntry constructor.

out/ProductX64/exe.stripped/dart_precompiled_runtime 4063464 -> 4046952 (-16k)

Change-Id: Iffd3de25a03d2354cdecf2d79aa761c33ab08bd3
Reviewed-on: https://dart-review.googlesource.com/c/83120
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-11-08 02:02:39 +00:00
Aart Bik 74d2c6aa99 [vm/compiler] Tune AOT inline heuristics
Rationale:
Last experiment left some performance at the table
(but for an unacceptable 200% code size increase).
This CL regains that performance for a much better
trade-off of just 8%. Performance gains vary from
10% to 100%, with e.g. 27% for DeltaBlue, 30% for
MD5 and 100% for SHA256). This is obtained by
always inlining byteswaps (to avoid calling into
the runtime when getInts remain) and a bit more
specific tuning of loop based heuristics. This
also fixes a bug in a list lookup.

https://github.com/dart-lang/sdk/issues/34473
https://github.com/dart-lang/sdk/issues/34969
https://github.com/dart-lang/sdk/issues/32167

Change-Id: Id1a64c3930c503546ae2d7f31ca3e597741022bb
Reviewed-on: https://dart-review.googlesource.com/c/82942
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-11-08 01:04:55 +00:00
Siva Annamalai cde479301a Revert "[vm/compiler] Fine tune operator and phi handling."
This reverts commit 4d5b5bb5a6.

Reason for revert: We are seeing an AOT compiler issue as a result of this change (please see https://github.com/flutter/flutter/issues/23879)

Original change's description:
> [vm/compiler] Fine tune operator and phi handling.
> 
> Rationale:
> Running an extra call specialization pass a bit later
> in the compiler passes stream (after types are propagated)
> recognizes more operators, which execute more efficiently.
> In addition, unboxing phis seems useful on all archs, not
> just 32-bit. These minor tweeks combined improve the prime
> number benchmark 3 fold.
> 
> https://github.com/flutter/flutter/issues/19677
> 
> Change-Id: Ib2102ce807c2f0a9f801542e0c4bc6a7673f552b
> Reviewed-on: https://dart-review.googlesource.com/69240
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> Commit-Queue: Aart Bik <ajcbik@google.com>

TBR=vegorov@google.com,alexmarkov@google.com,asiva@google.com,ajcbik@google.com

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

Change-Id: I46e420f9355bfc3c4a3f2fb9274f648e8a596d9a
Reviewed-on: https://dart-review.googlesource.com/c/83229
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2018-11-07 01:09:52 +00:00
Martin Kustermann 0fd14324c5 [VM] Use "null" object pool instead of nullptr for empty pools
Fixes https://github.com/dart-lang/sdk/issues/35054

Change-Id: I5b852701e1e70d5ab1345625296752208ed06ce7
Reviewed-on: https://dart-review.googlesource.com/c/82983
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-11-06 11:38:33 +00:00
Martin Kustermann cd98dd72f6 [VM] Make all stubs inside the VM isolate share the same pool
Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: I556272952e6d7846721c6d48ef0ffbae5891cfde
Reviewed-on: https://dart-review.googlesource.com/c/82587
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-06 10:01:03 +00:00
Ryan Macnak 04941b5507 [vm, gc] For large arrays (arrays on a large heap page), use a card-based remembered set.
Bug: https://github.com/dart-lang/sdk/issues/30433
Change-Id: I7c710d9e36ab593295d00fc5e9e72a86a1b843af
Reviewed-on: https://dart-review.googlesource.com/c/63688
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-05 22:03:34 +00:00
Régis Crelier 27127b364a [DBC simulator] Rename class Bytecode to SimulatorBytecode.
This frees the name Bytecode that will become the name of a new VM class.
Class Code will only refer to compiled code and Bytecode will refer to kernel
bytecode.

Change-Id: If64a5d688f0bf75220e67ef2932f4141782e9dc3
Reviewed-on: https://dart-review.googlesource.com/c/82703
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-11-02 20:53:24 +00:00
Martin Kustermann d9d15ee1fc [VM] Do not trace const functions seperately in AOT compilations, we use kernel2kernel constant evaluation
Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: I3474ceaca807a03cb3813e97fa47c3e43e495e24
Reviewed-on: https://dart-review.googlesource.com/c/82600
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-11-02 13:42:35 +00:00
Martin Kustermann a01513c685 [VM] Allow including disassembler in product mode if FORCE_INCLUDE_DISASSEMBLER is defined
This helps VM developers working with product mode.

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

Change-Id: I1933dea6f2d88c4745c63be772cfe301259f4a9c
Reviewed-on: https://dart-review.googlesource.com/c/82583
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-11-02 13:02:25 +00:00
Zach Anderson c4df463ba9 [vm] Reland kernel data library and class caches.
This is the same code as the previous commit, but it needs a fix
for issue #34953 to land first.

Change-Id: Id586f5e8a5ee498716e58ff44bb8a344822f73df
Reviewed-on: https://dart-review.googlesource.com/c/81840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-11-01 20:25:59 +00:00
Ryan Macnak a651838652 [vm] Fix misc printf format bugs.
Bug: https://github.com/dart-lang/sdk/issues/35009
Change-Id: I6b509e1eb8e76e07f60a086c67358d65d2a1fae4
Reviewed-on: https://dart-review.googlesource.com/c/82460
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-11-01 16:37:22 +00:00
Ryan Macnak 97940e77a4 [vm, compiler] Remove use of StoreIntoObject for arrays from hand-written assembly.
- Convert _List.[]= and _List._setIndexed to graph intrinsics.
 - Remove _GrowableList.add intrinsics (dead since Dart 2).

Eliminates need to shuffle registers at the assembler level when introducing card-remembering.

Change-Id: Ia94ae3229a5eb90215ac74ab624db843a0cda01c
Reviewed-on: https://dart-review.googlesource.com/c/82380
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-11-01 16:30:28 +00:00
Martin Kustermann b0b7cdb3da [VM] Add ArrayView class to access [Array]s which are treated as lists of tuples in a type-safe way
Change-Id: I0c356ba01bf3fc362d6e353285ddda7c21d56de4
Reviewed-on: https://dart-review.googlesource.com/c/81823
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-01 15:09:49 +00:00
Martin Kustermann 9b9a035154 [VM] Add PcRelativeCall / PcRelativeJump patterns & assembler support
Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: I0297c4bb502a1af28e3cf16646eade49f4cd0676
Reviewed-on: https://dart-review.googlesource.com/c/81827
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-01 12:34:42 +00:00
Martin Kustermann 29396606c8 [VM] Allow Code::object_pool() to be 'null', refactor some code in precompiler.cc
This is preparation work for a global object pool, which will not be attached
to the Code objects.

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

Change-Id: Ia1746ea657fe6d8e9adb7552d6835425ff65542c
Reviewed-on: https://dart-review.googlesource.com/c/82064
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-11-01 11:59:44 +00:00
Ryan Macnak fa4fdcefb0 [vm, gc] Enable concurrent marking on Android/iOS.
On a Flutter app scrolling through a large table running on a Moto G 4, max pause time reduces from 129ms to 52ms.
Before
   6-44ms CollectNewGeneration
118-129ms CollectOldGeneration
After
   6-52ms CollectNewGeneration
   3-10ms StartConcurrentMarking
  20-42ms CollectOldGeneration (i.e., finalize marking)

Code size increases on Flutter Gallery:
ARM32 Instructions(CodeSize): 5772688 -> 5968624 (+3.39%)
ARM64 Instructions(CodeSize): 6082400 -> 6251008 (+2.77%)

Bug: https://github.com/dart-lang/sdk/issues/34002
Change-Id: Iac9a0b3d91b497b5016c4f89e8779c488f105a5b
Reviewed-on: https://dart-review.googlesource.com/c/76780
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-10-31 20:34:25 +00:00
Ryan Macnak 7514ce941e [vm] Assert handles are only allocated when the thread is preventing safepoints.
Threads in the native or blocked states don't prevent safepoints, so they may run concurrently with a safepoint operation like GC. It is not safe for handles to be allocated while the GC is visiting them, so these threads must not allocate handles. Assert only threads in the VM or generated states, which prevent safepoints until they check in, may allocate handles. (Generated code does not allocate handles, but leaf runtime entries remain in the generated state.)

Bug: https://github.com/dart-lang/sdk/issues/34883
Change-Id: I1a211778f7ef96b53a2405f0ee9dde7871b122b6
Reviewed-on: https://dart-review.googlesource.com/c/81540
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-10-31 19:51:52 +00:00
Régis Crelier 98a0309fbd [VM compiler] Reuse function type arguments to avoid instantiation at runtime, when possible.
Change-Id: Icfcbd165bb96cf83b7911c6c11a7daca17c6ba12
Reviewed-on: https://dart-review.googlesource.com/c/81701
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-10-30 18:38:37 +00:00
Martin Kustermann 70abec503d [VM] Reland "[VM] Extract common code from Assembler to new AssemblerBase base class"
This reverts commit 04381d7571.

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

Change-Id: I843c3fe4cc8265fb43b6b09623e7509837a878f0
Reviewed-on: https://dart-review.googlesource.com/c/82041
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-10-30 12:00:22 +00:00
Alexander Aprelev 04381d7571 Revert "[VM] Extract common code from Assembler to new AssemblerBase base class"
This reverts commit 388c41de94 as it
breaks appjit_determinism_test on arm.

Bug: dartbug.com/34973
Change-Id: I25e995d3c4c8a77f2f3b681ed717adc4f723d86c
Reviewed-on: https://dart-review.googlesource.com/c/82000
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2018-10-29 23:08:34 +00:00