| 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 part of ssa; |
| 6 | 6 |
| 7 abstract class HVisitor<R> { | 7 abstract class HVisitor<R> { |
| 8 R visitAdd(HAdd node); | 8 R visitAdd(HAdd node); |
| 9 R visitBailoutTarget(HBailoutTarget node); | 9 R visitBailoutTarget(HBailoutTarget node); |
| 10 R visitBitAnd(HBitAnd node); | 10 R visitBitAnd(HBitAnd node); |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 | 762 |
| 763 // Type codes. | 763 // Type codes. |
| 764 static const int UNDEFINED_TYPECODE = -1; | 764 static const int UNDEFINED_TYPECODE = -1; |
| 765 static const int BOOLIFY_TYPECODE = 0; | 765 static const int BOOLIFY_TYPECODE = 0; |
| 766 static const int TYPE_GUARD_TYPECODE = 1; | 766 static const int TYPE_GUARD_TYPECODE = 1; |
| 767 static const int BOUNDS_CHECK_TYPECODE = 2; | 767 static const int BOUNDS_CHECK_TYPECODE = 2; |
| 768 static const int INTEGER_CHECK_TYPECODE = 3; | 768 static const int INTEGER_CHECK_TYPECODE = 3; |
| 769 static const int INTERCEPTOR_TYPECODE = 4; | 769 static const int INTERCEPTOR_TYPECODE = 4; |
| 770 static const int ADD_TYPECODE = 5; | 770 static const int ADD_TYPECODE = 5; |
| 771 static const int DIVIDE_TYPECODE = 6; | 771 static const int DIVIDE_TYPECODE = 6; |
| 772 static const int MULTIPLY_TYPECODE = 8; | 772 static const int MULTIPLY_TYPECODE = 7; |
| 773 static const int SUBTRACT_TYPECODE = 9; | 773 static const int SUBTRACT_TYPECODE = 8; |
| 774 static const int SHIFT_LEFT_TYPECODE = 11; | 774 static const int SHIFT_LEFT_TYPECODE = 9; |
| 775 static const int BIT_OR_TYPECODE = 13; | 775 static const int BIT_OR_TYPECODE = 10; |
| 776 static const int BIT_AND_TYPECODE = 14; | 776 static const int BIT_AND_TYPECODE = 11; |
| 777 static const int BIT_XOR_TYPECODE = 15; | 777 static const int BIT_XOR_TYPECODE = 12; |
| 778 static const int NEGATE_TYPECODE = 16; | 778 static const int NEGATE_TYPECODE = 13; |
| 779 static const int BIT_NOT_TYPECODE = 17; | 779 static const int BIT_NOT_TYPECODE = 14; |
| 780 static const int NOT_TYPECODE = 18; | 780 static const int NOT_TYPECODE = 15; |
| 781 static const int IDENTITY_TYPECODE = 20; | 781 static const int IDENTITY_TYPECODE = 16; |
| 782 static const int GREATER_TYPECODE = 21; | 782 static const int GREATER_TYPECODE = 17; |
| 783 static const int GREATER_EQUAL_TYPECODE = 22; | 783 static const int GREATER_EQUAL_TYPECODE = 18; |
| 784 static const int LESS_TYPECODE = 23; | 784 static const int LESS_TYPECODE = 19; |
| 785 static const int LESS_EQUAL_TYPECODE = 24; | 785 static const int LESS_EQUAL_TYPECODE = 20; |
| 786 static const int STATIC_TYPECODE = 25; | 786 static const int STATIC_TYPECODE = 21; |
| 787 static const int STATIC_STORE_TYPECODE = 26; | 787 static const int STATIC_STORE_TYPECODE = 22; |
| 788 static const int FIELD_GET_TYPECODE = 27; | 788 static const int FIELD_GET_TYPECODE = 23; |
| 789 static const int TYPE_CONVERSION_TYPECODE = 28; | 789 static const int TYPE_CONVERSION_TYPECODE = 24; |
| 790 static const int BAILOUT_TARGET_TYPECODE = 29; | 790 static const int BAILOUT_TARGET_TYPECODE = 25; |
| 791 static const int INVOKE_STATIC_TYPECODE = 30; | 791 static const int INVOKE_STATIC_TYPECODE = 26; |
| 792 static const int INVOKE_DYNAMIC_GETTER_TYPECODE = 31; | 792 static const int INDEX_TYPECODE = 27; |
| 793 static const int INDEX_TYPECODE = 32; | 793 static const int IS_TYPECODE = 28; |
| 794 static const int INVOKE_DYNAMIC_TYPECODE = 29; |
| 794 | 795 |
| 795 HInstruction(this.inputs) : id = idCounter++, usedBy = <HInstruction>[]; | 796 HInstruction(this.inputs) : id = idCounter++, usedBy = <HInstruction>[]; |
| 796 | 797 |
| 797 int get hashCode => id; | 798 int get hashCode => id; |
| 798 | 799 |
| 799 bool getFlag(int position) => (flags & (1 << position)) != 0; | 800 bool getFlag(int position) => (flags & (1 << position)) != 0; |
| 800 void setFlag(int position) { flags |= (1 << position); } | 801 void setFlag(int position) { flags |= (1 << position); } |
| 801 void clearFlag(int position) { flags &= ~(1 << position); } | 802 void clearFlag(int position) { flags &= ~(1 << position); } |
| 802 | 803 |
| 803 static int computeDependsOnFlags(int flags) => flags << FLAG_CHANGES_COUNT; | 804 static int computeDependsOnFlags(int flags) => flags << FLAG_CHANGES_COUNT; |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 : super(inputs); | 1321 : super(inputs); |
| 1321 toString() => 'invoke dynamic: $selector'; | 1322 toString() => 'invoke dynamic: $selector'; |
| 1322 HInstruction get receiver => inputs[0]; | 1323 HInstruction get receiver => inputs[0]; |
| 1323 | 1324 |
| 1324 bool get isInterceptorCall { | 1325 bool get isInterceptorCall { |
| 1325 // We know it's a selector call if it follows the interceptor | 1326 // We know it's a selector call if it follows the interceptor |
| 1326 // calling convention, which adds the actual receiver as a | 1327 // calling convention, which adds the actual receiver as a |
| 1327 // parameter to the call. | 1328 // parameter to the call. |
| 1328 return inputs.length - 2 == selector.argumentCount; | 1329 return inputs.length - 2 == selector.argumentCount; |
| 1329 } | 1330 } |
| 1331 |
| 1332 int typeCode() => HInstruction.INVOKE_DYNAMIC_TYPECODE; |
| 1333 bool typeEquals(other) => other is HInvokeDynamic; |
| 1334 bool dataEquals(HInvokeDynamic other) { |
| 1335 return selector == other.selector |
| 1336 && element == other.element; |
| 1337 } |
| 1330 } | 1338 } |
| 1331 | 1339 |
| 1332 class HInvokeClosure extends HInvokeDynamic { | 1340 class HInvokeClosure extends HInvokeDynamic { |
| 1333 HInvokeClosure(Selector selector, List<HInstruction> inputs) | 1341 HInvokeClosure(Selector selector, List<HInstruction> inputs) |
| 1334 : super(selector, null, inputs) { | 1342 : super(selector, null, inputs) { |
| 1335 assert(selector.isClosureCall()); | 1343 assert(selector.isClosureCall()); |
| 1336 } | 1344 } |
| 1337 accept(HVisitor visitor) => visitor.visitInvokeClosure(this); | 1345 accept(HVisitor visitor) => visitor.visitInvokeClosure(this); |
| 1338 } | 1346 } |
| 1339 | 1347 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 if (isSideEffectFree) { | 1391 if (isSideEffectFree) { |
| 1384 setUseGvn(); | 1392 setUseGvn(); |
| 1385 setDependsOnInstancePropertyStore(); | 1393 setDependsOnInstancePropertyStore(); |
| 1386 } else { | 1394 } else { |
| 1387 setDependsOnSomething(); | 1395 setDependsOnSomething(); |
| 1388 setAllSideEffects(); | 1396 setAllSideEffects(); |
| 1389 } | 1397 } |
| 1390 } | 1398 } |
| 1391 toString() => 'invoke dynamic getter: $selector'; | 1399 toString() => 'invoke dynamic getter: $selector'; |
| 1392 accept(HVisitor visitor) => visitor.visitInvokeDynamicGetter(this); | 1400 accept(HVisitor visitor) => visitor.visitInvokeDynamicGetter(this); |
| 1393 | |
| 1394 int typeCode() => HInstruction.INVOKE_DYNAMIC_GETTER_TYPECODE; | |
| 1395 bool typeEquals(other) => other is HInvokeDynamicGetter; | |
| 1396 bool dataEquals(HInvokeDynamicGetter other) => selector == other.selector; | |
| 1397 } | 1401 } |
| 1398 | 1402 |
| 1399 class HInvokeDynamicSetter extends HInvokeDynamicField { | 1403 class HInvokeDynamicSetter extends HInvokeDynamicField { |
| 1400 HInvokeDynamicSetter(selector, element, receiver, value, isSideEffectFree) | 1404 HInvokeDynamicSetter(selector, element, receiver, value, isSideEffectFree) |
| 1401 : super(selector, element, [receiver, value], isSideEffectFree) { | 1405 : super(selector, element, [receiver, value], isSideEffectFree) { |
| 1402 clearAllSideEffects(); | 1406 clearAllSideEffects(); |
| 1403 if (isSideEffectFree) { | 1407 if (isSideEffectFree) { |
| 1404 setChangesInstanceProperty(); | 1408 setChangesInstanceProperty(); |
| 1405 } else { | 1409 } else { |
| 1406 setAllSideEffects(); | 1410 setAllSideEffects(); |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2230 HInstruction getCheck(int index) => inputs[index + 1]; | 2234 HInstruction getCheck(int index) => inputs[index + 1]; |
| 2231 int get checkCount => inputs.length - 1; | 2235 int get checkCount => inputs.length - 1; |
| 2232 | 2236 |
| 2233 bool hasArgumentChecks() => inputs.length > 1; | 2237 bool hasArgumentChecks() => inputs.length > 1; |
| 2234 | 2238 |
| 2235 HType get guaranteedType => HType.BOOLEAN; | 2239 HType get guaranteedType => HType.BOOLEAN; |
| 2236 | 2240 |
| 2237 accept(HVisitor visitor) => visitor.visitIs(this); | 2241 accept(HVisitor visitor) => visitor.visitIs(this); |
| 2238 | 2242 |
| 2239 toString() => "$expression is $typeExpression"; | 2243 toString() => "$expression is $typeExpression"; |
| 2244 |
| 2245 int typeCode() => HInstruction.IS_TYPECODE; |
| 2246 bool typeEquals(HInstruction other) => other is HIs; |
| 2247 bool dataEquals(HIs other) { |
| 2248 return typeExpression == other.typeExpression |
| 2249 && nullOk == other.nullOk; |
| 2250 } |
| 2240 } | 2251 } |
| 2241 | 2252 |
| 2242 class HTypeConversion extends HCheck { | 2253 class HTypeConversion extends HCheck { |
| 2243 HType type; | 2254 HType type; |
| 2244 final int kind; | 2255 final int kind; |
| 2245 | 2256 |
| 2246 static const int NO_CHECK = 0; | 2257 static const int NO_CHECK = 0; |
| 2247 static const int CHECKED_MODE_CHECK = 1; | 2258 static const int CHECKED_MODE_CHECK = 1; |
| 2248 static const int ARGUMENT_TYPE_CHECK = 2; | 2259 static const int ARGUMENT_TYPE_CHECK = 2; |
| 2249 static const int CAST_TYPE_CHECK = 3; | 2260 static const int CAST_TYPE_CHECK = 3; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2635 HBasicBlock get start => expression.start; | 2646 HBasicBlock get start => expression.start; |
| 2636 HBasicBlock get end { | 2647 HBasicBlock get end { |
| 2637 // We don't create a switch block if there are no cases. | 2648 // We don't create a switch block if there are no cases. |
| 2638 assert(!statements.isEmpty); | 2649 assert(!statements.isEmpty); |
| 2639 return statements.last.end; | 2650 return statements.last.end; |
| 2640 } | 2651 } |
| 2641 | 2652 |
| 2642 bool accept(HStatementInformationVisitor visitor) => | 2653 bool accept(HStatementInformationVisitor visitor) => |
| 2643 visitor.visitSwitchInfo(this); | 2654 visitor.visitSwitchInfo(this); |
| 2644 } | 2655 } |
| OLD | NEW |