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

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

Issue 2302363003: No longer store the compilation-context in WorkItem. (Closed)
Patch Set: ... lint Created 4 years, 3 months 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 DiagnosticReporter get reporter => compiler.reporter; 80 DiagnosticReporter get reporter => compiler.reporter;
81 81
82 HGraph build(CodegenWorkItem work) { 82 HGraph build(CodegenWorkItem work) {
83 return measure(() { 83 return measure(() {
84 Element element = work.element.implementation; 84 Element element = work.element.implementation;
85 return reporter.withCurrentElement(element, () { 85 return reporter.withCurrentElement(element, () {
86 SsaBuilder builder = new SsaBuilder( 86 SsaBuilder builder = new SsaBuilder(
87 work.element.implementation, 87 work.element.implementation,
88 work.resolvedAst, 88 work.resolvedAst,
89 work.compilationContext,
90 work.registry, 89 work.registry,
91 backend, 90 backend,
92 emitter.nativeEmitter, 91 emitter.nativeEmitter,
93 sourceInformationFactory); 92 sourceInformationFactory);
94 HGraph graph = builder.build(); 93 HGraph graph = builder.build();
95 94
96 // Default arguments are handled elsewhere, but we must ensure 95 // Default arguments are handled elsewhere, but we must ensure
97 // that the default values are computed during codegen. 96 // that the default values are computed during codegen.
98 if (!identical(element.kind, ElementKind.FIELD)) { 97 if (!identical(element.kind, ElementKind.FIELD)) {
99 FunctionElement function = element; 98 FunctionElement function = element;
(...skipping 10 matching lines...) Expand all
110 if (element.isClassMember) { 109 if (element.isClassMember) {
111 String className = element.enclosingClass.name; 110 String className = element.enclosingClass.name;
112 String memberName = element.name; 111 String memberName = element.name;
113 name = "$className.$memberName"; 112 name = "$className.$memberName";
114 if (element.isGenerativeConstructorBody) { 113 if (element.isGenerativeConstructorBody) {
115 name = "$name (body)"; 114 name = "$name (body)";
116 } 115 }
117 } else { 116 } else {
118 name = "${element.name}"; 117 name = "${element.name}";
119 } 118 }
120 compiler.tracer.traceCompilation(name, work.compilationContext); 119 compiler.tracer.traceCompilation(name);
121 compiler.tracer.traceGraph('builder', graph); 120 compiler.tracer.traceGraph('builder', graph);
122 } 121 }
123 return graph; 122 return graph;
124 }); 123 });
125 }); 124 });
126 } 125 }
127 } 126 }
128 127
129 // Represents a single break/continue instruction. 128 // Represents a single break/continue instruction.
130 class JumpHandlerEntry { 129 class JumpHandlerEntry {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 implements SemanticSendVisitor { 360 implements SemanticSendVisitor {
362 /// The element for which this SSA builder is being used. 361 /// The element for which this SSA builder is being used.
363 final Element target; 362 final Element target;
364 363
365 ResolvedAst resolvedAst; 364 ResolvedAst resolvedAst;
366 365
367 /// Used to report information about inlining (which occurs while building the 366 /// Used to report information about inlining (which occurs while building the
368 /// SSA graph), when dump-info is enabled. 367 /// SSA graph), when dump-info is enabled.
369 final InfoReporter infoReporter; 368 final InfoReporter infoReporter;
370 369
371 /// If not null, the builder will store in [context] data that is used later
372 /// during the optimization phases.
373 final JavaScriptItemCompilationContext context;
374
375 /// Registry used to enqueue work during codegen, may be null to avoid 370 /// Registry used to enqueue work during codegen, may be null to avoid
376 /// enqueing any work. 371 /// enqueing any work.
377 // TODO(sigmund,johnniwinther): get rid of registry entirely. We should be 372 // TODO(sigmund,johnniwinther): get rid of registry entirely. We should be
378 // able to return the impact as a result after building and avoid enqueing 373 // able to return the impact as a result after building and avoid enqueing
379 // things here. Later the codegen task can decide whether to enqueue 374 // things here. Later the codegen task can decide whether to enqueue
380 // something. In the past this didn't matter as much because the SSA graph was 375 // something. In the past this didn't matter as much because the SSA graph was
381 // used only for codegen, but currently we want to experiment using it for 376 // used only for codegen, but currently we want to experiment using it for
382 // code-analysis too. 377 // code-analysis too.
383 final CodegenRegistry registry; 378 final CodegenRegistry registry;
384 final Compiler compiler; 379 final Compiler compiler;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 bool get isBuildingAsyncFunction { 416 bool get isBuildingAsyncFunction {
422 Element element = sourceElement; 417 Element element = sourceElement;
423 return (element is FunctionElement && 418 return (element is FunctionElement &&
424 element.asyncMarker == AsyncMarker.ASYNC); 419 element.asyncMarker == AsyncMarker.ASYNC);
425 } 420 }
426 421
427 // TODO(sigmund): make most args optional 422 // TODO(sigmund): make most args optional
428 SsaBuilder( 423 SsaBuilder(
429 this.target, 424 this.target,
430 this.resolvedAst, 425 this.resolvedAst,
431 this.context,
432 this.registry, 426 this.registry,
433 JavaScriptBackend backend, 427 JavaScriptBackend backend,
434 this.nativeEmitter, 428 this.nativeEmitter,
435 SourceInformationStrategy sourceInformationFactory) 429 SourceInformationStrategy sourceInformationFactory)
436 : this.compiler = backend.compiler, 430 : this.compiler = backend.compiler,
437 this.infoReporter = backend.compiler.dumpInfoTask, 431 this.infoReporter = backend.compiler.dumpInfoTask,
438 this.backend = backend, 432 this.backend = backend,
439 this.constantSystem = backend.constantSystem, 433 this.constantSystem = backend.constantSystem,
440 this.rti = backend.rti { 434 this.rti = backend.rti {
441 assert(target.isImplementation); 435 assert(target.isImplementation);
(...skipping 3761 matching lines...) Expand 10 before | Expand all | Expand 10 after
4203 typeMask: elementType, 4197 typeMask: elementType,
4204 instanceType: expectedType, 4198 instanceType: expectedType,
4205 sourceInformation: sourceInformation); 4199 sourceInformation: sourceInformation);
4206 removeInlinedInstantiation(expectedType); 4200 removeInlinedInstantiation(expectedType);
4207 } 4201 }
4208 HInstruction newInstance = stack.last; 4202 HInstruction newInstance = stack.last;
4209 if (isFixedList) { 4203 if (isFixedList) {
4210 // Overwrite the element type, in case the allocation site has 4204 // Overwrite the element type, in case the allocation site has
4211 // been inlined. 4205 // been inlined.
4212 newInstance.instructionType = elementType; 4206 newInstance.instructionType = elementType;
4213 if (context != null) { 4207 graph.allocatedFixedLists?.add(newInstance);
4214 context.allocatedFixedLists.add(newInstance);
4215 }
4216 } 4208 }
4217 4209
4218 // The List constructor forwards to a Dart static method that does 4210 // The List constructor forwards to a Dart static method that does
4219 // not know about the type argument. Therefore we special case 4211 // not know about the type argument. Therefore we special case
4220 // this constructor to have the setRuntimeTypeInfo called where 4212 // this constructor to have the setRuntimeTypeInfo called where
4221 // the 'new' is done. 4213 // the 'new' is done.
4222 if (backend.classNeedsRti(coreClasses.listClass) && 4214 if (backend.classNeedsRti(coreClasses.listClass) &&
4223 (isFixedListConstructorCall || 4215 (isFixedListConstructorCall ||
4224 isGrowableListConstructorCall || 4216 isGrowableListConstructorCall ||
4225 isJSArrayTypedConstructor)) { 4217 isJSArrayTypedConstructor)) {
(...skipping 3327 matching lines...) Expand 10 before | Expand all | Expand 10 after
7553 const _LoopTypeVisitor(); 7545 const _LoopTypeVisitor();
7554 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; 7546 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP;
7555 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; 7547 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP;
7556 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; 7548 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP;
7557 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; 7549 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP;
7558 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 7550 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
7559 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 7551 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
7560 int visitSwitchStatement(ast.SwitchStatement node) => 7552 int visitSwitchStatement(ast.SwitchStatement node) =>
7561 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; 7553 HLoopBlockInformation.SWITCH_CONTINUE_LOOP;
7562 } 7554 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/task.dart ('k') | pkg/compiler/lib/src/ssa/interceptor_simplifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698