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

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

Issue 2927093002: Support user class in compile_from_dill_test (Closed)
Patch Set: 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/codegen.dart' show CodegenRegistry; 9 import '../common/codegen.dart' show CodegenRegistry;
10 import '../common/names.dart'; 10 import '../common/names.dart';
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 parameters[parameter] = argument; 587 parameters[parameter] = argument;
588 localsHandler.updateLocal(parameter, argument); 588 localsHandler.updateLocal(parameter, argument);
589 } 589 }
590 590
591 constructor.function.positionalParameters.forEach(handleParameter); 591 constructor.function.positionalParameters.forEach(handleParameter);
592 constructor.function.namedParameters.toList() 592 constructor.function.namedParameters.toList()
593 ..sort(namedOrdering) 593 ..sort(namedOrdering)
594 ..forEach(handleParameter); 594 ..forEach(handleParameter);
595 595
596 // Set the locals handler state as if we were inlining the constructor. 596 // Set the locals handler state as if we were inlining the constructor.
597 ConstructorElement astElement = _elementMap.getConstructor(constructor); 597 ConstructorEntity astElement = _elementMap.getConstructor(constructor);
598 ResolvedAst resolvedAst = astElement.resolvedAst;
599 ClosureClassMap oldClosureData = localsHandler.closureData; 598 ClosureClassMap oldClosureData = localsHandler.closureData;
600 ClosureClassMap newClosureData = 599 ClosureClassMap newClosureData =
601 closureToClassMapper.getMemberMap(astElement); 600 closureToClassMapper.getMemberMap(astElement);
602 localsHandler.closureData = newClosureData; 601 if (astElement is ConstructorElement) {
603 if (resolvedAst.kind == ResolvedAstKind.PARSED) { 602 // TODO(johnniwinther): Support constructor (body) entities.
604 localsHandler.enterScope(newClosureData.capturingScopes[resolvedAst.node], 603 ResolvedAst resolvedAst = astElement.resolvedAst;
605 forGenerativeConstructorBody: astElement.isGenerativeConstructorBody); 604 localsHandler.closureData = newClosureData;
605 if (resolvedAst.kind == ResolvedAstKind.PARSED) {
606 localsHandler.enterScope(
607 newClosureData.capturingScopes[resolvedAst.node],
608 forGenerativeConstructorBody:
609 astElement.isGenerativeConstructorBody);
610 }
606 } 611 }
607 inlinedFrom(astElement, () { 612 inlinedFrom(astElement, () {
608 _buildInitializers(constructor, constructorChain, fieldValues); 613 _buildInitializers(constructor, constructorChain, fieldValues);
609 }); 614 });
610 localsHandler.closureData = oldClosureData; 615 localsHandler.closureData = oldClosureData;
611 } 616 }
612 617
613 /// Builds generative constructor body. 618 /// Builds generative constructor body.
614 void buildConstructorBody(ir.Constructor constructor) { 619 void buildConstructorBody(ir.Constructor constructor) {
615 openFunction(constructor.function); 620 openFunction(constructor.function);
(...skipping 10 matching lines...) Expand all
626 if (parent is ir.Procedure && parent.kind == ir.ProcedureKind.Factory) { 631 if (parent is ir.Procedure && parent.kind == ir.ProcedureKind.Factory) {
627 _addClassTypeVariablesIfNeeded(functionNode.parent); 632 _addClassTypeVariablesIfNeeded(functionNode.parent);
628 } 633 }
629 634
630 // If [functionNode] is `operator==` we explicitly add a null check at the 635 // If [functionNode] is `operator==` we explicitly add a null check at the
631 // beginning of the method. This is to avoid having call sites do the null 636 // beginning of the method. This is to avoid having call sites do the null
632 // check. 637 // check.
633 if (parent is ir.Procedure && 638 if (parent is ir.Procedure &&
634 parent.kind == ir.ProcedureKind.Operator && 639 parent.kind == ir.ProcedureKind.Operator &&
635 parent.name.name == '==') { 640 parent.name.name == '==') {
636 MethodElement method = _elementMap.getMethod(parent); 641 FunctionEntity method = _elementMap.getMethod(parent);
637 if (!backend.operatorEqHandlesNullArgument(method)) { 642 if (!backend.operatorEqHandlesNullArgument(method)) {
638 handleIf( 643 handleIf(
639 visitCondition: () { 644 visitCondition: () {
640 HParameterValue parameter = parameters.values.first; 645 HParameterValue parameter = parameters.values.first;
641 push(new HIdentity(parameter, graph.addConstantNull(closedWorld), 646 push(new HIdentity(parameter, graph.addConstantNull(closedWorld),
642 null, commonMasks.boolType)); 647 null, commonMasks.boolType));
643 }, 648 },
644 visitThen: () { 649 visitThen: () {
645 closeAndGotoExit(new HReturn( 650 closeAndGotoExit(new HReturn(
646 graph.addConstantBool(false, closedWorld), 651 graph.addConstantBool(false, closedWorld),
647 sourceInformationBuilder.buildImplicitReturn(method))); 652 // TODO(johnniwinther): Provider source information like
653 // `sourceInformationBuilder.buildImplicitReturn(method)`.
654 null));
648 }, 655 },
649 visitElse: null, 656 visitElse: null,
650 // TODO(27394): Add sourceInformation via 657 // TODO(27394): Add sourceInformation via
651 // `sourceInformationBuilder.buildIf(?)`. 658 // `sourceInformationBuilder.buildIf(?)`.
652 ); 659 );
653 } 660 }
654 } 661 }
655 functionNode.body.accept(this); 662 functionNode.body.accept(this);
656 closeFunction(); 663 closeFunction();
657 } 664 }
(...skipping 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after
3029 pop(); 3036 pop();
3030 stack.add(graph.addConstantBool(true, closedWorld)); 3037 stack.add(graph.addConstantBool(true, closedWorld));
3031 return; 3038 return;
3032 } 3039 }
3033 3040
3034 if (type is ir.DynamicType) { 3041 if (type is ir.DynamicType) {
3035 stack.add(graph.addConstantBool(true, closedWorld)); 3042 stack.add(graph.addConstantBool(true, closedWorld));
3036 return; 3043 return;
3037 } 3044 }
3038 3045
3039 ResolutionDartType typeValue = 3046 DartType typeValue =
3040 localsHandler.substInContext(_elementMap.getDartType(type)); 3047 localsHandler.substInContext(_elementMap.getDartType(type));
3041 3048
3042 if (type is ir.FunctionType) { 3049 if (type is ir.FunctionType) {
3043 HInstruction representation = 3050 HInstruction representation =
3044 typeBuilder.analyzeTypeArgument(typeValue, sourceElement); 3051 typeBuilder.analyzeTypeArgument(typeValue, sourceElement);
3045 List<HInstruction> inputs = <HInstruction>[ 3052 List<HInstruction> inputs = <HInstruction>[
3046 expression, 3053 expression,
3047 representation, 3054 representation,
3048 ]; 3055 ];
3049 _pushStaticInvocation( 3056 _pushStaticInvocation(
3050 _commonElements.functionTypeTest, inputs, commonMasks.boolType); 3057 _commonElements.functionTypeTest, inputs, commonMasks.boolType);
3051 HInstruction call = pop(); 3058 HInstruction call = pop();
3052 push(new HIs.compound(typeValue, expression, call, commonMasks.boolType)); 3059 push(new HIs.compound(typeValue, expression, call, commonMasks.boolType));
3053 return; 3060 return;
3054 } 3061 }
3055 3062
3056 if (type is ir.TypeParameterType) { 3063 if (type is ir.TypeParameterType) {
3057 HInstruction runtimeType = 3064 HInstruction runtimeType =
3058 typeBuilder.addTypeVariableReference(typeValue, sourceElement); 3065 typeBuilder.addTypeVariableReference(typeValue, sourceElement);
3059 _pushStaticInvocation(_commonElements.checkSubtypeOfRuntimeType, 3066 _pushStaticInvocation(_commonElements.checkSubtypeOfRuntimeType,
3060 <HInstruction>[expression, runtimeType], commonMasks.boolType); 3067 <HInstruction>[expression, runtimeType], commonMasks.boolType);
3061 push( 3068 push(
3062 new HIs.variable(typeValue, expression, pop(), commonMasks.boolType)); 3069 new HIs.variable(typeValue, expression, pop(), commonMasks.boolType));
3063 return; 3070 return;
3064 } 3071 }
3065 3072
3066 if (_isInterfaceWithNoDynamicTypes(type)) { 3073 if (_isInterfaceWithNoDynamicTypes(type)) {
3074 InterfaceType interfaceType = typeValue;
3067 HInstruction representations = typeBuilder 3075 HInstruction representations = typeBuilder
3068 .buildTypeArgumentRepresentations(typeValue, sourceElement); 3076 .buildTypeArgumentRepresentations(typeValue, sourceElement);
3069 add(representations); 3077 add(representations);
3070 ClassElement element = typeValue.element; 3078 ClassEntity element = interfaceType.element;
3071 js.Name operator = namer.operatorIs(element); 3079 js.Name operator = namer.operatorIs(element);
3072 HInstruction isFieldName = 3080 HInstruction isFieldName =
3073 graph.addConstantStringFromName(operator, closedWorld); 3081 graph.addConstantStringFromName(operator, closedWorld);
3074 HInstruction asFieldName = closedWorld.hasAnyStrictSubtype(element) 3082 HInstruction asFieldName = closedWorld.hasAnyStrictSubtype(element)
3075 ? graph.addConstantStringFromName( 3083 ? graph.addConstantStringFromName(
3076 namer.substitutionName(element), closedWorld) 3084 namer.substitutionName(element), closedWorld)
3077 : graph.addConstantNull(closedWorld); 3085 : graph.addConstantNull(closedWorld);
3078 List<HInstruction> inputs = <HInstruction>[ 3086 List<HInstruction> inputs = <HInstruction>[
3079 expression, 3087 expression,
3080 isFieldName, 3088 isFieldName,
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
3440 enterBlock.setBlockFlow( 3448 enterBlock.setBlockFlow(
3441 new HTryBlockInformation( 3449 new HTryBlockInformation(
3442 kernelBuilder.wrapStatementGraph(bodyGraph), 3450 kernelBuilder.wrapStatementGraph(bodyGraph),
3443 exception, 3451 exception,
3444 kernelBuilder.wrapStatementGraph(catchGraph), 3452 kernelBuilder.wrapStatementGraph(catchGraph),
3445 kernelBuilder.wrapStatementGraph(finallyGraph)), 3453 kernelBuilder.wrapStatementGraph(finallyGraph)),
3446 exitBlock); 3454 exitBlock);
3447 kernelBuilder.inTryStatement = previouslyInTryStatement; 3455 kernelBuilder.inTryStatement = previouslyInTryStatement;
3448 } 3456 }
3449 } 3457 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698