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

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

Issue 12263009: - Trust type annotations on fields of HTML classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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: sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/optimize.dart (revision 18508)
+++ sdk/lib/_internal/compiler/implementation/ssa/optimize.dart (working copy)
@@ -389,19 +389,16 @@
HInstruction visitInvokeDynamicMethod(HInvokeDynamicMethod node) {
if (node.isInterceptorCall) return handleInterceptorCall(node);
HType receiverType = types[node.receiver];
- if (receiverType.isExact()) {
- Element element = receiverType.lookupMember(node.selector.name, compiler);
- // TODO(ngeoffray): Also fold if it's a getter or variable.
- if (element != null && element.isFunction()) {
- if (node.selector.applies(element, compiler)) {
- FunctionElement method = element;
- FunctionSignature parameters = method.computeSignature(compiler);
- if (parameters.optionalParameterCount == 0) {
- node.element = element;
- }
- // TODO(ngeoffray): If the method has optional parameters,
- // we should pass the default values here.
- }
+ Element element = receiverType.lookupSingleTarget(node.selector, compiler);
+ // TODO(ngeoffray): Also fold if it's a getter or variable.
+ if (element != null && element.isFunction()) {
+ FunctionElement method = element;
+ FunctionSignature parameters = method.computeSignature(compiler);
+ // TODO(ngeoffray): If the method has optional parameters,
+ // we should pass the default values.
+ if (parameters.optionalParameterCount == 0
+ || parameters.parameterCount == node.selector.argumentCount) {
+ node.element = element;
}
}
return node;
@@ -603,9 +600,9 @@
Selector selector) {
HType receiverType = types[receiver];
if (!receiverType.isUseful()) return null;
- if (receiverType.canBeNull()) return null;
DartType type = receiverType.computeType(compiler);
if (type == null) return null;
+ if (Elements.isErroneousElement(type.element)) return null;
return compiler.world.locateSingleField(type, selector);
}
@@ -639,11 +636,17 @@
}
HFieldGet result = new HFieldGet(
field, node.inputs[0], isAssignable: !isFinalOrConst);
- HType type = backend.optimisticFieldType(field);
- if (type != null) {
- result.guaranteedType = type;
- backend.registerFieldTypesOptimization(
- work.element, field, result.guaranteedType);
+
+ if (field.getEnclosingClass().isNative()) {
+ result.guaranteedType =
+ new HType.subtype(field.computeType(compiler), compiler);
+ } else {
+ HType type = backend.optimisticFieldType(field);
+ if (type != null) {
+ backend.registerFieldTypesOptimization(
+ work.element, field, result.guaranteedType);
+ result.guaranteedType = type;
+ }
}
return result;
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/codegen.dart ('k') | sdk/lib/_internal/compiler/implementation/ssa/types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698