Commit Graph

34 Commits

Author SHA1 Message Date
Jenny Messerly 393a47441f fix #33138, local class name should not conflict with inline-JS in SDK
Also this removes the workaround for dart:html that used a RegExp to
attempt to match inline-JS code that might trigger the problem.

Change-Id: I74b447928aaeaca43b3a9241d42526c284dbeffa
Reviewed-on: https://dart-review.googlesource.com/55504
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Jenny Messerly <jmesserly@google.com>
2018-05-16 22:04:05 +00:00
Lasse Reichstein Holst Nielsen 862a894de6 Make cast do the same things as retype.
Deprecate `retype` and forward it to `cast`.

Change-Id: Ie17ffdd1eef0d3f19582bf638c5349927c7b5ebd
Reviewed-on: https://dart-review.googlesource.com/53802
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-05-09 08:00:08 +00:00
Leaf Petersen 4c881188b2 Disable the .whereType method until generic methods are turned on.
The whereType method silently does the wrong thing without methods,
so make it throw until we turn them on everywhere.

Change-Id: Id934c8bdb4f682dbc3560d78fbca580e37297e2d
Reviewed-on: https://dart-review.googlesource.com/45744
Reviewed-by: Nate Bosch <nbosch@google.com>
2018-03-08 23:14:22 +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
Lasse R.H. Nielsen 6f78471687 New methods on Iterable, List, Set, Queue, Map.
Changes signature of Iterable.singleWhere.
Makes LinkedHashMap no longer be a HashMap.

Change-Id: I7a12fea533d42b0fc8357086649df38ad01f3cdd
Reviewed-on: https://dart-review.googlesource.com/39140
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2018-02-07 06:12:53 +00:00
William Hesse 9c35cff5cd Revert "New methods on Iterable, List, Set, Queue, Map."
This reverts commit 0b59f24f97.

Reason for revert: Creates crashes in dart2js with kernel, see
https://luci-milo.appspot.com/buildbot/client.dart/dart2js-linux-d8-minified-1-5-be/9751

Original change's description:
> New methods on Iterable, List, Set, Queue, Map.
> Changes signature of Iterable.singleWhere.
> Makes LinkedHashMap no longer be a HashMap.
> 
> Change-Id: Ibd7e56e1ac03cb9fb10d19d1328d452fcd06d89f
> Reviewed-on: https://dart-review.googlesource.com/32541
> Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
> Reviewed-by: Leaf Petersen <leafp@google.com>

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

Change-Id: Iab904f5885a5213ae2e16ef496eed0b6843185f3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/39060
Reviewed-by: William Hesse <whesse@google.com>
2018-02-06 13:32:19 +00:00
Lasse R.H. Nielsen 0b59f24f97 New methods on Iterable, List, Set, Queue, Map.
Changes signature of Iterable.singleWhere.
Makes LinkedHashMap no longer be a HashMap.

Change-Id: Ibd7e56e1ac03cb9fb10d19d1328d452fcd06d89f
Reviewed-on: https://dart-review.googlesource.com/32541
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-02-06 11:17:46 +00:00
Jennifer Messerly 3a907e5cab add a script to build DDC's SDK to a dill file
Change-Id: I93f9d55bd99a3b98ee823c38255e9a8081954a4b
Reviewed-on: https://dart-review.googlesource.com/10213
Reviewed-by: Vijay Menon <vsm@google.com>
2017-10-03 20:27:12 +00:00
Jennifer Messerly 67f82b4eee optimize == in some more cases
Change-Id: Icdda25e85c8d3ab3805c7f0ab180c6e88e47f8ed
Reviewed-on: https://dart-review.googlesource.com/4580
Commit-Queue: Jennifer Messerly <jmesserly@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
2017-09-13 02:02:41 +00:00
Jennifer Messerly ab226fd40c optimize Object members in DDC
This should improve performance of these members in most cases:
- toString
- operator ==
- hashCode
- runtimeType
- noSuchMethod

