Avoid inlining of external functions

Change-Id: I43aed9e484c55d40a9fa7d5db029e0d11a698b3e
Reviewed-on: https://dart-review.googlesource.com/28562
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Johnni Winther 2017-12-13 09:28:09 +00:00
parent 2132089ec4
commit 9df549a2d0
3 changed files with 27 additions and 2 deletions

View file

@ -922,6 +922,8 @@ class KernelSsaGraphBuilder extends ir.Visitor
/// Builds a SSA graph for FunctionNodes of external methods.
void buildExternalFunctionNode(ir.FunctionNode functionNode) {
// TODO(johnniwinther): Non-js-interop external functions should
// throw a runtime error.
assert(functionNode.body == null);
openFunction(functionNode);
ir.TreeNode parent = functionNode.parent;
@ -4270,7 +4272,6 @@ class KernelSsaGraphBuilder extends ir.Visitor
* Try to inline [element] within the correct context of the builder. The
* insertion point is the state of the builder.
*/
// TODO(redemption): Use this.
bool _tryInlineMethod(
FunctionEntity function,
Selector selector,
@ -4284,6 +4285,10 @@ class KernelSsaGraphBuilder extends ir.Visitor
// Temporarily disable inlining of platform libraries.
return false;
}
if (function.isExternal) {
// Don't inline external methods; these should just fail at runtime.
return false;
}
if (nativeData.isJsInteropMember(function) &&
!(function is ConstructorEntity && function.isFactoryConstructor)) {

View file

@ -0,0 +1,20 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// ignore: IMPORT_INTERNAL_LIBRARY
import 'dart:_js_helper';
/*element: main:[]*/
main() {
externalFunction();
}
/*element: externalFunction:[]*/
@NoInline()
externalFunction() {
_externalFunction();
}
/*element: _externalFunction:[]*/
external _externalFunction();

View file

@ -28,7 +28,7 @@ main(List<String> args) {
Directory dataDir = new Directory.fromUri(Platform.script.resolve('data'));
await checkTests(
dataDir, computeMemberAstInlinings, computeMemberIrInlinings,
args: args, skipForKernel: []);
args: args, skipforAst: ['external.dart'], skipForKernel: []);
});
}