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

Side by Side Diff: pkg/compiler/lib/src/inferrer/node_tracer.dart

Issue 726383003: Compute more accurate bound on expected work when tracing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/type_graph_nodes.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of type_graph_inferrer; 5 part of type_graph_inferrer;
6 6
7 // A set of selectors we know do not escape the elements inside the 7 // A set of selectors we know do not escape the elements inside the
8 // list. 8 // list.
9 Set<String> doesNotEscapeListSet = new Set<String>.from( 9 Set<String> doesNotEscapeListSet = new Set<String>.from(
10 const <String>[ 10 const <String>[
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // The current [TypeInformation] in the analysis. 97 // The current [TypeInformation] in the analysis.
98 TypeInformation currentUser; 98 TypeInformation currentUser;
99 bool continueAnalyzing = true; 99 bool continueAnalyzing = true;
100 100
101 void addNewEscapeInformation(TypeInformation info) { 101 void addNewEscapeInformation(TypeInformation info) {
102 if (flowsInto.contains(info)) return; 102 if (flowsInto.contains(info)) return;
103 flowsInto.add(info); 103 flowsInto.add(info);
104 workList.add(info); 104 workList.add(info);
105 } 105 }
106 106
107 bool _wouldBeTooManyUsers(Iterable users) {
108 int seenSoFar = analyzedElements.length;
109 if (seenSoFar + users.length <= MAX_ANALYSIS_COUNT) return false;
floitsch 2014/11/17 14:52:57 users is an iterable. By asking `.length` you run
herhut 2014/11/17 15:12:45 Actually, it is a Set. I just used Iterable becaus
110 int actualWork = users.fold(0, (sum, user) {
floitsch 2014/11/17 14:52:57 I think I would have gone with a simple `for` loop
herhut 2014/11/17 15:12:45 Nice. Done.
111 return analyzedElements.contains(user.owner) ? sum : sum + 1;
112 });
113 return seenSoFar + actualWork > MAX_ANALYSIS_COUNT;
114 }
115
107 void analyze() { 116 void analyze() {
108 // Collect the [TypeInformation] where the list can flow in, 117 // Collect the [TypeInformation] where the list can flow in,
109 // as well as the operations done on all these [TypeInformation]s. 118 // as well as the operations done on all these [TypeInformation]s.
110 addNewEscapeInformation(tracedType); 119 addNewEscapeInformation(tracedType);
111 while (!workList.isEmpty) { 120 while (!workList.isEmpty) {
112 currentUser = workList.removeLast(); 121 currentUser = workList.removeLast();
113 int expectedWork = analyzedElements.length + currentUser.users.length; 122 if (_wouldBeTooManyUsers(currentUser.users)) {
114 if (expectedWork > MAX_ANALYSIS_COUNT) {
115 bailout('Too many users'); 123 bailout('Too many users');
116 break; 124 break;
117 } 125 }
118 for (TypeInformation info in currentUser.users) { 126 for (TypeInformation info in currentUser.users) {
119 analyzedElements.add(info.owner); 127 analyzedElements.add(info.owner);
120 info.accept(this); 128 info.accept(this);
121 } 129 }
122 while (!listsToAnalyze.isEmpty) { 130 while (!listsToAnalyze.isEmpty) {
123 analyzeStoredIntoList(listsToAnalyze.removeLast()); 131 analyzeStoredIntoList(listsToAnalyze.removeLast());
124 } 132 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 386 }
379 if (isParameterOfListAddingMethod(info.element) || 387 if (isParameterOfListAddingMethod(info.element) ||
380 isParameterOfMapAddingMethod(info.element)) { 388 isParameterOfMapAddingMethod(info.element)) {
381 // These elements are being handled in 389 // These elements are being handled in
382 // [visitDynamicCallSiteTypeInformation]. 390 // [visitDynamicCallSiteTypeInformation].
383 return; 391 return;
384 } 392 }
385 addNewEscapeInformation(info); 393 addNewEscapeInformation(info);
386 } 394 }
387 } 395 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/type_graph_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698