| 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 library dart2js.js_emitter.code_emitter_task; | 5 library dart2js.js_emitter.code_emitter_task; |
| 6 | 6 |
| 7 import 'package:js_runtime/shared/embedded_names.dart' show JsBuiltin; | 7 import 'package:js_runtime/shared/embedded_names.dart' show JsBuiltin; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/tasks.dart' show CompilerTask; | 10 import '../common/tasks.dart' show CompilerTask; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 /// The given type [e] might be a Typedef. | 141 /// The given type [e] might be a Typedef. |
| 142 jsAst.Expression typeAccess(Entity e) { | 142 jsAst.Expression typeAccess(Entity e) { |
| 143 return emitter.typeAccess(e); | 143 return emitter.typeAccess(e); |
| 144 } | 144 } |
| 145 | 145 |
| 146 /// Returns the JS template for the given [builtin]. | 146 /// Returns the JS template for the given [builtin]. |
| 147 jsAst.Template builtinTemplateFor(JsBuiltin builtin) { | 147 jsAst.Template builtinTemplateFor(JsBuiltin builtin) { |
| 148 return emitter.templateForBuiltin(builtin); | 148 return emitter.templateForBuiltin(builtin); |
| 149 } | 149 } |
| 150 | 150 |
| 151 Set<ClassEntity> _finalizeRti() { | 151 void _finalizeRti() { |
| 152 // Compute the required type checks to know which classes need a | 152 // Compute the required type checks to know which classes need a |
| 153 // 'is$' method. | 153 // 'is$' method. |
| 154 typeTestRegistry.computeRequiredTypeChecks(); | 154 typeTestRegistry.computeRequiredTypeChecks(backend.rtiChecksBuilder); |
| 155 // Compute the classes needed by RTI. | 155 // Compute the classes needed by RTI. |
| 156 return typeTestRegistry.computeRtiNeededClasses(); | 156 typeTestRegistry.computeRtiNeededClasses(backend.rtiSubstitutions, |
| 157 backend.mirrorsData, backend.generatedCode.keys); |
| 157 } | 158 } |
| 158 | 159 |
| 159 /// Creates the [Emitter] for this task. | 160 /// Creates the [Emitter] for this task. |
| 160 void createEmitter(Namer namer, ClosedWorld closedWorld, | 161 void createEmitter(Namer namer, ClosedWorld closedWorld, |
| 161 CodegenWorldBuilder codegenWorldBuilder) { | 162 CodegenWorldBuilder codegenWorldBuilder) { |
| 162 measure(() { | 163 measure(() { |
| 163 _emitter = _emitterFactory.createEmitter(this, namer, closedWorld); | 164 _emitter = _emitterFactory.createEmitter(this, namer, closedWorld); |
| 164 metadataCollector = new MetadataCollector( | 165 metadataCollector = new MetadataCollector( |
| 165 compiler.options, | 166 compiler.options, |
| 166 compiler.reporter, | 167 compiler.reporter, |
| 167 compiler.deferredLoadTask, | 168 compiler.deferredLoadTask, |
| 168 _emitter, | 169 _emitter, |
| 169 backend.constants, | 170 backend.constants, |
| 170 backend.typeVariableCodegenAnalysis, | 171 backend.typeVariableCodegenAnalysis, |
| 171 backend.mirrorsData, | 172 backend.mirrorsData, |
| 172 backend.rtiEncoder); | 173 backend.rtiEncoder); |
| 173 typeTestRegistry = new TypeTestRegistry( | 174 typeTestRegistry = new TypeTestRegistry(codegenWorldBuilder, closedWorld); |
| 174 codegenWorldBuilder, compiler.backend, closedWorld); | |
| 175 }); | 175 }); |
| 176 } | 176 } |
| 177 | 177 |
| 178 int assembleProgram(Namer namer, ClosedWorld closedWorld) { | 178 int assembleProgram(Namer namer, ClosedWorld closedWorld) { |
| 179 return measure(() { | 179 return measure(() { |
| 180 Set<ClassEntity> rtiNeededClasses = _finalizeRti(); | 180 _finalizeRti(); |
| 181 ProgramBuilder programBuilder = new ProgramBuilder( | 181 ProgramBuilder programBuilder = new ProgramBuilder( |
| 182 compiler.options, | 182 compiler.options, |
| 183 compiler.commonElements, | 183 compiler.commonElements, |
| 184 compiler.types, | 184 compiler.types, |
| 185 compiler.deferredLoadTask, | 185 compiler.deferredLoadTask, |
| 186 compiler.closureToClassMapper, | 186 compiler.closureToClassMapper, |
| 187 compiler.codegenWorldBuilder, | 187 compiler.codegenWorldBuilder, |
| 188 backend.nativeCodegenEnqueuer, | 188 backend.nativeCodegenEnqueuer, |
| 189 backend.backendUsage, | 189 backend.backendUsage, |
| 190 backend.constants, | 190 backend.constants, |
| 191 backend.nativeData, | 191 backend.nativeData, |
| 192 backend.rtiNeed, | 192 backend.rtiNeed, |
| 193 backend.mirrorsData, | 193 backend.mirrorsData, |
| 194 backend.interceptorData, | 194 backend.interceptorData, |
| 195 backend.superMemberData, | 195 backend.superMemberData, |
| 196 backend.rtiChecks, | 196 typeTestRegistry.rtiChecks, |
| 197 backend.rtiEncoder, | 197 backend.rtiEncoder, |
| 198 backend.rtiSubstitutions, | 198 backend.rtiSubstitutions, |
| 199 backend.jsInteropAnalysis, | 199 backend.jsInteropAnalysis, |
| 200 backend.oneShotInterceptorData, | 200 backend.oneShotInterceptorData, |
| 201 backend.customElementsCodegenAnalysis, | 201 backend.customElementsCodegenAnalysis, |
| 202 backend.generatedCode, | 202 backend.generatedCode, |
| 203 namer, | 203 namer, |
| 204 this, | 204 this, |
| 205 closedWorld, | 205 closedWorld, |
| 206 rtiNeededClasses, | 206 typeTestRegistry.rtiNeededClasses, |
| 207 compiler.mainFunction, | 207 compiler.mainFunction, |
| 208 isMockCompilation: compiler.isMockCompilation); | 208 isMockCompilation: compiler.isMockCompilation); |
| 209 int size = emitter.emitProgram(programBuilder); | 209 int size = emitter.emitProgram(programBuilder); |
| 210 // TODO(floitsch): we shouldn't need the `neededClasses` anymore. | 210 // TODO(floitsch): we shouldn't need the `neededClasses` anymore. |
| 211 neededClasses = programBuilder.collector.neededClasses; | 211 neededClasses = programBuilder.collector.neededClasses; |
| 212 return size; | 212 return size; |
| 213 }); | 213 }); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 /// Returns the JS code for accessing the given [constant]. | 272 /// Returns the JS code for accessing the given [constant]. |
| 273 jsAst.Expression constantReference(ConstantValue constant); | 273 jsAst.Expression constantReference(ConstantValue constant); |
| 274 | 274 |
| 275 /// Returns the JS template for the given [builtin]. | 275 /// Returns the JS template for the given [builtin]. |
| 276 jsAst.Template templateForBuiltin(JsBuiltin builtin); | 276 jsAst.Template templateForBuiltin(JsBuiltin builtin); |
| 277 | 277 |
| 278 /// Returns the size of the code generated for a given output [unit]. | 278 /// Returns the size of the code generated for a given output [unit]. |
| 279 int generatedSize(OutputUnit unit); | 279 int generatedSize(OutputUnit unit); |
| 280 } | 280 } |
| OLD | NEW |