[vm, compiler] Fix CanTriggerGC for LoadFieldInstr and LoadCodeUnitsInstr.

TEST=ci
Change-Id: I233802bfcd24b024e82e370b6d5b8baf44042476
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252781
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc
index bc4ebde..e7f9172 100644
--- a/runtime/vm/compiler/backend/il.cc
+++ b/runtime/vm/compiler/backend/il.cc
@@ -5722,6 +5722,7 @@
     __ TryAllocate(cls, compiler->intrinsic_slow_path_label(),
                    compiler::Assembler::kFarJump, result, temp);
   } else {
+    RELEASE_ASSERT(instruction->CanTriggerGC());
     auto slow_path = new BoxAllocationSlowPath(instruction, cls, result);
     compiler->AddSlowPathCode(slow_path);
 
diff --git a/runtime/vm/compiler/backend/il.h b/runtime/vm/compiler/backend/il.h
index 2aa863f..af9f8b1 100644
--- a/runtime/vm/compiler/backend/il.h
+++ b/runtime/vm/compiler/backend/il.h
@@ -445,7 +445,7 @@
   M(DebugStepCheck, _)                                                         \
   M(RecordCoverage, kNoGC)                                                     \
   M(LoadIndexed, kNoGC)                                                        \
-  M(LoadCodeUnits, kNoGC)                                                      \
+  M(LoadCodeUnits, _)                                                          \
   M(StoreIndexed, kNoGC)                                                       \
   M(StoreField, _)                                                             \
   M(LoadStaticField, _)                                                        \
@@ -5989,6 +5989,10 @@
 
   virtual bool HasUnknownSideEffects() const { return false; }
 
+  virtual bool CanTriggerGC() const {
+    return !can_pack_into_smi() && (representation() == kTagged);
+  }
+
  private:
   const intptr_t class_id_;
   const TokenPosition token_pos_;
@@ -6869,6 +6873,10 @@
 
   virtual bool AllowsCSE() const { return slot_.is_immutable(); }
 
+  virtual bool CanTriggerGC() const {
+    return calls_initializer() || IsPotentialUnboxedDartFieldLoad();
+  }
+
   virtual bool AttributesEqual(const Instruction& other) const;
 
   PRINT_OPERANDS_TO_SUPPORT