Commit Graph

205 Commits

Author SHA1 Message Date
asiva 30aa464f77 [VM] Remove 'corelib' and 'dart-io' sources generation into C++ arrays
- Remove all code that generates the corelib and dart:io library sources into C++ arrays and link them into dart_bootstrap
- Remove the executable dart_bootstrap and all uses of it
- Remove bootstrap_nolib.cc and builtin_nocore.cc
- Remove the Dart 1 code in core lib bootstrap path

Change-Id: Ifd33496204285a08b42fe09e39428e7a92b416b6
Reviewed-on: https://dart-review.googlesource.com/c/77241
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-10-02 23:27:05 +00:00
asiva c9f5c3a79e [VM] Delete access to Dart 1 parser.
- delete access to Dart 1 parser
- Skip codegen unit tests as they use the Dart 1 parser

Change-Id: I24f3986fac9c496e231c723c6eaa0704e6a616f5
Reviewed-on: https://dart-review.googlesource.com/77009
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-09-27 23:08:20 +00:00
Ryan Macnak 94481adbd4 [vm] Only include debugger/profiler slots in RawCode in product mode.
Saves 5 words per Code in product mode JIT.

Change-Id: I799a9c3bc1f4492d329c588ba1ea98f5b8baa304
Reviewed-on: https://dart-review.googlesource.com/75421
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-09-25 01:30:53 +00:00
Zach Anderson dba8b37d38 [vm] Benchmark for reading kernel bytecode
Change-Id: I07617a553193495fcc4fc0ce4a6382996ee7dc51
Reviewed-on: https://dart-review.googlesource.com/75821
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-09-24 15:54:49 +00:00
Alexander Markov 654c4babc8 [vm/bytecode] Fix a couple of assertions when running with bytecode
Also, add more tests to dartkb bots.

Change-Id: I6fbcbe73d6b9065ec03e64bf150b4ebd742e4d28
Reviewed-on: https://dart-review.googlesource.com/75981
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-09-21 22:54:39 +00:00
Alexander Markov 46ec629096 [vm/bytecode] Trigger JIT-compilation from interpreter
Performance on Richards benchmark (no bytecode in platform, release build):

Interpreter (--enable-interpreter --compilation-counter-threshold=-1)
Richards(RunTime): 177228.34433333334 us.

Interpreter + bytecode compilation with default threshold 10 (--enable-interpreter)
Richards(RunTime): 930.8050725919032 us.
Varies from run to run, spikes up to 4178.005912317328 (no OSR yet, only background compilation).

Bytecode compilation (--use-bytecode-compiler)
Richards(RunTime): 830.1371626556016 us

Default pipeline:
Richards(RunTime): 880.1557113946327 us.

Numbers on Richards benchmark (platform with bytecode, release build):

Interpreter (--enable-interpreter --compilation-counter-threshold=-1)
Richards(RunTime): 354553.6346666667 us.

Interpreter + compilation with default threshold 10 (--enable-interpreter)
Richards(RunTime): 934.7108855140189 us.

Bytecode compilation (--use-bytecode-compiler)
Richards(RunTime): 822.74178403949 us.


Change-Id: Ic13e9f7c7d98f2930e6de4c4f74bac4d28478249
Reviewed-on: https://dart-review.googlesource.com/75781
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-09-20 20:57:08 +00:00
Alexander Markov 3263550e86 [vm] Decouple bytecode reading from compilation
This way requests to compile won't end prematurely after reading
bytecode if interpreter is enabled.

Change-Id: Ic06cae98ea65bc4656ef491fbd306d34b0e1ef4c
Reviewed-on: https://dart-review.googlesource.com/75628
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-09-20 16:22:33 +00:00
Alexander Markov c6c4748185 [vm/bytecode] Bytecode compilation
Change-Id: I09192e4e929a397920c217b605580f8c4880e7c2
Reviewed-on: https://dart-review.googlesource.com/74002
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-09-14 22:02:29 +00:00
Vyacheslav Egorov 229d793602 [vm/compiler] Support materializing unboxed variables when entering catch.
Previously we tried to rely on the assumption that all variables would be
boxed - so the machinery for setting correct catch-entry state only
supported tagged values and constants. However this both leads to worse code
and is not entirely correct assumption.

