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: lib/compiler/implementation/ssa/builder.dart

Issue 10836339: Get rid of the name in HInvokeDynamic (just use the selector instead). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix checked mode. 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 | « lib/compiler/implementation/resolver.dart ('k') | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/builder.dart
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart
index 1d8e3d75f15ca07587476eb6189ccaec90ce0170..d17708dcb3f66c3eac09020e0717687681b23bd3 100644
--- a/lib/compiler/implementation/ssa/builder.dart
+++ b/lib/compiler/implementation/ssa/builder.dart
@@ -1065,14 +1065,20 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
if (body === null) continue;
List bodyCallInputs = <HInstruction>[];
bodyCallInputs.add(newObject);
+ int arity = body.functionSignature.parameterCount;
body.functionSignature.forEachParameter((parameter) {
bodyCallInputs.add(localsHandler.readLocal(parameter));
});
// TODO(ahe): The constructor name is statically resolved. See
// SsaCodeGenerator.visitInvokeDynamicMethod. Is there a cleaner
// way to do this?
- SourceString methodName = new SourceString(compiler.namer.getName(body));
- add(new HInvokeDynamicMethod(null, methodName, bodyCallInputs));
+ SourceString name = new SourceString(compiler.namer.getName(body));
+ // TODO(kasperl): This seems fishy. We shouldn't be inventing all
+ // these selectors. Maybe the resolver can do more of the work
+ // for us here?
+ LibraryElement library = body.getLibrary();
+ Selector selector = new Selector.call(name, library, arity);
+ add(new HInvokeDynamicMethod(selector, bodyCallInputs));
}
close(new HReturn(newObject)).addSuccessor(graph.exit);
return closeFunction();
@@ -1745,8 +1751,14 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
void generateInstanceGetterWithCompiledReceiver(Send send,
HInstruction receiver) {
assert(Elements.isInstanceSend(send, elements));
- SourceString getterName = send.selector.asIdentifier().source;
- Selector selector = elements.getSelector(send);
+ // 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;
Element staticInterceptor = null;
if (methodInterceptionEnabled) {
staticInterceptor = interceptors.getStaticGetInterceptor(getterName);
@@ -1757,7 +1769,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
List<HInstruction> inputs = <HInstruction>[target, receiver];
push(new HInvokeInterceptor(selector, getterName, inputs, getter: true));
} else {
- push(new HInvokeDynamicGetter(selector, null, getterName, receiver));
+ push(new HInvokeDynamicGetter(selector, null, receiver));
}
}
@@ -1789,21 +1801,21 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
HInstruction receiver,
HInstruction value) {
assert(Elements.isInstanceSend(send, elements));
- SourceString dartSetterName = send.selector.asIdentifier().source;
Selector selector = elements.getSelector(send);
+ assert(selector.isSetter());
+ SourceString setterName = selector.name;
Element staticInterceptor = null;
if (methodInterceptionEnabled) {
- staticInterceptor = interceptors.getStaticSetInterceptor(dartSetterName);
+ staticInterceptor = interceptors.getStaticSetInterceptor(setterName);
}
if (staticInterceptor != null) {
HStatic target = new HStatic(staticInterceptor);
add(target);
List<HInstruction> inputs = <HInstruction>[target, receiver, value];
add(new HInvokeInterceptor(
- selector, dartSetterName, inputs, setter: true));
+ selector, setterName, inputs, setter: true));
} else {
- add(new HInvokeDynamicSetter(selector, null, dartSetterName,
- receiver, value));
+ add(new HInvokeDynamicSetter(selector, null, receiver, value));
}
stack.add(value);
}
@@ -2053,8 +2065,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
addDynamicSendArgumentsToList(node, inputs);
// The first entry in the inputs list is the receiver.
- pushWithPosition(new HInvokeDynamicMethod(selector, dartMethodName, inputs),
- node);
+ pushWithPosition(new HInvokeDynamicMethod(selector, inputs), node);
if (isNotEquals) {
HNot not = new HNot(popBoolified());
@@ -2211,21 +2222,22 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
}
visitForeignSend(Send node) {
- Element element = elements[node];
- if (element.name == const SourceString('JS')) {
+ Selector selector = elements.getSelector(node);
+ SourceString name = selector.name;
+ if (name == const SourceString('JS')) {
handleForeignJs(node);
- } else if (element.name == const SourceString('UNINTERCEPTED')) {
+ } else if (name == const SourceString('UNINTERCEPTED')) {
handleForeignUnintercepted(node);
- } else if (element.name == const SourceString('JS_HAS_EQUALS')) {
+ } else if (name == const SourceString('JS_HAS_EQUALS')) {
handleForeignJsHasEquals(node);
- } else if (element.name == const SourceString('JS_CURRENT_ISOLATE')) {
+ } else if (name == const SourceString('JS_CURRENT_ISOLATE')) {
handleForeignJsCurrentIsolate(node);
- } else if (element.name == const SourceString('JS_CALL_IN_ISOLATE')) {
+ } else if (name == const SourceString('JS_CALL_IN_ISOLATE')) {
handleForeignJsCallInIsolate(node);
- } else if (element.name == const SourceString('DART_CLOSURE_TO_JS')) {
+ } else if (name == const SourceString('DART_CLOSURE_TO_JS')) {
handleForeignDartClosureToJs(node);
} else {
- throw "Unknown foreign: ${node.selector}";
+ throw "Unknown foreign: ${selector}";
}
}
@@ -2748,13 +2760,13 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
HInstruction buildCondition() {
SourceString name = const SourceString('hasNext');
Selector call = new Selector.call(name, work.element.getLibrary(), 0);
- push(new HInvokeDynamicMethod(call, name, <HInstruction>[iterator]));
+ push(new HInvokeDynamicMethod(call, <HInstruction>[iterator]));
return popBoolified();
}
void buildBody() {
SourceString name = const SourceString('next');
Selector call = new Selector.call(name, work.element.getLibrary(), 0);
- push(new HInvokeDynamicMethod(call, name, <HInstruction>[iterator]));
+ push(new HInvokeDynamicMethod(call, <HInstruction>[iterator]));
Element variable;
if (node.declaredIdentifier.asSend() !== null) {
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698