[pkg/vm_snapshot_analysis] Don't assume Code objects have an owner.

For regular stubs, the owner will be null.

Issue: https://github.com/flutter/flutter/issues/130009
Change-Id: I8c85e3130128af79c596f381869d61631221cf9e
Cq-Include-Trybots: luci.dart.try:pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-linux-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312660
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
This commit is contained in:
Tess Strickland 2023-07-07 09:52:50 +00:00 committed by Commit Queue
parent 82577191ec
commit 1133598168
3 changed files with 10 additions and 5 deletions

View file

@ -1,5 +1,10 @@
# Changelog
## 0.7.5
- Fix for flutter/flutter#130009 where an attempt to lookup the owner info
node for type testing stubs would cause a null check error.
## 0.7.4
- Fix for flutter/flutter#128402 where an attempt to lookup the owner info

View file

@ -413,16 +413,16 @@ class _ProgramInfoBuilder {
ProgramInfoNode? createInfoNodeFor(Node node) {
switch (node.type) {
case 'Code':
final owner = node['owner_']!;
if (owner.type == 'Function') {
final owner = node['owner_']; // Stubs may have no owner.
if (owner?.type == 'Function') {
// For normal functions we just attribute Code object and all
// objects dominated by it to the function itself.
return getInfoNodeFor(owner)!;
return getInfoNodeFor(owner!)!;
}
// For all stub types, we create a dummy functionNode that is going to
// own all objects dominated by it.
final ownerNode =
owner.type == 'Class' ? getInfoNodeFor(owner)! : program.stubs;
owner?.type == 'Class' ? getInfoNodeFor(owner!)! : program.stubs;
return makeInfoNode(node.index,
name: node.name, parent: ownerNode, type: NodeType.functionNode);

View file

@ -1,5 +1,5 @@
name: vm_snapshot_analysis
version: 0.7.4
version: 0.7.5
description: Utilities for analysing AOT snapshot size.
repository: https://github.com/dart-lang/sdk/tree/main/pkg/vm_snapshot_analysis