This also:

- renames various confusingly named classes: we move away from talking
about "catch entry state" to "catch entry moves" - because we only
record a subset of moves that needs to be performed and that does
not describe the whole state;
- refactors a bunch of associated code to be more readable and maintainable;
- adds documentation about catch implementation in optimized code
to runtime/docs/compiler;

Fixes https://github.com/flutter/flutter/issues/21685.

Change-Id: I03ae361a1bb7710acbd9f661ae014e663a163c59
Reviewed-on: https://dart-review.googlesource.com/74860
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-09-14 17:39:12 +00:00
Régis Crelier a2fae0125f [VM interpreter] Mark activation frames as interpreted instead of crashing.
This is a first step in supporting bytecode in the debugger.

Change-Id: Ieb06b8b534fcc7f0291457cd6912d772b8ee247a
Reviewed-on: https://dart-review.googlesource.com/74012
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-09-12 00:33:30 +00:00
Zach Anderson b4004f6476 [vm] Reland: Move the interpreter under a flag.
After this CL, the interpreter is included by default in the
JIT VM under the flag --enable-interpreter.

Reland with fix to NativeArgument setup in simulator_arm.cc

Change-Id: Ib9b4df6eb4d997dfbe361188b8a127828c1d9c6f
Reviewed-on: https://dart-review.googlesource.com/74003
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-09-07 19:25:31 +00:00
Zach Anderson 21406f576a Revert "[vm] Move the interpreter under a flag."
This reverts commit 715ab7b30b.

Reason for revert: simarm and kernel precomp builds failing

Original change's description:
> [vm] Move the interpreter under a flag.
> 
> After this CL, the interpreter is included by default in the
> JIT VM under the flag --enable-interpreter.
> 
> Change-Id: I06458f20288d67981822788ee6e867c2127ebdd3
> Reviewed-on: https://dart-review.googlesource.com/71800
> Commit-Queue: Zach Anderson <zra@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Régis Crelier <regis@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

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

Change-Id: I3622f4dbe53288d07fc21b34ee5ff68f2682b36d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/74001
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-09-07 17:14:21 +00:00
Zach Anderson 715ab7b30b [vm] Move the interpreter under a flag.
After this CL, the interpreter is included by default in the
JIT VM under the flag --enable-interpreter.

Change-Id: I06458f20288d67981822788ee6e867c2127ebdd3
Reviewed-on: https://dart-review.googlesource.com/71800
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-09-07 16:46:07 +00:00
Ryan Macnak 1d4c316d55 [vm, gc] Don't eagerly evacuate new space on old allocation failure, take 2.
Large allocations and direct old space allocations are not signals that the current new space objects will be long lived.

Still perform a scavenge to handle (dead new -> dead old) references even when new space allocation is low, but a non-evacuating scavenge.

Change-Id: I4008fb163c4536abfc7ba42410ec57917a69786a
Reviewed-on: https://dart-review.googlesource.com/72340
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-09-04 22:51:07 +00:00
Vyacheslav Egorov 7558644bd6 [vm/compiler] Move compiler state (CHA, deopt id) from Thread to a special class
Also move deopt id computation logic into a separate class and add a comment
explaining while deopt ids are incremented by 2.

Change-Id: Ife489be7d10c7198a8e7adf9e97e0c516d78ea55
Reviewed-on: https://dart-review.googlesource.com/72685
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-09-03 16:01:24 +00:00
Vyacheslav Egorov 52cacc6ef5 [vm/compiler] Use exactness when converting instance call to unchecked static call
JitCallSpecializer::VisitInstanceCall has two places where it converts
instance call into a static call. Previously we only made use of
exactness information in one of those places.

On dart2js compiling dart2js this change reduces number of times
we enter Map.putIfAbsent through checked entry point from
1107368 to 8640.

