Commit Graph

65 Commits

Author SHA1 Message Date
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
Alexander Markov ac7ca17652 [vm/kernel] Experimental: generate DBC-like bytecode in kernel binaries
To enable bytecode generation, toggle kEnableKernelBytecode flag at
the beginning of pkg/vm/lib/bytecode/gen_bytecode.dart.
This will also enable generation of bytecode in platform dill files.

Also, bytecode generation can be enabled using --gen-bytecode option of
pkg/vm/tool/gen_kernel.

In kernel binaries, the generated bytecode and constant pool are
placed into 'vm.bytecode' metadata attached to members.
pkg/vm/tool/dump_kernel tool can be used to disassemble
bytecode and print constant pool.

Differences between generated bytecode and original DBC are
described in pkg/vm/lib/bytecode/dbc.dart.

Format of constant pool is described in
pkg/vm/lib/bytecode/constant_pool.dart.

Currently, only a small subset of Dart language is supported.
Bytecode generator will not emit vm.bytecode metadata for a
member if its body has an unsupported operation.


Change-Id: I27d9a361dc779ea115e5676508ee757c1754e05d
Reviewed-on: https://dart-review.googlesource.com/49600
Reviewed-by: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-04-23 03:42:52 +00:00
Martin Kustermann 3b057dea98 [VM] Remove legacy Object::empty_context() and CTX constant
Our generated code does not keep the context in a special register
anymore (for quite some time now).  The context is just another definition
in the IR language and gets assigned register locations by the linearscan
register allocator.

Furthermore we no longer use an empty context for closures which have no
captured states, instead the context of those closures is just `null`.

This CL therefore removes Object::empty_context() and the CTX constant.

Change-Id: Iea171e0d0fd56c48f1c456e08e060a12267e39cc
Reviewed-on: https://dart-review.googlesource.com/51129
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-04-19 20:09:38 +00:00
Ryan Macnak 6664e3c02a [vm, dbc] Implement lazily-linked natives for DBC and enable AppJIT.
Because DBC still uses code patching to implement breakpoints, running a program from DBC AppJIT may trigger a crash attempting to set a breakpoint.

Change-Id: I5d761aacec6629be946d7d2510ec3f1e3f03f4a4
Reviewed-on: https://dart-review.googlesource.com/42584
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-02-23 02:20:12 +00:00
Martin Kustermann 32c4480403 [VM] Fix various issues in the VM, mainly simdbc64 related
* Fixes kernel flow graph builder to use instantiated type argumenst
    for CreateArray

  * Fixes prologue builder to mask the positon of named arguments in the
    arguments descriptor array

  * Add a SmiBitAndTOS instruction to DBC

  * Implement missing AssertSubtype DBC instruction

  * Ensure we don't use field guards in DBC mode

  * Remove incorrect assertions in LoadIndexedUnsafe/StoreIndexedUnsafe

  * Save argdesc_ in DBC simulator when calling the runtime to optimize
    a function (which can call re-entrant to Simulator via const
    evalulation)

Issue https://dart-review.googlesource.com/c/sdk/+/29581

Change-Id: Ia14b657db66f90643822b6986ec7f75f746ab0d8
Reviewed-on: https://dart-review.googlesource.com/30340
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-19 14:49:52 +00:00
Martin Kustermann cf1de7d46c [VM] Replace hand-written assembly prologues with IR
As part of the prologue changes we get rid of the empty context as well.

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

Change-Id: I707e23c631bcfbbad6c91c4963d0c10f7a0be625
Reviewed-on: https://dart-review.googlesource.com/25320
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-13 16:04:34 +00:00
Régis Crelier c29f5dd4f5 [VM DBC compiler and simulator] Support reified generic functions.
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2987323003 .
2017-08-16 10:48:07 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Erik Corry 029b1cb948 Spelling fixes e to i.
R=kevmoo@google.com
BUG=

