| 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 visitAwait(HAwait node); | 9 R visitAwait(HAwait node); |
| 10 R visitBitAnd(HBitAnd node); | 10 R visitBitAnd(HBitAnd node); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 R visitLocalValue(HLocalValue node); | 49 R visitLocalValue(HLocalValue node); |
| 50 R visitLoopBranch(HLoopBranch node); | 50 R visitLoopBranch(HLoopBranch node); |
| 51 R visitMultiply(HMultiply node); | 51 R visitMultiply(HMultiply node); |
| 52 R visitNegate(HNegate node); | 52 R visitNegate(HNegate node); |
| 53 R visitNot(HNot node); | 53 R visitNot(HNot node); |
| 54 R visitOneShotInterceptor(HOneShotInterceptor node); | 54 R visitOneShotInterceptor(HOneShotInterceptor node); |
| 55 R visitParameterValue(HParameterValue node); | 55 R visitParameterValue(HParameterValue node); |
| 56 R visitPhi(HPhi node); | 56 R visitPhi(HPhi node); |
| 57 R visitRangeConversion(HRangeConversion node); | 57 R visitRangeConversion(HRangeConversion node); |
| 58 R visitReadModifyWrite(HReadModifyWrite node); | 58 R visitReadModifyWrite(HReadModifyWrite node); |
| 59 R visitRef(HRef node); |
| 59 R visitReturn(HReturn node); | 60 R visitReturn(HReturn node); |
| 60 R visitShiftLeft(HShiftLeft node); | 61 R visitShiftLeft(HShiftLeft node); |
| 61 R visitShiftRight(HShiftRight node); | 62 R visitShiftRight(HShiftRight node); |
| 62 R visitStatic(HStatic node); | 63 R visitStatic(HStatic node); |
| 63 R visitStaticStore(HStaticStore node); | 64 R visitStaticStore(HStaticStore node); |
| 64 R visitStringConcat(HStringConcat node); | 65 R visitStringConcat(HStringConcat node); |
| 65 R visitStringify(HStringify node); | 66 R visitStringify(HStringify node); |
| 66 R visitSubtract(HSubtract node); | 67 R visitSubtract(HSubtract node); |
| 67 R visitSwitch(HSwitch node); | 68 R visitSwitch(HSwitch node); |
| 68 R visitThis(HThis node); | 69 R visitThis(HThis node); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 visitLoopBranch(HLoopBranch node) => visitConditionalBranch(node); | 341 visitLoopBranch(HLoopBranch node) => visitConditionalBranch(node); |
| 341 visitNegate(HNegate node) => visitInvokeUnary(node); | 342 visitNegate(HNegate node) => visitInvokeUnary(node); |
| 342 visitNot(HNot node) => visitInstruction(node); | 343 visitNot(HNot node) => visitInstruction(node); |
| 343 visitOneShotInterceptor(HOneShotInterceptor node) | 344 visitOneShotInterceptor(HOneShotInterceptor node) |
| 344 => visitInvokeDynamic(node); | 345 => visitInvokeDynamic(node); |
| 345 visitPhi(HPhi node) => visitInstruction(node); | 346 visitPhi(HPhi node) => visitInstruction(node); |
| 346 visitMultiply(HMultiply node) => visitBinaryArithmetic(node); | 347 visitMultiply(HMultiply node) => visitBinaryArithmetic(node); |
| 347 visitParameterValue(HParameterValue node) => visitLocalValue(node); | 348 visitParameterValue(HParameterValue node) => visitLocalValue(node); |
| 348 visitRangeConversion(HRangeConversion node) => visitCheck(node); | 349 visitRangeConversion(HRangeConversion node) => visitCheck(node); |
| 349 visitReadModifyWrite(HReadModifyWrite node) => visitInstruction(node); | 350 visitReadModifyWrite(HReadModifyWrite node) => visitInstruction(node); |
| 351 visitRef(HRef node) => node.value.accept(this); |
| 350 visitReturn(HReturn node) => visitControlFlow(node); | 352 visitReturn(HReturn node) => visitControlFlow(node); |
| 351 visitShiftLeft(HShiftLeft node) => visitBinaryBitOp(node); | 353 visitShiftLeft(HShiftLeft node) => visitBinaryBitOp(node); |
| 352 visitShiftRight(HShiftRight node) => visitBinaryBitOp(node); | 354 visitShiftRight(HShiftRight node) => visitBinaryBitOp(node); |
| 353 visitSubtract(HSubtract node) => visitBinaryArithmetic(node); | 355 visitSubtract(HSubtract node) => visitBinaryArithmetic(node); |
| 354 visitSwitch(HSwitch node) => visitControlFlow(node); | 356 visitSwitch(HSwitch node) => visitControlFlow(node); |
| 355 visitStatic(HStatic node) => visitInstruction(node); | 357 visitStatic(HStatic node) => visitInstruction(node); |
| 356 visitStaticStore(HStaticStore node) => visitInstruction(node); | 358 visitStaticStore(HStaticStore node) => visitInstruction(node); |
| 357 visitStringConcat(HStringConcat node) => visitInstruction(node); | 359 visitStringConcat(HStringConcat node) => visitInstruction(node); |
| 358 visitStringify(HStringify node) => visitInstruction(node); | 360 visitStringify(HStringify node) => visitInstruction(node); |
| 359 visitThis(HThis node) => visitParameterValue(node); | 361 visitThis(HThis node) => visitParameterValue(node); |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 | 1302 |
| 1301 /** | 1303 /** |
| 1302 * Return whether the instructions do not belong to a loop or | 1304 * Return whether the instructions do not belong to a loop or |
| 1303 * belong to the same loop. | 1305 * belong to the same loop. |
| 1304 */ | 1306 */ |
| 1305 bool hasSameLoopHeaderAs(HInstruction other) { | 1307 bool hasSameLoopHeaderAs(HInstruction other) { |
| 1306 return block.enclosingLoopHeader == other.block.enclosingLoopHeader; | 1308 return block.enclosingLoopHeader == other.block.enclosingLoopHeader; |
| 1307 } | 1309 } |
| 1308 } | 1310 } |
| 1309 | 1311 |
| 1312 /// A reference to a [HInstruction] that can hold its own source information. |
| 1313 /// |
| 1314 /// This used for attaching source information to reads of locals. |
| 1315 class HRef extends HInstruction { |
| 1316 HRef(HInstruction value, SourceInformation sourceInformation) |
| 1317 : super([value], value.instructionType) { |
| 1318 this.sourceInformation = sourceInformation; |
| 1319 } |
| 1320 |
| 1321 HInstruction get value => inputs[0]; |
| 1322 |
| 1323 @override |
| 1324 accept(HVisitor visitor) => visitor.visitRef(this); |
| 1325 |
| 1326 String toString() => 'HRef(${value})'; |
| 1327 } |
| 1328 |
| 1310 /** | 1329 /** |
| 1311 * Late instructions are used after the main optimization phases. They capture | 1330 * Late instructions are used after the main optimization phases. They capture |
| 1312 * codegen decisions just prior to generating JavaScript. | 1331 * codegen decisions just prior to generating JavaScript. |
| 1313 */ | 1332 */ |
| 1314 abstract class HLateInstruction extends HInstruction { | 1333 abstract class HLateInstruction extends HInstruction { |
| 1315 HLateInstruction(List<HInstruction> inputs, TypeMask type) | 1334 HLateInstruction(List<HInstruction> inputs, TypeMask type) |
| 1316 : super(inputs, type); | 1335 : super(inputs, type); |
| 1317 } | 1336 } |
| 1318 | 1337 |
| 1319 class HBoolify extends HInstruction { | 1338 class HBoolify extends HInstruction { |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 | 1726 |
| 1708 HLocalAccess(this.variable, List<HInstruction> inputs, TypeMask type) | 1727 HLocalAccess(this.variable, List<HInstruction> inputs, TypeMask type) |
| 1709 : super(inputs, type); | 1728 : super(inputs, type); |
| 1710 | 1729 |
| 1711 HInstruction get receiver => inputs[0]; | 1730 HInstruction get receiver => inputs[0]; |
| 1712 } | 1731 } |
| 1713 | 1732 |
| 1714 class HLocalGet extends HLocalAccess { | 1733 class HLocalGet extends HLocalAccess { |
| 1715 // No need to use GVN for a [HLocalGet], it is just a local | 1734 // No need to use GVN for a [HLocalGet], it is just a local |
| 1716 // access. | 1735 // access. |
| 1717 HLocalGet(Local variable, HLocalValue local, TypeMask type) | 1736 HLocalGet(Local variable, HLocalValue local, TypeMask type, |
| 1718 : super(variable, <HInstruction>[local], type); | 1737 SourceInformation sourceInformation) |
| 1738 : super(variable, <HInstruction>[local], type) { |
| 1739 this.sourceInformation = sourceInformation; |
| 1740 } |
| 1719 | 1741 |
| 1720 accept(HVisitor visitor) => visitor.visitLocalGet(this); | 1742 accept(HVisitor visitor) => visitor.visitLocalGet(this); |
| 1721 | 1743 |
| 1722 HLocalValue get local => inputs[0]; | 1744 HLocalValue get local => inputs[0]; |
| 1723 } | 1745 } |
| 1724 | 1746 |
| 1725 class HLocalSet extends HLocalAccess { | 1747 class HLocalSet extends HLocalAccess { |
| 1726 HLocalSet(Local variable, HLocalValue local, HInstruction value) | 1748 HLocalSet(Local variable, HLocalValue local, HInstruction value) |
| 1727 : super(variable, <HInstruction>[local, value], | 1749 : super(variable, <HInstruction>[local, value], |
| 1728 const TypeMask.nonNullEmpty()); | 1750 const TypeMask.nonNullEmpty()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1788 bool isJsStatement() => isStatement; | 1810 bool isJsStatement() => isStatement; |
| 1789 bool canThrow() => canBeNull() | 1811 bool canThrow() => canBeNull() |
| 1790 ? throwBehavior.canThrow | 1812 ? throwBehavior.canThrow |
| 1791 : throwBehavior.onNonNull.canThrow; | 1813 : throwBehavior.onNonNull.canThrow; |
| 1792 | 1814 |
| 1793 bool onlyThrowsNSM() => throwBehavior.isOnlyNullNSMGuard; | 1815 bool onlyThrowsNSM() => throwBehavior.isOnlyNullNSMGuard; |
| 1794 | 1816 |
| 1795 bool get isAllocation => nativeBehavior != null && | 1817 bool get isAllocation => nativeBehavior != null && |
| 1796 nativeBehavior.isAllocation && | 1818 nativeBehavior.isAllocation && |
| 1797 !canBeNull(); | 1819 !canBeNull(); |
| 1820 |
| 1821 String toString() => 'HForeignCode("${codeTemplate.source}",$inputs)'; |
| 1798 } | 1822 } |
| 1799 | 1823 |
| 1800 class HForeignNew extends HForeign { | 1824 class HForeignNew extends HForeign { |
| 1801 ClassElement element; | 1825 ClassElement element; |
| 1802 | 1826 |
| 1803 /// If this field is not `null`, this call is from an inlined constructor and | 1827 /// If this field is not `null`, this call is from an inlined constructor and |
| 1804 /// we have to register the instantiated type in the code generator. The | 1828 /// we have to register the instantiated type in the code generator. The |
| 1805 /// [instructionType] of this node is not enough, because we also need the | 1829 /// [instructionType] of this node is not enough, because we also need the |
| 1806 /// type arguments. See also [SsaFromAstMixin.currentInlinedInstantiations]. | 1830 /// type arguments. See also [SsaFromAstMixin.currentInlinedInstantiations]. |
| 1807 List<DartType> instantiatedTypes; | 1831 List<DartType> instantiatedTypes; |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2389 | 2413 |
| 2390 // inputs[0] is initially the only input, the receiver. | 2414 // inputs[0] is initially the only input, the receiver. |
| 2391 | 2415 |
| 2392 // inputs[1] is a constant interceptor when the interceptor is a constant | 2416 // inputs[1] is a constant interceptor when the interceptor is a constant |
| 2393 // except for a `null` receiver. This is used when the receiver can't be | 2417 // except for a `null` receiver. This is used when the receiver can't be |
| 2394 // falsy, except for `null`, allowing the generation of code like | 2418 // falsy, except for `null`, allowing the generation of code like |
| 2395 // | 2419 // |
| 2396 // (a && C.JSArray_methods).get$first(a) | 2420 // (a && C.JSArray_methods).get$first(a) |
| 2397 // | 2421 // |
| 2398 | 2422 |
| 2399 HInterceptor(HInstruction receiver, TypeMask type) | 2423 HInterceptor(HInstruction receiver, |
| 2424 TypeMask type) |
| 2400 : super(<HInstruction>[receiver], type) { | 2425 : super(<HInstruction>[receiver], type) { |
| 2426 this.sourceInformation = receiver.sourceInformation; |
| 2401 sideEffects.clearAllSideEffects(); | 2427 sideEffects.clearAllSideEffects(); |
| 2402 sideEffects.clearAllDependencies(); | 2428 sideEffects.clearAllDependencies(); |
| 2403 setUseGvn(); | 2429 setUseGvn(); |
| 2404 } | 2430 } |
| 2405 | 2431 |
| 2406 String toString() => 'interceptor on $interceptedClasses'; | 2432 String toString() => 'interceptor on $interceptedClasses'; |
| 2407 accept(HVisitor visitor) => visitor.visitInterceptor(this); | 2433 accept(HVisitor visitor) => visitor.visitInterceptor(this); |
| 2408 HInstruction get receiver => inputs[0]; | 2434 HInstruction get receiver => inputs[0]; |
| 2409 | 2435 |
| 2410 bool get isConditionalConstantInterceptor => inputs.length == 2; | 2436 bool get isConditionalConstantInterceptor => inputs.length == 2; |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3243 class HDynamicType extends HRuntimeType { | 3269 class HDynamicType extends HRuntimeType { |
| 3244 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3270 HDynamicType(DynamicType dartType, TypeMask instructionType) |
| 3245 : super(const <HInstruction>[], dartType, instructionType); | 3271 : super(const <HInstruction>[], dartType, instructionType); |
| 3246 | 3272 |
| 3247 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3273 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
| 3248 | 3274 |
| 3249 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3275 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
| 3250 | 3276 |
| 3251 bool typeEquals(HInstruction other) => other is HDynamicType; | 3277 bool typeEquals(HInstruction other) => other is HDynamicType; |
| 3252 } | 3278 } |
| OLD | NEW |