Bug: https://github.com/dart-lang/sdk/issues/31798
Change-Id: Id1665b998ecdf4c4d46cb7605a11bdde2e8c9782
Reviewed-on: https://dart-review.googlesource.com/72220
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2018-08-30 20:30:52 +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
Vyacheslav Egorov 80615aed27 [vm] Implement static type exactness tracking for method receivers.
Change-Id: I35ffcee7dfa741d2095b711d402a6caae388b2c4
Reviewed-on: https://dart-review.googlesource.com/68943
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-08-29 10:11:17 +00:00
Régis Crelier 11d986a03e [VM runtime] Introduce a DeoptIdScope class to safely save/restore deoptid.
Change-Id: I5debdd2accd9735ddabd3862165f3d04824b8247
Reviewed-on: https://dart-review.googlesource.com/71740
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-08-28 18:38:27 +00:00
Régis Crelier 4b8d3e4cf1 [VM runtime] Restore global isolate state after loading bytecode.
This caused deopt_ids to be wrongly reused when mixing
jitted and interpreted code.

Change-Id: I23eb93bb79d7297f8d9efdd81844394fee3fb821
Reviewed-on: https://dart-review.googlesource.com/71703
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-08-27 23:24:40 +00:00
Régis Crelier 3d74bb0980 [VM runtime] Fix Compiler::CompileAllFunctions() to work with interpreter.
Change-Id: Icd82beb21f7d5f22d9422bd730774e859e025694
Reviewed-on: https://dart-review.googlesource.com/71365
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-08-23 21:40:37 +00:00
Martin Kustermann cbf1b94790 [VM] Do not include precompiler-related things on IA32/DBC
Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: Ic27c89f1cffbad6c58ab3758f455d24863d9d675
Reviewed-on: https://dart-review.googlesource.com/71168
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-08-23 11:54:58 +00:00
Martin Kustermann df2d187f74 [VM] Move the ObjectPoolWrapper out of the Assembler
Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: I2e295a357939bc7c966c0658c344fcc4268669c1
Reviewed-on: https://dart-review.googlesource.com/71166
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-08-23 08:00:15 +00:00
Samir Jindel d8a4a3896a [vm] Multiple entrypoints: backend/assembler support.
Test Plan:

Will be tested by following revisions which introduce optimizations that invoke the
new entrypoint.

Change-Id: I56d714bceb92c44a13c46d52457154b82577aa8c
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-release-x64-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/67345
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-08-16 17:15:32 +00:00
Alexander Markov ff0327be67 [vm] Streamline passing of ICData through compilation pipeline
After this change, ICData map is always unpacked in CompileParsedFunctionHelper::Compile
regardless of the optimizing mode. The unpacked ICData array is passed
both to FlowGraphBuilder and to FlowGraphCompiler.

FlowGraphCompiler::FlowGraphCompiler no longer unpacks ICData array, and
the duplicated code for unpacking of ICData map is replaced with debug asserts.
Change-Id: Ib6864acdb6bcd02fe7acd1cb5bcf70d6c69808af
Reviewed-on: https://dart-review.googlesource.com/67505
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-08-02 00:00:59 +00:00
Aart Bik ac73b8e198 [vm/compiler] Improved type analysis for check class.
Rationale:
Improves the analysis if instance calls need checks
(check class or check null) combined with CHA.

History: revert^2 of original
https://dart-review.googlesource.com/c/sdk/+/65220
https://dart-review.googlesource.com/c/sdk/+/64440

Bug: https://github.com/dart-lang/sdk/issues/33664
Change-Id: I21ea857b68ba136d2bd4c9714ab557401ae7c7b8
Reviewed-on: https://dart-review.googlesource.com/66023
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-07-20 23:26:45 +00:00
Aart Bik a3ec4fec1d [vm/compiler] Bug fix on background to foreground passing.
Rationale:
Fixes a bug when JIT compiler sets is_background_optimizable
to false on a function to ensure it is no longer compiled on
the background but on the foreground. Before background
thread would directly put it back on its own queue which,
in some cases, could cause a compilation retry storm.

The new code correctly removes it from the queue so
that, with the higher usage count, the foreground thread
will soon pick it up.


https://github.com/dart-lang/sdk/issues/33664

Change-Id: I6e6041f571c2b32b13911c3b46b8688625d0834e
Reviewed-on: https://dart-review.googlesource.com/66000
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-07-20 21:29:06 +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
Alexander Markov 8245707b4c [vm] Refactoring: remove misuses of StreamingFlowGraphBuilder
In certain cases StreamingFlowGraphBuilder was used not for building
flow graph, but as an advanced kernel reader. This CL extracts all such
functionality from StreamingFlowGraphBuilder and revises all such uses.

