Commit Graph

34 Commits

Author SHA1 Message Date
Alexander Markov 741f662a60 [vm/kernel/bytecode] Fix number of checked arguments in bytecode calls
Number of checked arguments is corrected in ICData objects created when
reading bytecode, both for instance and static calls.

InstanceCall1 and InstanceCall2 bytecode instructions are replaced with
InstanceCall which works for any number of checked arguments. This makes
decision on number of checked arguments internal to VM and it is no longer
exposed to bytecode.

Change-Id: I0bba01eca6347336f3832de863b2ce4715fda04a
Reviewed-on: https://dart-review.googlesource.com/69421
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-13 17:50:21 +00:00
Vyacheslav Egorov c5f933fdf7 [vm/lib] String._identityHashCode should be the same as String.get:hashCode
On 64-bit platforms we use a field in the header to cache results of
Object.get:_identityHashCode. The very same field is also used to
cache String.get:hashCode result. Which means that their implementations
must be the same.

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

Change-Id: I98eef9eddf833c0d7c4c6f452728fe48e232efdc
Reviewed-on: https://dart-review.googlesource.com/68042
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-08-02 11:24:25 +00:00
Aart Bik c76e071b79 [vm/compiler] Improved integer power specialized inlining.
Rationale:
"Inlines" special cases of int pow() in strong mode
(viz. x^y for either small constant x or y).

History: revert^2 of
https://dart-review.googlesource.com/c/sdk/+/65576
https://dart-review.googlesource.com/c/sdk/+/66041

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

Change-Id: I779e18432a28e82db739cef77d6e6b82148eb70a
Reviewed-on: https://dart-review.googlesource.com/66120
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-07-22 20:59:48 +00:00
Aart Bik 9791508d90 Revert "[vm/compiler] Improved integer power specialized inlining."
This reverts commit cadc4c33ca.

Reason for revert: simarm is not happy with power, even without the opt

Original change's description:
> [vm/compiler] Improved integer power specialized inlining.
> 
> Rationale:
> "Inlines" special cases of int pow() in strong mode
> (viz. x^y for either small constant x or y).
> 
> https://github.com/dart-lang/sdk/issues/33861
> 
> Change-Id: I2e52784f82e39bb0ce33733aef70cbc56f27e451
> Reviewed-on: https://dart-review.googlesource.com/65576
> Commit-Queue: Aart Bik <ajcbik@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

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

Change-Id: I33daaf15fe7b7cac53ec5eeff76e867ee31d2451
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/66041
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-07-20 23:24:46 +00:00
Aart Bik cadc4c33ca [vm/compiler] Improved integer power specialized inlining.
Rationale:
"Inlines" special cases of int pow() in strong mode
(viz. x^y for either small constant x or y).

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

Change-Id: I2e52784f82e39bb0ce33733aef70cbc56f27e451
Reviewed-on: https://dart-review.googlesource.com/65576
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-07-20 20:14:28 +00:00
Aart Bik 34fc26d4cd [vm/inliner] Inline 64-bit typed data.
Rationale:
This CL finalizes recent improvements by allowing
inlining 64-bit and double getter/setter operations.
The runtime over all data types (with and without
view) now no longer has outliers.

Note:
64-bit targets only, 32-bit targets still tbd.

Performance:
About 4x improvement on micro benchmarks.

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

Change-Id: Ic82fa24167a68e3c196edf4843f0829c7fbcf9e1
Reviewed-on: https://dart-review.googlesource.com/60451
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-07-02 17:41:43 +00:00
Alexander Markov 57c0fc9593 [vm/corelib] More cleanup in integer operations after _Bigint is removed
Change-Id: I41da6a37e554ffb8b77f51fda3fee5a15f2b8045
Reviewed-on: https://dart-review.googlesource.com/60441
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-18 18:16:51 +00:00
Aart Bik 2a396d5315 [vm/intrinsics] Intrinsify 64-bit int typed data.
Rationale:
With limited integers, signed/unsigned 64-bit int typed
data is just a bit pattern, no need to sign/zero extend
these into bigger ints on load. This enables more
intrinsification of indexed stores/loads.

