20ca5bbb05
This forwarders are used at dynamic call-sites and perform type checking for all non-generic-covariant arguments. This allows to skip the same type checks in the actual method body. This yield on average 10% improvement in performance across the body of benchmarks including dart2js compilation times. Bug: https://github.com/dart-lang/sdk/issues/33257 Change-Id: If3fc94a2e0a6f496ec0633f0b379d053a54a40ca Reviewed-on: https://dart-review.googlesource.com/61244 Commit-Queue: Vyacheslav Egorov <vegorov@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
100 lines
2.3 KiB
Dart
100 lines
2.3 KiB
Dart
// Copyright (c) 2016, 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.
|
|
|
|
part of models;
|
|
|
|
enum FunctionKind {
|
|
regular,
|
|
closure,
|
|
implicitClosure,
|
|
getter,
|
|
setter,
|
|
constructor,
|
|
implicitGetter,
|
|
implicitSetter,
|
|
implicitStaticFinalGetter,
|
|
irregexpFunction,
|
|
staticInitializer,
|
|
methodExtractor,
|
|
noSuchMethodDispatcher,
|
|
invokeFieldDispatcher,
|
|
collected,
|
|
native,
|
|
stub,
|
|
tag,
|
|
signatureFunction,
|
|
dynamicInvocationForwarder
|
|
}
|
|
|
|
bool isSyntheticFunction(FunctionKind kind) {
|
|
switch (kind) {
|
|
case FunctionKind.collected:
|
|
case FunctionKind.native:
|
|
case FunctionKind.stub:
|
|
case FunctionKind.tag:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool isDartFunction(FunctionKind kind) => !isSyntheticFunction(kind);
|
|
bool isStubFunction(FunctionKind kind) => kind == FunctionKind.stub;
|
|
bool hasDartCode(FunctionKind kind) =>
|
|
isDartFunction(kind) || isStubFunction(kind);
|
|
|
|
String getFunctionFullName(FunctionRef function) {
|
|
var content = <String>[function.name];
|
|
ObjectRef owner = function.dartOwner;
|
|
while (owner is FunctionRef) {
|
|
FunctionRef function = (owner as FunctionRef);
|
|
content.add(function.name);
|
|
owner = function.dartOwner;
|
|
}
|
|
if (owner is ClassRef) {
|
|
content.add(owner.name);
|
|
}
|
|
return content.reversed.join('.');
|
|
}
|
|
|
|
abstract class FunctionRef extends ObjectRef {
|
|
/// The name of this class.
|
|
String get name;
|
|
|
|
/// The owner of this function, which can be a LibraryRef, ClassRef,
|
|
/// or a FunctionRef.
|
|
ObjectRef get dartOwner; // owner
|
|
|
|
/// Is this function static?
|
|
bool get isStatic;
|
|
|
|
/// Is this function const?
|
|
bool get isConst;
|
|
|
|
/// The kind of the function.
|
|
FunctionKind get kind;
|
|
}
|
|
|
|
abstract class ServiceFunction extends Object implements FunctionRef {
|
|
/// The location of this function in the source code. [optional]
|
|
SourceLocation get location;
|
|
|
|
/// The compiled code associated with this function. [optional]
|
|
CodeRef get code;
|
|
|
|
/// [optional]
|
|
CodeRef get unoptimizedCode;
|
|
|
|
/// [optional]
|
|
FieldRef get field;
|
|
int get usageCounter;
|
|
InstanceRef get icDataArray;
|
|
int get deoptimizations;
|
|
bool get isOptimizable;
|
|
bool get isInlinable;
|
|
bool get hasIntrinsic;
|
|
bool get isRecognized;
|
|
bool get isNative;
|
|
}
|