StreamingFlowGraphBuilder constructors without FlowGraphBuilder are
removed. After this CL StreamingFlowGraphBuilder is only used to build
flow graph, as intended.

Change-Id: I69b08e24d37f8f2f336bee85334af11be1639b24
Reviewed-on: https://dart-review.googlesource.com/64821
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-17 16:36:50 +00:00
Aart Bik 8ed9345ccd Revert "[vm/compiler] Improved type analysis for check class."
This reverts commit 5333dd7f0f.

Reason for revert:

vm-kernel-optcounter-threshold-linux-release-x64
started to timeout on buildbot, see:

https://github.com/dart-lang/sdk/issues/33870

Original change's description:
> [vm/compiler] Improved type analysis for check class.
> 
> Rationale:
> Improves the analysis if instance calls need checks
> (check class or check null) combined with CHA.
> 
> Bug: https://github.com/dart-lang/sdk/issues/33664
> 
> 
> Change-Id: I0a4761f8816bf5a5aaf5d17ca56d8bf4e3b79fc3
> Reviewed-on: https://dart-review.googlesource.com/64440
> Commit-Queue: Aart Bik <ajcbik@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@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.

Bug: https://github.com/dart-lang/sdk/issues/33664
Change-Id: Iac1e630e55ffbbb0b635c28bbfd5211c2ae6751d
Reviewed-on: https://dart-review.googlesource.com/65220
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-07-16 22:58:53 +00:00
Aart Bik 5333dd7f0f [vm/compiler] Improved type analysis for check class.
Rationale:
Improves the analysis if instance calls need checks
(check class or check null) combined with CHA.

Bug: https://github.com/dart-lang/sdk/issues/33664


Change-Id: I0a4761f8816bf5a5aaf5d17ca56d8bf4e3b79fc3
Reviewed-on: https://dart-review.googlesource.com/64440
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-07-15 03:51:36 +00:00
Alexander Markov f39eaf937c [vm] Refactoring: remove dependency of StreamingScopeBuilder on StreamingFlowGraphBuilder
StreamingScopeBuilder does not build a flow graph, but it was creating
and using StreamingFlowGraphBuilder under the hood (in order to read kernel).

This change makes StreamingScopeBuilder independent of StreamingFlowGraphBuilder
and prepares StreamingScopeBuilder to be moved out of kernel_binary_flowgraph.

Also, several unused classes, fields and parameters are removed.

Change-Id: I40ff983caf0e548529b3c52f44dcb785bd4e9f40
Reviewed-on: https://dart-review.googlesource.com/63305
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-07-03 21:04:06 +00:00
Régis Crelier 008aa729c5 [VM interpreter] Support implicit getters and setters without compiling them.
Change-Id: I1e61cd79f66efe55c963d970e27f81a9d4084600
Reviewed-on: https://dart-review.googlesource.com/61860
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-06-26 20:24:38 +00:00
Ryan Macnak 9b5a931b06 [vm] Replace most runtime/vm uses of OS::Print with OS::PrintErr.
Leave --print-snapshot-sizes on stdout because it is parsed by Flutter benchmarks.

Replace all runtime/bin uses of OS::Print with Log::Print.

Bug: https://github.com/dart-lang/sdk/issues/32134
Change-Id: I74aacfb410cdfa9270d06e7f6ab0534520c7c7ba
Reviewed-on: https://dart-review.googlesource.com/60021
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-06-13 19:51:40 +00:00
Martin Kustermann 45c524e106 [VM] Mark functions on BG compiler bailouts specially, allow them to be re-optimized on main thread
In some cases, bailouts in the bg compiler, e.g. caused by class
finalization, mark functions as unoptimizable, which can significantly
slow down an application.

Instead of doing this, we mark these functions as non-optimizable on the
BG compiler and trigger re-compilations on the main thread.

Change-Id: Ifbb6aa7972818be8fa1313427e38d8b5576053e3
Reviewed-on: https://dart-review.googlesource.com/54886
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-05-15 09:34:22 +00:00
Régis Crelier 41fcbd097c [VM runtime] Initial version of Kernel Bytecode interpreter in VM runtime.
Not fully working yet, only x64, no gc, no frame walking, etc...

