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

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

Issue 2894893002: Add ElementCodegenWorldBuilder (Closed)
Patch Set: Updated cf. comments. Created 3 years, 7 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 library ssa; 5 library ssa;
6 6
7 import '../common/codegen.dart' show CodegenWorkItem;
8 import '../common/tasks.dart' show CompilerTask; 7 import '../common/tasks.dart' show CompilerTask;
9 import '../elements/elements.dart' show Element, FunctionElement; 8 import '../elements/elements.dart' show Element, FunctionElement;
10 import '../io/source_information.dart'; 9 import '../io/source_information.dart';
11 import '../js/js.dart' as js; 10 import '../js/js.dart' as js;
12 import '../js_backend/backend.dart' show JavaScriptBackend, FunctionCompiler; 11 import '../js_backend/backend.dart' show JavaScriptBackend, FunctionCompiler;
12 import '../js_backend/element_strategy.dart' show ElementCodegenWorkItem;
13 import '../world.dart' show ClosedWorld; 13 import '../world.dart' show ClosedWorld;
14 14
15 import 'builder.dart'; 15 import 'builder.dart';
16 import 'builder_kernel.dart'; 16 import 'builder_kernel.dart';
17 import 'codegen.dart'; 17 import 'codegen.dart';
18 import 'nodes.dart'; 18 import 'nodes.dart';
19 import 'optimize.dart'; 19 import 'optimize.dart';
20 20
21 class SsaFunctionCompiler implements FunctionCompiler { 21 class SsaFunctionCompiler implements FunctionCompiler {
22 final SsaCodeGeneratorTask generator; 22 final SsaCodeGeneratorTask generator;
23 final SsaBuilderTask builder; 23 final SsaBuilderTask builder;
24 final SsaKernelBuilderTask builderKernel; 24 final SsaKernelBuilderTask builderKernel;
25 final SsaOptimizerTask optimizer; 25 final SsaOptimizerTask optimizer;
26 final JavaScriptBackend backend; 26 final JavaScriptBackend backend;
27 final bool useKernel; 27 final bool useKernel;
28 28
29 SsaFunctionCompiler(JavaScriptBackend backend, 29 SsaFunctionCompiler(JavaScriptBackend backend,
30 SourceInformationStrategy sourceInformationFactory, this.useKernel) 30 SourceInformationStrategy sourceInformationFactory, this.useKernel)
31 : generator = new SsaCodeGeneratorTask(backend, sourceInformationFactory), 31 : generator = new SsaCodeGeneratorTask(backend, sourceInformationFactory),
32 builder = new SsaBuilderTask(backend, sourceInformationFactory), 32 builder = new SsaBuilderTask(backend, sourceInformationFactory),
33 builderKernel = 33 builderKernel =
34 new SsaKernelBuilderTask(backend, sourceInformationFactory), 34 new SsaKernelBuilderTask(backend, sourceInformationFactory),
35 optimizer = new SsaOptimizerTask(backend), 35 optimizer = new SsaOptimizerTask(backend),
36 backend = backend; 36 backend = backend;
37 37
38 /// Generates JavaScript code for `work.element`. 38 /// Generates JavaScript code for `work.element`.
39 /// Using the ssa builder, optimizer and codegenerator. 39 /// Using the ssa builder, optimizer and codegenerator.
40 js.Fun compile(CodegenWorkItem work, ClosedWorld closedWorld) { 40 js.Fun compile(ElementCodegenWorkItem work, ClosedWorld closedWorld) {
41 HGraph graph = useKernel 41 HGraph graph = useKernel
42 ? builderKernel.build(work, closedWorld) 42 ? builderKernel.build(work, closedWorld)
43 : builder.build(work, closedWorld); 43 : builder.build(work, closedWorld);
44 optimizer.optimize(work, graph, closedWorld); 44 optimizer.optimize(work, graph, closedWorld);
45 Element element = work.element; 45 Element element = work.element;
46 js.Expression result = generator.generateCode(work, graph, closedWorld); 46 js.Expression result = generator.generateCode(work, graph, closedWorld);
47 if (element is FunctionElement) { 47 if (element is FunctionElement) {
48 // TODO(sigmund): replace by kernel transformer when `useKernel` is true. 48 // TODO(sigmund): replace by kernel transformer when `useKernel` is true.
49 result = backend.rewriteAsync(element, result); 49 result = backend.rewriteAsync(element, result);
50 } 50 }
51 return result; 51 return result;
52 } 52 }
53 53
54 Iterable<CompilerTask> get tasks { 54 Iterable<CompilerTask> get tasks {
55 return <CompilerTask>[ 55 return <CompilerTask>[
56 useKernel ? builderKernel : builder, 56 useKernel ? builderKernel : builder,
57 optimizer, 57 optimizer,
58 generator 58 generator
59 ]; 59 ];
60 } 60 }
61 } 61 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/codegen.dart ('k') | pkg/compiler/lib/src/universe/codegen_world_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698