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

Side by Side Diff: frog/world.dart

Issue 9222004: passing and good perf (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** The one true [World]. */ 5 /** The one true [World]. */
6 World world; 6 World world;
7 7
8 /** 8 /**
9 * Experimental phase to enable await, only set when using the 9 * Experimental phase to enable await, only set when using the
10 * await/awaitc.dart entrypoint. 10 * await/awaitc.dart entrypoint.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 return 'CompilerException: $_message'; 55 return 'CompilerException: $_message';
56 } 56 }
57 } 57 }
58 } 58 }
59 59
60 /** Counters that track statistics about the generated code. */ 60 /** Counters that track statistics about the generated code. */
61 class CounterLog { 61 class CounterLog {
62 int dynamicMethodCalls = 0; 62 int dynamicMethodCalls = 0;
63 int typeAsserts = 0; 63 int typeAsserts = 0;
64 int objectProtoMembers = 0; 64 int objectProtoMembers = 0;
65 int invokeCalls = 0;
66 int msetN = 0;
65 67
66 info() { 68 info() {
67 world.info('Dynamically typed method calls: $dynamicMethodCalls'); 69 world.info('Dynamically typed method calls: $dynamicMethodCalls');
68 world.info('Generated type assertions: $typeAsserts'); 70 world.info('Generated type assertions: $typeAsserts');
69 world.info('Members on Object.prototype: $objectProtoMembers'); 71 world.info('Members on Object.prototype: $objectProtoMembers');
72 world.info('Invoke calls: $invokeCalls');
73 world.info('msetN calls: $msetN');
70 } 74 }
71 75
72 // We need to push a new counter when we are abstract interpreting, so we 76 // We need to push a new counter when we are abstract interpreting, so we
73 // can discard it if we discard the code. 77 // can discard it if we discard the code.
74 // TODO(jmesserly): this is ugly but I'm not sure how to make it cleaner, 78 // TODO(jmesserly): this is ugly but I'm not sure how to make it cleaner,
75 // other than splitting abstract interpretation and code generation (which 79 // other than splitting abstract interpretation and code generation (which
76 // has its own problems). 80 // has its own problems).
77 add(CounterLog other) { 81 add(CounterLog other) {
78 dynamicMethodCalls += other.dynamicMethodCalls; 82 dynamicMethodCalls += other.dynamicMethodCalls;
79 typeAsserts += other.typeAsserts; 83 typeAsserts += other.typeAsserts;
80 objectProtoMembers += other.objectProtoMembers; 84 objectProtoMembers += other.objectProtoMembers;
85 invokeCalls += other.invokeCalls;
86 msetN += other.msetN;
81 } 87 }
82 } 88 }
83 89
90
84 /** Represents a Dart "world" of code. */ 91 /** Represents a Dart "world" of code. */
85 class World { 92 class World {
86 WorldGenerator gen; 93 WorldGenerator gen;
87 String legCode; // TODO(kasperl): Remove this temporary kludge. 94 String legCode; // TODO(kasperl): Remove this temporary kludge.
88 String frogCode; 95 String frogCode;
89 96
90 FileSystem files; 97 FileSystem files;
91 final LibraryReader reader; 98 final LibraryReader reader;
92 99
93 Map<String, Library> libraries; 100 Map<String, Library> libraries;
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 resolveAll() { 464 resolveAll() {
458 for (var lib in libraries.getValues()) { 465 for (var lib in libraries.getValues()) {
459 lib.resolve(); 466 lib.resolve();
460 } 467 }
461 for (var lib in libraries.getValues()) { 468 for (var lib in libraries.getValues()) {
462 lib.postResolveChecks(); 469 lib.postResolveChecks();
463 } 470 }
464 } 471 }
465 472
466 findMainMethod(Library lib) { 473 findMainMethod(Library lib) {
467 var mainMembers = lib.topType.resolveMember('main'); 474 var main = lib.lookup('main', lib.span);
468 var main = null; 475 if (main == null) {
469 if (mainMembers == null || mainMembers.members.length == 0) {
470 fatal('no main method specified'); 476 fatal('no main method specified');
471 } else if (mainMembers.members.length > 1) {
472 for (var m in mainMembers.members) {
473 main = m;
474 error('more than one main member (using last?)', main.span);
475 }
476 } else {
477 main = mainMembers.members[0];
478 } 477 }
479 return main; 478 return main;
480 } 479 }
481 480
482 generateCode(Library lib) { 481 generateCode(Library lib) {
483 gen = new WorldGenerator(findMainMethod(lib), new CodeWriter()); 482 gen = new WorldGenerator(findMainMethod(lib), new CodeWriter());
484 gen.run(); 483 gen.run();
485 frogCode = gen.writer.text; 484 frogCode = gen.writer.text;
486 jsBytesWritten = frogCode.length; 485 jsBytesWritten = frogCode.length;
487 gen = null; 486 gen = null;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 600
602 withTiming(String name, f()) { 601 withTiming(String name, f()) {
603 final sw = new Stopwatch(); 602 final sw = new Stopwatch();
604 sw.start(); 603 sw.start();
605 var result = f(); 604 var result = f();
606 sw.stop(); 605 sw.stop();
607 info('$name in ${sw.elapsedInMs()}msec'); 606 info('$name in ${sw.elapsedInMs()}msec');
608 return result; 607 return result;
609 } 608 }
610 } 609 }
OLDNEW
« frog/value.dart ('K') | « frog/var_member.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698