dart2js: Use the NoInline annotation on getInterceptor in the JS runtime.

This also requires fixing NoInline to work for the JS runtime.
Previously it was ignored.

R=karlklose@google.com
BUG=

Review URL: https://codereview.chromium.org//1315083002 .
This commit is contained in:
Kevin Millikin 2015-08-26 10:56:14 +02:00
parent 4c8049780c
commit e99fb4fc26
3 changed files with 12 additions and 9 deletions

View file

@ -1672,7 +1672,7 @@ class TransformingVisitor extends LeafVisitor {
node.target.treeElements.getSendStructure(expr);
if (structure is InvokeStructure) {
return structure.semantics.kind == AccessKind.TOPLEVEL_METHOD &&
compiler.backend.isForeign(structure.semantics.element);
backend.isForeign(structure.semantics.element);
}
}
return false;
@ -1680,12 +1680,9 @@ class TransformingVisitor extends LeafVisitor {
ast.Statement body = node.target.node.body;
bool shouldInline() {
// At compile time, 'getInterceptor' from the Javascript runtime has a
// foreign body that returns undefined. It is later mutated by replacing
// it with a specialized version. Inlining undefined would be wrong.
// TODO(kmillikin): matching the name prevents inlining other functions
// with the same name.
if (node.target.name == 'getInterceptor') return false;
if (backend.annotations.noInline(node.target)) {
return false;
}
// Inline functions that are a single return statement, expression
// statement, or block containing a return statement or expression

View file

@ -2819,6 +2819,8 @@ class Annotations {
ClassElement expectTrustTypeAnnotationsClass;
ClassElement expectAssumeDynamicClass;
JavaScriptBackend get backend => compiler.backend;
Annotations(this.compiler);
void onLibraryScanned(LibraryElement library) {
@ -2839,8 +2841,11 @@ class Annotations {
/// Returns `true` if inlining is disabled for [element].
bool noInline(Element element) {
// TODO(floitsch): restrict to test directory.
return _hasAnnotation(element, expectNoInlineClass);
if (_hasAnnotation(element, expectNoInlineClass)) {
// TODO(floitsch): restrict to elements from the test directory.
return true;
}
return _hasAnnotation(element, backend.noInlineClass);
}
/// Returns `true` if parameter and returns types should be trusted for

View file

@ -68,6 +68,7 @@ _symbolMapToStringMap(Map<Symbol, dynamic> map) {
* to emit a call to an intercepted method, that is a method that is
* defined in an interceptor class.
*/
@NoInline()
getInterceptor(object) {
// This is a magic method: the compiler does specialization of it
// depending on the uses of intercepted methods and instantiated