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

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

Issue 2898083002: dart2js kernel: generate `other==null` header for operator== methods (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 openFunction(); 641 openFunction();
642 _addClassTypeVariablesIfNeeded(constructor); 642 _addClassTypeVariablesIfNeeded(constructor);
643 constructor.function.body.accept(this); 643 constructor.function.body.accept(this);
644 closeFunction(); 644 closeFunction();
645 } 645 }
646 646
647 /// Builds a SSA graph for FunctionNodes, found in FunctionExpressions and 647 /// Builds a SSA graph for FunctionNodes, found in FunctionExpressions and
648 /// Procedures. 648 /// Procedures.
649 void buildFunctionNode(ir.FunctionNode functionNode) { 649 void buildFunctionNode(ir.FunctionNode functionNode) {
650 openFunction(); 650 openFunction();
651 if (functionNode.parent is ir.Procedure && 651 ir.TreeNode parent = functionNode.parent;
652 (functionNode.parent as ir.Procedure).kind == 652 if (parent is ir.Procedure && parent.kind == ir.ProcedureKind.Factory) {
653 ir.ProcedureKind.Factory) {
654 _addClassTypeVariablesIfNeeded(functionNode.parent); 653 _addClassTypeVariablesIfNeeded(functionNode.parent);
655 } 654 }
655
656 // If [functionNode] is `operator==` we explicitly add a null check at the
657 // beginning of the method. This is to avoid having call sites do the null
658 // check.
659 if (parent is ir.Procedure &&
660 parent.kind == ir.ProcedureKind.Operator &&
661 parent.name.name == '==') {
662 if (!backend
663 .operatorEqHandlesNullArgument(astAdapter.getMethod(parent))) {
664 handleIf(
665 visitCondition: () {
666 HParameterValue parameter = parameters.values.first;
667 push(new HIdentity(parameter, graph.addConstantNull(closedWorld),
668 null, commonMasks.boolType));
669 },
670 visitThen: () {
671 closeAndGotoExit(new HReturn(
672 graph.addConstantBool(false, closedWorld),
673 sourceInformationBuilder
674 .buildImplicitReturn(astAdapter.getElement(parent))));
675 },
676 visitElse: null,
677 // TODO(27394): Add sourceInformation via
678 // `sourceInformationBuilder.buildIf(?)`.
679 );
680 }
681 }
656 functionNode.body.accept(this); 682 functionNode.body.accept(this);
657 closeFunction(); 683 closeFunction();
658 } 684 }
659 685
660 void addImplicitInstantiation(ResolutionDartType type) { 686 void addImplicitInstantiation(ResolutionDartType type) {
661 if (type != null) { 687 if (type != null) {
662 currentImplicitInstantiations.add(type); 688 currentImplicitInstantiations.add(type);
663 } 689 }
664 } 690 }
665 691
(...skipping 2748 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 enterBlock.setBlockFlow( 3440 enterBlock.setBlockFlow(
3415 new HTryBlockInformation( 3441 new HTryBlockInformation(
3416 kernelBuilder.wrapStatementGraph(bodyGraph), 3442 kernelBuilder.wrapStatementGraph(bodyGraph),
3417 exception, 3443 exception,
3418 kernelBuilder.wrapStatementGraph(catchGraph), 3444 kernelBuilder.wrapStatementGraph(catchGraph),
3419 kernelBuilder.wrapStatementGraph(finallyGraph)), 3445 kernelBuilder.wrapStatementGraph(finallyGraph)),
3420 exitBlock); 3446 exitBlock);
3421 kernelBuilder.inTryStatement = previouslyInTryStatement; 3447 kernelBuilder.inTryStatement = previouslyInTryStatement;
3422 } 3448 }
3423 } 3449 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698