The helpers for checking `null` and then dispatching to the method are now very small again. Also, because we can lookup symbolized names always, we can start taking advantage of this in our Map/Set implementations (for a follow up CL).

This also improves correctness of these helpers given JavaScript objects; we were previously falling back to calling a Dart method name like `.hashCode`, which is incorrect (except for `toString` where fallback is probably the correct behavior).

Change-Id: I39cbc80ca3e93ca7672652610b02bce899894da1
Reviewed-on: https://dart-review.googlesource.com/3427
Commit-Queue: Jennifer Messerly <jmesserly@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2017-09-06 08:12:11 +00:00
Jennifer Messerly 087c5c6a81 fix list_test for strong mode, and fix DDC List constructors
R=vsm@google.com

Review-Url: https://codereview.chromium.org/3009623002 .
2017-08-25 18:32:43 -07:00
Leaf Petersen 1b8f4ac1e7 Optimize DDC private runtime library files.
Eliminate numerous type checks not needed in strong mode.  Use
private nullability annotations instead of inline JS to mark known
non-null variables, and to make the compiler generate null checks
for null checked variables. Use nullability annotations and code refactoring to
remove redundant null checks and to move checks out of loops.

BUG=
R=jmesserly@google.com

Review-Url: https://codereview.chromium.org/2994203002 .
2017-08-23 10:28:45 -07:00
Jennifer Messerly f0c8fe6763 remove redundant type check in DDC's SDK implementation
Review-Url: https://codereview.chromium.org/2985063002 .
2017-07-25 18:33:09 -07:00
Jennifer Messerly 04f3c8835f implement Invocation.typeArguments in DDC
also fixes various bugs:
* setters now use the correct memberName symbol, fixes #30223
* object members work for callable classes, fixes #30213
* some test fixes to work in strong mode
* a few other small cleanups (e.g. obsolete `dart.list` is removed)

R=vsm@google.com

Review-Url: https://codereview.chromium.org/2979353002 .
2017-07-21 15:51:16 -07:00
Jennifer Messerly 5533a256cb fix #30030, fix #27327 - fix tearoffs and various Object member bugs
this includes various cleanups found along the way:
* various issues with JS annotations, see #30043
* getGenericClass is now optimized when used in a JS builtin with a Type literal
* typed list literals should be slightly faster to create
* memoized getters used by dart:_runtime should be faster
* registerExtension should be a tad faster, and now understands JSArray
* dart.bind "safeName" hack gone in codegenerator
* JSArray<E>.runtimeType returns List<E>
* JSArray<E>.noSuchMethod works
* cleans up code that generates `setExtensionBaseClass` (used only by JSArray)
* _throwUnsafe helper for generating a `throw` in --unsafe compile mode
* fix tearoff of JS interop types (_emitSimpleIdentifier)
* fix TODO about splitting LazyJSType and AnonymousJSType
* fix is/as/cast methods on TypeRep and related classes
* fix codegenerator to not tearoff "hashCode" and "runtimeType" (they are not methods)
* fix NoSuchMethodError.toString()   (update via dart2js sdk impl)

R=vsm@google.com

Review-Url: https://codereview.chromium.org/2962263002 .
2017-07-05 14:17:53 -07:00
Leaf Petersen 6f73694bb7 Generate better code for '==', core.identical, and dart.test.
Avoid falling back to the dart.equal runtime helper where possible based on static types.  Also uses JS `==` or `===` in some cases.

Treat core.identical as a compiler intrinsic, based on type.

Make dart.test assume correct types, use dart.dtest for combined cast and nullability check only when required.

Fixes https://github.com/dart-lang/sdk/issues/29851
Fixes https://github.com/dart-lang/sdk/issues/29772
BUG=
R=jmesserly@google.com

Review-Url: https://codereview.chromium.org/2926613003 .
2017-06-30 15:04:29 -07:00
Vijay Menon a7645f817f Optimize runtime code on hot methods
ochafik: this should include your internal fixes.

