[dart2js] Share late-check name strings

0.925% reduction in specific Dart Angular app.

Change-Id: Ic4828a3175775060397a8f9cb513b18f175f5c6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242424
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/pkg/compiler/lib/src/ssa/codegen_helpers.dart b/pkg/compiler/lib/src/ssa/codegen_helpers.dart
index ca162ab..3600c44 100644
--- a/pkg/compiler/lib/src/ssa/codegen_helpers.dart
+++ b/pkg/compiler/lib/src/ssa/codegen_helpers.dart
@@ -787,6 +787,10 @@
     // at use in the check.
     if (instruction.usedBy.isEmpty) {
       visitInstruction(instruction);
+    } else {
+      // The name argument can be generated at use. If present, it is either a
+      // string constant or a reference to a string.
+      analyzeInputs(instruction, 1);
     }
   }
 
@@ -1280,6 +1284,8 @@
       // TODO(sra): Check if a.x="s" can avoid or specialize a write barrier.
       if (instruction is HFieldSet) return true;
 
+      if (instruction is HLateCheck) return true;
+
       // TODO(sra): Determine if other uses result in faster JavaScript code.
       return false;
     }
diff --git a/pkg/compiler/lib/src/ssa/nodes.dart b/pkg/compiler/lib/src/ssa/nodes.dart
index 36f104e..72dff8e 100644
--- a/pkg/compiler/lib/src/ssa/nodes.dart
+++ b/pkg/compiler/lib/src/ssa/nodes.dart
@@ -3701,12 +3701,15 @@
 /// A check for a late sentinel to determine if a late field may be read from or
 /// written to.
 abstract class HLateCheck extends HCheck {
-  final HInstruction name;
-
-  HLateCheck(HInstruction input, this.name, AbstractValue type)
+  HLateCheck(HInstruction input, HInstruction /*?*/ name, AbstractValue type)
       : super([input, if (name != null) name], type);
 
-  bool get hasName => name != null;
+  bool get hasName => inputs.length > 1;
+
+  HInstruction get name {
+    if (hasName) return inputs[1];
+    throw StateError('HLateCheck.name: no name');
+  }
 
   @override
   bool isControlFlow() => true;