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

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

Issue 1427643009: dart2js cps: Fix bug in trampoline visitor. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | 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 library dart2js.ir_nodes; 4 library dart2js.ir_nodes;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import '../constants/values.dart' as values; 7 import '../constants/values.dart' as values;
8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/source_information.dart' show SourceInformation; 10 import '../io/source_information.dart' show SourceInformation;
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 if (node.thisParameter != null) visit(node.thisParameter); 2060 if (node.thisParameter != null) visit(node.thisParameter);
2061 node.parameters.forEach(visit); 2061 node.parameters.forEach(visit);
2062 visit(node.returnContinuation); 2062 visit(node.returnContinuation);
2063 visit(node.body); 2063 visit(node.body);
2064 } 2064 }
2065 2065
2066 visitContinuation(Continuation cont) { 2066 visitContinuation(Continuation cont) {
2067 if (cont.isReturnContinuation) { 2067 if (cont.isReturnContinuation) {
2068 traverseContinuation(cont); 2068 traverseContinuation(cont);
2069 } else { 2069 } else {
2070 _trampoline(traverseContinuation(cont)); 2070 int initialHeight = _stack.length;
2071 Expression body = traverseContinuation(cont);
2072 _trampoline(body, initialHeight: initialHeight);
2071 } 2073 }
2072 } 2074 }
2073 2075
2074 visitLetPrim(LetPrim node) => _trampoline(node); 2076 visitLetPrim(LetPrim node) => _trampoline(node);
2075 visitLetCont(LetCont node) => _trampoline(node); 2077 visitLetCont(LetCont node) => _trampoline(node);
2076 visitLetHandler(LetHandler node) => _trampoline(node); 2078 visitLetHandler(LetHandler node) => _trampoline(node);
2077 visitLetMutable(LetMutable node) => _trampoline(node); 2079 visitLetMutable(LetMutable node) => _trampoline(node);
2078 2080
2079 Expression traverseContinuation(Continuation cont) { 2081 Expression traverseContinuation(Continuation cont) {
2080 processContinuation(cont); 2082 processContinuation(cont);
(...skipping 19 matching lines...) Expand all
2100 return node.body; 2102 return node.body;
2101 } 2103 }
2102 2104
2103 Expression traverseLetMutable(LetMutable node) { 2105 Expression traverseLetMutable(LetMutable node) {
2104 processLetMutable(node); 2106 processLetMutable(node);
2105 visit(node.variable); 2107 visit(node.variable);
2106 processReference(node.value); 2108 processReference(node.value);
2107 return node.body; 2109 return node.body;
2108 } 2110 }
2109 2111
2110 void _trampoline(Expression node) { 2112 void _trampoline(Expression node, {int initialHeight}) {
2111 int initialHeight = _stack.length; 2113 initialHeight = initialHeight ?? _stack.length;
2112 _processBlock(node); 2114 _processBlock(node);
2113 while (_stack.length > initialHeight) { 2115 while (_stack.length > initialHeight) {
2114 StackAction callback = _stack.removeLast(); 2116 StackAction callback = _stack.removeLast();
2115 callback(); 2117 callback();
2116 } 2118 }
2117 } 2119 }
2118 2120
2119 _processBlock(Expression node) { 2121 _processBlock(Expression node) {
2120 while (node is InteriorExpression) { 2122 while (node is InteriorExpression) {
2121 if (node is LetCont) { 2123 if (node is LetCont) {
(...skipping 13 matching lines...) Expand all
2135 /// Visit a just-deleted subterm and unlink all [Reference]s in it. 2137 /// Visit a just-deleted subterm and unlink all [Reference]s in it.
2136 class RemovalVisitor extends TrampolineRecursiveVisitor { 2138 class RemovalVisitor extends TrampolineRecursiveVisitor {
2137 processReference(Reference reference) { 2139 processReference(Reference reference) {
2138 reference.unlink(); 2140 reference.unlink();
2139 } 2141 }
2140 2142
2141 static void remove(Node node) { 2143 static void remove(Node node) {
2142 (new RemovalVisitor()).visit(node); 2144 (new RemovalVisitor()).visit(node);
2143 } 2145 }
2144 } 2146 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698