Chromium Code Reviews| Index: pkg/compiler/lib/src/cps_ir/inline.dart |
| diff --git a/pkg/compiler/lib/src/cps_ir/inline.dart b/pkg/compiler/lib/src/cps_ir/inline.dart |
| index 0e37570cdabce4bf1c96e795819c17ea695ceb4a..c50b56108f04e1c62df49c82fbb30eb64cedb1e1 100644 |
| --- a/pkg/compiler/lib/src/cps_ir/inline.dart |
| +++ b/pkg/compiler/lib/src/cps_ir/inline.dart |
| @@ -379,10 +379,8 @@ class InliningVisitor extends TrampolineRecursiveVisitor { |
| // Add a null check to the inlined function body if necessary. The |
| // cached function body does not contain the null check. |
| if (dartReceiver != null && abstractReceiver.isNullable) { |
| - Primitive check = |
| - _fragment.letPrim(new NullCheck(dartReceiver.definition, |
| - invoke.sourceInformation)); |
| - check.type = abstractReceiver.nonNullable(); |
| + Primitive check = nullReceiverGuard( |
| + invoke, _fragment, dartReceiver.definition, abstractReceiver); |
| if (invoke.callingConvention == CallingConvention.Intercepted) { |
| arguments[0] = check; |
| } else { |
| @@ -455,6 +453,31 @@ class InliningVisitor extends TrampolineRecursiveVisitor { |
| hint: invoke.hint); |
| } |
| + Primitive nullReceiverGuard(InvocationPrimitive invoke, |
| + CpsFragment fragment, |
| + Primitive dartReceiver, |
| + TypeMask abstractReceiver) { |
| + Selector selector = invoke is InvokeMethod ? invoke.selector : null; |
|
Harry Terkelsen
2015/12/28 19:30:41
maybe move inside the "if" since that is the only
|
| + if (typeSystem.isDefinitelyNum(abstractReceiver, allowNull: true)) { |
| + Primitive condition = _fragment.letPrim( |
| + new ApplyBuiltinOperator(BuiltinOperator.IsNotNumber, |
| + <Primitive>[dartReceiver], |
| + invoke.sourceInformation)); |
| + condition.type = typeSystem.boolType; |
| + Primitive check = _fragment.letPrim( |
| + new NullCheck.guarded( |
| + condition, dartReceiver, selector, invoke.sourceInformation)); |
| + check.type = abstractReceiver.nonNullable(); |
| + return check; |
| + } |
| + |
| + Primitive check = _fragment.letPrim( |
| + new NullCheck(dartReceiver, invoke.sourceInformation)); |
| + check.type = abstractReceiver.nonNullable(); |
| + return check; |
| + } |
| + |
| + |
| @override |
| Primitive visitInvokeStatic(InvokeStatic node) { |
| return tryInlining(node, node.target, null); |