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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_integrity.dart

Issue 1397953005: dart2js cps: Speed up integrity checking some more. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 library dart2js.cps_ir_integrity; 1 library dart2js.cps_ir_integrity;
2 2
3 import 'cps_ir_nodes.dart'; 3 import 'cps_ir_nodes.dart';
4 import 'cps_ir_nodes_sexpr.dart'; 4 import 'cps_ir_nodes_sexpr.dart';
5 import '../tracer.dart' as tracer; 5 import '../tracer.dart' as tracer;
6 6
7 /// Dump S-expressions on error if the tracer is enabled. 7 /// Dump S-expressions on error if the tracer is enabled.
8 /// 8 ///
9 /// Technically this has nothing to do with the tracer, but if you want one 9 /// Technically this has nothing to do with the tracer, but if you want one
10 /// enabled, you typically want the other as well, so we use the same flag. 10 /// enabled, you typically want the other as well, so we use the same flag.
(...skipping 15 matching lines...) Expand all
26 /// - Each definition object occurs only once in the IR (no redeclaring). 26 /// - Each definition object occurs only once in the IR (no redeclaring).
27 /// - Each reference object occurs only once in the IR (no sharing). 27 /// - Each reference object occurs only once in the IR (no sharing).
28 /// 28 ///
29 class CheckCpsIntegrity extends TrampolineRecursiveVisitor { 29 class CheckCpsIntegrity extends TrampolineRecursiveVisitor {
30 30
31 FunctionDefinition topLevelNode; 31 FunctionDefinition topLevelNode;
32 final Map<Definition, ScopeType> inScope = <Definition, ScopeType>{}; 32 final Map<Definition, ScopeType> inScope = <Definition, ScopeType>{};
33 final List<Definition> definitions = []; 33 final List<Definition> definitions = [];
34 String previousPass; 34 String previousPass;
35 35
36 void setScope(Iterable<Definition> defs, ScopeType scope) {
37 for (Definition def in defs) {
38 inScope[def] = scope;
39 }
40 }
asgerf 2015/10/15 10:13:29 This is an unused function I left here by accident
41
42 void handleDeclaration(Definition def) { 36 void handleDeclaration(Definition def) {
43 definitions.add(def); 37 definitions.add(def);
44 // Check the reference chain for cycles broken links. 38 // Check the reference chain for cycles broken links.
45 Reference anchor = null; 39 Reference anchor = null;
46 int i = 0; 40 int i = 0;
47 for (Reference ref = def.firstRef; ref != null; ref = ref.next) { 41 for (Reference ref = def.firstRef; ref != null; ref = ref.next) {
48 if (ref.definition != def) { 42 if (ref.definition != def) {
49 error('Reference to ${ref.definition} found in ' 43 error('Reference to ${ref.definition} found in '
50 'reference chain for $def', def); 44 'reference chain for $def', def);
51 } 45 }
(...skipping 18 matching lines...) Expand all
70 } 64 }
71 65
72 void enterContinuation(Continuation cont) { 66 void enterContinuation(Continuation cont) {
73 inScope[cont] = ScopeType.InDefinition; 67 inScope[cont] = ScopeType.InDefinition;
74 pushAction(() { 68 pushAction(() {
75 inScope[cont] = ScopeType.NotInScope; 69 inScope[cont] = ScopeType.NotInScope;
76 }); 70 });
77 } 71 }
78 72
79 void check(FunctionDefinition node, String previousPass) { 73 void check(FunctionDefinition node, String previousPass) {
80 topLevelNode = node; 74 // [check] will be called multiple times per instance to avoid reallocating
75 // the large [inScope] map. Reset the other fields.
76 this.topLevelNode = node;
81 this.previousPass = previousPass; 77 this.previousPass = previousPass;
78 this.definitions.clear();
82 ParentChecker.checkParents(node, this); 79 ParentChecker.checkParents(node, this);
83 visit(node); 80 visit(node);
84 // Check for broken reference chains. We check this last, so out-of-scope 81 // Check for broken reference chains. We check this last, so out-of-scope
85 // references are not classified as a broken reference chain. 82 // references are not classified as a broken reference chain.
86 definitions.forEach(checkReferenceChain); 83 definitions.forEach(checkReferenceChain);
87 } 84 }
88 85
89 @override 86 @override
90 Expression traverseLetCont(LetCont node) { 87 Expression traverseLetCont(LetCont node) {
91 node.continuations.forEach(handleDeclaration); 88 node.continuations.forEach(handleDeclaration);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 245 }
249 246
250 @override 247 @override
251 processReference(Reference node) { 248 processReference(Reference node) {
252 if (node.parent != _parent) { 249 if (node.parent != _parent) {
253 error('Parent pointer on $node is ${node.parent} but should be $_parent', 250 error('Parent pointer on $node is ${node.parent} but should be $_parent',
254 node); 251 node);
255 } 252 }
256 } 253 }
257 } 254 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/task.dart » ('j') | pkg/compiler/lib/src/js_backend/codegen/task.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698