Revert "[dart2js] drop unnecessary modular data (2): non foreign..."

Revert submission 300800

Reason for revert: broke bots. CQ didn't retrigger when second change int he chain was updated.

Reverted changes: /q/submissionid:300800

Change-Id: Iee3ef0e1e85a89708337a48c6a5a34a2f5114147
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300901
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
diff --git a/pkg/compiler/lib/src/ir/impact.dart b/pkg/compiler/lib/src/ir/impact.dart
index af9800e..68cf9f1 100644
--- a/pkg/compiler/lib/src/ir/impact.dart
+++ b/pkg/compiler/lib/src/ir/impact.dart
@@ -186,7 +186,7 @@
   void registerConstructorNode(ir.Constructor node);
   void registerFieldNode(ir.Field node);
   void registerProcedureNode(ir.Procedure node);
-  void registerForeignStaticInvocationNode(ir.StaticInvocation node);
+  void registerStaticInvocationNode(ir.StaticInvocation node);
   void registerSwitchStatementNode(ir.SwitchStatement node);
   void registerConstSymbolConstructorInvocationNode();
 }
diff --git a/pkg/compiler/lib/src/ir/impact_data.dart b/pkg/compiler/lib/src/ir/impact_data.dart
index 8d85549..271e301 100644
--- a/pkg/compiler/lib/src/ir/impact_data.dart
+++ b/pkg/compiler/lib/src/ir/impact_data.dart
@@ -8,7 +8,6 @@
 
 import '../common.dart';
 import '../common/elements.dart';
-import '../common/names.dart' show Identifiers, Uris;
 import '../elements/entities.dart';
 import '../elements/types.dart';
 import '../ir/scope.dart';
@@ -418,16 +417,7 @@
       registerStaticInvocation(node.target, positionArguments, namedArguments,
           typeArguments, getDeferredImport(node));
     }
-    // TODO(sigmund): consider using `_elementMap.getForeignKind` here. We
-    // currently don't use it because when this step is run modularly we try
-    // to keep most operations at the kernel level, otherwise it may triggers
-    // additional unnecessary work.
-    final name = node.target.name.text;
-    if (node.target.enclosingClass == null &&
-        node.target.enclosingLibrary.importUri == Uris.dart__foreign_helper &&
-        getForeignKindFromName(name) != ForeignKind.NONE) {
-      registerForeignStaticInvocationNode(node);
-    }
+    registerStaticInvocationNode(node);
   }
 
   @override
@@ -1001,8 +991,8 @@
   }
 
   @override
-  void registerForeignStaticInvocationNode(ir.StaticInvocation node) {
-    (_data._foreignStaticInvocationNodes ??= []).add(node);
+  void registerStaticInvocationNode(ir.StaticInvocation node) {
+    (_data._staticInvocationNodes ??= []).add(node);
   }
 
   @override
@@ -1062,7 +1052,7 @@
   List<ir.Field>? _fieldNodes;
   List<ir.Procedure>? _procedureNodes;
   List<ir.SwitchStatement>? _switchStatementNodes;
-  List<ir.StaticInvocation>? _foreignStaticInvocationNodes;
+  List<ir.StaticInvocation>? _staticInvocationNodes;
   bool _hasConstSymbolConstructorInvocation = false;
 
   ImpactData();
@@ -1132,8 +1122,7 @@
     _fieldNodes = source.readMemberNodesOrNull<ir.Field>();
     _procedureNodes = source.readMemberNodesOrNull<ir.Procedure>();
     _switchStatementNodes = source.readTreeNodesOrNull<ir.SwitchStatement>();
-    _foreignStaticInvocationNodes =
-        source.readTreeNodesOrNull<ir.StaticInvocation>();
+    _staticInvocationNodes = source.readTreeNodesOrNull<ir.StaticInvocation>();
     _hasConstSymbolConstructorInvocation = source.readBool();
     source.end(tag);
   }
@@ -1215,7 +1204,7 @@
     sink.writeMemberNodes(_fieldNodes, allowNull: true);
     sink.writeMemberNodes(_procedureNodes, allowNull: true);
     sink.writeTreeNodes(_switchStatementNodes, allowNull: true);
-    sink.writeTreeNodes(_foreignStaticInvocationNodes, allowNull: true);
+    sink.writeTreeNodes(_staticInvocationNodes, allowNull: true);
     sink.writeBool(_hasConstSymbolConstructorInvocation);
 
     sink.end(tag);
@@ -1548,9 +1537,9 @@
         registry.registerSwitchStatementNode(data);
       }
     }
-    if (_foreignStaticInvocationNodes != null) {
-      for (ir.StaticInvocation data in _foreignStaticInvocationNodes!) {
-        registry.registerForeignStaticInvocationNode(data);
+    if (_staticInvocationNodes != null) {
+      for (ir.StaticInvocation data in _staticInvocationNodes!) {
+        registry.registerStaticInvocationNode(data);
       }
     }
     if (_hasConstSymbolConstructorInvocation) {
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index 7a530e4..83296c1 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart
@@ -1606,9 +1606,19 @@
   }
 
   /// Compute the kind of foreign helper function called by [node], if any.
+
   ForeignKind getForeignKind(ir.StaticInvocation node) {
     if (commonElements.isForeignHelper(getMember(node.target))) {
-      return getForeignKindFromName(node.target.name.text);
+      switch (node.target.name.text) {
+        case Identifiers.JS:
+          return ForeignKind.JS;
+        case Identifiers.JS_BUILTIN:
+          return ForeignKind.JS_BUILTIN;
+        case Identifiers.JS_EMBEDDED_GLOBAL:
+          return ForeignKind.JS_EMBEDDED_GLOBAL;
+        case Identifiers.JS_INTERCEPTOR_CONSTANT:
+          return ForeignKind.JS_INTERCEPTOR_CONSTANT;
+      }
     }
     return ForeignKind.NONE;
   }
@@ -2199,18 +2209,3 @@
   }
   reporter.reportError(diagnosticMessage, infos);
 }
-
-ForeignKind getForeignKindFromName(String name) {
-  switch (name) {
-    case Identifiers.JS:
-      return ForeignKind.JS;
-    case Identifiers.JS_BUILTIN:
-      return ForeignKind.JS_BUILTIN;
-    case Identifiers.JS_EMBEDDED_GLOBAL:
-      return ForeignKind.JS_EMBEDDED_GLOBAL;
-    case Identifiers.JS_INTERCEPTOR_CONSTANT:
-      return ForeignKind.JS_INTERCEPTOR_CONSTANT;
-    default:
-      return ForeignKind.NONE;
-  }
-}
diff --git a/pkg/compiler/lib/src/kernel/kernel_impact.dart b/pkg/compiler/lib/src/kernel/kernel_impact.dart
index 194434c..3b8541f 100644
--- a/pkg/compiler/lib/src/kernel/kernel_impact.dart
+++ b/pkg/compiler/lib/src/kernel/kernel_impact.dart
@@ -402,7 +402,7 @@
   }
 
   @override
-  void registerForeignStaticInvocationNode(ir.StaticInvocation node) {
+  void registerStaticInvocationNode(ir.StaticInvocation node) {
     switch (elementMap.getForeignKind(node)) {
       case ForeignKind.JS:
         registerNativeImpact(elementMap.getNativeBehaviorForJsCall(node));