Commit Graph

45 Commits

Author SHA1 Message Date
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 9ee735b659 Add missing methods to List and Map implementations.
Optimize FollowedBy when the operands have efficient length.

Change-Id: I0af59240d70b929358c06b8d57a85df2deee6aaf
Reviewed-on: https://dart-review.googlesource.com/43665
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-02-28 12:26:53 +00:00
Dmitry Stefantsov 47fbe76d03 Avoid patching with redirecting factories in vm-related patches
Change-Id: Id45696a38b281b1b75a9a0e26d89216388a4ec19
Reviewed-on: https://dart-review.googlesource.com/39942
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-02-08 14:11:50 +00:00
Vyacheslav Egorov dcfb7b9a4c [VM] Fix typing violations in string_patch.dart.
Bug: https://github.com/dart-lang/sdk/issues/31052
Change-Id: I1a0a94ce19bb54cb4273d1508b6ed08b94c60307
Reviewed-on: https://dart-review.googlesource.com/14840
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2017-10-19 06:42:37 +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
Aske Simon Christensen cec963f028 The current growth strategy for growable arrays allocates a backing array of size 2 at (empty) creation and doubles the size whenever the capacity is insufficient while adding elements.
I collected statistics for the sizes and capacities of growable arrays which are promoted to old-space or survive an old-space gc when running dart2js and Fasta. For these applications, the vast majority of arrays stay empty. More than half of the total object size of promoted backing arrays is backing for empty growable arrays.

Furthermore, since the overhead for an array is 3 words (header, type parameters and length), and object sizes are rounded up to an even number of words, we waste one word for all even-sized arrays.

This CL changes the growth strategy so that empty growable arrays are created with a shared, zero-sized array as backing, avoiding the allocation of a backing array if no elements are added. When the array needs to grow, it starts out at 3 and grows to double size plus one each time: 7, 15, 31, ...

A few places in the VM code need to handle these shared, zero-sized arrays specially. In particular, the Array::MakeArray function needs to allocate a new, empty array if its result is to be returned to Dart code.

Benchmarks suggest that the change improves memory usage by a few percent overall and does not significantly affect run time.

BUG=
R=erikcorry@google.com

Review-Url: https://codereview.chromium.org/2949803002 .
2017-06-22 10:51:54 +02:00
Jacob Richman 4360e99d18 Revert "Fix observatory tests broken by running dartfmt."
This reverts commit b1f7e6d94673b098c93c187fe3efc45c15f27edc.

BUG=

Committed: https://github.com/dart-lang/sdk/commit/62be0eacfbb36bdc92a05c7c35bb4506621b6a3a
Review-Url: https://codereview.chromium.org/2767533002 .
2017-03-21 10:07:26 -07:00
Jacob Richman 62be0eacfb Revert "Fix observatory tests broken by running dartfmt."
This reverts commit b1f7e6d94673b098c93c187fe3efc45c15f27edc.

BUG=

Review-Url: https://codereview.chromium.org/2767533002 .
2017-03-20 22:19:22 -07:00
Jacob Richman 88f8aacd5f Re-apply rolled back CL to apply dartfmt to runtime.
Fix observatory tests broken by running dartfmt due to line and column changes.
Temporarily reverted formatting for evaluate_activation_test.dart as dartfmt doesn't yet handle multitests.

BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2759973004 .
2017-03-20 21:44:59 -07:00
Ryan Macnak ea4744a06f Revert "Run dartfmt on all files under runtime."
This reverts commit 15f393f189.

The change caused many service test failures due to changed line numbers.

TBR=jacobr@google.com

Review-Url: https://codereview.chromium.org/2762583003 .
2017-03-20 13:42:55 -07:00
Jacob Richman 15f393f189 Run dartfmt on all files under runtime.
I've omitted files where the formatter output is significantly uglier
than the original code and I'll send those files in a separate CL
with options for how to make the code look reasonable while still
taking advantage of the formatter.

BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2751423005 .
2017-03-20 13:13:50 -07:00
Kevin Millikin 50348f5f22 Fixes to patch files necessary to use the analyzer
The analyzer has a stricter patch parser than the VM.  Patch files
cannot change signatures of patched members.  Specifically, they cannot
change:

  - the return type
  - a parameter's name
  - a parameter to an initializing formal
  - an optional parameter's default value

