| OLD | NEW |
| 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 part of ssa; | 5 |
| 6 import '../closure.dart'; |
| 7 import '../common.dart'; |
| 8 import '../compiler.dart' show Compiler; |
| 9 import '../constants/constant_system.dart'; |
| 10 import '../constants/values.dart'; |
| 11 import '../dart_types.dart'; |
| 12 import '../elements/elements.dart'; |
| 13 import '../io/source_information.dart'; |
| 14 import '../js/js.dart' as js; |
| 15 import '../js_backend/backend_helpers.dart' show BackendHelpers; |
| 16 import '../js_backend/js_backend.dart'; |
| 17 import '../native/native.dart' as native; |
| 18 import '../tree/dartstring.dart' as ast; |
| 19 import '../types/constants.dart' show computeTypeMask; |
| 20 import '../types/types.dart'; |
| 21 import '../universe/selector.dart' show Selector; |
| 22 import '../universe/side_effects.dart' show SideEffects; |
| 23 import '../util/util.dart'; |
| 24 import '../world.dart' show ClassWorld, World; |
| 25 |
| 26 import 'validate.dart'; |
| 27 import 'invoke_dynamic_specializers.dart'; |
| 6 | 28 |
| 7 abstract class HVisitor<R> { | 29 abstract class HVisitor<R> { |
| 8 R visitAdd(HAdd node); | 30 R visitAdd(HAdd node); |
| 9 R visitAwait(HAwait node); | 31 R visitAwait(HAwait node); |
| 10 R visitBitAnd(HBitAnd node); | 32 R visitBitAnd(HBitAnd node); |
| 11 R visitBitNot(HBitNot node); | 33 R visitBitNot(HBitNot node); |
| 12 R visitBitOr(HBitOr node); | 34 R visitBitOr(HBitOr node); |
| 13 R visitBitXor(HBitXor node); | 35 R visitBitXor(HBitXor node); |
| 14 R visitBoolify(HBoolify node); | 36 R visitBoolify(HBoolify node); |
| 15 R visitBoundsCheck(HBoundsCheck node); | 37 R visitBoundsCheck(HBoundsCheck node); |
| (...skipping 2871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2887 : super(<HInstruction>[input], type) { | 2909 : super(<HInstruction>[input], type) { |
| 2888 sourceElement = input.sourceElement; | 2910 sourceElement = input.sourceElement; |
| 2889 } | 2911 } |
| 2890 | 2912 |
| 2891 bool get isMovable => false; | 2913 bool get isMovable => false; |
| 2892 | 2914 |
| 2893 accept(HVisitor visitor) => visitor.visitRangeConversion(this); | 2915 accept(HVisitor visitor) => visitor.visitRangeConversion(this); |
| 2894 } | 2916 } |
| 2895 | 2917 |
| 2896 class HStringConcat extends HInstruction { | 2918 class HStringConcat extends HInstruction { |
| 2897 final ast.Node node; | 2919 HStringConcat(HInstruction left, HInstruction right, TypeMask type) |
| 2898 HStringConcat(HInstruction left, HInstruction right, this.node, TypeMask type) | |
| 2899 : super(<HInstruction>[left, right], type) { | 2920 : super(<HInstruction>[left, right], type) { |
| 2900 // TODO(sra): Until Issue 9293 is fixed, this false dependency keeps the | 2921 // TODO(sra): Until Issue 9293 is fixed, this false dependency keeps the |
| 2901 // concats bunched with stringified inputs for much better looking code with | 2922 // concats bunched with stringified inputs for much better looking code with |
| 2902 // fewer temps. | 2923 // fewer temps. |
| 2903 sideEffects.setDependsOnSomething(); | 2924 sideEffects.setDependsOnSomething(); |
| 2904 } | 2925 } |
| 2905 | 2926 |
| 2906 HInstruction get left => inputs[0]; | 2927 HInstruction get left => inputs[0]; |
| 2907 HInstruction get right => inputs[1]; | 2928 HInstruction get right => inputs[1]; |
| 2908 | 2929 |
| 2909 accept(HVisitor visitor) => visitor.visitStringConcat(this); | 2930 accept(HVisitor visitor) => visitor.visitStringConcat(this); |
| 2910 toString() => "string concat"; | 2931 toString() => "string concat"; |
| 2911 } | 2932 } |
| 2912 | 2933 |
| 2913 /** | 2934 /** |
| 2914 * The part of string interpolation which converts and interpolated expression | 2935 * The part of string interpolation which converts and interpolated expression |
| 2915 * into a String value. | 2936 * into a String value. |
| 2916 */ | 2937 */ |
| 2917 class HStringify extends HInstruction { | 2938 class HStringify extends HInstruction { |
| 2918 final ast.Node node; | 2939 HStringify(HInstruction input, TypeMask type) |
| 2919 HStringify(HInstruction input, this.node, TypeMask type) | |
| 2920 : super(<HInstruction>[input], type) { | 2940 : super(<HInstruction>[input], type) { |
| 2921 sideEffects.setAllSideEffects(); | 2941 sideEffects.setAllSideEffects(); |
| 2922 sideEffects.setDependsOnSomething(); | 2942 sideEffects.setDependsOnSomething(); |
| 2923 } | 2943 } |
| 2924 | 2944 |
| 2925 accept(HVisitor visitor) => visitor.visitStringify(this); | 2945 accept(HVisitor visitor) => visitor.visitStringify(this); |
| 2926 toString() => "stringify"; | 2946 toString() => "stringify"; |
| 2927 } | 2947 } |
| 2928 | 2948 |
| 2929 /** Non-block-based (aka. traditional) loop information. */ | 2949 /** Non-block-based (aka. traditional) loop information. */ |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3092 {this.isContinue: false}) | 3112 {this.isContinue: false}) |
| 3093 : this.labels = const<LabelDefinition>[]; | 3113 : this.labels = const<LabelDefinition>[]; |
| 3094 | 3114 |
| 3095 HBasicBlock get start => body.start; | 3115 HBasicBlock get start => body.start; |
| 3096 HBasicBlock get end => body.end; | 3116 HBasicBlock get end => body.end; |
| 3097 | 3117 |
| 3098 bool accept(HStatementInformationVisitor visitor) => | 3118 bool accept(HStatementInformationVisitor visitor) => |
| 3099 visitor.visitLabeledBlockInfo(this); | 3119 visitor.visitLabeledBlockInfo(this); |
| 3100 } | 3120 } |
| 3101 | 3121 |
| 3102 class LoopTypeVisitor extends ast.Visitor { | |
| 3103 const LoopTypeVisitor(); | |
| 3104 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; | |
| 3105 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; | |
| 3106 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; | |
| 3107 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; | |
| 3108 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | |
| 3109 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | |
| 3110 int visitSwitchStatement(ast.SwitchStatement node) => | |
| 3111 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; | |
| 3112 } | |
| 3113 | |
| 3114 class HLoopBlockInformation implements HStatementInformation { | 3122 class HLoopBlockInformation implements HStatementInformation { |
| 3115 static const int WHILE_LOOP = 0; | 3123 static const int WHILE_LOOP = 0; |
| 3116 static const int FOR_LOOP = 1; | 3124 static const int FOR_LOOP = 1; |
| 3117 static const int DO_WHILE_LOOP = 2; | 3125 static const int DO_WHILE_LOOP = 2; |
| 3118 static const int FOR_IN_LOOP = 3; | 3126 static const int FOR_IN_LOOP = 3; |
| 3119 static const int SWITCH_CONTINUE_LOOP = 4; | 3127 static const int SWITCH_CONTINUE_LOOP = 4; |
| 3120 static const int NOT_A_LOOP = -1; | 3128 static const int NOT_A_LOOP = -1; |
| 3121 | 3129 |
| 3122 final int kind; | 3130 final int kind; |
| 3123 final HExpressionInformation initializer; | 3131 final HExpressionInformation initializer; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3153 } | 3161 } |
| 3154 | 3162 |
| 3155 HBasicBlock get end { | 3163 HBasicBlock get end { |
| 3156 if (updates != null) return updates.end; | 3164 if (updates != null) return updates.end; |
| 3157 if (kind == DO_WHILE_LOOP && condition != null) { | 3165 if (kind == DO_WHILE_LOOP && condition != null) { |
| 3158 return condition.end; | 3166 return condition.end; |
| 3159 } | 3167 } |
| 3160 return body.end; | 3168 return body.end; |
| 3161 } | 3169 } |
| 3162 | 3170 |
| 3163 static int loopType(ast.Node node) { | |
| 3164 return node.accept(const LoopTypeVisitor()); | |
| 3165 } | |
| 3166 | |
| 3167 bool accept(HStatementInformationVisitor visitor) => | 3171 bool accept(HStatementInformationVisitor visitor) => |
| 3168 visitor.visitLoopInfo(this); | 3172 visitor.visitLoopInfo(this); |
| 3169 } | 3173 } |
| 3170 | 3174 |
| 3171 class HIfBlockInformation implements HStatementInformation { | 3175 class HIfBlockInformation implements HStatementInformation { |
| 3172 final HExpressionInformation condition; | 3176 final HExpressionInformation condition; |
| 3173 final HStatementInformation thenGraph; | 3177 final HStatementInformation thenGraph; |
| 3174 final HStatementInformation elseGraph; | 3178 final HStatementInformation elseGraph; |
| 3175 HIfBlockInformation(this.condition, | 3179 HIfBlockInformation(this.condition, |
| 3176 this.thenGraph, | 3180 this.thenGraph, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3342 class HDynamicType extends HRuntimeType { | 3346 class HDynamicType extends HRuntimeType { |
| 3343 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3347 HDynamicType(DynamicType dartType, TypeMask instructionType) |
| 3344 : super(const <HInstruction>[], dartType, instructionType); | 3348 : super(const <HInstruction>[], dartType, instructionType); |
| 3345 | 3349 |
| 3346 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3350 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
| 3347 | 3351 |
| 3348 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3352 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
| 3349 | 3353 |
| 3350 bool typeEquals(HInstruction other) => other is HDynamicType; | 3354 bool typeEquals(HInstruction other) => other is HDynamicType; |
| 3351 } | 3355 } |
| OLD | NEW |