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

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

Issue 2942863002: Compile and run Hello World! (Closed)
Patch Set: Cleanup 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 26 matching lines...) Expand all
50 Iterable<CompilerTask> get tasks { 53 Iterable<CompilerTask> get tasks {
51 return <CompilerTask>[_builder, optimizer, generator]; 54 return <CompilerTask>[_builder, optimizer, generator];
52 } 55 }
53 } 56 }
54 57
55 abstract class SsaBuilderTask implements CompilerTask { 58 abstract class SsaBuilderTask implements CompilerTask {
56 /// Creates the [HGraph] for [work] or returns `null` if no code is needed 59 /// Creates the [HGraph] for [work] or returns `null` if no code is needed
57 /// for [work]. 60 /// for [work].
58 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld); 61 HGraph build(CodegenWorkItem work, ClosedWorld closedWorld);
59 } 62 }
63
64 abstract class SsaBuilderFieldMixin {
65 ConstantValue getFieldInitialConstantValue(FieldEntity field);
66
67 /// Handle field initializer of `work.element`. Returns `true` if no code
Siggi Cherem (dart-lang) 2017/06/15 18:28:55 nit: `work.element` => [element] (here and below)
Johnni Winther 2017/06/16 09:25:31 Done.
68 /// is needed for the field.
69 ///
70 /// If `work.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 /// return `true`.
Emily Fortuna 2017/06/15 17:54:34 return -> returns
Johnni Winther 2017/06/16 09:25:31 Done.
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
Emily Fortuna 2017/06/15 17:54:34 sorry, I don't understand why we don't need to gen
Johnni Winther 2017/06/16 09:25:31 All references inline the constant value. Add this
85 // the checked setter.
86 if (element.isStatic || element.isTopLevel) {
87 /// No code is created for this field.
88 return true;
89 }
90 } else {
91 // If the constant-handler was not able to produce a result we have to
92 // go through the builder (below) to generate the lazy initializer for
93 // the static variable.
94 // We also need to register the use of the cyclic-error helper.
95 registry.worldImpact.registerStaticUse(new StaticUse.staticInvoke(
96 closedWorld.commonElements.cyclicThrowHelper,
97 CallStructure.ONE_ARG));
98 }
99 }
100 return false;
101 }
102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698