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

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

Issue 10827359: Fix field-accesses for private fields that were "shadowed" by other private fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/optimize.dart
diff --git a/lib/compiler/implementation/ssa/optimize.dart b/lib/compiler/implementation/ssa/optimize.dart
index 4faa8e9e2e4ae016ee5352b71ae07b34f8c7f2fd..2b5ab21b9079d360c83b1d1a6be05801ec6249c3 100644
--- a/lib/compiler/implementation/ssa/optimize.dart
+++ b/lib/compiler/implementation/ssa/optimize.dart
@@ -555,14 +555,23 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
return (combinedType == value.propagatedType) ? value : node;
}
- HInstruction visitInvokeDynamicGetter(HInvokeDynamicGetter node) {
- HInstruction receiver = node.inputs[0];
- if (!receiver.propagatedType.isUseful()) return node;
- if (receiver.propagatedType.canBeNull()) return node;
+ Element findConcreteFieldForDynamicAccess(HInstruction receiver,
kasperl 2012/08/16 12:47:57 Can you use a selector instead of the fieldName he
floitsch 2012/08/16 16:15:55 Done.
+ SourceString fieldName) {
+ if (!receiver.propagatedType.isUseful()) return null;
+ if (receiver.propagatedType.canBeNull()) return null;
Type type = receiver.propagatedType.computeType(compiler);
- if (type === null) return node;
- Element field = compiler.world.locateSingleField(type, node.name);
- if (field === null) return node;
+ if (type === null) return null;
+ // TODO(floitsch): the library should not come from the current work item.
+ // Otherwise we cannot inline.
+ LibraryElement library = work.element.getLibrary();
+ Element field = compiler.world.locateSingleField(type, library, fieldName);
+ return field;
+ }
+
+ HInstruction visitInvokeDynamicGetter(HInvokeDynamicGetter node) {
+ Element field = findConcreteFieldForDynamicAccess(node.receiver, node.name);
+ if (field == null) return node;
+
Modifiers modifiers = field.modifiers;
bool isFinalOrConst = false;
if (modifiers != null) {
@@ -594,12 +603,7 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
}
HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) {
- HInstruction receiver = node.inputs[0];
- if (!receiver.propagatedType.isUseful()) return node;
- if (receiver.propagatedType.canBeNull()) return node;
- Type type = receiver.propagatedType.computeType(compiler);
- if (type === null) return node;
- Element field = compiler.world.locateSingleField(type, node.name);
+ Element field = findConcreteFieldForDynamicAccess(node.receiver, node.name);
if (field === null) return node;
return new HFieldSet.withElement(field, node.inputs[0], node.inputs[1]);
}

Powered by Google App Engine
This is Rietveld 408576698