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

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

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

Powered by Google App Engine
This is Rietveld 408576698