Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Unified Diff: sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart

Issue 18429011: Capture and handle properly every call to JSArray that read or writes elements via a native call (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Karl's comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/cpa_inference_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart b/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
index dd1935b447758b614747bbdf74a37c1c0cf8139e..bf0ec52c20072e308b13b8797e7f08a3de00d7fd 100644
--- a/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
+++ b/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
@@ -591,17 +591,41 @@ class ConcreteTypesInferrer extends TypesInferrer {
/**
* Constant representing [:ConcreteList#[]:] where [:ConcreteList:] is the
- * concrete implmentation of lists for the selected backend.
+ * concrete implementation of lists for the selected backend.
*/
FunctionElement listIndex;
/**
* Constant representing [:ConcreteList#[]=:] where [:ConcreteList:] is the
- * concrete implmentation of lists for the selected backend.
+ * concrete implementation of lists for the selected backend.
*/
FunctionElement listIndexSet;
/**
+ * Constant representing [:ConcreteList#add:] where [:ConcreteList:] is the
+ * concrete implementation of lists for the selected backend.
+ */
+ FunctionElement listAdd;
+
+ /**
+ * Constant representing [:ConcreteList#removeAt:] where [:ConcreteList:] is
+ * the concrete implementation of lists for the selected backend.
+ */
+ FunctionElement listRemoveAt;
+
+ /**
+ * Constant representing [:ConcreteList#insert:] where [:ConcreteList:] is
+ * the concrete implementation of lists for the selected backend.
+ */
+ FunctionElement listInsert;
+
+ /**
+ * Constant representing [:ConcreteList#removeLast:] where [:ConcreteList:] is
+ * the concrete implementation of lists for the selected backend.
+ */
+ FunctionElement listRemoveLast;
+
+ /**
* Constant representing [:List():].
*/
FunctionElement listConstructor;
@@ -1273,16 +1297,15 @@ class ConcreteTypesInferrer extends TypesInferrer {
}
}
- if (function == listIndex) {
- ConcreteType indexType = environment.lookupType(
- listIndex.functionSignature.requiredParameters.head);
+ if (function == listIndex || function == listRemoveAt) {
+ Link<Element> parameters = function.functionSignature.requiredParameters;
+ ConcreteType indexType = environment.lookupType(parameters.head);
if (!indexType.baseTypes.contains(baseTypes.intBaseType)) {
return emptyConcreteType;
}
return listElementType;
- } else if (function == listIndexSet) {
- Link<Element> parameters =
- listIndexSet.functionSignature.requiredParameters;
+ } else if (function == listIndexSet || function == listInsert) {
+ Link<Element> parameters = function.functionSignature.requiredParameters;
ConcreteType indexType = environment.lookupType(parameters.head);
if (!indexType.baseTypes.contains(baseTypes.intBaseType)) {
return emptyConcreteType;
@@ -1290,6 +1313,13 @@ class ConcreteTypesInferrer extends TypesInferrer {
ConcreteType elementType = environment.lookupType(parameters.tail.head);
augmentListElementType(elementType);
return emptyConcreteType;
+ } else if (function == listAdd) {
+ Link<Element> parameters = function.functionSignature.requiredParameters;
+ ConcreteType elementType = environment.lookupType(parameters.head);
+ augmentListElementType(elementType);
+ return emptyConcreteType;
+ } else if (function == listRemoveLast) {
+ return listElementType;
}
return null;
}
@@ -1446,6 +1476,11 @@ class ConcreteTypesInferrer extends TypesInferrer {
ClassElement jsArrayClass = baseTypes.listBaseType.element;
listIndex = jsArrayClass.lookupMember(const SourceString('[]'));
listIndexSet = jsArrayClass.lookupMember(const SourceString('[]='));
+ listAdd = jsArrayClass.lookupMember(const SourceString('add'));
+ listRemoveAt = jsArrayClass.lookupMember(const SourceString('removeAt'));
+ listInsert = jsArrayClass.lookupMember(const SourceString('insert'));
+ listRemoveLast =
+ jsArrayClass.lookupMember(const SourceString('removeLast'));
List<SourceString> typePreservingOps = const [const SourceString('+'),
const SourceString('-'),
const SourceString('*')];
@@ -1543,6 +1578,8 @@ class ConcreteTypesInferrer extends TypesInferrer {
inferredFieldTypes.forEach((k,v) {
print(" $k: $v");
});
+ print("listElementType:");
+ print(" $listElementType");
print("inferredParameterTypes:");
inferredParameterTypes.forEach((k,v) {
print(" $k: $v");
« no previous file with comments | « no previous file | tests/compiler/dart2js/cpa_inference_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698