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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 12334088: Stop creating selectors in the SSA builder that were already created by the resolver. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/builder.dart (revision 19125)
+++ sdk/lib/_internal/compiler/implementation/ssa/builder.dart (working copy)
@@ -2244,74 +2244,12 @@
pushWithPosition(result, node);
}
- void visitBinary(
- HInstruction left, Operator op, HInstruction right, Send send) {
- Selector selector = null;
- // TODO(ngeoffray): The resolver creates these selectors already
- // but does not put them on the [send] instruction.
+ void visitBinary(HInstruction left,
+ Operator op,
+ HInstruction right,
+ Selector selector,
+ Send send) {
switch (op.source.stringValue) {
- case "+":
- case "+=":
- case "++":
- selector = new Selector.binaryOperator(const SourceString('+'));
- break;
- case "-":
- case "-=":
- case "--":
- selector = new Selector.binaryOperator(const SourceString('-'));
- break;
- case "*":
- case "*=":
- selector = new Selector.binaryOperator(const SourceString('*'));
- break;
- case "/":
- case "/=":
- selector = new Selector.binaryOperator(const SourceString('/'));
- break;
- case "~/":
- case "~/=":
- selector = new Selector.binaryOperator(const SourceString('~/'));
- break;
- case "%":
- case "%=":
- selector = new Selector.binaryOperator(const SourceString('%'));
- break;
- case "<<":
- case "<<=":
- selector = new Selector.binaryOperator(const SourceString('<<'));
- break;
- case ">>":
- case ">>=":
- selector = new Selector.binaryOperator(const SourceString('>>'));
- break;
- case "|":
- case "|=":
- selector = new Selector.binaryOperator(const SourceString('|'));
- break;
- case "&":
- case "&=":
- selector = new Selector.binaryOperator(const SourceString('&'));
- break;
- case "^":
- case "^=":
- selector = new Selector.binaryOperator(const SourceString('^'));
- break;
- case "==":
- case "!=":
- selector = new Selector.binaryOperator(const SourceString('=='));
- break;
- case "<":
- selector = new Selector.binaryOperator(const SourceString('<'));
- break;
- case "<=":
- selector = new Selector.binaryOperator(const SourceString('<='));
- break;
- case ">":
- selector = new Selector.binaryOperator(const SourceString('>'));
- break;
- case ">=":
- selector = new Selector.binaryOperator(const SourceString('>='));
- break;
case "===":
pushWithPosition(new HIdentity(left, right), op);
return;
@@ -2320,9 +2258,6 @@
add(eq);
pushWithPosition(new HNot(eq), op);
return;
- default:
- compiler.internalError("Unexpected operator $op", node: op);
- break;
}
pushWithPosition(
@@ -2359,14 +2294,9 @@
}
void generateInstanceGetterWithCompiledReceiver(Send send,
+ Selector selector,
HInstruction receiver) {
assert(Elements.isInstanceSend(send, elements));
- // TODO(kasperl): This is a convoluted way of checking if we're
- // generating code for a compound assignment. If we are, we need
- // to get the selector from the mapping for the AST selector node.
- Selector selector = (send.asSendSet() == null)
- ? elements.getSelector(send)
- : elements.getSelector(send.selector);
assert(selector.isGetter());
SourceString getterName = selector.name;
Set<ClassElement> interceptedClasses = getInterceptedClassesOn(selector);
@@ -2419,7 +2349,8 @@
}
} else if (Elements.isInstanceSend(send, elements)) {
HInstruction receiver = generateInstanceSendReceiver(send);
- generateInstanceGetterWithCompiledReceiver(send, receiver);
+ generateInstanceGetterWithCompiledReceiver(
+ send, elements.getSelector(send), receiver);
} else if (Elements.isStaticOrTopLevelFunction(element)) {
// TODO(5346): Try to avoid the need for calling [declaration] before
// creating an [HStatic].
@@ -2712,7 +2643,7 @@
visit(node.argumentsNode);
var right = pop();
var left = pop();
- visitBinary(left, op, right, node);
+ visitBinary(left, op, right, elements.getSelector(node), node);
}
}
@@ -3119,7 +3050,9 @@
visitSuperSend(Send node) {
Selector selector = elements.getSelector(node);
Element element = elements[node];
- if (element == null) return generateSuperNoSuchMethodSend(node);
+ if (Elements.isUnresolved(element)) {
+ return generateSuperNoSuchMethodSend(node);
+ }
// TODO(5346): Try to avoid the need for calling [declaration] before
// creating an [HStatic].
HInstruction target = new HStatic(element.declaration);
@@ -3626,12 +3559,16 @@
}
HInvokeDynamicMethod left = buildInvokeDynamic(
- node, new Selector.index(), receiver, [index]);
+ node,
+ elements.getGetterSelectorInComplexSendSet(node),
+ receiver,
+ <HInstruction>[index]);
add(left);
- visitBinary(left, op, value, node);
+ visitBinary(left, op, value,
+ elements.getOperatorSelectorInComplexSendSet(node), node);
value = pop();
HInvokeDynamicMethod assign = buildInvokeDynamic(
- node, new Selector.indexSet(), receiver, [index, value]);
+ node, elements.getSelector(node), receiver, [index, value]);
add(assign);
if (isPrefix) {
stack.add(value);
@@ -3658,7 +3595,8 @@
HInstruction receiver = null;
if (Elements.isInstanceSend(node, elements)) {
receiver = generateInstanceSendReceiver(node);
- generateInstanceGetterWithCompiledReceiver(node, receiver);
+ generateInstanceGetterWithCompiledReceiver(
+ node, elements.getGetterSelectorInComplexSendSet(node), receiver);
} else {
generateGetter(node, elements[node.selector]);
}
@@ -3670,7 +3608,8 @@
} else {
right = graph.addConstantInt(1, constantSystem);
}
- visitBinary(left, op, right, node);
+ visitBinary(left, op, right,
+ elements.getOperatorSelectorInComplexSendSet(node), node);
HInstruction operation = pop();
assert(operation != null);
if (Elements.isInstanceSend(node, elements)) {
@@ -3916,9 +3855,7 @@
// The iterator is shared between initializer, condition and body.
HInstruction iterator;
void buildInitializer() {
- SourceString iteratorName = const SourceString("iterator");
- Selector selector =
- new Selector.getter(iteratorName, currentElement.getLibrary());
+ Selector selector = elements.getIteratorSelector(node);
Set<ClassElement> interceptedClasses = getInterceptedClassesOn(selector);
visit(node.expression);
HInstruction receiver = pop();
@@ -3938,15 +3875,12 @@
add(iterator);
}
HInstruction buildCondition() {
- SourceString name = const SourceString('moveNext');
- Selector selector = new Selector.call(
- name, currentElement.getLibrary(), 0);
+ Selector selector = elements.getMoveNextSelector(node);
push(new HInvokeDynamicMethod(selector, <HInstruction>[iterator]));
return popBoolified();
}
void buildBody() {
- SourceString name = const SourceString('current');
- Selector call = new Selector.getter(name, currentElement.getLibrary());
+ Selector call = elements.getCurrentSelector(node);
bool hasGetter = compiler.world.hasAnyUserDefinedGetter(call);
push(new HInvokeDynamicGetter(call, null, iterator, !hasGetter));

Powered by Google App Engine
This is Rietveld 408576698