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

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

Issue 1743283002: dart2js cps: Use definitions by default, not references. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix long lines and use helpers that we already have Created 4 years, 9 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.cps_ir.path_based_optimizer; 4 library dart2js.cps_ir.path_based_optimizer;
5 5
6 import 'cps_ir_nodes.dart'; 6 import 'cps_ir_nodes.dart';
7 import 'optimizers.dart'; 7 import 'optimizers.dart';
8 import 'cps_fragment.dart'; 8 import 'cps_fragment.dart';
9 import '../js_backend/js_backend.dart'; 9 import '../js_backend/js_backend.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 Expression traverseContinuation(Continuation cont) { 110 Expression traverseContinuation(Continuation cont) {
111 valueOf = valuesAt[cont]; 111 valueOf = valuesAt[cont];
112 if (valueOf == null) { 112 if (valueOf == null) {
113 // Do not go into unreachable code. 113 // Do not go into unreachable code.
114 destroyAndReplace(cont.body, new Unreachable()); 114 destroyAndReplace(cont.body, new Unreachable());
115 } 115 }
116 return cont.body; 116 return cont.body;
117 } 117 }
118 118
119 void visitInvokeContinuation(InvokeContinuation node) { 119 void visitInvokeContinuation(InvokeContinuation node) {
120 Continuation cont = node.continuation.definition; 120 Continuation cont = node.continuation;
121 if (cont.isReturnContinuation) return; 121 if (cont.isReturnContinuation) return;
122 if (node.isRecursive) return; 122 if (node.isRecursive) return;
123 Map<Primitive, int> target = valuesAt[cont]; 123 Map<Primitive, int> target = valuesAt[cont];
124 if (target == null) { 124 if (target == null) {
125 valuesAt[cont] = valueOf; 125 valuesAt[cont] = valueOf;
126 } else { 126 } else {
127 for (Primitive prim in target.keys) { 127 for (Primitive prim in target.keys) {
128 target[prim] |= valueOf[prim] ?? ANY; 128 target[prim] |= valueOf[prim] ?? ANY;
129 } 129 }
130 } 130 }
131 } 131 }
132 132
133 visitBranch(Branch node) { 133 visitBranch(Branch node) {
134 Primitive condition = node.condition.definition.effectiveDefinition; 134 Primitive condition = node.condition.effectiveDefinition;
135 Continuation trueCont = node.trueContinuation.definition; 135 Continuation trueCont = node.trueContinuation;
136 Continuation falseCont = node.falseContinuation.definition; 136 Continuation falseCont = node.falseContinuation;
137 if (condition.hasExactlyOneUse) { 137 if (condition.hasExactlyOneUse) {
138 // Handle common case specially. Do not add [condition] to the map if 138 // Handle common case specially. Do not add [condition] to the map if
139 // there are no other uses. 139 // there are no other uses.
140 valuesAt[trueCont] = copy(valueOf); 140 valuesAt[trueCont] = copy(valueOf);
141 valuesAt[falseCont] = valueOf; 141 valuesAt[falseCont] = valueOf;
142 return; 142 return;
143 } 143 }
144 int values = valueOf[condition] ?? ANY; 144 int values = valueOf[condition] ?? ANY;
145 int positiveValues = node.isStrictCheck ? TRUE : TRUTHY; 145 int positiveValues = node.isStrictCheck ? TRUE : TRUTHY;
146 int negativeValues = (~positiveValues) & ANY; 146 int negativeValues = (~positiveValues) & ANY;
(...skipping 13 matching lines...) Expand all
160 int receiverValue = valueOf[node.dartReceiver] ?? ANY; 160 int receiverValue = valueOf[node.dartReceiver] ?? ANY;
161 if (!backend.isInterceptedSelector(node.selector)) { 161 if (!backend.isInterceptedSelector(node.selector)) {
162 // Only self-interceptors can respond to a non-intercepted selector. 162 // Only self-interceptors can respond to a non-intercepted selector.
163 valueOf[node.dartReceiver] = receiverValue & SELF_INTERCEPTOR; 163 valueOf[node.dartReceiver] = receiverValue & SELF_INTERCEPTOR;
164 } else if (receiverValue & ~SELF_INTERCEPTOR == 0 && 164 } else if (receiverValue & ~SELF_INTERCEPTOR == 0 &&
165 node.callingConvention == CallingConvention.Intercepted) { 165 node.callingConvention == CallingConvention.Intercepted) {
166 // This is an intercepted call whose receiver is definitely a 166 // This is an intercepted call whose receiver is definitely a
167 // self-interceptor. 167 // self-interceptor.
168 // TODO(25646): If TypeMasks could represent "any self-interceptor" this 168 // TODO(25646): If TypeMasks could represent "any self-interceptor" this
169 // optimization should be subsumed by type propagation. 169 // optimization should be subsumed by type propagation.
170 node.receiver.changeTo(node.dartReceiver); 170 node.receiverRef.changeTo(node.dartReceiver);
171 171
172 // Replace the extra receiver argument with a dummy value if the 172 // Replace the extra receiver argument with a dummy value if the
173 // target definitely does not use it. 173 // target definitely does not use it.
174 if (typeSystem.targetIgnoresReceiverArgument(node.dartReceiver.type, 174 if (typeSystem.targetIgnoresReceiverArgument(node.dartReceiver.type,
175 node.selector)) { 175 node.selector)) {
176 Constant dummy = new Constant(new IntConstantValue(0)) 176 Constant dummy = new Constant(new IntConstantValue(0))
177 ..type = typeSystem.intType; 177 ..type = typeSystem.intType;
178 new LetPrim(dummy).insertAbove(node.parent); 178 new LetPrim(dummy).insertAbove(node.parent);
179 node.arguments[0].changeTo(dummy); 179 node.argumentRefs[0].changeTo(dummy);
180 node.callingConvention = CallingConvention.DummyIntercepted; 180 node.callingConvention = CallingConvention.DummyIntercepted;
181 } 181 }
182 } 182 }
183 } 183 }
184 } 184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698