Here are generated diffs:

JSArray:
       [dartx._get](index) {
-        if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index));
-        if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index));
+        if (index == null || index >= this.length || index < 0) {
+          dart.throw(_js_helper.diagnoseIndexError(this, index));
+        }
         return this[index];
       }
       [dartx._set](index, value) {
         E._check(value);
         this[dartx.checkMutable]('indexed set');
-        if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index));
-        if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index));
+        if (index == null || index >= this.length || index < 0) {
+          dart.throw(_js_helper.diagnoseIndexError(this, index));
+        }

R=jmesserly@google.com, ochafik@google.com

JSString:
     [dartx.codeUnitAt](index) {
-      if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index));
-      if (dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index));
-      if (dart.notNull(index) >= dart.notNull(this[dartx.length])) dart.throw(_js_helper.diagnoseIndexError(this, index));
+      if (index == null || index < 0 || index >= this.length) {
+        dart.throw(_js_helper.diagnoseIndexError(this, index));
+      }
       return this.charCodeAt(index);
     }
     [dartx.startsWith](pattern, index) {
       if (index === void 0) index = 0;
-      _js_helper.checkInt(index);
-      if (dart.notNull(index) < 0 || dart.notNull(index) > dart.notNull(this[dartx.length])) {
+      let length = this.length;
+      if (dart.notNull(index) < 0 || index > length) {
         dart.throw(new core.RangeError.range(index, 0, this[dartx.length]));
       }
       if (typeof pattern == 'string') {
         let other = pattern;
-        let otherLength = other[dartx.length];
-        let endIndex = dart.notNull(index) + dart.notNull(otherLength);
-        if (endIndex > dart.notNull(this[dartx.length])) return false;
+        let otherLength = other.length;
+        let endIndex = index + otherLength;
+        if (endIndex > length) return false;
         return other == this.substring(index, endIndex);
       }
       return pattern[dartx.matchAsPrefix](this, index) != null;
     }
     get [dartx.isEmpty]() {
-      return this[dartx.length] == 0;
+      return this.length == 0;
     }
     [dartx.compareTo](other) {
-      if (!(typeof other == 'string')) dart.throw(_js_helper.argumentErrorValue(other));
+      if (other == null) dart.throw(_js_helper.argumentErrorValue(other));
       return dart.equals(this, other) ? 0 : this < other ? -1 : 1;
     }
     get [dartx.hashCode]() {
       let hash = 0;
-      for (let i = 0; i < dart.notNull(this[dartx.length]); i++) {
+      let length = this.length;
+      for (let i = 0; i < length; i++) {
         hash = 536870911 & hash + this.charCodeAt(i);
         hash = 536870911 & hash + ((524287 & hash) << 10);
         hash = hash ^ hash >> 6;
         ...
     }
     [dartx._get](index) {
-      if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index));
-      if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index));
+      if (index == null || index >= this.length || index < 0) {
+        dart.throw(_js_helper.diagnoseIndexError(this, index));
+      }
       return this[index];
     }
Review-Url: https://codereview.chromium.org/2927763004 .
2017-06-08 17:31:44 -07: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
Erik Corry 2fb5d08102 Spelling a
R=ahe@google.com
BUG=

Review-Url: https://codereview.chromium.org/2841543002 .
2017-04-24 14:53:51 +02:00
Jacob Richman 66908140e7 Fix dev compiler formatter error.
BUG=

Review-Url: https://codereview.chromium.org/2764203002 .
2017-03-21 20:40:15 -07:00
Jacob Richman 9484ac8bdf Format all dart dev compiler files
BUG=
R=vsm@google.com

Review-Url: https://codereview.chromium.org/2752163002 .
2017-03-15 21:34:25 -07:00
Jennifer Messerly fe294f3753 unfork DDC's copy of most SDK libraries
There's some changes in strong mode errors we may want to follow up on.

