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

Unified Diff: lib/compiler/implementation/ssa/builder.dart

Issue 10452029: Fix bug when a variable is used in try/catch and accessed trough HFieldGet and HFieldSet: reference… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
Index: lib/compiler/implementation/ssa/builder.dart
===================================================================
--- lib/compiler/implementation/ssa/builder.dart (revision 7983)
+++ lib/compiler/implementation/ssa/builder.dart (working copy)
@@ -412,7 +412,14 @@
return lookup;
} else {
assert(isUsedInTry(element));
- HInstruction variable = new HFieldGet.fromActivation(element.name);
+ HParameterValue parameter = builder.activationVariables.putIfAbsent(
kasperl 2012/05/25 10:05:15 This code should be refactored. There's a lot of d
ngeoffray 2012/05/25 10:45:10 Done.
+ element, () {
+ HParameterValue parameter = new HParameterValue(element);
+ builder.add(parameter);
+ return parameter;
+ }
+ );
+ HInstruction variable = new HFieldGet.fromActivation(parameter);
builder.add(variable);
return variable;
}
@@ -461,7 +468,14 @@
builder.add(new HFieldSet(redirect.name, box, value));
} else {
assert(isUsedInTry(element));
- builder.add(new HFieldSet.fromActivation(element.name, value));
+ HParameterValue parameter = builder.activationVariables.putIfAbsent(
+ element, () {
+ HParameterValue parameter = new HParameterValue(element);
+ builder.add(parameter);
+ return parameter;
+ }
+ );
+ builder.add(new HFieldSet.fromActivation(parameter, value));
}
}
@@ -779,6 +793,13 @@
Map<TargetElement, JumpHandler> jumpTargets;
+ /**
+ * Variables stored in the current activation. These variables are
+ * being updated in try/catch blocks, and should be
+ * accessed indirectly through HFieldGet and HFieldSet.
+ */
+ Map<Element, HParameterValue> activationVariables;
+
// We build the Ssa graph by simulating a stack machine.
List<HInstruction> stack;
@@ -802,6 +823,7 @@
elements = work.resolutionTree,
graph = new HGraph(),
stack = new List<HInstruction>(),
+ activationVariables = new Map<Element, HParameterValue>(),
jumpTargets = new Map<TargetElement, JumpHandler>() {
localsHandler = new LocalsHandler(this);
}
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | tests/language/scoped_variables_try_catch_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698