Change-Id: I4d8357f6d46371bf21c3d54266cfe26163e3c8dc
Reviewed-on: https://dart-review.googlesource.com/50021
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-05-09 20:29:27 +00:00
Vyacheslav Egorov 4fb15fcbf2 [vm/compiler] Consolidate compiler passes and share them between JIT and AOT.
Passes bodies are moved into compiler_pass{.cc,.h}.

Invoking a pass is just INVOKE_PASS(Name) now, instead of putting a bunch of
if-s and calls in compiler.cc or precompiler.cc.

We also consolidate ability to print IL and enable-disable passes under a
single flag --compiler-passes, e.g.

--compiler-passes=-Inlining,-CSE    disable inlining and CSE passes

--compiler-passes=Inlining+         print IL after Inlining pass and all
                                    subsequent passes

Change-Id: I90ff54b04a54f20099f5bf38dd45b16b8e3c4781
Reviewed-on: https://dart-review.googlesource.com/43968
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-03-01 16:43:58 +00:00
Ryan Macnak 6ae272becf [vm] Make --compile_all retain the compiled code.
Change-Id: I5595c5855d638b5ed144e3591348ddb9080f9e81
Reviewed-on: https://dart-review.googlesource.com/42886
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-02-22 22:56:01 +00:00
Martin Kustermann 3347b700df [VM] Add support for skipping a prologue range of blocks (for inlining heuristics)
Issue https://github.com/dart-lang/sdk/issues/31495

Change-Id: I876f4e064cfd21f5c3e99b531ff69776eba99635
Reviewed-on: https://dart-review.googlesource.com/25060
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-01 00:03:56 +00:00
Ryan Macnak 9174a627f5 [vm, gc] Ensure BackgroundCompiler can't be deleted during a safepoint.
Previously, the background compiler was deleted by the thread pool, which could have raced ahead of the mutator clearing its reference. Now it is deleted by the mutator.

Change-Id: Id353a96022f699131ee60fe31156cd0404dfd285
Reviewed-on: https://dart-review.googlesource.com/24342
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2017-11-30 22:59:51 +00:00
Martin Kustermann ada5985e04 [VM] Move removal of unnecessary CheckStackOverflowInstr in leaf functions
Issue https://github.com/dart-lang/sdk/issues/31495

Change-Id: I0c07cdae00152fc6e2dce10e48b8ba99356e2751
Reviewed-on: https://dart-review.googlesource.com/24780
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-30 14:31:55 +00:00
Ryan Macnak d366f9619a [vm] Toward deterministic builds.
- Remove random build-id.
 - Replace build time in embedded version string with commit time.
 - Remove timestamps from Observatory tarball.
 - Zero-initialize skipped bytes in snapshot streams.
 - Fix uninitialized fields in PatchClass, Script and Library.
 - Disable (under flag) random identity hashes and concurrent GC.

Bug: https://github.com/dart-lang/sdk/issues/31427
Change-Id: I3e95de679c8372841cd27ca60df78d9b00ffbfe1
Reviewed-on: https://dart-review.googlesource.com/22901
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2017-11-23 00:07:56 +00:00
Ryan Macnak 074b43c863 [vm] Don't let the optimizer mislead coverage data.
Coverage uses the value of an execution counter to detect executed functions. However non-positive execution counter does not necessary mean that a function was never executed because we sometimes reset the counter.

Introduce additional bit on a function that is set whenever we reset positive execution counter and use this bit when generating coverage data.

Bug: https://github.com/dart-lang/sdk/issues/31326
Change-Id: I5357109603defad7e7c9415c433203f16bcf88f4
Reviewed-on: https://dart-review.googlesource.com/19760
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-10 22:35:48 +00:00
Martin Kustermann 239f45b5ca [VM] Combine use_speculative_inlining/inlining_blacklist into SpeculativeInliningPolicy
Change-Id: I20a1354842d825ed1df0a19de57405a6d4041bd8
Reviewed-on: https://dart-review.googlesource.com/17444
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-01 11:06:00 +00:00
Siva Chandra 9f0175059e Load class members lazily when loading from kernel.
This change brings down core snapshot size by ~750KB, and brings
down app-jit snapshot size of simple "Hello, World" dart script by
~650KB. The bot cycle times will also come down by around ~20%.

