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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
diff --git a/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart b/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
index c2b3e416d62296f61ef30f48b417191b9deb13b3..add3759a0779573cdb4d41b71369b74e0eaae4dd 100644
--- a/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
+++ b/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
@@ -150,6 +150,13 @@ class VariableScope<T> {
? null
: new VariableScope<T>.deepCopyOf(other.parent);
+ VariableScope.shallowCopyOf(VariableScope<T> other)
+ : variables = other.variables == null
+ ? null
+ : new Map<Local, T>.from(other.variables),
+ block = other.block,
+ parent = other.parent;
+
T operator [](Local variable) {
T result;
if (variables == null || (result = variables[variable]) == null) {
@@ -401,6 +408,16 @@ class LocalsHandler<T> {
inferrer = other.inferrer,
compiler = other.compiler;
+ LocalsHandler.shallowCopyOf(LocalsHandler<T> other)
+ : locals = new VariableScope<T>.shallowCopyOf(other.locals),
+ fieldScope = new FieldInitializationScope<T>.from(other.fieldScope),
+ captured = other.captured,
+ capturedAndBoxed = other.capturedAndBoxed,
+ tryBlock = other.tryBlock,
+ types = other.types,
+ inferrer = other.inferrer,
+ compiler = other.compiler;
+
T use(Local local) {
if (capturedAndBoxed.containsKey(local)) {
return inferrer.typeOfElement(capturedAndBoxed[local]);
@@ -906,11 +923,24 @@ abstract class InferrerVisitor
LocalsHandler<T> saved = locals;
locals = new LocalsHandler<T>.from(locals, node);
updateIsChecks(isChecks, usePositive: true);
- if (!oldAccumulateIsChecks) {
+ LocalsHandler<T> narrowed;
+ if (oldAccumulateIsChecks) {
+ 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
+ } else {
accumulateIsChecks = false;
isChecks = oldIsChecks;
}
visit(node.arguments.head);
+ if (oldAccumulateIsChecks) {
+ 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.
+ Element receiver = elements[test.receiver];
+ if (receiver is LocalElement) {
+ return narrowed.locals[receiver] != locals.locals[receiver];
+ }
+ return false;
+ }
+ isChecks.removeWhere(invalidatedInRightHandSide);
+ }
saved.mergeDiamondFlow(locals, null);
locals = saved;
return types.boolType;
« 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