Review-Url: https://codereview.chromium.org/2957593002 .
2017-06-24 13:41:39 +02:00
Erik Corry dfb67ecbf8 VM-codegen: Clean up the way we emit code for comparison instructions.
Removes some redundancy in the Emit* methods in intermediate_language_*.cc for
the 6 architectures we support.

This is a reapplication of https://codereview.chromium.org/2937933002/ -
see the comments there.  It fixes a bug in the way the TestCids
instruction was emitted on DBC.

R=vegorov@google.com
BUG=

Review-Url: https://codereview.chromium.org/2947633002 .
2017-06-20 17:41:12 +02:00
Erik Corry 1f7d2d5439 Revert "Reduce copying, redundancy & repetition for codegen of comparison instructions"
R=kustermann@google.com
BUG=

This reverts commit e25dfc07d1.
Reason: Failure on SIMDBC64
Review-Url: https://codereview.chromium.org/2949513002 .
2017-06-19 10:28:47 +02:00
Erik Corry e25dfc07d1 Reduce copying, redundancy & repetition for codegen of comparison instructions
R=vegorov@google.com
BUG=

Review-Url: https://codereview.chromium.org/2937933002 .
2017-06-19 09:45:03 +02:00
Erik Corry 4aa5e1d7aa Cleanup: Make CheckClassId instruction more general so it
can be used uniformly in the polymorphic inliner.

R=kustermann@google.com
BUG=

Review-Url: https://codereview.chromium.org/2891713002 .
2017-05-19 08:49:41 +02:00
Erik Corry 8bce36dab9 Use off-heap data for class check instructions
This continues the work from https://codereview.chromium.org/2842753002/
- see the motivation there.

R=vegorov@google.com
BUG=

Review-Url: https://codereview.chromium.org/2856543002 .
2017-05-11 10:01:05 +02:00
Erik Corry aa6353b6da Dart SDK Spelling b, c, and d.
R=kmillikin@google.com
BUG=

Review-Url: https://codereview.chromium.org/2850783002 .
2017-05-01 08:28:10 +02:00
Regis Crelier d0a7bad121 Pass a second type argument vector to all type instantiation calls in the VM.
With generic methods, uninstantiated types will require 2 instantiators, one
reflecting the class type arguments (as of today) and one reflecting the
function type arguments (new).
This is work in progress and the second instantiator is always null for now.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2799373002 .
2017-04-10 21:25:33 -07:00
Ryan Macnak cbb8519a69 Do not embed is_auto_setup_scope into the compilation of native calls.
Rather, split NativeCallWrapper into variants that do or do not set up an API scope. This makes it safe for lazy link natives to also lazily resolve.

Issue #24686

R=zra@google.com

Review-Url: https://codereview.chromium.org/2793163002 .
2017-04-05 15:30:06 -07:00
Erik Corry ae8e6705c0 Allow dispatch to use a range of Class-ids in tests
Use polymorphic call for all multi-cid call sites
Remove special hashCode code

R=vegorov@google.com
BUG=

Review-Url: https://codereview.chromium.org/2737303003 .
2017-03-15 16:08:46 +01:00
Florian Schneider 71cb54714b Reland "VM: Simplify lowering of is-tests.""
This reverts commit d44fec08b0.

Remove special-cases for known types (int, String, num, double, Smi). The generic
lowering into an instance call (_simpleInstanceOf) works just fine for these predefined
types.

Also, remove parameter for negated is-tests. Instead insert explicit negation when.
building the flow graph.

Diff to original CL:
 * Correct number of arguments in invocation of _instanceOf in kernel_to_il.cc.

R=vegorov@google.com
TBR=vegorov@google.com

Review-Url: https://codereview.chromium.org/2748063003 .
2017-03-14 09:19:51 -07:00
Vyacheslav Egorov d44fec08b0 Revert "VM: Simplify lowering of is-tests."
This reverts commit 066123e037.

