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

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

Issue 843613004: Consider updates of locals in type promotion. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('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 library inferrer_visitor; 5 library inferrer_visitor;
6 6
7 import '../dart2jslib.dart' hide Selector, TypedSelector; 7 import '../dart2jslib.dart' hide Selector, TypedSelector;
8 import '../dart_types.dart'; 8 import '../dart_types.dart';
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../tree/tree.dart'; 10 import '../tree/tree.dart';
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 VariableScope.deepCopyOf(VariableScope<T> other) 144 VariableScope.deepCopyOf(VariableScope<T> other)
145 : variables = other.variables == null 145 : variables = other.variables == null
146 ? null 146 ? null
147 : new Map<Local, T>.from(other.variables), 147 : new Map<Local, T>.from(other.variables),
148 block = other.block, 148 block = other.block,
149 parent = other.parent == null 149 parent = other.parent == null
150 ? null 150 ? null
151 : new VariableScope<T>.deepCopyOf(other.parent); 151 : new VariableScope<T>.deepCopyOf(other.parent);
152 152
153 VariableScope.shallowCopyOf(VariableScope<T> other)
154 : variables = other.variables == null
155 ? null
156 : new Map<Local, T>.from(other.variables),
157 block = other.block,
158 parent = other.parent;
159
153 T operator [](Local variable) { 160 T operator [](Local variable) {
154 T result; 161 T result;
155 if (variables == null || (result = variables[variable]) == null) { 162 if (variables == null || (result = variables[variable]) == null) {
156 return parent == null ? null : parent[variable]; 163 return parent == null ? null : parent[variable];
157 } 164 }
158 return result; 165 return result;
159 } 166 }
160 167
161 void operator []=(Local variable, T mask) { 168 void operator []=(Local variable, T mask) {
162 assert(mask != null); 169 assert(mask != null);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 LocalsHandler.deepCopyOf(LocalsHandler<T> other) 401 LocalsHandler.deepCopyOf(LocalsHandler<T> other)
395 : locals = new VariableScope<T>.deepCopyOf(other.locals), 402 : locals = new VariableScope<T>.deepCopyOf(other.locals),
396 fieldScope = new FieldInitializationScope<T>.from(other.fieldScope), 403 fieldScope = new FieldInitializationScope<T>.from(other.fieldScope),
397 captured = other.captured, 404 captured = other.captured,
398 capturedAndBoxed = other.capturedAndBoxed, 405 capturedAndBoxed = other.capturedAndBoxed,
399 tryBlock = other.tryBlock, 406 tryBlock = other.tryBlock,
400 types = other.types, 407 types = other.types,
401 inferrer = other.inferrer, 408 inferrer = other.inferrer,
402 compiler = other.compiler; 409 compiler = other.compiler;
403 410
411 LocalsHandler.shallowCopyOf(LocalsHandler<T> other)
412 : locals = new VariableScope<T>.shallowCopyOf(other.locals),
413 fieldScope = new FieldInitializationScope<T>.from(other.fieldScope),
414 captured = other.captured,
415 capturedAndBoxed = other.capturedAndBoxed,
416 tryBlock = other.tryBlock,
417 types = other.types,
418 inferrer = other.inferrer,
419 compiler = other.compiler;
420
404 T use(Local local) { 421 T use(Local local) {
405 if (capturedAndBoxed.containsKey(local)) { 422 if (capturedAndBoxed.containsKey(local)) {
406 return inferrer.typeOfElement(capturedAndBoxed[local]); 423 return inferrer.typeOfElement(capturedAndBoxed[local]);
407 } else { 424 } else {
408 if (captured.containsKey(local)) { 425 if (captured.containsKey(local)) {
409 inferrer.recordCapturedLocalRead(local); 426 inferrer.recordCapturedLocalRead(local);
410 } 427 }
411 return locals[local]; 428 return locals[local];
412 } 429 }
413 } 430 }
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 bool oldAccumulateIsChecks = accumulateIsChecks; 916 bool oldAccumulateIsChecks = accumulateIsChecks;
900 List<Send> oldIsChecks = isChecks; 917 List<Send> oldIsChecks = isChecks;
901 if (!accumulateIsChecks) { 918 if (!accumulateIsChecks) {
902 accumulateIsChecks = true; 919 accumulateIsChecks = true;
903 isChecks = <Send>[]; 920 isChecks = <Send>[];
904 } 921 }
905 visit(node.receiver); 922 visit(node.receiver);
906 LocalsHandler<T> saved = locals; 923 LocalsHandler<T> saved = locals;
907 locals = new LocalsHandler<T>.from(locals, node); 924 locals = new LocalsHandler<T>.from(locals, node);
908 updateIsChecks(isChecks, usePositive: true); 925 updateIsChecks(isChecks, usePositive: true);
909 if (!oldAccumulateIsChecks) { 926 LocalsHandler<T> narrowed;
927 if (oldAccumulateIsChecks) {
928 narrowed = new LocalsHandler<T>.shallowCopyOf(locals);
floitsch 2015/01/21 14:34:02 Would it be better to just copy out the locals? I
herhut 2015/01/21 14:45:19 It only copies the top level, so I have renamed it
929 } else {
910 accumulateIsChecks = false; 930 accumulateIsChecks = false;
911 isChecks = oldIsChecks; 931 isChecks = oldIsChecks;
912 } 932 }
913 visit(node.arguments.head); 933 visit(node.arguments.head);
934 if (oldAccumulateIsChecks) {
935 invalidatedInRightHandSide (Send test) {
floitsch 2015/01/21 14:34:02 bool invalidate ... new line before and after.
herhut 2015/01/21 14:45:19 Done.
936 Element receiver = elements[test.receiver];
937 if (receiver is LocalElement) {
938 return narrowed.locals[receiver] != locals.locals[receiver];
939 }
940 return false;
941 }
942 isChecks.removeWhere(invalidatedInRightHandSide);
943 }
914 saved.mergeDiamondFlow(locals, null); 944 saved.mergeDiamondFlow(locals, null);
915 locals = saved; 945 locals = saved;
916 return types.boolType; 946 return types.boolType;
917 } else if ("||" == op.source) { 947 } else if ("||" == op.source) {
918 conditionIsSimple = false; 948 conditionIsSimple = false;
919 List<Send> tests = <Send>[]; 949 List<Send> tests = <Send>[];
920 bool isSimple = handleCondition(node.receiver, tests); 950 bool isSimple = handleCondition(node.receiver, tests);
921 LocalsHandler<T> saved = locals; 951 LocalsHandler<T> saved = locals;
922 locals = new LocalsHandler<T>.from(locals, node); 952 locals = new LocalsHandler<T>.from(locals, node);
923 if (isSimple) updateIsChecks(tests, usePositive: false); 953 if (isSimple) updateIsChecks(tests, usePositive: false);
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 return type; 1299 return type;
1270 } 1300 }
1271 1301
1272 T visitCascade(Cascade node) { 1302 T visitCascade(Cascade node) {
1273 // Ignore the result of the cascade send and return the type of the cascade 1303 // Ignore the result of the cascade send and return the type of the cascade
1274 // receiver. 1304 // receiver.
1275 visit(node.expression); 1305 visit(node.expression);
1276 return cascadeReceiverStack.removeLast(); 1306 return cascadeReceiverStack.removeLast();
1277 } 1307 }
1278 } 1308 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698