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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/ssa/ssa.dart
diff --git a/pkg/compiler/lib/src/ssa/ssa.dart b/pkg/compiler/lib/src/ssa/ssa.dart
index 947ea6ef29c496b9aea228e38f2e4384c925c49b..bf8ffa55bf2416e643c7d7e1e842f8188d0ca7a1 100644
--- a/pkg/compiler/lib/src/ssa/ssa.dart
+++ b/pkg/compiler/lib/src/ssa/ssa.dart
@@ -4,13 +4,16 @@
library ssa;
-import '../common/codegen.dart' show CodegenWorkItem;
+import '../common/codegen.dart' show CodegenWorkItem, CodegenRegistry;
import '../common/tasks.dart' show CompilerTask, Measurer;
+import '../constants/values.dart';
import '../elements/elements.dart' show MethodElement;
-import '../elements/entities.dart' show MemberEntity;
+import '../elements/entities.dart' show FieldEntity, MemberEntity;
import '../io/source_information.dart';
import '../js/js.dart' as js;
import '../js_backend/backend.dart' show JavaScriptBackend, FunctionCompiler;
+import '../universe/call_structure.dart';
+import '../universe/use.dart';
import '../world.dart' show ClosedWorld;
import 'codegen.dart';
@@ -80,3 +83,44 @@ class SsaBuilderTask extends CompilerTask {
return _builder.build(work, closedWorld);
}
}
+
+abstract class SsaBuilderFieldMixin {
+ ConstantValue getFieldInitialConstantValue(FieldEntity field);
+
+ /// Handle field initializer of [element]. Returns `true` if no code
+ /// is needed for the field.
+ ///
+ /// If [element] is a field with a constant initializer, the value is
+ /// registered with the world impact. Otherwise the cyclic-throw helper is
+ /// registered for the lazy value computation.
+ ///
+ /// If the field is constant, no code is needed for the field and the method
+ /// returns `true`.
+ bool handleConstantField(
+ MemberEntity element, CodegenRegistry registry, ClosedWorld closedWorld) {
+ if (element.isField) {
+ ConstantValue initialValue = getFieldInitialConstantValue(element);
+ if (initialValue != null) {
+ registry.worldImpact
+ .registerConstantUse(new ConstantUse.init(initialValue));
+ // We don't need to generate code for static or top-level
+ // variables. For instance variables, we may need to generate
+ // the checked setter.
+ if (element.isStatic || element.isTopLevel) {
+ /// No code is created for this field: All references inline the
+ /// constant value.
+ return true;
+ }
+ } else {
+ // If the constant-handler was not able to produce a result we have to
+ // go through the builder (below) to generate the lazy initializer for
+ // the static variable.
+ // We also need to register the use of the cyclic-error helper.
+ registry.worldImpact.registerStaticUse(new StaticUse.staticInvoke(
+ closedWorld.commonElements.cyclicThrowHelper,
+ CallStructure.ONE_ARG));
+ }
+ }
+ return false;
+ }
+}
« 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