Index: pkg/compiler/lib/src/ssa/optimize.dart |
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart |
index 977900c2242fe466ffe89008300ffc8f52f6ba37..adb39b9eda65b45f30a9bbc0289eb6d866fc450f 100644 |
--- a/pkg/compiler/lib/src/ssa/optimize.dart |
+++ b/pkg/compiler/lib/src/ssa/optimize.dart |
@@ -301,22 +301,15 @@ class SsaInstructionSimplifier extends HBaseVisitor |
if (instruction != null) return instruction; |
Selector selector = node.selector; |
- TypeMask mask = node.mask; |
HInstruction input = node.inputs[1]; |
World world = compiler.world; |
- |
- bool applies(Element element) { |
- return selector.applies(element, world) && |
- (mask == null || mask.canHit(element, selector, world)); |
- } |
- |
if (selector.isCall || selector.isOperator) { |
Element target; |
if (input.isExtendableArray(compiler)) { |
- if (applies(backend.jsArrayRemoveLast)) { |
+ if (selector.applies(backend.jsArrayRemoveLast, world)) { |
target = backend.jsArrayRemoveLast; |
- } else if (applies(backend.jsArrayAdd)) { |
+ } else if (selector.applies(backend.jsArrayAdd, world)) { |
// The codegen special cases array calls, but does not |
// inline argument type checks. |
if (!compiler.enableTypeAssertions) { |
@@ -324,12 +317,12 @@ class SsaInstructionSimplifier extends HBaseVisitor |
} |
} |
} else if (input.isStringOrNull(compiler)) { |
- if (applies(backend.jsStringSplit)) { |
+ if (selector.applies(backend.jsStringSplit, world)) { |
HInstruction argument = node.inputs[2]; |
if (argument.isString(compiler)) { |
target = backend.jsStringSplit; |
} |
- } else if (applies(backend.jsStringOperatorAdd)) { |
+ } else if (selector.applies(backend.jsStringOperatorAdd, world)) { |
// `operator+` is turned into a JavaScript '+' so we need to |
// make sure the receiver and the argument are not null. |
// TODO(sra): Do this via [node.specializer]. |
@@ -339,7 +332,7 @@ class SsaInstructionSimplifier extends HBaseVisitor |
return new HStringConcat(input, argument, null, |
node.instructionType); |
} |
- } else if (applies(backend.jsStringToString) |
+ } else if (selector.applies(backend.jsStringToString, world) |
&& !input.canBeNull()) { |
return input; |
} |
@@ -354,13 +347,12 @@ class SsaInstructionSimplifier extends HBaseVisitor |
// bounds check will become explicit, so we won't need this |
// optimization. |
HInvokeDynamicMethod result = new HInvokeDynamicMethod( |
- node.selector, node.mask, |
- node.inputs.sublist(1), node.instructionType); |
+ node.selector, node.inputs.sublist(1), node.instructionType); |
result.element = target; |
return result; |
} |
} else if (selector.isGetter) { |
- if (selector.applies(backend.jsIndexableLength, world)) { |
+ if (selector.asUntyped.applies(backend.jsIndexableLength, world)) { |
HInstruction optimized = tryOptimizeLengthInterceptedGetter(node); |
if (optimized != null) return optimized; |
} |
@@ -376,14 +368,15 @@ class SsaInstructionSimplifier extends HBaseVisitor |
} |
TypeMask receiverType = node.getDartReceiver(compiler).instructionType; |
- Element element = |
- compiler.world.locateSingleElement(node.selector, receiverType); |
+ Selector selector = |
+ new TypedSelector(receiverType, node.selector, compiler.world); |
+ Element element = compiler.world.locateSingleElement(selector); |
// TODO(ngeoffray): Also fold if it's a getter or variable. |
if (element != null |
&& element.isFunction |
// If we found out that the only target is a [:noSuchMethod:], |
// we just ignore it. |
- && element.name == node.selector.name) { |
+ && element.name == selector.name) { |
FunctionElement method = element; |
if (method.isNative) { |
@@ -393,9 +386,8 @@ class SsaInstructionSimplifier extends HBaseVisitor |
// TODO(ngeoffray): If the method has optional parameters, |
// we should pass the default values. |
FunctionSignature parameters = method.functionSignature; |
- if (parameters.optionalParameterCount == 0 || |
- parameters.parameterCount == |
- node.selector.argumentCount) { |
+ if (parameters.optionalParameterCount == 0 |
+ || parameters.parameterCount == node.selector.argumentCount) { |
node.element = element; |
} |
} |
@@ -458,7 +450,7 @@ class SsaInstructionSimplifier extends HBaseVisitor |
TypeMask returnType = |
TypeMaskFactory.fromNativeBehavior(nativeBehavior, compiler); |
HInvokeDynamicMethod result = |
- new HInvokeDynamicMethod(node.selector, node.mask, inputs, returnType); |
+ new HInvokeDynamicMethod(node.selector, inputs, returnType); |
result.element = method; |
return result; |
} |
@@ -737,7 +729,8 @@ class SsaInstructionSimplifier extends HBaseVisitor |
VariableElement findConcreteFieldForDynamicAccess(HInstruction receiver, |
Selector selector) { |
TypeMask receiverType = receiver.instructionType; |
- return compiler.world.locateSingleField(selector, receiverType); |
+ return compiler.world.locateSingleField( |
+ new TypedSelector(receiverType, selector, compiler.world)); |
} |
HInstruction visitFieldGet(HFieldGet node) { |
@@ -809,8 +802,7 @@ class SsaInstructionSimplifier extends HBaseVisitor |
if (folded != node) return folded; |
} |
HInstruction receiver = node.getDartReceiver(compiler); |
- Element field = findConcreteFieldForDynamicAccess( |
- receiver, node.selector); |
+ Element field = findConcreteFieldForDynamicAccess(receiver, node.selector); |
if (field == null) return node; |
return directFieldGet(receiver, field); |
} |