Commit Graph

89 Commits

Author SHA1 Message Date
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
Alexander Markov fc27a2c9d4 [vm/corelib] Fix int/double comparisons in num.compareTo
* double.compareTo(int) is fixed to handle integers which are not
  precisely representable as doubles.

* int.compareTo(double) is fixed to properly handle doubles which
  are clamped when converted to integers (with Dart 2.0 fixed-size
  integers).

* Test for num.compareTo is updated for fixed-size integers; more corner
  cases added.

Closes https://github.com/dart-lang/sdk/issues/31917

Change-Id: I8e98c3627f032082ab6a397713dece436585afd1
Reviewed-on: https://dart-review.googlesource.com/35004
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-01-22 18:22:28 +00:00
Alexander Markov 2e5264ddea [vm/corelib] Fix int.toRadixString() for MIN_INT64
Closes https://github.com/dart-lang/sdk/issues/31346

Change-Id: Ib925bdacf6503262a3bfb39be032a9607c0420da
Reviewed-on: https://dart-review.googlesource.com/35063
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-01-17 21:50:08 +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
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
Lasse R.H. Nielsen e61fc07b58 Revert "Change some constant declarations to lowerCase."
This reverts commit c048cfb178.

Reason for revert: VM code fingerprints needs update.

Original change's description:
> Change some constant declarations to lowerCase.
> 
> Retain the old values.
> 
> Change-Id: I03bd326f379fe5f96d8f6081a7133de956d745c0
> Reviewed-on: https://dart-review.googlesource.com/11520
> Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
> Reviewed-by: Florian Loitsch <floitsch@google.com>

TBR=lrn@google.com,floitsch@google.com

Change-Id: I095e8198304ca4e59b39d30b0fdf0af4945e5231
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/20680
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2017-11-14 11:23:08 +00:00
Lasse R.H. Nielsen c048cfb178 Change some constant declarations to lowerCase.
Retain the old values.

Change-Id: I03bd326f379fe5f96d8f6081a7133de956d745c0
Reviewed-on: https://dart-review.googlesource.com/11520
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Florian Loitsch <floitsch@google.com>
2017-11-14 11:13:04 +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
Peter von der Ahé e8aef37eac Clean up patches so they can be compiled by Fasta.
Change-Id: Ie436375c78496366accf0ba82938e54cbe30b143
Reviewed-on: https://dart-review.googlesource.com/3001
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2017-10-05 14:05:50 +00:00
Florian Schneider 80b43ff15c Reland "VM: Handle null-comparisons in the flow graph type propagation"
This reverts commit ee452a8600.

Original CL: https://codereview.chromium.org/2772143002/

Additional bug fix: Correctly replace ToCid with ToNullableCid in
RedefinitionInstr::ComputeType.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2789943002 .
2017-03-31 15:39:01 -07:00
Florian Schneider ee452a8600 Revert "Reland "VM: Handle null-comparisons in the flow graph type propagation""
This reverts commit e7afde47e9.

This was because of analyzer test failures (out of memory in the background compiler)

TBR=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2794583002 .
2017-03-31 10:53:56 -07:00
Florian Schneider e7afde47e9 Reland "VM: Handle null-comparisons in the flow graph type propagation"
This reverts commit 30a942f728.

Plus:

1. Fixes integer type propagation in the optimizer by introducing a _int64 marker interface

2. Fixes calculation of whether an instructions can deoptimize: This has to be stable so that
once determined that an instructions can't deoptimize, it will stay that way and not flip back
later in the optimization

3. Address comments to improve CompileType::CopyNonNullable()

R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2772143002 .
2017-03-31 10:12:59 -07:00
Jacob Richman a129931cda The formatter struggles a bit with these files.
BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2765523003 .
2017-03-21 18:00:52 -07:00
Lasse Reichstein Holst Nielsen 3eee2e69b2 Avoid bigints entering non-bigint gcd implementation.
R=regis@google.com

