Index: pkg/compiler/lib/src/ssa/builder_kernel.dart |
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
index 9eed251738e2a1a60f7453d2e3e6e62a19e6f78c..3b99d41a9118892dca5ed2581417a263c1eec67b 100644 |
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart |
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
@@ -41,11 +41,13 @@ import 'kernel_string_builder.dart'; |
import 'locals_handler.dart'; |
import 'loop_handler.dart'; |
import 'nodes.dart'; |
+import 'ssa.dart'; |
import 'ssa_branch_builder.dart'; |
import 'switch_continue_analysis.dart'; |
import 'type_builder.dart'; |
-class KernelSsaGraphBuilder extends ir.Visitor with GraphBuilder { |
+class KernelSsaGraphBuilder extends ir.Visitor |
+ with GraphBuilder, SsaBuilderFieldMixin { |
final ir.Node target; |
final bool _targetIsConstructorBody; |
final MemberEntity targetElement; |
@@ -138,6 +140,13 @@ class KernelSsaGraphBuilder extends ir.Visitor with GraphBuilder { |
_targetFunction = (target as ir.Procedure).function; |
buildFunctionNode(_targetFunction); |
} else if (target is ir.Field) { |
+ if (handleConstantField(targetElement, registry, closedWorld)) { |
+ // No code is generated for `targetElement`: All references inline the |
+ // constant value. |
+ return null; |
+ } else if (targetElement.isStatic || targetElement.isTopLevel) { |
+ backend.constants.registerLazyStatic(targetElement); |
+ } |
buildField(target); |
} else if (target is ir.Constructor) { |
if (_targetIsConstructorBody) { |
@@ -160,6 +169,12 @@ class KernelSsaGraphBuilder extends ir.Visitor with GraphBuilder { |
}); |
} |
+ @override |
+ ConstantValue getFieldInitialConstantValue(FieldEntity field) { |
+ assert(field == targetElement); |
+ return _elementMap.getFieldConstantValue(target); |
+ } |
+ |
void buildField(ir.Field field) { |
openFunction(); |
if (field.initializer != null) { |
@@ -1289,7 +1304,9 @@ class KernelSsaGraphBuilder extends ir.Visitor with GraphBuilder { |
null, |
loopEntryBlock.loopInformation.target, |
loopEntryBlock.loopInformation.labels, |
- sourceInformationBuilder.buildLoop(astAdapter.getNode(doStatement))); |
+ // TODO(johnniwinther): Provide source information like: |
+ // sourceInformationBuilder.buildLoop(astAdapter.getNode(doStatement)) |
+ null); |
loopEntryBlock.setBlockFlow(loopBlockInfo, current); |
loopInfo.loopBlockInformation = loopBlockInfo; |
} else { |
@@ -1431,7 +1448,6 @@ class KernelSsaGraphBuilder extends ir.Visitor with GraphBuilder { |
/// continue statements from simple switch statements. |
JumpHandler createJumpHandler(ir.TreeNode node, {bool isLoopJump: false}) { |
JumpTarget target = localsMap.getJumpTarget(node); |
- assert(target is KernelJumpTarget); |
if (target == null) { |
// No breaks or continues to this node. |
return new NullJumpHandler(reporter); |
@@ -2593,7 +2609,7 @@ class KernelSsaGraphBuilder extends ir.Visitor with GraphBuilder { |
if (instruction is HConstant) { |
js.Name name = |
- astAdapter.getNameForJsGetName(argument, instruction.constant); |
+ _elementMap.getNameForJsGetName(instruction.constant, namer); |
stack.add(graph.addConstantStringFromName(name, closedWorld)); |
return; |
} |
@@ -2645,7 +2661,8 @@ class KernelSsaGraphBuilder extends ir.Visitor with GraphBuilder { |
js.Template template; |
if (instruction is HConstant) { |
- template = astAdapter.getJsBuiltinTemplate(instruction.constant); |
+ template = |
+ _elementMap.getJsBuiltinTemplate(instruction.constant, emitter); |
} |
if (template == null) { |
reporter.reportErrorMessage( |
@@ -2709,8 +2726,8 @@ class KernelSsaGraphBuilder extends ir.Visitor with GraphBuilder { |
if (argumentInstruction is HConstant) { |
ConstantValue argumentConstant = argumentInstruction.constant; |
if (argumentConstant is TypeConstantValue && |
- argumentConstant.representedType is ResolutionInterfaceType) { |
- ResolutionInterfaceType type = argumentConstant.representedType; |
+ argumentConstant.representedType is InterfaceType) { |
+ InterfaceType type = argumentConstant.representedType; |
// TODO(sra): Check that type is a subclass of [Interceptor]. |
ConstantValue constant = new InterceptorConstantValue(type.element); |
HInstruction instruction = graph.addConstant(constant, closedWorld); |
@@ -3033,7 +3050,11 @@ class KernelSsaGraphBuilder extends ir.Visitor with GraphBuilder { |
_addTypeArguments(arguments, invocation.arguments); |
} |
TypeMask typeMask = new TypeMask.nonNullExact(cls, closedWorld); |
+ InterfaceType type = _elementMap.createInterfaceType( |
+ target.enclosingClass, invocation.arguments.types); |
+ addImplicitInstantiation(type); |
_pushStaticInvocation(constructor, arguments, typeMask); |
+ removeImplicitInstantiation(type); |
} |
@override |