| 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 new Setlet<FunctionElement>(); | 504 new Setlet<FunctionElement>(); |
| 505 | 505 |
| 506 List<CompilerTask> get tasks { | 506 List<CompilerTask> get tasks { |
| 507 List<CompilerTask> result = functionCompiler.tasks; | 507 List<CompilerTask> result = functionCompiler.tasks; |
| 508 result.add(emitter); | 508 result.add(emitter); |
| 509 result.add(patchResolverTask); | 509 result.add(patchResolverTask); |
| 510 return result; | 510 return result; |
| 511 } | 511 } |
| 512 | 512 |
| 513 final RuntimeTypes rti; | 513 final RuntimeTypes rti; |
| 514 final RuntimeTypesEncoder rtiEncoder; |
| 514 | 515 |
| 515 /// Holds the method "disableTreeShaking" in js_mirrors when | 516 /// Holds the method "disableTreeShaking" in js_mirrors when |
| 516 /// dart:mirrors has been loaded. | 517 /// dart:mirrors has been loaded. |
| 517 FunctionElement disableTreeShakingMarker; | 518 FunctionElement disableTreeShakingMarker; |
| 518 | 519 |
| 519 /// Holds the method "preserveNames" in js_mirrors when | 520 /// Holds the method "preserveNames" in js_mirrors when |
| 520 /// dart:mirrors has been loaded. | 521 /// dart:mirrors has been loaded. |
| 521 FunctionElement preserveNamesMarker; | 522 FunctionElement preserveNamesMarker; |
| 522 | 523 |
| 523 /// Holds the method "preserveMetadata" in js_mirrors when | 524 /// Holds the method "preserveMetadata" in js_mirrors when |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 bool enabledNoSuchMethod = false; | 632 bool enabledNoSuchMethod = false; |
| 632 | 633 |
| 633 final SourceInformationStrategy sourceInformationStrategy; | 634 final SourceInformationStrategy sourceInformationStrategy; |
| 634 | 635 |
| 635 JavaScriptBackend(Compiler compiler, | 636 JavaScriptBackend(Compiler compiler, |
| 636 {bool generateSourceMap: true, | 637 {bool generateSourceMap: true, |
| 637 bool useStartupEmitter: false}) | 638 bool useStartupEmitter: false}) |
| 638 : namer = determineNamer(compiler), | 639 : namer = determineNamer(compiler), |
| 639 oneShotInterceptors = new Map<jsAst.Name, Selector>(), | 640 oneShotInterceptors = new Map<jsAst.Name, Selector>(), |
| 640 interceptedElements = new Map<String, Set<Element>>(), | 641 interceptedElements = new Map<String, Set<Element>>(), |
| 641 rti = new RuntimeTypes(compiler), | 642 rti = new _RuntimeTypes(compiler), |
| 643 rtiEncoder = new _RuntimeTypesEncoder(compiler), |
| 642 specializedGetInterceptors = new Map<jsAst.Name, Set<ClassElement>>(), | 644 specializedGetInterceptors = new Map<jsAst.Name, Set<ClassElement>>(), |
| 643 annotations = new Annotations(compiler), | 645 annotations = new Annotations(compiler), |
| 644 this.sourceInformationStrategy = | 646 this.sourceInformationStrategy = |
| 645 generateSourceMap | 647 generateSourceMap |
| 646 ? (useNewSourceInfo | 648 ? (useNewSourceInfo |
| 647 ? const PositionSourceInformationStrategy() | 649 ? const PositionSourceInformationStrategy() |
| 648 : const StartEndSourceInformationStrategy()) | 650 : const StartEndSourceInformationStrategy()) |
| 649 : const JavaScriptSourceInformationStrategy(), | 651 : const JavaScriptSourceInformationStrategy(), |
| 650 super(compiler) { | 652 super(compiler) { |
| 651 emitter = new CodeEmitterTask( | 653 emitter = new CodeEmitterTask( |
| (...skipping 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3219 TypeVariableElement variable) { | 3221 TypeVariableElement variable) { |
| 3220 assert(registry.isForResolution); | 3222 assert(registry.isForResolution); |
| 3221 registerBackendStaticInvocation(backend.getSetRuntimeTypeInfo(), registry); | 3223 registerBackendStaticInvocation(backend.getSetRuntimeTypeInfo(), registry); |
| 3222 registerBackendStaticInvocation(backend.getGetRuntimeTypeInfo(), registry); | 3224 registerBackendStaticInvocation(backend.getGetRuntimeTypeInfo(), registry); |
| 3223 backend.registerGetRuntimeTypeArgument(registry); | 3225 backend.registerGetRuntimeTypeArgument(registry); |
| 3224 registerBackendInstantiation(backend.compiler.listClass, registry); | 3226 registerBackendInstantiation(backend.compiler.listClass, registry); |
| 3225 registerBackendStaticInvocation(backend.getRuntimeTypeToString(), registry); | 3227 registerBackendStaticInvocation(backend.getRuntimeTypeToString(), registry); |
| 3226 registerBackendStaticInvocation(backend.getCreateRuntimeType(), registry); | 3228 registerBackendStaticInvocation(backend.getCreateRuntimeType(), registry); |
| 3227 needsInt(registry, 'Needed for accessing a type variable literal on this.'); | 3229 needsInt(registry, 'Needed for accessing a type variable literal on this.'); |
| 3228 ClassElement cls = variable.enclosingClass; | 3230 ClassElement cls = variable.enclosingClass; |
| 3229 backend.rti.classesUsingTypeVariableExpression.add(cls); | 3231 backend.rti.registerClassUsingTypeVariableExpression(cls); |
| 3230 } | 3232 } |
| 3231 | 3233 |
| 3232 // TODO(johnniwinther): Maybe split this into [onAssertType] and [onTestType]. | 3234 // TODO(johnniwinther): Maybe split this into [onAssertType] and [onTestType]. |
| 3233 void onIsCheck(DartType type, Registry registry) { | 3235 void onIsCheck(DartType type, Registry registry) { |
| 3234 assert(registry.isForResolution); | 3236 assert(registry.isForResolution); |
| 3235 type = type.unalias(backend.resolution); | 3237 type = type.unalias(backend.resolution); |
| 3236 registerBackendInstantiation(backend.compiler.boolClass, registry); | 3238 registerBackendInstantiation(backend.compiler.boolClass, registry); |
| 3237 bool inCheckedMode = backend.compiler.enableTypeAssertions; | 3239 bool inCheckedMode = backend.compiler.enableTypeAssertions; |
| 3238 if (inCheckedMode) { | 3240 if (inCheckedMode) { |
| 3239 registerBackendStaticInvocation(backend.getThrowRuntimeError(), registry); | 3241 registerBackendStaticInvocation(backend.getThrowRuntimeError(), registry); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3392 } | 3394 } |
| 3393 } | 3395 } |
| 3394 | 3396 |
| 3395 /// Records that [constant] is used by the element behind [registry]. | 3397 /// Records that [constant] is used by the element behind [registry]. |
| 3396 class Dependency { | 3398 class Dependency { |
| 3397 final ConstantValue constant; | 3399 final ConstantValue constant; |
| 3398 final Element annotatedElement; | 3400 final Element annotatedElement; |
| 3399 | 3401 |
| 3400 const Dependency(this.constant, this.annotatedElement); | 3402 const Dependency(this.constant, this.annotatedElement); |
| 3401 } | 3403 } |
| OLD | NEW |