Reason for revert: vm-kernel-* is broken because kernel_to_il.cc was not updated
in sync with flow_graph_builder.cc.

TBR=fschneider@google.com, rmacnak@google.com,

Review-Url: https://codereview.chromium.org/2748073002 .
2017-03-14 12:27:41 +01:00
Florian Schneider 066123e037 VM: Simplify lowering of is-tests.
Remove special-cases for known types (int, String, num, double, Smi). The generic
lowering into an instance call (_simpleInstanceOf) works just fine for these predefined
types.

Also, remove parameter for negated is-tests. Instead insert explicit negation when.
building the flow graph.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2751543003 .
2017-03-13 16:48:59 -07:00
Todd Turnidge 7d6ba6bf1f Make rewind work on DBC
Closes #27878

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2636443004 .
2017-03-08 13:15:54 -08:00
John McCutchan 8b6f610206 Fix hot reload test mode in simdbc by supporting forced slow paths on simdbc
- [x] Add new SIM DBC byte code: CheckStackAlwaysExit.
- [x] Emit CheckStackAlwaysExit instead of CheckStack when requested.

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2569013002 .
2016-12-12 14:07:22 -08:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Florian Schneider b1dfa2aee1 VM: Enable branch merging of isnan, isinf.
More general ComparisonInstr by introducing TemplateComparison.

R=zra@google.com

Review URL: https://codereview.chromium.org/2463593002 .
2016-10-31 20:21:19 +01:00
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07:00
Zachary Anderson 088347fd9d Reland "Add DoubleTestOp instruction"
Fixes DoubteTestOpInstr::AttributesEqual()

Review URL: https://codereview.chromium.org/2433813002 .
2016-10-18 22:46:36 -07:00
Zachary Anderson f6296cc91b Revert "Add DoubleTestOp instruction"
Review URL: https://codereview.chromium.org/2432903002 .
2016-10-18 21:57:05 -07:00
Zachary Anderson fa855cf1c2 Add DoubleTestOp instruction
This gives a ~5% bump to the Flutter layout benchmark
in checked mode.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2423843002 .
2016-10-18 21:24:12 -07:00
Florian Schneider 6d66f3dea8 VM: Make optimized try-catch work in DBC.
The catch entry block has all locals in fixed locations
(Rj) where j = kNumberOfRegisters - i for parameter i.

This means we reserve a range of DBC registers at the top-end of the frame.
Those registers are blocked for general allocation to avoid any overlap
with the rest of the registers that are allocated from the bottom.

Each optimized frame with a try-catch will be kNumberOfRegisters wide.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2388093003 .
2016-10-13 11:36:23 -07:00
Zachary Anderson 08d70cdca5 DBC: Fix CheckCids instruction
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2408423004 .
2016-10-12 12:45:38 -07:00
Zachary Anderson 775fce18d5 DBC: Add Smi fastpath to AssertAssignable
Flutter layout benchmark 14k us -> 10k us. ~30%
improvement in checked mode. There still appear
to be a lot of checks that should be hitting the
cache, so there may be other fast-paths needed
as well.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2404163004 .
2016-10-11 14:25:14 -07:00
Zachary Anderson f713658b71 DBC: Pull BadTypeError out of AssertAssignable
This was allocating a handle which is not allowed in the simulator loop.

Small improvement in Flutter's layout_bench in checked
mode. 15k us -> 14k us. 7% improvement.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2406383002 .
2016-10-11 11:04:17 -07:00
Florian Schneider a292de544f DBC: Support large offsets in optimized field access.
Added two new bytecodes: LoadFieldExt, StoreFieldExt that
store the field offset in the following nop-instruction that
is skipped.  This allows offsets up to 16 bit.

BUG=
R=zra@google.com

