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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart

Issue 831133004: Use closure conversion in new dart2js backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed redundant null-check Created 5 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 tree_ir_builder; 5 library tree_ir_builder;
6 6
7 import '../dart2jslib.dart' as dart2js; 7 import '../dart2jslib.dart' as dart2js;
8 import '../dart_types.dart'; 8 import '../dart_types.dart';
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; 10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir;
(...skipping 29 matching lines...) Expand all
40 * control-flow recognition. 40 * control-flow recognition.
41 * 41 *
42 * Otherwise, the output of Builder looks very much like the input. In 42 * Otherwise, the output of Builder looks very much like the input. In
43 * particular, intermediate values and blocks used for local control flow are 43 * particular, intermediate values and blocks used for local control flow are
44 * still all named. 44 * still all named.
45 */ 45 */
46 class Builder extends cps_ir.Visitor<Node> { 46 class Builder extends cps_ir.Visitor<Node> {
47 final dart2js.InternalErrorFunction internalError; 47 final dart2js.InternalErrorFunction internalError;
48 48
49 /// Maps variable/parameter elements to the Tree variables that represent it. 49 /// Maps variable/parameter elements to the Tree variables that represent it.
50 final Map<Element, List<Variable>> element2variables = 50 final Map<Local, List<Variable>> local2variables = <Local, List<Variable>>{};
51 <Element,List<Variable>>{};
52 51
53 /// Like [element2variables], except for closure variables. 52 /// Like [local2variables], except for closure variables.
54 final Map<cps_ir.ClosureVariable, Variable> local2closure = 53 final Map<cps_ir.ClosureVariable, Variable> local2closure =
55 <cps_ir.ClosureVariable, Variable>{}; 54 <cps_ir.ClosureVariable, Variable>{};
56 55
57 // Continuations with more than one use are replaced with Tree labels. This 56 // Continuations with more than one use are replaced with Tree labels. This
58 // is the mapping from continuations to labels. 57 // is the mapping from continuations to labels.
59 final Map<cps_ir.Continuation, Label> labels = <cps_ir.Continuation, Label>{}; 58 final Map<cps_ir.Continuation, Label> labels = <cps_ir.Continuation, Label>{};
60 59
61 ExecutableElement currentElement; 60 ExecutableElement currentElement;
62 cps_ir.Continuation returnContinuation; 61 cps_ir.Continuation returnContinuation;
63 62
(...skipping 16 matching lines...) Expand all
80 return local2closure.putIfAbsent(irVariable, 79 return local2closure.putIfAbsent(irVariable,
81 () => new Variable(currentElement, irVariable.hint)); 80 () => new Variable(currentElement, irVariable.hint));
82 } 81 }
83 82
84 /// Obtains the variable representing the given primitive. Returns null for 83 /// Obtains the variable representing the given primitive. Returns null for
85 /// primitives that have no reference and do not need a variable. 84 /// primitives that have no reference and do not need a variable.
86 Variable getVariable(cps_ir.Primitive primitive) { 85 Variable getVariable(cps_ir.Primitive primitive) {
87 if (primitive.registerIndex == null) { 86 if (primitive.registerIndex == null) {
88 return null; // variable is unused 87 return null; // variable is unused
89 } 88 }
90 List<Variable> variables = element2variables.putIfAbsent(primitive.hint, 89 List<Variable> variables = local2variables.putIfAbsent(primitive.hint,
91 () => <Variable>[]); 90 () => <Variable>[]);
92 while (variables.length <= primitive.registerIndex) { 91 while (variables.length <= primitive.registerIndex) {
93 variables.add(new Variable(currentElement, primitive.hint)); 92 variables.add(new Variable(currentElement, primitive.hint));
94 } 93 }
95 return variables[primitive.registerIndex]; 94 return variables[primitive.registerIndex];
96 } 95 }
97 96
98 /// Obtains a reference to the tree Variable corresponding to the IR primitive 97 /// Obtains a reference to the tree Variable corresponding to the IR primitive
99 /// referred to by [reference]. 98 /// referred to by [reference].
100 /// This increments the reference count for the given variable, so the 99 /// This increments the reference count for the given variable, so the
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 // visited. 544 // visited.
546 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node.'); 545 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node.');
547 return null; 546 return null;
548 } 547 }
549 548
550 Expression visitIsTrue(cps_ir.IsTrue node) { 549 Expression visitIsTrue(cps_ir.IsTrue node) {
551 return getVariableReference(node.value); 550 return getVariableReference(node.value);
552 } 551 }
553 } 552 }
554 553
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698