Chromium Code Reviews| 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]); |
| } |