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 js_backend; | 5 part of js_backend; |
6 | 6 |
7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
8 | 8 |
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 if (element.isConstructor && | 1520 if (element.isConstructor && |
1521 element.enclosingClass == helpers.jsNullClass) { | 1521 element.enclosingClass == helpers.jsNullClass) { |
1522 // Work around a problem compiling JSNull's constructor. | 1522 // Work around a problem compiling JSNull's constructor. |
1523 return const CodegenImpact(); | 1523 return const CodegenImpact(); |
1524 } | 1524 } |
1525 if (kind.category == ElementCategory.VARIABLE) { | 1525 if (kind.category == ElementCategory.VARIABLE) { |
1526 VariableElement variableElement = element; | 1526 VariableElement variableElement = element; |
1527 ConstantExpression constant = variableElement.constant; | 1527 ConstantExpression constant = variableElement.constant; |
1528 if (constant != null) { | 1528 if (constant != null) { |
1529 ConstantValue initialValue = constants.getConstantValue(constant); | 1529 ConstantValue initialValue = constants.getConstantValue(constant); |
1530 assert(invariant(variableElement, initialValue != null, | 1530 if (initialValue != null) { |
1531 message: "Constant expression without value: " | 1531 registerCompileTimeConstant(initialValue, work.registry); |
1532 "${constant.toStructuredText()}.")); | 1532 addCompileTimeConstantForEmission(initialValue); |
1533 registerCompileTimeConstant(initialValue, work.registry); | 1533 // We don't need to generate code for static or top-level |
1534 addCompileTimeConstantForEmission(initialValue); | 1534 // variables. For instance variables, we may need to generate |
1535 // We don't need to generate code for static or top-level | 1535 // the checked setter. |
1536 // variables. For instance variables, we may need to generate | 1536 if (Elements.isStaticOrTopLevel(element)) { |
1537 // the checked setter. | 1537 return impactTransformer |
1538 if (Elements.isStaticOrTopLevel(element)) { | 1538 .transformCodegenImpact(work.registry.worldImpact); |
1539 return impactTransformer | 1539 } |
1540 .transformCodegenImpact(work.registry.worldImpact); | 1540 } else { |
| 1541 assert(invariant( |
| 1542 variableElement, |
| 1543 variableElement.isInstanceMember || |
| 1544 constant.isImplicit || |
| 1545 constant.isPotential, |
| 1546 message: "Constant expression without value: " |
| 1547 "${constant.toStructuredText()}.")); |
1541 } | 1548 } |
1542 } else { | 1549 } else { |
1543 // If the constant-handler was not able to produce a result we have to | 1550 // If the constant-handler was not able to produce a result we have to |
1544 // go through the builder (below) to generate the lazy initializer for | 1551 // go through the builder (below) to generate the lazy initializer for |
1545 // the static variable. | 1552 // the static variable. |
1546 // We also need to register the use of the cyclic-error helper. | 1553 // We also need to register the use of the cyclic-error helper. |
1547 compiler.enqueuer.codegen.registerStaticUse(new StaticUse.staticInvoke( | 1554 compiler.enqueuer.codegen.registerStaticUse(new StaticUse.staticInvoke( |
1548 helpers.cyclicThrowHelper, CallStructure.ONE_ARG)); | 1555 helpers.cyclicThrowHelper, CallStructure.ONE_ARG)); |
1549 } | 1556 } |
1550 } | 1557 } |
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 | 3134 |
3128 @override | 3135 @override |
3129 void onImpactUsed(ImpactUseCase impactUse) { | 3136 void onImpactUsed(ImpactUseCase impactUse) { |
3130 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { | 3137 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { |
3131 // TODO(johnniwinther): Allow emptying when serialization has been | 3138 // TODO(johnniwinther): Allow emptying when serialization has been |
3132 // performed. | 3139 // performed. |
3133 resolution.emptyCache(); | 3140 resolution.emptyCache(); |
3134 } | 3141 } |
3135 } | 3142 } |
3136 } | 3143 } |
OLD | NEW |