Commit Graph

648 Commits

Author SHA1 Message Date
Erik Corry c0404e4f23 Propagate this-specialization to regular (megamorphic) calls
R=vegorov@google.com
BUG=

Review-Url: https://codereview.chromium.org/2716593002 .
2017-02-27 13:28:54 +01:00
Florian Schneider d8f223560a Fix environment mismatch in AOT inlining.
When replacing _instanceOf with a cid range check, the
number of arguments passed as arguments changes.

The new environment must reflect this change.

The failing test is from #28431, but the bug itself has nothing to
do with checked mode.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2639273003 .
2017-01-19 10:25:23 -08:00
Martin Kustermann 46449727a6 VM: Fix [StringInterpolateInstr]s canonicalization: null.ToString() should return "null" (not "Null")
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2637173003 .
2017-01-18 10:21:48 +01:00
Vyacheslav Egorov 1fcc7384aa VM: [DBC] Fix lazy deoptimization after calls that return no values.
On DBC calls return value on the stack instead of a dedicate register but not all calls have a return value (e.g. CheckStack does not) and such calls don't push anything. Implementation of a lazy deopt however assumed that value is always present and tried to manually preserve it by popping and pushing it back after the frame was rewritten. This of course damaged the frame if we performed a lazy deoptimization after the call that did not push anything.

Instead of manually preserving result value value use frame translation to handle it. This allows to handle calls that return value and those that do not uniformly in the Deopt bytecode. Compiler takes care of creating the right deoptimization environment instead.

BUG=
R=zra@google.com

Review-Url: https://codereview.chromium.org/2587133002 .
2016-12-19 23:08:26 +01:00
Todd Turnidge e0d350aa27 Implement rewind on all platforms except for dbc.
BUG=

Review URL: https://codereview.chromium.org/2534413005 .
2016-12-01 17:19:31 -08:00
Todd Turnidge 193ddba4db Revert "Implement rewind: drop one or more frames from the debugger."
This reverts commit af1875be91.

BUG=

Review URL: https://codereview.chromium.org/2521413002 .
2016-11-22 16:05:26 -08:00
Todd Turnidge af1875be91 Implement rewind: drop one or more frames from the debugger.
Not yet implemented on dbc.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2523053002 .
2016-11-22 15:26:08 -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 0e9d63d034 Fix a bug with an unused variable.
Fix my previous: Forgot to insert code that actually uses the
variable.

Strangely, clang did not report this, but other compilers did.

tbr=vegorov@

BUG=

Review URL: https://codereview.chromium.org/2466933002 .
2016-11-01 17:28:22 +01:00
Florian Schneider 0294f8650d AOT: Enable branch merging for checked smi comparisons
This generates better code for smi comparisons in AOT code where the inputs
are not known smis: It avoids materializing the bool-value before branching.

Before:

;; v46 <- CheckedSmiOp:86(==, v35, v77)
;; Branch if StrictCompare:88(!==, v46, v38) goto (8, 9)
0x10e0c2ca3    f6c201                 testb rdx,1
0x10e0c2ca6    0f8526010000           jnz 0x10e0c2dd2
0x10e0c2cac    483bca                 cmpq rcx,rdx
0x10e0c2caf    0f8409000000           jz 0x10e0c2cbe
0x10e0c2cb5    498b5e58               movq rbx,[thr+0x58]   false
0x10e0c2cb9    e904000000             jmp 0x10e0c2cc2
0x10e0c2cbe    498b5e50               movq rbx,[thr+0x50]   true
0x10e0c2cc2    493b5e50               cmpq rbx,[thr+0x50]   true
0x10e0c2cc6    0f8429000000           jz 0x10e0c2cf5  ;; B9
;; B8

===
After:
;; Branch if CheckedSmiComparison:86(!=, v35, v77) goto (8, 9)
0x118b3ce15    f6c201                 testb rdx,1
0x118b3ce18    0f850c010000           jnz 0x118b3cf2a
0x118b3ce1e    483bca                 cmpq rcx,rdx
0x118b3ce21    0f8429000000           jz 0x118b3ce50  ;; B9
;; B8

