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

Issue 11264005: InvocationMirror implemented in dart2js. (Closed)

Created:
8 years, 1 month ago by Johnni Winther
Modified:
8 years, 1 month ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

InvocationMirror implemented in dart2js.

Patch Set 1 #

Patch Set 2 : Working version #

Total comments: 14

Patch Set 3 : Optimization + updated cf comments. #

Total comments: 16

Patch Set 4 : Check JSInvocationMirror.invokeOn instead of InvocationMirror.invokeOn. #

Total comments: 18
Unified diffs Side-by-side diffs Delta from patch set Stats (+221 lines, -7 lines) Patch
M lib/compiler/implementation/compiler.dart View 1 2 3 5 chunks +15 lines, -0 lines 5 comments Download
M lib/compiler/implementation/enqueue.dart View 1 2 3 1 chunk +2 lines, -0 lines 1 comment Download
M lib/compiler/implementation/js_backend/emitter.dart View 1 2 3 2 chunks +25 lines, -3 lines 4 comments Download
M lib/compiler/implementation/lib/core_patch.dart View 1 1 chunk +2 lines, -2 lines 0 comments Download
M lib/compiler/implementation/lib/js_helper.dart View 1 2 3 1 chunk +72 lines, -0 lines 8 comments Download
M lib/compiler/implementation/ssa/codegen.dart View 1 2 3 1 chunk +7 lines, -0 lines 0 comments Download
M lib/compiler/implementation/universe/universe.dart View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M lib/core/object.dart View 1 1 chunk +1 line, -1 line 0 comments Download
A tests/language/invocation_mirror_indirect_test.dart View 1 2 3 1 chunk +50 lines, -0 lines 0 comments Download
A tests/language/invocation_mirror_test.dart View 1 2 3 1 chunk +45 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Johnni Winther
Tested with: class PlusMinus { noSuchMethod(InvocationMirror msg) { print(msg.memberName); return msg.memberName == 'mul' ? msg.invokeOn(mul()) ...
8 years, 1 month ago (2012-10-24 08:47:55 UTC) #1
Johnni Winther
PTAL
8 years, 1 month ago (2012-10-24 13:33:33 UTC) #2
bakster
Drive by comments, Lars https://codereview.chromium.org/11264005/diff/4001/lib/compiler/implementation/enqueue.dart File lib/compiler/implementation/enqueue.dart (right): https://codereview.chromium.org/11264005/diff/4001/lib/compiler/implementation/enqueue.dart#newcode251 lib/compiler/implementation/enqueue.dart:251: if (selector.applies(compiler.invokeOnMethod, compiler)) { Why ...
8 years, 1 month ago (2012-10-24 13:43:04 UTC) #3
Johnni Winther
PTAL
8 years, 1 month ago (2012-10-25 08:51:34 UTC) #4
Johnni Winther
https://codereview.chromium.org/11264005/diff/4001/lib/compiler/implementation/enqueue.dart File lib/compiler/implementation/enqueue.dart (right): https://codereview.chromium.org/11264005/diff/4001/lib/compiler/implementation/enqueue.dart#newcode251 lib/compiler/implementation/enqueue.dart:251: if (selector.applies(compiler.invokeOnMethod, compiler)) { On 2012/10/24 13:43:04, bakster wrote: ...
8 years, 1 month ago (2012-10-25 13:34:56 UTC) #5
ngeoffray
LGTM! https://codereview.chromium.org/11264005/diff/10003/lib/compiler/implementation/enqueue.dart File lib/compiler/implementation/enqueue.dart (right): https://codereview.chromium.org/11264005/diff/10003/lib/compiler/implementation/enqueue.dart#newcode252 lib/compiler/implementation/enqueue.dart:252: /*if (!compiler.enabledInvokeOn && name == Compiler.INVOKE_ON) { Remove ...
8 years, 1 month ago (2012-10-26 08:34:55 UTC) #6
Johnni Winther
https://codereview.chromium.org/11264005/diff/10003/lib/compiler/implementation/enqueue.dart File lib/compiler/implementation/enqueue.dart (right): https://codereview.chromium.org/11264005/diff/10003/lib/compiler/implementation/enqueue.dart#newcode252 lib/compiler/implementation/enqueue.dart:252: /*if (!compiler.enabledInvokeOn && name == Compiler.INVOKE_ON) { On 2012/10/26 ...
8 years, 1 month ago (2012-10-26 10:18:01 UTC) #7
ahe
8 years, 1 month ago (2012-10-29 12:14:04 UTC) #8
https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
File lib/compiler/implementation/compiler.dart (right):

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/compiler.dart:180: static const SourceString MAIN =
const SourceString('main');
How about adding a TODO that these should be selectors?

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/compiler.dart:335: findHelper(const
SourceString('createInvocationMirror'));
This looks specific to the JS backend.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/compiler.dart:337:
enqueuer.codegen.addToWorkList(createInvocationMirrorElement);
This should only be added if it is really needed.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/compiler.dart:390: lookupSpecialClass(const
SourceString('JSInvocationMirror'));
This looks specific to the JS backend.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/compiler.dart:425: const SourceString('invokeOn'));
This looks specific to the JS backend.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
File lib/compiler/implementation/enqueue.dart (right):

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/enqueue.dart:109: compiler.enabledInvokeOn = true;
Somehow the grammar seems wrong for these variable names. Is it only me?

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
File lib/compiler/implementation/js_backend/emitter.dart (right):

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/js_backend/emitter.dart:1294: CodeBuffer
generateMethod(String methodName, Selector selector) {
Could you rename this function while you're at it? This method has a general
name that hides its special purpose.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/js_backend/emitter.dart:1299: int type = METHOD;
In a compiler, type means something else. Please find a different name for this
variable, for example, invocationKind.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/js_backend/emitter.dart:1322: buffer.add('  return
this.$noSuchMethodName('
Notice that $noSuchMethodName is string interpolation. This means that it refers
to the name that is computed on line 1269.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/js_backend/emitter.dart:1323:
'\$.createInvocationMirror("$methodName", "$internalName",'
The same should be done here. The namer needs to have a say in this method name.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
File lib/compiler/implementation/lib/js_helper.dart (right):

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/lib/js_helper.dart:358: class JSInvocationMirror
implements InvocationMirror {
Please move this to its own file, like string_helper.dart and
regexp_helper.dart.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/lib/js_helper.dart:359: static const METHOD = 0;
FYI: It is possible to read these constants from the source code using the
constant evaluator. For an example of how to do this, see
ResolverTask.resolveMetadataAnnotation.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/lib/js_helper.dart:365: final int _kind;
This field could use some documentation.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/lib/js_helper.dart:377: if (_namedArgumentNames !=
null && _namedArgumentNames.length > 0) {
I think you need to compute this lazily.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/lib/js_helper.dart:398: var list = [];
You should be able to preallocate the correct size of this list.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/lib/js_helper.dart:400: _arguments.length -
_namedArgumentNames.length;
I think this fits on one line.

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/lib/js_helper.dart:401: for (var index = 0 ; index <
argumentCount ; index++) {
Please use the common pattern:

for (int i = 0;

https://codereview.chromium.org/11264005/diff/17001/lib/compiler/implementati...
lib/compiler/implementation/lib/js_helper.dart:410:
_namedIndices.forEach((String name, int index) {
I'm having a really hard time seeing why you would compute _namedIndices in the
constructor when you must iterate through the values after all.

Powered by Google App Engine
This is Rietveld 408576698