@@ -45,6 +45,7 @@ import '../options.dart';
4545import '../tracer.dart' ;
4646import '../universe/call_structure.dart' ;
4747import '../universe/feature.dart' ;
48+ import '../universe/member_usage.dart' show MemberAccess;
4849import '../universe/selector.dart' ;
4950import '../universe/side_effects.dart' show SideEffects;
5051import '../universe/target_checks.dart' show TargetChecks;
@@ -1197,7 +1198,7 @@ class KernelSsaGraphBuilder extends ir.Visitor {
11971198 /// that no corresponding ir.Node actually exists for it. We just use the
11981199 /// targetElement.
11991200 void _buildMethodSignature (ir.FunctionNode originalClosureNode) {
1200- _openFunction (targetElement);
1201+ _openFunction (targetElement, checks : TargetChecks .none );
12011202 List <HInstruction > typeArguments = < HInstruction > [];
12021203
12031204 // Add function type variables.
@@ -1243,13 +1244,10 @@ class KernelSsaGraphBuilder extends ir.Visitor {
12431244 return ;
12441245 }
12451246
1246- // TODO(sra): Static methods with no tear-off can be generated with no
1247- // checks.
1248- // TODO(sra): Instance methods can be generated with reduced checks if
1249- // called only from non-dynamic call-sites.
12501247 _openFunction (function,
12511248 functionNode: functionNode,
1252- parameterStructure: function.parameterStructure);
1249+ parameterStructure: function.parameterStructure,
1250+ checks: _checksForFunction (function));
12531251
12541252 // If [functionNode] is `operator==` we explicitly add a null check at the
12551253 // beginning of the method. This is to avoid having call sites do the null
@@ -1308,7 +1306,8 @@ class KernelSsaGraphBuilder extends ir.Visitor {
13081306 void _buildGenerator (FunctionEntity function, ir.FunctionNode functionNode) {
13091307 _openFunction (function,
13101308 functionNode: functionNode,
1311- parameterStructure: function.parameterStructure);
1309+ parameterStructure: function.parameterStructure,
1310+ checks: _checksForFunction (function));
13121311
13131312 // Prepare to tail-call the body.
13141313
@@ -1474,7 +1473,8 @@ class KernelSsaGraphBuilder extends ir.Visitor {
14741473 assert (functionNode.body == null );
14751474 _openFunction (function,
14761475 functionNode: functionNode,
1477- parameterStructure: function.parameterStructure);
1476+ parameterStructure: function.parameterStructure,
1477+ checks: _checksForFunction (function));
14781478
14791479 if (closedWorld.nativeData.isNativeMember (targetElement)) {
14801480 registry.registerNativeMethod (targetElement);
@@ -1572,12 +1572,24 @@ class KernelSsaGraphBuilder extends ir.Visitor {
15721572 }
15731573 }
15741574
1575+ TargetChecks _checksForFunction (FunctionEntity function) {
1576+ if (! function.isInstanceMember) {
1577+ // Static methods with no tear-off can be generated with no checks.
1578+ MemberAccess access = closedWorld.getMemberAccess (function);
1579+ if (access != null && access.reads.isEmpty) {
1580+ return TargetChecks .none;
1581+ }
1582+ }
1583+ // TODO(sra): Instance methods can be generated with reduced checks if
1584+ // called only from non-dynamic call-sites.
1585+ return TargetChecks .dynamicChecks;
1586+ }
1587+
15751588 void _openFunction (MemberEntity member,
15761589 {ir.FunctionNode functionNode,
15771590 ParameterStructure parameterStructure,
15781591 TargetChecks checks}) {
1579- // TODO(sra): Pass from all sites.
1580- checks ?? = TargetChecks .dynamicChecks;
1592+ assert (checks != null );
15811593
15821594 Map <Local , AbstractValue > parameterMap = {};
15831595 List <ir.VariableDeclaration > elidedParameters = [];
0 commit comments