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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 11416280: Decouple the constant handler from the compiler so we can have more than one. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge from master.' Created 8 years, 1 month 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index a5158c1c746bdc723659bc71e9b3594b2ea716ac..d76be36cf7f6805fe6a9ac11df78cc783505229a 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -202,7 +202,7 @@ class SsaBuilderTask extends CompilerTask {
new OptionalParameterTypes(signature.optionalParameterCount);
int index = 0;
signature.forEachOptionalParameter((Element parameter) {
- Constant defaultValue = compiler.compileVariable(parameter);
+ Constant defaultValue = builder.compileVariable(parameter);
HType type = HGraph.mapConstantTypeToSsaType(defaultValue);
defaultValueTypes.update(index, parameter.name, type);
index++;
@@ -988,6 +988,24 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
}
/**
+ * Compiles compile-time constants. Never returns [:null:]. If the
+ * initial value is not a compile-time constants, it reports an
+ * internal error.
+ */
+ Constant compileConstant(VariableElement element) {
+ return compiler.constantHandler.compileConstant(element);
+ }
+
+ Constant compileVariable(VariableElement element) {
+ return compiler.constantHandler.compileVariable(element);
+ }
+
+ bool isLazilyInitialized(VariableElement element) {
+ Constant initialValue = compileVariable(element);
+ return initialValue == null;
+ }
+
+ /**
* Documentation wanted -- johnniwinther
*
* Invariant: [functionElement] must be an implementation element.
@@ -1524,8 +1542,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
// }
// Fetch the original default value of [element];
- ConstantHandler handler = compiler.constantHandler;
- Constant constant = handler.compileVariable(element);
+ Constant constant = compileVariable(element);
HConstant defaultValue = constant == null
? graph.addConstantNull(constantSystem)
: graph.addConstant(constant);
@@ -2458,11 +2475,11 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
if (element.isField() && !element.isAssignable()) {
// A static final or const. Get its constant value and inline it if
// the value can be compiled eagerly.
- value = compiler.compileVariable(element);
+ value = compileVariable(element);
}
if (value != null) {
stack.add(graph.addConstant(value));
- } else if (element.isField() && compiler.isLazilyInitialized(element)) {
+ } else if (element.isField() && isLazilyInitialized(element)) {
push(new HLazyStatic(element));
} else {
// TODO(5346): Try to avoid the need for calling [declaration] before
@@ -2741,14 +2758,14 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
return pop();
}
- HInstruction compileConstant(Element parameter) {
+ HInstruction handleConstant(Element parameter) {
Constant constant;
TreeElements calleeElements =
compiler.enqueuer.resolution.getCachedElements(element);
if (calleeElements.isParameterChecked(parameter)) {
constant = SentinelConstant.SENTINEL;
} else {
- constant = compiler.compileConstant(parameter);
+ constant = compileConstant(parameter);
}
return graph.addConstant(constant);
}
@@ -2757,7 +2774,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
list,
element,
compileArgument,
- compileConstant,
+ handleConstant,
compiler);
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698