Commit Graph

15 Commits

Author SHA1 Message Date
Jenny Messerly b62276d97f fix DDC SDK implementation JS type annotations to work with CFE
This migrates the JS builtin's string type to the `<T>` type parameter
for a few more cases. This was done to eliminate null checks, casts and
dynamic calls when dartdevk builds the SDK, so it matches dartdevc.

Change-Id: I8570e5127149a45289a90002c27034333c3038ad
Reviewed-on: https://dart-review.googlesource.com/51207
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-04-17 19:29:40 +00:00
Erik Corry c8ae9bf77b [VM] Stop treating 0x180e as whitespace
This aligns us with JS engines and Unicode 6.3

R=lrn@google.com

Bug: 29060
Change-Id: I0b6356f0e652f7c9841bcf6485aa591a3d835061
Reviewed-on: https://dart-review.googlesource.com/35560
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Erik Corry <erikcorry@google.com>
2018-01-18 10:37:15 +00:00
Vijay Menon 05619da8ea Optimize String.length
Change-Id: I7e8481c8822d170492112704e04b92b19d5e5f2e
Reviewed-on: https://dart-review.googlesource.com/12340
Reviewed-by: Jennifer Messerly <jmesserly@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
2017-10-10 00:22:36 +00:00
Jennifer Messerly d0072fa73f Fix the return type of String.split in DDC to be correct
It wasn't actually a List<String>, so it could fail a strong mode cast, and also permitted non-Strings to be added.

R=leafp@google.com

Review-Url: https://codereview.chromium.org/3005533002 .
2017-08-25 11:24:54 -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
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
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
Jan-Hendrik Dolling 89560c68a0 change "the the" to the 2016-10-28 21:47:50 +02: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
Stephen Adams 5c41457500 Update CodeUnits.
TBR=vsm@google.com

Review URL: https://codereview.chromium.org/1956623002 .
2016-05-05 17:25:56 -07:00
Stephen Adams b016f035bd Update String methods.
This will need a second pass after core.Iterable is updated
and JS type strings are better parsed.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1950133003 .
2016-05-04 19:40:51 -07: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 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