Version 2.10.0-76.0.dev
Merge commit 'a81213f4e6198b2e0bdff2d1d4b02e8f14e5f3f8' into 'dev'
diff --git a/pkg/compiler/lib/src/inferrer/abstract_value_domain.dart b/pkg/compiler/lib/src/inferrer/abstract_value_domain.dart
index 8414450..274cf1d 100644
--- a/pkg/compiler/lib/src/inferrer/abstract_value_domain.dart
+++ b/pkg/compiler/lib/src/inferrer/abstract_value_domain.dart
@@ -414,6 +414,11 @@
/// primitive, possible `null`.
AbstractBool isPrimitiveOrNull(covariant AbstractValue value);
+ /// Return an [AbstractBool] that describes whether [value] is a JavaScript
+ /// 'truthy' value at runtime. This is effectively symbolically evaluating the
+ /// abstract value as a JavaScript condition.
+ AbstractBool isTruthy(covariant AbstractValue value);
+
/// Returns [AbstractValue] for the runtime values contained in either [a] or
/// [b].
AbstractValue union(covariant AbstractValue a, covariant AbstractValue b);
diff --git a/pkg/compiler/lib/src/inferrer/powersets/powerset_bits.dart b/pkg/compiler/lib/src/inferrer/powersets/powerset_bits.dart
index 96eb5df..21b6a29 100644
--- a/pkg/compiler/lib/src/inferrer/powersets/powerset_bits.dart
+++ b/pkg/compiler/lib/src/inferrer/powersets/powerset_bits.dart
@@ -194,6 +194,12 @@
return AbstractBool.Maybe;
}
+ AbstractBool isTruthy(int value) {
+ if (value & ~trueMask == 0) return AbstractBool.True;
+ if (value & ~(falseMask | nullMask) == 0) return AbstractBool.False;
+ return AbstractBool.Maybe;
+ }
+
AbstractBool isDoubleOrNull(int value) => isDouble(excludeNull(value));
AbstractBool isDouble(int value) => isOther(value);
diff --git a/pkg/compiler/lib/src/inferrer/powersets/powersets.dart b/pkg/compiler/lib/src/inferrer/powersets/powersets.dart
index 5f2fb1e..0d5fb61 100644
--- a/pkg/compiler/lib/src/inferrer/powersets/powersets.dart
+++ b/pkg/compiler/lib/src/inferrer/powersets/powersets.dart
@@ -431,6 +431,11 @@
_abstractValueDomain.isBoolean(value._abstractValue));
@override
+ AbstractBool isTruthy(covariant PowersetValue value) =>
+ AbstractBool.strengthen(_powersetBitsDomain.isTruthy(value._powersetBits),
+ _abstractValueDomain.isTruthy(value._abstractValue));
+
+ @override
AbstractBool isDoubleOrNull(covariant PowersetValue value) =>
AbstractBool.strengthen(
_powersetBitsDomain.isDoubleOrNull(value._powersetBits),
diff --git a/pkg/compiler/lib/src/inferrer/powersets/wrapped.dart b/pkg/compiler/lib/src/inferrer/powersets/wrapped.dart
index 8cdbaa3..e7df0d2 100644
--- a/pkg/compiler/lib/src/inferrer/powersets/wrapped.dart
+++ b/pkg/compiler/lib/src/inferrer/powersets/wrapped.dart
@@ -315,6 +315,10 @@
_abstractValueDomain.isBoolean(value._abstractValue);
@override
+ AbstractBool isTruthy(covariant WrappedAbstractValue value) =>
+ _abstractValueDomain.isTruthy(value._abstractValue);
+
+ @override
AbstractBool isDoubleOrNull(covariant WrappedAbstractValue value) =>
_abstractValueDomain.isDoubleOrNull(value._abstractValue);
diff --git a/pkg/compiler/lib/src/inferrer/trivial.dart b/pkg/compiler/lib/src/inferrer/trivial.dart
index b8ea357..afb7a7e 100644
--- a/pkg/compiler/lib/src/inferrer/trivial.dart
+++ b/pkg/compiler/lib/src/inferrer/trivial.dart
@@ -223,6 +223,9 @@
AbstractBool isBoolean(AbstractValue value) => AbstractBool.Maybe;
@override
+ AbstractBool isTruthy(AbstractValue value) => AbstractBool.Maybe;
+
+ @override
AbstractBool isDoubleOrNull(AbstractValue value) => AbstractBool.Maybe;
@override
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/masks.dart b/pkg/compiler/lib/src/inferrer/typemasks/masks.dart
index d6c6122..f20f16d 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/masks.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/masks.dart
@@ -654,6 +654,18 @@
}
@override
+ AbstractBool isTruthy(TypeMask value) {
+ if (value is ValueTypeMask && !value.isNullable) {
+ PrimitiveConstantValue constant = value.value;
+ if (constant is BoolConstantValue) {
+ return constant.boolValue ? AbstractBool.True : AbstractBool.False;
+ }
+ }
+ // TODO(sra): Non-intercepted types are generally JavaScript falsy values.
+ return AbstractBool.Maybe;
+ }
+
+ @override
AbstractBool isString(TypeMask value) {
return AbstractBool.trueOrMaybe(
value.containsOnlyString(_closedWorld) && !value.isNullable);
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index acb8cbc..5b4fb49 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -1219,6 +1219,17 @@
HInstruction visitIf(HIf node) {
HInstruction condition = node.condition;
if (condition.isConstant()) return node;
+
+ AbstractBool isTruthy =
+ _abstractValueDomain.isTruthy(condition.instructionType);
+ if (isTruthy.isDefinitelyTrue) {
+ return _replaceHIfCondition(
+ node, _graph.addConstantBool(true, _closedWorld));
+ } else if (isTruthy.isDefinitelyFalse) {
+ return _replaceHIfCondition(
+ node, _graph.addConstantBool(false, _closedWorld));
+ }
+
bool isNegated = condition is HNot;
if (isNegated) {
@@ -1241,6 +1252,15 @@
return node;
}
+ /// Returns [node] after replacing condition.
+ HInstruction _replaceHIfCondition(HIf node, HInstruction newCondition) {
+ HInstruction condition = node.condition;
+ node.inputs[0] = newCondition;
+ condition.usedBy.remove(node);
+ newCondition.usedBy.add(node);
+ return node;
+ }
+
@override
HInstruction visitPrimitiveCheck(HPrimitiveCheck node) {
if (node.isRedundant(_closedWorld)) return node.checkedInput;
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index e979cd8..0d5160f 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -8,7 +8,7 @@
* check out the [Element] class, the base class for many of the HTML
* DOM types.
*
- * For information on writing web apps with Dart, see https://webdev.dartlang.org.
+ * For information on writing web apps with Dart, see https://dart.dev/web.
*
* {@category Web}
*/
@@ -17965,15 +17965,12 @@
* as the requested resource.
* In the example above, the myData.json file must be co-located with the
* app that uses it.
- * You might be able to
- * [get around this restriction](http://www.dartlang.org/articles/json-web-service/#a-note-on-cors-and-httprequest)
- * by using CORS headers or JSONP.
*
* ## Other resources
*
* * [Fetch data dynamically](https://dart.dev/tutorials/web/fetch-data/),
* a tutorial shows how to load data from a static file or from a server.
- * * [Dart article on using HttpRequests](http://www.dartlang.org/articles/json-web-service/#getting-data)
+ * * [Dart article on using HttpRequests](https://dart.dev/guides/libraries/library-tour#using-http-resources-with-httprequest)
* * [JS XMLHttpRequest](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest)
* * [Using XMLHttpRequest](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest)
*/
@@ -28941,18 +28938,13 @@
* window.localStorage['key3'] = 'val3';
* assert(window.localStorage['key3'] == 'val3');
*
- * You can use [Map](http://api.dartlang.org/dart_core/Map.html) APIs
+ * You can use [Map](https://api.dart.dev/stable/dart-core/Map-class.html) APIs
* such as containsValue(), clear(), and length:
*
* assert(window.localStorage.containsValue('does not exist') == false);
* window.localStorage.clear();
* assert(window.localStorage.length == 0);
*
- * For more examples of using this API, see
- * [localstorage_test.dart](http://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/tests/html/localstorage_test.dart).
- * For details on using the Map API, see the
- * [Maps](https://www.dartlang.org/guides/libraries/library-tour#maps)
- * section of the library tour.
*/
@Unstable()
@Native("Storage")
diff --git a/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart b/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart
index f8fb0a7..21640b2 100644
--- a/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart
+++ b/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart
@@ -62,10 +62,6 @@
* and where both the keys and the values are strings.
*
* * [dart:web_sql]—a database that can be queried with SQL.
- *
- * For a tutorial about using the indexed_db library with Dart,
- * check out
- * [Use IndexedDB](http://www.dartlang.org/docs/tutorials/indexeddb/).
*
* MDN provides [API
* documentation](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API).
diff --git a/tools/VERSION b/tools/VERSION
index 992f0be..3d7e732 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 10
PATCH 0
-PRERELEASE 75
+PRERELEASE 76
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/dom/templates/html/dart2js/html_dart2js.darttemplate b/tools/dom/templates/html/dart2js/html_dart2js.darttemplate
index 8cc778e..0b19506 100644
--- a/tools/dom/templates/html/dart2js/html_dart2js.darttemplate
+++ b/tools/dom/templates/html/dart2js/html_dart2js.darttemplate
@@ -15,7 +15,7 @@
* check out the [Element] class, the base class for many of the HTML
* DOM types.
*
- * For information on writing web apps with Dart, see https://webdev.dartlang.org.
+ * For information on writing web apps with Dart, see https://dart.dev/web.
*
* {@category Web}
*/
diff --git a/tools/dom/templates/html/dart2js/indexed_db_dart2js.darttemplate b/tools/dom/templates/html/dart2js/indexed_db_dart2js.darttemplate
index 29bc8c5..f7f535e 100644
--- a/tools/dom/templates/html/dart2js/indexed_db_dart2js.darttemplate
+++ b/tools/dom/templates/html/dart2js/indexed_db_dart2js.darttemplate
@@ -71,10 +71,6 @@
*
* * [dart:web_sql]—a database that can be queried with SQL.
*
- * For a tutorial about using the indexed_db library with Dart,
- * check out
- * [Use IndexedDB](http://www.dartlang.org/docs/tutorials/indexeddb/).
- *
* MDN provides [API
* documentation](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API).
*
diff --git a/tools/dom/templates/html/impl/impl_Storage.darttemplate b/tools/dom/templates/html/impl/impl_Storage.darttemplate
index fa0787a..370d091 100644
--- a/tools/dom/templates/html/impl/impl_Storage.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Storage.darttemplate
@@ -16,18 +16,13 @@
* window.localStorage['key3'] = 'val3';
* assert(window.localStorage['key3'] == 'val3');
*
- * You can use [Map](http://api.dartlang.org/dart_core/Map.html) APIs
+ * You can use [Map](https://api.dart.dev/stable/dart-core/Map-class.html) APIs
* such as containsValue(), clear(), and length:
*
* assert(window.localStorage.containsValue('does not exist') == false);
* window.localStorage.clear();
* assert(window.localStorage.length == 0);
*
- * For more examples of using this API, see
- * [localstorage_test.dart](http://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/tests/html/localstorage_test.dart).
- * For details on using the Map API, see the
- * [Maps](https://www.dartlang.org/guides/libraries/library-tour#maps)
- * section of the library tour.
*/
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS
with MapMixin<String, String> {
diff --git a/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate b/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
index 27e5bcf..44d7ea4 100644
--- a/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
+++ b/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
@@ -33,15 +33,12 @@
* as the requested resource.
* In the example above, the myData.json file must be co-located with the
* app that uses it.
- * You might be able to
- * [get around this restriction](http://www.dartlang.org/articles/json-web-service/#a-note-on-cors-and-httprequest)
- * by using CORS headers or JSONP.
*
* ## Other resources
*
* * [Fetch data dynamically](https://dart.dev/tutorials/web/fetch-data/),
* a tutorial shows how to load data from a static file or from a server.
- * * [Dart article on using HttpRequests](http://www.dartlang.org/articles/json-web-service/#getting-data)
+ * * [Dart article on using HttpRequests](https://dart.dev/guides/libraries/library-tour#using-http-resources-with-httprequest)
* * [JS XMLHttpRequest](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest)
* * [Using XMLHttpRequest](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest)
*/