BUG=
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2612043002 .
2017-01-05 12:23:51 +01:00
Lasse Reichstein Holst Nielsen 7957a1c256 Make EfficientLength extend Iterable.
This should help least-upper-bound computations to not think of EfficientLength
as completely separate from Iterable even though they are always used together.

It doesn't solve all problems with the least-upper-bound computation,
but at least some of the more often occuring ones.

R=floitsch@google.com

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

Committed: https://github.com/dart-lang/sdk/commit/b08fb1373f88121bb4056adce9b71849a5bede2a
2016-11-28 08:04:04 +01:00
Ryan Macnak 6cf5c3baa3 Revert "Make EfficientLength extend Iterable."
This reverts commit b08fb1373f.

TBR=lrn@google.com

Review URL: https://codereview.chromium.org/2467283003 .
2016-11-02 13:20:41 -07:00
Lasse R.H. Nielsen b08fb1373f Make EfficientLength extend Iterable.
This should help least-upper-bound computations to not think of EfficientLength
as completely separate from Iterable even though they are always used together.

It doesn't solve all problems with the least-upper-bound computation,
but at least some of the more often occuring ones.

R=floitsch@google.com

Review URL: https://codereview.chromium.org/2467113003 .
2016-11-02 14:05:35 +01:00
Matthias Hausner 1a6d1eca32 Implement @patch annotation for patch class members
Allow members of patch classes to be annotated with @patch. The VM
ignores the annotation. I simply replaces the original method
if the name matches, or reports an error if field names match.

Adding a bit is_patched to members to do more checking remains a
TODO. There are currently no unused bits available, and I don’t want
to increase the size of Function objects for this.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/2230383003 .
2016-08-10 12:54:57 -07:00
Matthias Hausner e11ca24053 Use metadata annotation @patch for patch classes
Annotate patch classes and top-level patch functions with @patch
instead of the pseudo-keyword patch. This allows the analyzer
to read patch files, and matches the syntax that dart2js uses.

The deprecated syntax is still supported, but a warning is printed when detected.

BUG=

Review URL: https://codereview.chromium.org/2220883004 .
2016-08-09 09:48:03 -07:00
Lasse R.H. Nielsen fbf64bb7a5 Make Iterable.toList more efficient if the length is known.
Add more tests. Fix (some) bugs found by tests.

R=floitsch@google.com

Review URL: https://codereview.chromium.org/1999793002.
2016-05-23 10:00:19 +02:00
Lasse R.H. Nielsen 50aa43569d Add "growable" parameter to List.filled constructor.
Fixes issue #24884
BUG= http://dartbug.com/24884
R=floitsch@google.com

Review URL: https://codereview.chromium.org/1440663003 .
2015-11-13 09:30:46 +01:00
Ivan Posva e974b952a7 - Prevent getting an unmodifiable list being returned from List.from.
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1275703002 .
2015-08-05 13:25:32 -07:00
Lasse R.H. Nielsen babcd4e9c0 Revert "Make EfficientLength public, as EfficientLengthIterable."
It's still not a good solution for detecting an Iterable with an efficient
length. It's not inherited by, e.g., a DelegatingIterable wrapper or similar
generic Iterable transformers.

Keep this as an internal optimization for quickly detecting the most common
efficient-length Iterable classes (List, Set, Queue, Map.keys/values), but
don't make it public.

A *real* solution would be adding a hasEfficientLength getter to Iterable, or
adding an efficientLength getter that may return null if it's not efficient.
This would something that a wrapper can attach to.

R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1154263003
2015-05-29 12:52:45 +02:00
lrn@google.com 92c526b2a2 Make EfficientLength public, as EfficientLengthIterable.
R=iposva@google.com, sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45556 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-06 09:00:45 +00:00
lrn@google.com f139d0e93b Add List.unmodifiable constructor.
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45334 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-22 10:48:22 +00:00
lrn@google.com 3f1780f70d Change List/Set/Map/Queue.from constructrs to accept any iterable.
This allows using the .from constructor as a cast:

  new Set<int>.from(numSetContainingOnlyInts);