Review URL: https://codereview.chromium.org/2399333003 .
2016-10-07 14:03:34 -07:00
Zachary Anderson bc1dc06687 DBC: Double converstion instructions
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2341683003 .
2016-09-15 09:18:32 -07:00
Zachary Anderson 360d55b4f6 DBC: Another allocation fast path
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2335363002 .
2016-09-14 10:24:58 -07:00
Zachary Anderson 7d01ca5e0d DBC: A couple allocation fastpaths.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2331033003 .
2016-09-13 10:21:27 -07:00
Zachary Anderson b49de12f6c DBC: Fix more HTTP benchmark bailouts
HttpRequest(IOPerSecond) ~300 -> ~350

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2270483002 .
2016-08-22 15:57:57 -07:00
Zachary Anderson ae3d47fdc4 DBC: Add back special case for float64 load/store
After my last change eliminating the special case, there was a
20% perf drop on FluidMotion.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2268593002 .
2016-08-22 14:39:27 -07:00
Zachary Anderson 08ff3c039e DBC: Fixes typed data bugs. Adds unboxed int32 instructions
Typed data indexing was all wrong. It was also wrong to clobber the index register in LoadIndexed.

RSA benchmark: 88s -> 0.7s

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2258493004 .
2016-08-19 15:23:16 -07:00
Zachary Anderson f7e186eb20 DBC: Instructions for bailouts from http tests.
Load/Store indexed from typed data arrays, etc.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2258613002 .
2016-08-18 09:50:55 -07:00
Zachary Anderson c75200774b DBC: Fleshing out the polymorphic instance call instruction
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2244313002 .
2016-08-16 11:21:25 -07:00
Ryan Macnak 3dba3a77c1 DBC: Fix not-stopping/crashing at fast Smi op breakpoints.
When setting a breakpoint at a fast Smi op, replace the fast Smi op instruction with a Nop so we don't skip the following DebugBreak in the Smi case and don't attempt to increment an ICData counter through pool slot 0.

R=zra@google.com

Review URL: https://codereview.chromium.org/2194493002 .
2016-07-28 13:41:22 -07:00
Ryan Macnak 708334c614 DBC: Fix reading locals out of a deopt frame.
R=zra@google.com

Review URL: https://codereview.chromium.org/2176413003 .
2016-07-26 10:36:07 -07:00
Zachary Anderson d279392430 DBC: More Load/Store Indexed variants, A few more math instructions.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2181713002 .
2016-07-25 13:40:37 -07:00
Zachary Anderson 2c6449087d DBC: Misc double instructions
- DoubleToSmi
- MathUnary
- MathMinMax

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2162173002 .
2016-07-20 09:46:32 -07:00
Zachary Anderson 8aed249e88 DBC: A bit of Polymorphic instance call
Only for the case without checks. Still enough for a good bump on
Richards. I've also increased the number of "registers" to 32 to
get rid of the SPILLs on DeltaBlue, but couldn't see a performnace
improvement. Probably better not to bail out, though.

R=vegorov@google.com

Review URL: https://codereview.chromium.org/2162953005 .
2016-07-20 08:54:50 -07:00
Zachary Anderson 43e89ccdd3 DBC: Make unoptimized static calls call through ICData
Isolate reloading works by manipulating ICData. Unoptimized
static calls won't go to the new function after a reload unless
the calls go through the ICData.

R=vegorov@google.com

Review URL: https://codereview.chromium.org/2149993006 .
2016-07-18 10:39:09 -07:00
Zachary Anderson fe2b7b35c4 DBC: Enables unboxed doubles
This CL enables unboxed doubles for simdbc64. Unboxed
doubles are stored in regular dbc registers, which are
really 64-bit stack slots. It also implements binary
and unary double operations and comparisons.

R=vegorov@google.com

Review URL: https://codereview.chromium.org/2120703002 .
2016-07-14 16:05:20 -07:00
Zachary Anderson 726fd84ff4 DBC: Various instructions.
- LoadIndexed
- EqualityCompare
- RelationalOp

R=vegorov@google.com

Review URL: https://codereview.chromium.org/2113563002 .
2016-07-11 09:02:18 -07:00