[vm/compiler] Fix size regression with symbolic stack traces enabled.

TEST=Manually checked via Golem.

Change-Id: I4986d99afd9dbcc5f63292baa89ec9053b0f37a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190524
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index abb8ad0..0753c3e 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -702,7 +702,8 @@
         Array::Handle(Z, code.inlined_id_to_function());
     for (intptr_t i = 0; i < inlined_functions.Length(); i++) {
       target ^= inlined_functions.At(i);
-      AddFunction(target, RetainReasons::kSymbolicStackTraces);
+      AddRetainReason(target, RetainReasons::kSymbolicStackTraces);
+      AddTypesOf(target);
     }
   }
 }
@@ -775,7 +776,7 @@
 }
 
 void Precompiler::AddRetainReason(const Object& obj, const char* reason) {
-  if (!FLAG_trace_precompiler) return;
+  if (!FLAG_trace_precompiler || reason == nullptr) return;
   if (auto const kv = retained_reasons_map_->Lookup(&obj)) {
     if (kv->value->Lookup(reason) == nullptr) {
       kv->value->Insert(reason);
@@ -1100,9 +1101,9 @@
   if (retain_reason == nullptr) {
     retain_reason = MustRetainFunction(function);
   }
-  if (retain_reason != nullptr) {
-    AddRetainReason(function, retain_reason);
-  }
+  // Add even if we've already marked this function as possibly retained
+  // because this could be an additional reason for doing so.
+  AddRetainReason(function, retain_reason);
 
   if (possibly_retained_functions_.ContainsKey(function)) return;
   if (retain_reason != nullptr) {