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

Issue 10825337: Add name and library to selectors. (Closed)

Created:
8 years, 4 months ago by kasperl
Modified:
8 years, 4 months ago
Reviewers:
ahe, Søren Gjesse
CC:
reviews_dartlang.org, Anton Muhin
Visibility:
Public.

Description

Add name and library to selectors. This is the first step towards improving the Selector as an abstraction used by the resolver, builder, and enqueur. The intent is to have the resolver construct selectors that can be used for method lookup, tree shaking, and for simplifying the logic we use to build the correct SSA instructions for sends (some of which are quite complex). Next step is to get rid of more of the adhoc selector building that's done outside of the resolver and clean up how we resolve sends. After that, I'll start removing the need for passing around both a name and a selector in a lot of places. R=ahe@google.com,sgjesse@google.com BUG= Committed: https://code.google.com/p/dart/source/detail?r=10637

Patch Set 1 #

Total comments: 8

Patch Set 2 : Make library == null for non-private selectors. #

Total comments: 1

Patch Set 3 : Merge from master. #

Total comments: 15
Unified diffs Side-by-side diffs Delta from patch set Stats (+333 lines, -227 lines) Patch
M lib/compiler/implementation/compile_time_constants.dart View 1 chunk +4 lines, -1 line 0 comments Download
M lib/compiler/implementation/compiler.dart View 1 2 1 chunk +3 lines, -4 lines 0 comments Download
M lib/compiler/implementation/elements/elements.dart View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M lib/compiler/implementation/enqueue.dart View 1 2 3 chunks +20 lines, -5 lines 1 comment Download
M lib/compiler/implementation/js_backend/emitter.dart View 2 chunks +4 lines, -3 lines 0 comments Download
M lib/compiler/implementation/native_handler.dart View 1 2 1 chunk +6 lines, -10 lines 0 comments Download
M lib/compiler/implementation/resolver.dart View 1 2 12 chunks +102 lines, -52 lines 13 comments Download
M lib/compiler/implementation/ssa/builder.dart View 1 2 23 chunks +65 lines, -67 lines 0 comments Download
M lib/compiler/implementation/ssa/codegen.dart View 6 chunks +18 lines, -8 lines 0 comments Download
M lib/compiler/implementation/ssa/nodes.dart View 8 chunks +17 lines, -18 lines 0 comments Download
M lib/compiler/implementation/ssa/optimize.dart View 5 chunks +17 lines, -16 lines 0 comments Download
M lib/compiler/implementation/universe.dart View 1 5 chunks +72 lines, -38 lines 1 comment Download
M lib/compiler/implementation/world.dart View 1 chunk +2 lines, -1 line 0 comments Download
M tests/co19/co19-leg.status View 1 2 2 chunks +1 line, -2 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
kasperl
8 years, 4 months ago (2012-08-14 08:05:53 UTC) #1
kasperl
Adding Anton on the CC list.
8 years, 4 months ago (2012-08-14 08:15:43 UTC) #2
kasperl
https://chromiumcodereview.appspot.com/10825337/diff/1/lib/compiler/implementation/universe.dart File lib/compiler/implementation/universe.dart (right): https://chromiumcodereview.appspot.com/10825337/diff/1/lib/compiler/implementation/universe.dart#newcode88 lib/compiler/implementation/universe.dart:88: final LibraryElement library; // XXX: Should be null for ...
8 years, 4 months ago (2012-08-14 08:18:46 UTC) #3
Søren Gjesse
lgtm https://chromiumcodereview.appspot.com/10825337/diff/1/lib/compiler/implementation/ssa/builder.dart File lib/compiler/implementation/ssa/builder.dart (right): https://chromiumcodereview.appspot.com/10825337/diff/1/lib/compiler/implementation/ssa/builder.dart#newcode1846 lib/compiler/implementation/ssa/builder.dart:1846: void pushInvokeHelper0(Element helper) { How about "pushInvokeStatic0" and ...
8 years, 4 months ago (2012-08-14 12:01:38 UTC) #4
kasperl
Thanks for the comments! Landing as soon as all tests pass again after merging. https://chromiumcodereview.appspot.com/10825337/diff/1/lib/compiler/implementation/ssa/builder.dart ...
8 years, 4 months ago (2012-08-14 12:15:46 UTC) #5
ahe
8 years, 4 months ago (2012-08-15 07:37:59 UTC) #6
LGTM

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
File lib/compiler/implementation/enqueue.dart (right):

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/enqueue.dart:237: compiler.internalError("Wrong
selector name: $message.");
Style-wise, I think I'd prefer:

compiler.internalError("Wrong selector name: "
                       "$name != ${selector.name} (${selector.kind})");

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
File lib/compiler/implementation/resolver.dart (right):

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1139: name = selector.name;
Yay!

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1186: static Selector
computeSendSelector(Send node, LibraryElement library) {
Should this be moved somewhere less arbitrary?

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1188: bool isSet = node is SendSet;
Please use:

node.asSendSet() !== null

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1196: switch (source.stringValue) {
This is faster:

String value = source.stringValue;
if (value === '!' || ...) {
...

I have taken care to ensure you can use identity checks on these strings.

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1203: return node.arguments.isEmpty()
I like!

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1210: assert(!isSet);
Internal error?

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1218: List<SourceString> named =
<SourceString>[];
Why not use a Link?

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1224: named.add((argument as
NamedArgument).name.source);
Please don't use casts :-(((((

You could write it like this instead:

NamedArgument namedArgument = argument.asNamedArgument();
if (namedArgument !== null) {
  named.add(namedArgument.name.source);
}

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1244: void visitArguments(NodeList
list) {
I find it confusing to have a visitFoo which isn't a visitor method.

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1326: if (compoundAssignment) {
Nice simplification.

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1340: if (node.isIndex && node is
SendSet) {
node.asSendSet !== null

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1366: // Also register the getter for
compound assignments.
FYI: Clearly this is a hack. The getter should only be registered if we know
this is a compound assignment.

I should have added a TODO here when I wrote this code.

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/resolver.dart:1536: Selector selector = new
Selector.call(name, library, 0);
Seems like a helper method might be nice for handling this.

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
File lib/compiler/implementation/universe.dart (right):

https://chromiumcodereview.appspot.com/10825337/diff/7016/lib/compiler/implem...
lib/compiler/implementation/universe.dart:88: final SourceString name;       //
Name is null for call-any selectors.
Wouldn't it better using a documentation comment?

Powered by Google App Engine
This is Rietveld 408576698