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 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2293 // necessary, but the backend relies on them being resolved. | 2293 // necessary, but the backend relies on them being resolved. |
2294 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets()); | 2294 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets()); |
2295 } | 2295 } |
2296 | 2296 |
2297 if (mustPreserveNames) reporter.log('Preserving names.'); | 2297 if (mustPreserveNames) reporter.log('Preserving names.'); |
2298 | 2298 |
2299 if (mustRetainMetadata) { | 2299 if (mustRetainMetadata) { |
2300 reporter.log('Retaining metadata.'); | 2300 reporter.log('Retaining metadata.'); |
2301 | 2301 |
2302 compiler.libraryLoader.libraries.forEach(retainMetadataOf); | 2302 compiler.libraryLoader.libraries.forEach(retainMetadataOf); |
2303 | |
2304 if (enqueuer.isResolutionQueue) { | 2303 if (enqueuer.isResolutionQueue) { |
2305 /// Register the constant value of [metadata] as live in resolution. | 2304 /// Register the constant value of [metadata] as live in resolution. |
2306 void registerMetadataConstant(MetadataAnnotation metadata) { | 2305 void registerMetadataConstant(MetadataAnnotation metadata) { |
2307 ConstantValue constant = | 2306 ConstantValue constant = |
2308 constants.getConstantValueForMetadata(metadata); | 2307 constants.getConstantValueForMetadata(metadata); |
2309 Dependency dependency = | 2308 Dependency dependency = |
2310 new Dependency(constant, metadata.annotatedElement); | 2309 new Dependency(constant, metadata.annotatedElement); |
2311 metadataConstants.add(dependency); | 2310 metadataConstants.add(dependency); |
2312 registerCompileTimeConstant(dependency.constant, | 2311 registerCompileTimeConstant(dependency.constant, |
2313 new EagerRegistry('EagerRegistry for ${dependency}', enqueuer)); | 2312 new EagerRegistry('EagerRegistry for ${dependency}', enqueuer)); |
(...skipping 29 matching lines...) Expand all Loading... |
2343 if (element.enclosingClass != null) { | 2342 if (element.enclosingClass != null) { |
2344 processElementMetadata(element.enclosingClass); | 2343 processElementMetadata(element.enclosingClass); |
2345 } else { | 2344 } else { |
2346 processLibraryMetadata(element.library); | 2345 processLibraryMetadata(element.library); |
2347 } | 2346 } |
2348 } | 2347 } |
2349 } | 2348 } |
2350 | 2349 |
2351 // TODO(johnniwinther): We should have access to all recently processed | 2350 // TODO(johnniwinther): We should have access to all recently processed |
2352 // elements and process these instead. | 2351 // elements and process these instead. |
2353 compiler.enqueuer.resolution.processedElements.forEach(processElementMetadat
a); | 2352 compiler.enqueuer.resolution.processedElements |
| 2353 .forEach(processElementMetadata); |
2354 } | 2354 } |
2355 | 2355 |
2356 void onQueueClosed() { | 2356 void onQueueClosed() { |
2357 lookupMapAnalysis.onQueueClosed(); | 2357 lookupMapAnalysis.onQueueClosed(); |
2358 jsInteropAnalysis.onQueueClosed(); | 2358 jsInteropAnalysis.onQueueClosed(); |
2359 } | 2359 } |
2360 | 2360 |
2361 void onCodegenStart() { | 2361 void onCodegenStart() { |
2362 lookupMapAnalysis.onCodegenStart(); | 2362 lookupMapAnalysis.onCodegenStart(); |
2363 } | 2363 } |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3068 return transformed; | 3068 return transformed; |
3069 } | 3069 } |
3070 } | 3070 } |
3071 | 3071 |
3072 /// Records that [constant] is used by the element behind [registry]. | 3072 /// Records that [constant] is used by the element behind [registry]. |
3073 class Dependency { | 3073 class Dependency { |
3074 final ConstantValue constant; | 3074 final ConstantValue constant; |
3075 final Element annotatedElement; | 3075 final Element annotatedElement; |
3076 | 3076 |
3077 const Dependency(this.constant, this.annotatedElement); | 3077 const Dependency(this.constant, this.annotatedElement); |
| 3078 |
| 3079 String toString() => '$annotatedElement:${constant.toStructuredText()}'; |
3078 } | 3080 } |
3079 | 3081 |
3080 class JavaScriptImpactStrategy extends ImpactStrategy { | 3082 class JavaScriptImpactStrategy extends ImpactStrategy { |
3081 final Resolution resolution; | 3083 final Resolution resolution; |
3082 final DumpInfoTask dumpInfoTask; | 3084 final DumpInfoTask dumpInfoTask; |
3083 final bool supportDeferredLoad; | 3085 final bool supportDeferredLoad; |
3084 final bool supportDumpInfo; | 3086 final bool supportDumpInfo; |
3085 final bool supportSerialization; | 3087 final bool supportSerialization; |
3086 | 3088 |
3087 JavaScriptImpactStrategy(this.resolution, this.dumpInfoTask, | 3089 JavaScriptImpactStrategy(this.resolution, this.dumpInfoTask, |
(...skipping 25 matching lines...) Expand all Loading... |
3113 | 3115 |
3114 @override | 3116 @override |
3115 void onImpactUsed(ImpactUseCase impactUse) { | 3117 void onImpactUsed(ImpactUseCase impactUse) { |
3116 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { | 3118 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { |
3117 // TODO(johnniwinther): Allow emptying when serialization has been | 3119 // TODO(johnniwinther): Allow emptying when serialization has been |
3118 // performed. | 3120 // performed. |
3119 resolution.emptyCache(); | 3121 resolution.emptyCache(); |
3120 } | 3122 } |
3121 } | 3123 } |
3122 } | 3124 } |
OLD | NEW |