Note:
Still TBD, inline these indexed operations too.

Performance:
About 10x improvement on micro benchmarks.

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


Change-Id: I640c324a7d91e57fb4edc025e0dd456ad34fe906
Reviewed-on: https://dart-review.googlesource.com/60403
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-06-15 18:09:40 +00:00
Aart Bik db72134f90 [vm/inliner] Add smi return type of clamped convertors.
Rationale:
Rather than forced inlining of clamped convertors
(the "saturated" method _toClampedUint8() from
dart:typed_data), exposing the fact that it always
returns smi values (since they check fail on null inputs)
yields much better Uint8ClampedListView performance
(it avoids re-compilation due to a speculative CheckSmi).

Note:
In the long run, we may still want them inlined
and improve range analysis to deal with clamping.

Performance:
About 2.8x faster than previous optimized version,
about 4.5x faster than original.

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

Change-Id: I86a06525d2f2ea0476effd3c3d856ff8d9ab1d87
Reviewed-on: https://dart-review.googlesource.com/60201
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-06-13 23:15:04 +00:00
Aart Bik b7493b663e [vm/inliner] Inline small int convertors.
Rationale:
Always inline int convertors that don't do
much more than testing and anding.
For example, force inline
  v26 <- StaticCall:66( _toUint8@6027147<0> v4 T{Type: class 'int'?}) T{Type: class 'int'?}