Review URL: https://codereview.chromium.org/2557713002 .
2016-12-08 07:36:18 +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
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
Lars Bak bc6358e5ef Sped up hashCode by removing megamorphic call to _identityHashCode.
Microbenchmark measuring megamorhic hashCode access shows 25% speedup.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/2137673002 .
2016-07-08 15:19:55 -07:00
Stephen Adams 38fdb4bd4a vm: Generate 'and' instruction for Smi values.
This pattern ensures the generation of 'and' instructions on the Smi x Smi path of a polymorphic & operation.

There are two 'and' operations on most simple _InternalLinkedHashMap and _CompactLinkedHashSet operations. One of the inputs, the hashCode, is occasionally a _Bigint.  This change ensures that the usual case path has an 'and' instruction instead of a call to _IntegerImplementation.&

R=regis@google.com

Review URL: https://codereview.chromium.org/1913663002 .
2016-07-04 16:27:57 -07:00
Regis Crelier fcb02325cc Cleanup various argument and range errors in double.dart and integers.dart.
R=hausner@google.com

Review URL: https://codereview.chromium.org/1985823002 .
2016-05-16 14:31:26 -07:00
Florian Schneider 1217e539e9 VM: Remove _leftShiftWithMask32.
It was used for the Javascript integer overflow warnings which were already
removed from the VM.

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

Review URL: https://codereview.chromium.org/1900863004 .
2016-04-19 19:06:53 +02: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
Florian Schneider be298b60e9 VM: Remove unnecessary _Num class from runtime/lib.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1874853002 .
2016-04-08 16:25:52 -07:00
Stephen Adams dce10bba79 VM library tweaks to avoid megamorphic calls in dart2js
Problems this addresses:

1. dart2js has hashCode functions like

   get hashCode = this.x.hashCode + 17 * this.y.hashCode

When x and y are ints or bools VM optimizing compiler inlined the call
to Object.hashCode and generated MegamorphicLookups for
Object._identityHashCode.

2. HashMaps with _Smi keys had a double MegamorphicLookup: The hash
table reasonably calls MegamorphicLookup(get:hashCode) which returns
Object.hashCode; the compiled Object.hashCode is essentially
MegamorphicLookup(get:_identityHashCode), which returns
_Smi._identityHashCode which finally returns 'this'.

3. _interpolateSingle's call to o.toString() is megamorphic. We can
avoid it for the common case of String arguments, this is often
comming from StringBuffer.write() with a literal or interpolated
argument.

R=srdjan@google.com

Review URL: https://codereview.chromium.org/1820653002 .
2016-03-21 09:38:13 -07:00
Srdjan Mitrovic caa3cce77e Fix some TODOs
BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org//1263963003 .
2015-08-04 17:13:22 -07:00
Lasse R.H. Nielsen 3c976019cc Make int.gcd accept zero as an operand, including both operands being zero.
R=floitsch@google.com, regis@google.com, sgjesse@google.com

Review URL: https://codereview.chromium.org//1211473002.
2015-07-07 09:51:13 +02:00
Lasse R.H. Nielsen ede6cb71a5 Make modInv throw Exception on incompatible operands.
Also update errors to be more descriptive accross the integer methods.

I'm still considering whether a more precise "NotCoPrimeException" would be better.

R=regis@google.com, sgjesse@google.com

Review URL: https://codereview.chromium.org//1209523002.
2015-06-30 14:46:14 +02:00
Regis Crelier a192ef4acb Implement gcd in sdk.
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1199513003.
2015-06-19 13:40:01 -07:00
Regis Crelier 16bb52b88d Implement modInverse for an even modulus.
Update test.

Fixes #23502

R=srdjan@google.com

Review URL: https://codereview.chromium.org//1188843004.
2015-06-17 13:50:30 -07:00
Regis Crelier 9edc6e5a6d Detect zero receiver of modInverse (may not converge and time out
in that case).

See #23502

Review URL: https://codereview.chromium.org//1177063002.
2015-06-10 16:40:24 -07:00
Regis Crelier f6f338ce67 Implement modInverse (bigint version does not support even modulus yet).
Added tests.

See #23502

R=srdjan@google.com

Review URL: https://codereview.chromium.org//1174513004.
2015-06-10 15:01:46 -07:00
regis@google.com 8e5cd57b7e Add modPow(int exponent, int modulus) method to int abstract class.
Provide a dart2js implementation.

R=floitsch@google.com, lrn@google.com