Change-Id: I2a01c98bedc7ebfa2a653983995486a71504daf3
Reviewed-on: https://dart-review.googlesource.com/16323
Commit-Queue: Siva Chandra <sivachandra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2017-10-31 19:19:25 +00:00
Vyacheslav Egorov 2c97d724df [VM, JIT] Lower CloneContext into AllocateUninitializedContext.
CloneContext is implemented as a runtime call so it is considerably slower
than AllocateContext which leads to performance issues in loops that capture
iteration variables in for loops.

Lowering CloneContext into AllocateUninitializedContext and a sequence of
explicit load&store instructions both improves the performance by avoiding
the runtime call and also makes CloneContext semantics exposed to store-load
forwarding and allocation sinking.

PutIfAbsent benchmark from issue #31113 is improved by 5x, while 
ForInGeneratedLoop benchmark is improved by 8x.

Bug: https://github.com/dart-lang/sdk/issues/31113
Change-Id: I03fdede75f1a85fda92487aa8f9307ce06f23903
Reviewed-on: https://dart-review.googlesource.com/16280
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2017-10-25 11:09:29 +00:00
Jens Johansen 54f44f2a18 [kernel] Assert not optimizing when running constant evaluator.
Previously we could hit an assert when for instance "42 ~/ 0"
was being optimized by the background compiler. The reason was
that we assert that we're on the "mutator thread" when allocating
memory (which is done as we're evaluating the code - and we're
trying to evaluate it again because evaluating it gives an error,
and errors aren't cached).

However, to create a test for this it would be better if we could
make it always crash, i.e. use something like
```
--optimization_counter_threshold=5 --no-background-compilation
```
to force an optimization, but still make it crash dispite the
optimization happening in mutator thread (because of
--no-background-compilation).

This CL propagates if we're optimizing to the kernel builder,
and in the constant builder further more asserts that we're not.

Additionally it introduces a test that shows the crash and fixes it.

Change-Id: Ic5412ec8b8a1dbc2ba323f0a02a51103a32fab5c
Reviewed-on: https://dart-review.googlesource.com/11380
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-10-05 11:48:10 +00:00
Erik Corry 0beaa66339 [VM-compiler] Don't inline if we don't have inlining budget
When deciding whether to inline a function that has already been optimized
once, take a look at how many levels of inlining took place when it was
optimized stand-alone. If we don't have that much depth budget left, don't
inline.  This is an attempt to avoid the situation where we inline a function
that was already optimized, and then fail to inline important things that are
in the inner loop.

The benchmarking server shows about a 3% improvement on average when running
the DartJS compiler.

This is a reland of https://codereview.chromium.org/2994283002/

Bug

R=vegorov@google.com

Change-Id: Ib2d1f0daad5d68d140bf0266c362dded7a4ea36b
Reviewed-on: https://dart-review.googlesource.com/7706
Commit-Queue: Erik Corry <erikcorry@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-09-25 10:21:42 +00:00
Florian Loitsch 76c5d2f638 Revert "Don't inline if we don't have inlining budget enough to fully inline."
This reverts commit e5aa7158ff.

Change-Id: Icb258421693316158c7af96cf25cbdcadc2780c9
Reviewed-on: https://dart-review.googlesource.com/7548
Reviewed-by: Florian Loitsch <floitsch@google.com>
2017-09-21 11:07:33 +00:00
Erik Corry e5aa7158ff Don't inline if we don't have inlining budget enough to fully inline.
When deciding whether to inline a function that has already been optimized
once, take a look at how many levels of inlining took place when it was
optimized stand-alone. If we don't have that much depth budget left, don't
inline.  This is an attempt to avoid the situation where we inline a function
that was already optimized, and then fail to inline important things that are
in the inner loop.

The benchmarking server shows about a 3% improvement on average when running
the DartJS compiler

This was reviewed and LGTMed at https://codereview.chromium.org/2994283002

Bug:
Change-Id: Ia731c89f32ac4eacd643965a36dcee35f610c141
Reviewed-on: https://dart-review.googlesource.com/7544
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-09-21 09:13:28 +00:00