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

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

Issue 2938193003: Revert "Towards compiling Hello World!" and "Compile and run Hello World!" (Closed)
Patch Set: Created 3 years, 6 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, CodegenRegistry; 7 import '../common/codegen.dart' show CodegenWorkItem;
8 import '../common/tasks.dart' show CompilerTask, Measurer; 8 import '../common/tasks.dart' show CompilerTask, Measurer;
9 import '../constants/values.dart';
10 import '../elements/elements.dart' show MethodElement; 9 import '../elements/elements.dart' show MethodElement;
11 import '../elements/entities.dart' show FieldEntity, MemberEntity; 10 import '../elements/entities.dart' show MemberEntity;
12 import '../io/source_information.dart'; 11 import '../io/source_information.dart';
13 import '../js/js.dart' as js; 12 import '../js/js.dart' as js;
14 import '../js_backend/backend.dart' show JavaScriptBackend, FunctionCompiler; 13 import '../js_backend/backend.dart' show JavaScriptBackend, FunctionCompiler;
15 import '../universe/call_structure.dart';
16 import '../universe/use.dart';
17 import '../world.dart' show ClosedWorld; 14 import '../world.dart' show ClosedWorld;
18 15
19 import 'codegen.dart'; 16 import 'codegen.dart';
20 import 'nodes.dart'; 17 import 'nodes.dart';
21 import 'optimize.dart'; 18 import 'optimize.dart';
22 19
23 class SsaFunctionCompiler implements FunctionCompiler { 20 class SsaFunctionCompiler implements FunctionCompiler {
24 final SsaCodeGeneratorTask generator; 21 final SsaCodeGeneratorTask generator;
25 final SsaBuilderTask _builder; 22 final SsaBuilderTask _builder;
26 final SsaOptimizerTask optimizer; 23 final SsaOptimizerTask optimizer;
(...skipping 26 matching lines...) Expand all
53 Iterable<CompilerTask> get tasks { 50 Iterable<CompilerTask> get tasks {
54 return <CompilerTask>[_builder, optimizer, generator]; 51 return <CompilerTask>[_builder, optimizer, generator];
55 } 52 }
56 } 53 }
57 54
58 abstract class SsaBuilderTask implements CompilerTask { 55 abstract class SsaBuilderTask implements CompilerTask {
59 /// Creates the [HGraph] for [work] or returns `null` if no code is needed 56 /// Creates the [HGraph] for [work] or returns `null` if no code is needed
60 /// for [work]. 57 /// for [work].
61 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld); 58 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld);
62 } 59 }
63
64 abstract class SsaBuilderFieldMixin {
65 ConstantValue getFieldInitialConstantValue(FieldEntity field);
66
67 /// Handle field initializer of [element]. Returns `true` if no code
68 /// is needed for the field.
69 ///
70 /// If [element] is a field with a constant initializer, the value is
71 /// registered with the world impact. Otherwise the cyclic-throw helper is
72 /// registered for the lazy value computation.
73 ///
74 /// If the field is constant, no code is needed for the field and the method
75 /// returns `true`.
76 bool handleConstantField(
77 MemberEntity element, CodegenRegistry registry, ClosedWorld closedWorld) {
78 if (element.isField) {
79 ConstantValue initialValue = getFieldInitialConstantValue(element);
80 if (initialValue != null) {
81 registry.worldImpact
82 .registerConstantUse(new ConstantUse.init(initialValue));
83 // We don't need to generate code for static or top-level
84 // variables. For instance variables, we may need to generate
85 // the checked setter.
86 if (element.isStatic || element.isTopLevel) {
87 /// No code is created for this field: All references inline the
88 /// constant value.
89 return true;
90 }
91 } else {
92 // If the constant-handler was not able to produce a result we have to
93 // go through the builder (below) to generate the lazy initializer for
94 // the static variable.
95 // We also need to register the use of the cyclic-error helper.
96 registry.worldImpact.registerStaticUse(new StaticUse.staticInvoke(
97 closedWorld.commonElements.cyclicThrowHelper,
98 CallStructure.ONE_ARG));
99 }
100 }
101 return false;
102 }
103 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/rasta_ssa_builder_task.dart ('k') | pkg/compiler/lib/src/ssa/types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698