[dart2js] Moving entity map to kernel dump info annotator
Change-Id: I1aa5167759e1cdb1bdfbea76062df8fcafb8a67a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250022
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart
index 8dfbda7..8459ff0 100644
--- a/pkg/compiler/lib/src/dump_info.dart
+++ b/pkg/compiler/lib/src/dump_info.dart
@@ -435,9 +435,7 @@
if (libname == null || libname.isEmpty) {
libname = '${lib.importUri}';
}
-
LibraryInfo info = LibraryInfo(libname, lib.importUri, null, null);
- state.entityToInfo[libEntity] = info;
lib.members.forEach((ir.Member member) {
final memberEntity =
@@ -486,7 +484,6 @@
type: field.type.toStringInternal(),
isConst: field.isConst,
);
- state.entityToInfo[fieldEntity] = info;
if (compiler.options.experimentCallInstrumentation) {
// We use field.hashCode because it is globally unique and it is
@@ -511,7 +508,6 @@
// Omit class if it is not needed.
ClassInfo classInfo = ClassInfo(
name: clazz.name, isAbstract: clazz.isAbstract, outputUnit: null);
- state.entityToInfo[classEntity] = classInfo;
clazz.members.forEach((ir.Member member) {
final isSetter = member is ir.Procedure && member.isSetter;
@@ -521,19 +517,18 @@
setter: isSetter) ??
environment.lookupConstructor(classEntity, member.name.text);
if (memberEntity == null) return;
- // Multiple kernel members can map to single JWorld member
- // (e.g., when one of a getter/field pair are tree-shaken),
- // so avoid duplicating the downstream info object.
- if (state.entityToInfo.containsKey(memberEntity)) {
- return;
- }
if (member.function != null) {
- FunctionInfo functionInfo =
- visitFunction(member.function, functionEntity: memberEntity);
- if (functionInfo != null) {
- classInfo.functions.add(functionInfo);
- functionInfo.parent = classInfo;
+ // Multiple kernel members can map to single JWorld member
+ // (e.g., when one of a getter/field pair are tree-shaken),
+ // so avoid duplicating the downstream info object.
+ if (memberEntity is FunctionEntity) {
+ FunctionInfo functionInfo =
+ visitFunction(member.function, functionEntity: memberEntity);
+ if (functionInfo != null) {
+ classInfo.functions.add(functionInfo);
+ functionInfo.parent = classInfo;
+ }
}
} else {
FieldInfo fieldInfo = visitField(member, fieldEntity: memberEntity);
@@ -608,7 +603,6 @@
modifiers: modifiers,
returnType: function.returnType.toStringInternal(),
type: functionType.toStringInternal());
- state.entityToInfo[functionEntity] = info;
if (function.parent is ir.Member)
_addClosureInfo(info, function.parent,
@@ -646,13 +640,11 @@
});
final closureClassEntity = closureEntity.enclosingClass;
final closureInfo = ClosureInfo.fromKernel(name: value.disambiguatedName);
- state.entityToInfo[closureClassEntity] = closureInfo;
FunctionEntity callMethod = closedWorld.elementEnvironment
.lookupClassMember(closureClassEntity, Identifiers.call);
final functionInfo = visitFunction(key.function,
functionEntity: callMethod, localFunctionInfo: value);
- state.entityToInfo[closureEntity] = functionInfo;
closureInfo.function = functionInfo;
functionInfo.parent = closureInfo;
@@ -740,6 +732,7 @@
'Ambiguous library resolution. '
'Expected singleton, found $kLibraryInfos');
var kLibraryInfo = kLibraryInfos.first;
+ kernelInfo.state.entityToInfo[lib] = kLibraryInfo;
String libname = environment.getLibraryName(lib);
if (libname.isEmpty) {
@@ -802,6 +795,7 @@
'Ambiguous field resolution. '
'Expected singleton, found $kFieldInfos');
final kFieldInfo = kFieldInfos.first;
+ kernelInfo.state.entityToInfo[field] = kFieldInfo;
int size = dumpInfoTask.sizeOf(field);
List<CodeSpan> code = dumpInfoTask.codeOf(field);
@@ -863,6 +857,7 @@
'Ambiguous class resolution. '
'Expected singleton, found $kClassInfos');
final kClassInfo = kClassInfos.first;
+ kernelInfo.state.entityToInfo[clazz] = kClassInfo;
int size = dumpInfoTask.sizeOf(clazz);
final disambiguatedMemberName = '$parentName/${clazz.name}';
@@ -923,6 +918,7 @@
'Ambiguous closure resolution. '
'Expected singleton, found $kClosureInfos');
final kClosureInfo = kClosureInfos.first;
+ kernelInfo.state.entityToInfo[element] = kClosureInfo;
kClosureInfo.outputUnit = _unitInfoForClass(element);
kClosureInfo.size = dumpInfoTask.sizeOf(element);
@@ -968,6 +964,7 @@
'Expected single or none, found $kFunctionInfos');
if (kFunctionInfos.length == 0) return null;
final kFunctionInfo = kFunctionInfos.first;
+ kernelInfo.state.entityToInfo[function] = kFunctionInfo;
List<CodeSpan> code = dumpInfoTask.codeOf(function);
List<ParameterInfo> parameters = <ParameterInfo>[];