[dart2js] rename setRuntimeTypeInfo to _setArrayType

For a long time now this is used only to put types on JSArray.

Change-Id: I31f15d313d7e131eecac76697a8938c197f83e7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195940
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
Stephen Adams
2021-04-22 02:06:31 +00:00
committed by commit-bot@chromium.org
parent 2d632d0eac
commit b529afd10a
20 changed files with 118 additions and 116 deletions
+4 -4
View File
@@ -455,7 +455,7 @@ abstract class CommonElements {
// From dart:_rti
FunctionEntity get setRuntimeTypeInfo;
FunctionEntity get setArrayType;
FunctionEntity get findType;
FunctionEntity get instanceType;
@@ -1848,10 +1848,10 @@ class CommonElementsImpl
FunctionEntity _findRtiFunction(String name) =>
_findLibraryMember(rtiLibrary, name);
FunctionEntity _setRuntimeTypeInfo;
FunctionEntity _setArrayType;
@override
FunctionEntity get setRuntimeTypeInfo =>
_setRuntimeTypeInfo ??= _findRtiFunction('setRuntimeTypeInfo');
FunctionEntity get setArrayType =>
_setArrayType ??= _findRtiFunction('_setArrayType');
FunctionEntity _findType;
@override
@@ -108,7 +108,7 @@ class BackendImpacts {
BackendImpact get computeSignature {
return _computeSignature ??= new BackendImpact(globalUses: [
_commonElements.setRuntimeTypeInfo,
_commonElements.setArrayType,
], otherImpacts: [
listValues
]);
@@ -443,7 +443,7 @@ class BackendImpacts {
BackendImpact get typeVariableExpression {
return _typeVariableExpression ??= new BackendImpact(staticUses: [
_commonElements.setRuntimeTypeInfo,
_commonElements.setArrayType,
_commonElements.createRuntimeType
], otherImpacts: [
listValues,
@@ -464,7 +464,7 @@ class BackendImpacts {
BackendImpact get genericTypeCheck {
return _genericTypeCheck ??= new BackendImpact(staticUses: [
// TODO(johnniwinther): Investigate why this is needed.
_commonElements.setRuntimeTypeInfo,
_commonElements.setArrayType,
], otherImpacts: [
listValues,
getRuntimeTypeArgument,
@@ -654,7 +654,7 @@ class BackendImpacts {
// Literal lists can be translated into calls to these functions:
globalUses: [
_commonElements.jsArrayTypedConstructor,
_commonElements.setRuntimeTypeInfo,
_commonElements.setArrayType,
]);
}
@@ -688,7 +688,7 @@ class BackendImpacts {
return _runtimeTypeSupport ??= new BackendImpact(globalClasses: [
_commonElements.listClass
], globalUses: [
_commonElements.setRuntimeTypeInfo,
_commonElements.setArrayType,
], otherImpacts: [
getRuntimeTypeArgument,
computeSignature
@@ -202,7 +202,7 @@ class CodegenEnqueuerListener extends EnqueuerListener {
if (type is InterfaceType) {
impactBuilder.registerTypeUse(new TypeUse.instantiation(type));
if (_rtiNeed.classNeedsTypeArguments(type.element)) {
FunctionEntity helper = _commonElements.setRuntimeTypeInfo;
FunctionEntity helper = _commonElements.setArrayType;
impactBuilder.registerStaticUse(new StaticUse.staticInvoke(
helper, helper.parameterStructure.callStructure));
}
@@ -437,8 +437,7 @@ class ConstantEmitter extends ModularConstantEmitter {
ConstantValue constant, InterfaceType type, jsAst.Expression value) {
assert(type.element == _commonElements.jsArrayClass);
if (_rtiNeed.classNeedsTypeArguments(type.element)) {
return new jsAst.Call(
getHelperProperty(_commonElements.setRuntimeTypeInfo),
return new jsAst.Call(getHelperProperty(_commonElements.setArrayType),
[value, _reifiedTypeNewRti(type)]);
}
return value;
@@ -178,7 +178,7 @@ class MinifyNamer extends Namer
r'JSArray',
r'createInvocationMirror',
r'String',
r'setRuntimeTypeInfo',
r'setArrayType',
r'createRuntimeType'
]);
}
@@ -389,8 +389,11 @@ abstract class _MinifiedOneShotInterceptorNamer implements Namer {
String root = selector.isOperator
? operatorNameToIdentifier(selector.name)
: privateName(selector.memberName);
String prefix =
selector.isGetter ? r"$get" : selector.isSetter ? r"$set" : "";
String prefix = selector.isGetter
? r"$get"
: selector.isSetter
? r"$set"
: "";
String callSuffix = selector.isCall
? Namer.callSuffixForStructure(selector.callStructure).join()
: "";
+2 -2
View File
@@ -2200,14 +2200,14 @@ class KernelSsaGraphBuilder extends ir.Visitor<void> with ir.VisitorVoidMixin {
HInstruction _callSetRuntimeTypeInfo(HInstruction typeInfo,
HInstruction newObject, SourceInformation sourceInformation) {
// Set the runtime type information on the object.
FunctionEntity typeInfoSetterFn = _commonElements.setRuntimeTypeInfo;
FunctionEntity typeInfoSetterFn = _commonElements.setArrayType;
// TODO(efortuna): Insert source information in this static invocation.
_pushStaticInvocation(typeInfoSetterFn, <HInstruction>[newObject, typeInfo],
_abstractValueDomain.dynamicType, const <DartType>[],
sourceInformation: sourceInformation);
// The new object will now be referenced through the
// `setRuntimeTypeInfo` call. We therefore set the type of that
// `setArrayType` call. We therefore set the type of that
// instruction to be of the object's type.
assert(
stack.last is HInvokeStatic || stack.last == newObject,
+7 -7
View File
@@ -721,7 +721,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
// t1 = s.split(pattern);
// t2 = String;
// t3 = JSArray<t2>;
// t4 = setRuntimeTypeInfo(t1, t3);
// t4 = setArrayType(t1, t3);
//
AbstractValue resultMask = _abstractValueDomain.growableListType;
@@ -751,7 +751,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
node.block.addBefore(node, typeInfo);
HInvokeStatic tagInstruction = new HInvokeStatic(
commonElements.setRuntimeTypeInfo,
commonElements.setArrayType,
<HInstruction>[splitInstruction, typeInfo],
resultMask,
const <DartType>[]);
@@ -1368,8 +1368,8 @@ class SsaInstructionSimplifier extends HBaseVisitor
// Can we find the length as an input to an allocation?
HInstruction potentialAllocation = receiver;
if (receiver is HInvokeStatic &&
receiver.element == commonElements.setRuntimeTypeInfo) {
// Look through `setRuntimeTypeInfo(new Array(), ...)`
receiver.element == commonElements.setArrayType) {
// Look through `setArrayType(new Array(), ...)`
potentialAllocation = receiver.inputs.first;
}
if (_graph.allocatedFixedLists.contains(potentialAllocation)) {
@@ -1619,7 +1619,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
node.inputs[0], node.inputs[1], _abstractValueDomain.boolType)
..sourceInformation = node.sourceInformation;
}
} else if (element == commonElements.setRuntimeTypeInfo) {
} else if (element == commonElements.setArrayType) {
if (node.inputs.length == 2) {
return handleArrayTypeInfo(node);
}
@@ -2066,7 +2066,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
}
if (instance is HInvokeStatic &&
instance.element == commonElements.setRuntimeTypeInfo) {
instance.element == commonElements.setArrayType) {
// TODO(sra): What is the 'instantiated type' we should be registering as
// discussed above? Perhaps it should be carried on HLiteralList.
return instance.inputs.last;
@@ -3527,7 +3527,7 @@ class SsaLoadElimination extends HBaseVisitor implements OptimizationPhase {
// have it escape or store it into an object that escapes.
return false;
// TODO(sra): Handle library functions that we know do not modify or
// leak the inputs. For example `setRuntimeTypeInfo` is used to mark
// leak the inputs. For example `setArrayType` is used to mark
// list literals with type information.
}
if (use is HPhi) {
@@ -7,7 +7,7 @@
// TODO(sra): Lower when type of input does not need a generic covariant check.
@pragma('dart2js:noInline')
/*spec.member: test1:function() {
var t1 = H.setRuntimeTypeInfo([], type$.JSArray_int);
var t1 = H._setArrayType([], type$.JSArray_int);
C.JSArray_methods.add$1(t1, 1);
return t1;
}*/
+12 -12
View File
@@ -72,8 +72,8 @@ testAsyncStar() async* {}
_IterationMarker.uncaughtError(1),
_IterationMarker.yieldStar(1),
_makeSyncStarIterable<Null>(1),
def:local,
setRuntimeTypeInfo(2)],
_setArrayType(2),
def:local],
type=[
inst:Function,
inst:JSArray<dynamic>,
@@ -95,9 +95,9 @@ testLocalSyncStar() {
_asyncReturn(2),
_asyncStartSync(2),
_makeAsyncAwaitCompleter<Null>(0),
_setArrayType(2),
_wrapJsFunctionForAsync(1),
def:local,
setRuntimeTypeInfo(2)],
def:local],
type=[
inst:Function,
inst:JSArray<dynamic>,
@@ -118,10 +118,10 @@ testLocalAsync() {
_IterationMarker.yieldStar(1),
_asyncStarHelper(3),
_makeAsyncStarStreamController<Null>(1),
_setArrayType(2),
_streamOfController(1),
_wrapJsFunctionForAsync(1),
def:local,
setRuntimeTypeInfo(2)],
def:local],
type=[
inst:Function,
inst:JSArray<dynamic>,
@@ -141,8 +141,8 @@ testLocalAsyncStar() {
_IterationMarker.uncaughtError(1),
_IterationMarker.yieldStar(1),
_makeSyncStarIterable<Null>(1),
def:<anonymous>,
setRuntimeTypeInfo(2)],
_setArrayType(2),
def:<anonymous>],
type=[
inst:Function,
inst:JSArray<dynamic>,
@@ -163,9 +163,9 @@ testAnonymousSyncStar() {
_asyncReturn(2),
_asyncStartSync(2),
_makeAsyncAwaitCompleter<Null>(0),
_setArrayType(2),
_wrapJsFunctionForAsync(1),
def:<anonymous>,
setRuntimeTypeInfo(2)],
def:<anonymous>],
type=[
inst:Function,
inst:JSArray<dynamic>,
@@ -185,10 +185,10 @@ testAnonymousAsync() {
_IterationMarker.yieldStar(1),
_asyncStarHelper(3),
_makeAsyncStarStreamController<Null>(1),
_setArrayType(2),
_streamOfController(1),
_wrapJsFunctionForAsync(1),
def:<anonymous>,
setRuntimeTypeInfo(2)],
def:<anonymous>],
type=[
inst:Function,
inst:JSArray<dynamic>,
+6 -6
View File
@@ -231,9 +231,9 @@ class ForwardingConstructorGenericSuperClass<T> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -313,9 +313,9 @@ testEnum() => Enum.A;
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -419,9 +419,9 @@ class GenericClass<X, Y> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -79,9 +79,9 @@ const typeLiteralField = String;
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -253,9 +253,9 @@ testAs(dynamic o) => o as Class;
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
as:GenericClass<int*,String*>*,
inst:Closure,
@@ -50,10 +50,10 @@ class C implements A<int>, B<String, bool> {}
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
extractTypeArguments<A<dynamic>*>(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
impl:A<dynamic>*,
impl:Function,
@@ -104,10 +104,10 @@ testA(c, f) => extractTypeArguments<A>(c, f);
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
extractTypeArguments<B<dynamic,dynamic>*>(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
impl:B<dynamic,dynamic>*,
impl:Function,
@@ -343,9 +343,9 @@ class ClassGeneric<T> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -148,9 +148,9 @@ class Class2<T> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -201,9 +201,9 @@ class Class2<T> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
impl:A*,
inst:Closure,
@@ -459,9 +459,9 @@ class Class5<T1, T2> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -517,9 +517,9 @@ class Class5<T1, T2> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
impl:A*,
impl:D*,
@@ -577,9 +577,9 @@ class Class6<T1, T2> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -635,9 +635,9 @@ class Class6<T1, T2> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
impl:A*,
impl:D*,
@@ -752,9 +752,9 @@ class F<T> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -803,9 +803,9 @@ class F<T> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -859,9 +859,9 @@ class G extends F<int> {}
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
impl:List<int*>*,
inst:Closure,
+24 -24
View File
@@ -243,9 +243,9 @@ int topLevelFunction2Typed(String a, [num b, double c]) => null;
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -334,9 +334,9 @@ testTopLevelInvokeTyped() {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -384,9 +384,9 @@ topLevelFunctionTyped1(void a(num b)) {}
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -434,9 +434,9 @@ topLevelFunctionTyped2(void a(num b, [String c])) {}
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -484,9 +484,9 @@ topLevelFunctionTyped3(void a(num b, {String c, int d})) {}
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -796,9 +796,9 @@ testTopLevelFieldGeneric2() => topLevelFieldGeneric2;
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -912,8 +912,8 @@ testLocalWithInitializerTyped() {
/*member: testLocalFunction:
static=[
def:localFunction,
setRuntimeTypeInfo(2)],
_setArrayType(2),
def:localFunction],
type=[
inst:Function,
inst:JSArray<dynamic>,
@@ -962,10 +962,10 @@ testLocalFunction() {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
def:localFunction,
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:Function,
@@ -986,9 +986,9 @@ testLocalFunctionTyped() {
/*member: testLocalFunctionInvoke:
dynamic=[call(0)],
static=[
_setArrayType(2),
def:localFunction,
localFunction(0),
setRuntimeTypeInfo(2)],
localFunction(0)],
type=[
inst:Function,
inst:JSArray<dynamic>,
@@ -1004,8 +1004,8 @@ testLocalFunctionInvoke() {
/*member: testLocalFunctionGet:
static=[
def:localFunction,
setRuntimeTypeInfo(2)],
_setArrayType(2),
def:localFunction],
type=[
inst:Function,
inst:JSArray<dynamic>,
@@ -1021,8 +1021,8 @@ testLocalFunctionGet() {
/*member: testClosure:
static=[
def:<anonymous>,
setRuntimeTypeInfo(2)],
_setArrayType(2),
def:<anonymous>],
type=[
inst:Function,
inst:JSArray<dynamic>,
@@ -1038,8 +1038,8 @@ testClosure() {
/*member: testClosureInvoke:
dynamic=[call(0)],
static=[
def:<anonymous>,
setRuntimeTypeInfo(2)],
_setArrayType(2),
def:<anonymous>],
type=[
inst:Function,
inst:JSArray<dynamic>,
+2 -2
View File
@@ -96,9 +96,9 @@ class GenericClass<T> {
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -46,9 +46,9 @@ import 'package:js/js.dart';
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
+16 -16
View File
@@ -114,9 +114,9 @@ class Class4 {}
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -170,9 +170,9 @@ toString1(Class2<int> c) => '${c.runtimeType}';
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -226,9 +226,9 @@ toString2(Class2<int> c) => '${c?.runtimeType}';
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -280,9 +280,9 @@ toString3(Class2<int> c) => c.runtimeType.toString();
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -335,9 +335,9 @@ toString4(Class2<int> c) => c.runtimeType?.toString();
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -390,9 +390,9 @@ toString5(Class2<int> c) => c?.runtimeType?.toString();
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -443,9 +443,9 @@ toString6(Class2<int> c) => c?.runtimeType.toString();
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
@@ -498,9 +498,9 @@ unknown(Class2<int> c) => c.runtimeType;
_isObject(1),
_isString(1),
_isTop(1),
_setArrayType(2),
findType(1),
instanceType(1),
setRuntimeTypeInfo(2)],
instanceType(1)],
type=[
inst:Closure,
inst:JSArray<dynamic>,
+1 -1
View File
@@ -626,7 +626,7 @@ bool _isClosure(Object? object) => _Utils.instanceOf(object,
// Don't inline. Let the JS engine inline this. The call expression is much
// more compact that the inlined expansion.
@pragma('dart2js:noInline')
Object? setRuntimeTypeInfo(Object? target, Object? rti) {
Object? _setArrayType(Object? target, Object? rti) {
assert(rti != null);
var rtiProperty = JS_EMBEDDED_GLOBAL('', ARRAY_RTI_PROPERTY);
JS('var', r'#[#] = #', target, rtiProperty, rti);