BUG= http://dartbug.com/21731
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42620 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-06 10:14:56 +00:00
lrn@google.com 7947f84054 Optimize List.toList/.sublist and List.from on lists.
R=fschneider@google.com, srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39579 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-27 08:00:48 +00:00
iposva@google.com e7e2e4bf03 - Rename arrays to lists:
_ObjectArray -> _List
  _GrowableObjectArray -> _GrowableList
  _ImmutableArray -> _ImmutableList

R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28189 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-03 00:15:14 +00:00
floitsch@google.com f74e8a023b Revert "- Do not keep growing when creating Lists from Iterables."
This reverts commit r21531.

BUG= http://dartbug.com/10070

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21817 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-22 16:52:03 +00:00
iposva@google.com 6adbe1b84f - Do not keep growing when creating Lists from Iterables.
Review URL: https://codereview.chromium.org//14210006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21531 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 23:55:48 +00:00
iposva@google.com 5c71abedff - Do not use the ? operator in the List factory.
Review URL: https://codereview.chromium.org//12335146

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19178 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-27 22:36:22 +00:00
lrn@google.com 6b4f4b1bab Change new List(n) to return fixed length list.
Deprecate List.fixedLength, add List.filled.

Make Iterable.toList and List.from take "growable" argument,
defaulting to false.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19112 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-27 08:45:04 +00:00
floitsch@google.com e024c74a5f Remove List.filled constructor.
Review URL: https://codereview.chromium.org//12041019

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17871 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-30 20:10:27 +00:00
srdjan@google.com 2ad98117fd Fix performance of array literals (e.g. "[1, 2]"). Improves speed of DeltaBlue.
Simplify code to allocate groable object array from an object array.
Review URL: https://codereview.chromium.org//11882005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16999 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-11 23:39:00 +00:00
srdjan@google.com 8a831fe908 Factor out length check in list factories: reduce bloat, factorize code, improve performance.
Review URL: https://codereview.chromium.org//11773045

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16810 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-08 17:47:03 +00:00
srdjan@google.com 020b5893db Cleanups.
Review URL: https://codereview.chromium.org//11801023

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16756 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-07 22:13:47 +00:00
floitsch@google.com 4a7dfd2da3 Big merge from experimental to bleeding edge.
Review URL: https://codereview.chromium.org//11783009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16687 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-07 11:23:16 +00:00
ajohnsen@google.com 0f367f8894 Make List an abstract class.
This was the last interface in dart:core.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15240 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-22 07:40:52 +00:00
regis@google.com 02a8df0c83 Remove private class helping the parser to construct literal lists and maps.
Patch List and Map (implementation) classes with literal factories.
Review URL: https://codereview.chromium.org//11369234

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14873 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-14 04:28:02 +00:00
floitsch@google.com 8e6f238f86 a === b -> identical(a, b)
Replace === null with == null.

BUG=http://dartbug.com/6380

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14794 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-12 17:19:58 +00:00
ajohnsen@google.com dbbf15abd8 Move ListImplementation from coreimpl to core, as a private member.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14274 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-30 13:25:04 +00:00
ager@google.com 35e073bf80 Minor style and comment fixes from review comments.
R=iposva@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13161 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-03 08:08:34 +00:00
ager@google.com abee5139e5 Reapply change to hide VM-only List implementation classes.
The performance issue was that I had not updated the method
recognizer.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13003 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-28 11:08:38 +00:00
ager@google.com fe66a0af1a Revert hiding of VM-only coreimpl list implementation types. While I
investigate performance regression (even after fixing constructors
in the intrinsifier).

R=iposva@google.com,srdjan@google.com,fschneider@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12963 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-27 14:07:56 +00:00
ager@google.com 8e6a2c8345 Hide VM-only coreimpl List implementation types. These should not be
exposed as visible parts of coreimpl.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12952 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-27 12:37:30 +00:00
srdjan@google.com 3051c69910 Improve moves of Smi and null objects. Add result cid to List constructor calls. Add tracing of inline cache misses in optimized code (a big no-no).
Review URL: https://chromiumcodereview.appspot.com//10933019

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12208 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-11 15:41:34 +00:00
ajohnsen@google.com 660f03288e Unify list.
I've added a TODO that we'll have to address asap. This patch will
currently limit the checks being performed with List.from(other).

BUG=

Review URL: https://chromiumcodereview.appspot.com//10878077

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11384 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-27 14:06:03 +00:00