Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 2575083002: Pass ClosedWorld directly to codegen tasks (Closed)
Patch Set: Updated cf. comment. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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:collection'; 5 import 'dart:collection';
6 6
7 import 'package:js_runtime/shared/embedded_names.dart'; 7 import 'package:js_runtime/shared/embedded_names.dart';
8 8
9 import '../closure.dart'; 9 import '../closure.dart';
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 String get name => 'SSA builder'; 59 String get name => 'SSA builder';
60 60
61 SsaBuilderTask(JavaScriptBackend backend, this.sourceInformationFactory) 61 SsaBuilderTask(JavaScriptBackend backend, this.sourceInformationFactory)
62 : emitter = backend.emitter, 62 : emitter = backend.emitter,
63 backend = backend, 63 backend = backend,
64 compiler = backend.compiler, 64 compiler = backend.compiler,
65 super(backend.compiler.measurer); 65 super(backend.compiler.measurer);
66 66
67 DiagnosticReporter get reporter => compiler.reporter; 67 DiagnosticReporter get reporter => compiler.reporter;
68 68
69 HGraph build(CodegenWorkItem work) { 69 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) {
70 return measure(() { 70 return measure(() {
71 Element element = work.element.implementation; 71 Element element = work.element.implementation;
72 return reporter.withCurrentElement(element, () { 72 return reporter.withCurrentElement(element, () {
73 SsaBuilder builder = new SsaBuilder( 73 SsaBuilder builder = new SsaBuilder(
74 work.element.implementation, 74 work.element.implementation,
75 work.resolvedAst, 75 work.resolvedAst,
76 work.registry, 76 work.registry,
77 backend, 77 backend,
78 closedWorld,
78 emitter.nativeEmitter, 79 emitter.nativeEmitter,
79 sourceInformationFactory); 80 sourceInformationFactory);
80 HGraph graph = builder.build(); 81 HGraph graph = builder.build();
81 82
82 // Default arguments are handled elsewhere, but we must ensure 83 // Default arguments are handled elsewhere, but we must ensure
83 // that the default values are computed during codegen. 84 // that the default values are computed during codegen.
84 if (!identical(element.kind, ElementKind.FIELD)) { 85 if (!identical(element.kind, ElementKind.FIELD)) {
85 FunctionElement function = element; 86 FunctionElement function = element;
86 FunctionSignature signature = function.functionSignature; 87 FunctionSignature signature = function.functionSignature;
87 signature.forEachOptionalParameter((ParameterElement parameter) { 88 signature.forEachOptionalParameter((ParameterElement parameter) {
88 // This ensures the default value will be computed. 89 // This ensures the default value will be computed.
89 ConstantValue constant = 90 ConstantValue constant =
90 backend.constants.getConstantValue(parameter.constant); 91 backend.constants.getConstantValue(parameter.constant);
91 work.registry.registerCompileTimeConstant(constant); 92 work.registry.registerCompileTimeConstant(constant);
92 }); 93 });
93 } 94 }
94 if (compiler.tracer.isEnabled) { 95 if (backend.tracer.isEnabled) {
95 String name; 96 String name;
96 if (element.isClassMember) { 97 if (element.isClassMember) {
97 String className = element.enclosingClass.name; 98 String className = element.enclosingClass.name;
98 String memberName = element.name; 99 String memberName = element.name;
99 name = "$className.$memberName"; 100 name = "$className.$memberName";
100 if (element.isGenerativeConstructorBody) { 101 if (element.isGenerativeConstructorBody) {
101 name = "$name (body)"; 102 name = "$name (body)";
102 } 103 }
103 } else { 104 } else {
104 name = "${element.name}"; 105 name = "${element.name}";
105 } 106 }
106 compiler.tracer.traceCompilation(name); 107 backend.tracer.traceCompilation(name);
107 compiler.tracer.traceGraph('builder', graph); 108 backend.tracer.traceGraph('builder', graph);
108 } 109 }
109 return graph; 110 return graph;
110 }); 111 });
111 }); 112 });
112 } 113 }
113 } 114 }
114 115
115 /** 116 /**
116 * This class builds SSA nodes for functions represented in AST. 117 * This class builds SSA nodes for functions represented in AST.
117 */ 118 */
118 class SsaBuilder extends ast.Visitor 119 class SsaBuilder extends ast.Visitor
119 with 120 with
120 BaseImplementationOfCompoundsMixin, 121 BaseImplementationOfCompoundsMixin,
121 BaseImplementationOfSetIfNullsMixin, 122 BaseImplementationOfSetIfNullsMixin,
122 BaseImplementationOfSuperIndexSetIfNullMixin, 123 BaseImplementationOfSuperIndexSetIfNullMixin,
123 SemanticSendResolvedMixin, 124 SemanticSendResolvedMixin,
124 NewBulkMixin, 125 NewBulkMixin,
125 ErrorBulkMixin, 126 ErrorBulkMixin,
126 GraphBuilder 127 GraphBuilder
127 implements SemanticSendVisitor { 128 implements SemanticSendVisitor {
128 /// The element for which this SSA builder is being used. 129 /// The element for which this SSA builder is being used.
129 final Element target; 130 final Element target;
131 final ClosedWorld closedWorld;
130 132
131 ResolvedAst resolvedAst; 133 ResolvedAst resolvedAst;
132 134
133 /// Used to report information about inlining (which occurs while building the 135 /// Used to report information about inlining (which occurs while building the
134 /// SSA graph), when dump-info is enabled. 136 /// SSA graph), when dump-info is enabled.
135 final InfoReporter infoReporter; 137 final InfoReporter infoReporter;
136 138
137 /// Registry used to enqueue work during codegen, may be null to avoid 139 /// Registry used to enqueue work during codegen, may be null to avoid
138 /// enqueing any work. 140 /// enqueing any work.
139 // TODO(sigmund,johnniwinther): get rid of registry entirely. We should be 141 // TODO(sigmund,johnniwinther): get rid of registry entirely. We should be
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 193
192 /// Handles type check building. 194 /// Handles type check building.
193 TypeBuilder typeBuilder; 195 TypeBuilder typeBuilder;
194 196
195 // TODO(sigmund): make most args optional 197 // TODO(sigmund): make most args optional
196 SsaBuilder( 198 SsaBuilder(
197 this.target, 199 this.target,
198 this.resolvedAst, 200 this.resolvedAst,
199 this.registry, 201 this.registry,
200 JavaScriptBackend backend, 202 JavaScriptBackend backend,
203 this.closedWorld,
201 this.nativeEmitter, 204 this.nativeEmitter,
202 SourceInformationStrategy sourceInformationFactory) 205 SourceInformationStrategy sourceInformationFactory)
203 : this.infoReporter = backend.compiler.dumpInfoTask, 206 : this.infoReporter = backend.compiler.dumpInfoTask,
204 this.backend = backend, 207 this.backend = backend,
205 this.constantSystem = backend.constantSystem, 208 this.constantSystem = backend.constantSystem,
206 this.rti = backend.rti, 209 this.rti = backend.rti,
207 this.inferenceResults = backend.compiler.globalInference.results { 210 this.inferenceResults = backend.compiler.globalInference.results {
208 assert(target.isImplementation); 211 assert(target.isImplementation);
209 compiler = backend.compiler; 212 compiler = backend.compiler;
210 elementInferenceResults = _resultOf(target); 213 elementInferenceResults = _resultOf(target);
(...skipping 5315 matching lines...) Expand 10 before | Expand all | Expand 10 after
5526 HInstruction length = buildGetLength(); 5529 HInstruction length = buildGetLength();
5527 push(new HIdentity(length, originalLength, null, boolType)); 5530 push(new HIdentity(length, originalLength, null, boolType));
5528 pushInvokeStatic( 5531 pushInvokeStatic(
5529 node, helpers.checkConcurrentModificationError, [pop(), array]); 5532 node, helpers.checkConcurrentModificationError, [pop(), array]);
5530 pop(); 5533 pop();
5531 } 5534 }
5532 5535
5533 void buildInitializer() { 5536 void buildInitializer() {
5534 visit(node.expression); 5537 visit(node.expression);
5535 array = pop(); 5538 array = pop();
5536 isFixed = isFixedLength(array.instructionType, compiler); 5539 isFixed = isFixedLength(array.instructionType, closedWorld);
5537 localsHandler.updateLocal( 5540 localsHandler.updateLocal(
5538 indexVariable, graph.addConstantInt(0, compiler)); 5541 indexVariable, graph.addConstantInt(0, compiler));
5539 originalLength = buildGetLength(); 5542 originalLength = buildGetLength();
5540 } 5543 }
5541 5544
5542 HInstruction buildCondition() { 5545 HInstruction buildCondition() {
5543 HInstruction index = localsHandler.readLocal(indexVariable); 5546 HInstruction index = localsHandler.readLocal(indexVariable);
5544 HInstruction length = buildGetLength(); 5547 HInstruction length = buildGetLength();
5545 HInstruction compare = new HLess(index, length, null, boolType); 5548 HInstruction compare = new HLess(index, length, null, boolType);
5546 add(compare); 5549 add(compare);
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
6748 this.oldReturnLocal, 6751 this.oldReturnLocal,
6749 this.oldReturnType, 6752 this.oldReturnType,
6750 this.oldResolvedAst, 6753 this.oldResolvedAst,
6751 this.oldStack, 6754 this.oldStack,
6752 this.oldLocalsHandler, 6755 this.oldLocalsHandler,
6753 this.inTryStatement, 6756 this.inTryStatement,
6754 this.allFunctionsCalledOnce, 6757 this.allFunctionsCalledOnce,
6755 this.oldElementInferenceResults) 6758 this.oldElementInferenceResults)
6756 : super(function); 6759 : super(function);
6757 } 6760 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/ssa/builder_kernel.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698