Commit Graph

21 Commits

Author SHA1 Message Date
Vyacheslav Egorov f496e538f4 [vm] Decouple assemblers from runtime.
This is the next step towards preventing compiler from directly peeking
into runtime and instead interact with runtime through a well defined
surface. The goal of the refactoring to locate all places where compiler
accesses some runtime information and partion those accesses into two
categories:

- creating objects in the host runtime (e.g. allocating strings, numbers, etc)
during compilation;
- accessing properties of the target runtime (e.g. offsets of fields) to
embed those into the generated code;

This change introduces dart::compiler and dart::compiler::target namespaces.

All code in the compiler will gradually be moved into dart::compiler namespace.
One of the motivations for this change is to be able to prevent access to
globally defined host constants like kWordSize by shadowing them in the
dart::compiler namespace.

The nested namespace dart::compiler::target hosts all information about
target runtime that compiler could access, e.g. compiler::target::kWordSize
defines word size of the target which will eventually be made different
from the host kWordSize (defined by dart::kWordSize).

The API for compiler to runtime interaction is placed into compiler_api.h.

Note that we still permit runtime to access compiler internals directly -
this is not going to be decoupled as part of this work.

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

Change-Id: If4396d295879391becfa6c38d4802bbff81f5b20
Reviewed-on: https://dart-review.googlesource.com/c/90242
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-01-25 16:45:13 +00:00
Stevie Strickland 23f427b1a7 Reland [VM/Compiler] Removing definition status from Store{Indexed,InstanceField}.
Also do the same for the unsafe version of StoreIndexed.

Similar to the inliner, we may replace calls in the specializers with
these non-definition instructions, so we make variants that allow an
unrelated value to be used for the old users of the call site value. (In
all cases, this ends up being null, since the original calls wouldn't
have returned a useable value anyway.)

Change-Id: I0befd54920c4c0e63e086b804860ee4c9a7d3767
Reviewed-on: https://dart-review.googlesource.com/c/89585
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Stevie Strickland <sstrickl@google.com>
2019-01-15 17:23:21 +00:00
Vyacheslav Egorov 02b1658f59 Revert "[VM/Compiler] Revoke definition status of certain instructions."
This reverts commit a8777149a7.

Reason for revert: benchmarking infrastructure reports broken benchmarks on ARM.

Original change's description:
> [VM/Compiler] Revoke definition status of certain instructions.
> 
> Change StoreIndexed, StoreIndexedUnsafe, and StoreInstanceField
> to be non-definition instructions. Fix up the flow graph builders
> so they no longer treat StoreIndexed and StoreIndexedUnsafe as
> pushing values on the stack that need to be dropped.
> 
> We recently changed FlowGraphInliner::TryInlineRecognizedMethod
> to create a distinction between the last instruction to be inlined
> and the definition that should be used as the new result. Perform
> the same separation of replacement code and result in the call
> specializers.
> 
> Change-Id: I66c7ab60a662dcca05092e47156d1d4ba809d51f
> Reviewed-on: https://dart-review.googlesource.com/c/88326
> Commit-Queue: Stevie Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,sstrickl@google.com

Change-Id: I9c666d80a69ba6a5c37b421aae1ed83502694f19
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/89366
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2019-01-14 18:50:29 +00:00
Stevie Strickland a8777149a7 [VM/Compiler] Revoke definition status of certain instructions.
Change StoreIndexed, StoreIndexedUnsafe, and StoreInstanceField
to be non-definition instructions. Fix up the flow graph builders
so they no longer treat StoreIndexed and StoreIndexedUnsafe as
pushing values on the stack that need to be dropped.

We recently changed FlowGraphInliner::TryInlineRecognizedMethod
to create a distinction between the last instruction to be inlined
and the definition that should be used as the new result. Perform
the same separation of replacement code and result in the call
specializers.

Change-Id: I66c7ab60a662dcca05092e47156d1d4ba809d51f
Reviewed-on: https://dart-review.googlesource.com/c/88326
Commit-Queue: Stevie Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-01-14 15:45:03 +00:00
Alexander Markov d8e920fbad [vm/bytecode] Correct token kind for _instanceOf calls
When building flow graph from bytecode, token kind was not assigned
to _instanceOf calls, disabling certain optimizations.

Results on Iteration benchmark in --use-bytecode-compiler mode:

Before:
Iteration.concat.manual2(RunTime): 5234.970684073108 us.
Iteration.concat.manual2.typed(RunTime): 11202.951642458102 us.

After:
Iteration.concat.manual2(RunTime): 646.3644823909532 us.
Iteration.concat.manual2.typed(RunTime): 687.4386742268042 us.

