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

Side by Side Diff: pkg/compiler/lib/src/ssa/optimize.dart

Issue 2927093002: Support user class in compile_from_dill_test (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 5 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
6 import '../common/names.dart' show Selectors; 6 import '../common/names.dart' show Selectors;
7 import '../common/tasks.dart' show CompilerTask; 7 import '../common/tasks.dart' show CompilerTask;
8 import '../compiler.dart' show Compiler; 8 import '../compiler.dart' show Compiler;
9 import '../constants/constant_system.dart'; 9 import '../constants/constant_system.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
11 import '../common_elements.dart' show CommonElements; 11 import '../common_elements.dart' show CommonElements;
12 import '../elements/elements.dart' 12 import '../elements/elements.dart'
13 show ClassElement, FieldElement, MethodElement; 13 show ClassElement, FieldElement, MethodElement;
14 import '../elements/entities.dart'; 14 import '../elements/entities.dart';
15 import '../elements/resolution_types.dart'; 15 import '../elements/resolution_types.dart';
16 import '../elements/types.dart';
16 import '../js/js.dart' as js; 17 import '../js/js.dart' as js;
17 import '../js_backend/backend.dart'; 18 import '../js_backend/backend.dart';
18 import '../js_backend/native_data.dart' show NativeData; 19 import '../js_backend/native_data.dart' show NativeData;
19 import '../js_backend/runtime_types.dart'; 20 import '../js_backend/runtime_types.dart';
20 import '../native/native.dart' as native; 21 import '../native/native.dart' as native;
21 import '../options.dart'; 22 import '../options.dart';
22 import '../types/types.dart'; 23 import '../types/types.dart';
23 import '../universe/selector.dart' show Selector; 24 import '../universe/selector.dart' show Selector;
24 import '../universe/side_effects.dart' show SideEffects; 25 import '../universe/side_effects.dart' show SideEffects;
25 import '../util/util.dart'; 26 import '../util/util.dart';
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 simplifyCondition(node.thenBlock, hoisted, false); 773 simplifyCondition(node.thenBlock, hoisted, false);
773 simplifyCondition(node.elseBlock, hoisted, true); 774 simplifyCondition(node.elseBlock, hoisted, true);
774 }); 775 });
775 } 776 }
776 simplifyCondition(node.thenBlock, condition, !isNegated); 777 simplifyCondition(node.thenBlock, condition, !isNegated);
777 simplifyCondition(node.elseBlock, condition, isNegated); 778 simplifyCondition(node.elseBlock, condition, isNegated);
778 return node; 779 return node;
779 } 780 }
780 781
781 HInstruction visitIs(HIs node) { 782 HInstruction visitIs(HIs node) {
782 ResolutionDartType type = node.typeExpression; 783 DartType type = node.typeExpression;
783 784
784 if (!node.isRawCheck) { 785 if (!node.isRawCheck) {
785 return node; 786 return node;
786 } else if (type.isTypedef) { 787 } else if (type.isTypedef) {
787 return node; 788 return node;
788 } else if (type.isFunctionType) { 789 } else if (type.isFunctionType) {
789 return node; 790 return node;
790 } 791 }
791 792
792 if (type.isObject || type.treatAsDynamic) { 793 if (type == commonElements.objectType || type.treatAsDynamic) {
793 return _graph.addConstantBool(true, _closedWorld); 794 return _graph.addConstantBool(true, _closedWorld);
794 } 795 }
795 ResolutionInterfaceType interfaceType = type; 796 InterfaceType interfaceType = type;
796 ClassEntity element = interfaceType.element; 797 ClassEntity element = interfaceType.element;
797 HInstruction expression = node.expression; 798 HInstruction expression = node.expression;
798 if (expression.isInteger(_closedWorld)) { 799 if (expression.isInteger(_closedWorld)) {
799 if (element == commonElements.intClass || 800 if (element == commonElements.intClass ||
800 element == commonElements.numClass || 801 element == commonElements.numClass ||
801 commonElements.isNumberOrStringSupertype(element)) { 802 commonElements.isNumberOrStringSupertype(element)) {
802 return _graph.addConstantBool(true, _closedWorld); 803 return _graph.addConstantBool(true, _closedWorld);
803 } else if (element == commonElements.doubleClass) { 804 } else if (element == commonElements.doubleClass) {
804 // We let the JS semantics decide for that check. Currently 805 // We let the JS semantics decide for that check. Currently
805 // the code we emit will always return true. 806 // the code we emit will always return true.
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 return; 2316 return;
2316 } 2317 }
2317 } 2318 }
2318 2319
2319 HTypeKnown newInput = new HTypeKnown.pinned(convertedType, input); 2320 HTypeKnown newInput = new HTypeKnown.pinned(convertedType, input);
2320 dominator.addBefore(dominator.first, newInput); 2321 dominator.addBefore(dominator.first, newInput);
2321 dominatedUses.replaceWith(newInput); 2322 dominatedUses.replaceWith(newInput);
2322 } 2323 }
2323 2324
2324 void visitIs(HIs instruction) { 2325 void visitIs(HIs instruction) {
2325 ResolutionDartType type = instruction.typeExpression; 2326 DartType type = instruction.typeExpression;
2326 if (!instruction.isRawCheck) { 2327 if (!instruction.isRawCheck) {
2327 return; 2328 return;
2328 } else if (type.isTypedef) { 2329 } else if (type.isTypedef) {
2329 return; 2330 return;
2330 } 2331 }
2331 ResolutionInterfaceType interfaceType = type; 2332 InterfaceType interfaceType = type;
2332 ClassEntity cls = interfaceType.element; 2333 ClassEntity cls = interfaceType.element;
2333 2334
2334 List<HBasicBlock> trueTargets = <HBasicBlock>[]; 2335 List<HBasicBlock> trueTargets = <HBasicBlock>[];
2335 List<HBasicBlock> falseTargets = <HBasicBlock>[]; 2336 List<HBasicBlock> falseTargets = <HBasicBlock>[];
2336 2337
2337 collectTargets(instruction, trueTargets, falseTargets); 2338 collectTargets(instruction, trueTargets, falseTargets);
2338 2339
2339 if (trueTargets.isEmpty && falseTargets.isEmpty) return; 2340 if (trueTargets.isEmpty && falseTargets.isEmpty) return;
2340 2341
2341 TypeMask convertedType = new TypeMask.nonNullSubtype(cls, closedWorld); 2342 TypeMask convertedType = new TypeMask.nonNullSubtype(cls, closedWorld);
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
2987 2988
2988 keyedValues.forEach((receiver, values) { 2989 keyedValues.forEach((receiver, values) {
2989 result.keyedValues[receiver] = 2990 result.keyedValues[receiver] =
2990 new Map<HInstruction, HInstruction>.from(values); 2991 new Map<HInstruction, HInstruction>.from(values);
2991 }); 2992 });
2992 2993
2993 result.nonEscapingReceivers.addAll(nonEscapingReceivers); 2994 result.nonEscapingReceivers.addAll(nonEscapingReceivers);
2994 return result; 2995 return result;
2995 } 2996 }
2996 } 2997 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698