R=vegorov@google.com

Review URL: https://codereview.chromium.org/2466643002 .
2016-11-01 17:08:33 +01:00
Vyacheslav Egorov 0635b57d43 Reland "Recognize and optimize a.runtimeType == b.runtimeType pattern."
This relands commit f4ec20abac.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2465793003 .
2016-11-01 16:49:02 +01:00
Ryan Macnak 26245de7a5 Support unaligned integer loads on ARM and MIPS.
Fixes SDK build with SIMARM/SIMARM64/SIMMIPS.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2452453002 .
2016-10-31 17:41:53 -07: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
Martin Kustermann e984271b94 Add support for OSR in kernel-based FlowGraphBuilder
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2464953002 .
2016-10-31 19:12:09 +01:00
Vyacheslav Egorov 16e4f2f1c2 Revert "Revert "Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern."""
This reverts commit e495e100dd.

Commit breaks bots that are using Android devices (SIMARM is unaffected).

R=rmacnak@google.com
BUG=

Review URL: https://codereview.chromium.org/2449013004 .
2016-10-26 16:53:32 +02:00
Vyacheslav Egorov e495e100dd Revert "Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern.""
This reverts commit 890f694de5.

Previous commit was passing field_type_map_ down in a place where it was not passed down before.

This caused some handles to be used across zones, which caused crashes.

BUG=

Review URL: https://codereview.chromium.org/2453463006 .
2016-10-26 12:25:48 +02:00
Ryan Macnak 890f694de5 Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern."
This reverts commit f4ec20abac.

Revert "Use ZoneHandle when creating ConstantInstr"

This reverts commit cb87f2d82f.

This change introduced crashes on AOT and runtime errors on the GN SDK build.

TBR=vegorov@google.com

Review URL: https://codereview.chromium.org/2451893002 .
2016-10-25 13:19:33 -07:00
Vyacheslav Egorov f4ec20abac Recognize and optimize a.runtimeType == b.runtimeType pattern.
Start by removing all get:runtimeType overrides in the patch files to have a single point computing the runtime type - Object.get:runtimeType. Handle string, double and integer types inside both intrinsic and runtime call to unify their handling and guarantee that code works even with intrinsifier disabled.

With overrides removed we can easily check that get:runtimeType is unique function name within the application that is being precompiled and use that to convert InstanceCall(get:runtimeType, ...) into StaticCall even nothing is known about the receiver.

This enables us to check if both left side and right side of comparison are StaticCall(Object.get:runtimeType, ...) when specializing InstanceCall(==, x, y). If they are we convert InstanceCall(==, StaticCall(get:runtimeType, a), StaticCall(get:runtimeType, b)) into StaticCall(Object._hasSameRuntimeType, a, b). A canonicalization rule will later delete unused get:runtimeType invocations.

Object._hasSameRuntimeType is implemented in C++ and intrinsified. It operates without creating new runtime types (except for Closures - where it does for simplicity). Cases of different class ids (i.e. a.[cid] != b.[cid]) and non-parameterized types are handled completely in the intrinsic. The rest is handled in the runtime code.

Microbenchmarking results:

Same parameterized classes: 15x improvement
Different parameterized classes: 300x improvement
Different/same non-parameterized classes: 2x improvement

BUG=
R=fschneider@google.com, regis@google.com

Review URL: https://codereview.chromium.org/2379733002 .
2016-10-25 10:03:06 +02: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
Ryan Macnak 1bc2b04198 Fix bug in AOT compiler where we would propogate a result type for instances calls where the target is not known.
Interacted with cid range checks to incorrectly reduce

foo(x) => (x * 1.0) is double;

to

foo(x) { x * 1.0; return true; }

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2325753002 .
2016-09-08 14:36:28 -07:00
Florian Schneider 442fa8e7bc VM: Remove unecessary dead code from flow-graph builder.
We already recognize typed list factories and mark them
using is_known_list_constructor_.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2293103002 .
2016-08-30 11:14:40 -07:00
Florian Schneider 7d6f78b88f VM: More refactoring of recognized methods inlining.
Move inlining OneByteString._setAt, List constructor, Object constructor
and a few math function to the flow-graph inliner.

Enable inlining of trigonometric math functions in AOT that were previously not inlined.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2273943002 .
2016-08-24 10:35:05 -07:00
Florian Schneider 1e7dc8a5e8 Move inlining of recognized SIMD methods to the flow-graph inliner.
This allows inlining of these methods in the AOT optimizer.

Also fix missing inlining of some SIMD constructors (Float32x4FromInt32x4Bits and Int32x4FromFloat32x4Bits)

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2254053002 .
2016-08-18 12:50:37 -07:00
Zachary Anderson b5a40f8a60 DBC: Only try Smi fastpath in unoptimized code
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2173213002 .
2016-07-22 13:43:00 -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
Florian Schneider f50a14c4a9 Remove remaining stub code for IC range profiling.
I forgot to remove this in my previous CL.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2140683002 .
2016-07-11 09:11:26 -07:00
Zachary Anderson 1c783dea87 DBC: Remove special case from CheckClassInstr. Cleanup.
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2111803003 .
2016-07-01 10:19:21 -07:00
Zachary Anderson db26281172 DBC: CheckClassInstr
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2098573004 .
2016-06-29 15:25:43 -07:00
Florian Schneider 28c0ab16f2 Canonicalize CheckedSmiOp if compile type turns out to be smi.
Certain CheckedSmiOp operations can be specialized later during optimization
when the compile type turns out to be smi, and we know that the operation
can't deoptimize.

BUG=#26761
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2094613003 .
2016-06-23 10:31:23 -07:00
Zachary Anderson b3e5c5eeed DBC: Adds BinarySmiOp instruction
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2053213004 .
2016-06-15 14:48:11 -07:00
Zachary Anderson de78ddbc55 DBC: Collect type feedback for fastpath smi ops
R=turnidge@google.com, vegorov@google.com

Review URL: https://codereview.chromium.org/2015113002 .
2016-06-03 09:09:13 -07:00
Vyacheslav Egorov 655bc90489 Enable optimizer pipeline for DBC.
Most of the infrastructure is fixed to work with DBC stack layout:

- register allocator allocates DBC registers with the limitation that we allocate only 20 registers and bail out if anything needs spilling (there is no use implementing spilling on DBC because registers are memory locations themselves). We should be able to bump number of CPU registers on DBC up to 256 but this requires major surgery in some parts - so I postponed this;
- lazy deoptimization is implemented, eager deoptimization is not - because we don't emit any code that actually requires it. it's a minor change to support it once we have a target;
- stack scanning respects stack maps built by registers allocator;

We bailout from all unsupported instructions.

R=zra@google.com

Review URL: https://codereview.chromium.org/1992963002 .
2016-05-24 14:35:50 +02:00
John McCutchan 48c8ffa7f3 Initial isolate reload support
This is a cut of the work that Todd and I collaborated on in the reload branch.

In this CL, we've dropped the loader port hacks, in other words, on stack reloading in the standalone embedder does not work yet.

- [x] Support for hot reloading of isolate source code
- [x] Unit test harness and many tests
- [x] Service protocol and Observatory support
- [x] Product build does not include support for hot reloading.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1965823002 .
2016-05-17 12:19:06 -07:00
Florian Schneider f54c8d89fa VM: Remove PushTempInstr, simplify SSA renaming.
BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1950553002 .
2016-05-04 10:54:03 +02:00
Florian Schneider 6ff337f724 Revert "VM: Improve phi-elimination to improve code inside of try-catch."
This reverts commit 6d537d7e61.

Need more time to investigate test failures that occur with this CL.

TBR=vegorov@google.com

BUG=

Review URL: https://codereview.chromium.org/1922953002 .
2016-04-26 17:24:35 +02:00
Florian Schneider 6d537d7e61 VM: Improve phi-elimination to improve code inside of try-catch.
Since we don't have precise liveness information inside try-catch blocks,
there are often redundant phis inside try-catch of the form

v <- phi(v, v, ..., R, v, v, ...)

This CL finds these redundant phis and replaces them with R.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1918913002 .
2016-04-26 12:50:25 +02:00
Stephen Adams cceadc20d9 Canonicalize TestCidsInstr
This reduces Uri.toString() in dart2js from 514 lines to 345 lines.
(lines are instructions or code comments).

I noticed the following:

Uri.toString() has a statement: sb.write('//');

This was lined two levels deep, with effectively the following code
for the inlining of interoplateSingle:

    TestCids on constant '//':
       _OneByteString  -> return '//';
       Uri -> fallthrough;
       Message -> fallthrough;
       else deopt;

    if ('//' is not Uri) deopt;
    String s = Uri.toString('//');
    if (s is !_OneByteString) deopt;
    return s;

With canonicalization of TestCidsInstr, this whole thing clears up
eliminate interoplateSingle.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1891353003 .
2016-04-20 10:26:59 -07:00
Ryan Macnak f731dd0615 Reapply "- Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list and search for canonical instances."
- Rehash constants table during tree-shaking.
 - Rehash constants table on snapshot load.

R=regis@google.com

Review URL: https://codereview.chromium.org/1900863002 .
2016-04-18 16:46:26 -07:00
Vyacheslav Egorov ee0f608ce4 Dart Byte Code interpreter.
This version is Clang/GCC only and does not support Windows because it uses computed goto's.

Only unoptimized mode is supported.

Architecture is described in constants_dbc.h and stack_frame_dbc.h.

R=fschneider@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1858283002 .
2016-04-18 23:02:01 +02:00
Siva Annamalai 8ce7b6291a Revert "- Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list and search for canonical instances."
This reverts commit 95a2b02a9e.

Once the tree shaker in precompiled code is fixed to treat the constants array in a class as a hash table this CL can be re-applied.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1888593003 .
2016-04-13 18:49:53 -07:00
Siva Annamalai 95a2b02a9e - Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list and search for canonical instances.
- Some minor cleanups
  - Return an empty array right away in the parser instead of creating an
    empty array and canonicalizing it
  - The canonical bit was not being set for some of the singleton objects.

R=regis@google.com

Review URL: https://codereview.chromium.org/1873143003 .
2016-04-13 10:26:17 -07:00
Srdjan Mitrovic 80ba69dfdb Print messages when aborting background compilation (--trace-compiler); turn on background compilation; mark a slow test.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1879033002 .
2016-04-12 11:19:56 -07:00
Ivan Posva 5be5d54529 - Refactor Symbol allocation to expect a thread parameter.
- Preallocate all tokens as symbols to avoid repeated lookups.
- Pass thread/zone where useful while doing this change.
- Avoid allocating symbols for error messages.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1870343002 .
2016-04-11 16:28:29 -07:00
Ryan Macnak e048774776 Precompilation: Specialize instance calls when the call receiver is the method receiver and the method class has a small number of concrete subclasses (currently 5).
CompileOnceHelloHtml (ARMv7HF) +17.194%
DeltaBlueClosures (ARMv7HF) +28.379%
DeltaBlue (ARMv7HF) +30.190%

precompiled dart2js arm 19071745 -> 19504726 (+2.3%)

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1867913004 .
2016-04-11 12:52:28 -07:00
Ryan Macnak 34e4107c0d Add flag to disable string externalization, allowing the compiler to rely on string class checks remaining valid across calls.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1859273002 .
2016-04-07 13:24:44 -07:00
Srdjan Mitrovic 314bb44ea3 Fix background compilation queue access. Some cleanups.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1863273002 .
2016-04-07 09:12:56 -07:00
Srdjan Mitrovic cef337f8c7 Add instruction tags to saved ICData (debug mode only).
When restoring ICData in optimizing compiler, we can verify that the ICData/deopt-id matches an instruction. This should help catch non-deterministic graph generation.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1864143002 .
2016-04-06 11:01:46 -07:00
Florian Schneider 21e069a009 Reland "VM: Improve single-target polymorphic calls."
This reverts commit 53e92a31ae.

Reverted to check if this CL had anything to do with Dartium test failures. Turns out it does not.

TBR=srdjan@google.com,

BUG=

Review URL: https://codereview.chromium.org/1853003002 .
2016-04-02 18:08:32 -07:00