Change-Id: Ica48634ba1cdaf65ffff290e251de8e6f3b5a165
Reviewed-on: https://dart-review.googlesource.com/c/88230
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-01-02 23:18:38 +00:00
Régis Crelier 25851db73d [vm/bytecode] Replace InstanceCall instruction with InterfaceCall and DynamicCall.
Dispatch interface calls via hashtable rather than inline cache.
InterfaceCall doesn't need to take arguments descriptor into account
when doing method lookup.

Change-Id: I30eae6ea638d1d2ad2cf3ff073c653fee3377f31
Reviewed-on: https://dart-review.googlesource.com/c/86106
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-12-14 16:51:51 +00:00
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
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
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 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
Alexander Markov 59e626e5c9 [vm/bytecode] Change encoding of MoveSpecial bytecode instruction
Previously MoveSpecial bytecode instruction used unsigned 8-bit A field
to encode target local variable index. This is too restrictive as we allow
signed 16-bit local variable indices.

After this change MoveSpecial has A_X encoding, with A field used for
special index (0 or 1), and signed 16-bit X field used for target local.

Change-Id: Ib87992e192b2923a39a9968913c39476947d3ea5
Reviewed-on: https://dart-review.googlesource.com/c/81440
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2018-10-25 19:07:19 +00:00
Alexander Markov 1d10e037ef [vm/bytecode] Remove unreachable bytecode
Change-Id: I29393604547038cf359b8e19ea48078dd0eea3b1
Reviewed-on: https://dart-review.googlesource.com/c/81201
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2018-10-23 23:26:13 +00:00
Martin Kustermann 06f9a9e354 [VM] Introduce function and osr entrypoints to the VM's IR
Similar to how we treat catch entry instructions, this cl adds new
function and osr entry instructions. The [FunctionEntry] and
[OsrEntry] - just like [CatchBlockEntry] - have now their own initial
definitions. The [GraphEntry] has only initial definitions for
constants.

Explicit phis are inserted for all parameter / special parameter
instructions if necessary.

Future work is:

  a) Minimize parallel moves due to the phis on parameters
  b) Cleanup frame setup: Move it entirely into FunctionEntry/CatchEntry
    (instead of the split version we have now)

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

Change-Id: Iefa0280a709716f748d6fb0523b8d0f4d8de1fec
Reviewed-on: https://dart-review.googlesource.com/c/74782
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-10-15 13:02:51 +00:00
Ryan Macnak b8760fed67 [vm, compiler] Remove ASTs and AST flow graph builder.
Change-Id: I4d3c6500577d5285ced327954040dab42ba92341
Reviewed-on: https://dart-review.googlesource.com/c/78823
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-10-10 18:00:21 +00:00
Alexander Markov 6d0601a72b [vm/bytecode] Add bytecodes for int operations and '== null'
DeltaBlue performance in pure interpreted mode
(--enable-interpreter --compilation-counter-threshold=-1):
Before: DeltaBlue(RunTime): 269198.732 us.
After:  DeltaBlue(RunTime): 158216.34376923076 us. (-41.23%)

Change-Id: I9dea8d7949421986ee6fbdeae046fe4ef6d3227f
Reviewed-on: https://dart-review.googlesource.com/c/77231
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-10-03 15:45:36 +00:00
Alexander Markov 2aac05fe10 [vm/bytecode] Add specialized JumpIf* instructions
This change adds JumpIfEqStrict, JumpIfNeStrict, JumpIfTrue, JumpIfFalse,
JumpIfNull, JumpIfNotNull bytecode instructions. These instructions
supercede If*/Jump instruction patterns.

Change-Id: Icf9dc624001ce64d4b21409864591d693ead51d3
Reviewed-on: https://dart-review.googlesource.com/77011
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-09-28 16:29:23 +00:00
Régis Crelier 79d639a3a8 [VM interpreter/bytecode] Modify argument order for AssertAssignable bytecode.
The new argument order matches the runtime call and requires less copying.
Simplify Function::HasCode()
Remove obsolete workaround when updating type test cache.

Change-Id: I57c988f97ee2259a22730f445f336cd2a085959e
Reviewed-on: https://dart-review.googlesource.com/76584
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-09-26 21:15:16 +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 76091c13db [vm/bytecode] Add PushNull, PushTrue, PushFalse and PushInt bytecodes
These bytecode instructions are added in order to shrink constant pools
and reduce time spent for reading constant pool entries.

Change-Id: I8522f73dc7a6236969ac0422c6cb89b945559b2d
Reviewed-on: https://dart-review.googlesource.com/75125
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-09-15 17:55:46 +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