| 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 import 'dart:math' as math; | 5 import 'dart:math' as math; |
| 6 import 'dart:collection' show Queue; | 6 import 'dart:collection' show Queue; |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 9 import '../common/tasks.dart' show CompilerTask; | 9 import '../common/tasks.dart' show CompilerTask; |
| 10 import '../constants/constant_system.dart'; | 10 import '../constants/constant_system.dart'; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return measure(() { | 73 return measure(() { |
| 74 backend.tracer.traceGraph("codegen", graph); | 74 backend.tracer.traceGraph("codegen", graph); |
| 75 SourceInformation sourceInformation = sourceInformationFactory | 75 SourceInformation sourceInformation = sourceInformationFactory |
| 76 .createBuilderForContext(work.resolvedAst) | 76 .createBuilderForContext(work.resolvedAst) |
| 77 .buildDeclaration(work.resolvedAst); | 77 .buildDeclaration(work.resolvedAst); |
| 78 SsaCodeGenerator codegen = new SsaCodeGenerator( | 78 SsaCodeGenerator codegen = new SsaCodeGenerator( |
| 79 backend.compiler.options, | 79 backend.compiler.options, |
| 80 backend.emitter, | 80 backend.emitter, |
| 81 backend.nativeCodegenEnqueuer, | 81 backend.nativeCodegenEnqueuer, |
| 82 backend.checkedModeHelpers, | 82 backend.checkedModeHelpers, |
| 83 backend.interceptorData, | |
| 84 backend.oneShotInterceptorData, | 83 backend.oneShotInterceptorData, |
| 85 backend.rtiSubstitutions, | 84 backend.rtiSubstitutions, |
| 86 backend.rtiEncoder, | 85 backend.rtiEncoder, |
| 87 backend.namer, | 86 backend.namer, |
| 88 backend.superMemberData, | 87 backend.superMemberData, |
| 89 closedWorld, | 88 closedWorld, |
| 90 work); | 89 work); |
| 91 codegen.visitGraph(graph); | 90 codegen.visitGraph(graph); |
| 92 return new js.Fun(codegen.parameters, codegen.body) | 91 return new js.Fun(codegen.parameters, codegen.body) |
| 93 .withSourceInformation(sourceInformation); | 92 .withSourceInformation(sourceInformation); |
| 94 }); | 93 }); |
| 95 } | 94 } |
| 96 | 95 |
| 97 js.Expression generateMethod( | 96 js.Expression generateMethod( |
| 98 CodegenWorkItem work, HGraph graph, ClosedWorld closedWorld) { | 97 CodegenWorkItem work, HGraph graph, ClosedWorld closedWorld) { |
| 99 return measure(() { | 98 return measure(() { |
| 100 MethodElement element = work.element; | 99 MethodElement element = work.element; |
| 101 if (element.asyncMarker != AsyncMarker.SYNC) { | 100 if (element.asyncMarker != AsyncMarker.SYNC) { |
| 102 work.registry.registerAsyncMarker(element.asyncMarker); | 101 work.registry.registerAsyncMarker(element.asyncMarker); |
| 103 } | 102 } |
| 104 SsaCodeGenerator codegen = new SsaCodeGenerator( | 103 SsaCodeGenerator codegen = new SsaCodeGenerator( |
| 105 backend.compiler.options, | 104 backend.compiler.options, |
| 106 backend.emitter, | 105 backend.emitter, |
| 107 backend.nativeCodegenEnqueuer, | 106 backend.nativeCodegenEnqueuer, |
| 108 backend.checkedModeHelpers, | 107 backend.checkedModeHelpers, |
| 109 backend.interceptorData, | |
| 110 backend.oneShotInterceptorData, | 108 backend.oneShotInterceptorData, |
| 111 backend.rtiSubstitutions, | 109 backend.rtiSubstitutions, |
| 112 backend.rtiEncoder, | 110 backend.rtiEncoder, |
| 113 backend.namer, | 111 backend.namer, |
| 114 backend.superMemberData, | 112 backend.superMemberData, |
| 115 closedWorld, | 113 closedWorld, |
| 116 work); | 114 work); |
| 117 codegen.visitGraph(graph); | 115 codegen.visitGraph(graph); |
| 118 backend.tracer.traceGraph("codegen", graph); | 116 backend.tracer.traceGraph("codegen", graph); |
| 119 return buildJavaScriptFunction( | 117 return buildJavaScriptFunction( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 144 /** | 142 /** |
| 145 * Whether we are currently generating expressions instead of statements. | 143 * Whether we are currently generating expressions instead of statements. |
| 146 * This includes declarations, which are generated as expressions. | 144 * This includes declarations, which are generated as expressions. |
| 147 */ | 145 */ |
| 148 bool isGeneratingExpression = false; | 146 bool isGeneratingExpression = false; |
| 149 | 147 |
| 150 final CompilerOptions _options; | 148 final CompilerOptions _options; |
| 151 final CodeEmitterTask _emitter; | 149 final CodeEmitterTask _emitter; |
| 152 final native.NativeCodegenEnqueuer _nativeEnqueuer; | 150 final native.NativeCodegenEnqueuer _nativeEnqueuer; |
| 153 final CheckedModeHelpers _checkedModeHelpers; | 151 final CheckedModeHelpers _checkedModeHelpers; |
| 154 final InterceptorData _interceptorData; | |
| 155 final OneShotInterceptorData _oneShotInterceptorData; | 152 final OneShotInterceptorData _oneShotInterceptorData; |
| 156 final RuntimeTypesSubstitutions _rtiSubstitutions; | 153 final RuntimeTypesSubstitutions _rtiSubstitutions; |
| 157 final RuntimeTypesEncoder _rtiEncoder; | 154 final RuntimeTypesEncoder _rtiEncoder; |
| 158 final Namer _namer; | 155 final Namer _namer; |
| 159 final SuperMemberData _superMemberData; | 156 final SuperMemberData _superMemberData; |
| 160 final ClosedWorld _closedWorld; | 157 final ClosedWorld _closedWorld; |
| 161 final CodegenWorkItem _work; | 158 final CodegenWorkItem _work; |
| 162 | 159 |
| 163 final Set<HInstruction> generateAtUseSite; | 160 final Set<HInstruction> generateAtUseSite; |
| 164 final Set<HInstruction> controlFlowOperators; | 161 final Set<HInstruction> controlFlowOperators; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 SubGraph subGraph; | 198 SubGraph subGraph; |
| 202 | 199 |
| 203 // Pending blocks than need to be visited as part of current subgraph. | 200 // Pending blocks than need to be visited as part of current subgraph. |
| 204 Queue<HBasicBlock> blockQueue; | 201 Queue<HBasicBlock> blockQueue; |
| 205 | 202 |
| 206 SsaCodeGenerator( | 203 SsaCodeGenerator( |
| 207 this._options, | 204 this._options, |
| 208 this._emitter, | 205 this._emitter, |
| 209 this._nativeEnqueuer, | 206 this._nativeEnqueuer, |
| 210 this._checkedModeHelpers, | 207 this._checkedModeHelpers, |
| 211 this._interceptorData, | |
| 212 this._oneShotInterceptorData, | 208 this._oneShotInterceptorData, |
| 213 this._rtiSubstitutions, | 209 this._rtiSubstitutions, |
| 214 this._rtiEncoder, | 210 this._rtiEncoder, |
| 215 this._namer, | 211 this._namer, |
| 216 this._superMemberData, | 212 this._superMemberData, |
| 217 this._closedWorld, | 213 this._closedWorld, |
| 218 this._work, | 214 this._work, |
| 219 {SourceInformation sourceInformation}) | 215 {SourceInformation sourceInformation}) |
| 220 : declaredLocals = new Set<String>(), | 216 : declaredLocals = new Set<String>(), |
| 221 collectedVariableDeclarations = new Set<String>(), | 217 collectedVariableDeclarations = new Set<String>(), |
| 222 currentContainer = new js.Block.empty(), | 218 currentContainer = new js.Block.empty(), |
| 223 parameters = <js.Parameter>[], | 219 parameters = <js.Parameter>[], |
| 224 expressionStack = <js.Expression>[], | 220 expressionStack = <js.Expression>[], |
| 225 oldContainerStack = <js.Block>[], | 221 oldContainerStack = <js.Block>[], |
| 226 generateAtUseSite = new Set<HInstruction>(), | 222 generateAtUseSite = new Set<HInstruction>(), |
| 227 controlFlowOperators = new Set<HInstruction>(), | 223 controlFlowOperators = new Set<HInstruction>(), |
| 228 breakAction = new Map<Entity, EntityAction>(), | 224 breakAction = new Map<Entity, EntityAction>(), |
| 229 continueAction = new Map<Entity, EntityAction>(); | 225 continueAction = new Map<Entity, EntityAction>(); |
| 230 | 226 |
| 231 CodegenRegistry get _registry => _work.registry; | 227 CodegenRegistry get _registry => _work.registry; |
| 232 | 228 |
| 233 CommonElements get _commonElements => _closedWorld.commonElements; | 229 CommonElements get _commonElements => _closedWorld.commonElements; |
| 234 | 230 |
| 235 ConstantSystem get _constantSystem => _closedWorld.constantSystem; | 231 ConstantSystem get _constantSystem => _closedWorld.constantSystem; |
| 236 | 232 |
| 237 NativeData get _nativeData => _closedWorld.nativeData; | 233 NativeData get _nativeData => _closedWorld.nativeData; |
| 238 | 234 |
| 235 InterceptorData get _interceptorData => _closedWorld.interceptorData; |
| 236 |
| 239 bool isGenerateAtUseSite(HInstruction instruction) { | 237 bool isGenerateAtUseSite(HInstruction instruction) { |
| 240 return generateAtUseSite.contains(instruction); | 238 return generateAtUseSite.contains(instruction); |
| 241 } | 239 } |
| 242 | 240 |
| 243 bool hasNonBitOpUser(HInstruction instruction, Set<HPhi> phiSet) { | 241 bool hasNonBitOpUser(HInstruction instruction, Set<HPhi> phiSet) { |
| 244 for (HInstruction user in instruction.usedBy) { | 242 for (HInstruction user in instruction.usedBy) { |
| 245 if (user is HPhi) { | 243 if (user is HPhi) { |
| 246 if (!phiSet.contains(user)) { | 244 if (!phiSet.contains(user)) { |
| 247 phiSet.add(user); | 245 phiSet.add(user); |
| 248 if (hasNonBitOpUser(user, phiSet)) return true; | 246 if (hasNonBitOpUser(user, phiSet)) return true; |
| (...skipping 2789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3038 return _closedWorld.anyStrictSubclassOf(cls, (ClassEntity subclass) { | 3036 return _closedWorld.anyStrictSubclassOf(cls, (ClassEntity subclass) { |
| 3039 return !_rtiSubstitutions.isTrivialSubstitution(subclass, cls); | 3037 return !_rtiSubstitutions.isTrivialSubstitution(subclass, cls); |
| 3040 }); | 3038 }); |
| 3041 } | 3039 } |
| 3042 | 3040 |
| 3043 @override | 3041 @override |
| 3044 void visitRef(HRef node) { | 3042 void visitRef(HRef node) { |
| 3045 visit(node.value); | 3043 visit(node.value); |
| 3046 } | 3044 } |
| 3047 } | 3045 } |
| OLD | NEW |