Review URL: https://codereview.chromium.org//896393004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43572 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-06 21:46:32 +00:00
regis@google.com a5ee233d1b Make Bigint instances immutable by removing all setters.
This required rewriting a large portion of bigint.dart.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//842033005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43492 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-04 23:56:23 +00:00
regis@google.com a1c9e2b6b0 Simplify double to bigint conversion.
Remove 3 bigint mutators.
Remove unused support to create vm internal error.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//821123003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42842 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-13 21:29:44 +00:00
regis@google.com 8a96f1947c Revert modPow introduction since dart2js does not like it.
Review URL: https://codereview.chromium.org//851763002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42827 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-13 17:47:11 +00:00
regis@google.com 485be555bf Add modPow(int exponent, int modulus) method to int abstract class.
R=lrn@google.com

Review URL: https://codereview.chromium.org//834323002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42823 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-13 17:13:59 +00:00
regis@google.com defc9a5c54 Specialize _toPow2String for bigint to make it linear instead of quadratic.
Remove some duplicated bigint corelib tests.
Cleanup corelib tests status file.
Partially fix issue 20879 (not closed).

R=zra@google.com

Review URL: https://codereview.chromium.org//723963006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41728 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-13 23:54:33 +00:00
regis@google.com 21369fc864 Temporarily add a public modPow method to int interface.
Make Bigint modPow support non-bigint arguments.

R=srdjan@google.com

Review URL: https://codereview.chromium.org//570563004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40335 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-16 18:19:12 +00:00
regis@google.com 9ff3cd3342 Fix wrong conversion from double to bigint in overriden operators of new bigint.
Fix ambiguous call to pow on Windows.
Fix big_integer_vm_test to use numbers large enough to actually be bigint.
Re-enable dart2js tests.

R=srdjan@google.com

Review URL: https://codereview.chromium.org//559203003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40122 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-10 22:26:59 +00:00
regis@google.com 0220e41d72 New bigint implementation in the vm.
R=srdjan@google.com

Review URL: https://codereview.chromium.org//509153003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40061 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-09 21:47:44 +00:00
koda@google.com a4f45a89a0 Optimize number-to-string conversions.
Add lookup table for ints in [-99, 99] and a cache for doubles.

R=iposva@google.com

Review URL: https://codereview.chromium.org//518093002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39710 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-29 21:13:33 +00:00
koda@google.com c22d3cf74a Avoid UTF-8 decoding in num.toString.
4-7% speedup on SplayHarder.

Introduce _Num class to make Dart and VM hierarchies match and enable sharing code between integers and doubles.

R=iposva@google.com

Review URL: https://codereview.chromium.org//473673004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39383 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-19 21:15:39 +00:00
fschneider@google.com fc7d8c61ba Make compile-time constants in _IntegerImplementation.compareTo const.
Review URL: https://codereview.chromium.org//298203002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36864 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-02 11:10:06 +00:00
lrn@google.com 5f34d56f70 Avoid comparing smi to mint in smi.toString().
As it happens 10^10 has 11 digits, not 10.

R=ajohnsen@google.com

Review URL: https://codereview.chromium.org//247083002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35249 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-22 09:26:31 +00:00
lrn@google.com 13d8eae15a Faster _Smi.toString()
Add tests.

R=ajohnsen@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org//183973030

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33416 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-07 09:31:53 +00:00
lrn@google.com 86edf90273 Add num.sign getter.
BUG= http://dartbug.com/15580
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//113833002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31126 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-13 12:10:23 +00:00
srdjan@google.com 16f4e5c690 Constant fold strict comparison based on incoming types: different (exact) types means that the result is false. LoadStaticField computes type for final fields. Make a temporary buffer final.
R=kmillikin@google.com

Review URL: https://codereview.chromium.org//57703004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30119 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-08 17:42:45 +00:00
srdjan@google.com 2b9fad92c7 In preparation of inlining remainder and modulo binary Smi operations:
- Add REM token
- Fix checking of function fingerprints.
- Remove unused intrinsic for remainder (the function gets inlined and intrinsic is not generated)

R=hausner@google.com

Review URL: https://codereview.chromium.org//59933004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29929 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-05 19:27:46 +00:00