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

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

Issue 2926863002: Handle parameters in compile_from_dill_test (Closed)
Patch Set: Cleanup. 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 ..forEach(handleParameter); 596 ..forEach(handleParameter);
597 597
598 // Set the locals handler state as if we were inlining the constructor. 598 // Set the locals handler state as if we were inlining the constructor.
599 ConstructorElement astElement = _elementMap.getConstructor(constructor); 599 ConstructorElement astElement = _elementMap.getConstructor(constructor);
600 ResolvedAst resolvedAst = astElement.resolvedAst; 600 ResolvedAst resolvedAst = astElement.resolvedAst;
601 ClosureClassMap oldClosureData = localsHandler.closureData; 601 ClosureClassMap oldClosureData = localsHandler.closureData;
602 ClosureClassMap newClosureData = 602 ClosureClassMap newClosureData =
603 closureToClassMapper.getMemberMap(astElement); 603 closureToClassMapper.getMemberMap(astElement);
604 localsHandler.closureData = newClosureData; 604 localsHandler.closureData = newClosureData;
605 if (resolvedAst.kind == ResolvedAstKind.PARSED) { 605 if (resolvedAst.kind == ResolvedAstKind.PARSED) {
606 localsHandler.enterScope(resolvedAst.node, 606 localsHandler.enterScope(newClosureData.capturingScopes[resolvedAst.node],
607 forGenerativeConstructorBody: astElement.isGenerativeConstructorBody); 607 forGenerativeConstructorBody: astElement.isGenerativeConstructorBody);
608 } 608 }
609 inlinedFrom(astElement, () { 609 inlinedFrom(astElement, () {
610 _buildInitializers(constructor, constructorChain, fieldValues); 610 _buildInitializers(constructor, constructorChain, fieldValues);
611 }); 611 });
612 localsHandler.closureData = oldClosureData; 612 localsHandler.closureData = oldClosureData;
613 } 613 }
614 614
615 /// Builds generative constructor body. 615 /// Builds generative constructor body.
616 void buildConstructorBody(ir.Constructor constructor) { 616 void buildConstructorBody(ir.Constructor constructor) {
617 openFunction(); 617 openFunction();
618 _addClassTypeVariablesIfNeeded(constructor); 618 _addClassTypeVariablesIfNeeded(constructor);
619 constructor.function.body.accept(this); 619 constructor.function.body.accept(this);
620 closeFunction(); 620 closeFunction();
621 } 621 }
622 622
623 /// Builds a SSA graph for FunctionNodes, found in FunctionExpressions and 623 /// Builds a SSA graph for FunctionNodes, found in FunctionExpressions and
624 /// Procedures. 624 /// Procedures.
625 void buildFunctionNode(ir.FunctionNode functionNode) { 625 void buildFunctionNode(ir.FunctionNode functionNode) {
626 openFunction(); 626 Map<Local, TypeMask> parameterMap = <Local, TypeMask>{};
627
628 void handleParameter(ir.VariableDeclaration node) {
629 Local local = _localsMap.getLocal(node);
630 parameterMap[local] = _typeInferenceMap.getInferredTypeOfParameter(local);
631 }
632
633 functionNode.positionalParameters.forEach(handleParameter);
634 functionNode.namedParameters.toList()
635 ..sort(namedOrdering)
636 ..forEach(handleParameter);
637
638 openFunction(parameterMap);
627 ir.TreeNode parent = functionNode.parent; 639 ir.TreeNode parent = functionNode.parent;
628 if (parent is ir.Procedure && parent.kind == ir.ProcedureKind.Factory) { 640 if (parent is ir.Procedure && parent.kind == ir.ProcedureKind.Factory) {
629 _addClassTypeVariablesIfNeeded(functionNode.parent); 641 _addClassTypeVariablesIfNeeded(functionNode.parent);
630 } 642 }
631 643
632 // If [functionNode] is `operator==` we explicitly add a null check at the 644 // If [functionNode] is `operator==` we explicitly add a null check at the
633 // beginning of the method. This is to avoid having call sites do the null 645 // beginning of the method. This is to avoid having call sites do the null
634 // check. 646 // check.
635 if (parent is ir.Procedure && 647 if (parent is ir.Procedure &&
636 parent.kind == ir.ProcedureKind.Operator && 648 parent.kind == ir.ProcedureKind.Operator &&
(...skipping 26 matching lines...) Expand all
663 currentImplicitInstantiations.add(type); 675 currentImplicitInstantiations.add(type);
664 } 676 }
665 } 677 }
666 678
667 void removeImplicitInstantiation(DartType type) { 679 void removeImplicitInstantiation(DartType type) {
668 if (type != null) { 680 if (type != null) {
669 currentImplicitInstantiations.removeLast(); 681 currentImplicitInstantiations.removeLast();
670 } 682 }
671 } 683 }
672 684
673 void openFunction() { 685 void openFunction(
686 [Map<Local, TypeMask> parameters = const <Local, TypeMask>{}]) {
674 HBasicBlock block = graph.addNewBlock(); 687 HBasicBlock block = graph.addNewBlock();
675 open(graph.entry); 688 open(graph.entry);
676 689
677 localsHandler.startFunction(targetElement, functionNode, 690 ClosureClassMap closureData =
691 closureToClassMapper.getMemberMap(targetElement);
692 localsHandler.startFunction(targetElement, closureData,
693 closureData.capturingScopes[functionNode], parameters,
678 isGenerativeConstructorBody: _targetIsConstructorBody); 694 isGenerativeConstructorBody: _targetIsConstructorBody);
679 close(new HGoto()).addSuccessor(block); 695 close(new HGoto()).addSuccessor(block);
680 696
681 open(block); 697 open(block);
682 } 698 }
683 699
684 void closeFunction() { 700 void closeFunction() {
685 if (!isAborted()) closeAndGotoExit(new HGoto()); 701 if (!isAborted()) closeAndGotoExit(new HGoto());
686 graph.finalize(); 702 graph.finalize();
687 } 703 }
(...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after
3425 enterBlock.setBlockFlow( 3441 enterBlock.setBlockFlow(
3426 new HTryBlockInformation( 3442 new HTryBlockInformation(
3427 kernelBuilder.wrapStatementGraph(bodyGraph), 3443 kernelBuilder.wrapStatementGraph(bodyGraph),
3428 exception, 3444 exception,
3429 kernelBuilder.wrapStatementGraph(catchGraph), 3445 kernelBuilder.wrapStatementGraph(catchGraph),
3430 kernelBuilder.wrapStatementGraph(finallyGraph)), 3446 kernelBuilder.wrapStatementGraph(finallyGraph)),
3431 exitBlock); 3447 exitBlock);
3432 kernelBuilder.inTryStatement = previouslyInTryStatement; 3448 kernelBuilder.inTryStatement = previouslyInTryStatement;
3433 } 3449 }
3434 } 3450 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698