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

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

Issue 1251083002: dart2js cps: Avoid deep recursion using trampolines and basic blocks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase Created 5 years, 5 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 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library dart2js.cps_ir.mutable_ssa; 5 library dart2js.cps_ir.mutable_ssa;
6 6
7 import 'cps_ir_nodes.dart'; 7 import 'cps_ir_nodes.dart';
8 import 'optimizers.dart'; 8 import 'optimizers.dart';
9 9
10 /// Determines which mutable variables should be rewritten to phi assignments 10 /// Determines which mutable variables should be rewritten to phi assignments
11 /// in this pass. 11 /// in this pass.
12 /// 12 ///
13 /// We do not rewrite variables that have an assignment inside a try block that 13 /// We do not rewrite variables that have an assignment inside a try block that
14 /// does not contain its declaration. 14 /// does not contain its declaration.
15 class MutableVariablePreanalysis extends RecursiveVisitor { 15 class MutableVariablePreanalysis extends RecursiveVisitor {
16 // Number of try blocks enclosing the current position. 16 // Number of try blocks enclosing the current position.
17 int currentDepth = 0; 17 int currentDepth = 0;
18 18
19 /// Number of try blocks enclosing the declaration of a given mutable 19 /// Number of try blocks enclosing the declaration of a given mutable
20 /// variable. 20 /// variable.
21 /// 21 ///
22 /// All mutable variables seen will be present in the map after the analysis. 22 /// All mutable variables seen will be present in the map after the analysis.
23 Map<MutableVariable, int> variableDepth = <MutableVariable, int>{}; 23 Map<MutableVariable, int> variableDepth = <MutableVariable, int>{};
24 24
25 /// Variables with an assignment inside a try block that does not contain 25 /// Variables with an assignment inside a try block that does not contain
26 /// its declaration. 26 /// its declaration.
27 Set<MutableVariable> hasAssignmentInTry = new Set<MutableVariable>(); 27 Set<MutableVariable> hasAssignmentInTry = new Set<MutableVariable>();
28 28
29 void visitLetHandler(LetHandler node) { 29 @override
30 Expression traverseLetHandler(LetHandler node) {
31 push(node.handler);
30 ++currentDepth; 32 ++currentDepth;
31 visit(node.body); 33 pushAction(() => --currentDepth);
32 --currentDepth; 34 return node.body;
33 visit(node.handler);
34 } 35 }
35 36
36 void processLetMutable(LetMutable node) { 37 void processLetMutable(LetMutable node) {
37 variableDepth[node.variable] = currentDepth; 38 variableDepth[node.variable] = currentDepth;
38 } 39 }
39 40
40 void processSetMutable(SetMutable node) { 41 void processSetMutable(SetMutable node) {
41 MutableVariable variable = node.variable.definition; 42 MutableVariable variable = node.variable.definition;
42 if (currentDepth > variableDepth[variable]) { 43 if (currentDepth > variableDepth[variable]) {
43 hasAssignmentInTry.add(variable); 44 hasAssignmentInTry.add(variable);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 class VariableItem extends StackItem {} 246 class VariableItem extends StackItem {}
246 247
247 /// Represents a yet unprocessed continuation together with the 248 /// Represents a yet unprocessed continuation together with the
248 /// environment in which to process it. 249 /// environment in which to process it.
249 class ContinuationItem extends StackItem { 250 class ContinuationItem extends StackItem {
250 final Continuation continuation; 251 final Continuation continuation;
251 final Map<MutableVariable, Primitive> environment; 252 final Map<MutableVariable, Primitive> environment;
252 253
253 ContinuationItem(this.continuation, this.environment); 254 ContinuationItem(this.continuation, this.environment);
254 } 255 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/let_sinking.dart ('k') | pkg/compiler/lib/src/cps_ir/redundant_join.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698