Chromium Code Reviews| 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 bb65e1e157b22d54b135d2fd9286535f30d89b5b..97cfa09ed8e4604b25ba7e2f0e1309ab23b065c9 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 KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
| +class KernelSsaBuilder extends ir.Visitor |
| + with GraphBuilder, SsaBuilderFieldMixin { |
| final ir.Node target; |
| final bool _targetIsConstructorBody; |
| final MemberEntity targetElement; |
| @@ -138,6 +140,12 @@ class KernelSsaBuilder 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`. |
|
Emily Fortuna
2017/06/15 17:54:34
why?
Johnni Winther
2017/06/16 09:25:31
All references inline the constant value. Add this
|
| + return null; |
| + } else if (targetElement.isStatic || targetElement.isTopLevel) { |
| + backend.constants.registerLazyStatic(targetElement); |
| + } |
| buildField(target); |
| } else if (target is ir.Constructor) { |
| if (_targetIsConstructorBody) { |
| @@ -160,6 +168,12 @@ class KernelSsaBuilder 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) { |
| @@ -1294,7 +1308,9 @@ class KernelSsaBuilder 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 { |
| @@ -1436,7 +1452,6 @@ class KernelSsaBuilder 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); |
| @@ -2598,7 +2613,7 @@ class KernelSsaBuilder 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; |
| } |
| @@ -2650,7 +2665,8 @@ class KernelSsaBuilder 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( |
| @@ -2714,8 +2730,8 @@ class KernelSsaBuilder 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); |
| @@ -3038,7 +3054,11 @@ class KernelSsaBuilder 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 |