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

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

Issue 2942863002: Compile and run Hello World! (Closed)
Patch Set: Rebased 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; 7 import '../common/codegen.dart' show CodegenWorkItem, CodegenRegistry;
8 import '../common/tasks.dart' show CompilerTask, Measurer; 8 import '../common/tasks.dart' show CompilerTask, Measurer;
9 import '../constants/values.dart';
9 import '../elements/elements.dart' show MethodElement; 10 import '../elements/elements.dart' show MethodElement;
10 import '../elements/entities.dart' show MemberEntity; 11 import '../elements/entities.dart' show FieldEntity, MemberEntity;
11 import '../io/source_information.dart'; 12 import '../io/source_information.dart';
12 import '../js/js.dart' as js; 13 import '../js/js.dart' as js;
13 import '../js_backend/backend.dart' show JavaScriptBackend, FunctionCompiler; 14 import '../js_backend/backend.dart' show JavaScriptBackend, FunctionCompiler;
15 import '../universe/call_structure.dart';
16 import '../universe/use.dart';
14 import '../world.dart' show ClosedWorld; 17 import '../world.dart' show ClosedWorld;
15 18
16 import 'codegen.dart'; 19 import 'codegen.dart';
17 import 'nodes.dart'; 20 import 'nodes.dart';
18 import 'optimize.dart'; 21 import 'optimize.dart';
19 22
20 class SsaFunctionCompiler implements FunctionCompiler { 23 class SsaFunctionCompiler implements FunctionCompiler {
21 final SsaCodeGeneratorTask generator; 24 final SsaCodeGeneratorTask generator;
22 final SsaBuilderTask _builder; 25 final SsaBuilderTask _builder;
23 final SsaOptimizerTask optimizer; 26 final SsaOptimizerTask optimizer;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 _builder = _backend.compiler.backendStrategy 76 _builder = _backend.compiler.backendStrategy
74 .createSsaBuilder(this, _backend, _sourceInformationFactory); 77 .createSsaBuilder(this, _backend, _sourceInformationFactory);
75 } 78 }
76 79
77 /// Creates the [HGraph] for [work] or returns `null` if no code is needed 80 /// Creates the [HGraph] for [work] or returns `null` if no code is needed
78 /// for [work]. 81 /// for [work].
79 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) { 82 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) {
80 return _builder.build(work, closedWorld); 83 return _builder.build(work, closedWorld);
81 } 84 }
82 } 85 }
86
87 abstract class SsaBuilderFieldMixin {
88 ConstantValue getFieldInitialConstantValue(FieldEntity field);
89
90 /// Handle field initializer of [element]. Returns `true` if no code
91 /// is needed for the field.
92 ///
93 /// If [element] is a field with a constant initializer, the value is
94 /// registered with the world impact. Otherwise the cyclic-throw helper is
95 /// registered for the lazy value computation.
96 ///
97 /// If the field is constant, no code is needed for the field and the method
98 /// returns `true`.
99 bool handleConstantField(
100 MemberEntity element, CodegenRegistry registry, ClosedWorld closedWorld) {
101 if (element.isField) {
102 ConstantValue initialValue = getFieldInitialConstantValue(element);
103 if (initialValue != null) {
104 registry.worldImpact
105 .registerConstantUse(new ConstantUse.init(initialValue));
106 // We don't need to generate code for static or top-level
107 // variables. For instance variables, we may need to generate
108 // the checked setter.
109 if (element.isStatic || element.isTopLevel) {
110 /// No code is created for this field: All references inline the
111 /// constant value.
112 return true;
113 }
114 } else {
115 // If the constant-handler was not able to produce a result we have to
116 // go through the builder (below) to generate the lazy initializer for
117 // the static variable.
118 // We also need to register the use of the cyclic-error helper.
119 registry.worldImpact.registerStaticUse(new StaticUse.staticInvoke(
120 closedWorld.commonElements.cyclicThrowHelper,
121 CallStructure.ONE_ARG));
122 }
123 }
124 return false;
125 }
126 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/rasta_ssa_builder_task.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