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

Unified Diff: dart/lib/compiler/implementation/types/types.dart

Issue 10836134: Revert "Infer guaranteed types for static calls that are only called once." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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 | « dart/lib/compiler/implementation/ssa/builder.dart ('k') | dart/tests/compiler/dart2js/compiler_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/types/types.dart
diff --git a/dart/lib/compiler/implementation/types/types.dart b/dart/lib/compiler/implementation/types/types.dart
index 3dc6c79f049cf4a404d1a1acbeb88ba1022e4b96..17dc39b429b3620f77e21ff36111416cf844f2c3 100644
--- a/dart/lib/compiler/implementation/types/types.dart
+++ b/dart/lib/compiler/implementation/types/types.dart
@@ -7,20 +7,15 @@
#import('../leg.dart');
#import('../tree/tree.dart');
#import('../elements/elements.dart');
-#import('../util/util.dart');
/**
* The types task infers guaranteed types globally.
*/
class TypesTask extends CompilerTask {
final String name = 'Type inference';
- final Set<Element> untypedElements;
- final Map<Element, Link<Element>> typedSends;
+ final bool enabled = false;
- TypesTask(Compiler compiler)
- : untypedElements = new Set<Element>(),
- typedSends = new Map<Element, Link<Element>>(),
- super(compiler);
+ TypesTask(Compiler compiler) : super(compiler);
/**
* Called once for each method during the resolution phase of the
@@ -45,18 +40,11 @@ class TypesTask extends CompilerTask {
* Return the (inferred) guaranteed type of [element].
*/
Element getGuaranteedTypeOfElement(Element element) {
+ if (!enabled) return null;
return measure(() {
- if (!element.isParameter()) return null;
- Element holder = element.enclosingElement;
- Link<Element> types = typedSends[holder];
- if (types === null) return null;
- if (!holder.isFunction()) return null;
- if (untypedElements.contains(holder)) return null;
- FunctionElement function = holder;
- FunctionSignature signature = function.computeSignature(compiler);
- for (Element parameter in signature.requiredParameters) {
- if (element === parameter) return types.head;
- types = types.tail;
+ // TODO(ahe): Do something real here.
+ if (element.enclosingElement.name.slowToString() == 'print') {
+ return compiler.stringClass;
}
return null;
});
@@ -67,6 +55,7 @@ class TypesTask extends CompilerTask {
* [node] must be an AST node of [owner].
*/
Element getGuaranteedTypeOfNode(Node node, Element owner) {
+ if (!enabled) return null;
return measure(() {
// TODO(ahe): Do something real here.
return null;
@@ -145,44 +134,27 @@ class ConcreteTypeInferencer extends AbstractVisitor {
recordConcreteType(node, nullClass);
}
- Link<Element> computeConcreteSendArguments(Send node) {
- if (node.argumentsNode === null) return null;
- if (node.arguments.isEmpty()) return const EmptyLink<Element>();
+ isConcreteSend(Send node) {
+ if (node.argumentsNode === null) return true;
+ if (node.arguments.isEmpty()) return true;
if (node.receiver !== null && concreteTypes[node.receiver] === null) {
- return null;
+ return false;
}
- LinkBuilder<Element> types = new LinkBuilder<Element>();
for (Node argument in node.arguments) {
- Element type = concreteTypes[argument];
- if (type === null) return null;
- types.addLast(type);
+ if (concreteTypes[argument] === null) return false;
}
- return types.toLink();
+ return true;
}
visitSend(Send node) {
+ if (node.argumentsNode === null) return;
+ if (node.arguments.isEmpty()) return;
+ if (node.selector.toString() != 'print') return;
node.visitChildren(this);
- Element element = elements[node.selector];
- if (element === null) return;
- if (!element.isFunction()) return;
- if (node.argumentsNode === null) {
- // interest(node, 'closurized method');
- task.untypedElements.add(element);
- return;
- }
- Link<Element> types = computeConcreteSendArguments(node);
- if (types !== null) {
- Link<Element> existing = task.typedSends[element];
- if (existing === null) {
- task.typedSends[element] = types;
- } else {
- // interest(node, 'multiple invocations');
- // TODO(ahe): Compare [existing] to [types].
- task.untypedElements.add(element);
- }
+ if (isConcreteSend(node)) {
+ interest(node, 'all arguments are concrete');
} else {
- // interest(node, 'dynamically typed invocation');
- task.untypedElements.add(element);
+ interest(node, 'not all arguments are concrete');
}
}
@@ -193,6 +165,7 @@ class ConcreteTypeInferencer extends AbstractVisitor {
}
interest(Node node, String note) {
+ if (!task.enabled) return;
var message = MessageKind.GENERIC.message([note]);
task.compiler.reportWarning(node, message);
}
« no previous file with comments | « dart/lib/compiler/implementation/ssa/builder.dart ('k') | dart/tests/compiler/dart2js/compiler_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698