Unforks the following: async, collection, convert, core, developer, internal, io, isolate, math, mirrors.

Does not unfork: html, indexed_db, js, js_util, svg, typed_data, web_audio, web_gl, web_sql.

R=vsm@google.com

Review-Url: https://codereview.chromium.org/2698353003 .
2017-02-28 17:10:52 -08:00
Bob Nystrom 2c313a43ac Fix some errors around []= in core types.
- Get rid of JSMutableIndexable since it isn't useful.
- Make JSIndexable generic. (I think dart2js already did.)
- Add .length to NativeTypedArray since it no longer inherits it from
  JavaScriptIndexingBehavior.

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/2378423003 .
2016-09-30 13:03:10 -07:00
Bob Nystrom 33ff9a3d4f Fix type errors in sort().
If a comparer isn't provided, it was silently assuming the element type
implements Comparable, even though that isn't required. Fixed to add a
manual cast at each comparison.

A stricter faster approach might be to check that the type argument
itself is a type that implements Comparable, but I don't know if that's
too pessimistic, or even possible to do.

R=vsm@google.com

Review URL: https://codereview.chromium.org/2311513002 .
2016-09-08 17:14:36 -07:00
Stephen Adams d094888eec Use factory constructor for list literals
The list literal `<int>[1, 2, 3]` was

    dart.list([1, 2, 3], core.int)

now becomes

    JSArrayOfInt().of([1, 2, 3])

R=leafp@google.com

Review URL: https://codereview.chromium.org/2006443002 .
2016-05-25 17:40:46 -07:00
Stephen Adams aa2baf19d3 Updates for js_array.
Copy over most js_array methods.
Remove IterableMixinWorkaround.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1943563002 .
2016-05-05 11:35:37 -07:00
Stephen Adams 1aa00bc447 List.unmodifiable
Most operations don't check, that will happen as more code is updated
to a more recent sdk.

BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1939093003 .
2016-05-03 09:34:44 -07:00
Leaf Petersen 1c119bebb2 Update to latest analyzer
Fixes https://github.com/dart-lang/dev_compiler/issues/393

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1554683002 .
2016-01-05 15:58:50 -08:00
John Messerly 28f1e80cd6 fix some errors in our SDK, mostly around numbers, see issue #103
also improved codegen of JSNumber's methods

R=leafp@google.com

Review URL: https://codereview.chromium.org/1348453004 .
2015-09-18 17:10:02 -07:00
John Messerly c7b3846d8e fixes detection of SDK libraries
R=vsm@google.com

Review URL: https://codereview.chromium.org/1170813008.
2015-06-10 09:59:18 -07:00
John Messerly 6c3cdd707d fixes #40, extension methods for primitive types
fixes #138, extension methods for Iterable/List injected as needed, regardless of how the methods started

fixes #142, extension methods and dynamic dispatch

small change that fixes #139, recognize that '.length' doesn't need an extension method

Also restores JSArray, moved the methods out of List, which is back to just being an interface.

NOTE: this removes the capability of types that mix native JS members and some Dart extension members, instead it now *hides* all JS members for these native types. We'll want to bring that feature back to support dart:html, so it's just a simplification for now. Should be easy to add that capability when we pull in dart:html for reals.

R=leafp@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/1153003003
2015-06-04 14:58:18 -07:00
John Messerly ef8edb1273 fixes #175, fixed arrays
R=vsm@google.com

Review URL: https://codereview.chromium.org/1138533003
2015-05-08 14:33:37 -07:00
Jacob Richman 5a5ddca7bc Extension method support to move us closer to a valid List implementation.
BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1059583002
2015-04-03 14:52:04 -07:00
John Messerly 807d3b3b22 reorganize SDK inputs
it's all under input_sdk now:
  lib -> the lib folder
  private -> the dart:_* libs
  patch -> the files with @patch

I imagine we'll try and focus changes on the last two
2015-03-02 16:00:53 -08:00