to
  v47 <- Constant(#255)
  ..
  CheckSmi:10(v4 T{Type: class 'int'?})
  v45 <- BinarySmiOp:10(&, v4 T{_Smi}, v47 T{_Smi}) T{_Smi}

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

Change-Id: I595d9a64365e16ae244480b5e27f8be23c43d164
Reviewed-on: https://dart-review.googlesource.com/58061
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-06-05 16:54:19 +00:00
Alexander Markov c3b5939965 [vm] Remove --limit-ints-to-64-bits option and old _Bigint class
Closes https://github.com/dart-lang/sdk/issues/33306

Change-Id: I7088d8b7143edbe24f5cefe4be037ad2006e0625
Reviewed-on: https://dart-review.googlesource.com/58101
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-06-04 20:10:40 +00:00
Vyacheslav Egorov 3b86f823d0 [vm/corelib] Remove GrowableArrayMarker hack.
GrowableArrayMarker was a class that implemented int and was used to
enable implementation of default List factory constructor in pure Dart:

  factory List([int length = GROWABLE_ARRAY_MARKER]) {
    return identical(length, GROWABLE_ARRAY_MARKER) ? new _GrowableList<E>(0)
                                                    : new _List<E>(length);
  }

Its existence complicated all kinds of things in the VM and it is finally
time to remove it.

Instead we build List factory body directly in IL.

This CL also provides inlining rule for `new List(n)` case.

Change-Id: I870751658a4ac17fce649c9ac70395ff88a5436c
Reviewed-on: https://dart-review.googlesource.com/57262
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-05-30 13:44:43 +00:00
Lasse R.H. Nielsen 973a1a0219 Remove uses of upper-case constants in remaining SDK code.
This includes Fasta, tools and observatory, so the checked-in SDK must
have the lower-case constants.

Change-Id: I8380ad041ad058f7d02ae19caccfecd434d13d75
Reviewed-on: https://dart-review.googlesource.com/50201
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-04-16 16:11:57 +00:00
Régis Crelier f2806ab624 [Corelib, VM runtime] Fix handling of zero operand in Bigint operations (fixes #32465).
Fix VM, dart2js, and dcc Bigint implementations.
Add shift tests.
Re-enable Bigint intrinsics on VM.

Change-Id: Iec19eac8069cf17783a5346289ea2745ffcc7c26
Reviewed-on: https://dart-review.googlesource.com/46570
Reviewed-by: Florian Loitsch <floitsch@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-03-21 21:44:10 +00:00
Zach Anderson 76b8e397ed Revert "Reland "[VM runtime] Switch intrinsics from old to new Bigint implementation.""
This reverts commit be62fff82f.

Reason for revert: See https://github.com/dart-lang/sdk/issues/32465

Original change's description:
> Reland "[VM runtime] Switch intrinsics from old to new Bigint implementation."
> 
> The change was reverted (thanks Slava) because gen_snapshot was failing to
> find the core lib class _BigIntImpl on flutter.
> The PR https://github.com/flutter/engine/pull/4735 fixed that issue on flutter.
> 
> Change-Id: Id6863d79f7fdb17f0076b63b0168394d5e95ec8d
> Reviewed-on: https://dart-review.googlesource.com/44660
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=alexmarkov@google.com,regis@google.com

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

Change-Id: I412f5143442ca6ad43784b037c01fcf9bb42c348
Reviewed-on: https://dart-review.googlesource.com/45800
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-03-09 08:59:58 +00:00
Régis Crelier be62fff82f Reland "[VM runtime] Switch intrinsics from old to new Bigint implementation."
The change was reverted (thanks Slava) because gen_snapshot was failing to
find the core lib class _BigIntImpl on flutter.
The PR https://github.com/flutter/engine/pull/4735 fixed that issue on flutter.

Change-Id: Id6863d79f7fdb17f0076b63b0168394d5e95ec8d
Reviewed-on: https://dart-review.googlesource.com/44660
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-03-02 00:01:54 +00:00
Vyacheslav Egorov 4a11a27b53 Revert "[VM runtime] Switch intrinsics from old to new Bigint implementation."
This reverts commit 9ba8c08953.

Reason for revert: broke Flutter, to reproduce build Flutter engine with HEAD dart and try running animation benchmark in release or profile mode in --preview-dart-2, gen_snapshot would crash. Similarly this also breaks Flutter tests in --preview-dart-2 mode.

Original change's description:
> [VM runtime] Switch intrinsics from old to new Bigint implementation.
> 
> Change-Id: I43dfbdf76267bb96d1b1ce4aeb695d02bb18b7f8
> Reviewed-on: https://dart-review.googlesource.com/44025
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Régis Crelier <regis@google.com>

TBR=alexmarkov@google.com,regis@google.com

Change-Id: I926cc72e1ed89d8631e33ebcc8198853c05a08dc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/44065
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2018-02-28 11:27:45 +00:00
Régis Crelier 9ba8c08953 [VM runtime] Switch intrinsics from old to new Bigint implementation.
Change-Id: I43dfbdf76267bb96d1b1ce4aeb695d02bb18b7f8
Reviewed-on: https://dart-review.googlesource.com/44025
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-02-28 01:37:06 +00:00
Paul Berry ba2417fdc0 Fix SDK errors due to inconsistent inheritance of Operator==.
The informal spec for strong mode top level inference
(https://github.com/dart-lang/sdk/pull/28218) says "If there are
multiple overridden/implemented methods, and any two of them have
non-equal types (declared or inferred) for a parameter position which
is being inferred for the overriding method, it is an error."

This CL fixes several SDK errors that arise from this rule.  For
example, the classes _Closure, Function, and Object contained members
declared as follows:

    class _Closure implements Function {
      bool operator ==(other) ...
    }
    class Function {
      bool operator ==(Object other) ...
    }
    class Object {
      bool operator ==(other) ...
    }

The type of Object's operator == was (dynamic) -> bool; the type of
Function's operator == was (Object) -> bool; therefore the type of
_Closure's operator == (which overrides both, since _Closure extends
Object and implements Function) cannot be inferred and must be
specified.

A similar situation exists for _Double and _IntegerImplementation
(both implement num, which declares operator == to have type (Object)
-> bool), and _Uri (which implements Uri, which declares operator ==
to have type (Object) -> bool).

This CL fixes the error by specifying the type explicitly in the
classes _Closure, _Double, _IntegerImplementation, and _Uri.

Change-Id: I91f7ceef8549399d438ba4be8c408493b3f338db
Reviewed-on: https://dart-review.googlesource.com/28100
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-11 13:02:19 +00:00
Vyacheslav Egorov cc35ba4a1e [vm] Split _List&_GrowableList []= into checked and unchecked parts
This allows us to avoid going into runtime even if strong mode is
enabled: type checking is handled in the []= operator itself and
_setIndexed does not need to check types and thus can be intrinsified.

This CL also removes inline type checking done in ia32 version,
not other platform had it.

# Performance Impact

Mostly noticable on Dart v2 AOT configuration where AOT compiler
did not inline []=:

Richards  +26.27%
Meteor  +33.63%
BuildTableInterpolation +68.98%
DeltaBlueClosures +46.43%
StarryStrings +22.08%
NavierStokes  +94.81%
JsonParseCustomReviver  +45.22%
DeltaBlue +56.44%
BuildTableBufferWithCodes +84.40%
JsonParseDefaultReviver +46.13%
BuildTableBuffer  +125.8%
BuildTableIdiomatic +125.8%
StringBuffer  +127.3%
StringIdiomatic +127.2%
JsonObjectRoundTrip +95.42%
JsonStringifyFinancialOnce  +125.7%
JsonRoundTrip +96.01%

Bug:
Change-Id: Ie6d33ac55b5a0c0909ca06e0c88a60d8e0d2604e
Reviewed-on: https://dart-review.googlesource.com/26800
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2017-12-07 13:09:55 +00:00
Lasse R.H. Nielsen ad932a8c7a Fix fingerprints correctly
Change-Id: I5e1f443b1b6907953a9758abe15dcdd2d23289d6
Reviewed-on: https://dart-review.googlesource.com/20701
Reviewed-by: Erik Ernst <eernst@google.com>
2017-11-14 14:02:17 +00:00
Lasse R.H. Nielsen 0b58c4bd10 Change some constant declarations to lowerCase.
Retain the old values.

Reapply of https://dart-review.googlesource.com/c/sdk/+/20680 with fixes
for VM method fingerprints.

Change-Id: Ie14e7ccc3194d5561983348e6b6752728913ff4d
Reviewed-on: https://dart-review.googlesource.com/20664
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2017-11-14 12:59:14 +00:00
Régis Crelier f734e7ee38 [VM] Treat 'deferred' as a built-in identifier (fixes #31267 and #25732).
Reject built-in identifiers as prefix names (fixes #25733).
Update co19 status file.

Change-Id: I7fe5014d128bfdad442866e78196fb8dd2764dda
Reviewed-on: https://dart-review.googlesource.com/19860
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2017-11-09 23:29:52 +00:00
Alexander Markov 28793ea130 [VM] Add option to print precompiler entry points
Change-Id: Ieba8d086e34e669c0789db96ddbb00932a764cfa
Reviewed-on: https://dart-review.googlesource.com/18511
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-07 19:41:09 +00:00
Paul Berry 23d3baddb6 Update source fingerprints for min and max functions.
This should fix debug build failures after 3e85ad23cf.

Change-Id: I05797004359bb88007077b5176aaa9499a2162bc
Reviewed-on: https://dart-review.googlesource.com/18519
Reviewed-by: Alan Knight <alanknight@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-11-03 23:12:34 +00:00
Martin Kustermann 56050f47fb [VM] Let FlowGraphTypePropagator know that LinkedHashMap.index is kTypedDataUint32ArrayCid
Now that we do eager rehashing of linked hashmaps we no longer have the
index field be `null` (which in the past signaled we needed rehashing).

This means we can teach the optimizer that loads from the index fied
always result in kTypedDataUint32ArrayCid.

Change-Id: Ic012881c12b2310a6337696521fa1355afd4069f
Reviewed-on: https://dart-review.googlesource.com/17447
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-01 15:52:14 +00:00
Alexander Markov c84e2968ac [VM] Avoid dynamic call in _Double.==
Change-Id: Iab301370f33c375db1cd52f8eb87500955dfab09
Reviewed-on: https://dart-review.googlesource.com/17722
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-10-31 22:01:09 +00:00
Alexander Markov 6505994d58 [VM] Correct return type of _setHash
Change-Id: I3f02d584d30fc7a2f3bd93858eaf77abe3c9f5b7
Reviewed-on: https://dart-review.googlesource.com/17720
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-10-31 22:01:08 +00:00
Kasper Lund 1db8615e29 Avoid just truncating to the nearby int in double.hashCode.
Preserves the property that doubles and ints that are equal
share the same hash code, but gives different doubles a much
higher chance of having different hash codes.

BUG=https://github.com/dart-lang/sdk/issues/2884

Change-Id: Ia97164087db568f26ffbbd6854ed9c19f81e9611
Reviewed-on: https://dart-review.googlesource.com/15140
Commit-Queue: Kasper Lund <kasperl@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-10-23 06:47:20 +00:00
Vyacheslav Egorov 826b48ee8a [VM] Clean up typing violations in the numerics implementation.
Bug: https://github.com/dart-lang/sdk/issues/31052
Change-Id: I93d7bca2ff627431f1a316bb01a5dada1b5f2354
Reviewed-on: https://dart-review.googlesource.com/14522
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-10-17 21:00:24 +00:00
Alexander Markov 86fde60e4d [VM] Intrinsify Type.hashCode
This CL optimizes Type.hashCode similarly to String.hashCode, by
introducing intrinsic version of hashCode calculation which uses
hashcode stored in Type instance.

This is important for Flutter's .of pattern, which heavily uses
Maps with Type keys.

Results on Flutter stocks/build_bench.dart microbenchmark:
Before: 4906 µs
After:  4751 µs
(minimum of 5 runs, using tip of Flutter and Flutter engine)

Issue: https://github.com/dart-lang/sdk/issues/31011
Issue: https://github.com/flutter/flutter/issues/11572
Change-Id: Ifbaf721050007db49bbd969dc669d070f4ce839e
Reviewed-on: https://dart-review.googlesource.com/12622
Reviewed-by: Zach Anderson <zra@google.com>
2017-10-10 23:46:09 +00:00
Vyacheslav Egorov 552d09715d [VM] Cleanup SIMD related IL instructions.
This CL unifies 31 diverse Simd instructions into a single flexible SimdOp instruction.

These instructions were not different enough to warrant being implemented 
as separate IL instructions. The separation did not bring any benefit but
instead we payed the price with considerable amounts of duplicated code 
across the pipeline.

Main motivation for this refactoring is to reduce the surface of our IL.

Bug:
Change-Id: Ie8e39fecd2a51cb8edffdfe9c22e76835f912a9b
Reviewed-on: https://dart-review.googlesource.com/10120
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2017-10-07 13:25:13 +00:00
Alexander Markov 48f76f6b41 [VM, Compiler] Refactor and reuse token kind recognition
This CL moves method token kind recognition from kernel_to_il.cc
to method_recognizer.cc and reuses it in aot_call_specializer.cc.
Also, similar code in il.cc (TryFastPathSmiOp) is refactored to use
token kind.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: Ic7e75537259732daf2f87bce334deccf194bbca3
Reviewed-on: https://dart-review.googlesource.com/4602
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-09-10 23:54:03 +00:00
Vyacheslav Egorov 8a179fb953 [VM, Compiler] Move compiler to a separate folder.
New folder structure (nested under vm/):

- compiler/
-   jit/         - JIT specific code
-   aot/         - AOT specific code
-   backend/     - all middle-end and back-end code (IL, flow graph)
-   assembler/   - assemblers and disassemblers
-   frontend/    - front ends (AST -> IL, Kernel -> IL)

compiler/README.md would be the documentation root for the compiler
pipeline

Bug: https://github.com/dart-lang/sdk/issues/30575
Change-Id: I2dfd9688793bff737f7632ddc77fca766875ce36
Reviewed-on: https://dart-review.googlesource.com/2940
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-09-04 15:15:18 +00:00