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

Side by Side Diff: pkg/compiler/lib/src/kernel/kernel_visitor.dart

Issue 2693423003: Clean up deferred checks in Kernel. (Closed)
Patch Set: . Created 3 years, 10 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 import 'package:kernel/frontend/accessors.dart' 6 import 'package:kernel/frontend/accessors.dart'
7 show 7 show
8 Accessor, 8 Accessor,
9 IndexAccessor, 9 IndexAccessor,
10 NullAwarePropertyAccessor, 10 NullAwarePropertyAccessor,
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 ir.InvocationExpression visitBoolFromEnvironmentConstructorInvoke( 1217 ir.InvocationExpression visitBoolFromEnvironmentConstructorInvoke(
1218 NewExpression node, BoolFromEnvironmentConstantExpression constant, _) { 1218 NewExpression node, BoolFromEnvironmentConstantExpression constant, _) {
1219 return buildConstructorInvoke(node, isConst: true); 1219 return buildConstructorInvoke(node, isConst: true);
1220 } 1220 }
1221 1221
1222 ir.TypeLiteral buildTypeLiteral(TypeConstantExpression constant) { 1222 ir.TypeLiteral buildTypeLiteral(TypeConstantExpression constant) {
1223 return new ir.TypeLiteral(kernel.typeLiteralToIr(constant)); 1223 return new ir.TypeLiteral(kernel.typeLiteralToIr(constant));
1224 } 1224 }
1225 1225
1226 @override 1226 @override
1227 ir.TypeLiteral visitClassTypeLiteralGet( 1227 ir.Expression visitClassTypeLiteralGet(
1228 Send node, ConstantExpression constant, _) { 1228 Send node, ConstantExpression constant, _) {
1229 return buildTypeLiteral(constant); 1229 return _addCheckLibraryLoadedIfNeeded(buildTypeLiteral(constant));
1230 } 1230 }
1231 1231
1232 @override 1232 @override
1233 ir.MethodInvocation visitClassTypeLiteralInvoke( 1233 ir.MethodInvocation visitClassTypeLiteralInvoke(
1234 Send node, 1234 Send node,
1235 ConstantExpression constant, 1235 ConstantExpression constant,
1236 NodeList arguments, 1236 NodeList arguments,
1237 CallStructure callStructure, 1237 CallStructure callStructure,
1238 _) { 1238 _) {
1239 return associateNode( 1239 return associateNode(
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 } 2007 }
2008 2008
2009 @override 2009 @override
2010 visitStaticFieldDeclaration(VariableDefinitions node, Node definition, 2010 visitStaticFieldDeclaration(VariableDefinitions node, Node definition,
2011 FieldElement field, Node initializer, _) { 2011 FieldElement field, Node initializer, _) {
2012 // Shouldn't be called, handled by fieldToIr. 2012 // Shouldn't be called, handled by fieldToIr.
2013 return internalError(node, "StaticFieldDeclaration"); 2013 return internalError(node, "StaticFieldDeclaration");
2014 } 2014 }
2015 2015
2016 ir.Expression buildStaticGet(Element element) { 2016 ir.Expression buildStaticGet(Element element) {
2017 var expression = buildStaticAccessor(element).buildSimpleRead(); 2017 return _addCheckLibraryLoadedIfNeeded(
2018 if (_deferredLibrary != null) { 2018 buildStaticAccessor(element).buildSimpleRead());
2019 ir.Let let = new ir.Let(
2020 makeOrReuseVariable(new ir.CheckLibraryIsLoaded(_deferredLibrary)),
2021 expression);
2022 return let;
2023 }
2024 return expression;
2025 } 2019 }
2026 2020
2027 @override 2021 @override
2028 ir.Expression handleStaticFieldGet(Send node, FieldElement field, _) { 2022 ir.Expression handleStaticFieldGet(Send node, FieldElement field, _) {
2029 return associateNode(buildStaticGet(field), node); 2023 return associateNode(buildStaticGet(field), node);
2030 } 2024 }
2031 2025
2032 @override 2026 @override
2033 ir.MethodInvocation handleStaticFieldInvoke(Send node, FieldElement field, 2027 ir.MethodInvocation handleStaticFieldInvoke(Send node, FieldElement field,
2034 NodeList arguments, CallStructure callStructure, _) { 2028 NodeList arguments, CallStructure callStructure, _) {
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 FunctionExpression node, MethodElement getter, Node body, _) { 2701 FunctionExpression node, MethodElement getter, Node body, _) {
2708 return buildIrFunction(ir.ProcedureKind.Getter, getter, body); 2702 return buildIrFunction(ir.ProcedureKind.Getter, getter, body);
2709 } 2703 }
2710 2704
2711 @override 2705 @override
2712 IrFunction visitTopLevelSetterDeclaration(FunctionExpression node, 2706 IrFunction visitTopLevelSetterDeclaration(FunctionExpression node,
2713 MethodElement setter, NodeList parameters, Node body, _) { 2707 MethodElement setter, NodeList parameters, Node body, _) {
2714 return buildIrFunction(ir.ProcedureKind.Setter, setter, body); 2708 return buildIrFunction(ir.ProcedureKind.Setter, setter, body);
2715 } 2709 }
2716 2710
2717 @override 2711 ir.Expression _addCheckLibraryLoadedIfNeeded(ir.Expression inputExpression) {
2718 ir.TypeLiteral visitTypeVariableTypeLiteralGet( 2712 if (_deferredLibrary != null) {
2719 Send node, TypeVariableElement element, _) { 2713 ir.Let let = new ir.Let(
2720 return buildTypeVariable(element); 2714 makeOrReuseVariable(new ir.CheckLibraryIsLoaded(_deferredLibrary)),
2715 inputExpression);
2716 // Only need to add this check once per statement, regardless of the
2717 // number of expressions that access a deferred member.
sra1 2017/02/15 23:55:31 consider: prefix1.foo(prefix2.a, prefix3.b) do
Emily Fortuna 2017/02/16 02:21:56 yes.
2718 _deferredLibrary = null;
2719 return let;
2720 }
2721 return inputExpression;
2721 } 2722 }
2722 2723
2723 @override 2724 @override
2725 ir.Expression visitTypeVariableTypeLiteralGet(
2726 Send node, TypeVariableElement element, _) {
2727 return _addCheckLibraryLoadedIfNeeded(buildTypeVariable(element));
2728 }
2729
2730 @override
2724 ir.MethodInvocation visitTypeVariableTypeLiteralInvoke( 2731 ir.MethodInvocation visitTypeVariableTypeLiteralInvoke(
2725 Send node, 2732 Send node,
2726 TypeVariableElement element, 2733 TypeVariableElement element,
2727 NodeList arguments, 2734 NodeList arguments,
2728 CallStructure callStructure, 2735 CallStructure callStructure,
2729 _) { 2736 _) {
2730 return associateNode( 2737 return associateNode(
2731 buildCall(buildTypeVariable(element), callStructure, arguments), node); 2738 buildCall(buildTypeVariable(element), callStructure, arguments), node);
2732 } 2739 }
2733 2740
2734 @override 2741 @override
2735 ir.Expression visitTypeVariableTypeLiteralSet( 2742 ir.Expression visitTypeVariableTypeLiteralSet(
2736 SendSet node, TypeVariableElement element, Node rhs, _) { 2743 SendSet node, TypeVariableElement element, Node rhs, _) {
2737 return new ReadOnlyAccessor(buildTypeVariable(element)) 2744 return new ReadOnlyAccessor(buildTypeVariable(element))
2738 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); 2745 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext);
2739 } 2746 }
2740 2747
2741 @override 2748 @override
2742 ir.Expression visitTypeVariableTypeLiteralSetIfNull( 2749 ir.Expression visitTypeVariableTypeLiteralSetIfNull(
2743 Send node, TypeVariableElement element, Node rhs, _) { 2750 Send node, TypeVariableElement element, Node rhs, _) {
2744 return _finishSetIfNull( 2751 return _finishSetIfNull(
2745 node, new ReadOnlyAccessor(buildTypeVariable(element)), rhs); 2752 node, new ReadOnlyAccessor(buildTypeVariable(element)), rhs);
2746 } 2753 }
2747 2754
2748 @override 2755 @override
2749 ir.TypeLiteral visitTypedefTypeLiteralGet( 2756 ir.Expression visitTypedefTypeLiteralGet(
2750 Send node, ConstantExpression constant, _) { 2757 Send node, ConstantExpression constant, _) {
2751 return buildTypeLiteral(constant); 2758 return _addCheckLibraryLoadedIfNeeded(buildTypeLiteral(constant));
2752 } 2759 }
2753 2760
2754 @override 2761 @override
2755 ir.MethodInvocation visitTypedefTypeLiteralInvoke( 2762 ir.MethodInvocation visitTypedefTypeLiteralInvoke(
2756 Send node, 2763 Send node,
2757 ConstantExpression constant, 2764 ConstantExpression constant,
2758 NodeList arguments, 2765 NodeList arguments,
2759 CallStructure callStructure, 2766 CallStructure callStructure,
2760 _) { 2767 _) {
2761 return associateNode( 2768 return associateNode(
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 : this(null, true, node, initializers); 2913 : this(null, true, node, initializers);
2907 2914
2908 accept(ir.Visitor v) => throw "unsupported"; 2915 accept(ir.Visitor v) => throw "unsupported";
2909 2916
2910 visitChildren(ir.Visitor v) => throw "unsupported"; 2917 visitChildren(ir.Visitor v) => throw "unsupported";
2911 2918
2912 String toString() { 2919 String toString() {
2913 return "IrFunction($kind, $isConstructor, $node, $initializers)"; 2920 return "IrFunction($kind, $isConstructor, $node, $initializers)";
2914 } 2921 }
2915 } 2922 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/builder_kernel.dart » ('j') | pkg/compiler/lib/src/ssa/builder_kernel.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698